4
4
--
5
5
-- Helper function for assertions
6
6
--
7
- DROP FUNCTION IF EXISTS _index_exists (text , text , text , text );
8
- CREATE FUNCTION _index_exists (table_name text , column_name text , index_name text , state text DEFAULT ' pending' )
7
+ DROP FUNCTION IF EXISTS _search_config_exists (text , text , text , text );
8
+ CREATE FUNCTION _search_config_exists (table_name text , column_name text , index_name text , state text DEFAULT ' pending' )
9
9
RETURNS boolean
10
10
LANGUAGE sql STRICT PARALLEL SAFE
11
11
BEGIN ATOMIC
@@ -25,23 +25,23 @@ DO $$
25
25
BEGIN
26
26
27
27
-- Add indexes
28
- PERFORM eql_v2 .add_index (' users' , ' name' , ' match' );
29
- ASSERT (SELECT _index_exists (' users' , ' name' , ' match' ));
28
+ PERFORM eql_v2 .add_search_config (' users' , ' name' , ' match' );
29
+ ASSERT (SELECT _search_config_exists (' users' , ' name' , ' match' ));
30
30
31
31
-- Add index with cast
32
- PERFORM eql_v2 .add_index (' users' , ' name' , ' unique' , ' int' );
33
- ASSERT (SELECT _index_exists (' users' , ' name' , ' unique' ));
32
+ PERFORM eql_v2 .add_search_config (' users' , ' name' , ' unique' , ' int' );
33
+ ASSERT (SELECT _search_config_exists (' users' , ' name' , ' unique' ));
34
34
35
35
ASSERT (SELECT EXISTS (SELECT id FROM eql_v2_configuration c
36
36
WHERE c .state = ' pending' AND
37
37
c .data # > array['tables', 'users', 'name'] ? 'cast_as'));
38
38
39
39
-- Match index removed
40
- PERFORM eql_v2 .remove_index (' users' , ' name' , ' match' );
41
- ASSERT NOT (SELECT _index_exists (' users' , ' name' , ' match' ));
40
+ PERFORM eql_v2 .remove_search_config (' users' , ' name' , ' match' );
41
+ ASSERT NOT (SELECT _search_config_exists (' users' , ' name' , ' match' ));
42
42
43
43
-- All indexes removed, delete the emtpty pending config
44
- PERFORM eql_v2 .remove_index (' users' , ' name' , ' unique' );
44
+ PERFORM eql_v2 .remove_search_config (' users' , ' name' , ' unique' );
45
45
ASSERT (SELECT NOT EXISTS (SELECT FROM eql_v2_configuration c WHERE c .state = ' pending' ));
46
46
47
47
END;
@@ -60,16 +60,16 @@ DO $$
60
60
BEGIN
61
61
62
62
-- Add indexes
63
- PERFORM eql_v2 .add_index (' users' , ' name' , ' match' );
64
- ASSERT (SELECT _index_exists (' users' , ' name' , ' match' ));
63
+ PERFORM eql_v2 .add_search_config (' users' , ' name' , ' match' );
64
+ ASSERT (SELECT _search_config_exists (' users' , ' name' , ' match' ));
65
65
66
66
ASSERT (SELECT EXISTS (SELECT id FROM eql_v2_configuration c
67
67
WHERE c .state = ' pending' AND
68
68
c .data # > array['tables', 'users', 'name', 'indexes'] ? 'match'));
69
69
70
70
-- Add index with cast
71
- PERFORM eql_v2 .add_index (' blah' , ' vtha' , ' unique' , ' int' );
72
- ASSERT (SELECT _index_exists (' blah' , ' vtha' , ' unique' ));
71
+ PERFORM eql_v2 .add_search_config (' blah' , ' vtha' , ' unique' , ' int' );
72
+ ASSERT (SELECT _search_config_exists (' blah' , ' vtha' , ' unique' ));
73
73
74
74
ASSERT (SELECT EXISTS (SELECT id FROM eql_v2_configuration c
75
75
WHERE c .state = ' pending' AND
@@ -82,12 +82,12 @@ DO $$
82
82
83
83
84
84
-- Match index removed
85
- PERFORM eql_v2 .remove_index (' users' , ' name' , ' match' );
86
- ASSERT NOT (SELECT _index_exists (' users' , ' name' , ' match' ));
85
+ PERFORM eql_v2 .remove_search_config (' users' , ' name' , ' match' );
86
+ ASSERT NOT (SELECT _search_config_exists (' users' , ' name' , ' match' ));
87
87
88
88
-- Match index removed
89
- PERFORM eql_v2 .remove_index (' blah' , ' vtha' , ' unique' );
90
- ASSERT NOT (SELECT _index_exists (' users' , ' vtha' , ' unique' ));
89
+ PERFORM eql_v2 .remove_search_config (' blah' , ' vtha' , ' unique' );
90
+ ASSERT NOT (SELECT _search_config_exists (' users' , ' vtha' , ' unique' ));
91
91
92
92
-- All indexes removed, delete the emtpty pending config
93
93
ASSERT (SELECT NOT EXISTS (SELECT FROM eql_v2_configuration c WHERE c .state = ' pending' ));
@@ -107,12 +107,12 @@ $$ LANGUAGE plpgsql;
107
107
108
108
DO $$
109
109
BEGIN
110
- PERFORM eql_v2 .add_index (' users' , ' name' , ' match' );
111
- ASSERT (SELECT _index_exists (' users' , ' name' , ' match' ));
110
+ PERFORM eql_v2 .add_search_config (' users' , ' name' , ' match' );
111
+ ASSERT (SELECT _search_config_exists (' users' , ' name' , ' match' ));
112
112
113
113
-- Pending configuration contains the path `user/name.match.option`
114
- PERFORM eql_v2 .modify_index (' users' , ' name' , ' match' , ' int' , ' {"option": "value"}' ::jsonb);
115
- ASSERT (SELECT _index_exists (' users' , ' name' , ' match' ));
114
+ PERFORM eql_v2 .modify_search_config (' users' , ' name' , ' match' , ' int' , ' {"option": "value"}' ::jsonb);
115
+ ASSERT (SELECT _search_config_exists (' users' , ' name' , ' match' ));
116
116
117
117
ASSERT (SELECT EXISTS (SELECT id FROM eql_v2_configuration c
118
118
WHERE c .state = ' pending' AND
@@ -123,7 +123,7 @@ DO $$
123
123
c .data # > array['tables', 'users', 'name'] ? 'cast_as'));
124
124
125
125
-- All indexes removed, delete the emtpty pending config
126
- PERFORM eql_v2 .remove_index (' users' , ' name' , ' match' );
126
+ PERFORM eql_v2 .remove_search_config (' users' , ' name' , ' match' );
127
127
ASSERT (SELECT NOT EXISTS (SELECT FROM eql_v2_configuration c WHERE c .state = ' pending' ));
128
128
END;
129
129
$$ LANGUAGE plpgsql;
@@ -160,16 +160,16 @@ INSERT INTO eql_v2_configuration (state, data) VALUES (
160
160
-- An encrypting config should exist
161
161
DO $$
162
162
BEGIN
163
- ASSERT (SELECT _index_exists (' users' , ' blah' , ' match' , ' active' ));
163
+ ASSERT (SELECT _search_config_exists (' users' , ' blah' , ' match' , ' active' ));
164
164
165
- PERFORM eql_v2 .add_index (' users' , ' name' , ' match' );
165
+ PERFORM eql_v2 .add_search_config (' users' , ' name' , ' match' );
166
166
167
167
-- index added to name
168
- ASSERT (SELECT _index_exists (' users' , ' name' , ' match' ));
168
+ ASSERT (SELECT _search_config_exists (' users' , ' name' , ' match' ));
169
169
170
170
-- pending is a copy of the active config
171
171
-- and the active index still exists
172
- ASSERT (SELECT _index_exists (' users' , ' blah' , ' match' ));
172
+ ASSERT (SELECT _search_config_exists (' users' , ' blah' , ' match' ));
173
173
174
174
END;
175
175
$$ LANGUAGE plpgsql;
0 commit comments