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

MEMBER OF evaluates a non-string candidate twice

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • N/A
    • 13.2
    • JSON
    • None

    Description

      MEMBER OF evaluates a candidate that is not a string two times. Item_func_json_quote::val_str() (MDEV-13645 rewrite) first calls args[0]->val_str(), then val_int(), val_decimal() or val_real() on the same item. A candidate with a side effect (NEXTVAL(), @i:=@i+1, a stored function) runs twice and the first value is discarded. A string candidate is evaluated once.

      MEMBER OF returns 0,0,0 where 1,1,1 is expected, and LASTVAL(s) is 6 instead of 3.

      --source include/have_sequence.inc
       
      CREATE SEQUENCE s;
      --echo # BUG if LASTVAL is not 3 (each MEMBER OF consumes two values)
      SELECT NEXTVAL(s) MEMBER OF ('[1]'), NEXTVAL(s) MEMBER OF ('[2]'), NEXTVAL(s) MEMBER OF ('[3]');
      SELECT LASTVAL(s);
      DROP SEQUENCE s;
      

      13.2.0-MariaDB-asan-debug source revision: bef8c2acb7bfff211e0bc903e99248d91ac37d03
       
      SELECT NEXTVAL(s) MEMBER OF ('[1]'), NEXTVAL(s) MEMBER OF ('[2]'), NEXTVAL(s) MEMBER OF ('[3]');
      NEXTVAL(s) MEMBER OF ('[1]')	NEXTVAL(s) MEMBER OF ('[2]')	NEXTVAL(s) MEMBER OF ('[3]')
      0	0	0
      SELECT LASTVAL(s);
      LASTVAL(s)
      6
      

      JarirBob FYI

      Attachments

        Issue Links

          Activity

            People

              danblack Daniel Black
              alice Alice Sherepa
              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.