Message-ID: From: "cgm-aw (@cgm-aw)" To: "pgjdbc/pgjdbc" Date: Tue, 15 Apr 2025 07:36:19 +0000 Subject: [pgjdbc/pgjdbc] issue #3605: PgConnection.setSchema() does not support multiple schemas List-Id: X-GitHub-Author-Id: 67689002 X-GitHub-Author-Login: cgm-aw X-GitHub-Issue: 3605 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: open X-GitHub-Type: issue X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3605 Content-Type: text/plain; charset=utf-8 **Describe the issue** According to the [documentation](https://jdbc.postgresql.org/documentation/use/#connection-parameters), `currentSchema` can be a comma-separated list of schemas. While this works for the connection string, it does not work for `PgConnection.setSchema()`. **Driver Version?** Latest **Java Version?** Any **OS Version?** Any **PostgreSQL Version?** Any **To Reproduce** Call `PgConnection.setSchema("a, b")` - the search path will be set to the string "a, b" instead to the schemas "a" and "b". **Expected behaviour** The search path should be set to a list of schemas if a comma-separated list is provided. **Comments** This is because `PgConnection.setSchema()` puts single quotes around the passed schema: ``` StringBuilder sb = new StringBuilder(); sb.append("SET SESSION search_path TO '"); // See here Utils.escapeLiteral(sb, schema, getStandardConformingStrings()); sb.append("'"); // and here ``` I'm happy to provide a reproducer if you need one, but I think the issue is pretty clear. There is some escaping going on, a comma-separated list passed a a string ("a, b") should of course be escaped to: 'a', 'b' I don't know if you have helpful utils to do this, so I didn't create a pull request. If you like, I can try :) Best regards Andreas