pgsql: Remove redundant code in create_gather_merge_path

2024-07-22 Thread Richard Guo
Remove redundant code in create_gather_merge_path In create_gather_merge_path, we should always guarantee that the subpath is adequately ordered, and we do not add a Sort node in createplan.c for a Gather Merge node. Therefore, the 'else' branch in create_gather_merge_path, which computes the cos

pgsql: Fix rowcount estimate for gather (merge) paths

2024-07-22 Thread Richard Guo
Fix rowcount estimate for gather (merge) paths In the case of a parallel plan, when computing the number of tuples processed per worker, we divide the total number of tuples by the parallel_divisor obtained from get_parallel_divisor(), which accounts for the leader's contribution in addition to th

pgsql: Doc: improve description of plpgsql's FETCH and MOVE commands.

2024-07-22 Thread Tom Lane
Doc: improve description of plpgsql's FETCH and MOVE commands. We were not being clear about which variants of the "direction" clause are permitted in MOVE. Also, the text seemed to be written with only the FETCH/MOVE NEXT case in mind, so it didn't apply very well to other variants. Also, docum

pgsql: Doc: improve description of plpgsql's FETCH and MOVE commands.

2024-07-22 Thread Tom Lane
Doc: improve description of plpgsql's FETCH and MOVE commands. We were not being clear about which variants of the "direction" clause are permitted in MOVE. Also, the text seemed to be written with only the FETCH/MOVE NEXT case in mind, so it didn't apply very well to other variants. Also, docum

pgsql: Doc: improve description of plpgsql's FETCH and MOVE commands.

2024-07-22 Thread Tom Lane
Doc: improve description of plpgsql's FETCH and MOVE commands. We were not being clear about which variants of the "direction" clause are permitted in MOVE. Also, the text seemed to be written with only the FETCH/MOVE NEXT case in mind, so it didn't apply very well to other variants. Also, docum

pgsql: Doc: improve description of plpgsql's FETCH and MOVE commands.

2024-07-22 Thread Tom Lane
Doc: improve description of plpgsql's FETCH and MOVE commands. We were not being clear about which variants of the "direction" clause are permitted in MOVE. Also, the text seemed to be written with only the FETCH/MOVE NEXT case in mind, so it didn't apply very well to other variants. Also, docum

pgsql: Doc: improve description of plpgsql's FETCH and MOVE commands.

2024-07-22 Thread Tom Lane
Doc: improve description of plpgsql's FETCH and MOVE commands. We were not being clear about which variants of the "direction" clause are permitted in MOVE. Also, the text seemed to be written with only the FETCH/MOVE NEXT case in mind, so it didn't apply very well to other variants. Also, docum

pgsql: Doc: improve description of plpgsql's FETCH and MOVE commands.

2024-07-22 Thread Tom Lane
Doc: improve description of plpgsql's FETCH and MOVE commands. We were not being clear about which variants of the "direction" clause are permitted in MOVE. Also, the text seemed to be written with only the FETCH/MOVE NEXT case in mind, so it didn't apply very well to other variants. Also, docum

pgsql: Doc: improve description of plpgsql's FETCH and MOVE commands.

2024-07-22 Thread Tom Lane
Doc: improve description of plpgsql's FETCH and MOVE commands. We were not being clear about which variants of the "direction" clause are permitted in MOVE. Also, the text seemed to be written with only the FETCH/MOVE NEXT case in mind, so it didn't apply very well to other variants. Also, docum

pgsql: Revert "Test that vacuum removes tuples older than OldestXmin"

2024-07-22 Thread Melanie Plageman
Revert "Test that vacuum removes tuples older than OldestXmin" This reverts commit 80c34692e8e674e3b2f150f248ef2002ae2ac3a7. This test proved to be unstable on the buildfarm, timing out before the standby could catch up on 32-bit machines where more rows were required and failing to reliably trig

pgsql: Revert "Test that vacuum removes tuples older than OldestXmin"

2024-07-22 Thread Melanie Plageman
Revert "Test that vacuum removes tuples older than OldestXmin" This reverts commit aa607980aee08416211f003ab41aa750f5559712. This test proved to be unstable on the buildfarm, timing out before the standby could catch up on 32-bit machines where more rows were required and failing to reliably trig

pgsql: Initialize wal_level in the initial checkpoint record.

2024-07-22 Thread Robert Haas
Initialize wal_level in the initial checkpoint record. As per Coverity and Tom Lane, commit 402b586d0 (back-patched to v17 as 2b5819e2b) forgot to initialize this new structure member in this code path. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/6a6ebb92b0d4c07

pgsql: Initialize wal_level in the initial checkpoint record.

2024-07-22 Thread Robert Haas
Initialize wal_level in the initial checkpoint record. As per Coverity and Tom Lane, commit 402b586d0 (back-patched to v17 as 2b5819e2b) forgot to initialize this new structure member in this code path. Branch -- REL_17_STABLE Details --- https://git.postgresql.org/pg/commitdiff/e7dabbce

pgsql: Remove grotty use of disable_cost for TID scan plans.

2024-07-22 Thread Robert Haas
Remove grotty use of disable_cost for TID scan plans. Previously, the code charged disable_cost for CurrentOfExpr, and then subtracted disable_cost from the cost of a TID path that used CurrentOfExpr as the TID qual, effectively disabling all paths except that one. Now, we instead suppress generat

pgsql: Add missing call to ConditionVariableCancelSleep().

2024-07-22 Thread Robert Haas
Add missing call to ConditionVariableCancelSleep(). After calling ConditionVariableSleep() or ConditionVariableTimedSleep() one or more times, code is supposed to call ConditionVariableCancelSleep() to remove itself from the waitlist. This code neglected to do so. As far as I know, that had no obs

pgsql: Add missing call to ConditionVariableCancelSleep().

2024-07-22 Thread Robert Haas
Add missing call to ConditionVariableCancelSleep(). After calling ConditionVariableSleep() or ConditionVariableTimedSleep() one or more times, code is supposed to call ConditionVariableCancelSleep() to remove itself from the waitlist. This code neglected to do so. As far as I know, that had no obs

pgsql: Replace some strtok() with strsep()

2024-07-22 Thread Peter Eisentraut
Replace some strtok() with strsep() strtok() considers adjacent delimiters to be one delimiter, which is arguably the wrong behavior in some cases. Replace with strsep(), which has the right behavior: Adjacent delimiters create an empty token. Affected by this are parsing of: - Stored SCRAM sec

pgsql: postgres_fdw: Split out the query_cancel test to its own file

2024-07-22 Thread Alvaro Herrera
postgres_fdw: Split out the query_cancel test to its own file This allows us to skip it in Cygwin, where it's reportedly flaky because of platform bugs or something. Backpatch to 17, where the test was introduced by commit 2466d6654f85. Reported-by: Alexander Lakhin Discussion: https://postgr.e

pgsql: postgres_fdw: Split out the query_cancel test to its own file

2024-07-22 Thread Alvaro Herrera
postgres_fdw: Split out the query_cancel test to its own file This allows us to skip it in Cygwin, where it's reportedly flaky because of platform bugs or something. Backpatch to 17, where the test was introduced by commit 2466d6654f85. Reported-by: Alexander Lakhin Discussion: https://postgr.e

pgsql: Add port/ replacement for strsep()

2024-07-22 Thread Peter Eisentraut
Add port/ replacement for strsep() from OpenBSD, similar to strlcat, strlcpy There are currently no uses, but some will be added soon. Reviewed-by: Kyotaro Horiguchi Reviewed-by: David Steele Discussion: https://www.postgresql.org/message-id/flat/79692bf9-17d3-41e6-b9c9-fc8c39442...@eisentrau