[MDEV-23819] syntax error EXECUTE IMMEDIATE 'use ?' USING @current_database Created: 2020-09-25  Updated: 2020-09-25  Resolved: 2020-09-25

Status: Closed
Project: MariaDB Server
Component/s: Prepared Statements
Affects Version/s: 10.2.33
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Daniel Black Assignee: Sergei Golubchik
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

Probably an abuse of execute immediate:

SELECT database() INTO @current_database;
 
/*M!100203 EXECUTE IMMEDIATE 'use ?' USING @current_database */;

result

ERROR 1064 (42000) at line 147: 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 '?' at line 1

If it will never work, just note the extent and we'll get it documents
https://mariadb.com/kb/en/execute-immediate/



 Comments   
Comment by Sergei Golubchik [ 2020-09-25 ]

This is documented here: https://mariadb.com/kb/en/prepare-statement/

Parameter markers can be used only where expressions should appear

and you cannot use expressions in USE, for example USE CONCAT('te', 'st') will not work.

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