Chris Browne cbbrowne at lists.slony.info
Wed Apr 18 08:03:53 PDT 2007
Update of /home/cvsd/slony1/slony1-engine/src/slonik
In directory main.slony.info:/tmp/cvs-serv3274/src/slonik

Modified Files:
	dbutil.c parser.y scan.l slonik.c slonik.h 
Log Message:
Patch that removes TABLE ADD KEY from CVS HEAD.  This supercedes the
previous patch:

http://lists.slony.info/pipermail/slony1-patches/2007-April/000008.html

Per Bill Moran's comments, this also drops out usage of sl_rowid_seq.
http://lists.slony.info/pipermail/slony1-general/2007-April/005883.html

It passes test1, as revised in the patch (e.g. - to remove usage of
TABLE ADD KEY)...

----------------------------------------------------
creating origin DB: cbbrowne -h localhost -U cbbrowne -p 5882 slonyregress1
add plpgsql to Origin
loading origin DB with test1/init_schema.sql
setting up user cbbrowne to have weak access to data
done
creating subscriber 2 DB: cbbrowne -h localhost -U cbbrowne -p 5882
slonyregress2
add plpgsql to subscriber
loading subscriber 2 DB from slonyregress1
done
creating cluster
done
storing nodes
done
Granting weak access on Slony-I schema
done
storing paths
done
launching originnode : /opt/OXRS/dbs/pgsql82/bin/slon -s500 -g10 -d2
slony_regress1 "dbname=slonyregress1 host=localhost user=cbbrowne port=5882"
launching: /opt/OXRS/dbs/pgsql82/bin/slon -s500 -g10 -d2 slony_regress1
"dbname=slonyregress2 host=localhost user=cbbrowne port=5882"
subscribing
done
generating 468 transactions of random data
0 %
5 %
10 %
15 %
20 %
25 %
30 %
35 %
40 %
45 %
50 %
55 %
60 %
65 %
70 %
75 %
80 %
85 %
90 %
95 %
100 %
done
launching polling script
loading data
data load complete
completed generate_sync_event() test
completed make_function_strict() test
done
slony is caught up
getting data from origin DB for diffing
done
getting data from node 2 for diffing against origin
comparing
subscriber node 2 is the same as origin node 1
done
**** killing slon node 1
**** killing slon node 2
waiting for slons to die
done
dropping database
slonyregress1
slonyregress2
done
***************************
test test1 completed successfully
***************************


Index: slonik.h
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slonik/slonik.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** slonik.h	31 Oct 2006 22:09:40 -0000	1.29
--- slonik.h	18 Apr 2007 15:03:51 -0000	1.30
***************
*** 38,42 ****
  typedef struct SlonikStmt_set_move_table_s SlonikStmt_set_move_table;
  typedef struct SlonikStmt_set_move_sequence_s SlonikStmt_set_move_sequence;
- typedef struct SlonikStmt_table_add_key_s SlonikStmt_table_add_key;
  typedef struct SlonikStmt_store_trigger_s SlonikStmt_store_trigger;
  typedef struct SlonikStmt_drop_trigger_s SlonikStmt_drop_trigger;
--- 38,41 ----
***************
*** 83,87 ****
  	STMT_STORE_TRIGGER,
  	STMT_SUBSCRIBE_SET,
- 	STMT_TABLE_ADD_KEY,
  	STMT_UNINSTALL_NODE,
  	STMT_UNLOCK_SET,
--- 82,85 ----
***************
*** 280,284 ****
  	int			set_origin;
  	int			tab_id;
- 	int			use_serial;
  	char	   *use_key;
  	char	   *tab_fqname;
--- 278,281 ----
***************
*** 332,343 ****
  
  
- struct SlonikStmt_table_add_key_s
- {
- 	SlonikStmt	hdr;
- 	int			no_id;
- 	char	   *tab_fqname;
- };
- 
- 
  struct SlonikStmt_store_trigger_s
  {
--- 329,332 ----
***************
*** 559,563 ****
  extern int	slonik_set_move_table(SlonikStmt_set_move_table * stmt);
  extern int	slonik_set_move_sequence(SlonikStmt_set_move_sequence * stmt);
- extern int	slonik_table_add_key(SlonikStmt_table_add_key * stmt);
  extern int	slonik_store_trigger(SlonikStmt_store_trigger * stmt);
  extern int	slonik_drop_trigger(SlonikStmt_drop_trigger * stmt);
--- 548,551 ----

Index: parser.y
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slonik/parser.y,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** parser.y	31 Oct 2006 22:09:40 -0000	1.27
--- parser.y	18 Apr 2007 15:03:51 -0000	1.28
***************
*** 42,46 ****
  	O_SECONDS,
  	O_SERVER,
- 	O_SER_KEY,
  	O_SET_ID,
  	O_SPOOLNODE,
--- 42,45 ----
***************
*** 149,153 ****
  %type <statement>	stmt_set_move_table
  %type <statement>	stmt_set_move_sequence
- %type <statement>	stmt_table_add_key
  %type <statement>	stmt_store_trigger
  %type <statement>	stmt_drop_trigger
--- 148,151 ----
***************
*** 227,231 ****
  %token  K_SECONDS
  %token	K_SEQUENCE
- %token	K_SERIAL
  %token	K_SERVER
  %token	K_SET
--- 225,228 ----
***************
*** 449,454 ****
  					| stmt_merge_set
  						{ $$ = $1; }
- 					| stmt_table_add_key
- 						{ $$ = $1; }
  					| stmt_set_add_table
  						{ $$ = $1; }
--- 446,449 ----
***************
*** 920,950 ****
  					;
  
- stmt_table_add_key	: lno K_TABLE K_ADD K_KEY option_list
- 					{
- 						SlonikStmt_table_add_key *new;
- 						statement_option opt[] = {
- 							STMT_OPTION_INT( O_NODE_ID, -1 ),
- 							STMT_OPTION_STR( O_FQNAME, NULL ),
- 							STMT_OPTION_END
- 						};
- 
- 						new = (SlonikStmt_table_add_key *)
- 								malloc(sizeof(SlonikStmt_table_add_key));
- 						memset(new, 0, sizeof(SlonikStmt_table_add_key));
- 						new->hdr.stmt_type		= STMT_TABLE_ADD_KEY;
- 						new->hdr.stmt_filename	= current_file;
- 						new->hdr.stmt_lno		= $1;
- 
- 						if (assign_options(opt, $5) == 0)
- 						{
- 							new->no_id			= opt[0].ival;
- 							new->tab_fqname		= opt[1].str;
- 						}
- 						else
- 							parser_errors++;
- 
- 						$$ = (SlonikStmt *)new;
- 					}
- 					;
  
  stmt_set_add_table	: lno K_SET K_ADD K_TABLE option_list
--- 915,918 ----
***************
*** 957,961 ****
  							STMT_OPTION_STR( O_FQNAME, NULL ),
  							STMT_OPTION_STR( O_USE_KEY, NULL ),
- 							STMT_OPTION_INT( O_SER_KEY, 0 ),
  							STMT_OPTION_STR( O_COMMENT, NULL ),
  							STMT_OPTION_END
--- 925,928 ----
***************
*** 976,981 ****
  							new->tab_fqname		= opt[3].str;
  							new->use_key		= opt[4].str;
! 							new->use_serial		= opt[5].ival;
! 							new->tab_comment	= opt[6].str;
  						}
  						else
--- 943,947 ----
  							new->tab_fqname		= opt[3].str;
  							new->use_key		= opt[4].str;
! 							new->tab_comment	= opt[5].str;
  						}
  						else
***************
*** 1654,1670 ****
  						$$ = $3;
  					}
- 					| K_KEY '=' K_SERIAL
- 					{
- 						option_list *new;
- 						new = (option_list *)malloc(sizeof(option_list));
- 
- 						new->opt_code	= O_SER_KEY;
- 						new->ival	= 1;
- 						new->str	= NULL;
- 						new->lineno	= yylineno;
- 						new->next	= NULL;
- 
- 						$$ = new;
- 					}
  					| K_FORWARD '=' option_item_yn
  					{
--- 1620,1623 ----
***************
*** 1868,1872 ****
      	case O_SECONDS:         return "seconds";
  		case O_SERVER:			return "server";
- 		case O_SER_KEY:			return "key";
  		case O_SET_ID:			return "set id";
  		case O_SPOOLNODE:		return "spoolnode";
--- 1821,1824 ----

Index: slonik.c
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slonik/slonik.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -C2 -d -r1.74 -r1.75
*** slonik.c	16 Mar 2007 22:38:01 -0000	1.74
--- slonik.c	18 Apr 2007 15:03:51 -0000	1.75
***************
*** 12,19 ****
  
  
  #include <stdio.h>
  #include <stdlib.h>
  #include <stdarg.h>
- #ifndef WIN32
  #include <unistd.h>
  #include <fcntl.h>
--- 12,19 ----
  
  
+ #ifndef WIN32
  #include <stdio.h>
  #include <stdlib.h>
  #include <stdarg.h>
  #include <unistd.h>
  #include <fcntl.h>
***************
*** 21,31 ****
  #include <sys/types.h>
  #include <sys/wait.h>
  #else
  #define sleep(x) Sleep(x*1000)
  #define vsnprintf _vsnprintf
- #define INT64_FORMAT "%I64d"
  #endif
- #include <errno.h>
- #include <time.h>
  
  #include "postgres.h"
--- 21,30 ----
  #include <sys/types.h>
  #include <sys/wait.h>
+ #include <errno.h>
+ #include <time.h>
  #else
  #define sleep(x) Sleep(x*1000)
  #define vsnprintf _vsnprintf
  #endif
  
  #include "postgres.h"
***************
*** 555,567 ****
  						errors++;
  					}
- 					if (stmt->use_serial && stmt->use_key != NULL)
- 					{
- 						printf("%s:%d: Error: "
- 							   "unique key name or SERIAL are "
- 							   "mutually exclusive\n",
- 							   hdr->stmt_filename, hdr->stmt_lno);
- 						errors++;
- 					}
- 
  					if (stmt->tab_comment == NULL)
  						stmt->tab_comment = strdup(stmt->tab_fqname);
--- 554,557 ----
***************
*** 778,815 ****
  				break;
  
- 			case STMT_TABLE_ADD_KEY:
- 				{
- 					SlonikStmt_table_add_key *stmt =
- 					(SlonikStmt_table_add_key *) hdr;
- 
- 					/*
- 					 * Check that we have the node id and that we can reach
- 					 * it.
- 					 */
- 					if (stmt->no_id < 0)
- 					{
- 						printf("%s:%d: Error: "
- 							   "node id must be specified\n",
- 							   hdr->stmt_filename, hdr->stmt_lno);
- 						errors++;
- 					}
- 					else
- 					{
- 						if (script_check_adminfo(hdr, stmt->no_id) < 0)
- 							errors++;
- 					}
- 
- 					/*
- 					 * Check that we have the table name
- 					 */
- 					if (stmt->tab_fqname == NULL)
- 					{
- 						printf("%s:%d: Error: "
- 							   "table FQ-name must be specified\n",
- 							   hdr->stmt_filename, hdr->stmt_lno);
- 						errors++;
- 					}
- 				}
- 				break;
  
  			case STMT_STORE_TRIGGER:
--- 768,771 ----
***************
*** 1447,1460 ****
  				break;
  
- 			case STMT_TABLE_ADD_KEY:
- 				{
- 					SlonikStmt_table_add_key *stmt =
- 					(SlonikStmt_table_add_key *) hdr;
- 
- 					if (slonik_table_add_key(stmt) < 0)
- 						errors++;
- 				}
- 				break;
- 
  			case STMT_STORE_TRIGGER:
  				{
--- 1403,1406 ----
***************
*** 2402,2433 ****
  	PQclear(res);
  	
- 	/*
- 	 * If available, bump the rowid sequence to the last known value.
- 	 */
- 	slon_mkquery(&query,
- 		     "select max(seql_last_value) from \"_%s\".sl_seqlog "
- 		     "	where seql_seqid = 0 "
- 		     "	and seql_origin = %d; ",
- 		     stmt->hdr.script->clustername, stmt->no_id);
- 	res = db_exec_select((SlonikStmt *) stmt, adminfo2, &query);
- 	if (res == NULL)
- 	{
- 		dstring_free(&query);
- 		return -1;
- 	}
- 	if (PQntuples(res) == 1 && !PQgetisnull(res, 0, 0))
- 	{
- 		slon_mkquery(&query,
- 			     "select \"pg_catalog\".setval('\"_%s\".sl_rowid_seq', '%s'); ",
- 			     stmt->hdr.script->clustername, PQgetvalue(res, 0, 0));
- 		if (db_exec_command((SlonikStmt *) stmt, adminfo1, &query) < 0)
- 		{
- 			dstring_free(&query);
- 			PQclear(res);
- 			return -1;
- 		}
- 	}
- 	PQclear(res);
- 
  	/* On the existing node, call storeNode() and enableNode() */
  	slon_mkquery(&query,
--- 2348,2351 ----
***************
*** 3316,3348 ****
  	dstring_init(&query);
  
! 	/*
! 	 * Determine the attkind of the table. The stored procedure for KEY =
! 	 * SERIAL might actually add a bigserial column to the table.
! 	 */
! 	if (stmt->use_serial)
  	{
  		slon_mkquery(&query,
! 					 "select \"_%s\".determineIdxnameSerial('%q'), "
! 					 "       \"_%s\".determineAttKindSerial('%q'); ",
! 					 stmt->hdr.script->clustername, stmt->tab_fqname,
! 					 stmt->hdr.script->clustername, stmt->tab_fqname);
  
  	}
  	else
  	{
! 		if (stmt->use_key == NULL)
! 		{
! 			slon_mkquery(&query,
! 					   "select \"_%s\".determineIdxnameUnique('%q', NULL); ",
! 						 stmt->hdr.script->clustername, stmt->tab_fqname);
! 
! 		}
! 		else
! 		{
! 			slon_mkquery(&query,
! 					   "select \"_%s\".determineIdxnameUnique('%q', '%q'); ",
! 						 stmt->hdr.script->clustername,
! 						 stmt->tab_fqname, stmt->use_key);
! 		}
  	}
  
--- 3234,3250 ----
  	dstring_init(&query);
  
! 	if (stmt->use_key == NULL)
  	{
  		slon_mkquery(&query,
! 			     "select \"_%s\".determineIdxnameUnique('%q', NULL); ",
! 			     stmt->hdr.script->clustername, stmt->tab_fqname);
  
  	}
  	else
  	{
! 		slon_mkquery(&query,
! 			     "select \"_%s\".determineIdxnameUnique('%q', '%q'); ",
! 			     stmt->hdr.script->clustername,
! 			     stmt->tab_fqname, stmt->use_key);
  	}
  
***************
*** 3532,3572 ****
  }
  
- 
- int
- slonik_table_add_key(SlonikStmt_table_add_key * stmt)
- {
- 	SlonikAdmInfo *adminfo1;
- 	SlonDString query;
- 
- 	adminfo1 = get_active_adminfo((SlonikStmt *) stmt, stmt->no_id);
- 	if (adminfo1 == NULL)
- 		return -1;
- 
- 	if (db_begin_xact((SlonikStmt *) stmt, adminfo1) < 0)
- 		return -1;
- 
- 	dstring_init(&query);
- 
- 	/*
- 	 * call tableAddKey()
- 	 */
- 	db_notice_silent = true;
- 	slon_mkquery(&query,
- 				 "select \"_%s\".tableAddKey('%q'); ",
- 				 stmt->hdr.script->clustername,
- 				 stmt->tab_fqname);
- 	if (db_exec_command((SlonikStmt *) stmt, adminfo1, &query) < 0)
- 	{
- 		db_notice_silent = false;
- 		dstring_free(&query);
- 		return -1;
- 	}
- 	db_notice_silent = false;
- 
- 	dstring_free(&query);
- 	return 0;
- }
- 
- 
  int
  slonik_store_trigger(SlonikStmt_store_trigger * stmt)
--- 3434,3437 ----

Index: dbutil.c
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slonik/dbutil.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** dbutil.c	28 Jun 2006 04:47:14 -0000	1.12
--- dbutil.c	18 Apr 2007 15:03:51 -0000	1.13
***************
*** 12,19 ****
  
  
  #include <stdio.h>
  #include <stdlib.h>
  #include <stdarg.h>
- #ifndef WIN32
  #include <unistd.h>
  #include <sys/types.h>
--- 12,19 ----
  
  
+ #ifndef WIN32
  #include <stdio.h>
  #include <stdlib.h>
  #include <stdarg.h>
  #include <unistd.h>
  #include <sys/types.h>

Index: scan.l
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slonik/scan.l,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** scan.l	31 Oct 2006 22:09:40 -0000	1.26
--- scan.l	18 Apr 2007 15:03:51 -0000	1.27
***************
*** 119,123 ****
  seconds         { return K_SECONDS;         }
  sequence		{ return K_SEQUENCE;		}
- serial			{ return K_SERIAL;			}
  server			{ return K_SERVER;			}
  set				{ return K_SET;				}
--- 119,122 ----



More information about the Slony1-commit mailing list