Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nISaP-0004tt-AR for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Feb 2022 09:51:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nISaO-00044C-7u for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Feb 2022 09:51:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nISaN-000442-Ut for pgsql-hackers@lists.postgresql.org; Fri, 11 Feb 2022 09:51:27 +0000 Received: from ssl.nataraj.su ([88.198.198.57]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nISaL-0005TF-UI for pgsql-hackers@postgresql.org; Fri, 11 Feb 2022 09:51:27 +0000 Received: from thinkpad-pgpro.localnet (unknown [91.203.188.92]) by ssl.nataraj.su (Postfix) with ESMTPSA id 767879D2B0 for ; Fri, 11 Feb 2022 09:51:24 +0000 (UTC) From: Nikolay Shaplov To: PostgreSQL Hackers Subject: [PATCH] minor reloption regression tests improvement Date: Fri, 11 Feb 2022 12:51:22 +0300 Message-ID: <4563991.km65PDbjlG@thinkpad-pgpro> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart3608498.Tki310Yi80" Content-Transfer-Encoding: 7Bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --nextPart3608498.Tki310Yi80 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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 --nextPart3608498.Tki310Yi80 Content-Disposition: attachment; filename="reloption_regression_improvement.diff" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="reloption_regression_improvement.diff" diff --git a/src/test/regress/expected/reloptions.out b/src/test/regress/expected/reloptions.out index 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.sql index 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 -- --nextPart3608498.Tki310Yi80--