Skip to content

Commit 6e908a4

Browse files
committed
feat: EQL for supabase removing operator class and family
1 parent ad11d23 commit 6e908a4

File tree

11 files changed

+69
-65
lines changed

11 files changed

+69
-65
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
deps.txt
77
deps-ordered.txt
88

9+
deps-supabase.txt
10+
deps-supabase-ordered.txt
11+
912
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
1013

1114
src/version.sql

src/common.sql

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
-- AUTOMATICALLY GENERATED FILE
22
-- REQUIRE: src/schema.sql
33

4-
54
-- Constant time comparison of 2 bytea values
65

76

8-
9-
10-
11-
12-
-- DROP FUNCTION IF EXISTS eql_v1.bytea_eq(a bytea, b bytea);
13-
147
CREATE FUNCTION eql_v1.bytea_eq(a bytea, b bytea) RETURNS boolean AS $$
158
DECLARE
169
result boolean;
@@ -34,9 +27,6 @@ BEGIN
3427
END;
3528
$$ LANGUAGE plpgsql;
3629

37-
38-
-- DROP FUNCTION IF EXISTS eql_v1.jsonb_array_to_bytea_array(val jsonb);
39-
4030
-- Casts a jsonb array of hex-encoded strings to an array of bytea.
4131
CREATE FUNCTION eql_v1.jsonb_array_to_bytea_array(val jsonb)
4232
RETURNS bytea[] AS $$
@@ -60,7 +50,6 @@ $$ LANGUAGE plpgsql;
6050
--
6151
-- Convenience function to log a message
6252
--
63-
-- DROP FUNCTION IF EXISTS eql_v1.log(text);
6453
CREATE FUNCTION eql_v1.log(s text)
6554
RETURNS void
6655
AS $$
@@ -73,7 +62,6 @@ $$ LANGUAGE plpgsql;
7362
--
7463
-- Convenience function to describe a test
7564
--
76-
-- DROP FUNCTION IF EXISTS eql_v1.log(text, text);
7765
CREATE FUNCTION eql_v1.log(ctx text, s text)
7866
RETURNS void
7967
AS $$

src/jsonb/functions.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ AS $$
5555
IF found IS NOT NULL THEN
5656

5757
IF ary THEN
58-
59-
-- Wrapp found array elements as eql_v1_encrypted
58+
-- Wrap found array elements as eql_v1_encrypted
6059
RETURN NEXT jsonb_build_object(
6160
'sv', found,
6261
'a', 1

src/operators/class.sql renamed to src/operators/operator_class.sql

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@
1010
-- REQUIRE: src/operators/>.sql
1111

1212

13-
-- DROP ORERATOR CLASS & FAMILY BEFORE FUNCTION
14-
-- DROP OPERATOR CLASS IF EXISTS eql_v1.encrypted_operator USING btree;
15-
-- DROP OPERATOR FAMILY IF EXISTS eql_v1.encrypted_operator USING btree;
16-
17-
-- DROP FUNCTION IF EXISTS eql_v1.compare(a eql_v1_encrypted, b eql_v1_encrypted);
18-
19-
--
20-
-- Comparison function for eql_v1_encrypted
21-
-- Extracts ORE indexes and uses the appropriate ore compare function
22-
--
2313
CREATE FUNCTION eql_v1.compare(a eql_v1_encrypted, b eql_v1_encrypted)
2414
RETURNS integer
2515
IMMUTABLE STRICT PARALLEL SAFE
@@ -36,7 +26,6 @@ AS $$
3626
END;
3727
$$ LANGUAGE plpgsql;
3828

39-
4029
CREATE OPERATOR FAMILY eql_v1.encrypted_operator USING btree;
4130

4231
CREATE OPERATOR CLASS eql_v1.encrypted_operator DEFAULT FOR TYPE eql_v1_encrypted USING btree FAMILY eql_v1.encrypted_operator AS
File renamed without changes.

src/ore/operator_class.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- REQUIRE: src/schema.sql
2+
-- REQUIRE: src/ore/types.sql
3+
4+
5+
CREATE OPERATOR FAMILY eql_v1.ore_64_8_v1_btree_ops USING btree;
6+
7+
CREATE OPERATOR CLASS eql_v1.ore_64_8_v1_btree_ops DEFAULT FOR TYPE eql_v1.ore_64_8_v1 USING btree FAMILY eql_v1.ore_64_8_v1_btree_ops AS
8+
OPERATOR 1 <,
9+
OPERATOR 2 <=,
10+
OPERATOR 3 =,
11+
OPERATOR 4 >=,
12+
OPERATOR 5 >,
13+
FUNCTION 1 eql_v1.compare_ore_64_8_v1(a eql_v1.ore_64_8_v1, b eql_v1.ore_64_8_v1);

src/ore/operators.sql

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,3 @@ CREATE OPERATOR >= (
129129
RESTRICT = scalarlesel,
130130
JOIN = scalarlejoinsel
131131
);
132-
133-
134-
-- DROP OPERATOR FAMILY IF EXISTS eql_v1.ore_64_8_v1_btree_ops USING btree;
135-
136-
CREATE OPERATOR FAMILY eql_v1.ore_64_8_v1_btree_ops USING btree;
137-
138-
139-
-- DROP OPERATOR CLASS IF EXISTS eql_v1.ore_64_8_v1_btree_ops USING btree;
140-
141-
CREATE OPERATOR CLASS eql_v1.ore_64_8_v1_btree_ops DEFAULT FOR TYPE eql_v1.ore_64_8_v1 USING btree FAMILY eql_v1.ore_64_8_v1_btree_ops AS
142-
OPERATOR 1 <,
143-
OPERATOR 2 <=,
144-
OPERATOR 3 =,
145-
OPERATOR 4 >=,
146-
OPERATOR 5 >,
147-
FUNCTION 1 eql_v1.compare_ore_64_8_v1(a eql_v1.ore_64_8_v1, b eql_v1.ore_64_8_v1);
File renamed without changes.
File renamed without changes.

tasks/build.sh

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ mkdir -p release
1414
rm -f release/cipherstash-encrypt-uninstall.sql
1515
rm -f release/cipherstash-encrypt.sql
1616

17+
rm -f release/cipherstash-encrypt-uninstall-supabase.sql
18+
rm -f release/cipherstash-encrypt-supabase.sql
19+
1720
rm -f src/version.sql
18-
rm -f src/deps.txt
19-
rm -f src/deps-ordered.txt
21+
rm -f src/deps-supabase.txt
22+
rm -f src/deps-ordered-supabase.txt
2023

2124

2225
RELEASE_VERSION=${usage_version:-DEV}
@@ -43,17 +46,53 @@ find src -type f -path "*.sql" ! -path "*_test.sql" | while IFS= read -r sql_fil
4346
done < "$sql_file"
4447
done
4548

49+
4650
cat src/deps.txt | tsort | tac > src/deps-ordered.txt
4751

4852
cat src/deps-ordered.txt | xargs cat | grep -v REQUIRE >> release/cipherstash-encrypt.sql
4953

5054
cat tasks/uninstall.sql >> release/cipherstash-encrypt-uninstall.sql
5155

56+
57+
# --------------------------------------------------------
58+
find src -type f -path "*.sql" ! -path "*_test.sql" ! -path "**/operator_class.sql" | while IFS= read -r sql_file; do
59+
echo $sql_file
60+
61+
echo "$sql_file $sql_file" >> src/deps.txt
62+
63+
while IFS= read -r line; do
64+
# echo $line
65+
# Check if the line contains "-- REQUIRE:"
66+
if [[ "$line" == *"-- REQUIRE:"* ]]; then
67+
# Extract the required file(s) after "-- REQUIRE:"
68+
deps=${line#*-- REQUIRE: }
69+
70+
# Split multiple REQUIRE declarations if present
71+
for dep in $deps; do
72+
echo "$sql_file $dep" >> src/deps-supabase.txt
73+
done
74+
fi
75+
done < "$sql_file"
76+
done
77+
78+
79+
cat src/deps-supabase.txt | tsort | tac > src/deps-supabase-ordered.txt
80+
81+
cat src/deps-supabase-ordered.txt | xargs cat | grep -v REQUIRE >> release/cipherstash-encrypt-supabase.sql
82+
83+
cat tasks/uninstall.sql >> release/cipherstash-encrypt-uninstall-supabase.sql
84+
85+
5286
set +x
5387
echo
5488
echo '###############################################'
5589
echo "# ✅Build succeeded"
5690
echo '###############################################'
5791
echo
58-
echo 'Installer: release/cipherstash-encrypt.sql'
59-
echo 'Uninstaller: release/cipherstash-encrypt-uninstall.sql'
92+
echo 'Installer:'
93+
echo ' release/cipherstash-encrypt.sql'
94+
echo ' release/cipherstash-encrypt-supabase.sql'
95+
echo
96+
echo 'Uninstaller:'
97+
echo ' release/cipherstash-encrypt-uninstall.sql'
98+
echo ' release/cipherstash-encrypt-uninstall-supabase.sql'

0 commit comments

Comments
 (0)