When using a pipeline, a transaction starts from the first command and is committed with a Sync message or when the pipeline ends. Functions like IsInTransactionBlock() or PreventInTransactionBlock() were already able to understand a pipeline as being in a transaction block, but it was not the case of CheckTransactionBlock(). This function is called for example to generate a WARNING for SET LOCAL, complaining that it is used outside of a transaction block. The current state of the code caused multiple problems, like: - SET LOCAL executed at any stage of a pipeline issued a WARNING, even if the command was at least second in line where the pipeline is in a transaction state. - LOCK TABLE failed when invoked at any step of a pipeline, even if it should be able to work within a transaction block. The pipeline protocol assumes that the first command of a pipeline is not part of a transaction block, and that any follow-up commands is considered as within a transaction block. This commit changes the backend so as an implicit transaction block is started each time the first Execute message of a pipeline has finished processing, with this implicit transaction block ended once a sync is processed. The checks based on XACT_FLAGS_PIPELINING in the routines checking if we are in a transaction block are not necessary: it is enough to rely on the existing ones. Some tests are added to pgbench, that can be backpatched down to v17 when \syncpipeline is involved and down to v14 where \startpipeline and \endpipeline are available. This is unfortunately limited regarding the error patterns that can be checked, but it provides coverage for various pipeline combinations to check if these succeed or fail. These tests are able to capture the case of SET LOCAL's WARNING. The author has proposed a different feature to improve the coverage by adding similar meta-commands to psql where error messages could be checked, something more useful for the cases where commands cannot be used in transaction blocks, like REINDEX CONCURRENTLY or VACUUM. This is considered as future work for v18~. Author: Anthonin Bonnefoy Reviewed-by: Jelte Fennema-Nio, Michael Paquier Discussion: https://postgr.es/m/CAO6_XqrWO8uNBQrSu5r6jh+vTGi5Oiyk4y8yXDORdE2jbzw8xw@mail.gmail.com Backpatch-through: 13 |
1 year ago | |
|---|---|---|
| config | jit: Remove {llvm-config,clang}-N configure probes. | 2 years ago |
| contrib | Clean up newlines following left parentheses | 1 year ago |
| doc | Handle better implicit transaction state of pipeline mode | 1 year ago |
| src | Handle better implicit transaction state of pipeline mode | 1 year ago |
| .cirrus.star | Remove duplicate words in docs and code comments. | 2 years ago |
| .cirrus.tasks.yml | ci: Pin MacPorts version to 2.9.3. | 1 year ago |
| .cirrus.yml | ci: Make compute resources for CI configurable | 2 years ago |
| .dir-locals.el | Make Emacs perl-mode indent more like perltidy. | 7 years ago |
| .editorconfig | Add .editorconfig | 6 years ago |
| .git-blame-ignore-revs |
Add commit 7229ebe011 to .git-blame-ignore-revs.
|
1 year ago |
| .gitattributes | Remove non-existing file from .gitattributes | 2 years ago |
| .gitignore | Update top-level .gitignore. | 3 years ago |
| COPYRIGHT | Update copyright for 2024 | 2 years ago |
| GNUmakefile.in | Allow selecting the git revision to be packaged by "make dist". | 2 years ago |
| HISTORY | Canonicalize some URLs | 6 years ago |
| Makefile | Adapt REL_17_STABLE to its new status as a stable branch | 2 years ago |
| README.md | Adapt REL_17_STABLE to its new status as a stable branch | 2 years ago |
| aclocal.m4 | autoconf: Move export_dynamic determination to configure | 3 years ago |
| configure | Update configure probes for CFLAGS needed for ARM CRC instructions. | 1 year ago |
| configure.ac | Update configure probes for CFLAGS needed for ARM CRC instructions. | 1 year ago |
| meson.build | Clean up <stdbool.h> reference in meson.build. | 1 year ago |
| meson_options.txt | Allow selecting the git revision to be packaged by "make dist". | 2 years ago |
README.md
PostgreSQL Database Management System
This directory contains the source code distribution of the PostgreSQL database management system.
PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions. This distribution also contains C language bindings.
Copyright and license information can be found in the file COPYRIGHT.
General documentation about this version of PostgreSQL can be found at https://www.postgresql.org/docs/17/. In particular, information about building PostgreSQL from the source code can be found at https://www.postgresql.org/docs/17/installation.html.
The latest version of this software, and related software, may be obtained at https://www.postgresql.org/download/. For more information look at our web site located at https://www.postgresql.org/.