Multiple statements first prepare and then execute
siscia opened this issue · comments
RediSQL support multiple statements in the same "EXEC", hence it is possible and correct to do something like:
REDISQL.EXEC DB "INSERT INTO foo VALUES(1,2,3); INSERT INTO bar VALUES(2,3,4);"
Which is quite convenient when mixed with BEGIN, COMMIT and ABORT instruction.
One problem is that all the statements are first prepared all together, and then executed, all together.
This works fine in the general case, but has some limitation when to prepare a statement is necessary to have execute the previous one.
This is the case for creating a table and then create an index on that table, or create a second table with references to the first one.
The fix would be to return an iterator when generating the statements, so that each statement is generate only when the previous one is already execute.
Roughly here: https://github.com/RedBeardLab/rediSQL/blob/master/redisql_lib/src/community_statement.rs#L70
However there may be concurrency issues that I have overlooked.