[Bucardo-general] support for primary key column with a sequence as the default value

Omar Mehmood omarmehmood at yahoo.com
Wed Jan 20 19:18:17 UTC 2010


> > I was wondering if Bucardo supports the replication of data in tables
> > whose primary key contains a column with a sequence as the default
> > value.  For example:
> 
> Certainly. The only important parts are the data type (bigint in your
> example), and that the table has a primary key.
> 
> > CREATE SEQUENCE user_id_sequence START 2147483648;
> >
> > CREATE TABLE "user"( "user_id" Bigint DEFAULT
> > nextval('user_id_sequence') NOT NULL, "user_name" Character
> > varying(30) NOT NULL ) WITH (OIDS=FALSE);
> >
> > ALTER TABLE "user" ADD CONSTRAINT "user_P1" PRIMARY KEY ("user_id");
> >
> > INSERT INTO public.user (user_name) VALUES ('omar');
> >
> > When I test the above setup, Bucardo doesn't seem to replicate the
> > row resulting from the INSERT statement from the master to the slave.
> > However, the following does work:
> 
> Check the logs - they are very verbose and should tell you exactly what
> is happening. Check that the table on the master has bucardo_delta
> triggers, that an insert to the table populated bucardo_delta, and that
> no errors appear in the Bucardo logs.

Thanks.  I checked the bucardo.warning.log file.  The definition of the public.user table in the test database on the slave server was different than on the master servers-- no DEFAULT value was specified for the table on the slave server (not that it actually would matter in my particular test case, but it could easily be an issue in another setup).

> > INSERT INTO public.user (user_id, user_name) VALUES
> > (nextval('user_id_sequence'), 'omar')
> >
> > Any ideas ?
> 
> It's remotely possible the use of reserved words and thus forced quoting
> of the table name ("user") has something to do with it, but without the
> logs, it's impossible to tell.

No, it was my fault.  Both of my examples of using a sequence for the primary key column work correctly with Bucardo.

Omar


      


More information about the Bucardo-general mailing list