Re: [HACKERS] psql --batch

2017-08-28 Thread Fabien COELHO



I don't doubt about a sense of this configuration - but this specific
combination depends on usage - so I don't think so using special option is
good idea.


Although I agree with you that detailed settings are definitely debatable, 
I'd say that at least it would be a more reasonable starting point for 
scripting than the default configuration which is more interactive usage 
oriented.


So even if unperfect, one is free to update defaults to suit more closely 
their needs, eg "psql -B -F ':' ...", at least most of the scripting 
conviniencies are already there.


I think that such a scripting mode should also imply --no-readline.

--
Fabien.


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] psql --batch

2017-08-28 Thread Pavel Stehule
2017-08-28 11:05 GMT+02:00 Craig Ringer :

> On 28 August 2017 at 16:23, Fabien COELHO  wrote:
>
>>
>> This doesn't really address the original issue though, that it's far from
>>> obvious how to easily and correctly script psql.
>>>
>>
>> That is another interesting argument. I understood that the issue was
>> having to type these options, but now it is also to remember which one are
>> relevant and wanted, which is a little different and more justifiable as an
>> option.
>>
>> On that account, ISTM that '|' as a field separator is debatable, that
>> pager should be turned off... and maybe a few other things.
>>
>
>
> Good point re pager, though it's turned off automatically when stdout
> isn't a terminal, so in practice that'll only matter if you're using
> something like 'expect' that uses a pty. Still worth doing.
>
> I agree that | is a bit iffy, but so's anything really. null bytes aren't
> usable for all scripts, and nothing else cannot also be output in the data
> its self. No easy answers there. In cases where I expect that to be an
> issue I sometimes use \COPY ... TO STDOUT WITH (FORMAT CSV) though.
>

I don't doubt about a sense of this configuration - but this specific
combination depends on usage - so I don't think so using special option is
good idea.

Regards

Pavel


>
> --
>  Craig Ringer   http://www.2ndQuadrant.com/
>  PostgreSQL Development, 24x7 Support, Training & Services
>


Re: [HACKERS] psql --batch

2017-08-28 Thread Craig Ringer
On 28 August 2017 at 16:23, Fabien COELHO  wrote:

>
> This doesn't really address the original issue though, that it's far from
>> obvious how to easily and correctly script psql.
>>
>
> That is another interesting argument. I understood that the issue was
> having to type these options, but now it is also to remember which one are
> relevant and wanted, which is a little different and more justifiable as an
> option.
>
> On that account, ISTM that '|' as a field separator is debatable, that
> pager should be turned off... and maybe a few other things.
>


Good point re pager, though it's turned off automatically when stdout isn't
a terminal, so in practice that'll only matter if you're using something
like 'expect' that uses a pty. Still worth doing.

I agree that | is a bit iffy, but so's anything really. null bytes aren't
usable for all scripts, and nothing else cannot also be output in the data
its self. No easy answers there. In cases where I expect that to be an
issue I sometimes use \COPY ... TO STDOUT WITH (FORMAT CSV) though.

-- 
 Craig Ringer   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


Re: [HACKERS] psql --batch

2017-08-28 Thread Fabien COELHO



This doesn't really address the original issue though, that it's far from
obvious how to easily and correctly script psql.


That is another interesting argument. I understood that the issue was 
having to type these options, but now it is also to remember which one are 
relevant and wanted, which is a little different and more justifiable as 
an option.


On that account, ISTM that '|' as a field separator is debatable, that 
pager should be turned off... and maybe a few other things.


--
Fabien.


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] psql --batch

2017-08-28 Thread Craig Ringer
On 28 August 2017 at 15:34, Pavel Stehule  wrote:

>
>
> 2017-08-28 9:33 GMT+02:00 Fabien COELHO :
>
>>
>> ISTM that the real pain is the "-v ON_ERRORS_STOP=1" which I occasionally
 encountered as well, the other one letter ones are not too bad. Maybe it
 would be enough to have a shortcut for this one, say "-B"?

>>>
>>> I agree with last sentence. I don't think so -qAtX are expected always,
>>> but
>>> "-v ON_ERRORS_STOP=1" is pretty often.
>>>
>>
>> Yep. I often "\set" that in the script.
>>
>> What do you think about long option "--on-errors-stop" ?
>>>
>>
>> It does not really relieve the typing pain Craig is complaining about,
>> but it would be ok as the long option version if -B is added, and it is
>> auto-completion friendly.
>
>
>
This doesn't really address the original issue though, that it's far from
obvious how to easily and correctly script psql.

I guess there's always the option of a docs patch for that. *shrug*

I'll see what others have to say.

-- 
 Craig Ringer   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


Re: [HACKERS] psql --batch

2017-08-28 Thread Pavel Stehule
2017-08-28 9:33 GMT+02:00 Fabien COELHO :

>
> ISTM that the real pain is the "-v ON_ERRORS_STOP=1" which I occasionally
>>> encountered as well, the other one letter ones are not too bad. Maybe it
>>> would be enough to have a shortcut for this one, say "-B"?
>>>
>>
>> I agree with last sentence. I don't think so -qAtX are expected always,
>> but
>> "-v ON_ERRORS_STOP=1" is pretty often.
>>
>
> Yep. I often "\set" that in the script.
>
> What do you think about long option "--on-errors-stop" ?
>>
>
> It does not really relieve the typing pain Craig is complaining about, but
> it would be ok as the long option version if -B is added, and it is
> auto-completion friendly.


ok

Pavel

>
>
> --
> Fabien.
>


Re: [HACKERS] psql --batch

2017-08-28 Thread Fabien COELHO



ISTM that the real pain is the "-v ON_ERRORS_STOP=1" which I occasionally
encountered as well, the other one letter ones are not too bad. Maybe it
would be enough to have a shortcut for this one, say "-B"?


I agree with last sentence. I don't think so -qAtX are expected always, but
"-v ON_ERRORS_STOP=1" is pretty often.


Yep. I often "\set" that in the script.


What do you think about long option "--on-errors-stop" ?


It does not really relieve the typing pain Craig is complaining about, but 
it would be ok as the long option version if -B is added, and it is 
auto-completion friendly.


--
Fabien.


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] psql --batch

2017-08-28 Thread Pavel Stehule
2017-08-28 8:56 GMT+02:00 Fabien COELHO :

>
> I find myself regurgitating the incantation
>>
>> psql -qAtX -v ON_ERRORS_STOP=1
>>
>> quite a bit. It's not ... super friendly.
>>
>> It strikes me that we could possibly benefit from a 'psql --batch' option.
>>
>> Thoughts?
>>
>
> The link between -qAtX and "batch" is not that fully obvious, especially
> the unaligned tuples-only part. If so, why not some -F  as well?
>
> ISTM that the real pain is the "-v ON_ERRORS_STOP=1" which I occasionally
> encountered as well, the other one letter ones are not too bad. Maybe it
> would be enough to have a shortcut for this one, say "-B"?
>

I agree with last sentence. I don't think so -qAtX are expected always, but
"-v ON_ERROS_STOP=1" is pretty often.

What do you think about long option "---on-errors-stop" ?

Regards

Pavel


> alias?
>
> --
> Fabien.
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>


Re: [HACKERS] psql --batch

2017-08-28 Thread Craig Ringer
On 28 August 2017 at 14:56, Fabien COELHO  wrote:

>
> I find myself regurgitating the incantation
>>
>> psql -qAtX -v ON_ERRORS_STOP=1
>>
>> quite a bit. It's not ... super friendly.
>>
>> It strikes me that we could possibly benefit from a 'psql --batch' option.
>>
>> Thoughts?
>>
>
> The link between -qAtX and "batch" is not that fully obvious, especially
> the unaligned tuples-only part. If so, why not some -F  as well?
>
>
q: quiet

Pretty much always wanted for a batch mode run of anything.

A: unaligned tuples

Because alignment is pretty much never useful when you're parsing result
sets with scripting (splitting, cut, etc) and just makes everything harder.
The alignment psql uses isn't fixed, after all.

t: tuples-only

Headers just make everything more annoying to parse, and force you to do
extra work to skip them. If you're running batch code you know the headers
because you used a column-list form SELECT, or should've. You're unlikely
to be ingesting them and using them to split up the tuple anyway. I think
this one is a bit more arguable than the first two, though, as I can at
least think of some cases where you might want it.

X: skip .psqlrc

Reliable, portable scripted psql shouldn't be using the local .psqlrc IMO.
It's likely to just break things in exciting ways. But I can see it being
reasonable to require this option to be supplied separately and just
document it as "recommended" with --batch.



-- 
 Craig Ringer   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


Re: [HACKERS] psql --batch

2017-08-28 Thread Fabien COELHO



I find myself regurgitating the incantation

psql -qAtX -v ON_ERRORS_STOP=1

quite a bit. It's not ... super friendly.

It strikes me that we could possibly benefit from a 'psql --batch' option.

Thoughts?


The link between -qAtX and "batch" is not that fully obvious, especially 
the unaligned tuples-only part. If so, why not some -F  as well?


ISTM that the real pain is the "-v ON_ERRORS_STOP=1" which I occasionally 
encountered as well, the other one letter ones are not too bad. Maybe it 
would be enough to have a shortcut for this one, say "-B"?


alias?

--
Fabien.


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] psql --batch

2017-08-27 Thread Craig Ringer
Hi all

I find myself regurgitating the incantation

psql -qAtX -v ON_ERRORS_STOP=1

quite a bit. It's not ... super friendly.

It strikes me that we could possibly benefit from a 'psql --batch' option.

Thoughts?

-- 
 Craig Ringer   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services