CVS User Account cvsuser
Tue Jun 27 21:47:18 PDT 2006
Log Message:
-----------


Modified Files:
--------------
    slony1-engine/src/backend:
        slony1_funcs.c (r1.45 -> r1.46)
    slony1-engine/src/slon:
        dbutils.c (r1.21 -> r1.22)
    slony1-engine/src/slonik:
        dbutil.c (r1.11 -> r1.12)
    slony1-engine/tests/test1:
        generate_dml.sh (r1.5 -> r1.6)

-------------- next part --------------
Index: dbutils.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/dbutils.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -Lsrc/slon/dbutils.c -Lsrc/slon/dbutils.c -u -w -r1.21 -r1.22
--- src/slon/dbutils.c
+++ src/slon/dbutils.c
@@ -55,6 +55,8 @@
 {
 	PGconn	   *dbconn;
 	SlonConn   *conn;
+	PGresult   *res;
+	SlonDString query;
 
 	/*
 	 * Create the native database connection
@@ -81,13 +83,12 @@
 		PQfinish(dbconn);
 		return NULL;
 	}
+
+	dstring_init(&query);
+
 	if (sql_on_connection != NULL)
 	{
 
-		PGresult   *res;
-		SlonDString query;
-
-		dstring_init(&query);
 		slon_mkquery(&query, "%s", sql_on_connection);
 		res = PQexec(dbconn, dstring_data(&query));
 		if (!((PQresultStatus(res) == PGRES_TUPLES_OK) ||
@@ -100,6 +101,15 @@
 		PQclear(res);
 	}
 
+	/* set the datestyle to ISO */
+	slon_mkquery(&query, "set datestyle to 'ISO'");
+	res = PQexec(dbconn, dstring_data(&query));
+	if (!(PQresultStatus(res) == PGRES_COMMAND_OK))
+	{
+		slon_log(SLON_ERROR, "Unable to set the datestyle to ISO\n");
+	}
+	PQclear(res);
+	
 	/*
 	 * Embed it into a SlonConn structure used to exchange it with the
 	 * scheduler. On return this new connection object is locked.
Index: dbutil.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slonik/dbutil.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -Lsrc/slonik/dbutil.c -Lsrc/slonik/dbutil.c -u -w -r1.11 -r1.12
--- src/slonik/dbutil.c
+++ src/slonik/dbutil.c
@@ -111,6 +111,7 @@
 db_connect(SlonikStmt * stmt, SlonikAdmInfo * adminfo)
 {
 	PGconn	   *dbconn;
+	SlonDString	query;
 
 	db_notice_stmt = stmt;
 
@@ -136,7 +137,18 @@
 #else
 	PQsetNoticeProcessor(dbconn, db_notice_recv, NULL);
 #endif   /* !HAVE_PQSETNOTICERECEIVER */
+
+	dstring_init(&query);
+	slon_mkquery(&query,"SET datestyle to 'ISO'");
+
 	adminfo->dbconn = dbconn;
+	if (db_exec_command(stmt, adminfo, &query) < 0)
+	{
+		printf("Unable to set datestyle\n");
+		dstring_free(&query);
+		return -1;
+	}
+	dstring_free(&query); 
 	return 0;
 }
 
Index: slony1_funcs.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/backend/slony1_funcs.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -Lsrc/backend/slony1_funcs.c -Lsrc/backend/slony1_funcs.c -u -w -r1.45 -r1.46
--- src/backend/slony1_funcs.c
+++ src/backend/slony1_funcs.c
@@ -495,10 +495,12 @@
 		TupleDesc	tupdesc = tg->tg_relation->rd_att;
 		char	   *col_ident;
 		char	   *col_value;
+		
 		int			len_ident;
 		int			len_value;
 		int			i;
 		int			need_comma = false;
+		int			OldDateStyle = DateStyle;
 		char	   *cp = VARDATA(cs->cmddata_buf);
 
 		/*
@@ -567,6 +569,9 @@
 			 */
 			if (tupdesc->attrs[i]->attisdropped)
 				continue;
+
+			DateStyle = USE_ISO_DATES;
+
 			if ((col_value = SPI_getvalue(new_row, tupdesc, i + 1)) == NULL)
 			{
 				col_value = "NULL";
@@ -576,6 +581,8 @@
 				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)
@@ -622,6 +629,8 @@
 		int			i;
 		int			need_comma = false;
 		int			need_and = false;
+		int		OldDateStyle = DateStyle;
+
 		char	   *cp = VARDATA(cs->cmddata_buf);
 
 		/*
@@ -715,8 +724,11 @@
 			if (new_isnull)
 				col_value = "NULL";
 			else
+			{
+				DateStyle=USE_ISO_DATES;
 				col_value = slon_quote_literal(SPI_getvalue(new_row, tupdesc, i + 1));
-
+				DateStyle=OldDateStyle;
+			}
 			cmddata_need = (cp - (char *)(cs->cmddata_buf)) + 16 +
 				(len_ident = strlen(col_ident)) +
 				(len_value = strlen(col_value));
Index: generate_dml.sh
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tests/test1/generate_dml.sh,v
retrieving revision 1.5
retrieving revision 1.6
diff -Ltests/test1/generate_dml.sh -Ltests/test1/generate_dml.sh -u -w -r1.5 -r1.6
--- tests/test1/generate_dml.sh
+++ tests/test1/generate_dml.sh
@@ -30,6 +30,7 @@
   status "generating ${numrows} tranactions of random data"
   percent=`expr $j \* 5`
   status "$percent %"
+  GENDATA="$mktmp/generate.data"
   while : ; do
     txtalen=$(random_number 1 100)
     txta=$(random_string ${txtalen})
@@ -37,7 +38,6 @@
     txtblen=$(random_number 1 100)
     txtb=$(random_string ${txtblen})
     txtb=`echo ${txtb} | sed -e "s/\\\\\\\/\\\\\\\\\\\\\\/g" -e "s/'/''/g"`
-    GENDATA="$mktmp/generate.data"
     echo "INSERT INTO table1(data) VALUES ('${txta}');" >> $GENDATA
     echo "INSERT INTO table2(table1_id,data) SELECT id, '${txtb}' FROM table1 WHERE data='${txta}';" >> $GENDATA
     echo "INSERT INTO table3(table2_id) SELECT id FROM table2 WHERE data ='${txtb}';" >> $GENDATA



More information about the Slony1-commit mailing list