CVS User Account cvsuser
Sun Aug 6 07:57:51 PDT 2006
Log Message:
-----------
Rework  the DateStyle fix to call the GUC helper functions rather than direct manipulation of the var, given that the var is not accessable under win32.  Thanks to Stefan for A) discovering this, B) providing access to a msys box for debugging and testing.

Modified Files:
--------------
    slony1-engine/src/backend:
        slony1_funcs.c (r1.49 -> r1.50)

-------------- next part --------------
Index: slony1_funcs.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/backend/slony1_funcs.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -Lsrc/backend/slony1_funcs.c -Lsrc/backend/slony1_funcs.c -u -w -r1.49 -r1.50
--- src/backend/slony1_funcs.c
+++ src/backend/slony1_funcs.c
@@ -501,7 +501,7 @@
 		int			len_value;
 		int			i;
 		int			need_comma = false;
-		int			OldDateStyle = DateStyle;
+		char			*OldDateStyle;
 		char	   *cp = VARDATA(cs->cmddata_buf);
 
 		/*
@@ -563,6 +563,8 @@
 		 * Append the values
 		 */
 		need_comma = false;
+		OldDateStyle=GetConfigOptionByName("DateStyle", NULL);
+		set_config_option("DateStyle", "ISO", PGC_USERSET, PGC_S_SESSION, true, true);
 		for (i = 0; i < tg->tg_relation->rd_att->natts; i++)
 		{
 			/*
@@ -571,7 +573,6 @@
 			if (tupdesc->attrs[i]->attisdropped)
 				continue;
 
-			DateStyle = USE_ISO_DATES;
 
 			if ((col_value = SPI_getvalue(new_row, tupdesc, i + 1)) == NULL)
 			{
@@ -582,8 +583,6 @@
 				col_value = slon_quote_literal(col_value);
 			}
 
-			DateStyle = OldDateStyle;
-
 			cmddata_need = (cp - (char *)(cs->cmddata_buf)) + 16 +
 				(len_value = strlen(col_value));
 			if (cs->cmddata_size < cmddata_need)
@@ -605,6 +604,8 @@
 			cp += len_value;
 		}
 
+		set_config_option("DateStyle", OldDateStyle, PGC_USERSET, PGC_S_SESSION, true, true);
+
 		/*
 		 * Terminate and done
 		 */
@@ -630,7 +631,7 @@
 		int			i;
 		int			need_comma = false;
 		int			need_and = false;
-		int		OldDateStyle = DateStyle;
+		char		*OldDateStyle;
 
 		char	   *cp = VARDATA(cs->cmddata_buf);
 
@@ -726,9 +727,10 @@
 				col_value = "NULL";
 			else
 			{
-				DateStyle=USE_ISO_DATES;
+				OldDateStyle=GetConfigOptionByName("DateStyle", NULL);
+				set_config_option("DateStyle", "ISO", PGC_USERSET, PGC_S_SESSION, true, true);
 				col_value = slon_quote_literal(SPI_getvalue(new_row, tupdesc, i + 1));
-				DateStyle=OldDateStyle;
+				set_config_option("DateStyle", OldDateStyle, PGC_USERSET, PGC_S_SESSION, true, true);
 			}
 			cmddata_need = (cp - (char *)(cs->cmddata_buf)) + 16 +
 				(len_ident = strlen(col_ident)) +



More information about the Slony1-commit mailing list