Re: cmd-line interface

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: cmd-line interface
Дата
Msg-id 003901c124ef$d3c0dbe0$1001a8c0@archonet.com
обсуждение исходный текст
Ответ на cmd-line interface  (Craig Longman <craigl@begeek.com>)
Список pgsql-general
From: "Craig Longman" <craigl@begeek.com>

> but...  one thing i do like about the db2 app, is that on the cmd-line i
> can specify two things:
>
> 1) stop on error
> this seems to be doable through the env-var ON_ERROR_STOP, but i do wish
> it was also parm i could pass on the cmd-line to psql.  its just so much
> easier than setting the everytime i want the stop behaviour.  i guess i
> could just set it and leave it.

Wrap psql in a 2-line shellscript which sets the env-var for you.

> 2) wrap a file in an explicit transaction
[snipped]
> is 2) possible right now?  i can't see anything in the docs, so i think
> not.  anyway, having this sort of control would really help.  our
> scripts need to run on various servers, and some things use different
> syntax for transactions, db2 is 'rollback/commit work'.

Bit trickier this one. I'd do it in perl (you can probably do it in shell,
but I'm not good enough). Steps would be:

1. parse command-line parameters
2. open pipe to psql with all parameters except "-f filename" (if there)
3. write "BEGIN;" to psql
4. WHILE not EOF read STDIN/file listed on command-line
5. write "COMMIT;" to psql

With the appropriate error-checking etc.

HTH

- Richard Huxton


В списке pgsql-general по дате отправления:

Предыдущее
От: Lamar Owen
Дата:
Сообщение: Re: PostgreSQL articles
Следующее
От: "Gregory Wood"
Дата:
Сообщение: Re: cmd-line interface