Skip to main content

split_statements_sql

Function split_statements_sql 

Source
pub fn split_statements_sql(input: &str) -> Vec<&str>
Expand description

Split SQL input into statements on ;, using SQL’s own lexical rules.

The PowQL splitter (lexer::split_statements) knows " strings and # comments and nothing about -- or /* */, so it splits on a ; that is inside a SQL comment. That is dangerous rather than merely wrong: given -- cleanup; DELETE FROM t, the PowQL splitter yields -- cleanup and DELETE FROM t, and the second fragment is a live statement the user believed was commented out. A splitter that does not share the dialect’s idea of a comment cannot be used to decide what runs.

The rules here mirror lex_sql exactly: -- to end of line, /* ... */ blocks, ' and " quoting with '' doubling inside ', and a backslash escaping the next character inside either quote.