@@ -152,9 +152,59 @@ DO $$
152152 INSERT INTO encrypted (e) VALUES (' ("{\" hm\" : \" abc\" }")' );
153153 INSERT INTO encrypted (e) VALUES (' ("{\" hm\" : \" def\" }")' );
154154 INSERT INTO encrypted (e) VALUES (' ("{\" hm\" : \" ghi\" }")' );
155+ INSERT INTO encrypted (e) VALUES (' ("{\" hm\" : \" jkl\" }")' );
156+ INSERT INTO encrypted (e) VALUES (' ("{\" hm\" : \" mno\" }")' );
155157
158+ -- Literal row type type thing
156159 EXECUTE ' EXPLAIN ANALYZE SELECT e::jsonb FROM encrypted WHERE e = ' ' ("{\" hm\" : \" abc\" }")' ' ;' into result;
157160
161+ IF position(' Index Only Scan using encrypted' in result) > 0 THEN
162+ ASSERT true;
163+ ELSE
164+ RAISE EXCEPTION ' Expected Index Only Scan: %' , result;
165+ END IF;
166+
167+ -- Cast to jsonb
168+ EXECUTE ' EXPLAIN ANALYZE SELECT e::jsonb FROM encrypted WHERE e = ' ' {"hm": "abc"}' ' ::jsonb;' into result;
169+
170+ -- INDEX IS NOT USED
171+ IF position(' Seq Scan on encrypted' in result) > 0 THEN
172+ ASSERT true;
173+ ELSE
174+ RAISE EXCEPTION ' Unexpected Seq Scan: %' , result;
175+ END IF;
176+
177+ -- Cast to jsonb to eql_v2_encrypted
178+ EXECUTE ' EXPLAIN ANALYZE SELECT e::jsonb FROM encrypted WHERE e = ' ' {"hm": "abc"}' ' ::jsonb::eql_v2_encrypted;' into result;
179+
180+ IF position(' Index Only Scan using encrypted' in result) > 0 THEN
181+ ASSERT true;
182+ ELSE
183+ RAISE EXCEPTION ' Expected Index Only Scan: %' , result;
184+ END IF;
185+
186+ -- Cast to text to eql_v2_encrypted
187+ EXECUTE ' EXPLAIN ANALYZE SELECT e::jsonb FROM encrypted WHERE e = ' ' {"hm": "abc"}' ' ::text::eql_v2_encrypted;' into result;
188+
189+ IF position(' Index Only Scan using encrypted' in result) > 0 THEN
190+ ASSERT true;
191+ ELSE
192+ RAISE EXCEPTION ' Expected Index Only Scan: %' , result;
193+ END IF;
194+
195+ -- Use to_encrypted with jsonb
196+ EXECUTE ' EXPLAIN ANALYZE SELECT e::jsonb FROM encrypted WHERE e = eql_v2.to_encrypted(' ' {"hm": "abc"}' ' ::jsonb);' into result;
197+
198+ IF position(' Index Only Scan using encrypted' in result) > 0 THEN
199+ ASSERT true;
200+ ELSE
201+ RAISE EXCEPTION ' Expected Index Only Scan: %' , result;
202+ END IF;
203+
204+ -- Use to_encrypted with text
205+ EXECUTE ' EXPLAIN ANALYZE SELECT e::jsonb FROM encrypted WHERE e = eql_v2.to_encrypted(' ' {"hm": "abc"}' ' );' into result;
206+
207+
158208 IF position(' Index Only Scan using encrypted' in result) > 0 THEN
159209 ASSERT true;
160210 ELSE
0 commit comments