Re: [HACKERS] Request - repeat value of \pset title during \watch interations

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: [HACKERS] Request - repeat value of \pset title during \watch interations
Дата
Msg-id CA+TgmoZv_tOow2yRQCiKChGPTZ7artnyoR6xwOvg3n1mr_7uOg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [HACKERS] Request - repeat value of \pset title during \watch interations  (Michael Paquier <michael.paquier@gmail.com>)
Ответы Re: [HACKERS] Request - repeat value of \pset title during \watch interations  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
On Sun, Mar 20, 2016 at 9:31 AM, Michael Paquier
<michael.paquier@gmail.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


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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: [SQL] plan not correct?
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: PostgreSQL advocacy