diff --git a/pages/serverless-sql-databases/reference-content/known-differences.mdx b/pages/serverless-sql-databases/reference-content/known-differences.mdx index 5801173c5f..3ec38e273d 100644 --- a/pages/serverless-sql-databases/reference-content/known-differences.mdx +++ b/pages/serverless-sql-databases/reference-content/known-differences.mdx @@ -117,6 +117,8 @@ Serverless SQL Databases support the most popular PostgreSQL extensions. Refer t ``` In this example, `SHOW timezone` will always display `Europe/Paris` without any impact from any other connection despite connection pooling. +- `SET search_path TO` commands to use schemas works, but will be shared across multiple clients due to connection pooling, and will lead to unwanted effects. Refer to the [dedicated troubleshooting page](/serverless-sql-databases/troubleshooting/search-path-schema-errors/) for more information. + - Security labels cannot be defined or changed. ```sql diff --git a/pages/serverless-sql-databases/troubleshooting/index.mdx b/pages/serverless-sql-databases/troubleshooting/index.mdx index 4e361b22e7..61576e5323 100644 --- a/pages/serverless-sql-databases/troubleshooting/index.mdx +++ b/pages/serverless-sql-databases/troubleshooting/index.mdx @@ -44,4 +44,5 @@ productIcon: ServerlessDbProductIcon - [Solving Serverless SQL Databases connection timeouts](/serverless-sql-databases/troubleshooting/connection-timeout) - [Solving failing manual backup and restore operations](/serverless-sql-databases/troubleshooting/failing-backup-restore) - [Solving maximum prepared statements size errors](/serverless-sql-databases/troubleshooting/maximum-prepared-statements-reached) + - [Solving issues when setting search path to a schema](/serverless-sql-databases/troubleshooting/search-path-schema-errors/) diff --git a/pages/serverless-sql-databases/troubleshooting/search-path-schema-errors.mdx b/pages/serverless-sql-databases/troubleshooting/search-path-schema-errors.mdx new file mode 100644 index 0000000000..b683611a78 --- /dev/null +++ b/pages/serverless-sql-databases/troubleshooting/search-path-schema-errors.mdx @@ -0,0 +1,33 @@ +--- +title: Solving errors while setting search path to schemas +description: This page contains information to troubleshoot problems encountered while using SET search_path TO schema requests. +tags: set search path to schema error problem bug 500 connection lost db pgbouncer pooling +dates: + validation: 2025-10-10 + posted: 2025-10-10 +--- + +## Problem + +I am experiencing issues while using `SET` commands such as the following: + +```sql +SET search_path TO my_schema +``` + +## Cause + +- `SET search_path TO` commands to use schemas works, but will be shared across multiple clients due to connection pooling, and will lead to unwanted effects. + +## Possible solutions + +- Use fully qualified schema names (`schema.table`) to perform stateless and self-contained transactions that do not rely on or modify session-level settings. + +- Perform the `SET` command in the same transaction as the request, using the `SET LOCAL` command so it applies to the current transaction only: + +```sql +BEGIN; +SET LOCAL search_path TO schema1; +SELECT ... ; +COMMIT; +``` \ No newline at end of file