|
| 1 | +SELECT EXISTS(SELECT 1 FROM pg_available_extensions WHERE name = 're2') AS have_re2 \gset |
| 2 | +\if :have_re2 |
1 | 3 | CREATE SERVER re2_svr FOREIGN DATA WRAPPER clickhouse_fdw OPTIONS(dbname 're2_test'); |
2 | 4 | CREATE USER MAPPING FOR CURRENT_USER SERVER re2_svr; |
3 | 5 | SELECT clickhouse_raw_query('DROP DATABASE IF EXISTS re2_test'); |
4 | | - clickhouse_raw_query |
5 | | ----------------------- |
6 | | - |
7 | | -(1 row) |
8 | | - |
9 | 6 | SELECT clickhouse_raw_query('CREATE DATABASE re2_test'); |
10 | | - clickhouse_raw_query |
11 | | ----------------------- |
12 | | - |
13 | | -(1 row) |
14 | | - |
15 | 7 | SELECT clickhouse_raw_query($$ |
16 | 8 | CREATE TABLE re2_test.t1 ( |
17 | 9 | id Int32, |
18 | 10 | val String |
19 | 11 | ) ENGINE = MergeTree ORDER BY id |
20 | 12 | $$); |
21 | | - clickhouse_raw_query |
22 | | ----------------------- |
23 | | - |
24 | | -(1 row) |
25 | | - |
26 | 13 | SELECT clickhouse_raw_query($$ |
27 | 14 | INSERT INTO re2_test.t1 VALUES |
28 | 15 | (1, 'POSIX uses BRE and ERE'), |
29 | 16 | (2, 're2 uses finite automata'), |
30 | 17 | (3, 'PCRE supports backtracking') |
31 | 18 | $$); |
32 | | - clickhouse_raw_query |
33 | | ----------------------- |
34 | | - |
35 | | -(1 row) |
36 | | - |
37 | 19 | CREATE SCHEMA re2_test; |
38 | 20 | IMPORT FOREIGN SCHEMA re2_test FROM SERVER re2_svr INTO re2_test; |
39 | 21 | SET search_path = re2_test, public; |
40 | 22 | CREATE EXTENSION re2; |
41 | | -ERROR: extension "re2" is not available |
42 | | -HINT: The extension must first be installed on the system where PostgreSQL is running. |
43 | 23 | EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2match(val, 're2'); |
44 | | -ERROR: function re2match(text, unknown) does not exist |
45 | | -LINE 1: ...PLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2match(v... |
46 | | - ^ |
47 | | -HINT: No function matches the given name and argument types. You might need to add explicit type casts. |
48 | 24 | EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2extract(val, '(re2)') = 're2'; |
49 | | -ERROR: function re2extract(text, unknown) does not exist |
50 | | -LINE 1: ...PLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2extract... |
51 | | - ^ |
52 | | -HINT: No function matches the given name and argument types. You might need to add explicit type casts. |
53 | 25 | EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2extractall(val, '[A-Z]+') = ARRAY['POSIX','BRE','ERE']; |
54 | | -ERROR: function re2extractall(text, unknown) does not exist |
55 | | -LINE 1: ...PLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2extract... |
56 | | - ^ |
57 | | -HINT: No function matches the given name and argument types. You might need to add explicit type casts. |
58 | 26 | EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2regexpextract(val, '(re2)', 1) = 're2'; |
59 | | -ERROR: function re2regexpextract(text, unknown, integer) does not exist |
60 | | -LINE 1: ...PLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2regexpe... |
61 | | - ^ |
62 | | -HINT: No function matches the given name and argument types. You might need to add explicit type casts. |
63 | 27 | EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2extractgroups(val, '(POSIX) uses (BRE)') = ARRAY['POSIX','BRE']; |
64 | | -ERROR: function re2extractgroups(text, unknown) does not exist |
65 | | -LINE 1: ...PLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2extract... |
66 | | - ^ |
67 | | -HINT: No function matches the given name and argument types. You might need to add explicit type casts. |
68 | 28 | EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2replaceregexpone(val, 'POSIX', 're2') = 're2 uses BRE and ERE'; |
69 | | -ERROR: function re2replaceregexpone(text, unknown, unknown) does not exist |
70 | | -LINE 1: ...PLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2replace... |
71 | | - ^ |
72 | | -HINT: No function matches the given name and argument types. You might need to add explicit type casts. |
73 | 29 | EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2replaceregexpall(val, ' ', '-') = 're2-uses-finite-automata'; |
74 | | -ERROR: function re2replaceregexpall(text, unknown, unknown) does not exist |
75 | | -LINE 1: ...PLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2replace... |
76 | | - ^ |
77 | | -HINT: No function matches the given name and argument types. You might need to add explicit type casts. |
78 | 30 | EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2countmatches(val, 'e') > 0; |
79 | | -ERROR: function re2countmatches(text, unknown) does not exist |
80 | | -LINE 1: ...PLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2countma... |
81 | | - ^ |
82 | | -HINT: No function matches the given name and argument types. You might need to add explicit type casts. |
83 | 31 | EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2countmatchescaseinsensitive(val, 'E') > 0; |
84 | | -ERROR: function re2countmatchescaseinsensitive(text, unknown) does not exist |
85 | | -LINE 1: ...PLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2countma... |
86 | | - ^ |
87 | | -HINT: No function matches the given name and argument types. You might need to add explicit type casts. |
88 | 32 | EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2multimatchany(val, ARRAY['POSIX','PCRE']); |
89 | | -ERROR: function re2multimatchany(text, text[]) does not exist |
90 | | -LINE 1: ...PLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2multima... |
91 | | - ^ |
92 | | -HINT: No function matches the given name and argument types. You might need to add explicit type casts. |
93 | 33 | EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2multimatchanyindex(val, ARRAY['POSIX','PCRE']) > 0; |
94 | | -ERROR: function re2multimatchanyindex(text, text[]) does not exist |
95 | | -LINE 1: ...PLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2multima... |
96 | | - ^ |
97 | | -HINT: No function matches the given name and argument types. You might need to add explicit type casts. |
98 | 34 | EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2multimatchallindices(val, ARRAY['POSIX','PCRE']) = ARRAY[1]; |
99 | | -ERROR: function re2multimatchallindices(text, text[]) does not exist |
100 | | -LINE 1: ...PLAIN (VERBOSE, COSTS OFF) SELECT * FROM t1 WHERE re2multima... |
101 | | - ^ |
102 | | -HINT: No function matches the given name and argument types. You might need to add explicit type casts. |
103 | 35 | DROP EXTENSION re2; |
104 | | -ERROR: extension "re2" does not exist |
105 | 36 | DROP USER MAPPING FOR CURRENT_USER SERVER re2_svr; |
106 | 37 | SELECT clickhouse_raw_query('DROP DATABASE re2_test'); |
107 | | - clickhouse_raw_query |
108 | | ----------------------- |
109 | | - |
110 | | -(1 row) |
111 | | - |
112 | 38 | DROP SERVER re2_svr CASCADE; |
113 | | -NOTICE: drop cascades to foreign table t1 |
| 39 | +\else |
| 40 | +\echo 'SKIP: re2 extension not available' |
| 41 | +SKIP: re2 extension not available |
| 42 | +\endif |
0 commit comments