Currently, preparing multi-statements is not supported; so we can't prepare a query like select ?; select ?;.
However, the check for this condition just looked for any characters after the first ;, which meant that queries like select ?; \n would incorrectly throw an error.
This was made apparent using the Prisma ORM, which runs the query:
SELECT TABLE_NAME AS view_name, VIEW_DEFINITION AS view_sql
FROM INFORMATION_SCHEMA.VIEWS
WHERE TABLE_SCHEMA = ?;
Currently, preparing multi-statements is not supported; so we can't prepare a query like
select ?; select ?;
. However, the check for this condition just looked for any characters after the first;
, which meant that queries likeselect ?; \n
would incorrectly throw an error.This was made apparent using the Prisma ORM, which runs the query:
The above query ends in a newline character.
The fix is to use
SplitStatementToPieces()
, which trims these white space characters, and check if there's exactly one piece; this was taken from the vitessio repo: https://github.com/vitessio/vitess/blob/main/go/mysql/conn.go#L1204fixes https://github.com/dolthub/dolt/issues/8157