2 CREATE TABLE reloptions_test(i INT) WITH (FiLLFaCToR=30,
3 autovacuum_enabled = false, autovacuum_analyze_scale_factor = 0.2);
4 SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
6 ------------------------------------------------------------------------------
7 {fillfactor=30,autovacuum_enabled=false,autovacuum_analyze_scale_factor=0.2}
10 -- Fail min/max values check
11 CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=2);
12 ERROR: value 2 out of bounds for option "fillfactor"
13 DETAIL: Valid values are between "10" and "100".
14 CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=110);
15 ERROR: value 110 out of bounds for option "fillfactor"
16 DETAIL: Valid values are between "10" and "100".
17 CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_analyze_scale_factor = -10.0);
18 ERROR: value -10.0 out of bounds for option "autovacuum_analyze_scale_factor"
19 DETAIL: Valid values are between "0.000000" and "100.000000".
20 CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_analyze_scale_factor = 110.0);
21 ERROR: value 110.0 out of bounds for option "autovacuum_analyze_scale_factor"
22 DETAIL: Valid values are between "0.000000" and "100.000000".
23 -- Fail when option and namespace do not exist
24 CREATE TABLE reloptions_test2(i INT) WITH (not_existing_option=2);
25 ERROR: unrecognized parameter "not_existing_option"
26 CREATE TABLE reloptions_test2(i INT) WITH (not_existing_namespace.fillfactor=2);
27 ERROR: unrecognized parameter namespace "not_existing_namespace"
28 -- Fail while setting improper values
29 CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=-30.1);
30 ERROR: value -30.1 out of bounds for option "fillfactor"
31 DETAIL: Valid values are between "10" and "100".
32 CREATE TABLE reloptions_test2(i INT) WITH (fillfactor='string');
33 ERROR: invalid value for integer option "fillfactor": string
34 CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=true);
35 ERROR: invalid value for integer option "fillfactor": true
36 CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_enabled=12);
37 ERROR: invalid value for boolean option "autovacuum_enabled": 12
38 CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_enabled=30.5);
39 ERROR: invalid value for boolean option "autovacuum_enabled": 30.5
40 CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_enabled='string');
41 ERROR: invalid value for boolean option "autovacuum_enabled": string
42 CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_analyze_scale_factor='string');
43 ERROR: invalid value for floating point option "autovacuum_analyze_scale_factor": string
44 CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_analyze_scale_factor=true);
45 ERROR: invalid value for floating point option "autovacuum_analyze_scale_factor": true
46 -- Fail if option is specified twice
47 CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=30, fillfactor=40);
48 ERROR: parameter "fillfactor" specified more than once
49 -- Specifying name only for a non-Boolean option should fail
50 CREATE TABLE reloptions_test2(i INT) WITH (fillfactor);
51 ERROR: invalid value for integer option "fillfactor": true
53 ALTER TABLE reloptions_test SET (fillfactor=31,
54 autovacuum_analyze_scale_factor = 0.3);
55 SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
57 ------------------------------------------------------------------------------
58 {autovacuum_enabled=false,fillfactor=31,autovacuum_analyze_scale_factor=0.3}
61 -- Set boolean option to true without specifying value
62 ALTER TABLE reloptions_test SET (autovacuum_enabled, fillfactor=32);
63 SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
65 -----------------------------------------------------------------------------
66 {autovacuum_analyze_scale_factor=0.3,autovacuum_enabled=true,fillfactor=32}
69 -- Check that RESET works well
70 ALTER TABLE reloptions_test RESET (fillfactor);
71 SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
73 ---------------------------------------------------------------
74 {autovacuum_analyze_scale_factor=0.3,autovacuum_enabled=true}
77 -- Resetting all values causes the column to become null
78 ALTER TABLE reloptions_test RESET (autovacuum_enabled,
79 autovacuum_analyze_scale_factor);
80 SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass AND
87 -- RESET fails if a value is specified
88 ALTER TABLE reloptions_test RESET (fillfactor=12);
89 ERROR: RESET must not include values for parameters
90 -- We can RESET an invalid option which for some reason is already set
92 SET reloptions = '{fillfactor=13,autovacuum_enabled=false,illegal_option=4}'
93 WHERE oid = 'reloptions_test'::regclass;
94 ALTER TABLE reloptions_test RESET (illegal_option);
95 SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
97 ------------------------------------------
98 {fillfactor=13,autovacuum_enabled=false}
101 -- Test vacuum_truncate option
102 DROP TABLE reloptions_test;
103 CREATE TEMP TABLE reloptions_test(i INT NOT NULL, j text)
104 WITH (vacuum_truncate=false,
105 toast.vacuum_truncate=false,
106 autovacuum_enabled=false);
107 SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
109 --------------------------------------------------
110 {vacuum_truncate=false,autovacuum_enabled=false}
113 INSERT INTO reloptions_test VALUES (1, NULL), (NULL, NULL);
114 ERROR: null value in column "i" of relation "reloptions_test" violates not-null constraint
115 DETAIL: Failing row contains (null, null).
116 -- Do an aggressive vacuum to prevent page-skipping.
117 VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) reloptions_test;
118 SELECT pg_relation_size('reloptions_test') > 0;
124 SELECT reloptions FROM pg_class WHERE oid =
125 (SELECT reltoastrelid FROM pg_class
126 WHERE oid = 'reloptions_test'::regclass);
128 -------------------------
129 {vacuum_truncate=false}
132 ALTER TABLE reloptions_test RESET (vacuum_truncate);
133 SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
135 ----------------------------
136 {autovacuum_enabled=false}
139 INSERT INTO reloptions_test VALUES (1, NULL), (NULL, NULL);
140 ERROR: null value in column "i" of relation "reloptions_test" violates not-null constraint
141 DETAIL: Failing row contains (null, null).
142 -- Do an aggressive vacuum to prevent page-skipping.
143 VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) reloptions_test;
144 SELECT pg_relation_size('reloptions_test') = 0;
150 -- Test toast.* options
151 DROP TABLE reloptions_test;
152 CREATE TABLE reloptions_test (s VARCHAR)
153 WITH (toast.autovacuum_vacuum_cost_delay = 23);
154 SELECT reltoastrelid as toast_oid
155 FROM pg_class WHERE oid = 'reloptions_test'::regclass \gset
156 SELECT reloptions FROM pg_class WHERE oid = :toast_oid;
158 -----------------------------------
159 {autovacuum_vacuum_cost_delay=23}
162 ALTER TABLE reloptions_test SET (toast.autovacuum_vacuum_cost_delay = 24);
163 SELECT reloptions FROM pg_class WHERE oid = :toast_oid;
165 -----------------------------------
166 {autovacuum_vacuum_cost_delay=24}
169 ALTER TABLE reloptions_test RESET (toast.autovacuum_vacuum_cost_delay);
170 SELECT reloptions FROM pg_class WHERE oid = :toast_oid;
176 -- Fail on non-existent options in toast namespace
177 CREATE TABLE reloptions_test2 (i int) WITH (toast.not_existing_option = 42);
178 ERROR: unrecognized parameter "not_existing_option"
180 DROP TABLE reloptions_test;
181 CREATE TABLE reloptions_test (s VARCHAR) WITH
182 (toast.autovacuum_vacuum_cost_delay = 23,
183 autovacuum_vacuum_cost_delay = 24, fillfactor = 40);
184 SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
186 -------------------------------------------------
187 {autovacuum_vacuum_cost_delay=24,fillfactor=40}
190 SELECT reloptions FROM pg_class WHERE oid = (
191 SELECT reltoastrelid FROM pg_class WHERE oid = 'reloptions_test'::regclass);
193 -----------------------------------
194 {autovacuum_vacuum_cost_delay=23}
198 -- CREATE INDEX, ALTER INDEX for btrees
200 CREATE INDEX reloptions_test_idx ON reloptions_test (s) WITH (fillfactor=30);
201 SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx'::regclass;
207 -- Fail when option and namespace do not exist
208 CREATE INDEX reloptions_test_idx ON reloptions_test (s)
209 WITH (not_existing_option=2);
210 ERROR: unrecognized parameter "not_existing_option"
211 CREATE INDEX reloptions_test_idx ON reloptions_test (s)
212 WITH (not_existing_ns.fillfactor=2);
213 ERROR: unrecognized parameter namespace "not_existing_ns"
214 -- Check allowed ranges
215 CREATE INDEX reloptions_test_idx2 ON reloptions_test (s) WITH (fillfactor=1);
216 ERROR: value 1 out of bounds for option "fillfactor"
217 DETAIL: Valid values are between "10" and "100".
218 CREATE INDEX reloptions_test_idx2 ON reloptions_test (s) WITH (fillfactor=130);
219 ERROR: value 130 out of bounds for option "fillfactor"
220 DETAIL: Valid values are between "10" and "100".
222 ALTER INDEX reloptions_test_idx SET (fillfactor=40);
223 SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx'::regclass;
229 -- Check ALTER on empty reloption list
230 CREATE INDEX reloptions_test_idx3 ON reloptions_test (s);
231 ALTER INDEX reloptions_test_idx3 SET (fillfactor=40);
232 SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx3'::regclass;