[MDEV-16708] Unsupported commands for prepared statements Created: 2018-07-08  Updated: 2023-12-06  Resolved: 2021-06-17

Status: Closed
Project: MariaDB Server
Component/s: Binary Protocol, Prepared Statements
Fix Version/s: 10.6.2

Type: Task Priority: Blocker
Reporter: Georg Richter Assignee: Dmitry Shulga
Resolution: Fixed Votes: 1
Labels: CONNECTOR_RELATED

Issue Links:
Blocks
blocks CONJ-844 Performance improvement for 10.6 server Closed
blocks CONPY-90 XA test fail (SQL Alchemy) Confirmed
is blocked by MDEV-24860 Incorrect behaviour of SET STATEMENT ... Closed
is blocked by MDEV-25006 Failed assertion on executing EXPLAIN... Closed
is blocked by MDEV-25108 Running of the EXPLAIN EXTENDED state... Closed
is blocked by MDEV-25197 The statement set password=password('... Closed
Duplicate
is duplicated by MDEV-28997 Drop TRIGGERs, FUNCTIONs and ROUTINEs... Closed
Problem/Incident
causes MDEV-29329 Some MTR tests fail with PS protocol ... Open
causes MDEV-30772 Inconsistency in handling empty comme... Open
Relates
relates to MDEV-10865 COLLATE keyword doesn't work in PREPA... Confirmed
relates to MDEV-24392 execute immediate '/*M!100601 select ... Open
relates to MDEV-25302 Attempt to set some system variables ... Closed

 Description   

The page "Permitted statements" lists the commands that are allowed to be prepared.
Unfortunately, there is no list which lists the commands that are currently not allowed in prepare and should be supported in future versions.

The following list is not complete and should be expanded.

  • CREATE/ALTER/DROP PROCEDURE
  • CREATE/ALTER/DROP EVENT
  • CREATE/ALTER/DROP FUNCTION
  • DELETE FROM (bulk insert not supported)
  • LOAD DATA
  • ALTER DATABASE
  • USE
  • XA BEGIN
  • XA END
  • XA RECOVER
  • XA PREPARE
  • XA COMMIT
  • XA ROLLBACK
  • HELP


 Comments   
Comment by Diego Dupin [ 2018-07-23 ]

Another command that failed using binary protocol using COLLATE.
example :

CREATE TABLE IF NOT EXISTS `tt` (
`test` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
#Text work well
SELECT * FROM `tt` WHERE `test` LIKE 'jj' COLLATE utf8mb4_unicode_ci;
#will throw an error "Erreur SQL (1253) : COLLATION 'utf8mb4_unicode_ci' is not valid for CHARACTER SET 'binary'"
PREPARE stmt FROM 'SELECT * FROM `tt` WHERE `test` LIKE ? COLLATE utf8mb4_unicode_ci'; 

Comment by Sergei Golubchik [ 2020-09-22 ]

I think we should have a generic fallback that makes all statements prepareable. Like, prepare stores the SQL statement on the server side and execute just completely executes the statement as in the normal protocol.

Statements that return result sets need to use binary protocol.
But luckily all not-yet-prepareable statements don't send results, so it seems.
All statements using this fallback approach don't have to accept prepared parameters.

This should be a fallback approach that automatically applies to all statements that are not natively prepare-able. Even new statements that can be created in the future.

Comment by Georg Richter [ 2020-09-22 ]

serg XA RECOVER returns a result set.

Comment by Sergei Golubchik [ 2020-09-22 ]

oops. indeed. that makes it a bit more complex then

Comment by Oleksandr Byelkin [ 2020-09-22 ]

But it looks like metadata the same (depend of parameters but the same). so it is not a big problem to return them after prepare IMHO.

Comment by Oleksandr Byelkin [ 2020-09-22 ]

That XA looks like do not have such complex data as ALTER/CREATE so easy can be implemented as prepared IMHO...

actually CREATE/ALTER supported in SP, so to implement them we need only to organise "prepare" test somehow...

so maybe it will be simpler to implement (real list of commands shoud be checked)

Comment by Dmitry Shulga [ 2020-11-04 ]

The following commands is not currently supported in prepared mode:

SQLCOM_LOAD
SQLCOM_LOCK_TABLES
SQLCOM_UNLOCK_TABLES
SQLCOM_CHANGE_DB
SQLCOM_ALTER_DB
SQLCOM_CREATE_FUNCTION
SQLCOM_ALTER_FUNCTION
SQLCOM_DROP_FUNCTION
SQLCOM_CHECK
SQLCOM_SAVEPOINT
SQLCOM_RELEASE_SAVEPOINT
SQLCOM_BEGIN
SQLCOM_PURGE
SQLCOM_PURGE_BEFORE
SQLCOM_HA_OPEN
SQLCOM_HA_CLOSE
SQLCOM_EMPTY_QUERY
SQLCOM_HELP
SQLCOM_CREATE_PROCEDURE
SQLCOM_CREATE_SPFUNCTION
SQLCOM_CALL
SQLCOM_DROP_PROCEDURE
SQLCOM_ALTER_PROCEDURE
SQLCOM_PREPARE
SQLCOM_EXECUTE
SQLCOM_DEALLOCATE_PREPARE
SQLCOM_CREATE_VIEW
SQLCOM_CREATE_TRIGGER
SQLCOM_DROP_TRIGGER
SQLCOM_XA_START
SQLCOM_XA_END
SQLCOM_XA_PREPARE
SQLCOM_XA_COMMIT
SQLCOM_XA_ROLLBACK
SQLCOM_XA_RECOVER
SQLCOM_ALTER_TABLESPACE
SQLCOM_CREATE_SERVER
SQLCOM_DROP_SERVER
SQLCOM_ALTER_SERVER
SQLCOM_CREATE_EVENT
SQLCOM_ALTER_EVENT
SQLCOM_DROP_EVENT
SQLCOM_SIGNAL
SQLCOM_RESIGNAL
SQLCOM_SHOW_RELAYLOG_EVENTS
SQLCOM_GET_DIAGNOSTICS
SQLCOM_EXECUTE_IMMEDIATE
SQLCOM_CREATE_PACKAGE
SQLCOM_DROP_PACKAGE
SQLCOM_CREATE_PACKAGE_BODY
SQLCOM_DROP_PACKAGE_BODY
SQLCOM_BACKUP
SQLCOM_BACKUP_LOCK

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