pgsql: Add backend-level statistics to pgstats

2024-12-18 Thread Michael Paquier
Add backend-level statistics to pgstats This adds a new variable-numbered statistics kind in pgstats, where the object ID key of the stats entries is based on the proc number of the backends. This acts as an upper-bound for the number of stats entries that can exist at once. The entries are crea

pgsql: Extract logic filling pg_stat_get_io()'s tuplestore into its own

2024-12-18 Thread Michael Paquier
Extract logic filling pg_stat_get_io()'s tuplestore into its own routine This commit adds pg_stat_io_build_tuples(), a helper routine for pg_stat_get_io(), that fills its result tuplestore based on the contents of PgStat_BktypeIO. This will be used in a follow-up commit that uses the same structu

pgsql: Optimize grouping equality checks with virtual slots

2024-12-18 Thread David Rowley
Optimize grouping equality checks with virtual slots 8f4ee9626 fixed an old Assert failure that could happen when the slot type used to look up the hash table for BuildTupleHashTableExt() users wasn't a TTSOpsMinimalTuple slot. The fix for that in the back branches had to be to pass the TupleTabl

pgsql: Fix Assert failure in WITH RECURSIVE UNION queries

2024-12-18 Thread David Rowley
Fix Assert failure in WITH RECURSIVE UNION queries If the non-recursive part of a recursive CTE ended up using TTSOpsBufferHeapTuple as the table slot type, then a duplicate value could cause an Assert failure in CheckOpSlotCompatibility() when checking the hash table for the duplicate value. The

pgsql: Fix Assert failure in WITH RECURSIVE UNION queries

2024-12-18 Thread David Rowley
Fix Assert failure in WITH RECURSIVE UNION queries If the non-recursive part of a recursive CTE ended up using TTSOpsBufferHeapTuple as the table slot type, then a duplicate value could cause an Assert failure in CheckOpSlotCompatibility() when checking the hash table for the duplicate value. The

pgsql: Fix Assert failure in WITH RECURSIVE UNION queries

2024-12-18 Thread David Rowley
Fix Assert failure in WITH RECURSIVE UNION queries If the non-recursive part of a recursive CTE ended up using TTSOpsBufferHeapTuple as the table slot type, then a duplicate value could cause an Assert failure in CheckOpSlotCompatibility() when checking the hash table for the duplicate value. The

pgsql: Fix Assert failure in WITH RECURSIVE UNION queries

2024-12-18 Thread David Rowley
Fix Assert failure in WITH RECURSIVE UNION queries If the non-recursive part of a recursive CTE ended up using TTSOpsBufferHeapTuple as the table slot type, then a duplicate value could cause an Assert failure in CheckOpSlotCompatibility() when checking the hash table for the duplicate value. The

pgsql: Fix Assert failure in WITH RECURSIVE UNION queries

2024-12-18 Thread David Rowley
Fix Assert failure in WITH RECURSIVE UNION queries If the non-recursive part of a recursive CTE ended up using TTSOpsBufferHeapTuple as the table slot type, then a duplicate value could cause an Assert failure in CheckOpSlotCompatibility() when checking the hash table for the duplicate value. The

pgsql: Fix Assert failure in WITH RECURSIVE UNION queries

2024-12-18 Thread David Rowley
Fix Assert failure in WITH RECURSIVE UNION queries If the non-recursive part of a recursive CTE ended up using TTSOpsBufferHeapTuple as the table slot type, then a duplicate value could cause an Assert failure in CheckOpSlotCompatibility() when checking the hash table for the duplicate value. The

pgsql: Remove leftover mentions of XLOG_HEAP2_FREEZE_PAGE records

2024-12-18 Thread Melanie Plageman
Remove leftover mentions of XLOG_HEAP2_FREEZE_PAGE records f83d709760d merged the separate XLOG_HEAP2_FREEZE_PAGE records into a new combined prune, freeze, and vacuum record with opcode XLOG_HEAP2_PRUNE_VACUUM_SCAN. Remove the last few references to XLOG_HEAP2_FREEZE_PAGE records which were accid

pgsql: Bitmap Table Scans use unified TBMIterator

2024-12-18 Thread Melanie Plageman
Bitmap Table Scans use unified TBMIterator With the repurposing of TBMIterator as an interface for both parallel and serial iteration through TIDBitmaps in commit 7f9d4187e7bab10329cc, bitmap table scans may now use it. Modify bitmap table scan code to use the TBMIterator. This requires moving ar

pgsql: Add common interface for TBMIterators

2024-12-18 Thread Melanie Plageman
Add common interface for TBMIterators Add and use TBMPrivateIterator, which replaces the current TBMIterator for serial use cases, and repurpose TBMIterator to be a unified interface for both the serial ("private") and parallel ("shared") TID Bitmap iterator interfaces. This encapsulation simplifi

pgsql: Fix overflow danger in SampleHeapTupleVisible()

2024-12-18 Thread Melanie Plageman
Fix overflow danger in SampleHeapTupleVisible() 68d9662be1c4b70 made HeapScanDesc->rs_ntuples unsigned but neglected to change how it was being used in SampleHeapTupleVisible(). Return early if rs_ntuples is 0 to avoid overflowing and incorrectly executing the loop code in SampleHeapTupleVisible(

Re: pgsql: seg: pure parser and reentrant scanner

2024-12-18 Thread Melanie Plageman
On Wed, Dec 18, 2024 at 2:57 AM Peter Eisentraut wrote: > > seg: pure parser and reentrant scanner sifaka is failing [1] with cubescan.c:348:15: error: redefinition of typedef 'yyscan_t' is a C11 feature [-Werror,-Wtypedef-redefinition] 348 | typedef void* yyscan_t; | ^ ./c

pgsql: Make rs_cindex and rs_ntuples unsigned

2024-12-18 Thread Melanie Plageman
Make rs_cindex and rs_ntuples unsigned HeapScanDescData.rs_cindex and rs_ntuples can't be less than 0. All scan types using the heap scan descriptor expect these values to be >= 0. Make that expectation clear by making rs_cindex and rs_ntuples unsigned. Also remove the test in heapam_scan_bitmap_