v2-0002-Turn-off-autovacuum-for-pg_set_relation_stats-tes.patch
text/x-patch
Filename: v2-0002-Turn-off-autovacuum-for-pg_set_relation_stats-tes.patch
Type: text/x-patch
Part: 1
Message:
Re: Statistics Import and Export
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v2-0002
Subject: Turn off autovacuum for pg_set_relation_stats() tests.
| File | + | − |
|---|---|---|
| src/test/regress/expected/stats_import.out | 6 | 3 |
| src/test/regress/sql/stats_import.sql | 6 | 3 |
From f3a3df68763892f966547c2705b0cf9198bd55ec Mon Sep 17 00:00:00 2001
From: Corey Huinker <corey.huinker@gmail.com>
Date: Wed, 16 Oct 2024 18:45:57 -0400
Subject: [PATCH v2 2/3] Turn off autovacuum for pg_set_relation_stats() tests.
Unlikely as it may be, it is theoretically possible that autovacuum
could act upon one of the tables that have had test stats applied and
set the stats to reflect the empty table that it is. To avoid the
possibility of an intermittent (and very confusing) regression test
failure, turn off autovacuum for all tables that will have stats applied
during the tests.
---
src/test/regress/expected/stats_import.out | 9 ++++++---
src/test/regress/sql/stats_import.sql | 9 ++++++---
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/test/regress/expected/stats_import.out b/src/test/regress/expected/stats_import.out
index 46e45a5fa3..de37d890c4 100644
--- a/src/test/regress/expected/stats_import.out
+++ b/src/test/regress/expected/stats_import.out
@@ -11,7 +11,7 @@ CREATE TABLE stats_import.test(
comp stats_import.complex_type,
arange int4range,
tags text[]
-);
+) WITH (autovacuum_enabled = false);
-- starting stats
SELECT relpages, reltuples, relallvisible
FROM pg_class
@@ -136,11 +136,14 @@ SELECT
ERROR: cannot modify statistics for relation "testview"
DETAIL: This operation is not supported for views.
-- Partitioned tables with at least 1 child partition will, when analyzed,
--- have a relpages of -1
+-- have a relpages of -1.
+-- Note: can't set storage params on partitioned tables, so just set for
+-- the child table(s).
CREATE TABLE stats_import.part_parent ( i integer ) PARTITION BY RANGE(i);
CREATE TABLE stats_import.part_child_1
PARTITION OF stats_import.part_parent
- FOR VALUES FROM (0) TO (10);
+ FOR VALUES FROM (0) TO (10)
+ WITH (autovacuum_enabled = false);
ANALYZE stats_import.part_parent;
SELECT relpages
FROM pg_class
diff --git a/src/test/regress/sql/stats_import.sql b/src/test/regress/sql/stats_import.sql
index ad129b1ab9..b8d1ef795f 100644
--- a/src/test/regress/sql/stats_import.sql
+++ b/src/test/regress/sql/stats_import.sql
@@ -13,7 +13,7 @@ CREATE TABLE stats_import.test(
comp stats_import.complex_type,
arange int4range,
tags text[]
-);
+) WITH (autovacuum_enabled = false);
-- starting stats
SELECT relpages, reltuples, relallvisible
@@ -96,11 +96,14 @@ SELECT
'stats_import.testview'::regclass);
-- Partitioned tables with at least 1 child partition will, when analyzed,
--- have a relpages of -1
+-- have a relpages of -1.
+-- Note: can't set storage params on partitioned tables, so just set for
+-- the child table(s).
CREATE TABLE stats_import.part_parent ( i integer ) PARTITION BY RANGE(i);
CREATE TABLE stats_import.part_child_1
PARTITION OF stats_import.part_parent
- FOR VALUES FROM (0) TO (10);
+ FOR VALUES FROM (0) TO (10)
+ WITH (autovacuum_enabled = false);
ANALYZE stats_import.part_parent;
--
2.46.2