[php-src] PR #20572: pdo_pgsql: Reset persistent session state on disconnect-equivalent processing

From: Date: Mon, 24 Nov 2025 12:43:54 +0000
Subject: [php-src] PR #20572: pdo_pgsql: Reset persistent session state on disconnect-equivalent processing
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-34140@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/20572 Author: KentarouTakeda This patch makes ext/pdo_pgsql clear session-local state when performing disconnect-equivalent processing by issuing a single DISCARD ALL on the libpq connection. ## Why Persistent PDO connections could carry session-scoped state across disconnect-equivalent lifecycles, causing surprising behavior for users (changed session settings, leftover temporary objects or prepared statements, or stuck advisory locks). Clearing the session on disconnect-equivalent processing prevents these surprises. **ext/pgsql already performs a session reset using RESET ALL**; DISCARD ALL is more comprehensive (it also releases advisory locks and removes temporary objects), so pdo_pgsql uses DISCARD ALL for broader cleanup. ## Risk / Benefit The change runs only during disconnect-equivalent cleanup and does not affect active connections. The small runtime cost of the DISCARD ALL call is outweighed by reducing hard-to-diagnose bugs caused by stale session state. ## Ref * [PostgreSQL: Documentation: 18: 13.3. Explicit Locking - Advisory Locks](https://www.postgresql.org/docs/18/explicit-locking.html#ADVISORY-LOCKS) * [PostgreSQL: Documentation: 18: SET](https://www.postgresql.org/docs/18/sql-set.html) * [PostgreSQL: Documentation: 18: RESET](https://www.postgresql.org/docs/18/sql-reset.html) * [PostgreSQL: Documentation: 18: DISCARD](https://www.postgresql.org/docs/18/sql-discard.html) * [ext/pgsqls RESET ALL](https://github.com/php/php-src/blob/ca914ee3891f674ae6dfadd9c0e231e4bc41dee3/ext/pgsql/pgsql.c#L757-L760)

« previous php.git-pulls (#34140) next »