Refactor tests for catalog diff comparisons in stats_import.sql The tests of stats_import.sql include a set of queries to do differential checks of the three statistics catalog relations, based on the comparison of a source relation and a target relation, used for the copy of the stats data with the restore functions: - pg_statistic - pg_stats_ext - pg_stats_ext_exprs
This commit refactors the tests to reduce the bloat of such differential queries, by creating a set of objects that make the differential queries smaller: - View for a base relation type. - First function to retrieve stats data, that returns a type based on the view previously created. - Second function that checks the difference, based on two calls of the first function. This change leads to a nice reduction of stats_import.sql, with a larger effect on the output file. While on it, this adds some sanity checks for the three catalogs, to warn developers that the stats import facilities may need to be updated if any of the three catalogs change. These are rare in practice, see 918eee0c497c as one example. Another stylistic change is the use of the extended output format for the differential queries, so as we avoid long lines of output if a diff is caught. Author: Corey Huinker <[email protected]> Discussion: https://postgr.es/m/CADkLM=eEhxJpSUP+eC=emgzzsvopnfkdvvkucbsfg9cajyw...@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/ccd7abaa456f34a41efe2e5198f0bb2227aa43d9 Modified Files -------------- src/test/regress/expected/stats_import.out | 501 +++++++++++------------------ src/test/regress/sql/stats_import.sql | 461 ++++++++++---------------- 2 files changed, 357 insertions(+), 605 deletions(-)
