pgsql: Assign error codes where missing for user-facing failures

2024-07-03 Thread Michael Paquier
Assign error codes where missing for user-facing failures All the errors triggered in the code paths patched here would cause the backend to issue an internal_error errcode, which is a state that should be used only for "can't happen" situations. However, these code paths are reachable by the reg

pgsql: Fix typo in GetRunningTransactionData()

2024-07-03 Thread Alexander Korotkov
Fix typo in GetRunningTransactionData() e85662df44 made GetRunningTransactionData() calculate the oldest running transaction id within the current database. However, because of the typo, the new code uses oldestRunningXid instead of oldestDatabaseRunningXid in comparison before updating oldestDat

pgsql: Fix typo in GetRunningTransactionData()

2024-07-03 Thread Alexander Korotkov
Fix typo in GetRunningTransactionData() e85662df44 made GetRunningTransactionData() calculate the oldest running transaction id within the current database. However, because of the typo, the new code uses oldestRunningXid instead of oldestDatabaseRunningXid in comparison before updating oldestDat

pgsql: Optimize memory access in GetRunningTransactionData()

2024-07-03 Thread Alexander Korotkov
Optimize memory access in GetRunningTransactionData() e85662df44 made GetRunningTransactionData() calculate the oldest running transaction id within the current database. This commit optimized this calculation by performing a cheap transaction id comparison before fetching the process database id

pgsql: Remove incorrect Asserts in buffile.c

2024-07-03 Thread David Rowley
Remove incorrect Asserts in buffile.c Both BufFileSize() and BufFileAppend() contained Asserts to ensure the given BufFile(s) had a valid fileset. A valid fileset isn't required in either of these functions, so remove the Asserts and adjust the comments accordingly. This was noticed while work w

pgsql: Improve performance of binary_upgrade_set_pg_class_oids().

2024-07-03 Thread Nathan Bossart
Improve performance of binary_upgrade_set_pg_class_oids(). This function generates the commands that preserve the OIDs and relfilenodes of relations during pg_upgrade. It is called once per relevant relation, and each such call executes a relatively expensive query to retrieve information for a s

pgsql: Remove is_index parameter from binary_upgrade_set_pg_class_oids(

2024-07-03 Thread Nathan Bossart
Remove is_index parameter from binary_upgrade_set_pg_class_oids(). Since commit 9a974cbcba, this function retrieves the relkind before it needs to know whether the relation is an index, so we no longer need callers to provide this information. Suggested-by: Daniel Gustafsson Reviewed-by: Daniel G

pgsql: Avoid 0-length memcpy to NULL with EXEC_BACKEND

2024-07-03 Thread Heikki Linnakangas
Avoid 0-length memcpy to NULL with EXEC_BACKEND memcpy(NULL, src, 0) is forbidden by POSIX, even though every production version of libc allows it. Let's be tidy. Per report from Thomas Munro, running UBSan with EXEC_BACKEND. Backpatch to v17, where this code was added. Discussion: https://www.

pgsql: Tighten check for --forkchild argument when spawning child proce

2024-07-03 Thread Heikki Linnakangas
Tighten check for --forkchild argument when spawning child process Commit aafc05de1b removed all the other --fork* arguments. Altough this is inconsequential, backpatch to v17 since this is new. Author: Nathan Bossart Discussion: https://www.postgresql.org/message-id/ZnCCEN0l3qWv-XpW@nathan Bran

pgsql: Avoid 0-length memcpy to NULL with EXEC_BACKEND

2024-07-03 Thread Heikki Linnakangas
Avoid 0-length memcpy to NULL with EXEC_BACKEND memcpy(NULL, src, 0) is forbidden by POSIX, even though every production version of libc allows it. Let's be tidy. Per report from Thomas Munro, running UBSan with EXEC_BACKEND. Backpatch to v17, where this code was added. Discussion: https://www.

pgsql: Tighten check for --forkchild argument when spawning child proce

2024-07-03 Thread Heikki Linnakangas
Tighten check for --forkchild argument when spawning child process Commit aafc05de1b removed all the other --fork* arguments. Altough this is inconsequential, backpatch to v17 since this is new. Author: Nathan Bossart Discussion: https://www.postgresql.org/message-id/ZnCCEN0l3qWv-XpW@nathan Bran

pgsql: Fix the testcase introduced in commit 81d20fbf7a.

2024-07-03 Thread Amit Kapila
Fix the testcase introduced in commit 81d20fbf7a. The failed test was syncing failover replication slot to standby to test that we remove such slots after the standby is converted to subscriber by pg_createsubscriber. In one of the buildfarm members, the sync of the slot failed because the LSN on

pgsql: Fix the testcase introduced in commit 81d20fbf7a.

2024-07-03 Thread Amit Kapila
Fix the testcase introduced in commit 81d20fbf7a. The failed test was syncing failover replication slot to standby to test that we remove such slots after the standby is converted to subscriber by pg_createsubscriber. In one of the buildfarm members, the sync of the slot failed because the LSN on