[Bucardo-general] Patch to Enable Filtering in bucardo_add_delta functions

Benjamin Allen bsa at lanl.gov
Thu Mar 12 19:47:07 UTC 2009


Hello Everyone,

To solve the problem Meg and I were having with being able to filter  
out data from a table (goat) from being synced I've added a goatfilter  
table to the bucardo database and modified the validate_sync function.  
The table has an id, status, FK to the goat table, and a src_code  
column. The src_code column is used to store the source code of the  
bucardo_add_delta function for whichever goat you're working with. Our  
example is attached, so the goatfilter table would be populated like so:

INSERT INTO goatfilter VALUES ( DEFAULT, 12, $$
SOURCE_CODE GOES HERE
$$ );

Where 12 is the goat.id of the goat you're working with.

Limitations as of right now:

- The src_code of goatfilter totally replaces the default function  
source code if it exists. This is a bit clunky as you have to store  
the entire function in the src_code column.
	- Maybe instead of writing out the entire function, we could insert  
just a chunk of code into the already existing code. If you look at  
the example function you can see we only added code at the beginning  
of the function.

- Even though the data we want filtered is not added to the  
bucardo_delta table the sync is still kicked when filtered data is  
touched in the database.
	- Fixing this would involve doing filtering in the  
bucardo_triggerkick function.

- Current modifications to the validate_sync method takes just the  
first row from the select statement on the goatfilter table for a  
given goat.id. There's no validation that only one entry is created in  
the goatfilter table per goat.

I'm wondering if anyone can think up a better way or place of doing  
filtering of data. I've explored using PostgreSQL Views and Bucardo  
customcode and found no real logical way of doing it. By filtering it  
at the bucardo_add_delta function its eliminating any additional  
network traffic and processing from Bucardo. Thoughts?

Regards,

Ben Allen



-------------- next part --------------
A non-text attachment was scrubbed...
Name: bucardo_filter.patch
Type: application/octet-stream
Size: 4049 bytes
Desc: not available
Url : https://mail.endcrypt.com/pipermail/bucardo-general/attachments/20090312/55431ad2/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bucardo_add_delta_custom.sql
Type: application/octet-stream
Size: 1063 bytes
Desc: not available
Url : https://mail.endcrypt.com/pipermail/bucardo-general/attachments/20090312/55431ad2/attachment-0001.obj 
-------------- next part --------------





More information about the Bucardo-general mailing list