Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-16708

Unsupported commands for prepared statements

Details

    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

      Attachments

        Issue Links

          Activity

            diego dupin Diego Dupin added a comment -

            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'; 
            
            

            diego dupin Diego Dupin added a comment - 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' ;

            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.

            serg Sergei Golubchik added a comment - 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.
            georg Georg Richter added a comment -

            serg XA RECOVER returns a result set.

            georg Georg Richter added a comment - serg XA RECOVER returns a result set.

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

            serg Sergei Golubchik added a comment - oops. indeed. that makes it a bit more complex then

            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.

            sanja Oleksandr Byelkin added a comment - 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.
            sanja Oleksandr Byelkin added a comment - - edited

            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)

            sanja Oleksandr Byelkin added a comment - - edited 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)
            shulga Dmitry Shulga added a comment -

            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

            shulga Dmitry Shulga added a comment - 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

            People

              shulga Dmitry Shulga
              georg Georg Richter
              Votes:
              1 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.