mirror of https://github.com/postgres/postgres
This is preparation for a future patch to extensively change how reloptions work. Author: Nikolay Shaplov Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/2615372.orqtEn8VGB@x200mpull/31/head^2
parent
752871b6de
commit
4b95cc1dc3
@ -0,0 +1,185 @@ |
||||
-- Simple create |
||||
CREATE TABLE reloptions_test(i INT) WITH (FiLLFaCToR=30, |
||||
autovacuum_enabled = false, autovacuum_analyze_scale_factor = 0.2); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass; |
||||
reloptions |
||||
------------------------------------------------------------------------------ |
||||
{fillfactor=30,autovacuum_enabled=false,autovacuum_analyze_scale_factor=0.2} |
||||
(1 row) |
||||
|
||||
-- Fail min/max values check |
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=2); |
||||
ERROR: value 2 out of bounds for option "fillfactor" |
||||
DETAIL: Valid values are between "10" and "100". |
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=110); |
||||
ERROR: value 110 out of bounds for option "fillfactor" |
||||
DETAIL: Valid values are between "10" and "100". |
||||
CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_analyze_scale_factor = -10.0); |
||||
ERROR: value -10.0 out of bounds for option "autovacuum_analyze_scale_factor" |
||||
DETAIL: Valid values are between "0.000000" and "100.000000". |
||||
CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_analyze_scale_factor = 110.0); |
||||
ERROR: value 110.0 out of bounds for option "autovacuum_analyze_scale_factor" |
||||
DETAIL: Valid values are between "0.000000" and "100.000000". |
||||
-- Fail when option and namespace do not exist |
||||
CREATE TABLE reloptions_test2(i INT) WITH (not_existing_option=2); |
||||
ERROR: unrecognized parameter "not_existing_option" |
||||
CREATE TABLE reloptions_test2(i INT) WITH (not_existing_namespace.fillfactor=2); |
||||
ERROR: unrecognized parameter namespace "not_existing_namespace" |
||||
-- Fail while setting improper values |
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=30.5); |
||||
ERROR: invalid value for integer option "fillfactor": 30.5 |
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor='string'); |
||||
ERROR: invalid value for integer option "fillfactor": string |
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=true); |
||||
ERROR: invalid value for integer option "fillfactor": true |
||||
CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_enabled=12); |
||||
ERROR: invalid value for boolean option "autovacuum_enabled": 12 |
||||
CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_enabled=30.5); |
||||
ERROR: invalid value for boolean option "autovacuum_enabled": 30.5 |
||||
CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_enabled='string'); |
||||
ERROR: invalid value for boolean option "autovacuum_enabled": string |
||||
CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_analyze_scale_factor='string'); |
||||
ERROR: invalid value for floating point option "autovacuum_analyze_scale_factor": string |
||||
CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_analyze_scale_factor=true); |
||||
ERROR: invalid value for floating point option "autovacuum_analyze_scale_factor": true |
||||
-- Fail if option is specified twice |
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=30, fillfactor=40); |
||||
ERROR: parameter "fillfactor" specified more than once |
||||
-- Specifying name only for a non-Boolean option should fail |
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor); |
||||
ERROR: invalid value for integer option "fillfactor": true |
||||
-- Simple ALTER TABLE |
||||
ALTER TABLE reloptions_test SET (fillfactor=31, |
||||
autovacuum_analyze_scale_factor = 0.3); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass; |
||||
reloptions |
||||
------------------------------------------------------------------------------ |
||||
{autovacuum_enabled=false,fillfactor=31,autovacuum_analyze_scale_factor=0.3} |
||||
(1 row) |
||||
|
||||
-- Set boolean option to true without specifying value |
||||
ALTER TABLE reloptions_test SET (autovacuum_enabled, fillfactor=32); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass; |
||||
reloptions |
||||
----------------------------------------------------------------------------- |
||||
{autovacuum_analyze_scale_factor=0.3,autovacuum_enabled=true,fillfactor=32} |
||||
(1 row) |
||||
|
||||
-- Check that RESET works well |
||||
ALTER TABLE reloptions_test RESET (fillfactor); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass; |
||||
reloptions |
||||
--------------------------------------------------------------- |
||||
{autovacuum_analyze_scale_factor=0.3,autovacuum_enabled=true} |
||||
(1 row) |
||||
|
||||
-- Resetting all values causes the column to become null |
||||
ALTER TABLE reloptions_test RESET (autovacuum_enabled, |
||||
autovacuum_analyze_scale_factor); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass AND |
||||
reloptions IS NULL; |
||||
reloptions |
||||
------------ |
||||
|
||||
(1 row) |
||||
|
||||
-- RESET fails if a value is specified |
||||
ALTER TABLE reloptions_test RESET (fillfactor=12); |
||||
ERROR: RESET must not include values for parameters |
||||
-- The OIDS option is not stored |
||||
DROP TABLE reloptions_test; |
||||
CREATE TABLE reloptions_test(i INT) WITH (fillfactor=20, oids=true); |
||||
SELECT reloptions, relhasoids FROM pg_class WHERE oid = 'reloptions_test'::regclass; |
||||
reloptions | relhasoids |
||||
-----------------+------------ |
||||
{fillfactor=20} | t |
||||
(1 row) |
||||
|
||||
-- Test toast.* options |
||||
DROP TABLE reloptions_test; |
||||
CREATE TABLE reloptions_test (s VARCHAR) |
||||
WITH (toast.autovacuum_vacuum_cost_delay = 23); |
||||
SELECT reltoastrelid as toast_oid |
||||
FROM pg_class WHERE oid = 'reloptions_test'::regclass \gset |
||||
SELECT reloptions FROM pg_class WHERE oid = :toast_oid; |
||||
reloptions |
||||
----------------------------------- |
||||
{autovacuum_vacuum_cost_delay=23} |
||||
(1 row) |
||||
|
||||
ALTER TABLE reloptions_test SET (toast.autovacuum_vacuum_cost_delay = 24); |
||||
SELECT reloptions FROM pg_class WHERE oid = :toast_oid; |
||||
reloptions |
||||
----------------------------------- |
||||
{autovacuum_vacuum_cost_delay=24} |
||||
(1 row) |
||||
|
||||
ALTER TABLE reloptions_test RESET (toast.autovacuum_vacuum_cost_delay); |
||||
SELECT reloptions FROM pg_class WHERE oid = :toast_oid; |
||||
reloptions |
||||
------------ |
||||
|
||||
(1 row) |
||||
|
||||
-- Fail on non-existent options in toast namespace |
||||
CREATE TABLE reloptions_test2 (i int) WITH (toast.not_existing_option = 42); |
||||
ERROR: unrecognized parameter "not_existing_option" |
||||
-- Mix TOAST & heap |
||||
DROP TABLE reloptions_test; |
||||
CREATE TABLE reloptions_test (s VARCHAR) WITH |
||||
(toast.autovacuum_vacuum_cost_delay = 23, |
||||
autovacuum_vacuum_cost_delay = 24, fillfactor = 40); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass; |
||||
reloptions |
||||
------------------------------------------------- |
||||
{autovacuum_vacuum_cost_delay=24,fillfactor=40} |
||||
(1 row) |
||||
|
||||
SELECT reloptions FROM pg_class WHERE oid = ( |
||||
SELECT reltoastrelid FROM pg_class WHERE oid = 'reloptions_test'::regclass); |
||||
reloptions |
||||
----------------------------------- |
||||
{autovacuum_vacuum_cost_delay=23} |
||||
(1 row) |
||||
|
||||
-- |
||||
-- CREATE INDEX, ALTER INDEX for btrees |
||||
-- |
||||
CREATE INDEX reloptions_test_idx ON reloptions_test (s) WITH (fillfactor=30); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx'::regclass; |
||||
reloptions |
||||
----------------- |
||||
{fillfactor=30} |
||||
(1 row) |
||||
|
||||
-- Fail when option and namespace do not exist |
||||
CREATE INDEX reloptions_test_idx ON reloptions_test (s) |
||||
WITH (not_existing_option=2); |
||||
ERROR: unrecognized parameter "not_existing_option" |
||||
CREATE INDEX reloptions_test_idx ON reloptions_test (s) |
||||
WITH (not_existing_ns.fillfactor=2); |
||||
ERROR: unrecognized parameter namespace "not_existing_ns" |
||||
-- Check allowed ranges |
||||
CREATE INDEX reloptions_test_idx2 ON reloptions_test (s) WITH (fillfactor=1); |
||||
ERROR: value 1 out of bounds for option "fillfactor" |
||||
DETAIL: Valid values are between "10" and "100". |
||||
CREATE INDEX reloptions_test_idx2 ON reloptions_test (s) WITH (fillfactor=130); |
||||
ERROR: value 130 out of bounds for option "fillfactor" |
||||
DETAIL: Valid values are between "10" and "100". |
||||
-- Check ALTER |
||||
ALTER INDEX reloptions_test_idx SET (fillfactor=40); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx'::regclass; |
||||
reloptions |
||||
----------------- |
||||
{fillfactor=40} |
||||
(1 row) |
||||
|
||||
-- Check ALTER on empty reloption list |
||||
CREATE INDEX reloptions_test_idx3 ON reloptions_test (s); |
||||
ALTER INDEX reloptions_test_idx3 SET (fillfactor=40); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx3'::regclass; |
||||
reloptions |
||||
----------------- |
||||
{fillfactor=40} |
||||
(1 row) |
||||
|
@ -0,0 +1,113 @@ |
||||
|
||||
-- Simple create |
||||
CREATE TABLE reloptions_test(i INT) WITH (FiLLFaCToR=30, |
||||
autovacuum_enabled = false, autovacuum_analyze_scale_factor = 0.2); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass; |
||||
|
||||
-- Fail min/max values check |
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=2); |
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=110); |
||||
CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_analyze_scale_factor = -10.0); |
||||
CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_analyze_scale_factor = 110.0); |
||||
|
||||
-- Fail when option and namespace do not exist |
||||
CREATE TABLE reloptions_test2(i INT) WITH (not_existing_option=2); |
||||
CREATE TABLE reloptions_test2(i INT) WITH (not_existing_namespace.fillfactor=2); |
||||
|
||||
-- Fail while setting improper values |
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=30.5); |
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor='string'); |
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=true); |
||||
CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_enabled=12); |
||||
CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_enabled=30.5); |
||||
CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_enabled='string'); |
||||
CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_analyze_scale_factor='string'); |
||||
CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_analyze_scale_factor=true); |
||||
|
||||
-- Fail if option is specified twice |
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=30, fillfactor=40); |
||||
|
||||
-- Specifying name only for a non-Boolean option should fail |
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor); |
||||
|
||||
-- Simple ALTER TABLE |
||||
ALTER TABLE reloptions_test SET (fillfactor=31, |
||||
autovacuum_analyze_scale_factor = 0.3); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass; |
||||
|
||||
-- Set boolean option to true without specifying value |
||||
ALTER TABLE reloptions_test SET (autovacuum_enabled, fillfactor=32); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass; |
||||
|
||||
-- Check that RESET works well |
||||
ALTER TABLE reloptions_test RESET (fillfactor); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass; |
||||
|
||||
-- Resetting all values causes the column to become null |
||||
ALTER TABLE reloptions_test RESET (autovacuum_enabled, |
||||
autovacuum_analyze_scale_factor); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass AND |
||||
reloptions IS NULL; |
||||
|
||||
-- RESET fails if a value is specified |
||||
ALTER TABLE reloptions_test RESET (fillfactor=12); |
||||
|
||||
-- The OIDS option is not stored |
||||
DROP TABLE reloptions_test; |
||||
CREATE TABLE reloptions_test(i INT) WITH (fillfactor=20, oids=true); |
||||
SELECT reloptions, relhasoids FROM pg_class WHERE oid = 'reloptions_test'::regclass; |
||||
|
||||
-- Test toast.* options |
||||
DROP TABLE reloptions_test; |
||||
|
||||
CREATE TABLE reloptions_test (s VARCHAR) |
||||
WITH (toast.autovacuum_vacuum_cost_delay = 23); |
||||
SELECT reltoastrelid as toast_oid |
||||
FROM pg_class WHERE oid = 'reloptions_test'::regclass \gset |
||||
SELECT reloptions FROM pg_class WHERE oid = :toast_oid; |
||||
|
||||
ALTER TABLE reloptions_test SET (toast.autovacuum_vacuum_cost_delay = 24); |
||||
SELECT reloptions FROM pg_class WHERE oid = :toast_oid; |
||||
|
||||
ALTER TABLE reloptions_test RESET (toast.autovacuum_vacuum_cost_delay); |
||||
SELECT reloptions FROM pg_class WHERE oid = :toast_oid; |
||||
|
||||
-- Fail on non-existent options in toast namespace |
||||
CREATE TABLE reloptions_test2 (i int) WITH (toast.not_existing_option = 42); |
||||
|
||||
-- Mix TOAST & heap |
||||
DROP TABLE reloptions_test; |
||||
|
||||
CREATE TABLE reloptions_test (s VARCHAR) WITH |
||||
(toast.autovacuum_vacuum_cost_delay = 23, |
||||
autovacuum_vacuum_cost_delay = 24, fillfactor = 40); |
||||
|
||||
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); |
||||
|
||||
-- |
||||
-- CREATE INDEX, ALTER INDEX for btrees |
||||
-- |
||||
|
||||
CREATE INDEX reloptions_test_idx ON reloptions_test (s) WITH (fillfactor=30); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx'::regclass; |
||||
|
||||
-- Fail when option and namespace do not exist |
||||
CREATE INDEX reloptions_test_idx ON reloptions_test (s) |
||||
WITH (not_existing_option=2); |
||||
CREATE INDEX reloptions_test_idx ON reloptions_test (s) |
||||
WITH (not_existing_ns.fillfactor=2); |
||||
|
||||
-- Check allowed ranges |
||||
CREATE INDEX reloptions_test_idx2 ON reloptions_test (s) WITH (fillfactor=1); |
||||
CREATE INDEX reloptions_test_idx2 ON reloptions_test (s) WITH (fillfactor=130); |
||||
|
||||
-- Check ALTER |
||||
ALTER INDEX reloptions_test_idx SET (fillfactor=40); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx'::regclass; |
||||
|
||||
-- Check ALTER on empty reloption list |
||||
CREATE INDEX reloptions_test_idx3 ON reloptions_test (s); |
||||
ALTER INDEX reloptions_test_idx3 SET (fillfactor=40); |
||||
SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx3'::regclass; |
Loading…
Reference in new issue