Fix handling of nested values in "exprs" for pg_restore_extended_stats()

check_all_expr_argnames_valid() iterated over the keys of each
expression object without skipping nested containers, so an unknown key
whose value is an array or an object broke the expected key/value token
sequence.  This caused an assertion failure, or an infinite loop that
cannot be canceled in non-assert builds.

This issue is fixed by skipping any nested containers, as we expect a
single array with a single sets of key/value pairs.

While on it, remove an unused allocation of the invalid key name.
This one has been noticed in passing.

Author: Ilia Evdokimov <[email protected]>
Reviewed-by: Chao Li <[email protected]>
Reviewed-by: Michael Paquier <[email protected]>
Discussion: 
https://postgr.es/m/[email protected]
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f1d69bb7dfc2021091281b7063fe76c6ffcb9613

Modified Files
--------------
src/backend/statistics/extended_stats_funcs.c |  8 ++------
src/test/regress/expected/stats_import.out    | 14 ++++++++++++++
src/test/regress/sql/stats_import.sql         |  9 +++++++++
3 files changed, 25 insertions(+), 6 deletions(-)

Reply via email to