psql \watch always ignores \pset null

Lists: pgsql-hackers
From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: psql \watch always ignores \pset null
Date: 2014-11-19 05:34:50
Message-ID: CAHGQGwF6GM1-jRVki4FjHemynkbNsi5G9yxDB4gTJhB7B6RhFA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

> /*
> * Set up rendering options, in particular, disable the pager, because
> * nobody wants to be prompted while watching the output of 'watch'.
> */
> myopt.nullPrint = NULL;
> myopt.topt.pager = 0;

I found psql's \watch command always ignores \pset null setting.
The above source code comment explains why it does,
but I'd like to see the specified string for null value even in \watch's
output, in order to distinguish null and an empty value. Thought?
Is there any reason why \watch must ignore \pset null setting?

Regards,

--
Fujii Masao


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Will Leinweber <will(at)heroku(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql \watch always ignores \pset null
Date: 2014-11-19 05:54:04
Message-ID: 9543.1416376444@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Fujii Masao <masao(dot)fujii(at)gmail(dot)com> writes:
> Hi,
>> /*
>> * Set up rendering options, in particular, disable the pager, because
>> * nobody wants to be prompted while watching the output of 'watch'.
>> */
>> myopt.nullPrint = NULL;
>> myopt.topt.pager = 0;

> I found psql's \watch command always ignores \pset null setting.
> The above source code comment explains why it does,
> but I'd like to see the specified string for null value even in \watch's
> output, in order to distinguish null and an empty value. Thought?
> Is there any reason why \watch must ignore \pset null setting?

Hmmm ... the comment offers a reasonable argument for forcing pager = 0,
but I agree the nullPrint change is not adequately explained.
Will, do you remember why you did that?

regards, tom lane


From: Will Leinweber <will(at)heroku(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql \watch always ignores \pset null
Date: 2014-11-19 06:14:12
Message-ID: CAL8LqZSi-eKzO5W9GOtY1kw89Zwt2T7GOWTB2ZFF5CK8wM0t4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Nov 18, 2014 at 9:54 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Fujii Masao <masao(dot)fujii(at)gmail(dot)com> writes:
> > Hi,
> >> /*
> >> * Set up rendering options, in particular, disable the pager, because
> >> * nobody wants to be prompted while watching the output of 'watch'.
> >> */
> >> myopt.nullPrint = NULL;
> >> myopt.topt.pager = 0;
>
> > I found psql's \watch command always ignores \pset null setting.
> > The above source code comment explains why it does,
> > but I'd like to see the specified string for null value even in \watch's
> > output, in order to distinguish null and an empty value. Thought?
> > Is there any reason why \watch must ignore \pset null setting?
>
> Hmmm ... the comment offers a reasonable argument for forcing pager = 0,
> but I agree the nullPrint change is not adequately explained.
> Will, do you remember why you did that?
>
> regards, tom lane

I tracked down the individual commit[1] from my history where I added
that. What I added there is very similar to sections in
src/bin/psql/describe.c. I can't remember specifically my reasoning
then, but it's likely I copied the patterns there while getting things
working.

I do still think it's important to remove the pager, but the nullPrint
is probably a mistake.

[1]: https://github.com/will/postgres/commit/c42d29fece16ec9cb13c159b3307ab9fca892eb2


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Will Leinweber <will(at)heroku(dot)com>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql \watch always ignores \pset null
Date: 2014-11-19 06:24:06
Message-ID: 10403.1416378246@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Will Leinweber <will(at)heroku(dot)com> writes:
> On Tue, Nov 18, 2014 at 9:54 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Fujii Masao <masao(dot)fujii(at)gmail(dot)com> writes:
>>> Is there any reason why \watch must ignore \pset null setting?

>> Hmmm ... the comment offers a reasonable argument for forcing pager = 0,
>> but I agree the nullPrint change is not adequately explained.
>> Will, do you remember why you did that?

> I tracked down the individual commit[1] from my history where I added
> that. What I added there is very similar to sections in
> src/bin/psql/describe.c. I can't remember specifically my reasoning
> then, but it's likely I copied the patterns there while getting things
> working.
> I do still think it's important to remove the pager, but the nullPrint
> is probably a mistake.

I took a quick look and noted that the other places where nullPrint is
summarily forced to null are for \d and similar queries. For those,
the code can reasonably have an opinion about what the presentation should
be like, since it knows what SQL query it's issuing. That argument surely
doesn't apply to \watch, so I'm in agreement with Fujii that it'd be
better to respect the user's \pset setting.

regards, tom lane


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Will Leinweber <will(at)heroku(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql \watch always ignores \pset null
Date: 2014-11-27 17:46:13
Message-ID: CAHGQGwH2rOgFFk6Lj+TgAcpnQGiPg5siv9H5w9qFvEQpoe4uFg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Nov 19, 2014 at 3:24 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Will Leinweber <will(at)heroku(dot)com> writes:
>> On Tue, Nov 18, 2014 at 9:54 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Fujii Masao <masao(dot)fujii(at)gmail(dot)com> writes:
>>>> Is there any reason why \watch must ignore \pset null setting?
>
>>> Hmmm ... the comment offers a reasonable argument for forcing pager = 0,
>>> but I agree the nullPrint change is not adequately explained.
>>> Will, do you remember why you did that?
>
>> I tracked down the individual commit[1] from my history where I added
>> that. What I added there is very similar to sections in
>> src/bin/psql/describe.c. I can't remember specifically my reasoning
>> then, but it's likely I copied the patterns there while getting things
>> working.
>> I do still think it's important to remove the pager, but the nullPrint
>> is probably a mistake.
>
> I took a quick look and noted that the other places where nullPrint is
> summarily forced to null are for \d and similar queries. For those,
> the code can reasonably have an opinion about what the presentation should
> be like, since it knows what SQL query it's issuing. That argument surely
> doesn't apply to \watch, so I'm in agreement with Fujii that it'd be
> better to respect the user's \pset setting.

Thanks! I've just fixed this problem.

Regards,

--
Fujii Masao