citusdata / pg_shard

ATTENTION: pg_shard is superseded by Citus, its more powerful replacement
https://github.com/citusdata/citus
GNU Lesser General Public License v3.0
1.06k stars 63 forks source link

Conditionally support functions #109

Closed gmcquillan closed 9 years ago

gmcquillan commented 9 years ago

Addresses issue #108.

Mostly submitting to show that my idle curiosity is satisfied. Naturally, allowing function calls to go through to the shard workers includes a lot of unknowns, particularly around which extensions are loaded, which stored procedures have been saved, probably other things that I don't know about off the top of my head. I'm not sure what the best way to handle that would be, but maybe allowing a whitelist of function names that the maintainer of a cluster knows is on each of the postgres workers would be a good start? For now, this patch satisfies my use-case.

Example Table Definition:

template1=# \d test
     Table "public.test"
 Column |  Type   | Modifiers 
--------+---------+-----------
 id     | integer | 
 date   | date    | 

Example before patch:

template1=# insert into test values(111223232, now()::date);
ERROR:  cannot plan sharded modification containing values which are not constants or constant expressions

Example after patch:

template1=# insert into test values(111223233, now()::date);
INSERT 0 1
jasonmp85 commented 9 years ago

Unfortunately, those checks are crucial to ensure that each replica has exactly the same data set. We are exploring options here (more first-class replication using something like BDR, or folding some functions on the master, like now), but since we're doing modifications to replicas one-at-a-time, it is unsafe to evaluate anything except IMMUTABLE functions during modifications.

gmcquillan commented 9 years ago

Makes sense. It was mostly just curiosity that I sent this patch. I'll go ahead and close to keep the clutter out of the PR queue.