Skip to content

Support MySQL system variables: @@name, SET @@name, SET GLOBAL and SET NAMES to close #2862 - #3039

Open
mateuscmtropical wants to merge 2 commits into
AlaSQL:developfrom
mateuscmtropical:fix/2862-system-variables
Open

mateuscmtropical wants to merge 2 commits into
AlaSQL:developfrom
mateuscmtropical:fix/2862-system-variables

Conversation

@mateuscmtropical

Copy link
Copy Markdown
Contributor

Closes #2862

What was wrong

MySQL's system variables were parse errors: @@name, @@session.name, SET @@name = ..., SET GLOBAL name = ..., SET SESSION name = ... and SET NAMES charset.

What changed

  • A new alasql.sysvars object holds the system variables. Names are lower case, as MySQL's are not case sensitive.
  • The lexer reads @@name and @@global.name, @@session.name or @@local.name as a SYSVAR token. It is a VarValue with a system flag, which reads alasql.sysvars and is NULL when the variable is not set.
  • SET @@name = ..., SET GLOBAL|SESSION|LOCAL|PERSIST name = ... and SET NAMES x store into alasql.sysvars. SET name = value keeps what it does today and also stores the value, so @@name reads it back as the issue asks.
  • SET GLOBAL and the others are only tokens before name =, and SET NAMES only right after SET, so global, session and names still work as column names. The grammar still has 282 conflicts.

Tests

test/test2862.js covers each form from the issue, an unknown variable, and columns named global, session and names. The new forms are parse errors without the fix.

yarn test-only gives 2556 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.

System variables are parse errors: @@sql_mode, SET @@x = 1, SET GLOBAL x = 1, SET NAMES

2 participants