pgsql: Optimize alignment calculations in tuple form/deform

2024-12-20 Thread David Rowley
Optimize alignment calculations in tuple form/deform Here we convert CompactAttribute.attalign from a char, which is directly derived from pg_attribute.attalign into a uint8, which stores the number of bytes to align the column's value by in the tuple. This allows tuple deformation and tuple size

pgsql: Mark CatalogSnapshotData static

2024-12-20 Thread Heikki Linnakangas
Mark CatalogSnapshotData static Like CurrentSnapshotData, it should not be accessed directly outside snapmgr.c. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/1f81b48a9d567ae9074ab1f3233eae9997b3d7bd Modified Files -- src/backend/utils/time/snapmgr.c |

pgsql: Fix variable reference in comment

2024-12-20 Thread Heikki Linnakangas
Fix variable reference in comment This used to say "nsubxcnt isn't decreased when subtransactions abort", but there's no variable called nsubxcnt. Commit 8548ddc61b changed it to "subxcnt", among other typo fixes, but that was wrong too: the comment actually talks about txn->nsubtxns. That's the f

pgsql: Fix overflow danger in SampleHeapTupleVisible(), take 2

2024-12-20 Thread Melanie Plageman
Fix overflow danger in SampleHeapTupleVisible(), take 2 28328ec87b45725 addressed one overflow danger in SampleHeapTupleVisible() but introduced another, albeit a less likely one. Modify the binary search code to remove this danger. Reported-by: Richard Guo Reviewed-by: Richard Guo, Ranier Vilela

pgsql: Fix corruption when relation truncation fails.

2024-12-20 Thread Thomas Munro
Fix corruption when relation truncation fails. RelationTruncate() does three things, while holding an AccessExclusiveLock and preventing checkpoints: 1. Logs the truncation. 2. Drops buffers, even if they're dirty. 3. Truncates some number of files. Step 2 could previously be canceled if it had

pgsql: Fix corruption when relation truncation fails.

2024-12-20 Thread Thomas Munro
Fix corruption when relation truncation fails. RelationTruncate() does three things, while holding an AccessExclusiveLock and preventing checkpoints: 1. Logs the truncation. 2. Drops buffers, even if they're dirty. 3. Truncates some number of files. Step 2 could previously be canceled if it had

pgsql: Fix corruption when relation truncation fails.

2024-12-20 Thread Thomas Munro
Fix corruption when relation truncation fails. RelationTruncate() does three things, while holding an AccessExclusiveLock and preventing checkpoints: 1. Logs the truncation. 2. Drops buffers, even if they're dirty. 3. Truncates some number of files. Step 2 could previously be canceled if it had

pgsql: Fix corruption when relation truncation fails.

2024-12-20 Thread Thomas Munro
Fix corruption when relation truncation fails. RelationTruncate() does three things, while holding an AccessExclusiveLock and preventing checkpoints: 1. Logs the truncation. 2. Drops buffers, even if they're dirty. 3. Truncates some number of files. Step 2 could previously be canceled if it had

pgsql: Fix corruption when relation truncation fails.

2024-12-20 Thread Thomas Munro
Fix corruption when relation truncation fails. RelationTruncate() does three things, while holding an AccessExclusiveLock and preventing checkpoints: 1. Logs the truncation. 2. Drops buffers, even if they're dirty. 3. Truncates some number of files. Step 2 could previously be canceled if it had

pgsql: Fix corruption when relation truncation fails.

2024-12-20 Thread Thomas Munro
Fix corruption when relation truncation fails. RelationTruncate() does three things, while holding an AccessExclusiveLock and preventing checkpoints: 1. Logs the truncation. 2. Drops buffers, even if they're dirty. 3. Truncates some number of files. Step 2 could previously be canceled if it had

pgsql: Remove pg_attribute.attcacheoff column

2024-12-20 Thread David Rowley
Remove pg_attribute.attcacheoff column The column is no longer needed as the offset is now cached in the CompactAttribute struct per commit 5983a4cff. Author: David Rowley Reviewed-by: Andres Freund, Victor Yegorov Discussion: https://postgr.es/m/CAApHDvrBztXP3yx=NKNmo3xwFAFhEdyPnvrDg3=m0rhds+4.

pgsql: Relax regression test for fsync check of backend-level stats

2024-12-20 Thread Michael Paquier
Relax regression test for fsync check of backend-level stats One test added in 9aea73fc61d4 did not take into account that the backend may have some fsync even after a checkpoint. Let's relax it to be more flexible. Per report from buildfarm member grassquit, via Alexander Lakhin. Author: Bertr

pgsql: Introduce CompactAttribute array in TupleDesc, take 2

2024-12-20 Thread David Rowley
Introduce CompactAttribute array in TupleDesc, take 2 The new compact_attrs array stores a few select fields from FormData_pg_attribute in a more compact way, using only 16 bytes per column instead of the 104 bytes that FormData_pg_attribute uses. Using CompactAttribute allows performance-critica