Details
Description
A schema comment containing an embedded newline is returned correctly immediately after ALTER DATABASE, but loses the newline and all following text after FLUSH TABLES reloads the database options. A plain-text comment remains unchanged.
Steps to reproduce
- Save the following as test.sql.
- Run it with mariadb --batch --raw < test.sql.
SET SESSION sql_mode=''; |
SET SESSION lock_wait_timeout=5; |
CREATE DATABASE comment_db COMMENT 'alpha beta'; |
SHOW WARNINGS;
|
SELECT 'control_warm' AS phase, HEX(SCHEMA_COMMENT) AS comment_hex |
FROM information_schema.SCHEMATA |
WHERE SCHEMA_NAME='comment_db'; |
FLUSH TABLES;
|
SELECT 'control_cold' AS phase, HEX(SCHEMA_COMMENT) AS comment_hex |
FROM information_schema.SCHEMATA |
WHERE SCHEMA_NAME='comment_db'; |
ALTER DATABASE comment_db COMMENT 'alpha\nbeta'; |
SHOW WARNINGS;
|
SELECT 'newline_warm' AS phase, HEX(SCHEMA_COMMENT) AS comment_hex |
FROM information_schema.SCHEMATA |
WHERE SCHEMA_NAME='comment_db'; |
FLUSH TABLES;
|
SELECT 'newline_cold' AS phase, HEX(SCHEMA_COMMENT) AS comment_hex |
FROM information_schema.SCHEMATA |
WHERE SCHEMA_NAME='comment_db'; |
SELECT 'newline_recached' AS phase, HEX(SCHEMA_COMMENT) AS comment_hex |
FROM information_schema.SCHEMATA |
WHERE SCHEMA_NAME='comment_db'; |
DROP DATABASE comment_db; |
Actual result
The plain-text control remains stable. The newline comment initially contains the complete byte sequence for alpha\nbeta, but after FLUSH TABLES it contains only alpha and remains truncated on the next read. No warnings are reported.
phase comment_hex
|
control_warm 616C7068612062657461
|
control_cold 616C7068612062657461
|
newline_warm 616C7068610A62657461
|
newline_cold 616C706861
|
newline_recached 616C706861
|
Expected result
All three newline-comment reads should return 616C7068610A62657461. Clearing the cache must not change accepted schema-comment bytes when the database options are reloaded.
This occurs when a schema comment contains a newline and its cached database options are reloaded after FLUSH TABLES.