[MDEV-17894] Assertion `(thd->lex)->current_select' failed in MYSQLparse(), query with VALUES() Created: 2018-12-04  Updated: 2021-04-22  Resolved: 2019-05-14

Status: Closed
Project: MariaDB Server
Component/s: Parser
Affects Version/s: 10.3, 10.4
Fix Version/s: 10.3.15

Type: Bug Priority: Major
Reporter: Alice Sherepa Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-18091 using LIMIT with VALUES causes servic... Closed
is duplicated by MDEV-18000 VALUES (...) ORDER BY crashes MariaDB Closed
is duplicated by MDEV-19325 Wrong results of query, using bracket... Closed
Relates
relates to MDEV-25484 Crash when parsing query using derive... Closed

 Description   

values (5), (7) limit 1;
SELECT 2 UNION (values (5), (7) limit 1);

10.3 95f3c142a4f2fdb088e534

#6  0x00007f1f0fe95bd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x56362ad8944c "(thd->lex)->current_select", file=file@entry=0x56362ad13500 "/home/alice/git/10.3/sql/sql_yacc.yy", line=line@entry=12833, function=function@entry=0x56362ad8d3c0 <MYSQLparse(THD*)::__PRETTY_FUNCTION__> "int MYSQLparse(THD*)") at assert.c:92
#7  0x00007f1f0fe95c82 in __GI___assert_fail (assertion=0x56362ad8944c "(thd->lex)->current_select", file=0x56362ad13500 "/home/alice/git/10.3/sql/sql_yacc.yy", line=12833, function=0x56362ad8d3c0 <MYSQLparse(THD*)::__PRETTY_FUNCTION__> "int MYSQLparse(THD*)") at assert.c:101
#8  0x000056362a3739df in MYSQLparse (thd=0x7f1eb8000b00) at /home/alice/git/10.3/sql/sql_yacc.yy:12833
#9  0x000056362a134302 in parse_sql (thd=0x7f1eb8000b00, parser_state=0x7f1f09492470, creation_ctx=0x0, do_pfs_digest=true) at /home/alice/git/10.3/sql/sql_parse.cc:10102
#10 0x000056362a12f45b in mysql_parse (thd=0x7f1eb8000b00, rawbuf=0x7f1eb8014cd8 "values (5), (7) limit 1", length=23, parser_state=0x7f1f09492470, is_com_multi=false, is_next_command=false) at /home/alice/git/10.3/sql/sql_parse.cc:8044
#11 0x000056362a11c49f in dispatch_command (command=COM_QUERY, thd=0x7f1eb8000b00, packet=0x7f1eb8161121 "values (5), (7) limit 1", packet_length=23, is_com_multi=false, is_next_command=false) at /home/alice/git/10.3/sql/sql_parse.cc:1850
#12 0x000056362a11aebc in do_command (thd=0x7f1eb8000b00) at /home/alice/git/10.3/sql/sql_parse.cc:1395
#13 0x000056362a2827b4 in do_handle_one_connection (connect=0x56362c76ebc0) at /home/alice/git/10.3/sql/sql_connect.cc:1402
#14 0x000056362a282505 in handle_one_connection (arg=0x56362c76ebc0) at /home/alice/git/10.3/sql/sql_connect.cc:1308
#15 0x000056362ab5d63c in pfs_spawn_thread (arg=0x56362c777160) at /home/alice/git/10.3/storage/perfschema/pfs.cc:1862
#16 0x00007f1f10ada6ba in start_thread (arg=0x7f1f09493700) at pthread_create.c:333
#17 0x00007f1f0ff6f41d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

on 10.4 LIMIT is ignored:

MariaDB [test]> values (5), (7) limit 1;
+---+
| 5 |
+---+
| 5 |
+---+
1 row in set (0.001 sec)
 
MariaDB [test]> SELECT 2 UNION (values (5), (7) limit 1);
+---+
| 2 |
+---+
| 2 |
| 5 |
| 7 |
+---+
3 rows in set (0.003 sec)

At the same time KB says "The VALUES() function is meaningful only in INSERT ... ON DUPLICATE KEY UPDATE statements and returns NULL otherwise."



 Comments   
Comment by Oleksandr Byelkin [ 2018-12-20 ]

VALUES does not set 'braces' flag correctly.

Comment by Oleksandr Byelkin [ 2018-12-20 ]

And second line is just different bug in the parser.

Comment by Oleksandr Byelkin [ 2018-12-20 ]

First line actually problem is not in "braces" but TVC incorrectly linked or again use incorrect rule in the parser

Comment by Oleksandr Byelkin [ 2019-05-07 ]

OK to push

Comment by Igor Babaev [ 2019-05-14 ]

A fix for this bug was pushed in 10.3.
Due to differences in grammars the merge into 10.4 won't be easy.

Generated at Thu Feb 08 08:39:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.