Jan Wieck wieck at lists.slony.info
Mon Jun 4 15:51:21 PDT 2007
Update of /home/cvsd/slony1/slony1-engine/src/slonik
In directory main.slony.info:/tmp/cvs-serv31948/src/slonik

Modified Files:
      Tag: REL_1_2_STABLE
	slonik.c 
Log Message:
Fixed EXECUTE SCRIPT with respect to WAIT FOR EVENT. It will
now record the scripts event seqno inside of slonik's conninfo
state so that WAIT FOR EVENT will wait for the right seqno.

Jan


Index: slonik.c
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slonik/slonik.c,v
retrieving revision 1.67.2.9
retrieving revision 1.67.2.10
diff -C2 -d -r1.67.2.9 -r1.67.2.10
*** slonik.c	15 May 2007 16:56:37 -0000	1.67.2.9
--- slonik.c	4 Jun 2007 22:51:19 -0000	1.67.2.10
***************
*** 3935,3970 ****
  			printf("DDL Statement failed - %s\n", PQresStatus(rstat));
  			dstring_free(&query);
  			return -1;
  		}
  		/* rstat = PQresultStatus(res); */
  		/* printf ("Success - %s\n", PQresStatus(rstat)); */
  	}
  	
! 		printf("Complete DDL Event...\n");
! 		
! 		slon_mkquery(&query, "select \"_%s\".ddlScript_complete(%d, $1::text, %d); ", 
! 					 stmt->hdr.script->clustername,
! 					 stmt->ddl_setid,  
! 					 stmt->only_on_node);
! 		
! 		paramlens[PARMCOUNT-1] = 0;
! 		paramfmts[PARMCOUNT-1] = 0;
! 		params[PARMCOUNT-1] = dstring_data(&script);
! 		
! 		res = PQexecParams(adminfo1->dbconn, dstring_data(&query), PARMCOUNT,
! 						   NULL, params, paramlens, paramfmts, 0);
! 		
! 		if (PQresultStatus(res) != PGRES_COMMAND_OK && 
! 			PQresultStatus(res) != PGRES_TUPLES_OK &&
! 			PQresultStatus(res) != PGRES_EMPTY_QUERY)
! 			{
! 				rstat = PQresultStatus(res);
! 				printf("Event submission for DDL failed - %s\n", PQresStatus(rstat));
! 				dstring_free(&query);
! 				return -1;
! 			} else {
! 				rstat = PQresultStatus(res);
! 				printf ("DDL submission to initial node - %s\n", PQresStatus(rstat));
! 			}
  	dstring_free(&script);
  	dstring_free(&query);
--- 3935,3991 ----
  			printf("DDL Statement failed - %s\n", PQresStatus(rstat));
  			dstring_free(&query);
+ 			PQclear(res);
  			return -1;
  		}
  		/* rstat = PQresultStatus(res); */
  		/* printf ("Success - %s\n", PQresStatus(rstat)); */
+ 
+ 		PQclear(res);
  	}
  	
! 	printf("Complete DDL Event...\n");
! 	
! 	slon_mkquery(&query, "select \"_%s\".ddlScript_complete(%d, $1::text, %d); ", 
! 				 stmt->hdr.script->clustername,
! 				 stmt->ddl_setid,  
! 				 stmt->only_on_node);
! 	
! 	paramlens[PARMCOUNT-1] = 0;
! 	paramfmts[PARMCOUNT-1] = 0;
! 	params[PARMCOUNT-1] = dstring_data(&script);
! 	
! 	res = PQexecParams(adminfo1->dbconn, dstring_data(&query), PARMCOUNT,
! 					   NULL, params, paramlens, paramfmts, 0);
! 	
! 	/*
! 	 * Check that the event submission returned exactly one result row
! 	 */
! 	if (PQresultStatus(res) != PGRES_TUPLES_OK)
! 	{
! 		rstat = PQresultStatus(res);
! 		printf("Event submission for DDL failed - %s\n", PQresStatus(rstat));
! 		dstring_free(&script);
! 		dstring_free(&query);
! 		PQclear(res);
! 		return -1;
! 	}
! 	if (PQntuples(res) != 1)
! 	{
! 		printf("Event submission for DDL failed - query returned %d rows (expected 1)\n", PQntuples(res));
! 		dstring_free(&script);
! 		dstring_free(&query);
! 		PQclear(res);
! 		return -1;
! 	}
! 
! 	/*
! 	 * ... which should be the event-seqno for the DDL_SCRIPT event.
! 	 * We remember that in the admin conninfo for WAIT.
! 	 */
! 	slon_scanint64(PQgetvalue(res, 0, 0), &(adminfo1->last_event));
! 
! 	rstat = PQresultStatus(res);
! 	PQclear(res);
! 	printf ("DDL submission to initial node - %s\n", PQresStatus(rstat));
  	dstring_free(&script);
  	dstring_free(&query);



More information about the Slony1-commit mailing list