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

Unexpected result of prepared statement when use boolean value as parameters

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      Hi,

      I found a logic bug in MariaDB when using a Boolean value as the parameter of a prepared statement. In the following test case, the where condition should return false, but the query still return one row:
      ```
      CREATE TABLE t0(c0 REAL);
      CREATE TABLE t1 LIKE t0;
      INSERT INTO t1 VALUES (1);
      INSERT INTO t0 VALUES (1);
      SET @a = false;
      PREPARE prepare_query FROM "SELECT t1.c0, t0.c0 FROM t1 LEFT JOIN t0 ON 'J' WHERE (? OR ((t0.c0 IS TRUE) IN ('*_')))";
      EXECUTE prepare_query USING @a;
      — c0 c0
      — 1 NULL
      ```

      The equivalent normal query can return an empty result, which is expected.
      ```
      SELECT t1.c0, t0.c0 FROM t1 LEFT JOIN t0 ON 'J' WHERE (false OR ((t0.c0 IS TRUE) IN ('*_')));
      ```

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ChiZhang Chi Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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