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

Wrong result from INFORMATION_SCHEMA.COLUMNS with identical CASE branches containing OR FALSE

    XMLWordPrintable

Details

    • Unexpected results

    Description

      A query against INFORMATION_SCHEMA.COLUMNS returns an incorrect empty result when its WHERE predicate is wrapped in a CASE expression with identical branches containing OR FALSE. Both branches are equivalent to the original predicate, so the two queries should return the same row.

      CREATE TABLE target (to_seconds BIGINT);
       
      CREATE TABLE target (to_seconds BIGINT);
       
      SELECT data_type FROM information_schema.columns WHERE column_name = 'to_seconds';
       
      SELECT data_type FROM information_schema.columns WHERE CASE WHEN EXISTS ( SELECT 1 FROM information_schema.columns WHERE column_name = 'to_seconds') THEN column_name = 'to_seconds' OR FALSE ELSE column_name = 'to_seconds' OR FALSE END;
      

      Actual result on 11.8.9-MariaDB:

      The first query returns:

      data_type
      bigint
      

      The second query returns:

      Empty set
      

      Expected result:

      Both queries should return:

      data_type
      bigint
      

      Attachments

        Activity

          People

            sanja Oleksandr Byelkin
            jxgui jinxingui
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.