pgsql: Make unlink() work for junction points on Windows.

2022-08-05 Thread Thomas Munro
Make unlink() work for junction points on Windows. To support harmonization of Windows and Unix code, teach our unlink() wrapper that junction points need to be unlinked with rmdir() on Windows. Tested-by: Andrew Dunstan Discussion: https://postgr.es/m/CA%2BhUKGLfOOeyZpm5ByVcAt7x5Pn-%3DxGRNCvgi

pgsql: Provide lstat() for Windows.

2022-08-05 Thread Thomas Munro
Provide lstat() for Windows. Junction points will be reported with S_ISLNK(x.st_mode), simulating POSIX lstat(). stat() will follow pseudo-symlinks, like in POSIX (but only one level before giving up, unlike in POSIX). This completes a TODO left by commit bed90759fcb. Tested-by: Andrew Dunstan

pgsql: Replace pgwin32_is_junction() with lstat().

2022-08-05 Thread Thomas Munro
Replace pgwin32_is_junction() with lstat(). Now that lstat() reports junction points with S_IFLNK/S_ISLINK(), and unlink() can unlink them, there is no need for conditional code for Windows in a few places. That was expressed by testing for WIN32 or S_ISLNK, which we can now constant-fold. The c

pgsql: Remove fallbacks for strtoll, strtoull.

2022-08-05 Thread Thomas Munro
Remove fallbacks for strtoll, strtoull. strtoll was backfilled with either __strtoll or strtoq on systems without strtoll. The last such system on the buildfarm was an ancient HP-UX animal. We don't support HP-UX anymore, so remove. On other systems strtoll was present, but did not have a declara

pgsql: First-draft release notes for 14.5.

2022-08-05 Thread Tom Lane
First-draft release notes for 14.5. As usual, the release notes for older branches will be made by cutting these down, but put them up for community review first. Due to the out-of-cycle release of 14.4, there are a number of commits that appeared in 14.4 that are not yet shipped in the earlier b

pgsql: Fix comments about deduplication updating page.

2022-08-05 Thread Peter Geoghegan
Fix comments about deduplication updating page. nbtree deduplication passes add tuples from the original/target page to a temp page, merging as necessary. The temp page is copied back to the target permanent page in the critical section. This is similar to the approach taken by nbtree page split

pgsql: Add missing parenthesis to max item size macro.

2022-08-05 Thread Peter Geoghegan
Add missing parenthesis to max item size macro. Oversight in commit 92f37505, per buildfarm. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/b2fe783aecadb42e17868787bb45aa6328796d2a Modified Files -- src/backend/access/nbtree/nbtdedup.c | 3 +++ src/incl

pgsql: Partially undo commit 94da73281.

2022-08-05 Thread Tom Lane
Partially undo commit 94da73281. On closer inspection, mcv.c isn't as broken for ScalarArrayOpExpr as I thought. The Var-on-right issue is real enough, but actually it does cope fine with a NULL array constant --- I was misled by an XXX comment suggesting it didn't. Undo that part of the code ch

pgsql: Partially undo commit 94da73281.

2022-08-05 Thread Tom Lane
Partially undo commit 94da73281. On closer inspection, mcv.c isn't as broken for ScalarArrayOpExpr as I thought. The Var-on-right issue is real enough, but actually it does cope fine with a NULL array constant --- I was misled by an XXX comment suggesting it didn't. Undo that part of the code ch

pgsql: Partially undo commit 94da73281.

2022-08-05 Thread Tom Lane
Partially undo commit 94da73281. On closer inspection, mcv.c isn't as broken for ScalarArrayOpExpr as I thought. The Var-on-right issue is real enough, but actually it does cope fine with a NULL array constant --- I was misled by an XXX comment suggesting it didn't. Undo that part of the code ch

pgsql: Partially undo commit 94da73281.

2022-08-05 Thread Tom Lane
Partially undo commit 94da73281. On closer inspection, mcv.c isn't as broken for ScalarArrayOpExpr as I thought. The Var-on-right issue is real enough, but actually it does cope fine with a NULL array constant --- I was misled by an XXX comment suggesting it didn't. Undo that part of the code ch

pgsql: Fix handling of bare boolean expressions in mcv_get_match_bitmap

2022-08-05 Thread Tom Lane
Fix handling of bare boolean expressions in mcv_get_match_bitmap. Since v14, the extended stats machinery will try to estimate for otherwise-unsupported boolean expressions if they match an expression available from an extended stats object. mcv.c did not get the memo about this, and would spit u

pgsql: Fix handling of bare boolean expressions in mcv_get_match_bitmap

2022-08-05 Thread Tom Lane
Fix handling of bare boolean expressions in mcv_get_match_bitmap. Since v14, the extended stats machinery will try to estimate for otherwise-unsupported boolean expressions if they match an expression available from an extended stats object. mcv.c did not get the memo about this, and would spit u

pgsql: Fix handling of bare boolean expressions in mcv_get_match_bitmap

2022-08-05 Thread Tom Lane
Fix handling of bare boolean expressions in mcv_get_match_bitmap. Since v14, the extended stats machinery will try to estimate for otherwise-unsupported boolean expressions if they match an expression available from an extended stats object. mcv.c did not get the memo about this, and would spit u

pgsql: Fix non-bulletproof ScalarArrayOpExpr code for extended statisti

2022-08-05 Thread Tom Lane
Fix non-bulletproof ScalarArrayOpExpr code for extended statistics. statext_is_compatible_clause_internal() checked that the arguments of a ScalarArrayOpExpr are one Var and one Const, but it would allow cases where the Const was on the left. Subsequent uses of the clause are not expecting that a

pgsql: Fix non-bulletproof ScalarArrayOpExpr code for extended statisti

2022-08-05 Thread Tom Lane
Fix non-bulletproof ScalarArrayOpExpr code for extended statistics. statext_is_compatible_clause_internal() checked that the arguments of a ScalarArrayOpExpr are one Var and one Const, but it would allow cases where the Const was on the left. Subsequent uses of the clause are not expecting that a

pgsql: Fix non-bulletproof ScalarArrayOpExpr code for extended statisti

2022-08-05 Thread Tom Lane
Fix non-bulletproof ScalarArrayOpExpr code for extended statistics. statext_is_compatible_clause_internal() checked that the arguments of a ScalarArrayOpExpr are one Var and one Const, but it would allow cases where the Const was on the left. Subsequent uses of the clause are not expecting that a

pgsql: Fix non-bulletproof ScalarArrayOpExpr code for extended statisti

2022-08-05 Thread Tom Lane
Fix non-bulletproof ScalarArrayOpExpr code for extended statistics. statext_is_compatible_clause_internal() checked that the arguments of a ScalarArrayOpExpr are one Var and one Const, but it would allow cases where the Const was on the left. Subsequent uses of the clause are not expecting that a

pgsql: Backpatch addition of .git-blame-ignore-revs

2022-08-05 Thread Alvaro Herrera
Backpatch addition of .git-blame-ignore-revs This makes it more convenient for git config to contain the blame.ignoreRevsFile setting; otherwise current git versions complain if the file is not present. I constructed the file for each branch by scraping the file in branch master for commits that

pgsql: Backpatch addition of .git-blame-ignore-revs

2022-08-05 Thread Alvaro Herrera
Backpatch addition of .git-blame-ignore-revs This makes it more convenient for git config to contain the blame.ignoreRevsFile setting; otherwise current git versions complain if the file is not present. I constructed the file for each branch by scraping the file in branch master for commits that

pgsql: Backpatch addition of .git-blame-ignore-revs

2022-08-05 Thread Alvaro Herrera
Backpatch addition of .git-blame-ignore-revs This makes it more convenient for git config to contain the blame.ignoreRevsFile setting; otherwise current git versions complain if the file is not present. I constructed the file for each branch by scraping the file in branch master for commits that

pgsql: Backpatch addition of .git-blame-ignore-revs

2022-08-05 Thread Alvaro Herrera
Backpatch addition of .git-blame-ignore-revs This makes it more convenient for git config to contain the blame.ignoreRevsFile setting; otherwise current git versions complain if the file is not present. I constructed the file for each branch by scraping the file in branch master for commits that

pgsql: Backpatch addition of .git-blame-ignore-revs

2022-08-05 Thread Alvaro Herrera
Backpatch addition of .git-blame-ignore-revs This makes it more convenient for git config to contain the blame.ignoreRevsFile setting; otherwise current git versions complain if the file is not present. I constructed the file for each branch by scraping the file in branch master for commits that

pgsql: Backpatch addition of .git-blame-ignore-revs

2022-08-05 Thread Alvaro Herrera
Backpatch addition of .git-blame-ignore-revs This makes it more convenient for git config to contain the blame.ignoreRevsFile setting; otherwise current git versions complain if the file is not present. I constructed the file for each branch by scraping the file in branch master for commits that

pgsql: Backpatch addition of .git-blame-ignore-revs

2022-08-05 Thread Alvaro Herrera
Backpatch addition of .git-blame-ignore-revs This makes it more convenient for git config to contain the blame.ignoreRevsFile setting; otherwise current git versions complain if the file is not present. I constructed the file for each branch by scraping the file in branch master for commits that

pgsql: Fix incorrect permissions-checking code for extended statistics.

2022-08-05 Thread Tom Lane
Fix incorrect permissions-checking code for extended statistics. Commit a4d75c86b improved the extended-stats logic to allow extended stats to be collected on expressions not just bare Vars. To apply such stats, we first verify that the user has permissions to read all columns used in the stats.

pgsql: Fix incorrect permissions-checking code for extended statistics.

2022-08-05 Thread Tom Lane
Fix incorrect permissions-checking code for extended statistics. Commit a4d75c86b improved the extended-stats logic to allow extended stats to be collected on expressions not just bare Vars. To apply such stats, we first verify that the user has permissions to read all columns used in the stats.

pgsql: Fix incorrect permissions-checking code for extended statistics.

2022-08-05 Thread Tom Lane
Fix incorrect permissions-checking code for extended statistics. Commit a4d75c86b improved the extended-stats logic to allow extended stats to be collected on expressions not just bare Vars. To apply such stats, we first verify that the user has permissions to read all columns used in the stats.

pgsql: BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking

2022-08-05 Thread Alvaro Herrera
BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking That bit is unlogged and therefore it's wrong to consider it in WAL page comparison. Add a test that tickles the case, as branch testing technology allows. This has been a problem ever since wal consistency checking was introduced (commi

pgsql: BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking

2022-08-05 Thread Alvaro Herrera
BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking That bit is unlogged and therefore it's wrong to consider it in WAL page comparison. Add a test that tickles the case, as branch testing technology allows. This has been a problem ever since wal consistency checking was introduced (commi

pgsql: BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking

2022-08-05 Thread Alvaro Herrera
BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking That bit is unlogged and therefore it's wrong to consider it in WAL page comparison. Add a test that tickles the case, as branch testing technology allows. This has been a problem ever since wal consistency checking was introduced (commi

pgsql: BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking

2022-08-05 Thread Alvaro Herrera
BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking That bit is unlogged and therefore it's wrong to consider it in WAL page comparison. Add a test that tickles the case, as branch testing technology allows. This has been a problem ever since wal consistency checking was introduced (commi

pgsql: BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking

2022-08-05 Thread Alvaro Herrera
BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking That bit is unlogged and therefore it's wrong to consider it in WAL page comparison. Add a test that tickles the case, as branch testing technology allows. This has been a problem ever since wal consistency checking was introduced (commi

pgsql: BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking

2022-08-05 Thread Alvaro Herrera
BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking That bit is unlogged and therefore it's wrong to consider it in WAL page comparison. Add a test that tickles the case, as branch testing technology allows. This has been a problem ever since wal consistency checking was introduced (commi

pgsql: BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking

2022-08-05 Thread Alvaro Herrera
BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking That bit is unlogged and therefore it's wrong to consider it in WAL page comparison. Add a test that tickles the case, as branch testing technology allows. This has been a problem ever since wal consistency checking was introduced (commi

pgsql: Add HINT for restartpoint race with KeepFileRestoredFromArchive(

2022-08-05 Thread Noah Misch
Add HINT for restartpoint race with KeepFileRestoredFromArchive(). The five commits ending at cc2c7d65fc27e877c9f407587b0b92d46cd6dd16 closed this race condition for v15+. For v14 through v10, add a HINT to discourage studying the cosmetic problem. Reviewed by Kyotaro Horiguchi and David Steele.

pgsql: Add HINT for restartpoint race with KeepFileRestoredFromArchive(

2022-08-05 Thread Noah Misch
Add HINT for restartpoint race with KeepFileRestoredFromArchive(). The five commits ending at cc2c7d65fc27e877c9f407587b0b92d46cd6dd16 closed this race condition for v15+. For v14 through v10, add a HINT to discourage studying the cosmetic problem. Reviewed by Kyotaro Horiguchi and David Steele.

pgsql: Add HINT for restartpoint race with KeepFileRestoredFromArchive(

2022-08-05 Thread Noah Misch
Add HINT for restartpoint race with KeepFileRestoredFromArchive(). The five commits ending at cc2c7d65fc27e877c9f407587b0b92d46cd6dd16 closed this race condition for v15+. For v14 through v10, add a HINT to discourage studying the cosmetic problem. Reviewed by Kyotaro Horiguchi and David Steele.

pgsql: Be more prescriptive in new doc about re-archiving of same WAL f

2022-08-05 Thread Noah Misch
Be more prescriptive in new doc about re-archiving of same WAL file. Nathan Bossart, reviewed by David Steele. Discussion: https://postgr.es/m/[email protected] Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/d263ced225bffe2c340175125b0270d1

pgsql: Add HINT for restartpoint race with KeepFileRestoredFromArchive(

2022-08-05 Thread Noah Misch
Add HINT for restartpoint race with KeepFileRestoredFromArchive(). The five commits ending at cc2c7d65fc27e877c9f407587b0b92d46cd6dd16 closed this race condition for v15+. For v14 through v10, add a HINT to discourage studying the cosmetic problem. Reviewed by Kyotaro Horiguchi and David Steele.

pgsql: Add HINT for restartpoint race with KeepFileRestoredFromArchive(

2022-08-05 Thread Noah Misch
Add HINT for restartpoint race with KeepFileRestoredFromArchive(). The five commits ending at cc2c7d65fc27e877c9f407587b0b92d46cd6dd16 closed this race condition for v15+. For v14 through v10, add a HINT to discourage studying the cosmetic problem. Reviewed by Kyotaro Horiguchi and David Steele.

pgsql: regress: fix test instability

2022-08-05 Thread Alvaro Herrera
regress: fix test instability Having additional triggers in a test table made the ORDER BY clauses in old queries underspecified. Add another column there for stability. Per sporadic buildfarm pink. Branch -- REL_12_STABLE Details --- https://git.postgresql.org/pg/commitdiff/4ad4c1f419

pgsql: regress: fix test instability

2022-08-05 Thread Alvaro Herrera
regress: fix test instability Having additional triggers in a test table made the ORDER BY clauses in old queries underspecified. Add another column there for stability. Per sporadic buildfarm pink. Branch -- REL_15_STABLE Details --- https://git.postgresql.org/pg/commitdiff/aa242501af

pgsql: regress: fix test instability

2022-08-05 Thread Alvaro Herrera
regress: fix test instability Having additional triggers in a test table made the ORDER BY clauses in old queries underspecified. Add another column there for stability. Per sporadic buildfarm pink. Branch -- REL_11_STABLE Details --- https://git.postgresql.org/pg/commitdiff/91130dd316

pgsql: regress: fix test instability

2022-08-05 Thread Alvaro Herrera
regress: fix test instability Having additional triggers in a test table made the ORDER BY clauses in old queries underspecified. Add another column there for stability. Per sporadic buildfarm pink. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/90a4b64134ce0cb9a

pgsql: regress: fix test instability

2022-08-05 Thread Alvaro Herrera
regress: fix test instability Having additional triggers in a test table made the ORDER BY clauses in old queries underspecified. Add another column there for stability. Per sporadic buildfarm pink. Branch -- REL_14_STABLE Details --- https://git.postgresql.org/pg/commitdiff/6d9481cd05

pgsql: regress: fix test instability

2022-08-05 Thread Alvaro Herrera
regress: fix test instability Having additional triggers in a test table made the ORDER BY clauses in old queries underspecified. Add another column there for stability. Per sporadic buildfarm pink. Branch -- REL_13_STABLE Details --- https://git.postgresql.org/pg/commitdiff/d2a74621ed

pgsql: Simplify coding style of is_valid_ascii()

2022-08-05 Thread John Naylor
Simplify coding style of is_valid_ascii() Calculate end of input rather than maintaining length, per prior suggestion from Heikki Linnakangas. In passing, use more natural language in a comment. Discussion: https://www.postgresql.org/message-id/b4648cc2-5e9c-c93a-52cc-51e5c658a4f6%40iki.fi Bran

pgsql: postgres_fdw: Disable batch insertion when there are WCO constra

2022-08-05 Thread Etsuro Fujita
postgres_fdw: Disable batch insertion when there are WCO constraints. When inserting a view referencing a foreign table that has WITH CHECK OPTION constraints, in single-insert mode postgres_fdw retrieves the data that was actually inserted on the remote side so that the WITH CHECK OPTION constrai

pgsql: postgres_fdw: Disable batch insertion when there are WCO constra

2022-08-05 Thread Etsuro Fujita
postgres_fdw: Disable batch insertion when there are WCO constraints. When inserting a view referencing a foreign table that has WITH CHECK OPTION constraints, in single-insert mode postgres_fdw retrieves the data that was actually inserted on the remote side so that the WITH CHECK OPTION constrai

pgsql: postgres_fdw: Disable batch insertion when there are WCO constra

2022-08-05 Thread Etsuro Fujita
postgres_fdw: Disable batch insertion when there are WCO constraints. When inserting a view referencing a foreign table that has WITH CHECK OPTION constraints, in single-insert mode postgres_fdw retrieves the data that was actually inserted on the remote side so that the WITH CHECK OPTION constrai

pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly

2022-08-05 Thread Alvaro Herrera
Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Using ATSimpleRecursion() in ATPrepCmd() to do so as bbb927b4db9b did is not correct, because ATPrepCmd() can't distinguish between triggers that may be cloned and those that may not, so would wrongly try to recurse for the latter category o

pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly

2022-08-05 Thread Alvaro Herrera
Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Using ATSimpleRecursion() in ATPrepCmd() to do so as bbb927b4db9b did is not correct, because ATPrepCmd() can't distinguish between triggers that may be cloned and those that may not, so would wrongly try to recurse for the latter category o

pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly

2022-08-05 Thread Alvaro Herrera
Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Using ATSimpleRecursion() in ATPrepCmd() to do so as bbb927b4db9b did is not correct, because ATPrepCmd() can't distinguish between triggers that may be cloned and those that may not, so would wrongly try to recurse for the latter category o

pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly

2022-08-05 Thread Alvaro Herrera
Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Using ATSimpleRecursion() in ATPrepCmd() to do so as bbb927b4db9b did is not correct, because ATPrepCmd() can't distinguish between triggers that may be cloned and those that may not, so would wrongly try to recurse for the latter category o

pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly

2022-08-05 Thread Alvaro Herrera
Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Using ATSimpleRecursion() in ATPrepCmd() to do so as bbb927b4db9b did is not correct, because ATPrepCmd() can't distinguish between triggers that may be cloned and those that may not, so would wrongly try to recurse for the latter category o

pgsql: Fix ENABLE/DISABLE TRIGGER to handle recursion correctly

2022-08-05 Thread Alvaro Herrera
Fix ENABLE/DISABLE TRIGGER to handle recursion correctly Using ATSimpleRecursion() in ATPrepCmd() to do so as bbb927b4db9b did is not correct, because ATPrepCmd() can't distinguish between triggers that may be cloned and those that may not, so would wrongly try to recurse for the latter category o