Skip to content

MariaDB driver should not use prepared statement protocol when oneshot is true #42

Open
@joseferben

Description

@joseferben

First of all, thanks for this great project!

I am running into an issue while running migrations for following query on MariaDB 10.1.41:

let create_uuid_of = connection => {
  module Connection = (val connection: Caqti_lwt.CONNECTION);
  let request =
    Caqti_request.exec(
      ~oneshot=true,
      Caqti_type.unit,
      "
CREATE OR REPLACE
  FUNCTION uuid_of(uuid BINARY(16))
  RETURNS VARCHAR(36)
  RETURN LOWER(CONCAT(
  SUBSTR(HEX(uuid), 1, 8), '-',
  SUBSTR(HEX(uuid), 9, 4), '-',
  SUBSTR(HEX(uuid), 13, 4), '-',
  SUBSTR(HEX(uuid), 17, 4), '-',
  SUBSTR(HEX(uuid), 21)
));
",
    );
  Connection.exec(request, ());
};
Error 1295, This command is not supported in the prepared statement protocol yet

I tried to track down the issue, but I am not sure what the underlying MariaDB library is doing.

In caqti_driver_mariadb.ml:

...
      (match Caqti_request.query_id req with
       | None ->
          let templ = Caqti_request.query req driver_info in
          let query = linear_query_string templ in
          Mdb.prepare db query >>=
...

Even though the query id is None (due to oneshot being true), Mdb.prepare is called. I assume this is using the prepared statement protocol?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions