Fix bug in set add sequence(set id=1, sequences='test\\.seq*');
authorSteve Singer <steve@ssinger.info>
Wed, 1 Aug 2018 19:13:46 +0000 (15:13 -0400)
committerSteve Singer <steve@ssinger.info>
Wed, 1 Aug 2018 19:13:46 +0000 (15:13 -0400)
where the regex esacping for sequences was not working like
it did for tables in 'set add table'.

clustertest/regression/testregexadd/README [new file with mode: 0644]
clustertest/regression/testregexadd/init_add_tables.ik [new file with mode: 0644]
clustertest/regression/testregexadd/testregexadd.js [new file with mode: 0644]
clustertest/run_all_regression_tests.sh
src/slonik/slonik.c

diff --git a/clustertest/regression/testregexadd/README b/clustertest/regression/testregexadd/README
new file mode 100644 (file)
index 0000000..95ab9f6
--- /dev/null
@@ -0,0 +1 @@
+Test adding sequences with regexes
diff --git a/clustertest/regression/testregexadd/init_add_tables.ik b/clustertest/regression/testregexadd/init_add_tables.ik
new file mode 100644 (file)
index 0000000..0d554a3
--- /dev/null
@@ -0,0 +1 @@
+set add sequence(set id=1, sequences='test\\.seq*');
diff --git a/clustertest/regression/testregexadd/testregexadd.js b/clustertest/regression/testregexadd/testregexadd.js
new file mode 100644 (file)
index 0000000..29cfc99
--- /dev/null
@@ -0,0 +1,102 @@
+var NUM_NODES=2;
+coordinator.includeFile('regression/common_tests.js');
+
+function get_schema() {
+       var sqlScript = coordinator.readFile('regression/testregexadd/init_schema.sql');
+       return sqlScript;
+       
+}
+function load_data(coordinator) {
+       var sqlScript = coordinator.readFile('regression/testregexadd/init_data.sql');
+       psql = coordinator.createPsqlCommand('db1',sqlScript);
+       psql.run();
+       coordinator.join(psql);
+       
+       
+}
+
+function init_cluster() {
+       return 'init cluster(id=1, comment=\'Regress test node\');\n';
+                       
+}
+
+
+function init_tables() {
+       var script=     coordinator.readFile('regression/testregexadd/init_add_tables.ik');
+
+       return script;
+}
+       
+
+
+function create_set() {
+       return 'create set (id=1, origin=1,comment=\'All test1 tables\'); \n';
+
+}
+
+function subscribe_set() {
+       var script=     "subscribe set (id = 1, provider = 1, receiver = 2, forward = no);\n";
+       return script;
+}
+
+
+
+function generate_data_file(coordinator) {
+
+       var file = java.io.File.createTempFile("testdata",".sql");
+       file.deleteOnExit();
+       var fileWriter = new java.io.FileWriter(file);
+       fileWriter.write("select nextval('test.seq1');");
+       fileWriter.write("select nextval('testx.seq1');");
+       fileWriter.close();
+       return file;
+}
+
+/**
+ * advance the sequence on the second node.
+ * We need the sequence values to be equal to
+ * pass the compare. Hopefully changes to the second
+ * sequence were not replicated.
+ */
+function second_sequence_advance(coordinator) {
+       var file = java.io.File.createTempFile("testdata2",".sql");
+       file.deleteOnExit();
+       var fileWriter = new java.io.FileWriter(file);
+       //advance once from the init script and once from the generate_data_file
+       fileWriter.write("select nextval('testx.seq1');");
+       fileWriter.write("select nextval('testx.seq1');");
+       fileWriter.close();
+       psql = coordinator.createPsqlCommand('db2',file);
+       psql.run();
+       coordinator.join(psql);
+               
+}
+
+function do_test(coordinator) {
+       
+       var sqlScript='';
+       //Compare the initial states.
+       //They should match since this is an omit_copy test.
+       do_compare(coordinator);
+       var file = generate_data_file(coordinator);
+       
+       psql = coordinator.createPsqlCommand('db1',file);
+       psql.run();
+       coordinator.join(psql);
+       wait_for_sync(coordinator);
+       second_sequence_advance(coordinator);
+       coordinator.log("done");
+}
+
+function get_compare_queries() {
+       
+
+       var queries=["SELECT 1 as id, last_value from testx.seq1",
+                                "SELECT 1 as id, last_value from test.seq1 "
+                   ];
+
+       return queries;
+}
+
+run_test(coordinator,'testregexadd');
index 930cbef241b6b46b89e5eaa690181394887f5cee..d3b3c52d712fad37a854a7d9e97b12d7a0ef3abc 100755 (executable)
@@ -19,4 +19,4 @@ else
     exit 1
 fi    
 
-java -jar ${CLUSTERTESTJAR} ${DBP} ./regression/test1/test1.js ./regression/testdatestyles/testdatestyles.js ./regression/testddl/testddl.js ./regression/testdeadlockddl/testdeadlockddl.js ./regression/testinherit/testinherit.js ./regression/testlargetuples/testlargetuples.js ./regression/testmergeset/testmergeset.js ./regression/testmultipaths/testmultipaths.js ./regression/testmultiplemoves/testmultiplemoves.js ./regression/testomitcopy/testomitcopy.js ./regression/testschemanames/testschemanames.js ./regression/testseqnames/testseqnames.js ./regression/testtabnames/testtabnames.js ./regression/testutf8/testutf8.js ./regression/testtruncate/testtruncate.js
+java -jar ${CLUSTERTESTJAR} ${DBP} ./regression/test1/test1.js ./regression/testdatestyles/testdatestyles.js ./regression/testddl/testddl.js ./regression/testdeadlockddl/testdeadlockddl.js ./regression/testinherit/testinherit.js ./regression/testlargetuples/testlargetuples.js ./regression/testmergeset/testmergeset.js ./regression/testmultipaths/testmultipaths.js ./regression/testmultiplemoves/testmultiplemoves.js ./regression/testomitcopy/testomitcopy.js ./regression/testschemanames/testschemanames.js ./regression/testseqnames/testseqnames.js ./regression/testtabnames/testtabnames.js ./regression/testutf8/testutf8.js ./regression/testtruncate/testtruncate.js ./regression/testregexadd/testregexadd.js
index bd125707b6ddc6ecd32e30f2a08594a3d4d998d9..78235f45f2a72659eb022ed387197fdf552d5bad 100644 (file)
@@ -4378,7 +4378,7 @@ slonik_set_add_sequence(SlonikStmt_set_add_sequence * stmt)
                 */
                slon_mkquery(&query, "select sequence_schema || '.' || sequence_name "
                                         "from information_schema.sequences where "
-                                        "sequence_schema || '.'||sequence_name ~ '%s' "
+                                        "sequence_schema || '.'||sequence_name ~ E'%s' "
                                         "order by 1", stmt->sequences);
                result = db_exec_select((SlonikStmt *) stmt, adminfo1, &query);
                if (result == NULL)