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

CREATE PROCEDURE returns no error when using an unknown variable

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5, 10.1, 10.2, 10.3, 10.4, 10.0
    • Fix Version/s: 10.5.4
    • Component/s: Stored routines
    • Labels:
      None

      Description

      DELIMITER $$
      CREATE OR REPLACE PROCEDURE p1(a INT)
      BEGIN
        DECLARE res INT DEFAULT 0;
        IF (a < 0) THEN
          SET res=x;
        END IF;
      END;
      $$
      DELIMITER ;
      

      Now if I call the procedure as follows:

      CALL p1(0);
      

      it still returns no errors.

      It only returns an error if the condition in IF evaluates to true:

      call p1(-1);
      

      ERROR 1054 (42S22): Unknown column 'x' in 'field list'
      

      This behavior makes it very difficult to design stored procedures.
      The error should happen during CREATE PROCEDURE time.

      In this context, x can only be a variable. It cannot be a column because no tables are involved.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: