[MDEV-24795] EXECUTE IMMEDIATE within a executable comment parses incorrectly Created: 2021-02-06  Updated: 2021-02-12

Status: Open
Project: MariaDB Server
Component/s: Parser
Affects Version/s: 10.2.36
Fix Version/s: 10.2

Type: Bug Priority: Major
Reporter: Daniel Black Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: None


 Description   

MariaDB [(none)]> /*M!100203 EXECUTE IMMEDIATE CONCAT(" */ SELECT 1  /*M!100203 ") */;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '*/ SELECT 1  /*M!100203' at line 1
MariaDB [(none)]> select version();
+-----------------+
| version()       |
+-----------------+
| 10.2.36-MariaDB |
+-----------------+
1 row in set (0.00 sec)

gdb bt

Thread 32 "mysqld" hit Breakpoint 1, Prepared_statement::execute_immediate (this=this@entry=0x7f1aa00162d8, query=0x7f1b10cb65d0 " */ SELECT 1  /*M!100203 ", query_len=25) at /home/dan/repos/mariadb-server-10.2/sql/sql_prepare.cc:5135
5135	  @param query  - query text
(gdb) bt
#0  Prepared_statement::execute_immediate (this=this@entry=0x7f1aa00162d8, query=0x7f1b10cb65d0 " */ SELECT 1  /*M!100203 ", query_len=25) at /home/dan/repos/mariadb-server-10.2/sql/sql_prepare.cc:5135
#1  0x00000000005fe9e0 in mysql_sql_stmt_execute_immediate (thd=thd@entry=0x7f1aa0000c48) at /home/dan/repos/mariadb-server-10.2/sql/sql_prepare.cc:3010
#2  0x00000000005ea06f in mysql_execute_command (thd=<optimized out>, thd@entry=0x7f1aa0000c48) at /home/dan/repos/mariadb-server-10.2/sql/sql_parse.cc:3564
#3  0x00000000005e586b in mysql_parse (thd=thd@entry=0x7f1aa0000c48, rawbuf=0x7f1aa000f260 "/*M!100203 EXECUTE IMMEDIATE CONCAT(\" */ SELECT 1  /*M!100203 \") */", length=<optimized out>, parser_state=parser_state@entry=0x7f1b10cb7680, is_com_multi=false, is_next_command=false) at /home/dan/repos/mariadb-server-10.2/sql/sql_parse.cc:7761
#4  0x00000000005e2040 in dispatch_command (command=<optimized out>, command@entry=COM_QUERY, thd=thd@entry=0x7f1aa0000c48, packet=0x7f1aa000f260 "/*M!100203 EXECUTE IMMEDIATE CONCAT(\" */ SELECT 1  /*M!100203 \") */", packet@entry=0x7f1aa0006fa9 "/*M!100203 EXECUTE IMMEDIATE CONCAT(\" */ SELECT 1  /*M!100203 \") */", packet_length=0, packet_length@entry=67, is_com_multi=<optimized out>, is_next_command=false) at /home/dan/repos/mariadb-server-10.2/sql/sql_parse.cc:1827
#5  0x00000000005e43a0 in do_command (thd=0x7f1aa0000c48) at /home/dan/repos/mariadb-server-10.2/sql/sql_parse.cc:1381
#6  0x00000000006b452a in do_handle_one_connection (connect=<optimized out>, connect@entry=0x290bc98) at /home/dan/repos/mariadb-server-10.2/sql/sql_connect.cc:1336
#7  0x00000000006b42f3 in handle_one_connection (arg=0x290bc98) at /home/dan/repos/mariadb-server-10.2/sql/sql_connect.cc:1241
#8  0x00007f1b12bb73f9 in start_thread () from /lib64/libpthread.so.0
#9  0x00007f1b1221e903 in clone () from /lib64/libc.so.6



 Comments   
Comment by Daniel Black [ 2021-02-06 ]

the case for this was attempting to provide an all versions, including < 10.1, sys schema solution like https://github.com/grooverdan/mariadb-sys/commit/8147e226d4decc419418b3b50a36c5cacf3198c3

Comment by Daniel Black [ 2021-02-12 ]

Seems its just the way quotes are handed in executable comments, they are balanced before comments.

select /*M!100203 " */ 1 /*M!100203 " */;
+-------------------+
| */ 1 /*M!100203   |
+-------------------+
|  */ 1 /*M!100203  |
+-------------------+

Generated at Thu Feb 08 09:32:43 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.