[MDEV-11848] Automatic statement repreparation changes query semantics Created: 2017-01-20  Updated: 2018-08-31  Resolved: 2017-01-24

Status: Closed
Project: MariaDB Server
Component/s: Prepared Statements
Affects Version/s: 10.0, 10.1, 10.2, 10.3
Fix Version/s: 10.2.4

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-11880 sql_mode=ORACLE: Make the concatenati... Closed

 Description   

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.



 Comments   
Comment by Alexander Barkov [ 2017-01-24 ]

Approved by Monty on IRC.

Generated at Thu Feb 08 07:53:07 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.