Ashis Taru Mukherjee ashis
Mon Mar 7 07:03:28 PST 2005
Hi All,

I want to replicate two db between two different hosts.
I installed slony in two hosts, run slony_setup.pl. It asks for details
for both master and slave server and ask what db we want to replicate.
After that it run slon but slon get error. we see a new file created
slony_master_setup.sh.In log we see this error:
==============================
:ALTER TABLE
SET
ERROR:  there is no unique constraint matching given keys for referenced
table "report"
ERROR:  there is no unique constraint matching given keys for referenced
table "report"
ERROR:  there is no unique constraint matching given keys for referenced
table "report"
=============

We see this error is due to tables that has no primary key.We get this
solution:

=====================================
http://cbbrowne.com/info/definingsets.html

If the table has a formally identified primary key, SET ADD TABLE can be
used without any need to reference the primary key.
Slony-I will pick up that there is a primary key, and use it.

If the table hasn't got a primary key, but has some candidate primary
key((e.g. - keys that could be used as
primary keys, but which are not identified formally as such)), that is,
some index on a combination of fields that is UNIQUE
and NOT NULL, then you can specify the key, as in

    SET ADD TABLE (set id = 1, origin = 1, id = 42,
                   full qualified name = 'public.this_table',
                   key = 'this_by_that',
         comment='this_table has this_by_that as a candidate primary
key');


Notice that while you need to specify the namespace for the table, you
must not specify the namespace for the key, as it infers the
namespace from the table.

If the table hasn't even got a candidate primary key, you can ask
Slony-I to provide one. This is done by first using TABLE
ADD KEY to add a column populated using a Slony-I sequence, and then
having the SET ADD TABLE include the directive
key=serial, to indicate that Slony-I's own column should be used.

Example
         TABLE ADD KEY ( NODE ID = 1,
         FULLY QUALIFIED NAME = 'public.history' );


CREATE SET ( ID = 1, ORIGIN = 1, COMMENT = 'PGbench tables' );
        SET ADD TABLE ( SET ID = 1, ORIGIN = 1, ID = 1, FULL QUALIFIED
NAME = 'public.accounts',
                                COMMENT = 'Table accounts' );
        SET ADD TABLE ( SET ID = 1, ORIGIN = 1, ID = 2, FULL QUALIFIED
NAME = 'public.branches',
                                COMMENT = 'Table branches' );
        SET ADD TABLE ( SET ID = 1, ORIGIN = 1, ID = 3, FULL QUALIFIED
NAME = 'public.tellers',
                                COMMENT = 'Table tellers' );
        SET ADD TABLE ( SET ID = 1, ORIGIN = 1, ID = 4, FULL QUALIFIED
NAME = 'public.history',
                                KEY = SERIAL, COMMENT = 'Table history'
);

=====================================

Our script looks like this :

slony_master_setup.sh

        echo '  Adding table customer.report...';
        table add key ( node id = 1,  fully qualified name =
'public.history' );
        echo '    done';

we changed it to :
        echo '  Adding table customer.report...';
       table add key ( node id = 1,  fully qualified name =
'customer.report' );
       set add table (set id = 1, origin = 1, id = 139, full qualified
name = 'customer.report', key=serial,comment = 'Table
customer.report');
        echo '    done';


but it still shows the error:

ERROR:  there is no unique constraint matching given keys for referenced
table "report"
ERROR:  there is no unique constraint matching given keys for referenced
table "report"
ERROR:  there is no unique constraint matching given keys for referenced
table "report"


Can anybody please help me?



More information about the Slony1-general mailing list