[MDEV-24957] Unsupported binary command parameter support part Created: 2021-02-23  Updated: 2021-02-23

Status: Open
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: Task Priority: Major
Reporter: Diego Dupin Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Now all commands will be supported using binary protocol (MDEV-16708), but this fallback support is only partial, not permitting question mark for newly supported command.

An example is that some command without question mark works, but same one with parameter won't.
an example is :

      // without parameter
      try (PreparedStatement prep = con.prepareStatement("CREATE OR REPLACE USER 'testUser1' IDENTIFIED BY 'myPwd'")) {
          prep.execute();
      }
 
      // same with question mark will result in error
      //  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
      try (PreparedStatement prep = con.prepareStatement("CREATE OR REPLACE USER ? IDENTIFIED BY ?")) {
        for (int i = 0; i < 100; i++) {
          prep.setString(1, "testUser" + i);
          prep.setString(2, "myPwd");
          prep.execute();
        }
      }

Connectors normally doesn't have not to parse commands, to check that for example if this is an insert command, question mark are allowed, or for other they are not.

Solution would be for optimizer to support question mark on COM_STMT_PREPARE and execution to take given parameter of COM_STMT_EXECUTE



 Comments   
Comment by Sergei Golubchik [ 2021-02-23 ]

user name in CREATE USER isn't an expression (one cannot write CREATE USER CONCAT('a', 'b') , so one shouldn't expect a placeholder to work there.

But still there probably are statements that can now be prepared and that support expressions. E.g. LOAD and PURGE

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