[MDEV-5975] Prepared statements with DATE literals do not honor NO_ZERO_IN_DATE Created: 2014-03-28  Updated: 2014-04-22  Resolved: 2014-04-22

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.9
Fix Version/s: 10.0.11

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


 Description   

SET sql_mode=DEFAULT;
PREPARE stmt FROM "SELECT (SELECT DATE'2001-00-00') AS c";
EXECUTE stmt;
SET sql_mode='no_zero_in_date';
EXECUTE stmt;

returns:

+------------+
| c          |
+------------+
| 2001-00-00 |
+------------+
1 row in set (0.00 sec)

for both EXECUTE.
This is wrong. The second EXECUTE should return NULL.

If I change the script slightly:

SET sql_mode=DEFAULT;
PREPARE stmt FROM "SELECT (SELECT DATE('2001-00-00')) AS c";
EXECUTE stmt;
SET sql_mode='no_zero_in_date';
EXECUTE stmt;

it correctly returns '2001-00-00' for the first EXECUTE and NULL for the second EXECUTE,
as expected.



 Comments   
Comment by Alexander Barkov [ 2014-04-22 ]

Pushed into 10.0.

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