CVS User Account cvsuser
Tue Nov 15 21:26:09 PST 2005
Log Message:
-----------
Take a bunch of tests out of test1, and generate several whole new
tests:
 - testschemanames, which tortures schema names
 - testseqnames, torturing sequence names
 - testtabnames, torturing table names
 - testutf8, replicating multibyte data

Modified Files:
--------------
    slony1-engine/tests/test1:
        generate_dml.sh (r1.2 -> r1.3)
        init_add_tables.ik (r1.3 -> r1.4)
        init_schema.sql (r1.2 -> r1.3)
        schema.diff (r1.2 -> r1.3)

Added Files:
-----------
    slony1-engine/tests/testschemanames:
        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)
    slony1-engine/tests/testseqnames:
        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)
    slony1-engine/tests/testtabnames:
        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)
    slony1-engine/tests/testutf8:
        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/testseqnames/init_add_tables.ik
@@ -0,0 +1,9 @@
+set add table (id=1, set id=1, origin=1, fully qualified name = 'public.table1', comment='accounts table');
+set add table (id=2, set id=1, origin=1, fully qualified name = 'public.table2', key='table2_id_key');
+table add key (node id = 1, fully qualified name = 'public.table3');
+set add table (id=3, set id=1, origin=1, fully qualified name = 'public.table3', key = SERIAL);
+set add sequence (set id = 1, origin = 1, id = 1, fully qualified name = 'public."Evil Spacey Sequence Name"');
+
+set add sequence (set id = 1, origin = 1, id = 2, fully qualified name = '"Studly Spacey Schema"."user"');
+
+set add sequence (set id = 1, origin = 1, id = 3, fully qualified name = '"Schema.name"."a.periodic.sequence"');
--- /dev/null
+++ tests/testseqnames/init_cluster.ik
@@ -0,0 +1 @@
+init cluster (id=1, comment = 'Regress test node');
--- /dev/null
+++ tests/testseqnames/init_data.sql
@@ -0,0 +1,3 @@
+INSERT INTO table1(data) VALUES ('placeholder 1');
+INSERT INTO table2(table1_id,data) VALUES (1,'placeholder 1');
+INSERT INTO table3(table2_id) VALUES (1);
--- /dev/null
+++ tests/testseqnames/init_schema.sql
@@ -0,0 +1,27 @@
+CREATE TABLE table1(
+  id		SERIAL		PRIMARY KEY, 
+  data		TEXT
+);
+
+CREATE TABLE table2(
+  id		SERIAL		UNIQUE NOT NULL, 
+  table1_id	INT4		REFERENCES table1(id) 
+					ON UPDATE CASCADE ON DELETE CASCADE, 
+  data		TEXT
+);
+
+CREATE TABLE table3(
+  id		SERIAL,
+  table2_id	INT4		REFERENCES table2(id)
+					ON UPDATE SET NULL ON DELETE SET NULL,
+  mod_date	TIMESTAMPTZ	NOT NULL DEFAULT now(),
+  data		FLOAT		NOT NULL DEFAULT random()
+  CONSTRAINT table3_date_check	CHECK (mod_date <= now())
+); 
+
+-- Create some Evil names...
+create schema "Schema.name";
+create schema "Studly Spacey Schema";
+create sequence public."Evil Spacey Sequence Name";
+create sequence "Studly Spacey Schema"."user";
+create sequence "Schema.name"."a.periodic.sequence";
--- /dev/null
+++ tests/testseqnames/settings.ik
@@ -0,0 +1,4 @@
+NUMCLUSTERS=${NUMCLUSTERS:-"1"}
+NUMNODES=${NUMNODES:-"2"}
+ORIGINNODE=1
+WORKERS=${WORKERS:-"1"}
--- /dev/null
+++ tests/testseqnames/init_subscribe_set.ik
@@ -0,0 +1 @@
+subscribe set (id = 1, provider = 1, receiver = 2, forward = no);
--- /dev/null
+++ tests/testseqnames/init_create_set.ik
@@ -0,0 +1 @@
+create set (id=1, origin=1, comment='All test1 tables');
--- /dev/null
+++ tests/testseqnames/generate_dml.sh
@@ -0,0 +1,75 @@
+. support_funcs.sh
+
+init_dml()
+{
+  echo "init_dml()"
+}
+
+begin()
+{
+  echo "begin()"
+}
+
+rollback()
+{
+  echo "rollback()"
+}
+
+commit()
+{
+  echo "commit()"
+}
+
+generate_initdata()
+{
+  numrows=$(random_number 50 1000)
+  i=0;
+  trippoint=`expr $numrows / 20`
+  j=0;
+  percent=0
+  status "generating ${numrows} tranactions of random data"
+  percent=`expr $j \* 5`
+  status "$percent %"
+  while : ; do
+    txtalen=$(random_number 1 100)
+    txta=$(random_string ${txtalen})
+    txta=`echo ${txta} | sed -e "s/\\\\\\\/\\\\\\\\\\\\\\/g" -e "s/'/''/g"`
+    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
+    echo "select nextval('\"Schema.name\".\"a.periodic.sequence\"');" >> $GENDATA
+    echo "select nextval('\"Studly Spacey Schema\".\"user\"');" >> $GENDATA
+    if [ ${i} -ge ${numrows} ]; then
+      break;
+    else
+      i=$((${i} +1))
+      working=`expr $i % $trippoint`
+      if [ $working -eq 0 ]; then
+        j=`expr $j + 1`
+        percent=`expr $j \* 5`
+        status "$percent %"
+      fi 
+    fi
+  done
+  status "done"
+}
+
+do_initdata()
+{
+   originnode=${ORIGINNODE:-"1"}
+  eval db=\$DB${originnode}
+   eval host=\$HOST${originnode}
+  eval user=\$USER${originnode}
+  generate_initdata
+  launch_poll
+  status "loading data"
+  $pgbindir/psql -h $host $db $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/testseqnames/schema.diff
@@ -0,0 +1,5 @@
+SELECT id,data FROM table1 ORDER BY id
+SELECT id,table1_id,data FROM table2 ORDER BY id
+SELECT id,table2_id,mod_date, data FROM table3 ORDER BY id
+select last_value from "Studly Spacey Schema"."user"
+select last_value from "Schema.name"."a.periodic.sequence"
\ No newline at end of file
--- /dev/null
+++ tests/testseqnames/README
@@ -0,0 +1,4 @@
+$Id: README,v 1.1 2005/11/15 21:25:34 cbbrowne Exp $
+
+This test involves creating some sequences with wacky names involving
+StudlyCaps, spaces, and ".".
--- /dev/null
+++ tests/testtabnames/init_add_tables.ik
@@ -0,0 +1,14 @@
+set add table (id=1, set id=1, origin=1, fully qualified name = 'public.table1', comment='accounts table');
+set add table (id=2, set id=1, origin=1, fully qualified name = 'public.table2', key='table2_id_key');
+table add key (node id = 1, fully qualified name = 'public.table3');
+set add table (id=3, set id=1, origin=1, fully qualified name = 'public.table3', key = SERIAL);
+
+set add table (set id = 1, origin = 1, id = 5, fully qualified name =
+'public.evil_index_table', key = 'user', comment = 'Table with evil index name');
+
+set add table (set id = 1, origin = 1, id = 6, fully qualified name =
+'"Schema.name".user', comment = 'Table with evil name - user, and a field called user');
+
+set add table (set id = 1, origin = 1, id = 7, fully qualified name =
+'"Schema.name"."Capital Idea"', comment = 'Table with spaces in its name, caps, and a user field as PK');
+
--- /dev/null
+++ tests/testtabnames/init_cluster.ik
@@ -0,0 +1 @@
+init cluster (id=1, comment = 'Regress test node');
--- /dev/null
+++ tests/testtabnames/init_data.sql
@@ -0,0 +1,3 @@
+INSERT INTO table1(data) VALUES ('placeholder 1');
+INSERT INTO table2(table1_id,data) VALUES (1,'placeholder 1');
+INSERT INTO table3(table2_id) VALUES (1);
--- /dev/null
+++ tests/testtabnames/init_schema.sql
@@ -0,0 +1,42 @@
+CREATE TABLE table1(
+  id		SERIAL		PRIMARY KEY, 
+  data		TEXT
+);
+
+CREATE TABLE table2(
+  id		SERIAL		UNIQUE NOT NULL, 
+  table1_id	INT4		REFERENCES table1(id) 
+					ON UPDATE CASCADE ON DELETE CASCADE, 
+  data		TEXT
+);
+
+CREATE TABLE table3(
+  id		SERIAL,
+  table2_id	INT4		REFERENCES table2(id)
+					ON UPDATE SET NULL ON DELETE SET NULL,
+  mod_date	TIMESTAMPTZ	NOT NULL DEFAULT now(),
+  data		FLOAT		NOT NULL DEFAULT random()
+  CONSTRAINT table3_date_check	CHECK (mod_date <= now())
+); 
+
+-- Create some Evil names...
+create schema "Schema.name";
+create schema "Studly Spacey Schema";
+create table "Schema.name"."user" (
+  id integer,
+  "user" text not null unique,
+  primary key (id)
+);
+
+create table "Schema.name"."Capital Idea" (
+  "user" text,
+  description text,
+  primary key("user")
+);
+
+create table public.evil_index_table (
+  id integer not null,
+  name text not null,
+  "eViL StudlyCaps column" text
+);
+create unique index "user" on public.evil_index_table(id);
--- /dev/null
+++ tests/testtabnames/settings.ik
@@ -0,0 +1,4 @@
+NUMCLUSTERS=${NUMCLUSTERS:-"1"}
+NUMNODES=${NUMNODES:-"2"}
+ORIGINNODE=1
+WORKERS=${WORKERS:-"1"}
--- /dev/null
+++ tests/testtabnames/init_subscribe_set.ik
@@ -0,0 +1 @@
+subscribe set (id = 1, provider = 1, receiver = 2, forward = no);
--- /dev/null
+++ tests/testtabnames/init_create_set.ik
@@ -0,0 +1 @@
+create set (id=1, origin=1, comment='All test1 tables');
--- /dev/null
+++ tests/testtabnames/generate_dml.sh
@@ -0,0 +1,76 @@
+. support_funcs.sh
+
+init_dml()
+{
+  echo "init_dml()"
+}
+
+begin()
+{
+  echo "begin()"
+}
+
+rollback()
+{
+  echo "rollback()"
+}
+
+commit()
+{
+  echo "commit()"
+}
+
+generate_initdata()
+{
+  numrows=$(random_number 50 1000)
+  i=0;
+  trippoint=`expr $numrows / 20`
+  j=0;
+  percent=0
+  status "generating ${numrows} tranactions of random data"
+  percent=`expr $j \* 5`
+  status "$percent %"
+  while : ; do
+    txtalen=$(random_number 1 100)
+    txta=$(random_string ${txtalen})
+    txta=`echo ${txta} | sed -e "s/\\\\\\\/\\\\\\\\\\\\\\/g" -e "s/'/''/g"`
+    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
+    echo "INSERT INTO \"Schema.name\".\"Capital Idea\" (\"user\", description) values ('${txta}', '${txtb}');" >> $GENDATA
+    echo "INSERT INTO \"Schema.name\".\"user\" (\"user\", id) values ('${txtb}', $txtblen);" >> $GENDATA
+    echo "INSERT INTO public.evil_index_table (id, name, \"eViL StudlyCaps column\") values (${txtblen}, '${txta}', '${txtb}');" >> $GENDATA
+    if [ ${i} -ge ${numrows} ]; then
+      break;
+    else
+      i=$((${i} +1))
+      working=`expr $i % $trippoint`
+      if [ $working -eq 0 ]; then
+        j=`expr $j + 1`
+        percent=`expr $j \* 5`
+        status "$percent %"
+      fi 
+    fi
+  done
+  status "done"
+}
+
+do_initdata()
+{
+   originnode=${ORIGINNODE:-"1"}
+  eval db=\$DB${originnode}
+   eval host=\$HOST${originnode}
+  eval user=\$USER${originnode}
+  generate_initdata
+  launch_poll
+  status "loading data"
+  $pgbindir/psql -h $host $db $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/testtabnames/schema.diff
@@ -0,0 +1,6 @@
+SELECT id,data FROM table1 ORDER BY id
+SELECT id,table1_id,data FROM table2 ORDER BY id
+SELECT id,table2_id,mod_date, data FROM table3 ORDER BY id
+SELECT id, "user" from "Schema.name"."user" order by id
+SELECT "user", description from "Schema.name"."Capital Idea" order by "user"
+SELECT id, name, "eViL StudlyCaps column" from public.evil_index_table order by id
\ No newline at end of file
--- /dev/null
+++ tests/testtabnames/README
@@ -0,0 +1,4 @@
+$Id: README,v 1.1 2005/11/15 21:25:35 cbbrowne Exp $
+
+Create some Wacky Table Names involving spaces, StudlyCaps, as well as
+the reserved name, "user".
Index: init_add_tables.ik
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tests/test1/init_add_tables.ik,v
retrieving revision 1.3
retrieving revision 1.4
diff -Ltests/test1/init_add_tables.ik -Ltests/test1/init_add_tables.ik -u -w -r1.3 -r1.4
--- tests/test1/init_add_tables.ik
+++ tests/test1/init_add_tables.ik
@@ -2,19 +2,3 @@
 set add table (id=2, set id=1, origin=1, fully qualified name = 'public.table2', key='table2_id_key');
 table add key (node id = 1, fully qualified name = 'public.table3');
 set add table (id=3, set id=1, origin=1, fully qualified name = 'public.table3', key = SERIAL);
-set add table (id=4, set id=1, origin=1, fully qualified name = 'public.utf8table', comment='Test table for multibyte/UTF8');
-
-set add table (set id = 1, origin = 1, id = 5, fully qualified name =
-'public.evil_index_table', key = 'user', comment = 'Table with evil index name');
-
-set add table (set id = 1, origin = 1, id = 6, fully qualified name =
-'"Schema.name".user', comment = 'Table with evil name - user, and a field called user');
-
-set add table (set id = 1, origin = 1, id = 7, fully qualified name =
-'"Schema.name"."Capital Idea"', comment = 'Table with spaces in its name, caps, and a user field as PK');
-
-set add sequence (set id = 1, origin = 1, id = 1, fully qualified name = 'public."Evil Spacey Sequence Name"');
-
-set add sequence (set id = 1, origin = 1, id = 2, fully qualified name = '"Studly Spacey Schema"."user"');
-
-set add sequence (set id = 1, origin = 1, id = 3, fully qualified name = '"Schema.name"."a.periodic.sequence"');
Index: generate_dml.sh
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tests/test1/generate_dml.sh,v
retrieving revision 1.2
retrieving revision 1.3
diff -Ltests/test1/generate_dml.sh -Ltests/test1/generate_dml.sh -u -w -r1.2 -r1.3
--- tests/test1/generate_dml.sh
+++ tests/test1/generate_dml.sh
@@ -41,11 +41,6 @@
     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
-    echo "INSERT INTO utf8table (string) values ('${txtb} - \303\241');" >> $GENDATA
-    echo "INSERT INTO utf8table (string) values ('${txtb} -- \303\241');" >> $GENDATA
-    echo "INSERT INTO \"Schema.name\".\"Capital Idea\" (\"user\", description) values ('${txta}', '${txtb}');" >> $GENDATA
-    echo "INSERT INTO \"Schema.name\".\"user\" (\"user\", id) values ('${txtb}', $txtblen);" >> $GENDATA
-    echo "INSERT INTO public.evil_index_table (id, name, \"eViL StudlyCaps column\") values (${txtblen}, '${txta}', '${txtb}');" >> $GENDATA
     if [ ${i} -ge ${numrows} ]; then
       break;
     else
Index: schema.diff
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tests/test1/schema.diff,v
retrieving revision 1.2
retrieving revision 1.3
diff -Ltests/test1/schema.diff -Ltests/test1/schema.diff -u -w -r1.2 -r1.3
--- tests/test1/schema.diff
+++ tests/test1/schema.diff
@@ -1,7 +1,3 @@
 SELECT id,data FROM table1 ORDER BY id
 SELECT id,table1_id,data FROM table2 ORDER BY id
 SELECT id,table2_id,mod_date, data FROM table3 ORDER BY id
-SELECT id, string from utf8table order by id
-SELECT id, "user" from "Schema.name"."user" order by id
-SELECT "user", description from "Schema.name"."Capital Idea" order by "user"
-SELECT id, name, "eViL StudlyCaps column" from public.evil_index_table order by id
\ No newline at end of file
Index: init_schema.sql
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tests/test1/init_schema.sql,v
retrieving revision 1.2
retrieving revision 1.3
diff -Ltests/test1/init_schema.sql -Ltests/test1/init_schema.sql -u -w -r1.2 -r1.3
--- tests/test1/init_schema.sql
+++ tests/test1/init_schema.sql
@@ -19,39 +19,3 @@
   CONSTRAINT table3_date_check	CHECK (mod_date <= now())
 ); 
 
--- Table to perform UTF8 tests (checks multibyte; should be helpful in
--- preventing problems with Asian character sets too)
-create table utf8table (
-    id integer not null unique default nextval('utf8_id'),
-    string text,
-    primary key(id)
-);
-
-create sequence utf8_id;
-INSERT INTO utf8table (string) VALUES ('1b\303\241r') ;
-create sequence foo_id;
-
--- Create some Evil names...
-create schema "Schema.name";
-create schema "Studly Spacey Schema";
-create table "Schema.name"."user" (
-  id integer,
-  "user" text not null unique,
-  primary key (id)
-);
-
-create table "Schema.name"."Capital Idea" (
-  "user" text,
-  description text,
-  primary key("user")
-);
-
-create table public.evil_index_table (
-  id integer not null,
-  name text not null,
-  "eViL StudlyCaps column" text
-);
-create unique index "user" on public.evil_index_table(id);
-create sequence public."Evil Spacey Sequence Name";
-create sequence "Studly Spacey Schema"."user";
-create sequence "Schema.name"."a.periodic.sequence";
--- /dev/null
+++ tests/testschemanames/init_add_tables.ik
@@ -0,0 +1,14 @@
+set add table (id=1, set id=1, origin=1, fully qualified name = 'public.table1', comment='accounts table');
+set add table (id=2, set id=1, origin=1, fully qualified name = 'public.table2', key='table2_id_key');
+table add key (node id = 1, fully qualified name = 'public.table3');
+set add table (id=3, set id=1, origin=1, fully qualified name = 'public.table3', key = SERIAL);
+
+set add table (set id = 1, origin = 1, id = 6, fully qualified name =
+'"Schema.name".user', comment = 'Table with evil name - user, and a field called user');
+
+set add table (set id = 1, origin = 1, id = 7, fully qualified name =
+'"Schema.name"."Capital Idea"', comment = 'Table with spaces in its name, caps, and a user field as PK');
+
+set add sequence (set id = 1, origin = 1, id = 2, fully qualified name = '"Studly Spacey Schema"."user"');
+
+set add sequence (set id = 1, origin = 1, id = 3, fully qualified name = '"Schema.name"."a.periodic.sequence"');
--- /dev/null
+++ tests/testschemanames/init_cluster.ik
@@ -0,0 +1 @@
+init cluster ( id=1, comment = 'Regress test node');
--- /dev/null
+++ tests/testschemanames/init_data.sql
@@ -0,0 +1,3 @@
+INSERT INTO table1(data) VALUES ('placeholder 1');
+INSERT INTO table2(table1_id,data) VALUES (1,'placeholder 1');
+INSERT INTO table3(table2_id) VALUES (1);
--- /dev/null
+++ tests/testschemanames/init_schema.sql
@@ -0,0 +1,38 @@
+CREATE TABLE table1(
+  id		SERIAL		PRIMARY KEY, 
+  data		TEXT
+);
+
+CREATE TABLE table2(
+  id		SERIAL		UNIQUE NOT NULL, 
+  table1_id	INT4		REFERENCES table1(id) 
+					ON UPDATE CASCADE ON DELETE CASCADE, 
+  data		TEXT
+);
+
+CREATE TABLE table3(
+  id		SERIAL,
+  table2_id	INT4		REFERENCES table2(id)
+					ON UPDATE SET NULL ON DELETE SET NULL,
+  mod_date	TIMESTAMPTZ	NOT NULL DEFAULT now(),
+  data		FLOAT		NOT NULL DEFAULT random()
+  CONSTRAINT table3_date_check	CHECK (mod_date <= now())
+); 
+
+-- Create some Evil names...
+create schema "Schema.name";
+create schema "Studly Spacey Schema";
+create table "Schema.name"."user" (
+  id integer,
+  "user" text not null unique,
+  primary key (id)
+);
+
+create table "Schema.name"."Capital Idea" (
+  "user" text,
+  description text,
+  primary key("user")
+);
+
+create sequence "Studly Spacey Schema"."user";
+create sequence "Schema.name"."a.periodic.sequence";
--- /dev/null
+++ tests/testschemanames/settings.ik
@@ -0,0 +1,4 @@
+NUMCLUSTERS=${NUMCLUSTERS:-"1"}
+NUMNODES=${NUMNODES:-"2"}
+ORIGINNODE=1
+WORKERS=${WORKERS:-"1"}
--- /dev/null
+++ tests/testschemanames/init_subscribe_set.ik
@@ -0,0 +1 @@
+subscribe set ( id = 1, provider = 1, receiver = 2, forward = no);
--- /dev/null
+++ tests/testschemanames/init_create_set.ik
@@ -0,0 +1 @@
+create set (id=1, origin=1, comment='All test1 tables');
--- /dev/null
+++ tests/testschemanames/generate_dml.sh
@@ -0,0 +1,77 @@
+. support_funcs.sh
+
+init_dml()
+{
+  echo "init_dml()"
+}
+
+begin()
+{
+  echo "begin()"
+}
+
+rollback()
+{
+  echo "rollback()"
+}
+
+commit()
+{
+  echo "commit()"
+}
+
+generate_initdata()
+{
+  numrows=$(random_number 50 1000)
+  i=0;
+  trippoint=`expr $numrows / 20`
+  j=0;
+  percent=0
+  status "generating ${numrows} tranactions of random data"
+  percent=`expr $j \* 5`
+  status "$percent %"
+  while : ; do
+    txtalen=$(random_number 1 100)
+    txta=$(random_string ${txtalen})
+    txta=`echo ${txta} | sed -e "s/\\\\\\\/\\\\\\\\\\\\\\/g" -e "s/'/''/g"`
+    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
+    echo "INSERT INTO \"Schema.name\".\"Capital Idea\" (\"user\", description) values ('${txta}', '${txtb}');" >> $GENDATA
+    echo "INSERT INTO \"Schema.name\".\"user\" (\"user\", id) values ('${txtb}', $txtblen);" >> $GENDATA
+    echo "select nextval('\"Schema.name\".\"a.periodic.sequence\"');" >> $GENDATA
+    echo "select nextval('\"Studly Spacey Schema\".\"user\"');" >> $GENDATA
+    if [ ${i} -ge ${numrows} ]; then
+      break;
+    else
+      i=$((${i} +1))
+      working=`expr $i % $trippoint`
+      if [ $working -eq 0 ]; then
+        j=`expr $j + 1`
+        percent=`expr $j \* 5`
+        status "$percent %"
+      fi 
+    fi
+  done
+  status "done"
+}
+
+do_initdata()
+{
+   originnode=${ORIGINNODE:-"1"}
+  eval db=\$DB${originnode}
+   eval host=\$HOST${originnode}
+  eval user=\$USER${originnode}
+  generate_initdata
+  launch_poll
+  status "loading data"
+  $pgbindir/psql -h $host $db $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/testschemanames/schema.diff
@@ -0,0 +1,7 @@
+SELECT id,data FROM table1 ORDER BY id
+SELECT id,table1_id,data FROM table2 ORDER BY id
+SELECT id,table2_id,mod_date, data FROM table3 ORDER BY id
+SELECT id, "user" from "Schema.name"."user" order by id
+SELECT "user", description from "Schema.name"."Capital Idea" order by "user"
+select last_value from "Studly Spacey Schema"."user"
+select last_value from "Schema.name"."a.periodic.sequence"
\ No newline at end of file
--- /dev/null
+++ tests/testschemanames/README
@@ -0,0 +1,4 @@
+$Id: README,v 1.1 2005/11/15 21:25:34 cbbrowne Exp $
+
+This test involves creating tables and sequences in namespaces with
+some wacky names, with StudlyCaps, spaces, and ".".
--- /dev/null
+++ tests/testutf8/init_add_tables.ik
@@ -0,0 +1,5 @@
+set add table (id=1, set id=1, origin=1, fully qualified name = 'public.table1', comment='accounts table');
+set add table (id=2, set id=1, origin=1, fully qualified name = 'public.table2', key='table2_id_key');
+table add key (node id = 1, fully qualified name = 'public.table3');
+set add table (id=3, set id=1, origin=1, fully qualified name = 'public.table3', key = SERIAL);
+set add table (id=4, set id=1, origin=1, fully qualified name = 'public.utf8table', comment='Test table for multibyte/UTF8');
--- /dev/null
+++ tests/testutf8/init_cluster.ik
@@ -0,0 +1 @@
+init cluster (id=1, comment = 'Regress test node');
--- /dev/null
+++ tests/testutf8/init_data.sql
@@ -0,0 +1,3 @@
+INSERT INTO table1(data) VALUES ('placeholder 1');
+INSERT INTO table2(table1_id,data) VALUES (1,'placeholder 1');
+INSERT INTO table3(table2_id) VALUES (1);
--- /dev/null
+++ tests/testutf8/init_schema.sql
@@ -0,0 +1,31 @@
+CREATE TABLE table1(
+  id		SERIAL		PRIMARY KEY, 
+  data		TEXT
+);
+
+CREATE TABLE table2(
+  id		SERIAL		UNIQUE NOT NULL, 
+  table1_id	INT4		REFERENCES table1(id) 
+					ON UPDATE CASCADE ON DELETE CASCADE, 
+  data		TEXT
+);
+
+CREATE TABLE table3(
+  id		SERIAL,
+  table2_id	INT4		REFERENCES table2(id)
+					ON UPDATE SET NULL ON DELETE SET NULL,
+  mod_date	TIMESTAMPTZ	NOT NULL DEFAULT now(),
+  data		FLOAT		NOT NULL DEFAULT random()
+  CONSTRAINT table3_date_check	CHECK (mod_date <= now())
+); 
+
+-- Table to perform UTF8 tests (checks multibyte; should be helpful in
+-- preventing problems with Asian character sets too)
+create table utf8table (
+    id integer not null unique default nextval('utf8_id'),
+    string text,
+    primary key(id)
+);
+
+create sequence utf8_id;
+INSERT INTO utf8table (string) VALUES ('1b\303\241r') ;
--- /dev/null
+++ tests/testutf8/settings.ik
@@ -0,0 +1,4 @@
+NUMCLUSTERS=${NUMCLUSTERS:-"1"}
+NUMNODES=${NUMNODES:-"2"}
+ORIGINNODE=1
+WORKERS=${WORKERS:-"1"}
--- /dev/null
+++ tests/testutf8/init_subscribe_set.ik
@@ -0,0 +1 @@
+subscribe set (id = 1, provider = 1, receiver = 2, forward = no);
--- /dev/null
+++ tests/testutf8/init_create_set.ik
@@ -0,0 +1 @@
+create set (id=1, origin=1, comment='All test1 tables');
--- /dev/null
+++ tests/testutf8/generate_dml.sh
@@ -0,0 +1,75 @@
+. support_funcs.sh
+
+init_dml()
+{
+  echo "init_dml()"
+}
+
+begin()
+{
+  echo "begin()"
+}
+
+rollback()
+{
+  echo "rollback()"
+}
+
+commit()
+{
+  echo "commit()"
+}
+
+generate_initdata()
+{
+  numrows=$(random_number 50 1000)
+  i=0;
+  trippoint=`expr $numrows / 20`
+  j=0;
+  percent=0
+  status "generating ${numrows} tranactions of random data"
+  percent=`expr $j \* 5`
+  status "$percent %"
+  while : ; do
+    txtalen=$(random_number 1 100)
+    txta=$(random_string ${txtalen})
+    txta=`echo ${txta} | sed -e "s/\\\\\\\/\\\\\\\\\\\\\\/g" -e "s/'/''/g"`
+    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
+    echo "INSERT INTO utf8table (string) values ('${txtb} - \303\241');" >> $GENDATA
+    echo "INSERT INTO utf8table (string) values ('${txtb} -- \303\241');" >> $GENDATA
+    if [ ${i} -ge ${numrows} ]; then
+      break;
+    else
+      i=$((${i} +1))
+      working=`expr $i % $trippoint`
+      if [ $working -eq 0 ]; then
+        j=`expr $j + 1`
+        percent=`expr $j \* 5`
+        status "$percent %"
+      fi 
+    fi
+  done
+  status "done"
+}
+
+do_initdata()
+{
+   originnode=${ORIGINNODE:-"1"}
+  eval db=\$DB${originnode}
+   eval host=\$HOST${originnode}
+  eval user=\$USER${originnode}
+  generate_initdata
+  launch_poll
+  status "loading data"
+  $pgbindir/psql -h $host $db $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/testutf8/schema.diff
@@ -0,0 +1,4 @@
+SELECT id,data FROM table1 ORDER BY id
+SELECT id,table1_id,data FROM table2 ORDER BY id
+SELECT id,table2_id,mod_date, data FROM table3 ORDER BY id
+SELECT id, string from utf8table order by id
--- /dev/null
+++ tests/testutf8/README
@@ -0,0 +1,4 @@
+$Id: README,v 1.1 2005/11/15 21:25:36 cbbrowne Exp $
+
+This test involves creating databases in UNICODE form, and stowing
+UTF-8 values in a relevant table.


More information about the Slony1-commit mailing list