CVS User Account cvsuser
Tue Mar 28 13:27:02 PST 2006
Log Message:
-----------
Bug: slonik doesn't catch errors properly (ID: 1518)

This *WAS* troublesome because, due to a legacy of needing to have
PG 7.3 support, there was an "extra hoop" at the time new cluster is
created:

/*
* This little hoop is required because for some reason, 7.3 returns total
* garbage as a result code for such a big pile of commands. So we just
* fire that off, and then do one extra select and see if we have an
* aborted transaction.
*/

This extra select has been dropped, and the error message is now based
on the main query.

Modified Files:
--------------
    slony1-engine/src/slonik:
        slonik.c (r1.61 -> r1.62)

-------------- next part --------------
Index: slonik.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slonik/slonik.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -Lsrc/slonik/slonik.c -Lsrc/slonik/slonik.c -u -w -r1.61 -r1.62
--- src/slonik/slonik.c
+++ src/slonik/slonik.c
@@ -1789,18 +1789,10 @@
 
 	dstring_terminate(&query);
 
-	/*
-	 * This little hoop is required because for some reason, 7.3 returns total
-	 * garbage as a result code for such a big pile of commands. So we just
-	 * fire that off, and then do one extra select and see if we have an
-	 * aborted transaction.
-	 */
 	res = PQexec(adminfo->dbconn, dstring_data(&query));
-	dstring_free(&query);
-	PQclear(res);
-	res = PQexec(adminfo->dbconn, "select 1;");
+
 	rc = PQresultStatus(res);
-	if (rc != PGRES_TUPLES_OK)
+	if ((rc != PGRES_TUPLES_OK) && (rc != PGRES_COMMAND_OK) && (rc != PGRES_EMPTY_QUERY))
 	{
 		printf("%s:%d: loading of file %s: %s %s%s",
 			   stmt->stmt_filename, stmt->stmt_lno,
@@ -1810,6 +1802,7 @@
 		PQclear(res);
 		return -1;
 	}
+	dstring_free(&query);
 	PQclear(res);
 
 	return 0;
@@ -3813,6 +3806,7 @@
 	char		rex1[256];
 	char		rex2[256];
 	char		rex3[256];
+	char		rex4[256];
 	PGresult *res;
 	ExecStatusType rstat;
 
@@ -3832,7 +3826,8 @@
 		rc = strlen(rex1);
 		rex1[rc] = '\0';
 		replace_token(rex3, rex1, "@CLUSTERNAME@", stmt->hdr.script->clustername);
-		replace_token(buf, rex3, "@NAMESPACE@", rex2);
+		replace_token(rex4, rex3, "@MODULEVERSION@", SLONY_I_VERSION_STRING);
+		replace_token(buf, rex4, "@NAMESPACE@", rex2);
 		rc = strlen(buf);
 		dstring_nappend(&script, buf, rc);
 	}



More information about the Slony1-commit mailing list