Skip to content

Support PREPARE, EXECUTE and DEALLOCATE PREPARE to close #2863 - #3038

Open
mateuscmtropical wants to merge 2 commits into
AlaSQL:developfrom
mateuscmtropical:fix/2863-prepare-execute
Open

mateuscmtropical wants to merge 2 commits into
AlaSQL:developfrom
mateuscmtropical:fix/2863-prepare-execute

Conversation

@mateuscmtropical

Copy link
Copy Markdown
Contributor

Closes #2863

What was wrong

PREPARE name FROM 'text', EXECUTE name [USING @var, ...] and DEALLOCATE PREPARE name were parse errors.

What changed

  • The lexer reads PREPARE only in the form PREPARE name FROM, and DEALLOCATE PREPARE as one token, so prepare and deallocate still work as column names. EXECUTE already is a token (it reads as CALL), and CALL name [USING @a, ...] is added next to CALL func(). The grammar still has 282 conflicts.
  • A new Prepared statement keeps the text by name in alasql.prepared. PREPARE parses the text at once, so a syntax error shows there. The text can also come from a variable (PREPARE s FROM @q), as in MySQL.
  • EXECUTE runs the text with alasql.dexec in the current database, with the values of the USING variables as the ? parameters. Names are not case sensitive, as in MySQL.
  • EXECUTE or DEALLOCATE PREPARE of an unknown name throws "Unknown prepared statement".

Tests

test/test2863.js covers the statements from the issue, the text from a variable with two parameters, names in another case, the errors, EXECUTE func(), and columns named prepare and deallocate. The new statements are parse errors without the fix.

yarn test-only gives 2555 pass. The only failures are the 5 Test 418 cases that load files from the internet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PREPARE, EXECUTE and DEALLOCATE PREPARE are parse errors

2 participants