pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: davecramer (@davecramer) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: Re: [pgjdbc/pgjdbc] PR #3606: fix: add support for multiple schemas via PgConnection.setSchema
Date: Thu, 17 Apr 2025 13:00:24 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

> Yes `current_schema()` is a bit misleading, although the documentation states it correctly: "Returns the name of the schema that is **first** in the search path" - it does not say that it shows **all** schemas on the search_path. To view all schemas on the path, you have to call `show search_path`. Check this output:
> 
> ```
> postgres=# set session search_path to 'postgres','public';
> SET
> postgres=# select current_schema();
>  current_schema 
> ----------------
>  public
> (1 row)
> 
> postgres=# show search_path;
>    search_path    
> ------------------
>  postgres, public
> (1 row)
> ```
> 
> So Postgres does indeed support multiple schemas on the search path, which is why the JDBC driver allows setting multiple schemas in the connection string.
> 
> I need this feature because in our enterprise setting, I cannot edit the JDBC connection string and I have multiple database functions which call other functions without the schema in their prefix, which I also cannot edit.
> 
> So to make my setup work, I have to be able to programmatically add multiple schemas to my search_path. Of course I could call `set session search_path to...` in my application, but I think support in the driver would be nice 😃

So I think we need to fix getSchema then as it returns `current_schema()`

view thread (19+ 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 #3606: fix: add support for multiple schemas via PgConnection.setSchema
  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