Add test case for base64Encode returning corrupted data

Sometimes, base64Encode returns data that belongs to the next string
in the buffer. This test, when failing, shows something like that:

    -SELECT * FROM tabl_1 SETTINGS log_comment = ?;
    -SELECT * FROM tabl_2 SETTINGS log_comment = ?;
    +SELECT * FROM tabl_1 SETTINGS log_comment = ?;\0S
    +SELECT * FROM tabl_2 SETTINGS log_comment = ?;\0c

 Where the S at the end of the first string is the first S of the next
 string in the buffer.

 I don't know exactly why, but reading from query_log is how I manage
 to reliably trigger the bug. The same code on literals, or even on
 a different table, did not trigger the bug, something related to
 alignment maybe.
This commit is contained in:
Kevin Michel 2021-11-25 14:28:39 +01:00
parent fab8da1c64
commit f05aaa4651
No known key found for this signature in database
GPG Key ID: 9F95C41F2EB138FC
2 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,2 @@
SELECT * FROM tabl_1 SETTINGS log_comment = ?;
SELECT * FROM tabl_2 SETTINGS log_comment = ?;

View File

@ -0,0 +1,13 @@
SET log_queries=1;
CREATE TABLE tabl_1 (key String) ENGINE MergeTree ORDER BY key;
CREATE TABLE tabl_2 (key String) ENGINE MergeTree ORDER BY key;
SELECT * FROM tabl_1 SETTINGS log_comment = 'ad15a651';
SELECT * FROM tabl_2 SETTINGS log_comment = 'ad15a651';
SYSTEM FLUSH LOGS;
SELECT base64Decode(base64Encode(normalizeQuery(query)))
FROM system.query_log
WHERE type='QueryFinish' AND log_comment = 'ad15a651'
GROUP BY normalizeQuery(query)
ORDER BY normalizeQuery(query);