pgsql: cube: pure parser and reentrant scanner

2024-12-17 Thread Peter Eisentraut
cube: pure parser and reentrant scanner Use the flex %option reentrant and the bison option %pure-parser to make the generated scanner and parser pure, reentrant, and thread-safe. Make the generated scanner use palloc() etc. instead of malloc() etc. Previously, we only used palloc() for the buffe

pgsql: seg: pure parser and reentrant scanner

2024-12-17 Thread Peter Eisentraut
seg: pure parser and reentrant scanner Use the flex %option reentrant and the bison option %pure-parser to make the generated scanner and parser pure, reentrant, and thread-safe. Make the generated scanner use palloc() etc. instead of malloc() etc. Previously, we only used palloc() for the buffer

pgsql: psql: Add more information about service name

2024-12-17 Thread Michael Paquier
psql: Add more information about service name This commit adds support for the following items in psql, able to show a service name, when available: - Variable SERVICE. - Substitution %s in PROMPT{1,2,3}. This relies on 4b99fed7541e, that has made the service name available in PGconn for libpq.

pgsql: libpq: Add service name to PGconn and PQservice()

2024-12-17 Thread Michael Paquier
libpq: Add service name to PGconn and PQservice() This commit adds one field to PGconn for the database service name (if any), with PQservice() as routine to retrieve it. Like the other routines of this area, NULL is returned as result if the connection is NULL. A follow-up patch will make use o

pgsql: Fix memory leak in pg_restore with zstd-compressed data.

2024-12-17 Thread Tom Lane
Fix memory leak in pg_restore with zstd-compressed data. EndCompressorZstd() neglected to free everything. This was most visible with a lot of large objects in the dump. Per report from Tomasz Szypowski. Back-patch to v16 where this code came in. Discussion: https://postgr.es/m/du0pr04mb94193

pgsql: Fix memory leak in pg_restore with zstd-compressed data.

2024-12-17 Thread Tom Lane
Fix memory leak in pg_restore with zstd-compressed data. EndCompressorZstd() neglected to free everything. This was most visible with a lot of large objects in the dump. Per report from Tomasz Szypowski. Back-patch to v16 where this code came in. Discussion: https://postgr.es/m/du0pr04mb94193

pgsql: Fix memory leak in pg_restore with zstd-compressed data.

2024-12-17 Thread Tom Lane
Fix memory leak in pg_restore with zstd-compressed data. EndCompressorZstd() neglected to free everything. This was most visible with a lot of large objects in the dump. Per report from Tomasz Szypowski. Back-patch to v16 where this code came in. Discussion: https://postgr.es/m/du0pr04mb94193

pgsql: Fix incorrect slot type in BuildTupleHashTableExt

2024-12-17 Thread David Rowley
Fix incorrect slot type in BuildTupleHashTableExt 0f5738202 adjusted the execGrouping.c code so it made use of ExprStates to generate hash values. That commit made a wrong assumption that the slot type to pass to ExecBuildHash32FromAttrs() is always &TTSOpsMinimalTuple. That's not the case as the

pgsql: Accommodate very large dshash tables.

2024-12-17 Thread Nathan Bossart
Accommodate very large dshash tables. If a dshash table grows very large (e.g., the dshash table for cumulative statistics when there are millions of tables), resizing it may fail with an error like: ERROR: invalid DSA memory alloc request size 1073741824 To fix, permit dshash resizing t

pgsql: Accommodate very large dshash tables.

2024-12-17 Thread Nathan Bossart
Accommodate very large dshash tables. If a dshash table grows very large (e.g., the dshash table for cumulative statistics when there are millions of tables), resizing it may fail with an error like: ERROR: invalid DSA memory alloc request size 1073741824 To fix, permit dshash resizing t

pgsql: Accommodate very large dshash tables.

2024-12-17 Thread Nathan Bossart
Accommodate very large dshash tables. If a dshash table grows very large (e.g., the dshash table for cumulative statistics when there are millions of tables), resizing it may fail with an error like: ERROR: invalid DSA memory alloc request size 1073741824 To fix, permit dshash resizing t

pgsql: Accommodate very large dshash tables.

2024-12-17 Thread Nathan Bossart
Accommodate very large dshash tables. If a dshash table grows very large (e.g., the dshash table for cumulative statistics when there are millions of tables), resizing it may fail with an error like: ERROR: invalid DSA memory alloc request size 1073741824 To fix, permit dshash resizing t

pgsql: Accommodate very large dshash tables.

2024-12-17 Thread Nathan Bossart
Accommodate very large dshash tables. If a dshash table grows very large (e.g., the dshash table for cumulative statistics when there are millions of tables), resizing it may fail with an error like: ERROR: invalid DSA memory alloc request size 1073741824 To fix, permit dshash resizing t

pgsql: Accommodate very large dshash tables.

2024-12-17 Thread Nathan Bossart
Accommodate very large dshash tables. If a dshash table grows very large (e.g., the dshash table for cumulative statistics when there are millions of tables), resizing it may fail with an error like: ERROR: invalid DSA memory alloc request size 1073741824 To fix, permit dshash resizing t

pgsql: Skip useless calculation of join RTE column names during EXPLAIN

2024-12-17 Thread Tom Lane
Skip useless calculation of join RTE column names during EXPLAIN. There's no need for set_simple_column_names() to compute unique column names for join RTEs, because a finished plan tree will not contain any join alias Vars that we could need names for. Its other, internal callers will not pass it

pgsql: Rename LVRelState->frozen_pages

2024-12-17 Thread Melanie Plageman
Rename LVRelState->frozen_pages Rename frozen_pages to new_frozen_tuple_pages in LVRelState, the struct used for tracking state during vacuuming of a heap relation. frozen_pages sounds like it tracks pages set all-frozen. That is a misnomer. It only includes pages with at least one newly frozen tu

pgsql: Count pages set all-visible and all-frozen in VM during vacuum

2024-12-17 Thread Melanie Plageman
Count pages set all-visible and all-frozen in VM during vacuum Heap vacuum already counts and logs pages with newly frozen tuples. Now count and log the number of pages newly set all-visible and all-frozen in the visibility map. Pages that are all-visible but not all-frozen are debt for future ag

pgsql: Make visibilitymap_set() return previous state of vmbits

2024-12-17 Thread Melanie Plageman
Make visibilitymap_set() return previous state of vmbits It can be useful to know the state of a relation page's VM bits before visibilitymap_set(). visibilitymap_set() has the old value on hand, so returning it is simple. This commit does not use visibilitymap_set()'s new return value. Author: M

pgsql: Set the stack_base_ptr in main(), not in random other places.

2024-12-17 Thread Tom Lane
Set the stack_base_ptr in main(), not in random other places. Previously we did this in PostmasterMain() and InitPostmasterChild(), which meant that stack depth checking was disabled in non-postmaster server processes, for instance in single-user mode. That seems like a fairly bad idea, since the

pgsql: Set max_safe_fds whenever we create shared memory and semaphores

2024-12-17 Thread Tom Lane
Set max_safe_fds whenever we create shared memory and semaphores. Formerly we skipped this in bootstrap/check mode and in single-user mode. That's bad in check mode because it may allow accepting a value of max_connections that doesn't actually work: on platforms where semaphores consume file des

pgsql: Detect version mismatch in brin_page_items

2024-12-17 Thread Tomas Vondra
Detect version mismatch in brin_page_items Commit dae761a87ed modified brin_page_items() to return the new "empty" flag for each BRIN range. But the new output parameter was added in the middle, which may cause crashes when using the new binary with old function definition. The ideal solution wou

pgsql: Detect version mismatch in brin_page_items

2024-12-17 Thread Tomas Vondra
Detect version mismatch in brin_page_items Commit dae761a87ed modified brin_page_items() to return the new "empty" flag for each BRIN range. But the new output parameter was added in the middle, which may cause crashes when using the new binary with old function definition. The ideal solution wou

pgsql: Update comments about index parallel builds

2024-12-17 Thread Tomas Vondra
Update comments about index parallel builds Commit b43757171470 allowed parallel builds for BRIN, but left behind two comments claiming only btree indexes support parallel builds. Reported by Egor Rogov, along with similar issues in SGML docs. Backpatch to 17, where parallel builds for BRIN were

pgsql: Update comments about index parallel builds

2024-12-17 Thread Tomas Vondra
Update comments about index parallel builds Commit b43757171470 allowed parallel builds for BRIN, but left behind two comments claiming only btree indexes support parallel builds. Reported by Egor Rogov, along with similar issues in SGML docs. Backpatch to 17, where parallel builds for BRIN were

pgsql: Remove ts_locale.c's lowerstr()

2024-12-17 Thread Peter Eisentraut
Remove ts_locale.c's lowerstr() lowerstr() and lowerstr_with_len() in ts_locale.c do the same thing as str_tolower() that the rest of the system uses, except that the former don't use the common locale provider framework but instead use the global libc locale settings. This patch replaces uses of

pgsql: Remove ts_locale.c's t_isdigit(), t_isspace(), t_isprint()

2024-12-17 Thread Peter Eisentraut
Remove ts_locale.c's t_isdigit(), t_isspace(), t_isprint() These do the same thing as the standard isdigit(), isspace(), and isprint() but with multibyte and encoding support. But all the callers are only interested in analyzing single-byte ASCII characters. So this extra layer is overkill and we

pgsql: Avoid unnecessary wrapping for more complex expressions

2024-12-17 Thread Richard Guo
Avoid unnecessary wrapping for more complex expressions When pulling up a subquery that is under an outer join, if the subquery's target list contains a strict expression that uses a subquery variable, it's okay to pull up the expression without wrapping it in a PlaceHolderVar: if the subquery var

pgsql: Doc: Fix the wrong link on pg_createsubscriber page.

2024-12-17 Thread Amit Kapila
Doc: Fix the wrong link on pg_createsubscriber page. Commit 84db9a0eb1 has added the incorrect link to 'initial data synchronization'. It was a subsection of Row Filter and didn't provide the required information. Author: Peter Smith Reviewed-by: Vignesh C, Pavel Luzanov Backpatch-through: 17, wh

pgsql: Doc: Fix the wrong link on pg_createsubscriber page.

2024-12-17 Thread Amit Kapila
Doc: Fix the wrong link on pg_createsubscriber page. Commit 84db9a0eb1 has added the incorrect link to 'initial data synchronization'. It was a subsection of Row Filter and didn't provide the required information. Author: Peter Smith Reviewed-by: Vignesh C, Pavel Luzanov Backpatch-through: 17, wh