Re: Add ldapservice connection parameter - Mailing list pgsql-hackers

From Zsolt Parragi
Subject Re: Add ldapservice connection parameter
Date
Msg-id CAN4CZFOBPOTh=z_OfqqDo1F54vF=2Af7hDKRL=JOHkBprCbmZA@mail.gmail.com
Whole thread
In response to Re: Add ldapservice connection parameter  (Andrew Jackson <andrewjackson947@gmail.com>)
Responses Re: Add ldapservice connection parameter
List 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.



pgsql-hackers by date:

Previous
From: Tender Wang
Date:
Subject: Fix "detected double pfree in PgStat Snapshot 0x557d9926b400" error
Next
From: Fujii Masao
Date:
Subject: Re: Exit walsender before confirming remote flush in logical replication