Plug-in common/logging.h with vacuumlo and oid2name

Lists: pgsql-hackers
From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Plug-in common/logging.h with vacuumlo and oid2name
Date: 2019-08-20 01:28:19
Message-ID: 20190820012819.GA8326@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi all,

While refactoring some code, I have bumped into $subject, which causes
both tools to have incorrect error message formats and progname being
used all through the code, sometimes incorrectly or just missing.

At the same time, we are missing a call to set_pglocale_pgservice()
for both binaries.

Any objections to the cleanup attached?
--
Michael

Attachment Content-Type Size
vacuumlo-oid2name-logging.patch text/x-diff 9.3 KB

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Plug-in common/logging.h with vacuumlo and oid2name
Date: 2019-09-04 08:17:57
Message-ID: 9479f52d-f170-acff-9b2c-96db3f5edf6a@2ndquadrant.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2019-08-20 03:28, Michael Paquier wrote:
> + pg_log_error("\nfailed to remove lo %u: %s", lo,
> + PQerrorMessage(conn));

This newline should be removed.

progname can probably be made into a local variable now.

The rest looks good to me.

Do we need set_pglocale_pgservice() calls here if we're not doing NLS?
Does the logging stuff require it? I'm not sure.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Plug-in common/logging.h with vacuumlo and oid2name
Date: 2019-09-04 12:17:46
Message-ID: 20190904121746.GA1496@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Sep 04, 2019 at 10:17:57AM +0200, Peter Eisentraut wrote:
> On 2019-08-20 03:28, Michael Paquier wrote:
> > + pg_log_error("\nfailed to remove lo %u: %s", lo,
> > + PQerrorMessage(conn));
>
> This newline should be removed.

Thanks, missed that.

> progname can probably be made into a local variable now.

Can it? vacuumlo() still uses the progname from _param for the
connection string.

> Do we need set_pglocale_pgservice() calls here if we're not doing NLS?
> Does the logging stuff require it? I'm not sure.

The logging part does not require it, but this can be used for
PGSYSCONFDIR, no?
--
Michael


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Plug-in common/logging.h with vacuumlo and oid2name
Date: 2019-09-04 12:37:12
Message-ID: b8cbb915-3a2e-51db-12c7-98b68ffbb20d@2ndquadrant.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2019-09-04 14:17, Michael Paquier wrote:
>> progname can probably be made into a local variable now.
>
> Can it? vacuumlo() still uses the progname from _param for the
> connection string.

Yeah, probably best to leave it as is for now.

>> Do we need set_pglocale_pgservice() calls here if we're not doing NLS?
>> Does the logging stuff require it? I'm not sure.
>
> The logging part does not require it, but this can be used for
> PGSYSCONFDIR, no?

How does PGSYSCONFDIR come into play here?

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Plug-in common/logging.h with vacuumlo and oid2name
Date: 2019-09-04 23:59:41
Message-ID: 20190904235941.GA14853@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Sep 04, 2019 at 02:37:12PM +0200, Peter Eisentraut wrote:
>>> Do we need set_pglocale_pgservice() calls here if we're not doing NLS?
>>> Does the logging stuff require it? I'm not sure.
>>
>> The logging part does not require it, but this can be used for
>> PGSYSCONFDIR, no?
>
> How does PGSYSCONFDIR come into play here?

There is an argument to allow libpq to find out a service file for
a connection from the executable path. Note that oid2name can use a
connection string for connection, but not vacuumlo, so I somewhat
missed that.
--
Michael


From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Plug-in common/logging.h with vacuumlo and oid2name
Date: 2019-09-05 07:40:46
Message-ID: 20190905074046.GE22147@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Sep 05, 2019 at 08:59:41AM +0900, Michael Paquier wrote:
> There is an argument to allow libpq to find out a service file for
> a connection from the executable path. Note that oid2name can use a
> connection string for connection, but not vacuumlo, so I somewhat
> missed that.

If you think that's not worth considering for now, I am fine to drop
that part. What do you think about the updated patch attached then?
--
Michael

Attachment Content-Type Size
vacuumlo-oid2name-logging-v2.patch text/x-diff 9.2 KB

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Plug-in common/logging.h with vacuumlo and oid2name
Date: 2019-09-05 12:21:34
Message-ID: e47af103-e4c0-1d70-e381-b3bc11f75dd3@2ndquadrant.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2019-09-05 01:59, Michael Paquier wrote:
> On Wed, Sep 04, 2019 at 02:37:12PM +0200, Peter Eisentraut wrote:
>>>> Do we need set_pglocale_pgservice() calls here if we're not doing NLS?
>>>> Does the logging stuff require it? I'm not sure.
>>>
>>> The logging part does not require it, but this can be used for
>>> PGSYSCONFDIR, no?
>>
>> How does PGSYSCONFDIR come into play here?
>
> There is an argument to allow libpq to find out a service file for
> a connection from the executable path. Note that oid2name can use a
> connection string for connection, but not vacuumlo, so I somewhat
> missed that.

Oh I see what's going on. PGSYSCONFDIR is used by libpq, and
set_pglocale_pgservice() does some path mangling on PGSYSCONFDIR if set
for Windows. Shouldn't libpq do that itself? Worth looking into but
probably unrelated to your patch.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Plug-in common/logging.h with vacuumlo and oid2name
Date: 2019-09-05 13:59:51
Message-ID: 20190905135951.GA24123@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Patch looks good to me, please push.

Generally speaking I find the 'progname' handling a bit silly (since we
have it both as a variable in each program and also in logging.c
separately), but that's not the fault of this patch, and this patch
doesn't make it worse. That said, I think some other messages in
vacuumlo can be made pg_log_somelevel(), based on occurrences of
'progname'.

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Plug-in common/logging.h with vacuumlo and oid2name
Date: 2019-09-06 05:01:42
Message-ID: 20190906050142.GB1608@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Sep 05, 2019 at 09:59:51AM -0400, Alvaro Herrera wrote:
> Patch looks good to me, please push.

Thanks, applied without the calls to set_pglocale_pgservice().

> Generally speaking I find the 'progname' handling a bit silly (since we
> have it both as a variable in each program and also in logging.c
> separately), but that's not the fault of this patch, and this patch
> doesn't make it worse. That said, I think some other messages in
> vacuumlo can be made pg_log_somelevel(), based on occurrences of
> 'progname'.

That would mean moving some of the messages from stdout to stderr. We
could do that.
--
Michael