| From: | Rahila Syed <rahilasyed90(at)gmail(dot)com> |
|---|---|
| To: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
| Cc: | solai v <solai(dot)cdac(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Melanie Plageman <melanieplageman(at)gmail(dot)com> |
| Subject: | Re: Preserve statistics targets with ALTER TABLE ALTER COLUMN TYPE |
| Date: | 2026-12-03 06:04:15 |
| Message-ID: | CAH2L28tqNFY8Bo8cN5L-u2dBM80XOAvZczhozK0hQeaJFikEpQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
Thank you for the bug fixes.
This bug has been recently reported here [1]. I verified that the proposed
v3-0001 fixes the issues reported there.
Please find a few comments below regarding the v3-0001 patch.
1.
+++ b/src/include/nodes/parsenodes.h
@@ -3574,6 +3574,7 @@ typedef struct CreateStatsStmt
bool transformed; /* true when transformStatsStmt is finished */
bool if_not_exists; /* do nothing if stats name already exists */
Oid owner; /* OID of owner, or InvalidOid for default */
+ int stxstattarget; /* statistics target, or -1 for default */
} CreateStatsStmt;
Why not make the target field a Node * as is done in AlterStatsStmt?
Node *stxstattarget would hold an Integer node, with NULL as default.
That way gram.y and parse_utilcmd.c changes won't be needed and we
won't have to worry about whether the default of -1 is set correctly in
various places.
2. The comment says this also fixes the SET EXPRESSION case. It would
be nice to include a test demonstrating that in the stats_ext.sql file.
Something like this (taken from the linked bug report):
CREATE TABLE st3 (a int, g int GENERATED ALWAYS AS (a * 2) VIRTUAL);
CREATE STATISTICS st3_s ON g, (a + g) FROM st3;
ALTER STATISTICS st3_s SET STATISTICS 400;
ALTER TABLE st3 ALTER COLUMN g SET EXPRESSION AS (a * 3);
SELECT s.stxstattarget FROM pg_statistic_ext s WHERE s.stxname = 'st3_s';
3. The fix adds a field to CreateStatsStmt, a quick search on [2] shows
that this
struct is being used in modules like pgpool-II, pg-stat-plans etc. In that
case
would this pose a problem when the fix is backported? The related commit
6713a6e04cb mentions that no-known third party code constructs this struct.
It may be worth verifying this claim once.
Thank you,
Rahila Syed
[1].
https://www.postgresql.org/message-id/19833-37de35b8f159e62a@postgresql.org
[2].
https://codesearch.debian.net/search?q=CreateStatsStmt&literal=1&page=23
<https://codesearch.debian.net/search?q=CreateStatsStmt&literal=1&page=23>
On Tue, 24 Nov 2026 at 03:12, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
wrote:
> Thank you for the testing!
>
> v3 is a trivial rebase.
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | shveta malik | 2026-12-03 06:10:51 | Re: ALTER DEFAULT PRIVILEGES IN SCHEMA pg_conflict silently has no effect |
| Previous Message | vignesh C | 2026-12-03 06:04:06 | Re: Show the conflict log table in \dRs+ output |