Issue #2920527: Guard nested PostgreSQL SELECT savepoints and test rollback
Issue: https://www.drupal.org/project/drupal/issues/2920527
The PostgreSQL Select driver opens mimic_implicit_commit before parent::execute() runs query-alter hooks. A nested SELECT in one of those hooks attempts the same savepoint name. This still reproduces on core 11.4.6; the affected method is unchanged on main.
Adapt the savepoint-existence guard from !10859 to the current transaction API. The existing local savepoint variable keeps release and rollback with the caller that created it. No access or validation checks are removed.
Add a core-only regression to SelectTest, with a database_test query-alter hook that performs a nested SELECT. It checks repeated nested queries, recovery after an invalid SELECT, and rollback of the outer transaction.
Verification on core 11.4.6, PostgreSQL 16, PHP 8.4.22:
- New regression without the fix: TransactionNameNonUniqueException with mimic_implicit_commit already in use.
- Patched Select suite: 44 tests, 111 assertions, no failures (dependency deprecations reported).
- A moderated-node draft-continuation functional test with node grants and an existing node-reference field changes from HTTP 500 to passing all 30 assertions. Published and previous revisions are preserved.
The main branch contribution is cherry-picked from the tested 11.4.6 patch. Full main CI remains to be verified.