pgsql: Add pg_nodiscard decorations to base64 functions

2025-01-16 Thread Peter Eisentraut
Add pg_nodiscard decorations to base64 functions The result of pg_b64_encode() and pg_b64_decode() should be checked for errors. This attribute could detect mistakes such as those fixed in commit ff030ebe250 and d278541be42. Reviewed-by: Michael Paquier Reviewed-by: Ranier Vilela Discussion:

pgsql: Revert recent changes related to handling of 2PC files at recove

2025-01-16 Thread Michael Paquier
Revert recent changes related to handling of 2PC files at recovery This commit reverts 8f67f994e8ea (down to v13) and c3de0f9eed38 (down to v17), as these are proving to not be completely correct regarding two aspects: - In v17 and newer branches, c3de0f9eed38's check for epoch handling is incorre

pgsql: Revert recent changes related to handling of 2PC files at recove

2025-01-16 Thread Michael Paquier
Revert recent changes related to handling of 2PC files at recovery This commit reverts 8f67f994e8ea (down to v13) and c3de0f9eed38 (down to v17), as these are proving to not be completely correct regarding two aspects: - In v17 and newer branches, c3de0f9eed38's check for epoch handling is incorre

pgsql: Revert recent changes related to handling of 2PC files at recove

2025-01-16 Thread Michael Paquier
Revert recent changes related to handling of 2PC files at recovery This commit reverts 8f67f994e8ea (down to v13) and c3de0f9eed38 (down to v17), as these are proving to not be completely correct regarding two aspects: - In v17 and newer branches, c3de0f9eed38's check for epoch handling is incorre

pgsql: Revert recent changes related to handling of 2PC files at recove

2025-01-16 Thread Michael Paquier
Revert recent changes related to handling of 2PC files at recovery This commit reverts 8f67f994e8ea (down to v13) and c3de0f9eed38 (down to v17), as these are proving to not be completely correct regarding two aspects: - In v17 and newer branches, c3de0f9eed38's check for epoch handling is incorre

pgsql: Revert recent changes related to handling of 2PC files at recove

2025-01-16 Thread Michael Paquier
Revert recent changes related to handling of 2PC files at recovery This commit reverts 8f67f994e8ea (down to v13) and c3de0f9eed38 (down to v17), as these are proving to not be completely correct regarding two aspects: - In v17 and newer branches, c3de0f9eed38's check for epoch handling is incorre

pgsql: Revert recent changes related to handling of 2PC files at recove

2025-01-16 Thread Michael Paquier
Revert recent changes related to handling of 2PC files at recovery This commit reverts 8f67f994e8ea (down to v13) and c3de0f9eed38 (down to v17), as these are proving to not be completely correct regarding two aspects: - In v17 and newer branches, c3de0f9eed38's check for epoch handling is incorre

pgsql: Remove redefinitions of SIG_* macros in win32_port.h.

2025-01-16 Thread Nathan Bossart
Remove redefinitions of SIG_* macros in win32_port.h. It is not clear why these were originally added. One hypothesis is that an ancient version of MinGW didn't define them. In any case, they appear to now be superfluous, so let's remove them. If nothing else, the buildfarm might offer us clues

pgsql: Fix setrefs.c's failure to do expression processing on prune ste

2025-01-16 Thread Tom Lane
Fix setrefs.c's failure to do expression processing on prune steps. We should run the expression subtrees of PartitionedRelPruneInfo structs through fix_scan_expr. Failure to do so means that AlternativeSubPlans within those expressions won't be cleaned up properly, resulting in "unrecognized nod

pgsql: Fix setrefs.c's failure to do expression processing on prune ste

2025-01-16 Thread Tom Lane
Fix setrefs.c's failure to do expression processing on prune steps. We should run the expression subtrees of PartitionedRelPruneInfo structs through fix_scan_expr. Failure to do so means that AlternativeSubPlans within those expressions won't be cleaned up properly, resulting in "unrecognized nod

pgsql: Fix setrefs.c's failure to do expression processing on prune ste

2025-01-16 Thread Tom Lane
Fix setrefs.c's failure to do expression processing on prune steps. We should run the expression subtrees of PartitionedRelPruneInfo structs through fix_scan_expr. Failure to do so means that AlternativeSubPlans within those expressions won't be cleaned up properly, resulting in "unrecognized nod

pgsql: Fix setrefs.c's failure to do expression processing on prune ste

2025-01-16 Thread Tom Lane
Fix setrefs.c's failure to do expression processing on prune steps. We should run the expression subtrees of PartitionedRelPruneInfo structs through fix_scan_expr. Failure to do so means that AlternativeSubPlans within those expressions won't be cleaned up properly, resulting in "unrecognized nod

pgsql: Fix setrefs.c's failure to do expression processing on prune ste

2025-01-16 Thread Tom Lane
Fix setrefs.c's failure to do expression processing on prune steps. We should run the expression subtrees of PartitionedRelPruneInfo structs through fix_scan_expr. Failure to do so means that AlternativeSubPlans within those expressions won't be cleaned up properly, resulting in "unrecognized nod

pgsql: Fix setrefs.c's failure to do expression processing on prune ste

2025-01-16 Thread Tom Lane
Fix setrefs.c's failure to do expression processing on prune steps. We should run the expression subtrees of PartitionedRelPruneInfo structs through fix_scan_expr. Failure to do so means that AlternativeSubPlans within those expressions won't be cleaned up properly, resulting in "unrecognized nod

pgsql: Add and use BitmapHeapScanDescData struct

2025-01-16 Thread Melanie Plageman
Add and use BitmapHeapScanDescData struct Move the several members of HeapScanDescData which are specific to Bitmap Heap Scans into a new struct, BitmapHeapScanDescData, which inherits from HeapScanDescData. This reduces the size of the HeapScanDescData for other types of scans and will allow us

pgsql: Rework macro pgstat_is_ioop_tracked_in_bytes()

2025-01-16 Thread Michael Paquier
Rework macro pgstat_is_ioop_tracked_in_bytes() As written, it was triggering a compilation warning for old versions of clang, as reported by buildfarm members ayu, batfish and demoiselle. Forcing a cast with "unsigned int" should fix the warning. While on it, the macro is moved to pgstat.h, close

pgsql: Convert libpgport's pqsignal() to a void function.

2025-01-16 Thread Nathan Bossart
Convert libpgport's pqsignal() to a void function. The protections added by commit 3b00fdba9f introduced race conditions to this function that can lead to bogus return values. Since nobody seems to inspect the return value, this is of little consequence, but it would have been nice to convert it t

pgsql: Avoid calling pqsignal() with invalid signals on Windows fronten

2025-01-16 Thread Nathan Bossart
Avoid calling pqsignal() with invalid signals on Windows frontends. As noted by the comment at the top of port/pqsignal.c, Windows frontend programs can only use pqsignal() with the 6 signals required by C. Most places avoid using invalid signals via #ifndef WIN32, but initdb and pg_test_fsync ch

pgsql: Seek zone abbreviations in the IANA data before timezone_abbrevi

2025-01-16 Thread Tom Lane
Seek zone abbreviations in the IANA data before timezone_abbreviations. If a time zone abbreviation used in datetime input is defined in the currently active timezone, use that definition in preference to looking in the timezone_abbreviations list. That allows us to correctly handle abbreviations

pgsql: Make pg_interpret_timezone_abbrev() check sp->defaulttype too.

2025-01-16 Thread Tom Lane
Make pg_interpret_timezone_abbrev() check sp->defaulttype too. This omission caused it to not recognize the furthest-back zone abbreviation when working with timezone data compiled with relatively recent zic (2018f or newer). Older versions of zic produced a dummy DST transition at the Big Bang,

pgsql: Fix nbtree contradictory array element comment.

2025-01-16 Thread Peter Geoghegan
Fix nbtree contradictory array element comment. Oversight in commit 5bf748b8, which enhanced nbtree ScalarArrayOp execution. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/901bd4a65ab9bc0025be0fc8fe1fce3c69e7b78e Modified Files -- src/backend/access/nb

pgsql: Split ATExecValidateConstraint into reusable pieces

2025-01-16 Thread Álvaro Herrera
Split ATExecValidateConstraint into reusable pieces With this, we have separate functions to add validation requests to ALTER TABLE's phase 3 queue for check and foreign key constraints, which allows reusing them in future commits -- particularly this will allow us to perform validation of invalid

pgsql: Add OLD/NEW support to RETURNING in DML queries.

2025-01-16 Thread Dean Rasheed
Add OLD/NEW support to RETURNING in DML queries. This allows the RETURNING list of INSERT/UPDATE/DELETE/MERGE queries to explicitly return old and new values by using the special aliases "old" and "new", which are automatically added to the query (if not already defined) while parsing its RETURNIN

pgsql: Remove dead code

2025-01-16 Thread Peter Eisentraut
Remove dead code As of commit 9895b35cb88, AlterDomainAddConstraint() can only be called with constraints of type CONSTR_CHECK and CONSTR_NOTNULL. So all the code to check for and reject other constraint type values is dead and can be removed. Author: jian he Discussion: https://www.postgresql

pgsql: refactor: split ATExecAlterConstrRecurse()

2025-01-16 Thread Peter Eisentraut
refactor: split ATExecAlterConstrRecurse() This splits out a couple of subroutines from ATExecAlterConstrRecurse(). This makes the main function a bit smaller, and a future patch (NOT ENFORCED foreign-key constraints) will also want to call some of the pieces separately. Author: Amul Sul Review

pgsql: Fix error handling of pg_b64_decode()

2025-01-16 Thread Peter Eisentraut
Fix error handling of pg_b64_decode() Fix for commit 761c79508e7. The previous error handling logic was not quite correct. Discussion: https://www.postgresql.org/message-id/flat/CAEudQAq-3yHsSdWoOOaw%2BgAQYgPMpMGuB5pt2yCXgv-YuxG2Hg%40mail.gmail.com Branch -- master Details --- https:/