Skip to content

Strange effect when mixing escaped variable names + parameters #589

@dimzon

Description

@dimzon

UPD. Every time someone use escaped user defined variable names into query all parameter values become NULL;
Just add this to you query and all parameters become NULL:

SET @'example-variable-name':= 0;

OR

SET @`example-variable-name`:= 0;

OR

SET @"example-variable-name":= 0;

All of these commands executed in single transaction in both MySqlConnector and Oracle’s Connector/NET. Every time DbParameter name = foo, value=22, type=int64 is supplied:


SET @'var':=1;
SELECT @'var' as R

returns 1 for both providers


SELECT @foo as R

returns 22 for both providers


SET @'var':=1;
SELECT @foo+@'var' as R

returns 23 for Oracle, DbNull for MySqlConnector


SET @'var':=1;
SELECT @foo+1 as R

returns 23 for Oracle, DbNull for MySqlConnector


SET @'var':=@foo+1;
SELECT @'var' as R

returns 23 for Oracle, DbNull for MySqlConnector

please note this behavior differs only when I'm using ESCAPED variable names (using "" or '' etc) https://dev.mysql.com/doc/refman/8.0/en/user-variables.html

IE any times I mix BOTH parameters and user-defined variables WITH ESCAPED name I got nulls

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions