Examines an index tuple and updates its bloom filter by adding a new value from a heap tuple, returning whether the bloom filter was modified.
Datum brin_bloom_add_value(PG_FUNCTION_ARGS)This function is a BRIN operator function that maintains bloom filter summaries for index ranges. It processes a new value from a heap tuple and determines if it needs to update the existing bloom filter:
- Initialization: If this is the first non-null value for the range, initializes a new bloom filter using calculated ndistinct and false positive rate parameters
- Hash computation: Computes a hash value for the new input using the appropriate hash function for the column's data type
- Filter update: Adds the hash value to the bloom filter and determines if the filter was actually modified
- State management: Updates the BrinValues structure with the new or modified bloom filter
The function handles the transition from all-null state to having actual data and ensures the bloom filter is properly maintained throughout the life of the BRIN index.
- PG_FUNCTION_ARGS: Standard PostgreSQL function argument structure containing:
bdesc: BRIN descriptor with index metadatacolumn: BrinValues structure containing current bloom filter statenewval: New datum value to potentially add to the bloom filterisnull: Boolean indicating if the new value is null (used for assertions)
- Functions called/Symbols referenced:
- brin_bloom_get_ndistinct
- BloomGetFalsePositiveRate
- bloom_init
- bloom_get_procinfo
- bloom_add_value
- FunctionCall1Coll
- DatumGetUInt32
- PG_DETOAST_DATUM
- Called from (representative examples):
- This is a BRIN operator function called by the BRIN indexing infrastructure
- This is a PostgreSQL internal function that follows the PG_FUNCTION_ARGS convention for operator functions
- The function is designed to be called during BRIN index construction and maintenance
- Uses assertions to verify that null values are not processed (Assert(!isnull))
- Handles TOAST decompression for existing bloom filters that may be stored compressed
- The return value indicates whether the bloom filter summary was actually updated, which is important for BRIN's change tracking
- The function manages memory by ensuring the updated bloom filter is properly stored back in the BrinValues structure