Re: [GENERAL] Request - repeat value of \pset title during \watch interations - Mailing list pgsql-hackers

From Robert Haas
Subject Re: [GENERAL] Request - repeat value of \pset title during \watch interations
Date
Msg-id CA+TgmobYVUPKcJVELY0YaNHQ4OGJZb7bDqbVyWk6fxvwXpuf5w@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] Request - repeat value of \pset title during \watch interations  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: [GENERAL] Request - repeat value of \pset title during \watch interations
List pgsql-hackers
On Thu, Mar 10, 2016 at 1:40 AM, David G. Johnston
<david.g.johnston@gmail.com> wrote:
> Adding -hackers for consideration in the Commitfest.

I don't much like how this patch uses the arbitrary constant 50 in no
fewer than 5 locations.

Also, it seems like we could arrange for head_title to be "" rather
than NULL when myopt.title is NULL.  Then instead of this:

+        if (head_title)
+            snprintf(title, strlen(myopt.title) + 50,
+                     _("Watch every %lds\t%s\n%s"),
+                     sleep, asctime(localtime(&timer)), head_title);
+        else
+            snprintf(title, 50, _("Watch every %lds\t%s"),
+                     sleep, asctime(localtime(&timer)));

...we could just the first branch of that if all the time.

         if (res == -1)
+        {
+            pg_free(title);
+            pg_free(head_title);
             return false;
+        }

Instead of repeating the cleanup code, how about making this break;
then, change the return statement at the bottom of the function to
return (res != -1).

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Parallel Aggregate
Next
From: Robert Haas
Date:
Subject: Re: [patch] Proposal for \crosstabview in psql