SqlScript

object SqlScript

Cuts a script into the statements it is made of.

PostgreSQL takes a whole script in one message and runs it inside an implicit transaction, which is what is wanted right up until one of the statements is CREATE INDEX CONCURRENTLY, VACUUM, or anything else the server refuses inside a transaction block. Those have to arrive one message at a time, and sending them one at a time means knowing where each one ends.

Nothing here parses SQL. A statement is the text between separators; whether the server will accept it is the server's answer to give. The one place words are read at all is a standard-SQL function body, which is not quoted and so cannot be skipped the way a dollar-quoted one is.

Functions

Link copied to clipboard

Splits sql on the ; that separate statements, and on no other ;.