CVS User Account cvsuser
Fri Mar 24 15:42:05 PST 2006
Log Message:
-----------
The query that submits the DDL event needs to be handled via PQexecParams()
in order that it not require any quoting.

Otherwise, if you have plain quotes in your DDL, such as the quotes
around 'y' and 'n' in the following DDL, they'll cause the insert into
sl_event to fail.

ALTER TABLE billing_discount add constraint use_term_cons check (use_term in ('y','n'));

Modified Files:
--------------
    slony1-engine/src/slonik:
        slonik.c (r1.59 -> r1.60)

-------------- next part --------------
Index: slonik.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slonik/slonik.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -Lsrc/slonik/slonik.c -Lsrc/slonik/slonik.c -u -w -r1.59 -r1.60
--- src/slonik/slonik.c
+++ src/slonik/slonik.c
@@ -3890,24 +3890,44 @@
 			dstring_free(&query);
 			return -1;
 		}
-		rstat = PQresultStatus(res);
-		printf ("Success - %s\n", PQresStatus(rstat));
+		/* rstat = PQresultStatus(res); */
+		/* printf ("Success - %s\n", PQresStatus(rstat)); */
 	}
 	
-	printf("Submitting SQL statements to subscribers...\n");
+	printf("Submit DDL Event to subscribers...\n");
 
-	slon_mkquery(&query, "select \"_%s\".ddlScript_complete(%d, '%s', %d); ", 
+	slon_mkquery(&query, "select \"_%s\".ddlScript_complete(%d, $1::text, %d); ", 
 		     stmt->hdr.script->clustername,
-		     stmt->ddl_setid,  dstring_data(&script),
+		     stmt->ddl_setid,  
 		     stmt->only_on_node);
 
-	dstring_free(&script);
-	if (db_exec_evcommand((SlonikStmt *) stmt, adminfo1, &query) < 0)
+#define PARMCOUNT 1
+
+	const char *params[PARMCOUNT];
+	int paramlens[PARMCOUNT];
+	int paramfmts[PARMCOUNT];
+
+	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 on origin - %s\n", PQresStatus(rstat));
 	}
 
+	dstring_free(&script);
 	dstring_free(&query);
 	return 0;
 }



More information about the Slony1-commit mailing list