Re: Add ldapservice connection parameter

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: Andrew Jackson <andrewjackson947(at)gmail(dot)com>
Cc: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Roman Khapov <rkhapov(at)yandex-team(dot)ru>, niushiji(at)gmail(dot)com, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Subject: Re: Add ldapservice connection parameter
Date: 2026-04-08 07:59:33
Message-ID: CAN4CZFOBPOTh=z_OfqqDo1F54vF=2Af7hDKRL=JOHkBprCbmZA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

+ /*
+ * ldapServiceLookup has 4 potential return values. We only care here
+ * if it succeeded, if it failed we dont care why, return failure.
+ */
+ if ((rc = ldapServiceLookup(ldapserviceurl, options, errorMessage)) != 0){
+
+ /*
+ * ldapServiceLookup == 2 is the only return code for libpq_append_error
+ * that does not append error because when used in pg_service.conf it is
+ * allowed to fallback to additional URLs without failing.
+ */
+ if (rc == 2)
+ libpq_append_error(errorMessage,
+ "connection could not be established to ldapserviceurl: \"%s\"",
+ ldapserviceurl);
+
+ return false;

This comment seems to be confusing to me, at first I thought that it
is the opposite of what the code below does, and then I realized that
no, it's just difficult to understand.

Maybe something like:

/*
* ldapServiceLookup() return code 2 means the LDAP server could
* not be contacted. Unlike other non-zero returns, it does not
* append an error message, because in pg_service.conf parsing
* the caller silently falls back to the next URL. Here there is
* no fallback, so we must provide an error message ourselves.
*/

+ This option specifies an LDAP query that can be used to
reference connection parameters
+ stored on an LDAP server. Any connection parameter that is
looked up in this way is
+ overridden by explicitly named connection parameters or
environment variables. This

Is the environment variable part true? ldapServiceLookup is now at
line 6765, environment variables are handled later at 6794 in
conninfo_add_defaults, so it is later, but it also has a NULL check in
it. If a value is already set in ldapServiceLookup, the environment
variable loop later won't override it.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2026-04-08 08:11:50 Re: Exit walsender before confirming remote flush in logical replication
Previous Message Tender Wang 2026-04-08 07:56:46 Fix "detected double pfree in PgStat Snapshot 0x557d9926b400" error