On Sat, 2024-07-27 at 21:08 -0400, Corey Huinker wrote: > > > I don't like the idea of mixing statistics and control parameters > > in > > the same list. > > > > > There's no way around it, at least now we need never worry about a > confusing order for the parameters in the _restore_ functions because > they can now be in any order you like.
Perhaps I was not precise enough when I said "control" parameters. Mainly what I was worried about is trying to take parameters that control things like transaction behavior (in-place vs mvcc), and pg_dump should not be specifying that kind of thing. A parameter like "version" is specified by pg_dump anyway, so it's probably fine the way you've done it. > SELECT pg_catalog.pg_set_attribute_stats( > relation => 'stats_import.test'::regclass::oid, > attname => 'arange'::name, > inherited => false::boolean, > null_frac => 0.5::real, > avg_width => 2::integer, > n_distinct => -0.1::real, > range_empty_frac => 0.5::real, > range_length_histogram => '{399,499,Infinity}'::text > ); > pg_set_attribute_stats > ------------------------ > > (1 row) I like it. > and here is a restore function > > -- warning: mcv cast failure > SELECT * > FROM pg_catalog.pg_restore_attribute_stats( > 'relation', 'stats_import.test'::regclass::oid, > 'attname', 'id'::name, > 'inherited', false::boolean, > 'version', 150000::integer, > 'null_frac', 0.5::real, > 'avg_width', 2::integer, > 'n_distinct', -0.4::real, > 'most_common_vals', '{2,four,3}'::text, > 'most_common_freqs', '{0.3,0.25,0.05}'::real[] > ); > WARNING: invalid input syntax for type integer: "four" > row_written | stats_applied | > stats_rejected | params_rejected > -------------+----------------------------------+-------------------- > ------------------+----------------- > t | {null_frac,avg_width,n_distinct} | > {most_common_vals,most_common_freqs} | > (1 row) I think I like this, as well, except for the return value, which seems like too much information and a bit over-engineered. Can we simplify it to what's actually going to be used by pg_upgrade and other tools? > Attached is v25. I believe 0001 and 0002 are in good shape API-wise, and I can start getting those committed. I will try to clean up the code in the process. Regards, Jeff Davis