|
20 | 20 | 'postgres', q(
|
21 | 21 | CREATE EXTENSION amcheck;
|
22 | 22 |
|
23 |
| - CREATE SCHEMA test_amcheck; |
24 |
| - SET search_path = test_amcheck; |
25 |
| -
|
26 | 23 | CREATE FUNCTION ok_cmp (int4, int4)
|
27 |
| - RETURNS int LANGUAGE sql SET search_path = test_amcheck AS |
| 24 | + RETURNS int LANGUAGE sql AS |
28 | 25 | $$
|
29 | 26 | SELECT
|
30 | 27 | CASE WHEN $1 < $2 THEN -1
|
|
37 | 34 | --- Check 1: uniqueness violation.
|
38 | 35 | ---
|
39 | 36 | CREATE FUNCTION ok_cmp1 (int4, int4)
|
40 |
| - RETURNS int LANGUAGE sql SET search_path = test_amcheck AS |
| 37 | + RETURNS int LANGUAGE sql AS |
41 | 38 | $$
|
42 |
| - SELECT ok_cmp($1, $2); |
| 39 | + SELECT public.ok_cmp($1, $2); |
43 | 40 | $$;
|
44 | 41 |
|
45 | 42 | ---
|
46 | 43 | --- Make values 768 and 769 look equal.
|
47 | 44 | ---
|
48 | 45 | CREATE FUNCTION bad_cmp1 (int4, int4)
|
49 |
| - RETURNS int LANGUAGE sql SET search_path = test_amcheck AS |
| 46 | + RETURNS int LANGUAGE sql AS |
50 | 47 | $$
|
51 | 48 | SELECT
|
52 | 49 | CASE WHEN ($1 = 768 AND $2 = 769) OR
|
53 | 50 | ($1 = 769 AND $2 = 768) THEN 0
|
54 |
| - ELSE ok_cmp($1, $2) |
| 51 | + ELSE public.ok_cmp($1, $2) |
55 | 52 | END;
|
56 | 53 | $$;
|
57 | 54 |
|
58 | 55 | ---
|
59 | 56 | --- Check 2: uniqueness violation without deduplication.
|
60 | 57 | ---
|
61 | 58 | CREATE FUNCTION ok_cmp2 (int4, int4)
|
62 |
| - RETURNS int LANGUAGE sql SET search_path = test_amcheck AS |
| 59 | + RETURNS int LANGUAGE sql AS |
63 | 60 | $$
|
64 |
| - SELECT ok_cmp($1, $2); |
| 61 | + SELECT public.ok_cmp($1, $2); |
65 | 62 | $$;
|
66 | 63 |
|
67 | 64 | CREATE FUNCTION bad_cmp2 (int4, int4)
|
68 |
| - RETURNS int LANGUAGE sql SET search_path = test_amcheck AS |
| 65 | + RETURNS int LANGUAGE sql AS |
69 | 66 | $$
|
70 | 67 | SELECT
|
71 | 68 | CASE WHEN $1 = $2 AND $1 = 400 THEN -1
|
72 |
| - ELSE ok_cmp($1, $2) |
| 69 | + ELSE public.ok_cmp($1, $2) |
73 | 70 | END;
|
74 | 71 | $$;
|
75 | 72 |
|
76 | 73 | ---
|
77 | 74 | --- Check 3: uniqueness violation with deduplication.
|
78 | 75 | ---
|
79 | 76 | CREATE FUNCTION ok_cmp3 (int4, int4)
|
80 |
| - RETURNS int LANGUAGE sql SET search_path = test_amcheck AS |
| 77 | + RETURNS int LANGUAGE sql AS |
81 | 78 | $$
|
82 |
| - SELECT ok_cmp($1, $2); |
| 79 | + SELECT public.ok_cmp($1, $2); |
83 | 80 | $$;
|
84 | 81 |
|
85 | 82 | CREATE FUNCTION bad_cmp3 (int4, int4)
|
86 |
| - RETURNS int LANGUAGE sql SET search_path = test_amcheck AS |
| 83 | + RETURNS int LANGUAGE sql AS |
87 | 84 | $$
|
88 |
| - SELECT bad_cmp2($1, $2); |
| 85 | + SELECT public.bad_cmp2($1, $2); |
89 | 86 | $$;
|
90 | 87 |
|
91 | 88 | ---
|
|
145 | 142 | # We have not yet broken the index, so we should get no corruption
|
146 | 143 | $result = $node->safe_psql(
|
147 | 144 | 'postgres', q(
|
148 |
| - SELECT bt_index_check('test_amcheck.bttest_unique_idx1', true, true); |
| 145 | + SELECT bt_index_check('bttest_unique_idx1', true, true); |
149 | 146 | ));
|
150 | 147 | is($result, '', 'run amcheck on non-broken bttest_unique_idx1');
|
151 | 148 |
|
152 | 149 | # Change the operator class to use a function which considers certain different
|
153 | 150 | # values to be equal.
|
154 | 151 | $node->safe_psql(
|
155 | 152 | 'postgres', q(
|
156 |
| - SET search_path = test_amcheck; |
157 | 153 | UPDATE pg_catalog.pg_amproc SET
|
158 | 154 | amproc = 'bad_cmp1'::regproc
|
159 | 155 | WHERE amproc = 'ok_cmp1'::regproc;
|
160 | 156 | ));
|
161 | 157 |
|
162 | 158 | ($result, $stdout, $stderr) = $node->psql(
|
163 | 159 | 'postgres', q(
|
164 |
| - SELECT bt_index_check('test_amcheck.bttest_unique_idx1', true, true); |
| 160 | + SELECT bt_index_check('bttest_unique_idx1', true, true); |
165 | 161 | ));
|
166 | 162 | ok( $stderr =~ /index uniqueness is violated for index "bttest_unique_idx1"/,
|
167 | 163 | 'detected uniqueness violation for index "bttest_unique_idx1"');
|
|
179 | 175 | # but no uniqueness violation.
|
180 | 176 | ($result, $stdout, $stderr) = $node->psql(
|
181 | 177 | 'postgres', q(
|
182 |
| - SELECT bt_index_check('test_amcheck.bttest_unique_idx2', true, true); |
| 178 | + SELECT bt_index_check('bttest_unique_idx2', true, true); |
183 | 179 | ));
|
184 | 180 | ok( $stderr =~ /item order invariant violated for index "bttest_unique_idx2"/,
|
185 | 181 | 'detected item order invariant violation for index "bttest_unique_idx2"');
|
186 | 182 |
|
187 | 183 | $node->safe_psql(
|
188 | 184 | 'postgres', q(
|
189 |
| - SET search_path = test_amcheck; |
190 | 185 | UPDATE pg_catalog.pg_amproc SET
|
191 | 186 | amproc = 'ok_cmp2'::regproc
|
192 | 187 | WHERE amproc = 'bad_cmp2'::regproc;
|
193 | 188 | ));
|
194 | 189 |
|
195 | 190 | ($result, $stdout, $stderr) = $node->psql(
|
196 | 191 | 'postgres', q(
|
197 |
| - SELECT bt_index_check('test_amcheck.bttest_unique_idx2', true, true); |
| 192 | + SELECT bt_index_check('bttest_unique_idx2', true, true); |
198 | 193 | ));
|
199 | 194 | ok( $stderr =~ /index uniqueness is violated for index "bttest_unique_idx2"/,
|
200 | 195 | 'detected uniqueness violation for index "bttest_unique_idx2"');
|
|
211 | 206 | # but no uniqueness violation.
|
212 | 207 | ($result, $stdout, $stderr) = $node->psql(
|
213 | 208 | 'postgres', q(
|
214 |
| - SELECT bt_index_check('test_amcheck.bttest_unique_idx3', true, true); |
| 209 | + SELECT bt_index_check('bttest_unique_idx3', true, true); |
215 | 210 | ));
|
216 | 211 | ok( $stderr =~ /item order invariant violated for index "bttest_unique_idx3"/,
|
217 | 212 | 'detected item order invariant violation for index "bttest_unique_idx3"');
|
|
220 | 215 | # with different visibility.
|
221 | 216 | $node->safe_psql(
|
222 | 217 | 'postgres', q(
|
223 |
| - SET search_path = test_amcheck; |
224 | 218 | DELETE FROM bttest_unique3 WHERE 380 <= i AND i <= 420;
|
225 | 219 | INSERT INTO bttest_unique3 (SELECT * FROM generate_series(380, 420));
|
226 | 220 | INSERT INTO bttest_unique3 VALUES (400);
|
|
234 | 228 |
|
235 | 229 | $node->safe_psql(
|
236 | 230 | 'postgres', q(
|
237 |
| - SET search_path = test_amcheck; |
238 | 231 | UPDATE pg_catalog.pg_amproc SET
|
239 | 232 | amproc = 'ok_cmp3'::regproc
|
240 | 233 | WHERE amproc = 'bad_cmp3'::regproc;
|
241 | 234 | ));
|
242 | 235 |
|
243 | 236 | ($result, $stdout, $stderr) = $node->psql(
|
244 | 237 | 'postgres', q(
|
245 |
| - SELECT bt_index_check('test_amcheck.bttest_unique_idx3', true, true); |
| 238 | + SELECT bt_index_check('bttest_unique_idx3', true, true); |
246 | 239 | ));
|
247 | 240 | ok( $stderr =~ /index uniqueness is violated for index "bttest_unique_idx3"/,
|
248 | 241 | 'detected uniqueness violation for index "bttest_unique_idx3"');
|
|
0 commit comments