aboutsummaryrefslogtreecommitdiff
path: root/src/test/modules/dummy_index_am/expected/reloptions.out
blob: c873a80bb75d721a821a6eaf45a964e257a7490b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
-- Tests for relation options
CREATE EXTENSION dummy_index_am;
CREATE TABLE dummy_test_tab (i int4);
-- Silence validation checks for strings
SET client_min_messages TO 'warning';
-- Test with default values.
CREATE INDEX dummy_test_idx ON dummy_test_tab
  USING dummy_index_am (i);
SELECT unnest(reloptions) FROM pg_class WHERE relname = 'dummy_test_idx';
 unnest 
--------
(0 rows)

DROP INDEX dummy_test_idx;
-- Test with full set of options.
-- Allow validation checks for strings, just for the index creation
SET client_min_messages TO 'notice';
CREATE INDEX dummy_test_idx ON dummy_test_tab
  USING dummy_index_am (i) WITH (
  option_bool = false,
  option_int = 5,
  option_real = 3.1,
  option_enum = 'two',
  option_string_val = NULL,
  option_string_null = 'val');
NOTICE:  new option value for string parameter null
NOTICE:  new option value for string parameter val
-- Silence again validation checks for strings until the end of the test.
SET client_min_messages TO 'warning';
SELECT unnest(reloptions) FROM pg_class WHERE relname = 'dummy_test_idx';
         unnest         
------------------------
 option_bool=false
 option_int=5
 option_real=3.1
 option_enum=two
 option_string_val=null
 option_string_null=val
(6 rows)

-- ALTER INDEX .. SET
ALTER INDEX dummy_test_idx SET (option_int = 10);
ALTER INDEX dummy_test_idx SET (option_bool = true);
ALTER INDEX dummy_test_idx SET (option_real = 3.2);
ALTER INDEX dummy_test_idx SET (option_string_val = 'val2');
ALTER INDEX dummy_test_idx SET (option_string_null = NULL);
ALTER INDEX dummy_test_idx SET (option_enum = 'one');
ALTER INDEX dummy_test_idx SET (option_enum = 'three');
ERROR:  invalid value for enum option "option_enum": three
DETAIL:  Valid values are "one" and "two".
SELECT unnest(reloptions) FROM pg_class WHERE relname = 'dummy_test_idx';
         unnest          
-------------------------
 option_int=10
 option_bool=true
 option_real=3.2
 option_string_val=val2
 option_string_null=null
 option_enum=one
(6 rows)

-- ALTER INDEX .. RESET
ALTER INDEX dummy_test_idx RESET (option_int);
ALTER INDEX dummy_test_idx RESET (option_bool);
ALTER INDEX dummy_test_idx RESET (option_real);
ALTER INDEX dummy_test_idx RESET (option_enum);
ALTER INDEX dummy_test_idx RESET (option_string_val);
ALTER INDEX dummy_test_idx RESET (option_string_null);
SELECT unnest(reloptions) FROM pg_class WHERE relname = 'dummy_test_idx';
 unnest 
--------
(0 rows)

-- Cross-type checks for reloption values
-- Integer
ALTER INDEX dummy_test_idx SET (option_int = 3.3); -- ok
ALTER INDEX dummy_test_idx SET (option_int = true); -- error
ERROR:  invalid value for integer option "option_int": true
ALTER INDEX dummy_test_idx SET (option_int = 'val3'); -- error
ERROR:  invalid value for integer option "option_int": val3
SELECT unnest(reloptions) FROM pg_class WHERE relname = 'dummy_test_idx';
     unnest     
----------------
 option_int=3.3
(1 row)

ALTER INDEX dummy_test_idx RESET (option_int);
-- Boolean
ALTER INDEX dummy_test_idx SET (option_bool = 4); -- error
ERROR:  invalid value for boolean option "option_bool": 4
ALTER INDEX dummy_test_idx SET (option_bool = 1); -- ok, as true
ALTER INDEX dummy_test_idx SET (option_bool = 3.4); -- error
ERROR:  invalid value for boolean option "option_bool": 3.4
ALTER INDEX dummy_test_idx SET (option_bool = 'val4'); -- error
ERROR:  invalid value for boolean option "option_bool": val4
SELECT unnest(reloptions) FROM pg_class WHERE relname = 'dummy_test_idx';
    unnest     
---------------
 option_bool=1
(1 row)

ALTER INDEX dummy_test_idx RESET (option_bool);
-- Float
ALTER INDEX dummy_test_idx SET (option_real = 4); -- ok
ALTER INDEX dummy_test_idx SET (option_real = true); -- error
ERROR:  invalid value for floating point option "option_real": true
ALTER INDEX dummy_test_idx SET (option_real = 'val5'); -- error
ERROR:  invalid value for floating point option "option_real": val5
SELECT unnest(reloptions) FROM pg_class WHERE relname = 'dummy_test_idx';
    unnest     
---------------
 option_real=4
(1 row)

ALTER INDEX dummy_test_idx RESET (option_real);
-- Enum
ALTER INDEX dummy_test_idx SET (option_enum = 'one'); -- ok
ALTER INDEX dummy_test_idx SET (option_enum = 0); -- error
ERROR:  invalid value for enum option "option_enum": 0
DETAIL:  Valid values are "one" and "two".
ALTER INDEX dummy_test_idx SET (option_enum = true); -- error
ERROR:  invalid value for enum option "option_enum": true
DETAIL:  Valid values are "one" and "two".
ALTER INDEX dummy_test_idx SET (option_enum = 'three'); -- error
ERROR:  invalid value for enum option "option_enum": three
DETAIL:  Valid values are "one" and "two".
SELECT unnest(reloptions) FROM pg_class WHERE relname = 'dummy_test_idx';
     unnest      
-----------------
 option_enum=one
(1 row)

ALTER INDEX dummy_test_idx RESET (option_enum);
-- String
ALTER INDEX dummy_test_idx SET (option_string_val = 4); -- ok
ALTER INDEX dummy_test_idx SET (option_string_val = 3.5); -- ok
ALTER INDEX dummy_test_idx SET (option_string_val = true); -- ok, as "true"
SELECT unnest(reloptions) FROM pg_class WHERE relname = 'dummy_test_idx';
         unnest         
------------------------
 option_string_val=true
(1 row)

ALTER INDEX dummy_test_idx RESET (option_string_val);
DROP INDEX dummy_test_idx;