pgsql: Remove provider field from pg_locale_t.

2025-07-01 Thread Jeff Davis
Remove provider field from pg_locale_t.

The behavior of pg_locale_t is specified by methods, so a separate
provider field is no longer necessary.

Reviewed-by: Andreas Karlsson 
Reviewed-by: Peter Eisentraut 
Discussion: 
https://postgr.es/m/2830211e1b6e6a2e26d845780b03e125281ea17b.camel%40j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/8af0d0ab01b406b8671ff4426acfe9b1d2af30d8

Modified Files
--
src/backend/utils/adt/pg_locale_builtin.c |  1 -
src/backend/utils/adt/pg_locale_icu.c | 11 ---
src/backend/utils/adt/pg_locale_libc.c|  6 --
src/include/utils/pg_locale.h |  1 -
4 files changed, 19 deletions(-)



pgsql: Control ctype behavior internally with a method table.

2025-07-01 Thread Jeff Davis
Control ctype behavior internally with a method table.

Previously, pattern matching and case mapping behavior branched based
on the provider. Refactor to use a method table, which is less
error-prone.

This is also a step toward multiple provider versions, which we may
want to support in the future.

Reviewed-by: Andreas Karlsson 
Reviewed-by: Peter Eisentraut 
Discussion: 
https://postgr.es/m/2830211e1b6e6a2e26d845780b03e125281ea17b.camel%40j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/5a38104b364234615c780656a8b2424f96ed9efa

Modified Files
--
src/backend/regex/regc_pg_locale.c| 429 ++
src/backend/utils/adt/like.c  |  22 +-
src/backend/utils/adt/like_support.c  |   7 +-
src/backend/utils/adt/pg_locale.c | 121 +++--
src/backend/utils/adt/pg_locale_builtin.c | 111 +++-
src/backend/utils/adt/pg_locale_icu.c | 119 -
src/backend/utils/adt/pg_locale_libc.c| 331 ---
src/include/utils/pg_locale.h |  53 
src/tools/pgindent/typedefs.list  |   1 -
9 files changed, 686 insertions(+), 508 deletions(-)



pgsql: Use pg_ascii_tolower()/pg_ascii_toupper() where appropriate.

2025-07-01 Thread Jeff Davis
Use pg_ascii_tolower()/pg_ascii_toupper() where appropriate.

Avoids unnecessary dependence on setlocale(). No behavior change.

This commit reverts e1458f2f1b, which reverted some changes
unintentionally committed before the branch for 19.

Reviewed-by: Peter Eisentraut 
Discussion: 
https://postgr.es/m/a8666c391dfcabe79868d95f7160eac533ace718.ca...@j-davis.com
Discussion: 
https://postgr.es/m/7efaaa645aa5df3771bb47b9c35df27e08f3520e.ca...@j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/d81dcc8d6243054e3bde40c6fb2b2a0be4b19da6

Modified Files
--
contrib/isn/isn.c | 4 ++--
contrib/spi/refint.c  | 2 +-
src/backend/commands/copyfromparse.c  | 2 +-
src/backend/utils/adt/inet_net_pton.c | 3 +--
4 files changed, 5 insertions(+), 6 deletions(-)



pgsql: Correct docs about partitions and EXCLUDE constraints.

2025-06-19 Thread Jeff Davis
Correct docs about partitions and EXCLUDE constraints.

In version 17 we added support for cross-partition EXCLUDE
constraints, as long as they included all partition key columns and
compared them with equality (see 8c852ba9a4). I updated the docs for
exclusion constraints, but I missed that the docs for CREATE TABLE
still said that they were not supported. This commit fixes that.

Author: Paul A. Jungwirth 
Co-authored-by: Jeff Davis 
Discussion: 
https://postgr.es/m/c955d292-b92d-42d1-a2a0-1ec6715a2...@illuminatedcomputing.com
Backpatch-through: 17

Branch
--
REL_17_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/0f5ac7f321fbe19e666b5c5f19218f6ff5cd8c83

Modified Files
--
doc/src/sgml/ref/create_table.sgml | 17 -
1 file changed, 12 insertions(+), 5 deletions(-)



pgsql: Correct docs about partitions and EXCLUDE constraints.

2025-06-19 Thread Jeff Davis
Correct docs about partitions and EXCLUDE constraints.

In version 17 we added support for cross-partition EXCLUDE
constraints, as long as they included all partition key columns and
compared them with equality (see 8c852ba9a4). I updated the docs for
exclusion constraints, but I missed that the docs for CREATE TABLE
still said that they were not supported. This commit fixes that.

Author: Paul A. Jungwirth 
Co-authored-by: Jeff Davis 
Discussion: 
https://postgr.es/m/c955d292-b92d-42d1-a2a0-1ec6715a2...@illuminatedcomputing.com
Backpatch-through: 17

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/6c29088fc6e269b7d64797bb62533b82afe03d93

Modified Files
--
doc/src/sgml/ref/create_table.sgml | 17 -
1 file changed, 12 insertions(+), 5 deletions(-)



pgsql: Comment fixups from 626df47ad9.

2025-06-13 Thread Jeff Davis
Comment fixups from 626df47ad9.

Reported-by: Peter Smith 
Discussion: 
https://postgr.es/m/cahut+pspbhqmrcbl1c-opojetukuafffuqjd2rhdzqwurwc...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/a0c7b765372d949cec54960dafcaadbc04b3204e

Modified Files
--
src/backend/executor/execGrouping.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgsql: Revert a few small patches that were intended for version 19.

2025-06-11 Thread Jeff Davis
Revert a few small patches that were intended for version 19.

- 4c787a24e7e220a60022e47c1776f22f72902899
- 78bd364ee39ca70a8f9cb8719282389866a08e14
- 7a6880fadc177873d5663961ec3a02d67e34dcbe
- 8898082a5d3e94eef073f0e08124137e096e78ef

Suggested-by: Robert Haas 
Discussion: 
https://postgr.es/m/CA+TgmoZ=J=pvnzunkaxulu+kuvst3y-aj1dz9y3co6mu0z6...@mail.gmail.com
Discussion: 
https://postgr.es/m/60e8c6d0a6c08e67f15dbbe9e53df0119c710065.ca...@j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/e1458f2f1b56cfe07b3e8fc99b223ea8c852d7ce

Modified Files
--
contrib/isn/isn.c | 4 ++--
contrib/spi/refint.c  | 2 +-
src/backend/commands/copyfromparse.c  | 2 +-
src/backend/utils/adt/inet_net_pton.c | 3 ++-
4 files changed, 6 insertions(+), 5 deletions(-)



Re: pgsql: copyfromparse.c: use pg_ascii_tolower() rather than tolower().

2025-06-11 Thread Jeff Davis
On Wed, 2025-06-11 at 16:07 -0400, Robert Haas wrote:
> All 3 of these commits seem like things that could just as well have
> been done after we branch.

Yeah, I called out my mistake here:

https://www.postgresql.org/message-id/60e8c6d0a6c08e67f15dbbe9e53df0119c710065.camel%40j-davis.com

Nobody seemed terribly upset about it so I left them. But for the sake
of ending any confusion I just reverted them. I will reapply them in a
few weeks after the branch.

Regards,
    Jeff Davis





Re: pgsql: inet_net_pton.c: use pg_ascii_tolower() rather than tolower().

2025-06-10 Thread Jeff Davis
On Tue, 2025-06-10 at 18:24 +, Jeff Davis wrote:
> inet_net_pton.c: use pg_ascii_tolower() rather than tolower().

These 4 small patches were somewhat of a "false start" on 19 -- sorry
about that. Not sure if it's worth it to revert them and reapply in a
couple weeks, as they look pretty harmless.

Regards,
Jeff Davis





pgsql: copyfromparse.c: use pg_ascii_tolower() rather than tolower().

2025-06-10 Thread Jeff Davis
copyfromparse.c: use pg_ascii_tolower() rather than tolower().

Avoid dependence on setlocale(). No behavior change.

Discussion: 
https://postgr.es/m/9875f7f9-50f1-4b5d-86fc-ee8b03e8c...@eisentraut.org
Reviewed-by: Peter Eisentraut 

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/4c787a24e7e220a60022e47c1776f22f72902899

Modified Files
--
src/backend/commands/copyfromparse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: isn.c: use pg_ascii_toupper() instead of toupper().

2025-06-10 Thread Jeff Davis
isn.c: use pg_ascii_toupper() instead of toupper().

Avoid dependence on setlocale(). No behavior change.

Discussion: 
https://postgr.es/m/9875f7f9-50f1-4b5d-86fc-ee8b03e8c...@eisentraut.org
Reviewed-by: Peter Eisentraut 

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/7a6880fadc177873d5663961ec3a02d67e34dcbe

Modified Files
--
contrib/isn/isn.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgsql: contrib/spi/refint.c: use pg_ascii_tolower() instead.

2025-06-10 Thread Jeff Davis
contrib/spi/refint.c: use pg_ascii_tolower() instead.

Avoid dependence on setlocale(). No behavior change.

Discussion: 
https://postgr.es/m/9875f7f9-50f1-4b5d-86fc-ee8b03e8c...@eisentraut.org
Reviewed-by: Peter Eisentraut 

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/78bd364ee39ca70a8f9cb8719282389866a08e14

Modified Files
--
contrib/spi/refint.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: inet_net_pton.c: use pg_ascii_tolower() rather than tolower().

2025-06-10 Thread Jeff Davis
inet_net_pton.c: use pg_ascii_tolower() rather than tolower().

Avoid dependence on setlocale(). No behavior change.

Discussion: 
https://postgr.es/m/9875f7f9-50f1-4b5d-86fc-ee8b03e8c...@eisentraut.org
Reviewed-by: Peter Eisentraut 

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/8898082a5d3e94eef073f0e08124137e096e78ef

Modified Files
--
src/backend/utils/adt/inet_net_pton.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)



pgsql: Improve CREATE DATABASE error message for invalid libc locale.

2025-06-06 Thread Jeff Davis
Improve CREATE DATABASE error message for invalid libc locale.

Discussion: 
https://postgr.es/m/73959a14-267b-49c1-8293-291b17568...@manitou-mail.org
Reviewed-by: Daniel Verite 

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/5b40feab594c3019fd6b09e46f97f5b367050cf9

Modified Files
--
src/backend/commands/dbcommands.c | 41 +++
1 file changed, 33 insertions(+), 8 deletions(-)



pgsql: Change pg_dump default for statistics export.

2025-05-27 Thread Jeff Davis
Change pg_dump default for statistics export.

Set the default behavior of pg_dump and pg_dumpall to be
--no-statistics.

Leave the default for pg_restore and pg_upgrade to be
--with-statistics.

Discussion: 
https://postgr.es/m/CA+TgmoZ9=rnwccozikyyjzs_aw1p4qxcw--h4dollhuf1om...@mail.gmail.com
Reviewed-by: Greg Sabino Mullane 
Reviewed-by: Nathan Bossart 
Reviewed-by: Robert Haas 
Reviewed-by: Tom Lane 

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/34eb2a80d5a3ea1392e4a9f16ebac54e96d0c6ed

Modified Files
--
doc/src/sgml/ref/pg_dump.sgml| 20 ++--
doc/src/sgml/ref/pg_dumpall.sgml | 20 ++--
src/bin/pg_dump/pg_backup_archiver.c |  2 +-
src/bin/pg_dump/t/002_pg_dump.pl | 59 
src/bin/pg_upgrade/dump.c|  2 +-
5 files changed, 81 insertions(+), 22 deletions(-)



pgsql: Fix INITCAP() word boundaries for PG_UNICODE_FAST.

2025-04-21 Thread Jeff Davis
Fix INITCAP() word boundaries for PG_UNICODE_FAST.

Word boundaries are based on whether a character is alphanumeric or
not. For the PG_UNICODE_FAST collation, alphanumeric includes
non-ASCII digits; whereas for the PG_C_UTF8 collation, it only
includes digits 0-9. Pass down the right information from the
pg_locale_t into initcap_wbnext to differentiate the behavior.

Reported-by: Noah Misch 
Reviewed-by: Noah Misch 
Discussion: https://postgr.es/m/20250417135841.33.nmi...@google.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/90260e2ec6bbfc3dfa9d9501ab75c535de52f677

Modified Files
--
src/backend/utils/adt/pg_locale_builtin.c  |  4 +++-
src/common/unicode/case_test.c | 13 -
src/test/regress/expected/collate.utf8.out |  8 ++--
src/test/regress/sql/collate.utf8.sql  |  2 ++
4 files changed, 23 insertions(+), 4 deletions(-)



pgsql: Improve comment in regc_pg_locale.c.

2025-04-16 Thread Jeff Davis
Improve comment in regc_pg_locale.c.

Reported-by: Noah Misch 
Reviewed-by: Noah Misch 
Discussion: https://postgr.es/m/20250412123430.8c.nmi...@google.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/b107744ce73782a996aaa65dfd9d1bb3c543503d

Modified Files
--
src/backend/regex/regc_pg_locale.c | 29 +
1 file changed, 13 insertions(+), 16 deletions(-)



pgsql: Another unintentional behavior change in commit e9931bfb75.

2025-04-16 Thread Jeff Davis
Another unintentional behavior change in commit e9931bfb75.

Reported-by: Noah Misch 
Reviewed-by: Noah Misch 
Discussion: https://postgr.es/m/20250412123430.8c.nmi...@google.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/2e5353be2534aed99a714f99c8a193f85777e64a

Modified Files
--
src/backend/regex/regc_pg_locale.c | 12 
1 file changed, 12 insertions(+)



Re: pgsql: Transfer statistics during pg_upgrade.

2025-04-08 Thread Jeff Davis
On Tue, 2025-04-08 at 17:24 +1200, David Rowley wrote:
> I was surprised to see when I did pg_dump -T just_this_table that I
> also got statistics data for all tables in the database.

-T means "exclude this pattern"

I tried a few basic variations and they seemed to do what I expected:

   CREATE TABLE mytable1(i INT);
   INSERT INTO mytable1 VALUES(1);
   CREATE TABLE mytable2(i INT);
   INSERT INTO mytable2 VALUES(2);
   CREATE TABLE mytable3(i INT);
   INSERT INTO mytable3 VALUES(3);
   ANALYZE;

   $ ./bin/pg_dump -t mytable1 postgres | grep "Name: mytable"
   -- Name: mytable1; Type: TABLE; Schema: public; Owner: jdavis
   -- Data for Name: mytable1; Type: TABLE DATA; Schema: ...
   -- Statistics for Name: mytable1; Type: STATISTICS DATA; ...

   $ ./bin/pg_dump -T mytable1 postgres | grep "Name: mytable"
   -- Name: mytable2; Type: TABLE; Schema: public; Owner: jdavis
   -- Name: mytable3; Type: TABLE; Schema: public; Owner: jdavis
   -- Data for Name: mytable2; Type: TABLE DATA; Schema: ...
   -- Data for Name: mytable3; Type: TABLE DATA; Schema: ...
   -- Statistics for Name: mytable2; Type: STATISTICS DATA; ...
   -- Statistics for Name: mytable3; Type: STATISTICS DATA; ...

If you still see a problem, please let me know.

Regards,
Jeff Davis





Re: pgsql: pg_upgrade: Fix inconsistency in memory freeing

2025-04-06 Thread Jeff Davis
On Sat, 2025-04-05 at 17:24 +0900, Michael Paquier wrote:
> I am back to a laptop, and just noticed that you have applied
> f4e51eab4eb0 into the tree to take care of this issue, affecting only
> HEAD.  Why didn't you do a backpatch of this commit down to v16?
> That's down to where 2a083ab807db has been applied.

My mistake, backported through 16 now.

Regards,
Jeff Davis





pgsql: Fix unintentional 'NULL' string literal in pg_upgrade.

2025-04-06 Thread Jeff Davis
Fix unintentional 'NULL' string literal in pg_upgrade.

Introduced in 2a083ab807.

Note: backport of commit 945126234b, which was missed at the time.

Discussion: 
https://postgr.es/m/e852442da35b4f31acc600ed98bbee0f12e65e0c.ca...@j-davis.com
Reviewed-by: Michael Paquier 
Backpatch-through: 16

Branch
--
REL_16_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/57467ec7b3d3769d6e96c3995ca4060ac0167901

Modified Files
--
src/bin/pg_upgrade/pg_upgrade.c | 15 +--
1 file changed, 9 insertions(+), 6 deletions(-)



pgsql: Fix unintentional 'NULL' string literal in pg_upgrade.

2025-04-06 Thread Jeff Davis
Fix unintentional 'NULL' string literal in pg_upgrade.

Introduced in 2a083ab807.

Note: backport of commit 945126234b, which was missed at the time.

Discussion: 
https://postgr.es/m/e852442da35b4f31acc600ed98bbee0f12e65e0c.ca...@j-davis.com
Reviewed-by: Michael Paquier 
Backpatch-through: 16

Branch
--
REL_17_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/0851b6573877f0d22510688623eff4a2ab1dea49

Modified Files
--
src/bin/pg_upgrade/pg_upgrade.c | 15 +--
1 file changed, 9 insertions(+), 6 deletions(-)



pgsql: Create accessor functions for TupleHashEntry.

2025-04-05 Thread Jeff Davis
Create accessor functions for TupleHashEntry.

Refactor for upcoming optimizations.

Reviewed-by: David Rowley 
Discussion: 
https://postgr.es/m/1cc3b400a0e8eead18ff967436fa9e42c0c14cfb.ca...@j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/4d143509cbfae0207c35abffae7b0e3b4d078349

Modified Files
--
src/backend/executor/execGrouping.c | 14 ++
src/backend/executor/nodeAgg.c  | 32 +++-
src/backend/executor/nodeSetOp.c| 33 ++---
src/backend/executor/nodeSubplan.c  |  2 +-
src/include/executor/executor.h | 34 ++
src/include/nodes/execnodes.h   |  1 +
6 files changed, 83 insertions(+), 33 deletions(-)



pgsql: Oversight in commit b81ffa13e3.

2025-04-04 Thread Jeff Davis
Oversight in commit b81ffa13e3.

Should warn if a materialized view may be affected, as well.

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/3556c89321e8baa2242288bd4f015efd1e9d6be0

Modified Files
--
src/bin/pg_upgrade/check.c | 4 
1 file changed, 4 insertions(+)



pgsql: Fix unintentional 'NULL' string literal in pg_upgrade.

2025-04-03 Thread Jeff Davis
Fix unintentional 'NULL' string literal in pg_upgrade.

Introduced in 2a083ab807.

Discussion: 
https://postgr.es/m/e852442da35b4f31acc600ed98bbee0f12e65e0c.ca...@j-davis.com
Reviewed-by: Michael Paquier 

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/945126234bbc03a5a8f40e46383f550c08fce08e

Modified Files
--
src/bin/pg_upgrade/pg_upgrade.c | 15 +--
1 file changed, 9 insertions(+), 6 deletions(-)



pgsql: pg_upgrade check for Unicode-dependent relations.

2025-04-03 Thread Jeff Davis
pg_upgrade check for Unicode-dependent relations.

This check will not cause an upgrade failure, only a warning.

Discussion: 
https://postgr.es/m/ef03d678b39a64392f4b12e0f59d1495c740969e.camel%40j-davis.com
Reviewed-by: Peter Eisentraut 

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/b81ffa13e35693af8accf00f1694bbeca6809fb6

Modified Files
--
src/bin/pg_upgrade/check.c | 180 +
1 file changed, 180 insertions(+)



pgsql: Add relallfrozen to pg_dump statistics.

2025-03-30 Thread Jeff Davis
Add relallfrozen to pg_dump statistics.

Author: Corey Huinker 
Discussion: 
https://postgr.es/m/CADkLM=descuf3dvhasadvduvrmb-5go0mhmo5u9nzgv6i7u...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/4694aedf63bf5b5d91f766cb6d6d6d14a9e4434b

Modified Files
--
src/bin/pg_dump/pg_dump.c  | 42 +-
src/bin/pg_dump/pg_dump.h  |  1 +
src/bin/pg_dump/t/002_pg_dump.pl   |  3 +-
src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm |  5 +++
4 files changed, 43 insertions(+), 8 deletions(-)



Re: pgsql: pg_upgrade: Fix inconsistency in memory freeing

2025-03-30 Thread Jeff Davis
On Sun, 2025-03-30 at 07:03 +0900, Michael Paquier wrote:
> Thanks for the report.  It would be possible to switch to a second
> approach here, where we use pg_free() if we don't have a
> locale->db_locale to make sure that the memory is freed in its
> correct
> context, like in the attached.  What do you think?

Why pg_strdup() the "NULL" at all in that case? Usually I see that done
so that there doesn't need to be a conditional when freeing, but here
there's a conditional anyway.

Perhaps something like the attached?

> This test has been added in v16 via 9637badd9f92, with the buildfarm
> not complaining.  Could it be possible to improve the situation so as
> we would know about 002_pg_upgrade.pl failing for such cross-upgrades
> like what you are doing here?

Ideally the buildfarm would do cross-version upgrades the same way as
002_pg_upgrade.pl, in which case the test would have failed in the
buildfarm. But as it is, the only way to test the cross-version
upgrades in 002_pg_upgrade.pl is to initiate them manually by setting
olddump/oldinstall.

There are some ways that the buildfarm test is better, for example it
can go back more versions successfully. I'm not sure what all of the
reasons are, though.

Regards,
Jeff Davis

From 64b895188c164795e0419c76470fb8c1aa5bfd06 Mon Sep 17 00:00:00 2001
From: Jeff Davis 
Date: Sun, 30 Mar 2025 09:22:03 -0700
Subject: [PATCH] fixup

---
 src/bin/pg_upgrade/pg_upgrade.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 9295e46aed3..72b5a5fde5a 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -441,7 +441,6 @@ set_locale_and_encoding(void)
 	char	   *datcollate_literal;
 	char	   *datctype_literal;
 	char	   *datlocale_literal = NULL;
-	char	   *datlocale_src;
 	DbLocaleInfo *locale = old_cluster.template0;
 
 	prep_status("Setting locale and encoding for new cluster");
@@ -455,10 +454,13 @@ set_locale_and_encoding(void)
 	datctype_literal = PQescapeLiteral(conn_new_template1,
 	   locale->db_ctype,
 	   strlen(locale->db_ctype));
-	datlocale_src = locale->db_locale ? locale->db_locale : "NULL";
-	datlocale_literal = PQescapeLiteral(conn_new_template1,
-		datlocale_src,
-		strlen(datlocale_src));
+
+	if (locale->db_locale)
+		datlocale_literal = PQescapeLiteral(conn_new_template1,
+			locale->db_locale,
+			strlen(locale->db_locale));
+	else
+		datlocale_literal = "NULL";
 
 	/* update template0 in new cluster */
 	if (GET_MAJOR_VERSION(new_cluster.major_version) >= 1700)
@@ -502,7 +504,8 @@ set_locale_and_encoding(void)
 
 	PQfreemem(datcollate_literal);
 	PQfreemem(datctype_literal);
-	PQfreemem(datlocale_literal);
+	if (locale->db_locale)
+		PQfreemem(datlocale_literal);
 
 	PQfinish(conn_new_template1);
 
-- 
2.34.1



Re: pgsql: pg_upgrade: Fix inconsistency in memory freeing

2025-03-29 Thread Jeff Davis
On Fri, 2025-02-28 at 01:16 +, Michael Paquier wrote:
> pg_upgrade: Fix inconsistency in memory freeing

> Details
> ---
> https://git.postgresql.org/pg/commitdiff/2a083ab807db6d9e2e0e3aa82ee8f6ff9fc44c8d
> 

This seems to have broken the pg_upgrade test when olddump/oldinstall
are set to PG14 or earlier:

stderr:
#   Failed test 'check that locales in new cluster match original
cluster'
#   at
/home/jdavis/git/postgresql/src/bin/pg_upgrade/t/002_pg_upgrade.pl line
506.
#  got: '0|c|C|C|NULL'
# expected: '0|c|C|C|'
# Looks like you failed 1 test of 16.

Looking at the commit, it seems you are escaping NULL as a literal. 

Regards,
Jeff Davis





pgsql: Matview statistics depend on matview data.

2025-03-28 Thread Jeff Davis
Matview statistics depend on matview data.

REFRESH MATERIALIZED VIEW replaces the storage, which resets
statistics, so statistics must be restored afterward.

If both statistics and data are being dumped for a materialized view,
add a dependency from the former to the latter. Defer the statistics
to SECTION_POST_DATA, and use RESTORE_PASS_POST_ACL.

Reported-by: Ashutosh Bapat 
Reviewed-by: Ashutosh Bapat 
Discussion: 
https://postgr.es/m/caexhw5s47kmubpbbrjzsm-zfe0tj2o3gbagb7yaye8rq-v2...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/a0a4601765b896079eb82a9d5cfa1f41154fcfdb

Modified Files
--
src/bin/pg_dump/pg_backup_archiver.c |  46 +++-
src/bin/pg_dump/pg_dump.c| 100 +++
src/bin/pg_dump/pg_dump.h|   3 +-
src/bin/pg_dump/pg_dump_sort.c   |   2 +-
4 files changed, 91 insertions(+), 60 deletions(-)



pgsql: Add pg_dump --with-{schema|data|statistics} options.

2025-03-25 Thread Jeff Davis
Add pg_dump --with-{schema|data|statistics} options.

By adding the positive variants of options, in addition to the
negative variants that already exist, users can be explicit about what
pg_dump should produce.

Discussion: 
https://postgr.es/m/bd0513e4b1ea2b2f2d06f02720c6579711cb62a6.ca...@j-davis.com
Reviewed-by: Corey Huinker 
Reviewed-by: Andres Freund 

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/bde2fb797aaebcbe06bf60f330ba5a068f17dda7

Modified Files
--
doc/src/sgml/ref/pg_dump.sgml| 27 ++
doc/src/sgml/ref/pg_dumpall.sgml | 27 ++
doc/src/sgml/ref/pg_restore.sgml | 27 ++
src/bin/pg_dump/pg_dump.c| 49 
src/bin/pg_dump/pg_dumpall.c | 15 
src/bin/pg_dump/pg_restore.c | 47 +-
src/bin/pg_dump/t/002_pg_dump.pl | 29 +++-
7 files changed, 210 insertions(+), 11 deletions(-)



pgsql: Stats: use schemaname/relname instead of regclass.

2025-03-25 Thread Jeff Davis
Stats: use schemaname/relname instead of regclass.

For import and export, use schemaname/relname rather than
regclass.

This is more natural during export, fits with the other arguments
better, and it gives better control over error handling in case we
need to downgrade more errors to warnings.

Also, use text for the argument types for schemaname, relname, and
attname so that casts to "name" are not required.

Author: Corey Huinker 
Discussion: 
https://postgr.es/m/CADkLM=ceOSsx_=oe73qq-bxufr2cwqum7-up_fpe22dby0n...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/650ab8aaf1957863ae14c80265e79f5d903b49fd

Modified Files
--
doc/src/sgml/func.sgml |  45 ++--
src/backend/statistics/attribute_stats.c   |  61 --
src/backend/statistics/relation_stats.c|  54 +++--
src/backend/statistics/stat_utils.c|  22 ++
src/bin/pg_dump/pg_dump.c  |  25 ++-
src/bin/pg_dump/t/002_pg_dump.pl   |   6 +-
src/include/catalog/catversion.h   |   2 +-
src/include/catalog/pg_proc.dat|   8 +-
src/include/statistics/stat_utils.h|   2 +
src/test/regress/expected/stats_import.out | 337 -
src/test/regress/sql/stats_import.sql  | 306 +-
11 files changed, 579 insertions(+), 289 deletions(-)



pgsql: Minor doc update for commit 99f8f3fbbc.

2025-03-25 Thread Jeff Davis
Minor doc update for commit 99f8f3fbbc.

Author: Corey Huinker 

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/2a420f7995e415f4813fccf1c42ab29a3a32182f

Modified Files
--
doc/src/sgml/func.sgml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)



pgsql: Add ExecCopySlotMinimalTupleExtra().

2025-03-24 Thread Jeff Davis
Add ExecCopySlotMinimalTupleExtra().

Allows an "extra" argument that allocates extra memory at the end of
the MinimalTuple. This is important for callers that need to store
additional data, but do not want to perform an additional allocation.

Suggested-by: David Rowley 
Discussion: 
https://postgr.es/m/caaphdvppeqw2pnm-+ahbojwq2qmc0hoagsmcpc89qvmeoov...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/a0942f441ed651f6345d969b7a8f4774eda1fceb

Modified Files
--
src/backend/access/common/heaptuple.c  | 27 +--
src/backend/executor/execTuples.c  | 24 +---
src/backend/executor/nodeGatherMerge.c |  2 +-
src/backend/utils/sort/tuplesortvariants.c |  2 +-
src/backend/utils/sort/tuplestore.c|  6 +++---
src/include/access/htup_details.h  |  7 ---
src/include/executor/tuptable.h| 20 ++--
7 files changed, 61 insertions(+), 27 deletions(-)



pgsql: Remove 'additional' pointer from TupleHashEntryData.

2025-03-24 Thread Jeff Davis
Remove 'additional' pointer from TupleHashEntryData.

Reduces memory required for hash aggregation by avoiding an allocation
and a pointer in the TupleHashEntryData structure. That structure is
used for all buckets, whether occupied or not, so the savings is
substantial.

Discussion: 
https://postgr.es/m/AApHDvpN4v3t_sdz4dvrv1Fx_ZPw=twsnxuteytryp7lfz5...@mail.gmail.com
Reviewed-by: David Rowley 

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/626df47ad9db809dc8f93330175ab95b75914721

Modified Files
--
src/backend/executor/execGrouping.c | 17 -
src/include/executor/executor.h |  5 -
src/include/nodes/execnodes.h   |  1 -
3 files changed, 16 insertions(+), 7 deletions(-)



pgsql: HashAgg: use Bump allocator for hash TupleHashTable entries.

2025-03-24 Thread Jeff Davis
HashAgg: use Bump allocator for hash TupleHashTable entries.

The entries aren't freed until the entire hash table is destroyed, so
use the Bump allocator to improve allocation speed, avoid wasting
space on the chunk header, and avoid wasting space due to the
power-of-two allocations.

Discussion: 
https://postgr.es/m/caaphdvqv1anb4cm36fzrwivxrevbo_lsg_eq3nqdxtjecaa...@mail.gmail.com
Reviewed-by: David Rowley

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/cc721c459d3783bbdb4beb1bbfa802a5328d15a2

Modified Files
--
src/backend/executor/execUtils.c |  17 +++---
src/backend/executor/nodeAgg.c   | 111 ---
src/include/nodes/execnodes.h|   5 +-
3 files changed, 104 insertions(+), 29 deletions(-)



pgsql: Fix headerscheck warning.

2025-03-18 Thread Jeff Davis
Fix headerscheck warning.

Reported-by: Tom Lane 
Discussion: https://postgr.es/m/93731.1742310...@sss.pgh.pa.us

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/549ea06e4217aca10d3a73dc09cf5018c51bc23a

Modified Files
--
src/common/unicode/generate-unicode_case_table.pl | 14 --
src/common/unicode_case.c | 11 +++
src/include/common/unicode_case_table.h   | 11 ---
3 files changed, 11 insertions(+), 25 deletions(-)



pgsql: Optimization for lower(), upper(), casefold() functions.

2025-03-15 Thread Jeff Davis
Optimization for lower(), upper(), casefold() functions.

Improve performance and reduce table sizes for case mapping.

The main case mapping table stores only 16-bit offsets, which can be
used to look up the mapped code point in any of the case tables (fold,
lower, upper, or title case). Simple case pairs point to the same
offsets.

Generate a function in generate-unicode_case_table.pl that consists of
a nested branches to test for specific codepoint ranges that determine
the offset in the main table.

Other approaches were considered, such as representing these ranges as
another structure (rather than branches in a generated function), or a
different approach such as a radix tree, or perfect hashing. The
author implemented and tested these alternatives and settled on the
generated branches.

Author: Alexander Borisov 
Reviewed-by: Heikki Linnakangas 
Discussion: https://postgr.es/m/7cac7e66-9a3b-4e3f-a997-42aa0c401f80%40gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/27bdec06841d1bb004ca7627eac97808b08a7ac7

Modified Files
--
src/common/unicode/generate-unicode_case_table.pl |   388 +-
src/common/unicode_case.c |80 +-
src/include/common/unicode_case_table.h   | 16418 
3 files changed, 13671 insertions(+), 3215 deletions(-)



pgsql: Organize and deduplicate statistics import tests.

2025-03-15 Thread Jeff Davis
Organize and deduplicate statistics import tests.

Author: Corey Huinker 
Reported-by: Melanie Plageman 
Discussion: 
https://postgr.es/m/CAAKRu_bWEqUfxhODfJ-XbZC75vq=P6DYOKK6biyey=ym1ah...@mail.gmail.com
Discussion: 
https://postgr.es/m/CADkLM=f1n2_Vomq0gKab7xdxDHmJGgn=de48p8fzqop3mrs...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/1d33de9d683722bfa14e436e30a8f5b999a4e2e7

Modified Files
--
src/test/regress/expected/stats_import.out | 681 +++--
src/test/regress/sql/stats_import.sql  | 555 +--
2 files changed, 454 insertions(+), 782 deletions(-)



pgsql: Refactor convert_case() to prepare for optimizations.

2025-03-12 Thread Jeff Davis
Refactor convert_case() to prepare for optimizations.

Upcoming optimizations will add complexity to convert_case(). This
patch reorganizes slightly so that the complexity can be contained
within the logic to convert the case of a single character, rather
than mixing it in with logic to iterate through the string.

Reviewed-by: Alexander Borisov 
Discussion: https://postgr.es/m/44005c3d-88f4-4a26-981f-fd82dfa8e...@gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/d3b2e5e1ab5ca3e9738d20409debfdd299e65a2e

Modified Files
--
src/common/unicode_case.c | 153 ++
1 file changed, 101 insertions(+), 52 deletions(-)



pgsql: Don't convert to and from floats in pg_dump.

2025-03-08 Thread Jeff Davis
Don't convert to and from floats in pg_dump.

Commit 8f427187db improved performance by remembering relation stats
as native types rather than issuing a new query for each relation.

Using native types is fine for integers like relpages; but reltuples
is floating point. The commit controllled for that complexity by using
setlocale(LC_NUMERIC, "C"). After that, Alexander Lakhin found a
problem in pg_strtof(), fixed in 00d61a08c5.

While we aren't aware of any more problems with that approach, it
seems wise to just use a string the whole way for floating point
values, as Corey's original patch did, and get rid of the
setlocale(). Integers are still converted to native types to avoid
wasting memory.

Co-authored-by: Corey Huinker 
Discussion: https://postgr.es/m/3049348.1740855...@sss.pgh.pa.us
Discussion: 
https://postgr.es/m/560cca3781740bd69881bb07e26eb8f65b09792c.camel%40j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/1852aea3f526b124b95585f7b1f655f3af04afd5

Modified Files
--
src/bin/pg_dump/pg_dump.c | 22 +-
src/bin/pg_dump/pg_dump.h |  2 +-
2 files changed, 10 insertions(+), 14 deletions(-)



pgsql: Address stats export review comments.

2025-03-07 Thread Jeff Davis
Address stats export review comments.

Per discussion, did not use Jian He's patch exactly.

Reported-by: jian he 
Reviewed-by: Corey Huinker 
Discussion: 
https://postgr.es/m/CACJufxFVq=tq9u1zrhwysbmi1t07gs9ff0ljscmco4hzmtz...@mail.gmail.com
Discussion: 
https://postgr.es/m/CADkLM=f1n2_Vomq0gKab7xdxDHmJGgn=de48p8fzqop3mrs...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/f9f4b43b8dc0174797f939af986d8c9bb52269eb

Modified Files
--
src/bin/pg_dump/pg_backup_archiver.c | 8 ++--
1 file changed, 2 insertions(+), 6 deletions(-)



pgsql: CREATE INDEX: don't update table stats if autovacuum=off.

2025-03-07 Thread Jeff Davis
CREATE INDEX: don't update table stats if autovacuum=off.

We previously fixed this for binary upgrade in 71b66171d0, but a
similar problem remained when dumping statistics without data.

Fix by not opportunistically updating table stats during CREATE INDEX
when autovacuum is disabled. For stats to be stable at all, the server
needs to be aware that it should not take every opportunity to update
stats. Per discussion, autovacuum=off is a signal that the user
expects stats to be stable; though if necessary, we could create
a more specific mode in the future.

Reported-by: Ashutosh Bapat 
Discussion: 
https://postgr.es/m/CAExHW5vf9D+8-a5_BEX3y=2y_xY9hiCxV1=c+fnxdvfprwv...@mail.gmail.com
Discussion: 
https://postgr.es/m/ca81cbf6e6ea2af838df972801ad4da52640a503.camel%40j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/d611f8b1587b8f30caa7c0da99ae5d28e914d54f

Modified Files
--
src/backend/catalog/index.c| 22 ++
src/test/regress/expected/stats_import.out | 29 +
src/test/regress/sql/stats_import.sql  | 17 +
3 files changed, 68 insertions(+)



pgsql: Address stats import review comments.

2025-03-05 Thread Jeff Davis
Address stats import review comments.

Reported-by: jian he 
Discussion: 
https://postgr.es/m/cacjufxhg9mbqozbjq4jrbcrbuo+t+sx4qlzx092rs_9b4sr...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/298944e8d80252820531309e5b73d7de7d85e2df

Modified Files
--
src/backend/statistics/relation_stats.c |  8 +---
src/backend/statistics/stat_utils.c | 10 ++
2 files changed, 7 insertions(+), 11 deletions(-)



pgsql: Adjust pg_dump tag for relation stats.

2025-02-27 Thread Jeff Davis
Adjust pg_dump tag for relation stats.

Do not use fmtId(), just use dobj->name directly, like for table data.

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/424ededc580b03e1bcf8aff18a735e519c80061f

Modified Files
--
src/bin/pg_dump/pg_dump.c | 7 +--
1 file changed, 1 insertion(+), 6 deletions(-)



pgsql: Remove stray diff introduced by a5cbdeb98a.

2025-02-26 Thread Jeff Davis
Remove stray diff introduced by a5cbdeb98a.

Reported-by: Michael Paquier 
Discussion: https://postgr.es/m/z77ikjmmfbffn...@paquier.xyz

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/15df9d7b5123b2b478886175c17cd0c0359d9996

Modified Files
--
src/include/catalog/pg_proc.dat | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Avoid unnecessary relation stats query in pg_dump.

2025-02-25 Thread Jeff Davis
Avoid unnecessary relation stats query in pg_dump.

The few fields we need can be easily collected in getTables() and
getIndexes() and stored in RelStatsInfo.

Reviewed-by: Tom Lane 
Reported-by: Andres Freund 
Co-authored-by: Corey Huinker 
Co-authored-by: Jeff Davis 
Discussion: 
https://postgr.es/m/CADkLM=f0a43atd88xw4xcfayef25g-7htrhx_whv40hyocs...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/8f427187db78a549af316a69d54f5969db5f4951

Modified Files
--
src/bin/pg_dump/pg_dump.c | 145 +++---
src/bin/pg_dump/pg_dump.h |   5 +-
2 files changed, 64 insertions(+), 86 deletions(-)



pgsql: pg_dump: prepare attribute stats query.

2025-02-25 Thread Jeff Davis
pg_dump: prepare attribute stats query.

Follow precedent in pg_dump for preparing queries to improve
performance. Also, simplify the query by removing unnecessary joins.

Reviewed-by: Tom Lane 
Reported-by: Andres Freund 
Co-authored-by: Corey Huinker 
Co-authored-by: Jeff Davis 
Discussion: 
https://postgr.es/m/CADkLM=drmc6t8gp9gvf6y6e_r5echqjmaah_vpyih_zmiq0...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/6ee3b91bad269b8f1acee38607bd17923efd6e06

Modified Files
--
src/bin/pg_dump/pg_backup.h |   1 +
src/bin/pg_dump/pg_dump.c   | 123 
2 files changed, 58 insertions(+), 66 deletions(-)



pgsql: Remove redundant pg_set_*_stats() variants.

2025-02-25 Thread Jeff Davis
Remove redundant pg_set_*_stats() variants.

After commit f3dae2ae58, the primary purpose of separating the
pg_set_*_stats() from the pg_restore_*_stats() variants was
eliminated.

Leave pg_restore_relation_stats() and pg_restore_attribute_stats(),
which satisfy both purposes, and remove pg_set_relation_stats() and
pg_set_attribute_stats().

Reviewed-by: Corey Huinker 
Discussion: https://postgr.es/m/1457469.1740419...@sss.pgh.pa.us

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/a5cbdeb98af9a8d4f683fbffa69cd74be1f4a084

Modified Files
--
doc/src/sgml/func.sgml |  254 +++---
src/backend/catalog/system_functions.sql   |   32 -
src/backend/statistics/attribute_stats.c   |   98 +-
src/backend/statistics/relation_stats.c|   24 +-
src/backend/statistics/stat_utils.c|   30 +-
src/include/catalog/catversion.h   |2 +-
src/include/catalog/pg_proc.dat|   32 +-
src/include/statistics/stat_utils.h|8 +-
src/test/regress/expected/stats_import.out | 1339 
src/test/regress/sql/stats_import.sql  | 1075 +++---
10 files changed, 872 insertions(+), 2022 deletions(-)



pgsql: Missing doc update for f3dae2ae58.

2025-02-24 Thread Jeff Davis
Missing doc update for f3dae2ae58.

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/15601fa21a5509b83a871c39ab98671f560da905

Modified Files
--
doc/src/sgml/func.sgml | 8 
1 file changed, 8 deletions(-)



pgsql: Do not use in-place updates for statistics import.

2025-02-24 Thread Jeff Davis
Do not use in-place updates for statistics import.

The use of in-place updates was originally there to follow the
precedent of ANALYZE and to reduce the potential for bloat on
pg_class. Per discussion, it's not worth the risks.

Reported-by: Andres Freund 
Discussion: 
https://postgr.es/m/cpdanvzykcb5o64rmapkx6n5gjypoce3y52hff7ocxupgpbxu4@53jmlyvukijo

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/f3dae2ae5856dec9935a51e53216400566ef8d4f

Modified Files
--
src/backend/statistics/relation_stats.c| 138 ++---
src/test/regress/expected/stats_import.out |  53 ---
src/test/regress/sql/stats_import.sql  |  33 ---
3 files changed, 47 insertions(+), 177 deletions(-)



Re: pgsql: Trial fix for old cross-version upgrades.

2025-02-24 Thread Jeff Davis
On Sat, 2025-02-22 at 21:48 -0500, Tom Lane wrote:
> CREATE INDEX vcharidx ON vchartmp USING GIST ( text(a) );
> 
> The index column will be given the name "text".  However, it
> dumps as
> 
> CREATE INDEX vcharidx ON public.vchartmp USING gist (((a)::text));

Thank you! I dismissed the naming issue too early, going down the path
of something related to GiST.

> and when *that* gets loaded, the index column is given the name
> "a", because FigureColname treats function-like constructs
> differently from cast-like constructs.

Ugh.

> We have dealt with some similar issues in the past, and the
> solution was to allow index columns to be referenced by
> column number not name.  (ALTER INDEX ... ALTER COLUMN ...
> SET STATISTICS does that, not sure if there are other places.)
> Recommend adopting the same solution here.

I'll submit a patch to the -hackers thread. There are a few minor
choices here that might get some discussion.

Regards,
Jeff Davis





Re: pgsql: Trial fix for old cross-version upgrades.

2025-02-22 Thread Jeff Davis
On Sat, 2025-02-22 at 20:15 -0500, Tom Lane wrote:
> That's just crazy --- I would be
> unsurprised if a range of back releases were misbehaving in the same
> way, but not two isolated branches.
> 
> Furthermore, it can't be a coincidence that the four tables we are
> seeing relallvisible diffs for are exactly the four tables in the
> regression database that have hash indexes.
> 
> But I'm baffled where to look beyond that.  I could believe that
> CREATE INDEX with a hash index misbehaves by changing the
> relallvisible value even when we're doing a binary upgrade --- but
> such a bug would be on the restoring side, so how would it be
> sensitive to the source branch?  I'm confused.

It's also strange that copperhead is consistently failing on 12 with:

  pg_restore: while PROCESSING TOC:
  pg_restore: from TOC entry 4163; 0 0 STATISTICS DATA "vcharidx" (no
owner)
  pg_restore: error: could not execute query: ERROR:  column "text" of
relation "vcharidx" does not exist

https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=copperhead&dt=2025-02-22%2009%3A10%3A36&stg=xversion-upgrade-REL_12_STABLE-HEAD

I was puzzling through whether the attribute name uniqueness logic was
doing something strange, but it's very simple. And the table and index
should both be locked at the point of the syscache lookup.

Regards,
Jeff Davis





pgsql: Documentation fixups for dumping statistics.

2025-02-22 Thread Jeff Davis
Documentation fixups for dumping statistics.

Reported-by: Hayato Kuroda (Fujitsu) 
Reported-by: Andrew Dunstan 
Discussion: 
https://postgr.es/m/oscpr01mb149665630030e7f54fda8b27bf5...@oscpr01mb14966.jpnprd01.prod.outlook.com
Discussion: 
https://postgr.es/m/25d26774-25fa-46f2-9888-c6a707d1f...@dunslane.net

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/cb45dc3afb05ce5e5267b1a9be4725d0be7ee33c

Modified Files
--
doc/src/sgml/ref/pg_dump.sgml| 18 ++
doc/src/sgml/ref/pg_dumpall.sgml | 12 
doc/src/sgml/ref/pg_restore.sgml | 14 --
doc/src/sgml/ref/pgupgrade.sgml  | 17 +
src/bin/pg_upgrade/check.c   |  2 +-
5 files changed, 40 insertions(+), 23 deletions(-)



Re: pgsql: Trial fix for old cross-version upgrades.

2025-02-21 Thread Jeff Davis
On Fri, 2025-02-21 at 21:57 -0500, Tom Lane wrote:
> Hmm.  I forced my local BF installation to run a v17-to-HEAD upgrade
> test, and it still failed, though seemingly with fewer diffs than
> the buildfarm is reporting for older branches.  (Diffs attached for
> amusement's sake.)  I don't believe we've made any definitional
> changes in the contents of pg_statistic since v17, so whatever's
> going on here seems a little subtler than I was hoping.

Also the non-buildfarm tests (src/bin/pg_upgrade/TESTING) are all
passing for versions 10+.

> I wonder if it'd be a good idea to rearrange TestUpgradeXversion.pm
> so that instead of testing upgrades from oldest prior version to
> newest, it tested from newest to oldest?  My thought here is that
> the oldest cases are most likely to fail, and when they do, it'd
> be valuable information to know which branches still work.

That's a good idea and would be a big help.

Regards,
Jeff Davis





Re: pgsql: Trial fix for old cross-version upgrades.

2025-02-21 Thread Jeff Davis
On Fri, 2025-02-21 at 21:00 -0500, Tom Lane wrote:
> I think we might indeed want that, but it doesn't seem to be the
> explanation for the buildfarm failures, because the diffs look
> to be consistent across runs which you'd not expect from
> autovacuum-driven changes.  I suspect that the problem is that
> pg_dump is interpreting old-version stats in some way that doesn't
> match up with what we get from restoring the dump.

I agree it doesn't explain the failures.

> I did experiment with the attached very-quick-n-dirty patch, which
> should succeed in suppressing autovacuum in both the old and new
> versions if I understand the code correctly (which I might well not).
> It made no difference at all in the dump diffs ...

In 002_pg_upgrade.pl, I disabled autovacuum and restarted after the
regression run. In other words, in the old cluster, autovacuum did have
a chance to run, just not after the first dumpall.

Regards,
Jeff Davis





Re: pgsql: Trial fix for old cross-version upgrades.

2025-02-21 Thread Jeff Davis
On Thu, 2025-02-20 at 13:17 -0800, Jeff Davis wrote:
> On Thu, 2025-02-20 at 18:30 +0000, Jeff Davis wrote:
> > Trial fix for old cross-version upgrades.
> 
> That fixed one problem, but there are other problems with 9.2
> upgrades.

The version that I committed had the following change to
002_pg_upgrade.pl:

  # Stabilize stats before pg_dumpall.
  $oldnode->append_conf('postgresql.conf', 'autovacuum = off');
  $oldnode->restart;

  ...

  $newnode->append_conf('postgresql.conf', 'autovacuum = off');

I think we need a similar change in the buildfarm client's
TestUpgradeXversion.pm? Is -hackers the right place to discuss that?

Regards,
Jeff Davis





pgsql: Fix for pg_restore_attribute_stats().

2025-02-20 Thread Jeff Davis
Fix for pg_restore_attribute_stats().

Use RelationGetIndexExpressions() rather than rd_indexprs directly.

Author: Corey Huinker 

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/b50a554cc84066577f0f0a3baafe2f1fac302006

Modified Files
--
src/backend/statistics/attribute_stats.c | 42 +---
1 file changed, 28 insertions(+), 14 deletions(-)



Re: pgsql: Trial fix for old cross-version upgrades.

2025-02-20 Thread Jeff Davis
On Thu, 2025-02-20 at 18:30 +, Jeff Davis wrote:
> Trial fix for old cross-version upgrades.

That fixed one problem, but there are other problems with 9.2 upgrades.
And it looks like there's also a problem with upgrades from 12.
Investigating...

Regards,
    Jeff Davis





pgsql: Trial fix for old cross-version upgrades.

2025-02-20 Thread Jeff Davis
Trial fix for old cross-version upgrades.

Per buildfarm and reports, it seems that 9.X to 18 upgrades were
failing after commit 1fd1bd8710 due to an incorrect regex. Loosen the
regex to accommodate older versions.

Reported-by: vignesh C 
Reported-by: Andrew Dunstan 
Discussion: 
https://postgr.es/m/CALDaNm3GUs+U8Nt4S=v5zmb+k8-rfac03vrens0teeoq0lc...@mail.gmail.com
Discussion: 
https://postgr.es/m/ea4cbbc1-c5a5-43d1-9618-8ff3f2155...@dunslane.net

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/ab84d0ff806dd791ea9da5f1ca302daf3cf42980

Modified Files
--
src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgsql: Transfer statistics during pg_upgrade.

2025-02-20 Thread Jeff Davis
Transfer statistics during pg_upgrade.

Add support to pg_dump for dumping stats, and use that during
pg_upgrade so that statistics are transferred during upgrade. In most
cases this removes the need for a costly re-analyze after upgrade.

Some statistics are not transferred, such as extended statistics or
statistics with a custom stakind.

Now pg_dump accepts the options --schema-only, --no-schema,
--data-only, --no-data, --statistics-only, and --no-statistics; which
allow all combinations of schema, data, and/or stats. The options are
named this way to preserve compatibility with the previous
--schema-only and --data-only options.

Statistics are in SECTION_DATA, unless the object itself is in
SECTION_POST_DATA.

The stats are represented as calls to pg_restore_relation_stats() and
pg_restore_attribute_stats().

Author: Corey Huinker, Jeff Davis
Reviewed-by: Jian He
Discussion: 
https://postgr.es/m/CADkLM=fzX7QX6r78fShWDjNN3Vcr4PVAnvXxQ4DiGy6V=0b...@mail.gmail.com
Discussion: 
https://postgr.es/m/CADkLM%3DcB0rF3p_FuWRTMSV0983ihTRpsH%2BOCpNyiqE7Wk0vUWA%40mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/1fd1bd871012732e3c6c482667d2f2c56f1a9395

Modified Files
--
doc/src/sgml/ref/pg_dump.sgml  |  75 -
doc/src/sgml/ref/pg_dumpall.sgml   |  41 ++-
doc/src/sgml/ref/pg_restore.sgml   |  48 ++-
doc/src/sgml/ref/pgupgrade.sgml|   9 +
src/bin/pg_dump/pg_backup.h|   2 +
src/bin/pg_dump/pg_backup_archiver.c   |  83 +++--
src/bin/pg_dump/pg_backup_archiver.h   |   3 +-
src/bin/pg_dump/pg_backup_directory.c  |   2 +-
src/bin/pg_dump/pg_dump.c  | 415 -
src/bin/pg_dump/pg_dump.h  |  12 +
src/bin/pg_dump/pg_dump_sort.c |  37 ++-
src/bin/pg_dump/pg_dumpall.c   |  24 +-
src/bin/pg_dump/pg_restore.c   |  25 +-
src/bin/pg_dump/t/001_basic.pl |  18 ++
src/bin/pg_dump/t/002_pg_dump.pl   | 106 ++-
src/bin/pg_upgrade/dump.c  |   3 +-
src/bin/pg_upgrade/option.c|   7 +
src/bin/pg_upgrade/pg_upgrade.h|   1 +
src/bin/pg_upgrade/t/002_pg_upgrade.pl |   7 +
src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm |  10 +
src/test/recovery/t/027_stream_regress.pl  |   4 +-
src/tools/pgindent/typedefs.list   |   1 +
22 files changed, 858 insertions(+), 75 deletions(-)



pgsql: Update outdated comments in nodeAgg.c.

2025-02-18 Thread Jeff Davis
Update outdated comments in nodeAgg.c.

Author: Zhang Mingli
Reviewed-by: Richard Guo
Discussion: https://postgr.es/m/198a8d1e-0792-4e7f-828e-902aa342f36e@Spark

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/a1f7f80bfef105c8c02153e8832d4106df3cf459

Modified Files
--
src/backend/executor/nodeAgg.c | 6 ++
1 file changed, 2 insertions(+), 4 deletions(-)



pgsql: Injection points for hash aggregation.

2025-02-11 Thread Jeff Davis
Injection points for hash aggregation.

Requires adding a guard against shift-by-32. Previously, that was
impossible because the number of partitions was always greater than 1,
but a new injection point can force the number of partitions to 1.

Discussion: 
https://postgr.es/m/ff4e59305e5d689e03cd256a736348d3e7958f8f.ca...@j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/38172d1856b34792a5ee60eaa0d883166e90d33d

Modified Files
--
src/backend/executor/nodeAgg.c | 48 ++-
src/test/modules/injection_points/Makefile |  2 +-
.../modules/injection_points/expected/hashagg.out  | 68 ++
src/test/modules/injection_points/meson.build  |  1 +
src/test/modules/injection_points/sql/hashagg.sql  | 26 +
5 files changed, 141 insertions(+), 4 deletions(-)



pgsql: Lock table in ShareUpdateExclusive when importing index stats.

2025-02-10 Thread Jeff Davis
Lock table in ShareUpdateExclusive when importing index stats.

Follow locking behavior of ANALYZE when importing statistics. In
particular, when importing index statistics, the table must be locked
in ShareUpdateExclusive mode. Fixes bug reportd by Jian He.

ANALYZE doesn't update statistics on partitioned indexes, and the
locking requirements are slightly different for in-place updates on
partitioned indexes versus normal indexes. To be conservative, lock
both the partitioned table and the partitioned index in
ShareUpdateExclusive mode when importing stats for a partitioned
index.

Author: Corey Huinker
Reported-by: Jian He
Reviewed-by: Michael Paquier
Discussion: 
https://www.postgresql.org/message-id/CACJufxGreTY7qsCV8%2BBkuv0p5SXGTScgh%3DD%2BDq6%3D%2B_%3DXTp7FWg%40mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/9f12da78d9538016efccbf17e6f816f1c286b7f5

Modified Files
--
src/backend/statistics/stat_utils.c|  70 
src/test/regress/expected/stats_import.out | 103 +
src/test/regress/sql/stats_import.sql  |  68 +++
3 files changed, 228 insertions(+), 13 deletions(-)



pgsql: Fix PDF doc build.

2025-01-25 Thread Jeff Davis
Fix PDF doc build.

Reported-by: Tom Lane
Discussion: https://postgr.es/m/608525.1737781...@sss.pgh.pa.us

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/d2ca16bb509c453eac181c1ef805ff55289df779

Modified Files
--
doc/src/sgml/func.sgml | 12 
1 file changed, 4 insertions(+), 8 deletions(-)



pgsql: Add SQL function CASEFOLD().

2025-01-24 Thread Jeff Davis
Add SQL function CASEFOLD().

Useful for caseless matching. Similar to LOWER(), but avoids edge-case
problems with using LOWER() for caseless matching.

For collations that support it, CASEFOLD() handles characters with
more than two case variations or multi-character case variations. Some
characters may fold to uppercase. The results of case folding are also
more stable across Unicode versions than LOWER() or UPPER().

Discussion: 
https://postgr.es/m/a1886ddfcd8f60cb3e905c93009b646b4cfb74c5.camel%40j-davis.com
Reviewed-by: Ian Lawrence Barwick

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/bfc5992069cf00b189af83d96a83ae5ebb65e938

Modified Files
--
doc/src/sgml/func.sgml | 46 -
src/backend/utils/adt/formatting.c | 69 ++
src/backend/utils/adt/oracle_compat.c  | 16 ++
src/backend/utils/adt/pg_locale.c  | 24 +
src/backend/utils/adt/pg_locale_builtin.c  | 10 
src/backend/utils/adt/pg_locale_icu.c  | 58 ++
src/include/catalog/catversion.h   |  2 +-
src/include/catalog/pg_proc.dat|  3 ++
src/include/utils/formatting.h |  1 +
src/include/utils/pg_locale.h  |  3 ++
src/test/regress/expected/collate.icu.utf8.out | 24 +
src/test/regress/expected/collate.utf8.out | 14 ++
src/test/regress/sql/collate.icu.utf8.sql  |  5 ++
src/test/regress/sql/collate.utf8.sql  |  6 +++
14 files changed, 278 insertions(+), 3 deletions(-)



pgsql: Add support for Unicode case folding.

2025-01-23 Thread Jeff Davis
Add support for Unicode case folding.

Expand case mapping tables to include entries for case folding, which
are parsed from CaseFolding.txt.

Discussion: 
https://postgr.es/m/a1886ddfcd8f60cb3e905c93009b646b4cfb74c5.camel%40j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/4e7f62bc386a479593e4e8ecfb94370f5a88e522

Modified Files
--
src/common/unicode/Makefile   |6 +-
src/common/unicode/case_test.c|   32 +-
src/common/unicode/generate-unicode_case_table.pl |  110 +-
src/common/unicode/meson.build|4 +-
src/common/unicode_case.c |   32 +
src/include/common/unicode_case.h |3 +
src/include/common/unicode_case_table.h   | 6218 +++--
7 files changed, 3280 insertions(+), 3125 deletions(-)



pgsql: Support Unicode full case mapping and conversion.

2025-01-17 Thread Jeff Davis
Support Unicode full case mapping and conversion.

Generate tables from Unicode SpecialCasing.txt to support more
sophisticated case mapping behavior:

 * support case mappings to multiple codepoints, such as "ß"
   uppercasing to "SS"
 * support conditional case mappings, such as the "final sigma"
 * support titlecase variants, such as "dž" uppercasing to "DŽ" but
   titlecasing to "Dž"

Discussion: 
https://postgr.es/m/ddfd67928818f138f51635712529bc5e1d25e4e7.ca...@j-davis.com
Discussion: 
https://postgr.es/m/27bb0e52-801d-4f73-a0a4-02cfdd4a9...@eisentraut.org
Reviewed-by: Peter Eisentraut, Daniel Verite

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/286a365b9c25479f8ad82043ed136748733adfa6

Modified Files
--
src/backend/utils/adt/pg_locale_builtin.c |6 +-
src/common/unicode/Makefile   |4 +-
src/common/unicode/case_test.c|  202 +-
src/common/unicode/generate-unicode_case_table.pl |  161 +-
src/common/unicode/meson.build|4 +-
src/common/unicode_case.c |  158 +-
src/include/common/unicode_case.h |8 +-
src/include/common/unicode_case_table.h   | 6094 +++--
src/tools/pgindent/typedefs.list  |1 +
9 files changed, 3645 insertions(+), 2993 deletions(-)



pgsql: Support PG_UNICODE_FAST locale in the builtin collation provider

2025-01-17 Thread Jeff Davis
Support PG_UNICODE_FAST locale in the builtin collation provider.

The PG_UNICODE_FAST locale uses code point sort order (fast,
memcmp-based) combined with Unicode character semantics. The character
semantics are based on Unicode full case mapping.

Full case mapping can map a single codepoint to multiple codepoints,
such as "ß" uppercasing to "SS". Additionally, it handles
context-sensitive mappings like the "final sigma", and it uses
titlecase mappings such as "Dž" when titlecasing (rather than plain
uppercase mappings).

Importantly, the uppercasing of "ß" as "SS" is specifically mentioned
by the SQL standard. In Postgres, UCS_BASIC uses plain ASCII semantics
for case mapping and pattern matching, so if we changed it to use the
PG_UNICODE_FAST locale, it would offer better compliance with the
standard. For now, though, do not change the behavior of UCS_BASIC.

Discussion: 
https://postgr.es/m/ddfd67928818f138f51635712529bc5e1d25e4e7.ca...@j-davis.com
Discussion: 
https://postgr.es/m/27bb0e52-801d-4f73-a0a4-02cfdd4a9...@eisentraut.org
Reviewed-by: Peter Eisentraut, Daniel Verite

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/d3d0983169130a9b81e3fe48d5c2ca4931480956

Modified Files
--
doc/src/sgml/charset.sgml  |  29 +-
doc/src/sgml/ref/create_collation.sgml |   3 +-
doc/src/sgml/ref/create_database.sgml  |   6 +-
doc/src/sgml/ref/initdb.sgml   |   4 +-
src/backend/regex/regc_pg_locale.c |   6 +-
src/backend/utils/adt/pg_locale.c  |   7 +-
src/backend/utils/adt/pg_locale_builtin.c  |  12 ++-
src/bin/initdb/initdb.c|   6 +-
src/include/catalog/catversion.h   |   2 +-
src/include/catalog/pg_collation.dat   |   3 +
src/include/utils/pg_locale.h  |   1 +
src/test/regress/expected/collate.utf8.out | 160 +
src/test/regress/sql/collate.utf8.sql  |  60 +++
13 files changed, 283 insertions(+), 16 deletions(-)



pgsql: Revert "TupleHashTable: store additional data along with tuple."

2025-01-13 Thread Jeff Davis
Revert "TupleHashTable: store additional data along with tuple."

This reverts commit e0ece2a981ee9068f50c4423e303836c2585eb02 due to
performance regressions.

Reported-by: David Rowley

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/b4a07f532b40a64fb4714a3f7ab6063435411edb

Modified Files
--
src/backend/executor/execGrouping.c | 57 ++---
src/backend/executor/nodeAgg.c  | 20 +++--
src/backend/executor/nodeSetOp.c| 17 ++-
src/backend/executor/nodeSubplan.c  |  2 +-
src/include/executor/executor.h |  3 --
src/include/nodes/execnodes.h   | 10 +--
6 files changed, 31 insertions(+), 78 deletions(-)



pgsql: Fix redefinition of type in commit e0ece2a981.

2025-01-10 Thread Jeff Davis
Fix redefinition of type in commit e0ece2a981.

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/ceb2855522940d5aaae4c6e5eed493d60e3196ce

Modified Files
--
src/backend/executor/execGrouping.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgsql: TupleHashTable: store additional data along with tuple.

2025-01-10 Thread Jeff Davis
TupleHashTable: store additional data along with tuple.

Previously, the caller needed to allocate the memory and the
TupleHashTable would store a pointer to it. That wastes space for the
palloc overhead as well as the size of the pointer itself.

Now, the TupleHashTable relies on the caller to correctly specify the
additionalsize, and allocates that amount of space. The caller can
then request a pointer into that space.

Discussion: 
https://postgr.es/m/b9cbf0219a9859dc8d240311643ff4362fd9602c.ca...@j-davis.com
Reviewed-by: Heikki Linnakangas

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/e0ece2a981ee9068f50c4423e303836c2585eb02

Modified Files
--
src/backend/executor/execGrouping.c | 57 +++--
src/backend/executor/nodeAgg.c  | 20 ++---
src/backend/executor/nodeSetOp.c| 17 +--
src/backend/executor/nodeSubplan.c  |  2 +-
src/include/executor/executor.h |  3 ++
src/include/nodes/execnodes.h   | 10 ++-
6 files changed, 78 insertions(+), 31 deletions(-)



pgsql: Fix duplicate typedef from commit a2f17f004d.

2025-01-08 Thread Jeff Davis
Fix duplicate typedef from commit a2f17f004d.

Reported-by: Thomas Munro

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/229e7793d96954739d3fb9b37e2ccf77c2803f07

Modified Files
--
src/include/utils/pg_locale.h | 2 --
1 file changed, 2 deletions(-)



pgsql: Control collation behavior with a method table.

2025-01-08 Thread Jeff Davis
Control collation behavior with a method table.

Previously, behavior branched based on the provider. A method table is
less error-prone and more flexible.

The ctype behavior will be addressed in an upcoming commit.

Reviewed-by: Andreas Karlsson
Discussion: 
https://postgr.es/m/2830211e1b6e6a2e26d845780b03e125281ea17b.camel%40j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/a2f17f004d229f69a32cfa80904b95edcbc68f95

Modified Files
--
src/backend/utils/adt/pg_locale.c  | 123 ---
src/backend/utils/adt/pg_locale_icu.c  | 147 +++--
src/backend/utils/adt/pg_locale_libc.c |  53 ++--
src/include/utils/pg_locale.h  |  33 
4 files changed, 180 insertions(+), 176 deletions(-)



pgsql: Move code for collation version into provider-specific files.

2025-01-08 Thread Jeff Davis
Move code for collation version into provider-specific files.

Author: Andreas Karlsson
Discussion: https://postgr.es/m/4548a168-62cd-457b-8d06-9ba7b985c477%40proxel.se

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/4f5cef2607c1f8804d4b54250642aaf586745b0e

Modified Files
--
src/backend/utils/adt/pg_locale.c | 103 +++---
src/backend/utils/adt/pg_locale_builtin.c |  24 +++
src/backend/utils/adt/pg_locale_icu.c |  17 +
src/backend/utils/adt/pg_locale_libc.c|  74 +
4 files changed, 123 insertions(+), 95 deletions(-)



pgsql: ExecInitAgg: update aggstate->numaggs and ->numtrans earlier.

2025-01-07 Thread Jeff Davis
ExecInitAgg: update aggstate->numaggs and ->numtrans earlier.

Functions hash_agg_entry_size() and build_hash_tables() make use of
those values for memory size estimates.

Because this change only affects memory estimates, don't backpatch.

Discussion: 
https://postgr.es/m/7530bd8783b1a78d53a3c70383e38d8da0a5ffe5.camel%40j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/3f482940dbcbd15834a67894f4d9efdf5ceb7e16

Modified Files
--
src/backend/executor/nodeAgg.c | 11 ++-
1 file changed, 2 insertions(+), 9 deletions(-)



pgsql: nodeSetOp.c: missing additionalsize for BuildTupleHashTable().

2025-01-07 Thread Jeff Davis
nodeSetOp.c: missing additionalsize for BuildTupleHashTable().

Provide additionalsize argument, which can affect the calculations for
'nbuckets'. Also, future work for Hash Aggregation will rely on the
correct additionalsize.

Discussion: 
https://postgr.es/m/7530bd8783b1a78d53a3c70383e38d8da0a5ffe5.camel%40j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/32ddfaffd1493b27f200afb3919d3fd2e6a200ef

Modified Files
--
src/backend/executor/nodeSetOp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Remove unused TupleHashTableData->entrysize.

2025-01-07 Thread Jeff Davis
Remove unused TupleHashTableData->entrysize.

Discussion: 
https://postgr.es/m/7530bd8783b1a78d53a3c70383e38d8da0a5ffe5.camel%40j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/8a96faedc408b447acd1570d2f51300bcec34959

Modified Files
--
src/backend/executor/execGrouping.c | 1 -
src/include/nodes/execnodes.h   | 1 -
2 files changed, 2 deletions(-)



pgsql: Add missing typedefs.list entry for AggStatePerGroupData.

2025-01-07 Thread Jeff Davis
Add missing typedefs.list entry for AggStatePerGroupData.

Discussion: 
https://postgr.es/m/7530bd8783b1a78d53a3c70383e38d8da0a5ffe5.camel%40j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/834c9e807cf12e355f06479a8b1f7a82aba77315

Modified Files
--
src/include/executor/nodeAgg.h   | 2 +-
src/tools/pgindent/typedefs.list | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)



pgsql: Refactor string case conversion into provider-specific files.

2024-12-16 Thread Jeff Davis
Refactor string case conversion into provider-specific files.

Create API entry points pg_strlower(), etc., that work with any
provider and give the caller control over the destination
buffer. Then, move provider-specific logic into pg_locale_builtin.c,
pg_locale_icu.c, and pg_locale_libc.c as appropriate.

Discussion: 
https://postgr.es/m/7aa46d77b377428058403723440862d12a8a129a.ca...@j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/86a5d6006aff956a5e00982b7628177fa7dc5027

Modified Files
--
src/backend/utils/adt/formatting.c| 465 --
src/backend/utils/adt/pg_locale.c |  78 +
src/backend/utils/adt/pg_locale_builtin.c |  80 +
src/backend/utils/adt/pg_locale_icu.c | 130 -
src/backend/utils/adt/pg_locale_libc.c| 327 +
src/include/utils/pg_locale.h |  14 +-
6 files changed, 676 insertions(+), 418 deletions(-)



pgsql: Use in-place updates for pg_restore_relation_stats().

2024-12-10 Thread Jeff Davis
Use in-place updates for pg_restore_relation_stats().

This matches the behavior of vac_update_relstats(), which is important
to avoid bloating pg_class.

Author: Corey Huinker
Discussion: 
https://postgr.es/m/CADkLM=fc3je+ufv3gshqjjssf+t8674rxpuxw62el55mueq...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/a43567483c617fb046c805b61964d5168c9a0553

Modified Files
--
doc/src/sgml/func.sgml |   8 ++
src/backend/statistics/relation_stats.c| 200 +++--
src/test/regress/expected/stats_import.out |  61 +
src/test/regress/sql/stats_import.sql  |  37 ++
4 files changed, 235 insertions(+), 71 deletions(-)



pgsql: Comment fix: "buffer context lock" to "buffer content lock".

2024-12-06 Thread Jeff Davis
Comment fix: "buffer context lock" to "buffer content lock".

The term "buffer context lock" is outdated as of commit 5d5087363d.

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/ffe003cae1ff28b698f1769e46e3dc14b5516070

Modified Files
--
src/backend/access/transam/xact.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Move check for ucol_strcollUTF8 to pg_locale_icu.c

2024-12-03 Thread Jeff Davis
Move check for ucol_strcollUTF8 to pg_locale_icu.c

The result of the check is only used by pg_locale_icu.c.

Author: Andreas Karlsson
Discussion: https://postgr.es/m/4548a168-62cd-457b-8d06-9ba7b985c...@proxel.se

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/7167e05fc7d191bfd59f16d0852705d8f4a3fa08

Modified Files
--
src/backend/utils/adt/pg_locale_icu.c | 12 
src/include/utils/pg_locale.h | 13 -
2 files changed, 12 insertions(+), 13 deletions(-)



pgsql: Perform provider-specific initialization in new functions.

2024-12-02 Thread Jeff Davis
Perform provider-specific initialization in new functions.

Reviewed-by: Andreas Karlsson
Discussion: https://postgr.es/m/4548a168-62cd-457b-8d06-9ba7b985c...@proxel.se

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/1ba0782ce90cb4261098de59b49ae5cb2326566b

Modified Files
--
src/backend/utils/adt/Makefile|   1 +
src/backend/utils/adt/meson.build |   1 +
src/backend/utils/adt/pg_locale.c | 162 +-
src/backend/utils/adt/pg_locale_builtin.c |  70 +
src/backend/utils/adt/pg_locale_icu.c |  97 +-
src/backend/utils/adt/pg_locale_libc.c|  74 +-
6 files changed, 259 insertions(+), 146 deletions(-)



pgsql: Fix unintentional behavior change in commit e9931bfb75.

2024-12-02 Thread Jeff Davis
Fix unintentional behavior change in commit e9931bfb75.

Prior to that commit, there was special case to use ASCII case mapping
behavior for the libc provider with a single-byte encoding when that's
the default collation. Commit e9931bfb75 mistakenly eliminated that
special case; this commit restores it.

Discussion: 
https://postgr.es/m/01a104f0d2179d756261e90d96fd65c36ad6fcf0.ca...@j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/e3fa2b037c6f0f435838e99200050dc54c306085

Modified Files
--
src/backend/utils/adt/formatting.c | 30 +-
src/backend/utils/adt/like.c   |  2 ++
src/backend/utils/adt/pg_locale.c  |  2 ++
src/include/utils/pg_locale.h  |  1 +
4 files changed, 30 insertions(+), 5 deletions(-)



pgsql: Disallow modifying statistics on system columns.

2024-11-22 Thread Jeff Davis
Disallow modifying statistics on system columns.

Reported-by: Heikki Linnakangas
Discussion: https://postgr.es/m/df3e1c41-4e6c-40ad-9636-98deefe48...@iki.fi

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/869ee4f10eca2acda3d2210198a46d5029a569fc

Modified Files
--
src/backend/statistics/attribute_stats.c   | 14 ++
src/test/regress/expected/stats_import.out | 15 +++
src/test/regress/sql/stats_import.sql  | 15 +++
3 files changed, 44 insertions(+)



pgsql: Fix lc_collate_is_c() when LC_COLLATE != LC_CTYPE.

2024-11-06 Thread Jeff Davis
Fix lc_collate_is_c() when LC_COLLATE != LC_CTYPE.

An unfortunate typo in commit 2d819a08a1 can cause wrong results when
the default collation provider is libc, LC_CTYPE=C, and LC_COLLATE is
a real locale. Users with this combination of settings must REINDEX
all affected indexes.

The same typo can also cause performance degradation when LC_COLLATE=C
and LC_CTYPE is a real locale.

Problem does not exist in master (due to refactoring), so fix only in
version 17.

Reported-by: Drew Callahan
Discussion: 
https://postgr.es/m/d5081a7f4f6d425c28dd69d1e09b2e78f149e726.ca...@j-davis.com

Branch
--
REL_17_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/8148e7124d550770e3a9064b9b45b354d783b949

Modified Files
--
src/backend/utils/adt/pg_locale.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgsql: Add missing CommandCounterIncrement() in stats import functions.

2024-10-29 Thread Jeff Davis
Add missing CommandCounterIncrement() in stats import functions.

Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/98b2fcf0-f701-369e-d63d-6be9739ce...@gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/f22e436bff779fee4e1ce49733ba5791d4634fb1

Modified Files
--
src/backend/statistics/attribute_stats.c | 11 ---
src/backend/statistics/relation_stats.c  |  2 ++
2 files changed, 10 insertions(+), 3 deletions(-)



pgsql: Refactor the code to create a pg_locale_t into new function.

2024-10-25 Thread Jeff Davis
Refactor the code to create a pg_locale_t into new function.

Reviewed-by: Andreas Karlsson
Discussion: https://postgr.es/m/59da7ee4-5e1a-4727-b464-a603c6ed8...@proxel.se

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/3aa2373c114124f62e80016d8939331fcb4d5586

Modified Files
--
src/backend/utils/adt/pg_locale.c | 296 ++
1 file changed, 139 insertions(+), 157 deletions(-)



pgsql: Add functions pg_restore_relation_stats(), pg_restore_attribute_

2024-10-24 Thread Jeff Davis
Add functions pg_restore_relation_stats(), pg_restore_attribute_stats().

Similar to the pg_set_*_stats() functions, except with a variadic
signature that's designed to be more future-proof. Additionally, most
problems are reported as WARNINGs rather than ERRORs, allowing most
stats to be restored even if some cannot.

These functions are intended to be called from pg_dump to avoid the
need to run ANALYZE after an upgrade.

Author: Corey Huinker
Discussion: 
https://postgr.es/m/CADkLM=eergzn7ecdpwfcptjkok9sxzek5pot4d94evtzsvj...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/d32d1463995c036853eeb9ec99cc367ffc7794ae

Modified Files
--
doc/src/sgml/func.sgml | 100 +++
src/backend/statistics/attribute_stats.c   |  19 +
src/backend/statistics/relation_stats.c|  60 +-
src/backend/statistics/stat_utils.c| 126 
src/include/catalog/catversion.h   |   2 +-
src/include/catalog/pg_proc.dat|  20 +-
src/include/statistics/stat_utils.h|   5 +
src/test/regress/expected/stats_import.out | 955 +++--
src/test/regress/sql/stats_import.sql  | 696 -
9 files changed, 1891 insertions(+), 92 deletions(-)



pgsql: Improve pg_set_attribute_stats() error message.

2024-10-23 Thread Jeff Davis
Improve pg_set_attribute_stats() error message.

Previously, an invalid attribute name was caught, but the error
message was unhelpful.

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/4b096c67e0eed81e287094b9692fff72b9ea3eef

Modified Files
--
src/backend/statistics/attribute_stats.c   | 10 ++
src/test/regress/expected/stats_import.out | 23 ++-
src/test/regress/sql/stats_import.sql  | 23 ++-
3 files changed, 54 insertions(+), 2 deletions(-)



pgsql: Another documentation fixup.

2024-10-23 Thread Jeff Davis
Another documentation fixup.

Reported-by: Erik Rijkers

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/0a3f9838218f6f7ff825bb0af00177681fef83ce

Modified Files
--
doc/src/sgml/func.sgml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Fix compiler warning.

2024-10-23 Thread Jeff Davis
Fix compiler warning.

Some buildfarm members complained about an always-true test in the
SOFT_ERROR_OCCURRED macro. Fix by reading the field directly rather
than using the macro.

Reported-by: Tom Lane
Discussion: https://postgr.es/m/2144895.1729653...@sss.pgh.pa.us

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/56b1e88c804b0c7e32f77b4e2bd3cc42ebdfcc3f

Modified Files
--
src/backend/statistics/attribute_stats.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Documentation fixup.

2024-10-23 Thread Jeff Davis
Documentation fixup.

Wrong return type for pg_clear_attribute_stats().

Author: Noriyoshi Shinoda
Discussion: 
https://postgr.es/m/dm4pr84mb17347944f27a552f0ccdf84cee...@dm4pr84mb1734.namprd84.prod.outlook.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/07d00692c8da83fe2835900b2294e8966c2be247

Modified Files
--
doc/src/sgml/func.sgml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Add functions pg_set_attribute_stats() and pg_clear_attribute_st

2024-10-22 Thread Jeff Davis
Add functions pg_set_attribute_stats() and pg_clear_attribute_stats().

Enable manipulation of attribute statistics. Only superficial
validation is performed, so it's possible to add nonsense, and it's up
to the planner (or other users of statistics) to behave reasonably in
that case.

Bump catalog version.

Author: Corey Huinker
Discussion: 
https://postgr.es/m/CADkLM=eergzn7ecdpwfcptjkok9sxzek5pot4d94evtzsvj...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/ce207d2a79017713c0293bf70132dc6d41166b03

Modified Files
--
doc/src/sgml/func.sgml |  72 +++
src/backend/catalog/system_functions.sql   |  22 +
src/backend/statistics/Makefile|   1 +
src/backend/statistics/attribute_stats.c   | 869 +
src/backend/statistics/meson.build |   1 +
src/backend/statistics/stat_utils.c|  73 +++
src/include/catalog/catversion.h   |   2 +-
src/include/catalog/pg_proc.dat|  14 +
src/include/statistics/stat_utils.h|   7 +
src/test/regress/expected/stats_import.out | 659 +-
src/test/regress/sql/stats_import.sql  | 545 ++
11 files changed, 2263 insertions(+), 2 deletions(-)



pgsql: Change pg_*_relation_stats() functions to return type to void.

2024-10-22 Thread Jeff Davis
Change pg_*_relation_stats() functions to return type to void.

These functions will either raise an ERROR or run to normal
completion, so no return value is necessary.

Bump catalog version.

Author: Corey Huinker
Discussion: 
https://postgr.es/m/CADkLM=cbf8rnphutyhfi3kyzb9bydgx57hwk9rz2yp7s+om...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/dbe6bd4343d8cdb1b3cf1f66d6f66dd876a6c09d

Modified Files
--
doc/src/sgml/func.sgml | 11 ---
src/backend/catalog/system_functions.sql   |  2 +-
src/backend/statistics/relation_stats.c|  6 --
src/include/catalog/catversion.h   |  2 +-
src/include/catalog/pg_proc.dat|  4 ++--
src/test/regress/expected/stats_import.out | 16 
6 files changed, 20 insertions(+), 21 deletions(-)



pgsql: Allow pg_set_relation_stats() to set relpages to -1.

2024-10-18 Thread Jeff Davis
Allow pg_set_relation_stats() to set relpages to -1.

While the default value for relpages is 0, if a partitioned table with
at least one child has been analyzed, then the partititoned table will
have a relpages value of -1.

Author: Corey Huinker
Discussion: 
https://postgr.es/m/CADkLM=fajh1Lpcyr_XsMmq-9Z=sgk-u+_zeac7pt0ran3ui...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/b391d882ff38da423dc99fc6224bde4be4100212

Modified Files
--
doc/src/sgml/func.sgml |  2 +-
src/backend/statistics/relation_stats.c|  9 +--
src/test/regress/expected/stats_import.out | 38 +-
src/test/regress/sql/stats_import.sql  | 25 
4 files changed, 70 insertions(+), 4 deletions(-)



pgsql: Disable autovacuum for tables in stats import tests.

2024-10-18 Thread Jeff Davis
Disable autovacuum for tables in stats import tests.

While we haven't observed any test instability, it seems like a good
idea to disable autovacuum during the stats import tests.

Author: Corey Huinker
Discussion: 
https://postgr.es/m/CADkLM=fajh1Lpcyr_XsMmq-9Z=sgk-u+_zeac7pt0ran3ui...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/779972e534c05c51be3e593b0681029afb1bd155

Modified Files
--
src/test/regress/expected/stats_import.out | 5 +++--
src/test/regress/sql/stats_import.sql  | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)



pgsql: Improve ThrowErrorData() comments for use with soft errors.

2024-10-17 Thread Jeff Davis
Improve ThrowErrorData() comments for use with soft errors.

Reviewed-by: Corey Huinker
Discussion: 
https://postgr.es/m/901ab7cf01957f92ea8b30b6feeb0eacfb7505fc.ca...@j-davis.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/eecd9138a0ef565366427a88866d0651530f7da4

Modified Files
--
src/backend/utils/error/elog.c | 15 +--
src/include/nodes/miscnodes.h  |  7 ---
2 files changed, 13 insertions(+), 9 deletions(-)



pgsql: Whitespace fixup from generated unicode tables.

2024-10-16 Thread Jeff Davis
Whitespace fixup from generated unicode tables.

When running the 'update-unicode' build target, generate files that
conform to pgindent whitespace rules.

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/a7f2f6adc240a2823c2344b89e90bb630dea8803

Modified Files
--
src/common/unicode/generate-unicode_case_table.pl | 4 ++--
src/common/unicode/generate-unicode_category_table.pl | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)



  1   2   3   4   5   6   >