summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Singer2018-08-01 19:13:46 +0000
committerSteve Singer2018-08-01 19:13:46 +0000
commit7c55e3693df87454b74fe8b413589892b1966c7c (patch)
treecf53f23c163eb9dcfb4402cb583c9b6232c5b120
parent7cf2af6f321201406eae1baf585c6bbd23745478 (diff)
Fix bug in set add sequence(set id=1, sequences='test\\.seq*');
where the regex esacping for sequences was not working like it did for tables in 'set add table'.
-rw-r--r--clustertest/regression/testregexadd/README1
-rw-r--r--clustertest/regression/testregexadd/init_add_tables.ik1
-rw-r--r--clustertest/regression/testregexadd/testregexadd.js102
-rwxr-xr-xclustertest/run_all_regression_tests.sh2
-rw-r--r--src/slonik/slonik.c2
5 files changed, 106 insertions, 2 deletions
diff --git a/clustertest/regression/testregexadd/README b/clustertest/regression/testregexadd/README
new file mode 100644
index 00000000..95ab9f64
--- /dev/null
+++ b/clustertest/regression/testregexadd/README
@@ -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
index 00000000..0d554a3b
--- /dev/null
+++ b/clustertest/regression/testregexadd/init_add_tables.ik
@@ -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
index 00000000..29cfc994
--- /dev/null
+++ b/clustertest/regression/testregexadd/testregexadd.js
@@ -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');
diff --git a/clustertest/run_all_regression_tests.sh b/clustertest/run_all_regression_tests.sh
index 930cbef2..d3b3c52d 100755
--- a/clustertest/run_all_regression_tests.sh
+++ b/clustertest/run_all_regression_tests.sh
@@ -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
diff --git a/src/slonik/slonik.c b/src/slonik/slonik.c
index bd125707..78235f45 100644
--- a/src/slonik/slonik.c
+++ b/src/slonik/slonik.c
@@ -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)