Re: missing semicolon at end of psql files - Mailing list pgsql-hackers

From Dmitriy Igrishin
Subject Re: missing semicolon at end of psql files
Date
Msg-id CAAfz9KMZa7BsLD6D8MfkGHec8P0sS1v=qWtdMC3=vARiFGuZrQ@mail.gmail.com
Whole thread Raw
In response to missing semicolon at end of psql files  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers


2012/9/12 Peter Eisentraut <peter_e@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.


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: git author vs committer
Next
From: Tom Lane
Date:
Subject: Re: missing semicolon at end of psql files