Details
-
Bug
-
Status: Open (View Workflow)
-
Critical
-
Resolution: Unresolved
-
N/A
-
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
- relates to
-
MDEV-13645 JSON_QUOTE() - return NULL on numbers
-
- Approved
-
-
MDEV-38591 MEMBER OF json operator
-
- In Testing
-