pgsql: libpq: Add support for Close on portals and statements

2023-07-03 Thread Michael Paquier
libpq: Add support for Close on portals and statements The following routines are added to libpq: PGresult *PQclosePrepared(PGconn *conn, const char *stmt); PGresult *PQclosePortal(PGconn *conn, const char *portal); int PQsendClosePrepared(PGconn *conn, const char *stmt); int

pgsql: Re-bin segment when memory pages are freed.

2023-07-03 Thread Thomas Munro
Re-bin segment when memory pages are freed. It's OK to be lazy about re-binning memory segments when allocating, because that can only leave segments in a bin that's too high. We'll search higher bins if necessary while allocating next time, and also eventually re-bin, so no memory can become

pgsql: Re-bin segment when memory pages are freed.

2023-07-03 Thread Thomas Munro
Re-bin segment when memory pages are freed. It's OK to be lazy about re-binning memory segments when allocating, because that can only leave segments in a bin that's too high. We'll search higher bins if necessary while allocating next time, and also eventually re-bin, so no memory can become

pgsql: Re-bin segment when memory pages are freed.

2023-07-03 Thread Thomas Munro
Re-bin segment when memory pages are freed. It's OK to be lazy about re-binning memory segments when allocating, because that can only leave segments in a bin that's too high. We'll search higher bins if necessary while allocating next time, and also eventually re-bin, so no memory can become

pgsql: Re-bin segment when memory pages are freed.

2023-07-03 Thread Thomas Munro
Re-bin segment when memory pages are freed. It's OK to be lazy about re-binning memory segments when allocating, because that can only leave segments in a bin that's too high. We'll search higher bins if necessary while allocating next time, and also eventually re-bin, so no memory can become

pgsql: Re-bin segment when memory pages are freed.

2023-07-03 Thread Thomas Munro
Re-bin segment when memory pages are freed. It's OK to be lazy about re-binning memory segments when allocating, because that can only leave segments in a bin that's too high. We'll search higher bins if necessary while allocating next time, and also eventually re-bin, so no memory can become

pgsql: Re-bin segment when memory pages are freed.

2023-07-03 Thread Thomas Munro
Re-bin segment when memory pages are freed. It's OK to be lazy about re-binning memory segments when allocating, because that can only leave segments in a bin that's too high. We'll search higher bins if necessary while allocating next time, and also eventually re-bin, so no memory can become

pgsql: Re-bin segment when memory pages are freed.

2023-07-03 Thread Thomas Munro
Re-bin segment when memory pages are freed. It's OK to be lazy about re-binning memory segments when allocating, because that can only leave segments in a bin that's too high. We'll search higher bins if necessary while allocating next time, and also eventually re-bin, so no memory can become

pgsql: Remove trailing zero words from Bitmapsets

2023-07-03 Thread David Rowley
Remove trailing zero words from Bitmapsets Prior to this, Bitmapsets could contain trailing words which had no members set. Many places in bitmapset.c had to loop over trailing words to check for empty words. If we ensure we always remove these trailing zero words then we can perform various

pgsql: Fix regression tests of unaccent to work without UTF8 support

2023-07-03 Thread Michael Paquier
Fix regression tests of unaccent to work without UTF8 support The tests of unaccent rely on UTF8 characters, and unlike any other test suite in the tree (fuzzystrmatch, citext, hstore, etc.), they would fail if run on a database that does not support UTF8 encoding. This commit fixes the tests of

pgsql: Show information about flex (version and command path) in meson

2023-07-03 Thread Michael Paquier
Show information about flex (version and command path) in meson output Like bison, this is useful to know which version and command of flex are detected by meson. For example, this was useful for me when using win_flex.exe on Windows. Reviewed-by: Peter Eisentraut Discussion:

pgsql: Increase size of bgw_library_name.

2023-07-03 Thread Nathan Bossart
Increase size of bgw_library_name. This commit increases the size of the bgw_library_name member of the BackgroundWorker struct from BGW_MAXLEN (96) bytes to MAXPGPATH (default of 1024) bytes so that it can store longer file names (e.g., absolute paths). Author: Yurii Rashkovskii Reviewed-by:

pgsql: Fix race in SSI interaction with bitmap heap scan.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with bitmap heap scan. When performing a bitmap heap scan, we don't want to miss concurrent writes that occurred after we observed the heap's rs_nblocks, but before we took predicate locks on index pages. Therefore, we can't skip fetching any heap tuples that are

pgsql: Fix race in SSI interaction with empty btrees.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with empty btrees. When predicate-locking btrees, we have a special case for completely empty btrees, since there is no page to lock. This was racy, because, without buffer lock held, a matching key could be inserted between the _bt_search() and the

pgsql: Fix race in SSI interaction with gin fast path.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with gin fast path. The ginfast.c code previously checked for conflicts in before locking the relevant buffer, leaving a window where a RW conflict could be missed. Re-order. There was also a place where buffer ID and block number were confused while trying to

pgsql: Fix race in SSI interaction with bitmap heap scan.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with bitmap heap scan. When performing a bitmap heap scan, we don't want to miss concurrent writes that occurred after we observed the heap's rs_nblocks, but before we took predicate locks on index pages. Therefore, we can't skip fetching any heap tuples that are

pgsql: Fix race in SSI interaction with empty btrees.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with empty btrees. When predicate-locking btrees, we have a special case for completely empty btrees, since there is no page to lock. This was racy, because, without buffer lock held, a matching key could be inserted between the _bt_search() and the

pgsql: Fix race in SSI interaction with gin fast path.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with gin fast path. The ginfast.c code previously checked for conflicts in before locking the relevant buffer, leaving a window where a RW conflict could be missed. Re-order. There was also a place where buffer ID and block number were confused while trying to

pgsql: Fix race in SSI interaction with bitmap heap scan.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with bitmap heap scan. When performing a bitmap heap scan, we don't want to miss concurrent writes that occurred after we observed the heap's rs_nblocks, but before we took predicate locks on index pages. Therefore, we can't skip fetching any heap tuples that are

pgsql: Fix race in SSI interaction with empty btrees.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with empty btrees. When predicate-locking btrees, we have a special case for completely empty btrees, since there is no page to lock. This was racy, because, without buffer lock held, a matching key could be inserted between the _bt_search() and the

pgsql: Fix race in SSI interaction with gin fast path.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with gin fast path. The ginfast.c code previously checked for conflicts in before locking the relevant buffer, leaving a window where a RW conflict could be missed. Re-order. There was also a place where buffer ID and block number were confused while trying to

pgsql: Fix race in SSI interaction with empty btrees.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with empty btrees. When predicate-locking btrees, we have a special case for completely empty btrees, since there is no page to lock. This was racy, because, without buffer lock held, a matching key could be inserted between the _bt_search() and the

pgsql: Fix race in SSI interaction with gin fast path.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with gin fast path. The ginfast.c code previously checked for conflicts in before locking the relevant buffer, leaving a window where a RW conflict could be missed. Re-order. There was also a place where buffer ID and block number were confused while trying to

pgsql: Fix race in SSI interaction with bitmap heap scan.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with bitmap heap scan. When performing a bitmap heap scan, we don't want to miss concurrent writes that occurred after we observed the heap's rs_nblocks, but before we took predicate locks on index pages. Therefore, we can't skip fetching any heap tuples that are

pgsql: Fix race in SSI interaction with empty btrees.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with empty btrees. When predicate-locking btrees, we have a special case for completely empty btrees, since there is no page to lock. This was racy, because, without buffer lock held, a matching key could be inserted between the _bt_search() and the

pgsql: Fix race in SSI interaction with bitmap heap scan.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with bitmap heap scan. When performing a bitmap heap scan, we don't want to miss concurrent writes that occurred after we observed the heap's rs_nblocks, but before we took predicate locks on index pages. Therefore, we can't skip fetching any heap tuples that are

pgsql: Fix race in SSI interaction with gin fast path.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with gin fast path. The ginfast.c code previously checked for conflicts in before locking the relevant buffer, leaving a window where a RW conflict could be missed. Re-order. There was also a place where buffer ID and block number were confused while trying to

pgsql: Fix race in SSI interaction with bitmap heap scan.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with bitmap heap scan. When performing a bitmap heap scan, we don't want to miss concurrent writes that occurred after we observed the heap's rs_nblocks, but before we took predicate locks on index pages. Therefore, we can't skip fetching any heap tuples that are

pgsql: Fix race in SSI interaction with empty btrees.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with empty btrees. When predicate-locking btrees, we have a special case for completely empty btrees, since there is no page to lock. This was racy, because, without buffer lock held, a matching key could be inserted between the _bt_search() and the

pgsql: Fix race in SSI interaction with gin fast path.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with gin fast path. The ginfast.c code previously checked for conflicts in before locking the relevant buffer, leaving a window where a RW conflict could be missed. Re-order. There was also a place where buffer ID and block number were confused while trying to

pgsql: Fix race in SSI interaction with empty btrees.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with empty btrees. When predicate-locking btrees, we have a special case for completely empty btrees, since there is no page to lock. This was racy, because, without buffer lock held, a matching key could be inserted between the _bt_search() and the

pgsql: Fix race in SSI interaction with gin fast path.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with gin fast path. The ginfast.c code previously checked for conflicts in before locking the relevant buffer, leaving a window where a RW conflict could be missed. Re-order. There was also a place where buffer ID and block number were confused while trying to

pgsql: Fix race in SSI interaction with bitmap heap scan.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with bitmap heap scan. When performing a bitmap heap scan, we don't want to miss concurrent writes that occurred after we observed the heap's rs_nblocks, but before we took predicate locks on index pages. Therefore, we can't skip fetching any heap tuples that are

pgsql: Don't truncate database and user names in startup packets.

2023-07-03 Thread Nathan Bossart
Don't truncate database and user names in startup packets. Unlike commands such as CREATE DATABASE, ProcessStartupPacket() does not perform multibyte-aware truncation of overlength names. This means that connection attempts might fail even if the user provides the same overlength names that were

pgsql: Consider fillfactor when estimating relation size

2023-07-03 Thread Tomas Vondra
Consider fillfactor when estimating relation size When table_block_relation_estimate_size() estimated the number of tuples in a relation without statistics (e.g. right after load), it did not consider fillfactor when calculating density. With non-default fillfactor values, this may result in

pgsql: Remove expensive test of postgres_fdw batch inserts

2023-07-03 Thread Tomas Vondra
Remove expensive test of postgres_fdw batch inserts The test inserted 70k rows into a foreign table, in order to verify correct behavior with more than 65535 parameters, and was added in response to a bug report. However, this is rather expensive, especially when running the tests under

pgsql: Remove expensive test of postgres_fdw batch inserts

2023-07-03 Thread Tomas Vondra
Remove expensive test of postgres_fdw batch inserts The test inserted 70k rows into a foreign table, in order to verify correct behavior with more than 65535 parameters, and was added in response to a bug report. However, this is rather expensive, especially when running the tests under

pgsql: Remove expensive test of postgres_fdw batch inserts

2023-07-03 Thread Tomas Vondra
Remove expensive test of postgres_fdw batch inserts The test inserted 70k rows into a foreign table, in order to verify correct behavior with more than 65535 parameters, and was added in response to a bug report. However, this is rather expensive, especially when running the tests under

pgsql: Remove expensive test of postgres_fdw batch inserts

2023-07-03 Thread Tomas Vondra
Remove expensive test of postgres_fdw batch inserts The test inserted 70k rows into a foreign table, in order to verify correct behavior with more than 65535 parameters, and was added in response to a bug report. However, this is rather expensive, especially when running the tests under

Re: pgsql: Improve pg_basebackup long file name test Windows robustness

2023-07-03 Thread Andrew Dunstan
On 2023-07-03 Mo 10:51, Andrew Dunstan wrote: On 2023-07-03 Mo 10:19, Daniel Gustafsson wrote: On 3 Jul 2023, at 16:08, Andrew Dunstan wrote: Improve pg_basebackup long file name test Windows robustness Creation of a file with a very long name can create problems on Windows due to its

pgsql: Revert "Improve pg_basebackup long file name test Windows robust

2023-07-03 Thread Andrew Dunstan
Revert "Improve pg_basebackup long file name test Windows robustness" Version 13 and older are missing the required infrastructure. Branch -- REL_13_STABLE Details --- https://git.postgresql.org/pg/commitdiff/753f20c179f7be94a335e9dc67a5d58c6036d119 Modified Files --

pgsql: Revert "Improve pg_basebackup long file name test Windows robust

2023-07-03 Thread Andrew Dunstan
Revert "Improve pg_basebackup long file name test Windows robustness" Version 12 and older are missing the required infrastructure. Branch -- REL_11_STABLE Details --- https://git.postgresql.org/pg/commitdiff/4463a78460eed9d16a2f554a19de574a2fdda0af Modified Files --

pgsql: Revert "Improve pg_basebackup long file name test Windows robust

2023-07-03 Thread Andrew Dunstan
Revert "Improve pg_basebackup long file name test Windows robustness" Version 12 and older are missing the required infrastructure. Branch -- REL_12_STABLE Details --- https://git.postgresql.org/pg/commitdiff/bec0dcb62963403490abdb89983f3472377c828e Modified Files --

Re: pgsql: Improve pg_basebackup long file name test Windows robustness

2023-07-03 Thread Andrew Dunstan
On 2023-07-03 Mo 10:19, Daniel Gustafsson wrote: On 3 Jul 2023, at 16:08, Andrew Dunstan wrote: Improve pg_basebackup long file name test Windows robustness Creation of a file with a very long name can create problems on Windows due to its file path limits. Work around that by creating the

pgsql: Use older package name in pg_basebackup test

2023-07-03 Thread Andrew Dunstan
Use older package name in pg_basebackup test Commit 83ed4de20f inadvertently used the new package names. In version 14 or older, use TestLib intead of using PostgreSQL::Test::Utils Branch -- REL_13_STABLE Details ---

pgsql: Use older package name in pg_basebackup test

2023-07-03 Thread Andrew Dunstan
Use older package name in pg_basebackup test Commit 83ed4de20f inadvertently used the new package names. In version 14 or older, use TestLib intead of using PostgreSQL::Test::Utils Branch -- REL_14_STABLE Details ---

pgsql: Use older package name in pg_basebackup test

2023-07-03 Thread Andrew Dunstan
Use older package name in pg_basebackup test Commit 83ed4de20f inadvertently used the new package names. In version 14 or older, use TestLib intead of using PostgreSQL::Test::Utils Branch -- REL_11_STABLE Details ---

pgsql: Use older package name in pg_basebackup test

2023-07-03 Thread Andrew Dunstan
Use older package name in pg_basebackup test Commit 83ed4de20f inadvertently used the new package names. In version 14 or older, use TestLib intead of using PostgreSQL::Test::Utils Branch -- REL_12_STABLE Details ---

Re: pgsql: Improve pg_basebackup long file name test Windows robustness

2023-07-03 Thread Daniel Gustafsson
> On 3 Jul 2023, at 16:08, Andrew Dunstan wrote: > > Improve pg_basebackup long file name test Windows robustness > > Creation of a file with a very long name can create problems on Windows > due to its file path limits. Work around that by creating the file via a > symlink with a shorter name.

pgsql: Improve pg_basebackup long file name test Windows robustness

2023-07-03 Thread Andrew Dunstan
Improve pg_basebackup long file name test Windows robustness Creation of a file with a very long name can create problems on Windows due to its file path limits. Work around that by creating the file via a symlink with a shorter name. Error displayed by buildfarm animal fairywren.o Backpatch to

pgsql: Improve pg_basebackup long file name test Windows robustness

2023-07-03 Thread Andrew Dunstan
Improve pg_basebackup long file name test Windows robustness Creation of a file with a very long name can create problems on Windows due to its file path limits. Work around that by creating the file via a symlink with a shorter name. Error displayed by buildfarm animal fairywren.o Backpatch to

pgsql: Improve pg_basebackup long file name test Windows robustness

2023-07-03 Thread Andrew Dunstan
Improve pg_basebackup long file name test Windows robustness Creation of a file with a very long name can create problems on Windows due to its file path limits. Work around that by creating the file via a symlink with a shorter name. Error displayed by buildfarm animal fairywren.o Backpatch to

pgsql: Improve pg_basebackup long file name test Windows robustness

2023-07-03 Thread Andrew Dunstan
Improve pg_basebackup long file name test Windows robustness Creation of a file with a very long name can create problems on Windows due to its file path limits. Work around that by creating the file via a symlink with a shorter name. Error displayed by buildfarm animal fairywren.o Backpatch to

pgsql: Improve pg_basebackup long file name test Windows robustness

2023-07-03 Thread Andrew Dunstan
Improve pg_basebackup long file name test Windows robustness Creation of a file with a very long name can create problems on Windows due to its file path limits. Work around that by creating the file via a symlink with a shorter name. Error displayed by buildfarm animal fairywren.o Backpatch to

pgsql: Improve pg_basebackup long file name test Windows robustness

2023-07-03 Thread Andrew Dunstan
Improve pg_basebackup long file name test Windows robustness Creation of a file with a very long name can create problems on Windows due to its file path limits. Work around that by creating the file via a symlink with a shorter name. Error displayed by buildfarm animal fairywren.o Backpatch to

pgsql: Improve pg_basebackup long file name test Windows robustness

2023-07-03 Thread Andrew Dunstan
Improve pg_basebackup long file name test Windows robustness Creation of a file with a very long name can create problems on Windows due to its file path limits. Work around that by creating the file via a symlink with a shorter name. Error displayed by buildfarm animal fairywren.o Backpatch to

Re: pgsql: Introduce bloom_filter_size for BRIN bloom opclass

2023-07-03 Thread Tomas Vondra
On 7/3/23 04:18, Andrew Dunstan wrote: > > On 2023-07-02 Su 20:30, Tom Lane wrote: >> Michael Paquier writes: >>> koel has failed its indent step after these commits. I am unsure >>> whether you need to fix this as it does not seem that we have a >>> consensus to automate that, just FYI. >>

pgsql: Fix code indentation violations

2023-07-03 Thread Tomas Vondra
Fix code indentation violations Commits ce5aaea8cd, 2b8b2852bb and 28d03feac3 violated the expected code indentation rules, upsetting the new buildfarm member "koel." Discussion: https://postgr.es/m/ZKIU4mhWpgJOM0W0%40paquier.xyz Branch -- master Details ---

pgsql: A minor simplification for List manipulation

2023-07-03 Thread Peter Eisentraut
A minor simplification for List manipulation Fix one place that was using lfirst(list_head(list)) by using linitial(list) instead. They are equivalent but the latter is simpler. We did the same in 9d299a49. Author: Richard Guo Discussion:

pgsql: Update PG_CACHE_LINE_SIZE description.

2023-07-03 Thread Heikki Linnakangas
Update PG_CACHE_LINE_SIZE description. PG_CACHE_LINE_SIZE was originally only used in xlog.c, but this hasn't been true for a very long time and is now wildly used, so modify its description to not mention any explicit source code file. Author: Julien Rouhaud Discussion:

pgsql: cirrus/freebsd: define ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS

2023-07-03 Thread Peter Eisentraut
cirrus/freebsd: define ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS See also: 54100f5c6052404f68de9ce7310ceb61f1c2918f Author: Justin Pryzby Discussion: https://www.postgresql.org/message-id/flat/20220528153741.gk19...@telsasoft.com Branch -- master Details ---