2004-02-17 11:34:35 +08:00
|
|
|
BEGIN;
|
|
|
|
|
2002-06-24 05:58:08 +08:00
|
|
|
|
2002-08-22 08:01:51 +08:00
|
|
|
CREATE FUNCTION "recordchange" () RETURNS trigger AS
|
2004-02-17 11:34:35 +08:00
|
|
|
'$libdir/pending.so', 'recordchange' LANGUAGE 'C';
|
|
|
|
|
2002-06-24 05:58:08 +08:00
|
|
|
|
|
|
|
|
2004-02-17 11:34:35 +08:00
|
|
|
CREATE TABLE dbmirror_MirrorHost (
|
|
|
|
MirrorHostId serial not null,
|
|
|
|
SlaveName varchar NOT NULL,
|
|
|
|
PRIMARY KEY(MirrorHostId)
|
|
|
|
);
|
2002-06-24 05:58:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-02-17 11:34:35 +08:00
|
|
|
CREATE TABLE dbmirror_Pending (
|
|
|
|
SeqId serial,
|
|
|
|
TableName Name NOT NULL,
|
|
|
|
Op character,
|
|
|
|
XID int4 NOT NULL,
|
|
|
|
PRIMARY KEY (SeqId)
|
2002-06-24 05:58:08 +08:00
|
|
|
);
|
|
|
|
|
2004-09-10 12:31:06 +08:00
|
|
|
CREATE INDEX dbmirror_Pending_XID_Index ON dbmirror_Pending (XID);
|
2002-06-24 05:58:08 +08:00
|
|
|
|
2004-02-17 11:34:35 +08:00
|
|
|
CREATE TABLE dbmirror_PendingData (
|
|
|
|
SeqId int4 NOT NULL,
|
|
|
|
IsKey bool NOT NULL,
|
|
|
|
Data varchar,
|
|
|
|
PRIMARY KEY (SeqId, IsKey) ,
|
|
|
|
FOREIGN KEY (SeqId) REFERENCES dbmirror_Pending (SeqId) ON UPDATE CASCADE ON DELETE CASCADE
|
2002-06-24 05:58:08 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2004-02-17 11:34:35 +08:00
|
|
|
CREATE TABLE dbmirror_MirroredTransaction (
|
|
|
|
XID int4 NOT NULL,
|
|
|
|
LastSeqId int4 NOT NULL,
|
|
|
|
MirrorHostId int4 NOT NULL,
|
|
|
|
PRIMARY KEY (XID,MirrorHostId),
|
|
|
|
FOREIGN KEY (MirrorHostId) REFERENCES dbmirror_MirrorHost (MirrorHostId) ON UPDATE CASCADE ON DELETE CASCADE,
|
|
|
|
FOREIGN KEY (LastSeqId) REFERENCES dbmirror_Pending (SeqId) ON UPDATE
|
2002-06-24 05:58:08 +08:00
|
|
|
CASCADE ON DELETE CASCADE
|
|
|
|
);
|
2004-02-17 11:34:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
UPDATE pg_proc SET proname='nextval_pg' WHERE proname='nextval';
|
|
|
|
|
|
|
|
CREATE FUNCTION pg_catalog.nextval(text) RETURNS int8 AS
|
2004-09-10 12:31:06 +08:00
|
|
|
'$libdir/pending.so', 'nextval' LANGUAGE 'C' STRICT;
|
2004-02-17 11:34:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
UPDATE pg_proc set proname='setval_pg' WHERE proname='setval';
|
|
|
|
|
2004-09-10 12:31:06 +08:00
|
|
|
CREATE FUNCTION pg_catalog.setval("unknown",integer,boolean) RETURNS int8 AS
|
|
|
|
'$libdir/pending.so', 'setval' LANGUAGE 'C' STRICT;
|
|
|
|
CREATE FUNCTION pg_catalog.setval("unknown",integer) RETURNS int8 AS
|
|
|
|
'$libdir/pending.so', 'setval' LANGUAGE 'C' STRICT;
|
2004-02-17 11:34:35 +08:00
|
|
|
|
2004-09-10 12:31:06 +08:00
|
|
|
COMMIT;
|