Yi Zhao yi.zhao at alibaba-inc.com
Wed Aug 13 06:37:27 PDT 2008
yes, I got it!

thanks very much:D

regards,
Yi
On Wed, 2008-08-13 at 17:04 +1000, Charles Duffy wrote:
> On Wed, Aug 13, 2008 at 1:49 PM, Yi Zhao <yi.zhao at alibaba-inc.com> wrote:
> > I have a table which have unique like:
> > unique(foo_id, bar_id);
> >
> > my slonik script is below:
> > set add table (set id = 1, origin = 1, id = 2, full qualified name =
> > 'search.thread', key = 'foo_id, bar_id', comment = 'nodesc');
> >
> > when I execute:
> > <stdin>:16: PGRES_FATAL_ERROR select
> > "_replication".determineIdxnameUnique('search.thread', 'foo_id,
> > bar_id');  - ERROR:  Slony-I: table "search"."thread" has no unique
> > index foo_id, bar_id
> >
> > how to add a table which have unique with two column into slony???
> 
> The unique constraint on your table will make use of an index.
> You should specify the name of this index in the 'key' parameter, not
> the name of the columns in the constraint definition.
> Like:
> 
> postgres=# create table table1 (foo_id int, bar_id int);
> CREATE TABLE
> postgres=# alter table table1 add constraint unique_idx unique (foo_id,bar_id);
> NOTICE:  ALTER TABLE / ADD UNIQUE will create implicit index
> "unique_idx" for table "table1"
> ALTER TABLE
> postgres=# \d table1
>     Table "public.table1"
>  Column |  Type   | Modifiers
> --------+---------+-----------
>  foo_id | integer |
>  bar_id | integer |
> Indexes:
>     "unique_idx" UNIQUE, btree (foo_id, bar_id)
> 
> Then your slonik command should look like:
> 
> set add table (set id = 1, origin = 1, id = 2, full qualified name =
> 'search.thread', key = 'unique_idx' comment = 'nodesc');
> 
> Note that you also need to have NOT NULL on all the columns composing
> the index. As the manual says, you might as well define a primary key
> consisting of these columns.
> 
> Thanks,
> 
> Charles Duffy
> 



More information about the Slony1-general mailing list