forked from babelfish-for-postgresql/babelfish_extensions
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…lfish-for-postgresql#3073) Valid names of user-defined T-SQL variables and/or parameters are @@Myvar, @Myvar#, @#myvar, etc. and indeed we see customer T-SQL applications using such names. Until now, such names have raised errors in the backend because we can only handle variable/parameter names with one leading @ and without # characters. This fix adds support by enclosing such variable names in square bracket delimiters; when using double quotes as delimiters (as is currently done in most places for regular-named variables), a query like select @@v will produce the string '@@v' instead of the value of variable @@v. The fix is partly done through ANTLR rewriting and partly at execution time elsewhere in the babelfish_tsql codeline. Things are complicated by the fact that the ANTLR rewriting logic is very fragmented, as well as that for some variables reference contexts inside the body of a procedure or trigger, rewriting must be postponed until the body is executed. This means there are multiple code paths where these variable names must be intercepted. This fix also addresses variable names in some contexts (like a cursor variable) that previously could not be longer than 63 characters. This fix also solves the previous issue that a variable could be declared with a name matching an internal sys function, but was resolved as the intern function instead of the variable, i.e. DECLARE @@rand INT=123 SELECT @@rand would return a random number instead of 123. Issues Resolved: BABEL-2481 Parameter declarations containing # characters not handled correctly BABEL-476 Support local variables/parameters with multiple '@' characters BABEL-5384 User-defined @@variable should not be mapped to sys function Signed-off-by: Rob Verschoor [email protected]
- Loading branch information
1 parent
4870eec
commit 86f693b
Showing
21 changed files
with
6,849 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.