Description
Is your feature request related to a problem? Please describe.
Currently sql prompt would finish a statement and send it to back when it sees ;
character outside of a string and hit Enter
. This make it hard to write CREATE FUNCTION
with BEGIN ATOMIC...END
clause because the sql statements within the function body are not contained in a string and they all end with ;
. For example:
CREATE FUNCTION f() RETURNS INT LANGUAGE SQL
BEGIN ATOMIC
SELECT 1;
SELECT 2;
END;
Currently sql prompt would finish early when it sees the first ;
after SELECT 1
and we'd see a syntax error.
Describe the solution you'd like
We need to make sql prompt aware that it enters the BEGIN ATOMIC
context and continue the multiline statement even it sees ;
outside of a string. We could track the tokens sql seen so far to recognize the context.
Jira issue: CRDB-17401