Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-5975

Prepared statements with DATE literals do not honor NO_ZERO_IN_DATE

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.0.9
    • Fix Version/s: 10.0.11
    • Component/s: None
    • 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.

        Attachments

          Activity

            People

            Assignee:
            bar Alexander Barkov
            Reporter:
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration