|
This script:
SET sql_mode=DEFAULT;
|
CREATE OR REPLACE TABLE t1 (a TEXT);
|
PREPARE stmt FROM 'INSERT INTO t1 (a) VALUES (2||3)';
|
EXECUTE stmt;
|
|
SET sql_mode=ORACLE;
|
EXECUTE stmt;
|
|
ALTER TABLE t1 ADD b INT;
|
EXECUTE stmt;
|
|
SELECT * FROM t1;
|
returns:
+------+------+
|
| a | b |
|
+------+------+
|
| 1 | NULL |
|
| 1 | NULL |
|
| 23 | NULL |
|
+------+------+
|
Notice, changing sql_mode between EXECUTE and PREPARE does not change the result, || is still treated as boolean OR in the second EXECUTE. However, as soon as I do ALTER TABLE, it forces automatic statement repreparation and the meaning of || in the third EXECUTE changes to concatenation.
This should be fixed to remember sql_mode with the prepared statement, so when the automatic repreparation happens it uses the same sql_mode which was used during PREPARE.
|