Skip to main content

has_trailing_statement

Function has_trailing_statement 

Source
fn has_trailing_statement(query: &str) -> bool
Expand description

Returns true if another statement follows the first statement-level ;.

Expects strip_leading_comments to have run, so a leading comment is never the reason an executable comment is rejected below.

Every pattern here ends in (.*), so absorbing a multi-statement request would discard its trailing statements without executing them — BEGIN; INSERT INTO t VALUES (1) would report success and write nothing. Such a request must reach the query engine, which executes each statement.

Plain comments, string literals and empty statements are skipped, so a ; inside a comment or a literal does not split the request, and BEGIN; -- done stays a single statement.

A /*!...*/ executable comment carries a statement, so anything but a request that starts with one — mysqldump’s /*!40101 SET NAMES ... */, which the patterns match whole — also counts as a trailing statement.