From f6988b4d4127f3699980cc17610929bceb81b208 Mon Sep 17 00:00:00 2001 From: Simone Mosciatti Date: Sun, 16 Jun 2019 16:41:52 +0200 Subject: [PATCH 1/3] fix possible race condition in test --- test/correctness/test.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/correctness/test.py b/test/correctness/test.py index 31f282d..573dce6 100755 --- a/test/correctness/test.py +++ b/test/correctness/test.py @@ -275,6 +275,14 @@ def test_multi_statement_multi_table_single_bind(self): result = self.exec_cmd("A", "SELECT * FROM t2 ORDER BY A;") self.assertEquals(result, [[2], [4]]) + def test_multi_statement_different_bindings(self): + with DB(self, "A"): + with Table(self, "t1", "(A INTEGER)", key = "A"): + ok = self.exec_naked("REDISQL.CREATE_STATEMENT", "A", "insert", "insert into t1 values(?1); insert into t1 values(?2 + 1); select * from t1;") + self.assertEquals(ok, "OK") + result = self.exec_naked("REDISQL.EXEC_STATEMENT", "A", "insert", "3", "8") + self.assertEquals(result, [[3], [9]]) + def test_update_statement(self): with DB(self, "A"): @@ -434,12 +442,13 @@ def test100(self): self.assertEquals(done, ["DONE", 0L]) for i in xrange(catty): self.exec_naked("HSET", "cat:" + str(i), "meow", i) + time.sleep(0.5) result = self.exec_naked("REDISQL.EXEC", "A", "SELECT * FROM cats") self.assertEquals(catty, len(result)) def test_rdb_persistency(self): - with DB(self, "A"): - done = self.exec_naked("REDISQL.EXEC", "A", "CREATE VIRTUAL TABLE cats USING REDISQL_TABLES_BRUTE_HASH(cat, meow)") + with DB(self, "Y"): + done = self.exec_naked("REDISQL.EXEC", "Y", "CREATE VIRTUAL TABLE cats USING REDISQL_TABLES_BRUTE_HASH(cat, meow)") for i in xrange(5): self.exec_naked("HSET", "cat:" + str(i), "meow", i) @@ -448,7 +457,7 @@ def test_rdb_persistency(self): pass time.sleep(0.5) - result = self.exec_naked("REDISQL.EXEC", "A", "SELECT rowid, cat, meow FROM cats") + result = self.exec_naked("REDISQL.EXEC", "Y", "SELECT rowid, cat, meow FROM cats") self.assertEquals(5, len(result)) self.assertTrue([0L, "cat:0", "0"] in result) self.assertTrue([1L, "cat:1", "1"] in result) From 1ed31c3c22699941e25d615a31a35eaa67dfa841 Mon Sep 17 00:00:00 2001 From: Simone Mosciatti Date: Sun, 16 Jun 2019 16:42:20 +0200 Subject: [PATCH 2/3] fix wrong management of paramenters in multi statements --- redisql_lib/src/community_statement.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/redisql_lib/src/community_statement.rs b/redisql_lib/src/community_statement.rs index 339cce9..2a22770 100644 --- a/redisql_lib/src/community_statement.rs +++ b/redisql_lib/src/community_statement.rs @@ -210,6 +210,7 @@ impl<'a> StatementTrait<'a> for Statement { ) } { ffi::SQLITE_OK => Ok(SQLiteOK::OK), + ffi::SQLITE_RANGE => Ok(SQLiteOK::OK), _ => Err(self.get_last_error()), } } From 7a94ae6d7e06135b5a9dbd94299fe6a89eb63868 Mon Sep 17 00:00:00 2001 From: Simone Mosciatti Date: Sun, 16 Jun 2019 17:19:43 +0200 Subject: [PATCH 3/3] add explaination comment --- redisql_lib/src/community_statement.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/redisql_lib/src/community_statement.rs b/redisql_lib/src/community_statement.rs index 2a22770..f86974a 100644 --- a/redisql_lib/src/community_statement.rs +++ b/redisql_lib/src/community_statement.rs @@ -210,6 +210,9 @@ impl<'a> StatementTrait<'a> for Statement { ) } { ffi::SQLITE_OK => Ok(SQLiteOK::OK), + + // it means that a statement requires less than $index paramenter, it is fine to just + // shortcut it to Ok. ffi::SQLITE_RANGE => Ok(SQLiteOK::OK), _ => Err(self.get_last_error()), }