Fix issues with handling of expressions in extended stats restore This commit addresses some defects with the handling of expressions in pg_restore_extended_stats() and pg_clear_extended_stats(): - Misleading WARNING for an incorrect number of expressions, where the number of required expressions was reported as the number of elements given in input rather than the actual number of expressions expected by the extstats object definition. - Incorrect matching of expression names, where a key name was considered as valid as long as it matched with the prefix of a legit key name. For example "correlatio" given in input would match with "correlation", and be considered valid. The consequence of this bug was a silent discard of the input data, where the operation would be considered a success. The value associated to the prefixed key was not inserted in the catalogs, just ignored. pg_dump would not generate such input data patterns, but a user doing manual stats injection could. - Missing heap_freetuple() in pg_clear_extended_stats(), for the case where the extstats object in input does not match with its parent relation.
Author: Chao Li <[email protected]> Discussion: https://postgr.es/m/[email protected] Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/a28fa2947d2a507089605c47bbfa9016d457208c Modified Files -------------- src/backend/statistics/extended_stats_funcs.c | 6 +++-- src/test/regress/expected/stats_import.out | 32 +++++++++++++++++++++++++-- src/test/regress/sql/stats_import.sql | 19 +++++++++++++++- 3 files changed, 52 insertions(+), 5 deletions(-)
