You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IF eql_v2.has_ore_block_u64_8_256(a) ANDeql_v2.has_ore_block_u64_8_256(b) THEN
46
+
RETURN eql_v2.compare_ore_block_u64_8_256(a, b);
47
+
END IF;
48
+
49
+
-- Fallback to hmac if BOTH parameters have hmac index
50
+
IF eql_v2.has_hmac_256(a) ANDeql_v2.has_hmac_256(b) THEN
51
+
RETURN eql_v2.compare_hmac(a, b);
52
+
END IF;
53
+
54
+
-- Fallback to ORE if one of the parameters has ore index
55
+
IF eql_v2.has_ore_block_u64_8_256(a) OReql_v2.has_ore_block_u64_8_256(b) THEN
56
+
RETURN eql_v2.compare_ore_block_u64_8_256(a, b);
57
+
END IF;
58
+
59
+
-- Fallback to hmac if ONE of the parameters has hmac index
60
+
IF eql_v2.has_hmac_256(a) OReql_v2.has_hmac_256(b) THEN
61
+
RETURN eql_v2.compare_hmac(a, b);
62
+
END IF;
63
+
64
+
RAISE 'Expected an hmac_256 (hm) or ore_block_u64_8_256 (ob) value in json: %', val;
65
+
END;
66
+
$$ LANGUAGE plpgsql;
67
+
68
+
--------------------
69
+
70
+
CREATEFUNCTIONeql_v2.compare_ore_block_u64_8_256(a eql_v2_encrypted, b eql_v2_encrypted)
71
+
RETURNS integer
72
+
IMMUTABLE STRICT PARALLEL SAFE
16
73
AS $$
17
74
DECLARE
18
75
a_ore eql_v2.ore_block_u64_8_256;
@@ -38,6 +95,51 @@ AS $$
38
95
END;
39
96
$$ LANGUAGE plpgsql;
40
97
98
+
99
+
--------------------
100
+
101
+
CREATEFUNCTIONeql_v2.compare_hmac(a eql_v2_encrypted, b eql_v2_encrypted)
102
+
RETURNS integer
103
+
IMMUTABLE STRICT PARALLEL SAFE
104
+
AS $$
105
+
DECLARE
106
+
a_hmac eql_v2.hmac_256;
107
+
b_hmac eql_v2.hmac_256;
108
+
BEGIN
109
+
110
+
a_hmac =eql_v2.hmac_256(a);
111
+
b_hmac =eql_v2.hmac_256(b);
112
+
113
+
IF a_hmac IS NULLAND b_hmac IS NULL THEN
114
+
RETURN 0;
115
+
END IF;
116
+
117
+
IF a_hmac IS NULL THEN
118
+
RETURN -1;
119
+
END IF;
120
+
121
+
IF b_hmac IS NULL THEN
122
+
RETURN 1;
123
+
END IF;
124
+
125
+
IF a_hmac = b_hmac THEN
126
+
RETURN 0;
127
+
END IF;
128
+
129
+
IF a_hmac < b_hmac THEN
130
+
RETURN -1;
131
+
END IF;
132
+
133
+
IF a_hmac > b_hmac THEN
134
+
RETURN 1;
135
+
END IF;
136
+
137
+
END;
138
+
$$ LANGUAGE plpgsql;
139
+
140
+
141
+
--------------------
142
+
41
143
CREATEOPERATORFAMILYeql_v2.encrypted_operator USING btree;
42
144
43
145
CREATEOPERATOR CLASSeql_v2.encrypted_operator DEFAULT FOR TYPE eql_v2_encrypted USING btree FAMILY eql_v2.encrypted_operatorAS
@@ -48,3 +150,28 @@ CREATE OPERATOR CLASS eql_v2.encrypted_operator DEFAULT FOR TYPE eql_v2_encrypte
48
150
OPERATOR 5>,
49
151
FUNCTION 1eql_v2.compare(a eql_v2_encrypted, b eql_v2_encrypted);
50
152
153
+
154
+
--------------------
155
+
156
+
-- CREATE OPERATOR FAMILY eql_v2.encrypted_operator_ore_block_u64_8_256 USING btree;
157
+
158
+
-- CREATE OPERATOR CLASS eql_v2.encrypted_operator_ore_block_u64_8_256 FOR TYPE eql_v2_encrypted USING btree FAMILY eql_v2.encrypted_operator_ore_block_u64_8_256 AS
159
+
-- OPERATOR 1 <,
160
+
-- OPERATOR 2 <=,
161
+
-- OPERATOR 3 =,
162
+
-- OPERATOR 4 >=,
163
+
-- OPERATOR 5 >,
164
+
-- FUNCTION 1 eql_v2.compare_ore_block_u64_8_256(a eql_v2_encrypted, b eql_v2_encrypted);
165
+
166
+
-- --------------------
167
+
168
+
-- CREATE OPERATOR FAMILY eql_v2.encrypted_hmac_256_operator USING btree;
169
+
170
+
-- CREATE OPERATOR CLASS eql_v2.encrypted_hmac_256_operator FOR TYPE eql_v2_encrypted USING btree FAMILY eql_v2.encrypted_hmac_256_operator AS
171
+
-- OPERATOR 1 <,
172
+
-- OPERATOR 2 <=,
173
+
-- OPERATOR 3 =,
174
+
-- OPERATOR 4 >=,
175
+
-- OPERATOR 5 >,
176
+
-- FUNCTION 1 eql_v2.compare_hmac(a eql_v2_encrypted, b eql_v2_encrypted);
0 commit comments