pgsql: Remove literal backslash from Perl \Q ... \E.

2021-06-29 Thread Noah Misch
Remove literal backslash from Perl \Q ... \E. The behavior changed sometime after Perl 5.8.9, and "man perlre" says it "may lead to confusing results." Per buildfarm member gaur. This repairs commit a7a7be1f2fa6b9f0f48e69f12256d8f588af729b. Discussion: https://postgr.es/m/20210629053627.ga2061.

pgsql: Remove libpq's use of abort(3) to handle mutex failure cases.

2021-06-29 Thread Tom Lane
Remove libpq's use of abort(3) to handle mutex failure cases. Doing an abort() seems all right in development builds, but not in production builds of general-purpose libraries. However, the functions that were doing this lack any way to report a failure back up to their callers. It seems like we

pgsql: Add a build-time check that libpq doesn't call exit() or abort()

2021-06-29 Thread Tom Lane
Add a build-time check that libpq doesn't call exit() or abort(). Directly exiting or aborting seems like poor form for a general-purpose library. Now that libpq liberally uses bits out of src/common/, it's very easy to accidentally include code that would do something unwanted like calling exit(

pgsql: Fix bogus logic for reporting which hash partition conflicts.

2021-06-29 Thread Tom Lane
Fix bogus logic for reporting which hash partition conflicts. Commit efbfb6424 added logic for reporting exactly which existing partition conflicts when complaining that a new hash partition's modulus isn't compatible with the existing ones. However, it misunderstood the partitioning data structu

pgsql: Fix bogus logic for reporting which hash partition conflicts.

2021-06-29 Thread Tom Lane
Fix bogus logic for reporting which hash partition conflicts. Commit efbfb6424 added logic for reporting exactly which existing partition conflicts when complaining that a new hash partition's modulus isn't compatible with the existing ones. However, it misunderstood the partitioning data structu

pgsql: Add PQsendFlushRequest to libpq

2021-06-29 Thread Alvaro Herrera
Add PQsendFlushRequest to libpq This new libpq function allows the application to send an 'H' message, which instructs the server to flush its outgoing buffer. This hasn't been needed so far because the Sync message already requests a buffer; and I failed to realize that this was needed in pipeli

pgsql: Add PQsendFlushRequest to libpq

2021-06-29 Thread Alvaro Herrera
Add PQsendFlushRequest to libpq This new libpq function allows the application to send an 'H' message, which instructs the server to flush its outgoing buffer. This hasn't been needed so far because the Sync message already requests a buffer; and I failed to realize that this was needed in pipeli

pgsql: Fix libpq state machine in pipeline mode

2021-06-29 Thread Alvaro Herrera
Fix libpq state machine in pipeline mode The original coding required that PQpipelineSync had been called before the first call to PQgetResult, and failure to do that would result in an unexpected NULL result being returned. Fix by setting the right state when a query is sent, rather than leaving

pgsql: Fix libpq state machine in pipeline mode

2021-06-29 Thread Alvaro Herrera
Fix libpq state machine in pipeline mode The original coding required that PQpipelineSync had been called before the first call to PQgetResult, and failure to do that would result in an unexpected NULL result being returned. Fix by setting the right state when a query is sent, rather than leaving

pgsql: Fixes for multirange selectivity estimation

2021-06-29 Thread Alexander Korotkov
Fixes for multirange selectivity estimation * Fix enumeration of the multirange operators in calc_multirangesel() and calc_multirangesel() switches. * Add more regression tests for matching to empty ranges/multiranges. Reported-by: Alexander Lakhin Discussion: https://postgr.es/m/c5269c65-f9

pgsql: Fixes for multirange selectivity estimation

2021-06-29 Thread Alexander Korotkov
Fixes for multirange selectivity estimation * Fix enumeration of the multirange operators in calc_multirangesel() and calc_multirangesel() switches. * Add more regression tests for matching to empty ranges/multiranges. Reported-by: Alexander Lakhin Discussion: https://postgr.es/m/c5269c65-f9

pgsql: Optimize pg_checksums --enable where checksum is already set

2021-06-29 Thread Michael Paquier
Optimize pg_checksums --enable where checksum is already set This commit prevents pg_checksums to do a rewrite of a block if it has no need to, in the case where the computed checksum matches with what's already stored in the block read. This is helpful to accelerate successive runs of the tool w

pgsql: Fix incorrect PITR message for transaction ROLLBACK PREPARED

2021-06-29 Thread Michael Paquier
Fix incorrect PITR message for transaction ROLLBACK PREPARED Reaching PITR on such a transaction would cause the generation of a LOG message mentioning a transaction committed, not aborted. Oversight in 4f1b890. Author: Simon Riggs Discussion: https://postgr.es/m/canbhv-gj6kijecgdorxqmcq+c8qik6

pgsql: Fix incorrect PITR message for transaction ROLLBACK PREPARED

2021-06-29 Thread Michael Paquier
Fix incorrect PITR message for transaction ROLLBACK PREPARED Reaching PITR on such a transaction would cause the generation of a LOG message mentioning a transaction committed, not aborted. Oversight in 4f1b890. Author: Simon Riggs Discussion: https://postgr.es/m/canbhv-gj6kijecgdorxqmcq+c8qik6

pgsql: Fix incorrect PITR message for transaction ROLLBACK PREPARED

2021-06-29 Thread Michael Paquier
Fix incorrect PITR message for transaction ROLLBACK PREPARED Reaching PITR on such a transaction would cause the generation of a LOG message mentioning a transaction committed, not aborted. Oversight in 4f1b890. Author: Simon Riggs Discussion: https://postgr.es/m/canbhv-gj6kijecgdorxqmcq+c8qik6

pgsql: Fix incorrect PITR message for transaction ROLLBACK PREPARED

2021-06-29 Thread Michael Paquier
Fix incorrect PITR message for transaction ROLLBACK PREPARED Reaching PITR on such a transaction would cause the generation of a LOG message mentioning a transaction committed, not aborted. Oversight in 4f1b890. Author: Simon Riggs Discussion: https://postgr.es/m/canbhv-gj6kijecgdorxqmcq+c8qik6

pgsql: Fix incorrect PITR message for transaction ROLLBACK PREPARED

2021-06-29 Thread Michael Paquier
Fix incorrect PITR message for transaction ROLLBACK PREPARED Reaching PITR on such a transaction would cause the generation of a LOG message mentioning a transaction committed, not aborted. Oversight in 4f1b890. Author: Simon Riggs Discussion: https://postgr.es/m/canbhv-gj6kijecgdorxqmcq+c8qik6

pgsql: Fix incorrect PITR message for transaction ROLLBACK PREPARED

2021-06-29 Thread Michael Paquier
Fix incorrect PITR message for transaction ROLLBACK PREPARED Reaching PITR on such a transaction would cause the generation of a LOG message mentioning a transaction committed, not aborted. Oversight in 4f1b890. Author: Simon Riggs Discussion: https://postgr.es/m/canbhv-gj6kijecgdorxqmcq+c8qik6

pgsql: Fix incorrect PITR message for transaction ROLLBACK PREPARED

2021-06-29 Thread Michael Paquier
Fix incorrect PITR message for transaction ROLLBACK PREPARED Reaching PITR on such a transaction would cause the generation of a LOG message mentioning a transaction committed, not aborted. Oversight in 4f1b890. Author: Simon Riggs Discussion: https://postgr.es/m/canbhv-gj6kijecgdorxqmcq+c8qik6

pgsql: Allow enabling two-phase option via replication protocol.

2021-06-29 Thread Amit Kapila
Allow enabling two-phase option via replication protocol. Extend the replication command CREATE_REPLICATION_SLOT to support the TWO_PHASE option. This will allow decoding commands like PREPARE TRANSACTION, COMMIT PREPARED and ROLLBACK PREPARED for slots created with this option. The decoding of th

pgsql: Allow streaming the changes after speculative aborts.

2021-06-29 Thread Amit Kapila
Allow streaming the changes after speculative aborts. Until now, we didn't allow to stream the changes in logical replication till we receive speculative confirm or the next DML change record after speculative inserts. The reason was that we never use to process speculative aborts but after commit

pgsql: Allow streaming the changes after speculative aborts.

2021-06-29 Thread Amit Kapila
Allow streaming the changes after speculative aborts. Until now, we didn't allow to stream the changes in logical replication till we receive speculative confirm or the next DML change record after speculative inserts. The reason was that we never use to process speculative aborts but after commit

pgsql: Replace magic constants used in pg_stat_get_replication_slot().

2021-06-29 Thread Amit Kapila
Replace magic constants used in pg_stat_get_replication_slot(). A few variables have been using 10 as a magic constant while PG_STAT_GET_REPLICATION_SLOT_COLS can be used instead. Author: Masahiko Sawada Reviewed-By: Amit Kapila Backpatch-through: 14, where it was introduced Discussion: https://

pgsql: Replace magic constants used in pg_stat_get_replication_slot().

2021-06-29 Thread Amit Kapila
Replace magic constants used in pg_stat_get_replication_slot(). A few variables have been using 10 as a magic constant while PG_STAT_GET_REPLICATION_SLOT_COLS can be used instead. Author: Masahiko Sawada Reviewed-By: Amit Kapila Backpatch-through: 14, where it was introduced Discussion: https://

pgsql: genbki stricter error handling

2021-06-29 Thread Peter Eisentraut
genbki stricter error handling Instead of just writing warnings for invalid cross-catalog lookups, count the errors and error out at the end. Reviewed-by: Tom Lane Discussion: https://www.postgresql.org/message-id/flat/ca8ee41d-241b-1bf3-71f0-aaf1add6d3c5%40enterprisedb.com Branch -- maste