Skip to content
This repository was archived by the owner on Jul 11, 2021. It is now read-only.

Commit 3dc7cf2

Browse files
committed
add REDISQL.V2.STATEMENT db LIST NOW
1 parent f94358d commit 3dc7cf2

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/v2/statement.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use parser::statement::Statement;
55
use redisql_lib::redis as r;
66
use redisql_lib::redis::LoopData;
77
use redisql_lib::redis::RedisReply;
8+
use redisql_lib::redis::ReturnMethod;
9+
use redisql_lib::redis::Returner;
810
use redisql_lib::redis::StatementCache;
911
use redisql_lib::redis_type::BlockedClient;
1012
use redisql_lib::redis_type::ReplicateVerbatim;
@@ -111,7 +113,15 @@ pub extern "C" fn Statement_v2(
111113
.list_statements();
112114
match result {
113115
Err(mut e) => e.reply_v2(&context),
114-
Ok(mut q) => q.reply_v2(&context),
116+
Ok(q) => {
117+
let mut to_return = q.create_data_to_return(
118+
&context,
119+
&ReturnMethod::ReplyWithHeader,
120+
std::time::Instant::now()
121+
+ std::time::Duration::from_secs(10),
122+
);
123+
to_return.reply_v2(&context)
124+
}
115125
}
116126
}
117127
_ => todo!(),

test/correctness/test_v2.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,15 @@ def test_list_one(self):
674674
['insert_ntimes', "insert into t1 values(?1); insert into t1 values(?2); select ?3;", 3, 0],
675675
['select_all', 'SELECT * from t1', 0, 1],
676676
['select_multiples', "select ?1; select ?2; select ?3;", 3, 1]])
677+
result = self.exec_naked("REDISQL.v2.STATEMENT", "A", "LIST", "NOW")
678+
self.compare_results(result, [['RESULT'],
679+
["identifier", 'SQL', 'parameters_count', 'read_only'],
680+
['TEXT', 'TEXT', 'INT', 'INT'],
681+
['insert', 'insert into t1 values(?1);', 1, 0],
682+
['insert_twice', "insert into t1 values(?1); insert into t1 values(?1 * 10)", 1, 0],
683+
['insert_ntimes', "insert into t1 values(?1); insert into t1 values(?2); select ?3;", 3, 0],
684+
['select_all', 'SELECT * from t1', 0, 1],
685+
['select_multiples', "select ?1; select ?2; select ?3;", 3, 1]])
677686

678687

679688
if __name__ == '__main__':

0 commit comments

Comments
 (0)