Re: missing semicolon at end of psql files
От | Peter Eisentraut |
---|---|
Тема | Re: missing semicolon at end of psql files |
Дата | |
Msg-id | 1347507447.18266.2.camel@vanquo.pezone.net обсуждение исходный текст |
Ответ на | missing semicolon at end of psql files (Peter Eisentraut <peter_e@gmx.net>) |
Список | pgsql-hackers |
On Wed, 2012-09-12 at 17:20 +0300, Heikki Linnakangas wrote: > On 12.09.2012 17:10, Peter Eisentraut wrote: > > 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. > > Even interactive psql doesn't require a semicolon at the end; it's just > that without it, it doesn't know whether you're still adding to the > command or if it's finished. But you can also use \g: > > ostgres=# select 1 > postgres-# \g > ?column? > ---------- > 1 > (1 row) A \g is equivalent to a semicolon, at least as far as saying, execute this command now. Note that postgres=# select 1 postgres-# <press Ctrl-D here> does not execute the command before quitting.
В списке pgsql-hackers по дате отправления: