Jan Wieck wieck at lists.slony.info
Thu Jul 5 11:19:06 PDT 2007
Update of /home/cvsd/slony1/slony1-engine/src/slonik
In directory main.slony.info:/tmp/cvs-serv2930/src/slonik

Modified Files:
	parser.y scan.l slonik.c slonik.h 
Log Message:
Removed all support for STORE/DROP TRIGGER commands. Users are supposed
to use the ALTER TABLE [ENABLE|DISABLE] TRIGGER functionality in
Postgres from now on.

Jan


Index: slonik.h
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slonik/slonik.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** slonik.h	5 Jun 2007 22:22:07 -0000	1.31
--- slonik.h	5 Jul 2007 18:19:04 -0000	1.32
***************
*** 38,43 ****
  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_store_trigger_s SlonikStmt_store_trigger;
- typedef struct SlonikStmt_drop_trigger_s SlonikStmt_drop_trigger;
  typedef struct SlonikStmt_subscribe_set_s SlonikStmt_subscribe_set;
  typedef struct SlonikStmt_unsubscribe_set_s SlonikStmt_unsubscribe_set;
--- 38,41 ----
***************
*** 61,65 ****
  	STMT_DROP_PATH,
  	STMT_DROP_SET,
- 	STMT_DROP_TRIGGER,
  	STMT_ECHO,
  	STMT_EXIT,
--- 59,62 ----
***************
*** 80,84 ****
  	STMT_STORE_NODE,
  	STMT_STORE_PATH,
- 	STMT_STORE_TRIGGER,
  	STMT_SUBSCRIBE_SET,
  	STMT_UNINSTALL_NODE,
--- 77,80 ----
***************
*** 329,350 ****
  
  
- struct SlonikStmt_store_trigger_s
- {
- 	SlonikStmt	hdr;
- 	int			trig_tabid;
- 	char	   *trig_tgname;
- 	int			ev_origin;
- };
- 
- 
- struct SlonikStmt_drop_trigger_s
- {
- 	SlonikStmt	hdr;
- 	int			trig_tabid;
- 	char	   *trig_tgname;
- 	int			ev_origin;
- };
- 
- 
  struct SlonikStmt_subscribe_set_s
  {
--- 325,328 ----
***************
*** 548,553 ****
  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_store_trigger(SlonikStmt_store_trigger * stmt);
- extern int	slonik_drop_trigger(SlonikStmt_drop_trigger * stmt);
  extern int	slonik_subscribe_set(SlonikStmt_subscribe_set * stmt);
  extern int	slonik_unsubscribe_set(SlonikStmt_unsubscribe_set * stmt);
--- 526,529 ----

Index: parser.y
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slonik/parser.y,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** parser.y	18 Apr 2007 15:03:51 -0000	1.28
--- parser.y	5 Jul 2007 18:19:04 -0000	1.29
***************
*** 148,153 ****
  %type <statement>	stmt_set_move_table
  %type <statement>	stmt_set_move_sequence
- %type <statement>	stmt_store_trigger
- %type <statement>	stmt_drop_trigger
  %type <statement>	stmt_subscribe_set
  %type <statement>	stmt_unsubscribe_set
--- 148,151 ----
***************
*** 234,238 ****
  %token	K_TABLE
  %token	K_TIMEOUT
- %token	K_TRIGGER
  %token	K_TRUE
  %token	K_TRY
--- 232,235 ----
***************
*** 458,465 ****
  					| stmt_set_move_sequence
  						{ $$ = $1; }
- 					| stmt_store_trigger
- 						{ $$ = $1; }
- 					| stmt_drop_trigger
- 						{ $$ = $1; }
  					| stmt_subscribe_set
  						{ $$ = $1; }
--- 455,458 ----
***************
*** 1098,1161 ****
  					;
  
- stmt_store_trigger	: lno K_STORE K_TRIGGER option_list
- 					{
- 						SlonikStmt_store_trigger *new;
- 						statement_option opt[] = {
- 							STMT_OPTION_INT( O_TAB_ID, -1 ),
- 							STMT_OPTION_STR( O_TRIG_NAME, NULL ),
- 							STMT_OPTION_INT( O_EVENT_NODE, 1 ),
- 							STMT_OPTION_END
- 						};
- 
- 						new = (SlonikStmt_store_trigger *)
- 								malloc(sizeof(SlonikStmt_store_trigger));
- 						memset(new, 0, sizeof(SlonikStmt_store_trigger));
- 						new->hdr.stmt_type		= STMT_STORE_TRIGGER;
- 						new->hdr.stmt_filename	= current_file;
- 						new->hdr.stmt_lno		= $1;
- 
- 						if (assign_options(opt, $4) == 0)
- 						{
- 							new->trig_tabid		= opt[0].ival;
- 							new->trig_tgname	= opt[1].str;
- 							new->ev_origin		= opt[2].ival;
- 						}
- 						else
- 							parser_errors++;
- 
- 						$$ = (SlonikStmt *)new;
- 					}
- 					;
- 
- stmt_drop_trigger	: lno K_DROP K_TRIGGER option_list
- 					{
- 						SlonikStmt_drop_trigger *new;
- 						statement_option opt[] = {
- 							STMT_OPTION_INT( O_TAB_ID, -1 ),
- 							STMT_OPTION_STR( O_TRIG_NAME, NULL ),
- 							STMT_OPTION_INT( O_EVENT_NODE, 1 ),
- 							STMT_OPTION_END
- 						};
- 
- 						new = (SlonikStmt_drop_trigger *)
- 								malloc(sizeof(SlonikStmt_drop_trigger));
- 						memset(new, 0, sizeof(SlonikStmt_drop_trigger));
- 						new->hdr.stmt_type		= STMT_DROP_TRIGGER;
- 						new->hdr.stmt_filename	= current_file;
- 						new->hdr.stmt_lno		= $1;
- 
- 						if (assign_options(opt, $4) == 0)
- 						{
- 							new->trig_tabid		= opt[0].ival;
- 							new->trig_tgname	= opt[1].str;
- 							new->ev_origin		= opt[2].ival;
- 						}
- 						else
- 							parser_errors++;
- 
- 						$$ = (SlonikStmt *)new;
- 					}
- 					;
- 
  stmt_subscribe_set	: lno K_SUBSCRIBE K_SET option_list
  					{
--- 1091,1094 ----
***************
*** 1605,1613 ****
  						$$ = $4;
  					}
- 					| K_TRIGGER K_NAME '=' option_item_literal
- 					{
- 						$4->opt_code	= O_TRIG_NAME;
- 						$$ = $4;
- 					}
  					| K_FULL K_QUALIFIED K_NAME '=' option_item_literal
  					{
--- 1538,1541 ----
***************
*** 1825,1829 ****
  		case O_TAB_ID:			return "table id";
  		case O_TIMEOUT:			return "timeout";
- 		case O_TRIG_NAME:		return "trigger name";
  		case O_USE_KEY:			return "key";
  		case O_WAIT_CONFIRMED:	return "confirmed";
--- 1753,1756 ----

Index: slonik.c
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slonik/slonik.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -C2 -d -r1.78 -r1.79
*** slonik.c	5 Jun 2007 22:22:07 -0000	1.78
--- slonik.c	5 Jul 2007 18:19:04 -0000	1.79
***************
*** 769,830 ****
  
  
- 			case STMT_STORE_TRIGGER:
- 				{
- 					SlonikStmt_store_trigger *stmt =
- 					(SlonikStmt_store_trigger *) hdr;
- 
- 					if (stmt->ev_origin < 0)
- 					{
- 						stmt->ev_origin = 1;
- 					}
- 					if (stmt->trig_tabid < 0)
- 					{
- 						printf("%s:%d: Error: "
- 							   "table id must be specified\n",
- 							   hdr->stmt_filename, hdr->stmt_lno);
- 						errors++;
- 					}
- 					if (stmt->trig_tgname == NULL)
- 					{
- 						printf("%s:%d: Error: "
- 							   "trigger name must be specified\n",
- 							   hdr->stmt_filename, hdr->stmt_lno);
- 						errors++;
- 					}
- 
- 					if (script_check_adminfo(hdr, stmt->ev_origin) < 0)
- 						errors++;
- 				}
- 				break;
- 
- 			case STMT_DROP_TRIGGER:
- 				{
- 					SlonikStmt_drop_trigger *stmt =
- 					(SlonikStmt_drop_trigger *) hdr;
- 
- 					if (stmt->ev_origin < 0)
- 					{
- 						stmt->ev_origin = 1;
- 					}
- 					if (stmt->trig_tabid < 0)
- 					{
- 						printf("%s:%d: Error: "
- 							   "table id must be specified\n",
- 							   hdr->stmt_filename, hdr->stmt_lno);
- 						errors++;
- 					}
- 					if (stmt->trig_tgname == NULL)
- 					{
- 						printf("%s:%d: Error: "
- 							   "trigger name must be specified\n",
- 							   hdr->stmt_filename, hdr->stmt_lno);
- 						errors++;
- 					}
- 
- 					if (script_check_adminfo(hdr, stmt->ev_origin) < 0)
- 						errors++;
- 				}
- 				break;
- 
  			case STMT_SUBSCRIBE_SET:
  				{
--- 769,772 ----
***************
*** 1403,1426 ****
  				break;
  
- 			case STMT_STORE_TRIGGER:
- 				{
- 					SlonikStmt_store_trigger *stmt =
- 					(SlonikStmt_store_trigger *) hdr;
- 
- 					if (slonik_store_trigger(stmt) < 0)
- 						errors++;
- 				}
- 				break;
- 
- 			case STMT_DROP_TRIGGER:
- 				{
- 					SlonikStmt_drop_trigger *stmt =
- 					(SlonikStmt_drop_trigger *) hdr;
- 
- 					if (slonik_drop_trigger(stmt) < 0)
- 						errors++;
- 				}
- 				break;
- 
  			case STMT_SUBSCRIBE_SET:
  				{
--- 1345,1348 ----
***************
*** 3394,3457 ****
  
  int
- slonik_store_trigger(SlonikStmt_store_trigger * stmt)
- {
- 	SlonikAdmInfo *adminfo1;
- 	SlonDString query;
- 
- 	adminfo1 = get_active_adminfo((SlonikStmt *) stmt, stmt->ev_origin);
- 	if (adminfo1 == NULL)
- 		return -1;
- 
- 	if (db_begin_xact((SlonikStmt *) stmt, adminfo1) < 0)
- 		return -1;
- 
- 	dstring_init(&query);
- 
- 	slon_mkquery(&query,
- 				 "select \"_%s\".storeTrigger(%d, '%q'); ",
- 				 stmt->hdr.script->clustername,
- 				 stmt->trig_tabid, stmt->trig_tgname);
- 	if (db_exec_evcommand((SlonikStmt *) stmt, adminfo1, &query) < 0)
- 	{
- 		dstring_free(&query);
- 		return -1;
- 	}
- 
- 	dstring_free(&query);
- 	return 0;
- }
- 
- 
- int
- slonik_drop_trigger(SlonikStmt_drop_trigger * stmt)
- {
- 	SlonikAdmInfo *adminfo1;
- 	SlonDString query;
- 
- 	adminfo1 = get_active_adminfo((SlonikStmt *) stmt, stmt->ev_origin);
- 	if (adminfo1 == NULL)
- 		return -1;
- 
- 	if (db_begin_xact((SlonikStmt *) stmt, adminfo1) < 0)
- 		return -1;
- 
- 	dstring_init(&query);
- 
- 	slon_mkquery(&query,
- 				 "select \"_%s\".dropTrigger(%d, '%q'); ",
- 				 stmt->hdr.script->clustername,
- 				 stmt->trig_tabid, stmt->trig_tgname);
- 	if (db_exec_evcommand((SlonikStmt *) stmt, adminfo1, &query) < 0)
- 	{
- 		dstring_free(&query);
- 		return -1;
- 	}
- 
- 	dstring_free(&query);
- 	return 0;
- }
- 
- 
- int
  slonik_subscribe_set(SlonikStmt_subscribe_set * stmt)
  {
--- 3316,3319 ----

Index: scan.l
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slonik/scan.l,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** scan.l	18 Apr 2007 15:03:51 -0000	1.27
--- scan.l	5 Jul 2007 18:19:04 -0000	1.28
***************
*** 130,134 ****
  table			{ return K_TABLE;			}
  timeout			{ return K_TIMEOUT;			}
- trigger			{ return K_TRIGGER;			}
  true			{ return K_TRUE;			}
  try				{ return K_TRY;				}
--- 130,133 ----



More information about the Slony1-commit mailing list