Fix implicit result column name/alias for SELECT item literals with NULL bytes#314
Fix implicit result column name/alias for SELECT item literals with NULL bytes#314
SELECT item literals with NULL bytes#314Conversation
|
|
||
| // When the literal value contains a NULL byte, MySQL truncates the | ||
| // resulting identifier at the position of the first one of them. | ||
| $fist_null_byte_pos = strpos( $alias, "\0" ); |
There was a problem hiding this comment.
Does this matter in more places than just translate_select_item?
There was a problem hiding this comment.
@adamziel I will check that a bit deeper in a follow-up PR. There is the case where you type this explicitly (SELECT 1 AS 'a\0b'), and we need a follow-up to tackle that. Then, I think there is no other way where a string literal gets "converted" to an alias, but—I found some inconsistencies in how we process string literals vs. quoted identifiers and want to improve that too. We seem to treat them the same, but they shouldn't. It might be an interesting edge case bug going down to the lexer.
adamziel
left a comment
There was a problem hiding this comment.
LGTM and solves a problem so looks good for merging. We may want to follow up with a more general solution if that matters beyond the SELECT columns list.
Fixes
SELECTqueries that have string literals withNULLbytes in them and no column alias.E.g.:
This is because in MySQL:
\0bytes in identifiers (like column names). The lexer will reject that.SELECT 'abc\0xyz'The result column name will be:abc