From: Nikolay Shaplov <dhyan@nataraj.su>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Subject: [PATCH] minor reloption regression tests improvement
Date: Fri, 11 Feb 2022 12:51:22 +0300
Message-ID: <4563991.km65PDbjlG@thinkpad-pgpro> (raw)
I'd like to suggest a patch for reloption regression tests.
This patch tests case, that can be rarely met in actual life: when reloptions
have some illegal option set (as a result of malfunction or extension
downgrade or something), and user tries to remove this option by using RESET.
Current postgres behaviour is to actually remove this option.
Like:
UPDATE pg_class SET reloptions = '{illegal_option=4}'
WHERE oid = 'reloptions_test'::regclass;
ALTER TABLE reloptions_test RESET (illegal_option);
Why this should be tested:
1. It is what postgres actually do now.
2. This behaviour is reasonable. DB User can fix problem without updating
pg_class, having rights to change his own table.
3. Better to get test alarm, if this behavior is accidentally changed.
--
Nikolay Shaplov aka Nataraj
Fuzzing Engineer at Postgres Professional
Matrix IM: @dhyan:nataraj.su
Attachments:reloption_regression_improvement.diff (text/x-patch, 1.7K) downloaddiff --git a/src/test/regress/expected/reloptions.out b/src/test/regress/expected/reloptions.outindex b6aef6f654..9f460a7e60 100644--- a/src/test/regress/expected/reloptions.out+++ b/src/test/regress/expected/reloptions.out@@ -183,6 +183,17 @@ SELECT reloptions FROM pg_class WHERE oid = (
{autovacuum_vacuum_cost_delay=23}
(1 row)
+-- Can reset option that is not allowed, but for some reason is already set+UPDATE pg_class+ SET reloptions = '{fillfactor=13,autovacuum_enabled=false,illegal_option=4}'+ WHERE oid = 'reloptions_test'::regclass;+ALTER TABLE reloptions_test RESET (illegal_option);+SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;+ reloptions +------------------------------------------+ {fillfactor=13,autovacuum_enabled=false}+(1 row)+
--
-- CREATE INDEX, ALTER INDEX for btrees
--
diff --git a/src/test/regress/sql/reloptions.sql b/src/test/regress/sql/reloptions.sqlindex 4252b0202f..fadce3384d 100644--- a/src/test/regress/sql/reloptions.sql+++ b/src/test/regress/sql/reloptions.sql@@ -105,6 +105,13 @@ SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
SELECT reloptions FROM pg_class WHERE oid = (
SELECT reltoastrelid FROM pg_class WHERE oid = 'reloptions_test'::regclass);
+-- Can reset option that is not allowed, but for some reason is already set+UPDATE pg_class+ SET reloptions = '{fillfactor=13,autovacuum_enabled=false,illegal_option=4}'+ WHERE oid = 'reloptions_test'::regclass;+ALTER TABLE reloptions_test RESET (illegal_option);+SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;+
--
-- CREATE INDEX, ALTER INDEX for btrees
--
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: dhyan@nataraj.su
Subject: Re: [PATCH] minor reloption regression tests improvement
In-Reply-To: <4563991.km65PDbjlG@thinkpad-pgpro>
References: <4563991.km65PDbjlG@thinkpad-pgpro>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox