[MDEV-24860] Incorrect behaviour of SET STATEMENT in case it is executed as a prepared statement Created: 2021-02-13  Updated: 2022-08-06  Resolved: 2021-02-25

Status: Closed
Project: MariaDB Server
Component/s: Prepared Statements
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6
Fix Version/s: 10.2.38, 10.3.29, 10.4.19, 10.5.10, 10.6.0

Type: Bug Priority: Major
Reporter: Dmitry Shulga Assignee: Dmitry Shulga
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-16708 Unsupported commands for prepared sta... Closed
Problem/Incident
causes MDEV-29217 Assertion failure in Item_param::can_... Open

 Description   

While working on the task MDEV-16708 (Unsupported commands for prepared statements)
I hit the bug caused by incorrect handling of the ' SET STATEMENT' clause when the whole statement, containing the 'SET STATEMENT' clause, is executed in prepared statement mode.

The following test case shows the incorrect behavior:

PREPARE stmt FROM "SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR CREATE TABLE t1 AS SELECT CONCAT('abc') AS c1";
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c1` varchar(3) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;

It's expected that the output from the command SHOW CREATE TABLE t1 shows
`c1` varchar(3) CHARACTER SET utf8 NOT NULL
for the column c1 as it takes place in case this statement is run as a regular statement.

Instead, SHOW CREATE TABLE t1 outputs the following data
`c1` varchar(3) CHARACTER SET utf8 DEFAULT NULL
as a definition of the column c1



 Comments   
Comment by Oleksandr Byelkin [ 2021-02-17 ]

OK to push

Generated at Thu Feb 08 09:33:14 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.