Re: SERVICEFILE shows wrong file after servicefile fallback

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, tfoertsch123(at)gmail(dot)com, kanbayashi(dot)dev(at)gmail(dot)com
Subject: Re: SERVICEFILE shows wrong file after servicefile fallback
Date: 2026-06-04 05:47:04
Message-ID: ADAA6E48-6983-4EDD-8AA2-55007C67C3A1@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Jun 4, 2026, at 12:47, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Tue, Jun 02, 2026 at 09:42:23PM +0800, Chao Li wrote:
>> While testing “psql: Add variable SERVICEFILE”, I found a small
>> issue where SERVICEFILE may show the wrong value.
>>
>> While tracing the code, I noticed there is a fallback path. If the
>> service file specified in the connection string does not contain the
>> requested service, libpq falls back to pg_service.conf. So I tested
>> the following case:
>
> Right, as of the default file in PGSYSCONFDIR. This qualifies as an
> open item for v19.
>
>> I think the bug was actually introduced by the previous commit
>> 092f3c63efc6. In parseServiceFile(), if the service file has already
>> been set in the connection options, it refuses to update the value,
>> so the fallback service file is not synced to the connection
>> options. Then SERVICEFILE is read from the connection options, which
>> still contain the original file specified on the command line. So,
>> SERVICEFILE just makes the bug visible.
>
> Yep, it looks like you are right here. It does not make sense to show
> in SERVICEFILE the file that has been skipped in favor of the second
> default in PGSYSCONFDIR. We need to show the latter. An \echo of
> SERVICEFILE is an interesting way to show your point. Why not.
>
> Thanks for the report, will fix.
> --
> Michael

Thanks for confirming. I just added it to the Open Item list.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-06-04 05:57:05 Fix tuple deformation with virtual generated NOT NULL columns
Previous Message JoongHyuk Shin 2026-06-04 05:41:01 Re: [PATCH] Don't call ereport(ERROR) from recovery target GUC assign hooks