Skip to content

Commit cebefcd

Browse files
committed
docs(sql): add Doxygen comments to hash and bloom filter index modules (Phase 3 batch 1)
Documented three index module types with comprehensive Doxygen comments: Modules documented: - blake3: 6 database objects (type, constructor, extractor, comparator, caster, compare function) - hmac_256: 6 database objects (type, constructor, extractor, comparator, caster, compare function) - bloom_filter: 5 database objects (type, constructor, extractor, comparator, caster) Changes: - Added @brief descriptions for all types and functions - Documented @param and @return tags for all parameters and return values - Clarified "three-way comparison" terminology in compare functions - Standardized documentation format across all index modules Progress: 17 database objects documented across 8 files
1 parent b96945c commit cebefcd

File tree

8 files changed

+171
-15
lines changed

8 files changed

+171
-15
lines changed

src/blake3/compare.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
-- REQUIRE: src/blake3/functions.sql
44

55

6+
--! @brief Compare two encrypted values using Blake3 hash index terms
7+
--!
8+
--! Performs a three-way comparison (returns -1/0/1) of encrypted values using
9+
--! their Blake3 hash index terms. Used internally by the equality operator (=)
10+
--! for exact-match queries without decryption.
11+
--!
12+
--! @param a eql_v2_encrypted First encrypted value to compare
13+
--! @param b eql_v2_encrypted Second encrypted value to compare
14+
--! @return Integer -1 if a < b, 0 if a = b, 1 if a > b
15+
--!
16+
--! @note NULL values are sorted before non-NULL values
17+
--! @note Comparison uses underlying text type ordering of Blake3 hashes
18+
--!
19+
--! @see eql_v2.blake3
20+
--! @see eql_v2.has_blake3
21+
--! @see eql_v2."="
622
CREATE FUNCTION eql_v2.compare_blake3(a eql_v2_encrypted, b eql_v2_encrypted)
723
RETURNS integer
824
IMMUTABLE STRICT PARALLEL SAFE

src/blake3/functions.sql

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
-- REQUIRE: src/schema.sql
22

3-
-- extracts ste_vec index from a jsonb value
4-
5-
-- extracts blake3 index from a jsonb value
6-
7-
3+
--! @brief Extract Blake3 hash index term from JSONB payload
4+
--!
5+
--! Extracts the Blake3 hash value from the 'b3' field of an encrypted
6+
--! data payload. Used internally for exact-match comparisons.
7+
--!
8+
--! @param val JSONB Encrypted data payload containing index terms
9+
--! @return eql_v2.blake3 Blake3 hash value, or NULL if not present
10+
--! @throws Exception if 'b3' field is missing when blake3 index is expected
11+
--!
12+
--! @see eql_v2.has_blake3
13+
--! @see eql_v2.compare_blake3
814
CREATE FUNCTION eql_v2.blake3(val jsonb)
915
RETURNS eql_v2.blake3
1016
IMMUTABLE STRICT PARALLEL SAFE
@@ -27,8 +33,15 @@ AS $$
2733
$$ LANGUAGE plpgsql;
2834

2935

30-
-- extracts blake3 index from an eql_v2_encrypted value
31-
36+
--! @brief Extract Blake3 hash index term from encrypted column value
37+
--!
38+
--! Extracts the Blake3 hash from an encrypted column value by accessing
39+
--! its underlying JSONB data field.
40+
--!
41+
--! @param val eql_v2_encrypted Encrypted column value
42+
--! @return eql_v2.blake3 Blake3 hash value, or NULL if not present
43+
--!
44+
--! @see eql_v2.blake3(jsonb)
3245
CREATE FUNCTION eql_v2.blake3(val eql_v2_encrypted)
3346
RETURNS eql_v2.blake3
3447
IMMUTABLE STRICT PARALLEL SAFE
@@ -39,6 +52,15 @@ AS $$
3952
$$ LANGUAGE plpgsql;
4053

4154

55+
--! @brief Check if JSONB payload contains Blake3 index term
56+
--!
57+
--! Tests whether the encrypted data payload includes a 'b3' field,
58+
--! indicating a Blake3 hash is available for exact-match queries.
59+
--!
60+
--! @param val JSONB Encrypted data payload
61+
--! @return Boolean True if 'b3' field is present and non-null
62+
--!
63+
--! @see eql_v2.blake3
4264
CREATE FUNCTION eql_v2.has_blake3(val jsonb)
4365
RETURNS boolean
4466
IMMUTABLE STRICT PARALLEL SAFE
@@ -49,6 +71,15 @@ AS $$
4971
$$ LANGUAGE plpgsql;
5072

5173

74+
--! @brief Check if encrypted column value contains Blake3 index term
75+
--!
76+
--! Tests whether an encrypted column value includes a Blake3 hash
77+
--! by checking its underlying JSONB data field.
78+
--!
79+
--! @param val eql_v2_encrypted Encrypted column value
80+
--! @return Boolean True if Blake3 hash is present
81+
--!
82+
--! @see eql_v2.has_blake3(jsonb)
5283
CREATE FUNCTION eql_v2.has_blake3(val eql_v2_encrypted)
5384
RETURNS boolean
5485
IMMUTABLE STRICT PARALLEL SAFE

src/blake3/types.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
-- REQUIRE: src/schema.sql
22

3+
--! @brief Blake3 hash index term type
4+
--!
5+
--! Domain type representing Blake3 cryptographic hash values.
6+
--! Used for exact-match encrypted searches via the 'unique' index type.
7+
--! The hash is stored in the 'b3' field of encrypted data payloads.
8+
--!
9+
--! @see eql_v2.add_search_config
10+
--! @note This is a transient type used only during query execution
311
CREATE DOMAIN eql_v2.blake3 AS text;

src/bloom_filter/functions.sql

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
-- REQUIRE: src/schema.sql
22

33

4-
-- extracts match index from an emcrypted column
5-
4+
--! @brief Extract Bloom filter index term from JSONB payload
5+
--!
6+
--! Extracts the Bloom filter array from the 'bf' field of an encrypted
7+
--! data payload. Used internally for pattern-match queries (LIKE operator).
8+
--!
9+
--! @param val JSONB Encrypted data payload containing index terms
10+
--! @return eql_v2.bloom_filter Bloom filter as smallint array
11+
--! @throws Exception if 'bf' field is missing when bloom_filter index is expected
12+
--!
13+
--! @see eql_v2.has_bloom_filter
14+
--! @see eql_v2."~~"
615
CREATE FUNCTION eql_v2.bloom_filter(val jsonb)
716
RETURNS eql_v2.bloom_filter
817
IMMUTABLE STRICT PARALLEL SAFE
@@ -21,8 +30,15 @@ AS $$
2130
$$ LANGUAGE plpgsql;
2231

2332

24-
-- extracts unique index from an encrypted column
25-
33+
--! @brief Extract Bloom filter index term from encrypted column value
34+
--!
35+
--! Extracts the Bloom filter from an encrypted column value by accessing
36+
--! its underlying JSONB data field.
37+
--!
38+
--! @param val eql_v2_encrypted Encrypted column value
39+
--! @return eql_v2.bloom_filter Bloom filter as smallint array
40+
--!
41+
--! @see eql_v2.bloom_filter(jsonb)
2642
CREATE FUNCTION eql_v2.bloom_filter(val eql_v2_encrypted)
2743
RETURNS eql_v2.bloom_filter
2844
IMMUTABLE STRICT PARALLEL SAFE
@@ -33,6 +49,15 @@ AS $$
3349
$$ LANGUAGE plpgsql;
3450

3551

52+
--! @brief Check if JSONB payload contains Bloom filter index term
53+
--!
54+
--! Tests whether the encrypted data payload includes a 'bf' field,
55+
--! indicating a Bloom filter is available for pattern-match queries.
56+
--!
57+
--! @param val JSONB Encrypted data payload
58+
--! @return Boolean True if 'bf' field is present and non-null
59+
--!
60+
--! @see eql_v2.bloom_filter
3661
CREATE FUNCTION eql_v2.has_bloom_filter(val jsonb)
3762
RETURNS boolean
3863
IMMUTABLE STRICT PARALLEL SAFE
@@ -43,6 +68,15 @@ AS $$
4368
$$ LANGUAGE plpgsql;
4469

4570

71+
--! @brief Check if encrypted column value contains Bloom filter index term
72+
--!
73+
--! Tests whether an encrypted column value includes a Bloom filter
74+
--! by checking its underlying JSONB data field.
75+
--!
76+
--! @param val eql_v2_encrypted Encrypted column value
77+
--! @return Boolean True if Bloom filter is present
78+
--!
79+
--! @see eql_v2.has_bloom_filter(jsonb)
4680
CREATE FUNCTION eql_v2.has_bloom_filter(val eql_v2_encrypted)
4781
RETURNS boolean
4882
IMMUTABLE STRICT PARALLEL SAFE

src/bloom_filter/types.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
-- REQUIRE: src/schema.sql
22

3+
--! @brief Bloom filter index term type
4+
--!
5+
--! Domain type representing Bloom filter bit arrays stored as smallint arrays.
6+
--! Used for pattern-match encrypted searches via the 'match' index type.
7+
--! The filter is stored in the 'bf' field of encrypted data payloads.
8+
--!
9+
--! @see eql_v2.add_search_config
10+
--! @see eql_v2."~~"
11+
--! @note This is a transient type used only during query execution
312
CREATE DOMAIN eql_v2.bloom_filter AS smallint[];
413

src/hmac_256/compare.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
-- REQUIRE: src/hmac_256/functions.sql
44

55

6+
--! @brief Compare two encrypted values using HMAC-SHA256 index terms
7+
--!
8+
--! Performs a three-way comparison (returns -1/0/1) of encrypted values using
9+
--! their HMAC-SHA256 hash index terms. Used internally by the equality operator (=)
10+
--! for exact-match queries without decryption.
11+
--!
12+
--! @param a eql_v2_encrypted First encrypted value to compare
13+
--! @param b eql_v2_encrypted Second encrypted value to compare
14+
--! @return Integer -1 if a < b, 0 if a = b, 1 if a > b
15+
--!
16+
--! @note NULL values are sorted before non-NULL values
17+
--! @note Comparison uses underlying text type ordering of HMAC-SHA256 hashes
18+
--!
19+
--! @see eql_v2.hmac_256
20+
--! @see eql_v2.has_hmac_256
21+
--! @see eql_v2."="
622
CREATE FUNCTION eql_v2.compare_hmac_256(a eql_v2_encrypted, b eql_v2_encrypted)
723
RETURNS integer
824
IMMUTABLE STRICT PARALLEL SAFE

src/hmac_256/functions.sql

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
-- REQUIRE: src/schema.sql
22
-- REQUIRE: src/hmac_256/types.sql
33

4-
-- extracts hmac_256 index from an encrypted column
5-
4+
--! @brief Extract HMAC-SHA256 index term from JSONB payload
5+
--!
6+
--! Extracts the HMAC-SHA256 hash value from the 'hm' field of an encrypted
7+
--! data payload. Used internally for exact-match comparisons.
8+
--!
9+
--! @param val JSONB Encrypted data payload containing index terms
10+
--! @return eql_v2.hmac_256 HMAC-SHA256 hash value
11+
--! @throws Exception if 'hm' field is missing when hmac_256 index is expected
12+
--!
13+
--! @see eql_v2.has_hmac_256
14+
--! @see eql_v2.compare_hmac_256
615
CREATE FUNCTION eql_v2.hmac_256(val jsonb)
716
RETURNS eql_v2.hmac_256
817
IMMUTABLE STRICT PARALLEL SAFE
@@ -20,6 +29,15 @@ AS $$
2029
$$ LANGUAGE plpgsql;
2130

2231

32+
--! @brief Check if JSONB payload contains HMAC-SHA256 index term
33+
--!
34+
--! Tests whether the encrypted data payload includes an 'hm' field,
35+
--! indicating an HMAC-SHA256 hash is available for exact-match queries.
36+
--!
37+
--! @param val JSONB Encrypted data payload
38+
--! @return Boolean True if 'hm' field is present and non-null
39+
--!
40+
--! @see eql_v2.hmac_256
2341
CREATE FUNCTION eql_v2.has_hmac_256(val jsonb)
2442
RETURNS boolean
2543
IMMUTABLE STRICT PARALLEL SAFE
@@ -30,6 +48,15 @@ AS $$
3048
$$ LANGUAGE plpgsql;
3149

3250

51+
--! @brief Check if encrypted column value contains HMAC-SHA256 index term
52+
--!
53+
--! Tests whether an encrypted column value includes an HMAC-SHA256 hash
54+
--! by checking its underlying JSONB data field.
55+
--!
56+
--! @param val eql_v2_encrypted Encrypted column value
57+
--! @return Boolean True if HMAC-SHA256 hash is present
58+
--!
59+
--! @see eql_v2.has_hmac_256(jsonb)
3360
CREATE FUNCTION eql_v2.has_hmac_256(val eql_v2_encrypted)
3461
RETURNS boolean
3562
IMMUTABLE STRICT PARALLEL SAFE
@@ -41,8 +68,15 @@ $$ LANGUAGE plpgsql;
4168

4269

4370

44-
-- extracts hmac_256 index from an encrypted column
45-
71+
--! @brief Extract HMAC-SHA256 index term from encrypted column value
72+
--!
73+
--! Extracts the HMAC-SHA256 hash from an encrypted column value by accessing
74+
--! its underlying JSONB data field.
75+
--!
76+
--! @param val eql_v2_encrypted Encrypted column value
77+
--! @return eql_v2.hmac_256 HMAC-SHA256 hash value
78+
--!
79+
--! @see eql_v2.hmac_256(jsonb)
4680
CREATE FUNCTION eql_v2.hmac_256(val eql_v2_encrypted)
4781
RETURNS eql_v2.hmac_256
4882
IMMUTABLE STRICT PARALLEL SAFE

src/hmac_256/types.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
-- REQUIRE: src/schema.sql
22

3+
--! @brief HMAC-SHA256 index term type
4+
--!
5+
--! Domain type representing HMAC-SHA256 hash values.
6+
--! Used for exact-match encrypted searches via the 'unique' index type.
7+
--! The hash is stored in the 'hm' field of encrypted data payloads.
8+
--!
9+
--! @see eql_v2.add_search_config
10+
--! @note This is a transient type used only during query execution
311
CREATE DOMAIN eql_v2.hmac_256 AS text;

0 commit comments

Comments
 (0)