sqlgg icon indicating copy to clipboard operation
sqlgg copied to clipboard

Can't use @ in SET variable names.

Open cyberhuman opened this issue 7 years ago • 3 comments

e.g.

SET @noop = 0;

results in

==> SET @noop = 0
Position 1:9 Tokens: @noop = 0
Error: Sqlgg.Sql_parser.MenhirBasics.Error
Errors encountered, no code generated

Note that `@noop` is not the same as @noop (e.g. Mysql would complain that a system variable by that name does not exist, if backticks are used).

cyberhuman avatar Dec 13 '18 08:12 cyberhuman

I have just realized that we can live without noop :-) Closing this.

cyberhuman avatar Dec 14 '18 08:12 cyberhuman

It is not straightforward to fix, because while it is possible to parse such set with some hacks, but later when this var is referenced it will be confused with a parameter (because syntax is the same). I see two ways out : either keep track of all variable names defined and recover them when they are confused for parameters by lexer, or make selection of params syntax exclusive

ygrek avatar Dec 14 '18 08:12 ygrek

reopening as a reminder

ygrek avatar Dec 14 '18 08:12 ygrek