pgsql: test_custom_stats: Test module for custom cumulative statistics

2025-12-07 Thread Michael Paquier
test_custom_stats: Test module for custom cumulative statistics This test module acts as a replacement that existed prior to d52c24b0f808 in the test module injection_points. It uses a more flexible structure than its ancestor: - Two libraries are built, one for fixed-sized stats and one for vari

pgsql: Prevent invalidation of newly created replication slots.

2025-12-07 Thread Amit Kapila
Prevent invalidation of newly created replication slots. A race condition could cause a newly created replication slot to become invalidated between WAL reservation and a checkpoint. Previously, if the required WAL was removed, we retried the reservation process. However, the slot could still be

pgsql: Prevent invalidation of newly created replication slots.

2025-12-07 Thread Amit Kapila
Prevent invalidation of newly created replication slots. A race condition could cause a newly created replication slot to become invalidated between WAL reservation and a checkpoint. Previously, if the required WAL was removed, we retried the reservation process. However, the slot could still be

Re: pgsql: injection_points: Remove portions related to custom pgstats

2025-12-07 Thread Tom Lane
Michael Paquier writes: > On Sun, Dec 07, 2025 at 11:15:13PM -0500, Tom Lane wrote: >> I think that this is really a bug in the Xversion-update test, because >> I don't see why we'd be holding src/test/modules libraries to the >> standard of can-be-upgraded-across-versions. But maybe there's >> s

Re: pgsql: injection_points: Remove portions related to custom pgstats

2025-12-07 Thread Michael Paquier
On Sun, Dec 07, 2025 at 11:15:13PM -0500, Tom Lane wrote: > I think that this is really a bug in the Xversion-update test, because > I don't see why we'd be holding src/test/modules libraries to the > standard of can-be-upgraded-across-versions. But maybe there's > something I'm missing? Yes, I'v

Re: pgsql: injection_points: Remove portions related to custom pgstats

2025-12-07 Thread Tom Lane
Michael Paquier writes: > injection_points: Remove portions related to custom pgstats BF member crake is unhappy with this, because it broke cross-version update tests [1]: pg_restore: while PROCESSING TOC: pg_restore: from TOC entry 230; 1255 55098 FUNCTION injection_points_stats_drop() buildf

pgsql: injection_points: Remove portions related to custom pgstats

2025-12-07 Thread Michael Paquier
injection_points: Remove portions related to custom pgstats The test module injection_points has been used as a landing spot to provide coverage for the custom pgstats APIs, for both fixed-sized and variable-sized stats kinds. Some recent work related to pgstats is proving that this structure mak

pgsql: Improve error messages of input functions for pg_dependencies an

2025-12-07 Thread Michael Paquier
Improve error messages of input functions for pg_dependencies and pg_ndistinct The error details updated in this commit can be reached in the regression tests. They did not follow the project style, and they should be written them as full sentences. Some of the errors are switched to use an elog

pgsql: ecpg: refactor to eliminate cast-away-const in find_variable().

2025-12-07 Thread Tom Lane
ecpg: refactor to eliminate cast-away-const in find_variable(). find_variable() and its subroutines transiently scribble on the passed-in "name" string, even though we've declared that "const". The string is in fact temporary, so this is not very harmful, but it's confusing and will produce compil

pgsql: Revise APIs for pushJsonbValue() and associated routines.

2025-12-07 Thread Tom Lane
Revise APIs for pushJsonbValue() and associated routines. Instead of passing "JsonbParseState **" to pushJsonbValue(), pass a pointer to a JsonbInState, which will contain the parseState stack pointer as well as other useful fields. Also, instead of returning a JsonbValue pointer that is often mea

pgsql: Remove fundamentally-redundant processing in jsonb_agg() et al.

2025-12-07 Thread Tom Lane
Remove fundamentally-redundant processing in jsonb_agg() et al. The various variants of jsonb_agg() operate as follows, for each aggregate input value: 1. Build a JsonbValue tree representation of the input value. 2. Flatten the JsonbValue tree into a Jsonb in on-disk format. 3. Iterate through t

pgsql: Add a macro for the declared typlen of type timetz.

2025-12-07 Thread Tom Lane
Add a macro for the declared typlen of type timetz. pg_type.typlen says 12 for the size of timetz, but sizeof(TimeTzADT) will be 16 on most platforms due to alignment padding. Using the sizeof number is no problem for usages such as palloc'ing a result datum, but in usages such as datumCopy we re

pgsql: Micro-optimize datatype conversions in datum_to_jsonb_internal.

2025-12-07 Thread Tom Lane
Micro-optimize datatype conversions in datum_to_jsonb_internal. The general case for converting to a JSONB numeric value is to run the source datatype's output function and then numeric_in, but we can do substantially better than that for integer and numeric source values. This patch improves the