From: | Dmitriy Igrishin <dmitigr(at)gmail(dot)com> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: missing semicolon at end of psql files |
Date: | 2012-09-12 18:06:55 |
Message-ID: | CAAfz9KMZa7BsLD6D8MfkGHec8P0sS1v=qWtdMC3=vARiFGuZrQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2012/9/12 Peter Eisentraut <peter_e(at)gmx(dot)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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>
--
// Dmitriy.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2012-09-12 19:20:24 | Re: missing semicolon at end of psql files |
Previous Message | Tom Lane | 2012-09-12 17:34:59 | Re: git author vs committer |