|
| 1 | +-- Simple create |
| 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; |
| 5 | + reloptions |
| 6 | +------------------------------------------------------------------------------ |
| 7 | + {fillfactor=30,autovacuum_enabled=false,autovacuum_analyze_scale_factor=0.2} |
| 8 | +(1 row) |
| 9 | + |
| 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.5); |
| 30 | +ERROR: invalid value for integer option "fillfactor": 30.5 |
| 31 | +CREATE TABLE reloptions_test2(i INT) WITH (fillfactor='string'); |
| 32 | +ERROR: invalid value for integer option "fillfactor": string |
| 33 | +CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=true); |
| 34 | +ERROR: invalid value for integer option "fillfactor": true |
| 35 | +CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_enabled=12); |
| 36 | +ERROR: invalid value for boolean option "autovacuum_enabled": 12 |
| 37 | +CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_enabled=30.5); |
| 38 | +ERROR: invalid value for boolean option "autovacuum_enabled": 30.5 |
| 39 | +CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_enabled='string'); |
| 40 | +ERROR: invalid value for boolean option "autovacuum_enabled": string |
| 41 | +CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_analyze_scale_factor='string'); |
| 42 | +ERROR: invalid value for floating point option "autovacuum_analyze_scale_factor": string |
| 43 | +CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_analyze_scale_factor=true); |
| 44 | +ERROR: invalid value for floating point option "autovacuum_analyze_scale_factor": true |
| 45 | +-- Fail if option is specified twice |
| 46 | +CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=30, fillfactor=40); |
| 47 | +ERROR: parameter "fillfactor" specified more than once |
| 48 | +-- Specifying name only for a non-Boolean option should fail |
| 49 | +CREATE TABLE reloptions_test2(i INT) WITH (fillfactor); |
| 50 | +ERROR: invalid value for integer option "fillfactor": true |
| 51 | +-- Simple ALTER TABLE |
| 52 | +ALTER TABLE reloptions_test SET (fillfactor=31, |
| 53 | + autovacuum_analyze_scale_factor = 0.3); |
| 54 | +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass; |
| 55 | + reloptions |
| 56 | +------------------------------------------------------------------------------ |
| 57 | + {autovacuum_enabled=false,fillfactor=31,autovacuum_analyze_scale_factor=0.3} |
| 58 | +(1 row) |
| 59 | + |
| 60 | +-- Set boolean option to true without specifying value |
| 61 | +ALTER TABLE reloptions_test SET (autovacuum_enabled, fillfactor=32); |
| 62 | +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass; |
| 63 | + reloptions |
| 64 | +----------------------------------------------------------------------------- |
| 65 | + {autovacuum_analyze_scale_factor=0.3,autovacuum_enabled=true,fillfactor=32} |
| 66 | +(1 row) |
| 67 | + |
| 68 | +-- Check that RESET works well |
| 69 | +ALTER TABLE reloptions_test RESET (fillfactor); |
| 70 | +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass; |
| 71 | + reloptions |
| 72 | +--------------------------------------------------------------- |
| 73 | + {autovacuum_analyze_scale_factor=0.3,autovacuum_enabled=true} |
| 74 | +(1 row) |
| 75 | + |
| 76 | +-- Resetting all values causes the column to become null |
| 77 | +ALTER TABLE reloptions_test RESET (autovacuum_enabled, |
| 78 | + autovacuum_analyze_scale_factor); |
| 79 | +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass AND |
| 80 | +reloptions IS NULL; |
| 81 | + reloptions |
| 82 | +------------ |
| 83 | + |
| 84 | +(1 row) |
| 85 | + |
| 86 | +-- RESET fails if a value is specified |
| 87 | +ALTER TABLE reloptions_test RESET (fillfactor=12); |
| 88 | +ERROR: RESET must not include values for parameters |
| 89 | +-- The OIDS option is not stored |
| 90 | +DROP TABLE reloptions_test; |
| 91 | +CREATE TABLE reloptions_test(i INT) WITH (fillfactor=20, oids=true); |
| 92 | +SELECT reloptions, relhasoids FROM pg_class WHERE oid = 'reloptions_test'::regclass; |
| 93 | + reloptions | relhasoids |
| 94 | +-----------------+------------ |
| 95 | + {fillfactor=20} | t |
| 96 | +(1 row) |
| 97 | + |
| 98 | +-- Test toast.* options |
| 99 | +DROP TABLE reloptions_test; |
| 100 | +CREATE TABLE reloptions_test (s VARCHAR) |
| 101 | + WITH (toast.autovacuum_vacuum_cost_delay = 23); |
| 102 | +SELECT reltoastrelid as toast_oid |
| 103 | + FROM pg_class WHERE oid = 'reloptions_test'::regclass \gset |
| 104 | +SELECT reloptions FROM pg_class WHERE oid = :toast_oid; |
| 105 | + reloptions |
| 106 | +----------------------------------- |
| 107 | + {autovacuum_vacuum_cost_delay=23} |
| 108 | +(1 row) |
| 109 | + |
| 110 | +ALTER TABLE reloptions_test SET (toast.autovacuum_vacuum_cost_delay = 24); |
| 111 | +SELECT reloptions FROM pg_class WHERE oid = :toast_oid; |
| 112 | + reloptions |
| 113 | +----------------------------------- |
| 114 | + {autovacuum_vacuum_cost_delay=24} |
| 115 | +(1 row) |
| 116 | + |
| 117 | +ALTER TABLE reloptions_test RESET (toast.autovacuum_vacuum_cost_delay); |
| 118 | +SELECT reloptions FROM pg_class WHERE oid = :toast_oid; |
| 119 | + reloptions |
| 120 | +------------ |
| 121 | + |
| 122 | +(1 row) |
| 123 | + |
| 124 | +-- Fail on non-existent options in toast namespace |
| 125 | +CREATE TABLE reloptions_test2 (i int) WITH (toast.not_existing_option = 42); |
| 126 | +ERROR: unrecognized parameter "not_existing_option" |
| 127 | +-- Mix TOAST & heap |
| 128 | +DROP TABLE reloptions_test; |
| 129 | +CREATE TABLE reloptions_test (s VARCHAR) WITH |
| 130 | + (toast.autovacuum_vacuum_cost_delay = 23, |
| 131 | + autovacuum_vacuum_cost_delay = 24, fillfactor = 40); |
| 132 | +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass; |
| 133 | + reloptions |
| 134 | +------------------------------------------------- |
| 135 | + {autovacuum_vacuum_cost_delay=24,fillfactor=40} |
| 136 | +(1 row) |
| 137 | + |
| 138 | +SELECT reloptions FROM pg_class WHERE oid = ( |
| 139 | + SELECT reltoastrelid FROM pg_class WHERE oid = 'reloptions_test'::regclass); |
| 140 | + reloptions |
| 141 | +----------------------------------- |
| 142 | + {autovacuum_vacuum_cost_delay=23} |
| 143 | +(1 row) |
| 144 | + |
| 145 | +-- |
| 146 | +-- CREATE INDEX, ALTER INDEX for btrees |
| 147 | +-- |
| 148 | +CREATE INDEX reloptions_test_idx ON reloptions_test (s) WITH (fillfactor=30); |
| 149 | +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx'::regclass; |
| 150 | + reloptions |
| 151 | +----------------- |
| 152 | + {fillfactor=30} |
| 153 | +(1 row) |
| 154 | + |
| 155 | +-- Fail when option and namespace do not exist |
| 156 | +CREATE INDEX reloptions_test_idx ON reloptions_test (s) |
| 157 | + WITH (not_existing_option=2); |
| 158 | +ERROR: unrecognized parameter "not_existing_option" |
| 159 | +CREATE INDEX reloptions_test_idx ON reloptions_test (s) |
| 160 | + WITH (not_existing_ns.fillfactor=2); |
| 161 | +ERROR: unrecognized parameter namespace "not_existing_ns" |
| 162 | +-- Check allowed ranges |
| 163 | +CREATE INDEX reloptions_test_idx2 ON reloptions_test (s) WITH (fillfactor=1); |
| 164 | +ERROR: value 1 out of bounds for option "fillfactor" |
| 165 | +DETAIL: Valid values are between "10" and "100". |
| 166 | +CREATE INDEX reloptions_test_idx2 ON reloptions_test (s) WITH (fillfactor=130); |
| 167 | +ERROR: value 130 out of bounds for option "fillfactor" |
| 168 | +DETAIL: Valid values are between "10" and "100". |
| 169 | +-- Check ALTER |
| 170 | +ALTER INDEX reloptions_test_idx SET (fillfactor=40); |
| 171 | +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx'::regclass; |
| 172 | + reloptions |
| 173 | +----------------- |
| 174 | + {fillfactor=40} |
| 175 | +(1 row) |
| 176 | + |
| 177 | +-- Check ALTER on empty reloption list |
| 178 | +CREATE INDEX reloptions_test_idx3 ON reloptions_test (s); |
| 179 | +ALTER INDEX reloptions_test_idx3 SET (fillfactor=40); |
| 180 | +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx3'::regclass; |
| 181 | + reloptions |
| 182 | +----------------- |
| 183 | + {fillfactor=40} |
| 184 | +(1 row) |
| 185 | + |
0 commit comments