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

CREATE PROCEDURE returns no error when using an unknown variable

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5, 10.0, 10.1, 10.2, 10.3, 10.4
    • 10.5.4
    • Stored routines
    • 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

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

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.