File tree Expand file tree Collapse file tree 3 files changed +86
-3
lines changed
Expand file tree Collapse file tree 3 files changed +86
-3
lines changed Original file line number Diff line number Diff line change 1+ -- REQUIRE: src/schema.sql
2+ -- REQUIRE: src/ore_cllw_u64_8/types.sql
3+ -- REQUIRE: src/ore_cllw_u64_8/functions.sql
4+
5+
6+ CREATE FUNCTION eql_v2 .compare_ore_cllw_var_8(a eql_v2_encrypted, b eql_v2_encrypted)
7+ RETURNS integer
8+ IMMUTABLE STRICT PARALLEL SAFE
9+ AS $$
10+ DECLARE
11+ a_term eql_v2 .ore_cllw_var_8 ;
12+ b_term eql_v2 .ore_cllw_var_8 ;
13+ BEGIN
14+
15+ -- PERFORM eql_v2.log('eql_v2.compare_ore_cllw_var_8');
16+ -- PERFORM eql_v2.log('a', a::text);
17+ -- PERFORM eql_v2.log('b', b::text);
18+
19+ IF a IS NULL AND b IS NULL THEN
20+ RETURN 0 ;
21+ END IF;
22+
23+ IF a IS NULL THEN
24+ RETURN - 1 ;
25+ END IF;
26+
27+ IF b IS NULL THEN
28+ RETURN 1 ;
29+ END IF;
30+
31+ IF eql_v2 .has_ore_cllw_var_8 (a) THEN
32+ a_term := eql_v2 .ore_cllw_var_8 (a);
33+ END IF;
34+
35+ IF eql_v2 .has_ore_cllw_var_8 (a) THEN
36+ b_term := eql_v2 .ore_cllw_var_8 (b);
37+ END IF;
38+
39+ IF a_term IS NULL AND b_term IS NULL THEN
40+ RETURN 0 ;
41+ END IF;
42+
43+ IF a_term IS NULL THEN
44+ RETURN - 1 ;
45+ END IF;
46+
47+ IF b_term IS NULL THEN
48+ RETURN 1 ;
49+ END IF;
50+
51+ RETURN eql_v2 .compare_ore_cllw_var_8_term (a_term, b_term);
52+ END;
53+ $$ LANGUAGE plpgsql;
54+
Original file line number Diff line number Diff line change 1+ \set ON_ERROR_STOP on
2+
3+ DO $$
4+ DECLARE
5+ a eql_v2_encrypted;
6+ b eql_v2_encrypted;
7+ c eql_v2_encrypted;
8+ BEGIN
9+
10+ -- {"hello": "world{N}"}
11+ -- $.hello: d90b97b5207d30fe867ca816ed0fe4a7
12+ a := eql_v2 .jsonb_path_query (create_encrypted_ste_vec_json(1 ), ' d90b97b5207d30fe867ca816ed0fe4a7' );
13+ b := eql_v2 .jsonb_path_query (create_encrypted_ste_vec_json(2 ), ' d90b97b5207d30fe867ca816ed0fe4a7' );
14+ c := eql_v2 .jsonb_path_query (create_encrypted_ste_vec_json(3 ), ' d90b97b5207d30fe867ca816ed0fe4a7' );
15+
16+ ASSERT eql_v2 .compare_ore_cllw_var_8 (a, a) = 0 ;
17+ ASSERT eql_v2 .compare_ore_cllw_var_8 (a, b) = - 1 ;
18+ ASSERT eql_v2 .compare_ore_cllw_var_8 (a, c) = - 1 ;
19+
20+ ASSERT eql_v2 .compare_ore_cllw_var_8 (b, b) = 0 ;
21+ ASSERT eql_v2 .compare_ore_cllw_var_8 (b, a) = 1 ;
22+ ASSERT eql_v2 .compare_ore_cllw_var_8 (b, c) = - 1 ;
23+
24+ ASSERT eql_v2 .compare_ore_cllw_var_8 (c, c) = 0 ;
25+ ASSERT eql_v2 .compare_ore_cllw_var_8 (c, b) = 1 ;
26+ ASSERT eql_v2 .compare_ore_cllw_var_8 (c, a) = 1 ;
27+ END;
28+ $$ LANGUAGE plpgsql;
29+
Original file line number Diff line number Diff line change 6262$$ LANGUAGE plpgsql;
6363
6464
65- CREATE FUNCTION eql_v2 .compare_ore_cllw_var_8 (a eql_v2 .ore_cllw_var_8 , b eql_v2 .ore_cllw_var_8 )
65+ CREATE FUNCTION eql_v2 .compare_ore_cllw_var_8_term (a eql_v2 .ore_cllw_var_8 , b eql_v2 .ore_cllw_var_8 )
6666RETURNS int AS $$
6767DECLARE
6868 len_a INT ;
9595 common_len := len_b;
9696 END IF;
9797
98- -- Use the compare_bytea function to compare byte by byte
99- cmp_result := eql_v2 .compare_ore_cllw (
98+ -- Use the compare_ore_cllw_term function to compare byte by byte
99+ cmp_result := eql_v2 .compare_ore_cllw_term_bytes (
100100 SUBSTRING (a .bytes FROM 1 FOR common_len),
101101 SUBSTRING (b .bytes FROM 1 FOR common_len)
102102 );
You can’t perform that action at this time.
0 commit comments