From b80703cc90ae518207a618ab90d4667f45c14d27 Mon Sep 17 00:00:00 2001 From: "Andrey V. Lepikhov" Date: Tue, 31 Jan 2023 15:33:09 +0500 Subject: [PATCH] Rewrite update_functions.sql to avoid dependency on internal logic of the optimizer which can vary on version of PG core. --- expected/update_functions.out | 78 ++++++----------------------------- sql/update_functions.sql | 16 ++++--- 2 files changed, 22 insertions(+), 72 deletions(-) diff --git a/expected/update_functions.out b/expected/update_functions.out index 03a97fe7..cf9cee8e 100644 --- a/expected/update_functions.out +++ b/expected/update_functions.out @@ -295,40 +295,10 @@ UNION ALL -- aqo_data_update() testing. -- -- Populate aqo_data with dump data. -SELECT aqo_data_update(fs, fss, nfeatures, features, targets, reliability, oids) AS res -FROM aqo_data_dump -ORDER BY res; - res ------ - t - t - t - t - t - t - t - t - t - t - t - t - t - t - t - t - t - t - t - t - t - t - t - t - t - t - t -(27 rows) - +SELECT count(*) AS res1 FROM + aqo_data_dump, + LATERAL aqo_data_update(fs, fss, nfeatures, features, targets, reliability, oids) AS ret +WHERE ret \gset -- Check if data is the same as in source, no result rows expected. (TABLE aqo_data_dump EXCEPT TABLE aqo_data) UNION ALL @@ -338,39 +308,15 @@ UNION ALL (0 rows) -- Update aqo_data with dump data. -SELECT aqo_data_update(fs, fss, nfeatures, features, targets, reliability, oids) AS res -FROM aqo_data_dump -ORDER BY res; - res ------ - t - t - t - t - t - t - t - t - t - t - t - t +SELECT count(*) AS res2 FROM + aqo_data_dump, + LATERAL aqo_data_update(fs, fss, nfeatures, features, targets, reliability, oids) AS ret +WHERE ret \gset +SELECT :res1 = :res2 AS ml_sizes_are_equal; + ml_sizes_are_equal +-------------------- t - t - t - t - t - t - t - t - t - t - t - t - t - t - t -(27 rows) +(1 row) -- Check if data is the same as in source, no result rows expected. (TABLE aqo_data_dump EXCEPT TABLE aqo_data) diff --git a/sql/update_functions.sql b/sql/update_functions.sql index 85b711e6..84add94a 100644 --- a/sql/update_functions.sql +++ b/sql/update_functions.sql @@ -146,9 +146,10 @@ UNION ALL -- -- Populate aqo_data with dump data. -SELECT aqo_data_update(fs, fss, nfeatures, features, targets, reliability, oids) AS res -FROM aqo_data_dump -ORDER BY res; +SELECT count(*) AS res1 FROM + aqo_data_dump, + LATERAL aqo_data_update(fs, fss, nfeatures, features, targets, reliability, oids) AS ret +WHERE ret \gset -- Check if data is the same as in source, no result rows expected. (TABLE aqo_data_dump EXCEPT TABLE aqo_data) @@ -156,9 +157,12 @@ UNION ALL (TABLE aqo_data EXCEPT TABLE aqo_data_dump); -- Update aqo_data with dump data. -SELECT aqo_data_update(fs, fss, nfeatures, features, targets, reliability, oids) AS res -FROM aqo_data_dump -ORDER BY res; +SELECT count(*) AS res2 FROM + aqo_data_dump, + LATERAL aqo_data_update(fs, fss, nfeatures, features, targets, reliability, oids) AS ret +WHERE ret \gset + +SELECT :res1 = :res2 AS ml_sizes_are_equal; -- Check if data is the same as in source, no result rows expected. (TABLE aqo_data_dump EXCEPT TABLE aqo_data)