File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ -- REQUIRE: src/schema.sql
2+ -- REQUIRE: src/encrypted/types.sql
3+
4+ --
5+ -- Compare two eql_v2_encrypted values as literal jsonb values
6+ -- Used as a fallback when no suitable search term is available
7+ --
8+ CREATE FUNCTION eql_v2 .compare_literal(a eql_v2_encrypted, b eql_v2_encrypted)
9+ RETURNS integer
10+ IMMUTABLE STRICT PARALLEL SAFE
11+ AS $$
12+ DECLARE
13+ a_data jsonb;
14+ b_data jsonb;
15+ BEGIN
16+
17+ IF a IS NULL AND b IS NULL THEN
18+ RETURN 0 ;
19+ END IF;
20+
21+ IF a IS NULL THEN
22+ RETURN - 1 ;
23+ END IF;
24+
25+ IF b IS NULL THEN
26+ RETURN 1 ;
27+ END IF;
28+
29+ a_data := a .data ;
30+ b_data := b .data ;
31+
32+ IF a_data < b_data THEN
33+ RETURN - 1 ;
34+ END IF;
35+
36+ IF a_data > b_data THEN
37+ RETURN 1 ;
38+ END IF;
39+
40+ RETURN 0 ;
41+ END;
42+ $$ LANGUAGE plpgsql;
You can’t perform that action at this time.
0 commit comments