CVS User Account cvsuser
Fri Jun 23 08:37:58 PDT 2006
Log Message:
-----------
Add in testdatestyles test that checks whether DATESTYLE is being
propagated properly.

Shown as a bug in #1566
http://gborg.postgresql.org/project/slony1/bugs/bugupdate.php?1566

Added Files:
-----------
    slony1-engine/tests/testdatestyles:
        README (r1.1)
        generate_dml.sh (r1.1)
        init_add_tables.ik (r1.1)
        init_cluster.ik (r1.1)
        init_create_set.ik (r1.1)
        init_data.sql (r1.1)
        init_schema.sql (r1.1)
        init_subscribe_set.ik (r1.1)
        schema.diff (r1.1)
        settings.ik (r1.1)

-------------- next part --------------
--- /dev/null
+++ tests/testdatestyles/init_add_tables.ik
@@ -0,0 +1 @@
+set add table (id=1, set id=1, origin=1, fully qualified name = 'public.table1', comment='big date table');
--- /dev/null
+++ tests/testdatestyles/init_cluster.ik
@@ -0,0 +1 @@
+init cluster (id=1, comment = 'Regress test node');
--- /dev/null
+++ tests/testdatestyles/init_data.sql
@@ -0,0 +1,3 @@
+insert into table1(ts, tsz, ds) values ('2006-01-01', '2006-06-01', '2007-01-01');
+insert into table1(ts, tsz, ds) values ('infinity', 'infinity', now());
+insert into table1(ts, tsz, ds) values ('-infinity', '-infinity', now());
--- /dev/null
+++ tests/testdatestyles/init_schema.sql
@@ -0,0 +1,9 @@
+CREATE TABLE table1(
+  id            SERIAL PRIMARY KEY, 
+  ts            TIMESTAMP,
+  tsz           TIMESTAMPTZ,
+  ds            DATE,
+  nowts         TIMESTAMP DEFAULT NOW(),
+  nowtsz        TIMESTAMPTZ DEFAULT NOW(),
+  nowds         DATE DEFAULT NOW()
+);
--- /dev/null
+++ tests/testdatestyles/settings.ik
@@ -0,0 +1,4 @@
+NUMCLUSTERS=${NUMCLUSTERS:-"1"}
+NUMNODES=${NUMNODES:-"2"}
+ORIGINNODE=1
+WORKERS=${WORKERS:-"1"}
--- /dev/null
+++ tests/testdatestyles/init_subscribe_set.ik
@@ -0,0 +1 @@
+subscribe set (id = 1, provider = 1, receiver = 2, forward = no);
--- /dev/null
+++ tests/testdatestyles/init_create_set.ik
@@ -0,0 +1 @@
+create set (id=1, origin=1, comment='All test1 tables');
--- /dev/null
+++ tests/testdatestyles/generate_dml.sh
@@ -0,0 +1,86 @@
+. support_funcs.sh
+
+init_dml()
+{
+  echo "init_dml()"
+}
+
+begin()
+{
+  echo "begin()"
+}
+
+rollback()
+{
+  echo "rollback()"
+}
+
+commit()
+{
+  echo "commit()"
+}
+
+generate_initdata()
+{
+  GENDATA="$mktmp/generate.data"
+  for datestyle in DMY European German ISO MDY NonEuropean Postgres SQL US YMD; do
+     status "generating tranactions of date data for datestyle ${datestyle}"
+     echo "SET DATESTYLE TO ${datestyle};" >> $GENDATA
+     echo "insert into table1(ts, tsz, ds) values ('infinity', 'infinity', now());" >> $GENDATA
+     echo "insert into table1(ts, tsz, ds) values ('-infinity', '-infinity', now());" >> $GENDATA
+     # Final second of last year
+     TS="(date_trunc('years', now())-'1 second'::interval)"
+     echo "insert into table1(ts, tsz, ds) values ($TS, $TS, $TS);" >> $GENDATA
+     # Final second of last month
+     TS="(date_trunc('months', now())-'1 second'::interval)"
+     echo "insert into table1(ts, tsz, ds) values ($TS, $TS, $TS);" >> $GENDATA
+     # Sorta February 29th...
+     TS="(date_trunc('years', now())+'60 days'::interval)"
+     echo "insert into table1(ts, tsz, ds) values ($TS, $TS, $TS);" >> $GENDATA
+     # Sorta February 29th...
+     TS="(date_trunc('years', now())+'60 days'::interval+'1 year'::interval)"
+     echo "insert into table1(ts, tsz, ds) values ($TS, $TS, $TS);" >> $GENDATA
+     # Sorta February 29th...
+     TS="(date_trunc('years', now())+'60 days'::interval+'2 years'::interval)"
+     echo "insert into table1(ts, tsz, ds) values ($TS, $TS, $TS);" >> $GENDATA
+     # Sorta February 29th...
+     TS="(date_trunc('years', now())+'60 days'::interval+'3 years'::interval)"
+     echo "insert into table1(ts, tsz, ds) values ($TS, $TS, $TS);" >> $GENDATA
+     # Sorta February 29th...
+     TS="(date_trunc('years', now())+'60 days'::interval+'4 years'::interval)"
+     echo "insert into table1(ts, tsz, ds) values ($TS, $TS, $TS);" >> $GENDATA
+     # Now
+     TS="now()"
+     echo "insert into table1(ts, tsz, ds) values ($TS, $TS, $TS);" >> $GENDATA
+
+     # Now, go for a period of 1000 days, and generate an entry for each
+     # day.
+     for d1 in 0 1 2 3 4 5 6 7 8 9; do
+       for d2 in 0 1 2 3 4 5 6 7 8 9; do
+          for d3 in 0 1 2 3 4 5 6 7 8 9; do
+             NUM="${d1}${d2}${d3}"
+	     TS="(date_trunc('years',now())+'${NUM} days'::interval)"
+	     echo "insert into table1(ts, tsz, ds) values ($TS, $TS, $TS);" >> $GENDATA
+	  done
+       done
+     done     
+  done
+  status "done"
+}
+
+do_initdata()
+{
+   originnode=${ORIGINNODE:-"1"}
+  eval db=\$DB${originnode}
+   eval host=\$HOST${originnode}
+  eval user=\$USER${originnode}
+  eval port=\$PORT${originnode}
+  generate_initdata
+  launch_poll
+  status "loading data from $mktmp/generate.data"
+  $pgbindir/psql -h $host -p $port -d $db -U $user < $mktmp/generate.data 1> $mktmp/initdata.log 2> $mktmp/initdata.log
+  if [ $? -ne 0 ]; then
+    warn 3 "do_initdata failed, see $mktmp/initdata.log for details"
+  fi 
+  status "done"
+}
--- /dev/null
+++ tests/testdatestyles/schema.diff
@@ -0,0 +1 @@
+SELECT id,ts,tsz,ds,nowts,nowtsz,nowds FROM table1 ORDER BY id
--- /dev/null
+++ tests/testdatestyles/README
@@ -0,0 +1,4 @@
+$Id: README,v 1.1 2006/06/23 15:37:57 cbbrowne Exp $
+
+This test involves submitting date and timestamps in various DATESTYLE
+forms, and verifying that all load in properly.
\ No newline at end of file



More information about the Slony1-commit mailing list