Re: Add expressions to pg_restore_extended_stats()
Corey Huinker <corey.huinker@gmail.com>
From: Corey Huinker <corey.huinker@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Chao Li <li.evan.chao@gmail.com>, Tender Wang <tndrwang@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Tomas Vondra <tomas@vondra.me>
Date: 2026-03-09T04:40:45Z
Lists: pgsql-hackers
> > Thanks for the patches. I have tweaked a couple of comments, and > applied them after merging the whole together. I have also spent the > time checking things by breaking some of the internal logic of the > restore functions, to see if diffs were correctly showing up. > My test method was to mis-name one of the objects (i.e. test_clone becomes test_clone0) and the diffs popped right up. > > One thing I was wondering is if the flat functions should call the > view, but at the end I guess that it does not matter much as long as > each query is grouped close to the other. There is no need to expose > attrelid in the view, information we do not want to show in the type > of the view anyway. > They can't call the view. If the view doesn't contain the object name or oid, then we can't use it to reference the object, and if it does contain that then we can't do a (SELECT * FROM A EXCEPT SELECT * FROM B) on one object vs its clone because it'll always be different. The choice of a view was just a convenient way to get all the fieldnames and datatypes right even if they change. I suppose I could have created the view with the oids, created a type from the view, altered the type to remove the oid columns, and then had the _flat function select from the view and return the type, but instead opted to do what I did. While writing this I kept thinking that the pattern would benefit from the proposed column exclusion (i.e. SELECT * EXCEPT (a, b) FROM table...) syntax, but even that wouldn't save us because the ANYARRAY columns would still need to be cast to text. So my imagined elegant solution isn't out there, unless we want to define an equality operator between ANYARRAY types. Thanks for the commits!
Commits
-
Refactor tests for catalog diff comparisons in stats_import.sql
- ccd7abaa456f 19 (unreleased) landed
-
Fix typo in stats_import.sql
- 9e8193a26229 19 (unreleased) landed
-
Add support for "exprs" in pg_restore_extended_stats()
- ba97bf9cb7b4 19 (unreleased) landed
-
Add information about range type stats to pg_stats_ext_exprs
- 307447e6dbc0 19 (unreleased) landed
-
Fix comment in extended_stats_funcs.c
- 9476ef206c64 19 (unreleased) landed