[development] sequences and table prefixing

Robert Douglass rob at robshouse.net
Thu Jan 19 13:24:58 UTC 2006

If I want to share tables between databases (user, spam, whatever), I 
usually have to consider issues with the primary key sequences. The 
solution that comes to mind is to share the sequences table as well. It 
is nice that Drupal offers this flexibility.

Is there a way that one can specify "use db1.sequences for node_id 
sequences, db2.sequences for user_id sequences, and db3.sequences for 
spam_id sequences"? I don't think so, but this might be a feature we 
should consider implementing.

Why? Because the current system only allows a database to join a shared 
pool of something (take spam for now) at the beginning of its lifetime. 
If I had 5 sites sharing spam tables, and wanted to integrate an 
existing site, I'd be out of luck if I had to rely on a shared, running 
sequid for the spam tables.

I think it would be very useful if one could specify a sequences array 
like the $db_prefix array:

$db_sequences = array(
   'node_id' => 'default',
   'spam_id' => 'db_spam.',

This would result in all sequences being taken from the default sequence 
table except for the (purely illustrational) 'spam_id' sequence, which 
would be taken from the db_spam.sequences table.

Is there a way to do this currently in Drupal that I've overlooked? 
Would people be in support of this functionality if a patch appeared?



More information about the development mailing list