2004-02-17 06:34:35 +03:00
|
|
|
BEGIN;
|
|
|
|
|
2006-02-27 19:09:50 +03:00
|
|
|
CREATE FUNCTION "recordchange" () RETURNS trigger
|
|
|
|
AS '$libdir/pending', 'recordchange'
|
|
|
|
LANGUAGE C;
|
2002-06-24 01:58:08 +04:00
|
|
|
|
2004-02-17 06:34:35 +03:00
|
|
|
CREATE TABLE dbmirror_MirrorHost (
|
2006-02-27 19:09:50 +03:00
|
|
|
MirrorHostId serial PRIMARY KEY,
|
|
|
|
SlaveName varchar NOT NULL
|
2004-02-17 06:34:35 +03:00
|
|
|
);
|
2002-06-24 01:58:08 +04:00
|
|
|
|
2004-02-17 06:34:35 +03:00
|
|
|
CREATE TABLE dbmirror_Pending (
|
2006-02-27 19:09:50 +03:00
|
|
|
SeqId serial PRIMARY KEY,
|
|
|
|
TableName name NOT NULL,
|
|
|
|
Op character,
|
|
|
|
XID integer NOT NULL
|
2002-06-24 01:58:08 +04:00
|
|
|
);
|
|
|
|
|
2004-09-10 08:31:06 +04:00
|
|
|
CREATE INDEX dbmirror_Pending_XID_Index ON dbmirror_Pending (XID);
|
2002-06-24 01:58:08 +04:00
|
|
|
|
2004-02-17 06:34:35 +03:00
|
|
|
CREATE TABLE dbmirror_PendingData (
|
2006-02-27 19:09:50 +03:00
|
|
|
SeqId integer NOT NULL,
|
|
|
|
IsKey boolean NOT NULL,
|
|
|
|
Data varchar,
|
|
|
|
PRIMARY KEY (SeqId, IsKey) ,
|
|
|
|
FOREIGN KEY (SeqId) REFERENCES dbmirror_Pending (SeqId) ON UPDATE CASCADE ON DELETE CASCADE
|
2002-06-24 01:58:08 +04:00
|
|
|
);
|
|
|
|
|
2004-02-17 06:34:35 +03:00
|
|
|
CREATE TABLE dbmirror_MirroredTransaction (
|
2006-02-27 19:09:50 +03:00
|
|
|
XID integer NOT NULL,
|
|
|
|
LastSeqId integer NOT NULL,
|
|
|
|
MirrorHostId integer 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 CASCADE ON DELETE CASCADE
|
2002-06-24 01:58:08 +04:00
|
|
|
);
|
2004-02-17 06:34:35 +03:00
|
|
|
|
|
|
|
UPDATE pg_proc SET proname='nextval_pg' WHERE proname='nextval';
|
|
|
|
|
2006-02-27 19:09:50 +03:00
|
|
|
CREATE FUNCTION pg_catalog.nextval(regclass) RETURNS bigint
|
|
|
|
AS '$libdir/pending', 'nextval_mirror'
|
|
|
|
LANGUAGE C STRICT;
|
2004-02-17 06:34:35 +03:00
|
|
|
|
|
|
|
UPDATE pg_proc set proname='setval_pg' WHERE proname='setval';
|
|
|
|
|
2006-02-27 19:09:50 +03:00
|
|
|
CREATE FUNCTION pg_catalog.setval(regclass, bigint, boolean) RETURNS bigint
|
|
|
|
AS '$libdir/pending', 'setval3_mirror'
|
|
|
|
LANGUAGE C STRICT;
|
|
|
|
|
|
|
|
CREATE FUNCTION pg_catalog.setval(regclass, bigint) RETURNS bigint
|
|
|
|
AS '$libdir/pending', 'setval_mirror'
|
|
|
|
LANGUAGE C STRICT;
|
2004-02-17 06:34:35 +03:00
|
|
|
|
2004-09-10 08:31:06 +04:00
|
|
|
COMMIT;
|