pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: sehrope (@sehrope) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: Re: [pgjdbc/pgjdbc] PR #3565: Use query to find the current catalog instead of relying on the database in the connection URL or connection properties as this could be different if connected through a pooler or proxy
Date: Wed, 02 Apr 2025 12:07:02 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

Let me preface this by saying I'm not opposed to this PR ... though thinking about this a couple questions came to mind.

What happens if the DB changes? The whole point of this PR is to skip the fixed value in connection properties and pass through to the actual database, potentially bypassing any intermediate connection pool(s). If the pooler reroutes the connection somewhere else then it'd be wrong as we would have cached the previous value. I suppose that type of pooling is less common, but it does come up for things like live migrations and upgrades.

There's also a slight change in behavior here. Previously the method was a pass through to `QueryExecutor.getDatabase()` which returned a cached `String` value. Now that we always execute the command on the first call, this means you cannot call this method while the connection is otherwise in use. I'm worried this may lead to some weird edge case where a user runs a query or COPY operation, and then tries to use this data while processing the result.

We could resolve this by caching the value at connection startup. But I don't think we want to add more mandatory startup round trips.

view thread (13+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://pgjdbc/pgjdbc
  Cc: [email protected], [email protected]
  Subject: Re: [pgjdbc/pgjdbc] PR #3565: Use query to find the current catalog instead of relying on the database in the connection URL or connection properties as this could be different if connected through a pooler or proxy
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox