From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: [HACKERS] Request - repeat value of \pset title during \watch interations |
Date: | 2016-03-21 15:03:20 |
Message-ID: | CA+TgmoZv_tOow2yRQCiKChGPTZ7artnyoR6xwOvg3n1mr_7uOg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
On Sun, Mar 20, 2016 at 9:31 AM, Michael Paquier
<michael(dot)paquier(at)gmail(dot)com> wrote:
> And the patch attached gives the following output:
> With title:
> =# \watch 1
> Watch every 1s Sun Mar 20 22:28:38 2016
> popo
> a
> ---
> 1
> (1 row)
>
> And without title:
> Watch every 1s Sun Mar 20 22:29:31 2016
>
> a
> ---
> 1
> (1 row)
And does everybody agree that this is a desirable change?
As for the patch itself, you could replace all this:
+ /*
+ * Take into account any title present in the user setup as a part of
+ * what is printed for each iteration by using it as a header.
+ */
+ if (myopt.title)
+ {
+ title_len = strlen(myopt.title);
+ title = pg_malloc(title_len + 50);
+ head_title = pg_strdup(myopt.title);
+ }
+ else
+ {
+ title_len = 0;
+ title = pg_malloc(50);
+ head_title = pg_strdup("");
+ }
...with:
head_title = pg_strdup(myopt.title != NULL ? myopt.title : "");
title_len = strlen(head_title);
title = pg_malloc(title_len + 50);
Better yet, include the + 50 in title_len, and then you don't need to
reference the number 50 again further down.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2016-03-21 15:08:15 | Re: PostgreSQL advocacy |
Previous Message | Adrian Klaver | 2016-03-21 15:01:35 | Re: [SQL] plan not correct? |
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2016-03-21 15:11:37 | Re: Proposal: Generic WAL logical messages |
Previous Message | Bert | 2016-03-21 14:57:49 | Re: [COMMITTERS] pgsql: Support parallel aggregation. |