Repository navigation
feat: add transaction search_path mode for PgBouncer pooling #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
85a358b
feat(PLT-13586): add transaction search_path mode
ganzyukv 2deb35c
ci(PLT-13586): skip coverage in integration job
ganzyukv 9128bc1
ci(PLT-13586): run integration tests in the matrix job
ganzyukv ed96925
ci(PLT-13586): add code coverage check and PR comment
ganzyukv 4fd2a6b
fix(PLT-13586): address Copilot review comments
ganzyukv fc9fa9b
chore(PLT-13586): add Copilot code review runner and instructions
ganzyukv ae253c6
ci(PLT-13586): update actions/checkout to v4
ganzyukv 7e5573a
fix(PLT-13586): address second Copilot review
ganzyukv 96f8c8b
fix(PLT-13586): harden transaction control tracking and driver check
ganzyukv 29f0fc9
fix(PLT-13586): handle chained, failed and batched transaction control
ganzyukv 087d32b
refactor(PLT-13586): simplify transaction search_path mode
ganzyukv 67bb800
fix(PLT-13586): handle nested comments and escape strings in SQL clas…
ganzyukv d99ddea
fix(PLT-13586): fail closed on unclassifiable SQL and verify server t…
ganzyukv d240bdf
test(PLT-13586): assert rejected batches write nothing to public
ganzyukv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Copilot review instructions | ||
|
|
||
| `macpaw/postgres-schema-bundle` is a public Symfony bundle. It switches the PostgreSQL `search_path` per request | ||
| through a Doctrine DBAL wrapper connection (`SchemaConnection`). Services configure it from `Kernel::boot()`. | ||
|
|
||
| ## Compatibility | ||
|
|
||
| - PHP `>=8.3`, Doctrine DBAL `^3.4`, ORM `^2.17 || ^3.0`, Symfony `^6.4 || ^7.4 || ^8.0`. | ||
| - DBAL 3 driver interfaces declare return types in docblocks only. Native return types that narrow | ||
| them in subclasses are fine; their absence is not a fatal error. | ||
|
|
||
| ## Behaviour that must not change | ||
|
|
||
| - `SearchPathMode::Session` is the default. With it, every statement must pass through exactly as before | ||
| the transaction mode existed. Flag any change that touches statements in Session mode. | ||
| - In `SearchPathMode::Transaction` the schema is applied only with `SET LOCAL`, never with a session `SET`. | ||
| A session `SET` leaks to other clients behind PgBouncer in transaction pooling. | ||
| - Transaction control SQL (`BEGIN`, `COMMIT`, `ROLLBACK`, savepoints) must run without a `SET LOCAL` before it. | ||
|
|
||
| ## Intentional decisions (do not flag) | ||
|
|
||
| - `BEGIN; SET LOCAL search_path TO ...` is sent in one `exec()` to save a round trip. Only `pdo_pgsql` is | ||
| supported, and the native `pgsql` driver is rejected. | ||
| - Mode, resolver and logger are static setters, matching how the bundle has always been configured. | ||
| - Statements outside a transaction commit before the result is fetched; this relies on `pdo_pgsql` buffering. | ||
|
|
||
| ## Code and tests | ||
|
|
||
| - `declare(strict_types=1)`, PSR-12, max line length 120, PHPStan level max. | ||
| - Unit tests in `tests/Doctrine` and `tests/Command` use mocks. Integration tests in `tests/Integration` need | ||
| PostgreSQL behind PgBouncer in transaction pooling (`docker compose`, or the CI services) and must fail, | ||
| not skip, in CI. | ||
| - Every change to `src/Doctrine/Middleware` needs an integration test that fails without it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: Copilot code review runner | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| copilot-setup-steps: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: '8.3' | ||
| extensions: pdo_pgsql | ||
| coverage: none | ||
|
|
||
| - name: Install dependencies | ||
| run: composer install --no-interaction --no-progress |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.