Re: missing semicolon at end of psql files
От | Dmitriy Igrishin |
---|---|
Тема | Re: missing semicolon at end of psql files |
Дата | |
Msg-id | CAAfz9KMZa7BsLD6D8MfkGHec8P0sS1v=qWtdMC3=vARiFGuZrQ@mail.gmail.com обсуждение исходный текст |
Ответ на | missing semicolon at end of psql files (Peter Eisentraut <peter_e@gmx.net>) |
Список | 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?
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 по дате отправления: