Skip to content

Commit 7685d26

Browse files
committed
test: index test less brittle
1 parent fb82411 commit 7685d26

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/operators/compare.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ AS $$
8181
RETURN eql_v2.compare_blake3(a, b);
8282
END IF;
8383

84-
8584
-- Fallback to literal comparison of the encrypted data
8685
-- Compare must have consistent ordering for a given state
8786
-- Without this text fallback, database errors with "lock BufferContent is not held"

src/operators/operator_class_test.sql

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ SELECT create_table_with_encrypted();
44
SELECT seed_encrypted_json();
55

66

7-
87
--
98
-- Confirm index used correctly
109
--
@@ -77,50 +76,52 @@ DO $$
7776
-- Add index
7877
CREATE INDEX encrypted_index ON encrypted (e eql_v2.encrypted_operator_class);
7978

80-
EXECUTE 'EXPLAIN ANALYZE SELECT e::jsonb FROM encrypted WHERE e = ''("{\"bf\": \"[1,2,3\"}")'';' into result;
79+
ANALYZE encrypted;
8180

82-
-- PERFORM eql_v2.log('', result);
81+
EXECUTE 'EXPLAIN ANALYZE SELECT e::jsonb FROM encrypted WHERE e = ''("{\"bf\": \"[1,2,3]\"}")'';' into result;
8382

84-
IF position('Bitmap Heap Scan on encrypted' in result) > 0 THEN
85-
RAISE EXCEPTION 'Unexpected Bitmap Heap Scan: %', result;
86-
ELSE
83+
IF position('Seq Scan on encrypted' in result) > 0 THEN
8784
ASSERT true;
85+
ELSE
86+
RAISE EXCEPTION 'Unexpected Seq Scan: %', result;
8887
END IF;
8988

9089
-- NO INDEX WILL BE USED
9190
EXECUTE 'EXPLAIN ANALYZE SELECT e::jsonb FROM encrypted WHERE e = ''("{\"hm\": \"abc\"}")'';' into result;
9291

93-
-- PERFORM eql_v2.log('', result);
94-
95-
IF position('Bitmap Heap Scan on encrypted' in result) > 0 THEN
96-
RAISE EXCEPTION 'Unexpected Bitmap Heap Scan: %', result;
97-
ELSE
92+
IF position('Seq Scan on encrypted' in result) > 0 THEN
9893
ASSERT true;
94+
ELSE
95+
RAISE EXCEPTION 'Unexpected Seq Scan: %', result;
9996
END IF;
10097

10198
INSERT INTO encrypted (e) VALUES ('("{\"hm\": \"abc\"}")');
10299
INSERT INTO encrypted (e) VALUES ('("{\"hm\": \"def\"}")');
103100
INSERT INTO encrypted (e) VALUES ('("{\"hm\": \"ghi\"}")');
104101

102+
ANALYZE encrypted;
103+
105104
-- STILL NO INDEX WILL BE USED
106105
EXECUTE 'EXPLAIN ANALYZE SELECT e::jsonb FROM encrypted WHERE e = ''("{\"hm\": \"abc\"}")'';' into result;
107106

108-
IF position('Bitmap Heap Scan on encrypted' in result) > 0 THEN
109-
RAISE EXCEPTION 'Unexpected Bitmap Heap Scan: %', result;
110-
ELSE
107+
IF position('Seq Scan on encrypted' in result) > 0 THEN
111108
ASSERT true;
109+
ELSE
110+
RAISE EXCEPTION 'Unexpected Seq Scan: %', result;
112111
END IF;
113112

114113
DROP INDEX encrypted_index;
115114
CREATE INDEX encrypted_index ON encrypted (e eql_v2.encrypted_operator_class);
116115

116+
ANALYZE encrypted;
117+
117118
EXECUTE 'EXPLAIN ANALYZE SELECT e::jsonb FROM encrypted WHERE e = ''("{\"hm\": \"abc\"}")'';' into result;
118119

119-
-- AND STILL NOPE
120-
IF position('Bitmap Heap Scan on encrypted' in result) > 0 THEN
121-
RAISE EXCEPTION 'Unexpected Bitmap Heap Scan: %', result;
122-
ELSE
120+
-- -- AND STILL NOPE
121+
IF position('Seq Scan on encrypted' in result) > 0 THEN
123122
ASSERT true;
123+
ELSE
124+
RAISE EXCEPTION 'Unexpected Seq Scan: %', result;
124125
END IF;
125126

126127

0 commit comments

Comments
 (0)