New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql: support anonymous compound statement #4316
Comments
Points suggested by @kostja:
|
SAVEPOINT x;
START TRANSACTION;
BEGIN NOT ATOMIC /* [NOT ATOMIC] okay? */
BEGIN /* BEGIN within BEGIN okay? */
ROLLBACK TO x; /* transaction environment is irrelevant? */
DROP TABLE t; /* Is this "last statement in a compound statement? */
END; /* semicolon mandatory? */
END;
BEGIN
END; /* Will client wait till I type END;? */
select id from t; select id from t; /* why do you think this may be bad? */
EXPLAIN 'BEGIN ... END';/* this will be supported someday? */ |
isnt this already implemented: |
Related: #4809. |
An SQL transaction may not be used from a connector without defining an extra Lua function, which will do something like: box.execute('START TRANSACTION')
for _, sql_request in ipairs(sql_requests) do
box.execute(sql_request)
end
box.execute('COMMIT') To overcome this, either this issue or #2016 should be resolved. Note: Each of those issues resolves the problem with an SQL transaction, but each of them is not purely about this. Don't consider one as a replacement of another. |
It is part of SQL/PMS standard.
It is necessary to execute multiple statements in one transaction at least until #2016 will be implemented for both vinyl and memtx. The discussion about that was initiated in #4123.
SQLite3 supports several statements with semicolons between them w/o BEGIN / END. Not sure why we're not going this way, but I suspect it may contradict with the standard.
SQLite3 grammar is the following (
input
is the root non-terminal,SEMI
is a semicolon, the version is3.29.0 2019-06-28 07:08:13 eab4297577e4d325fed4757867fc77860de7448998d86f098c8a50272e17alt1
):I verified that is works:
Tarantool grammar is the following now (2.2.0-482-g8c84932ad):
I tried to add the compound statement support to tarantool in this way:
(I don't know to be honest why it is necessary to remove END from %fallback, but my rules does not work w/o this change. It seems that the parser step into a wrong branch somewhere.)
This way it the following request gives the following assertion fail:
It is possible to avoid sql_finish_coding() calls (create a list of
cmdx
instead ofecmd
in the grammar) and it even 'works'. Resulting rows contain values from all requests in a compound statement and the metadata contains a metainfo for one of them. This is certainly invalid result. I hope that we should return result of the last statement in a compound statement.So we should first agree on syntax and then implement proper vdbe state cleaining, or results discarding, or kinda.
The text was updated successfully, but these errors were encountered: