CVS User Account cvsuser
Tue Mar 28 12:48:55 PST 2006
Log Message:
-----------
Bug #1519 - Should explicitly check slony version on store node command

Add a test function early in slony1_funcs.sql that checks the 
version information in the SPI stored procedure against a macro
expansion of @MODULEVERSION@ done by slonik.

The function aborts with an explanatory error message if those
versions do not match.

This will cause a much earlier, explained, abort of STORE
NODE/INITIALIZE CLUSTER if there is a version mismatch between slonik
and the stored functions/schema.

Modified Files:
--------------
    slony1-engine/src/backend:
        slony1_funcs.sql (r1.82 -> r1.83)
    slony1-engine/src/slonik:
        slonik.c (r1.60 -> r1.61)

-------------- next part --------------
Index: slony1_funcs.sql
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/backend/slony1_funcs.sql,v
retrieving revision 1.82
retrieving revision 1.83
diff -Lsrc/backend/slony1_funcs.sql -Lsrc/backend/slony1_funcs.sql -u -w -r1.82 -r1.83
--- src/backend/slony1_funcs.sql
+++ src/backend/slony1_funcs.sql
@@ -180,6 +180,22 @@
 comment on function @NAMESPACE at .getModuleVersion () is
   'Returns the compiled-in version number of the Slony-I shared object';
 
+create or replace function @NAMESPACE at .checkmoduleversion () returns text as '
+begin
+  if @NAMESPACE at .getModuleVersion() <> ''@MODULEVERSION@'' then
+      raise exception ''Slonik version: % != Slony-I version in PG build %'',
+             ''@MODULEVERSION@'', @NAMESPACE at .getModuleVersion();
+  end if;
+  return null;
+end;' language plpgsql;
+
+comment on function @NAMESPACE at .checkmoduleversion () is 
+'Inline test function that verifies that slonik request for STORE
+NODE/INIT CLUSTER is being run against a conformant set of
+schema/functions.';
+
+select @NAMESPACE at .checkmoduleversion();
+
 -- ----------------------------------------------------------------------
 -- FUNCTION setSessionRole (name, role)
 --
Index: slonik.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slonik/slonik.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -Lsrc/slonik/slonik.c -Lsrc/slonik/slonik.c -u -w -r1.60 -r1.61
--- src/slonik/slonik.c
+++ src/slonik/slonik.c
@@ -1750,6 +1750,7 @@
 	char		rex1[256];
 	char		rex2[256];
 	char		rex3[256];
+	char		rex4[256];
 	FILE	   *stmtp;
 
 
@@ -1778,7 +1779,8 @@
 		rex1[rc] = '\0';
 		rex3[0] = '\0';
 		replace_token(rex3, rex1, "@CLUSTERNAME@", stmt->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(&query, buf, rc);
 	}



More information about the Slony1-commit mailing list