2012/9/12 Peter Eisentraut <pete...@gmx.net> > I was surprised to find that psql -f file.sql with a file such as this > > select 1; > select 2 > > executes both commands even though the second one is not terminated. > > I realize that this is inconsistently handled throughout the system, for > example libpq APIs don't care about the missing semicolon, but > interactive psql does. > Furthermore, if the query string looks like ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;" the backend will return EmptyQueryResponse. But according to http://www.postgresql.org/docs/9.2/static/protocol-flow.html EmptyQueryResponse means "An empty query string was recognized." But this is debatable what is meant by "empty query string" -- when strlen(query_string) == 0 or when the query_string does not contains any SQL command?
> But what bothered me about this is that if a file gets truncated by > accident, there could be an unqualified DELETE or something similar at > the end. > Good point. The result can be disastrous. > > Comments? > > > > > -- > Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-hackers > -- // Dmitriy.