mirror of
https://github.com/postgres/postgres.git
synced 2025-11-18 02:02:55 +03:00
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=eErgzn7ECDpwFcptJKOk9SxZEk5Pot4d94eVTZsvj3gw@mail.gmail.com
This commit is contained in:
@@ -877,3 +877,22 @@ pg_clear_attribute_stats(PG_FUNCTION_ARGS)
|
||||
delete_pg_statistic(reloid, attnum, inherited);
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_restore_attribute_stats(PG_FUNCTION_ARGS)
|
||||
{
|
||||
LOCAL_FCINFO(positional_fcinfo, NUM_ATTRIBUTE_STATS_ARGS);
|
||||
bool result = true;
|
||||
|
||||
InitFunctionCallInfoData(*positional_fcinfo, NULL, NUM_ATTRIBUTE_STATS_ARGS,
|
||||
InvalidOid, NULL, NULL);
|
||||
|
||||
if (!stats_fill_fcinfo_from_arg_pairs(fcinfo, positional_fcinfo,
|
||||
attarginfo, WARNING))
|
||||
result = false;
|
||||
|
||||
if (!attribute_statistics_update(positional_fcinfo, WARNING))
|
||||
result = false;
|
||||
|
||||
PG_RETURN_BOOL(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user