Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit58bc188

Browse files
committed
extracted from xtm branch of postgres
0 parents  commit58bc188

File tree

18 files changed

+1902
-0
lines changed

18 files changed

+1902
-0
lines changed

‎Makefile‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
MODULE_big = pg_dtm
2+
OBJS = pg_dtm.o
3+
4+
EXTENSION = pg_dtm
5+
DATA = pg_dtm--1.0.sql
6+
7+
ifndefPG_CONFIG
8+
PG_CONFIG = pg_config
9+
endif
10+
11+
PGXS :=$(shell$(PG_CONFIG) --pgxs)
12+
include$(PGXS)
13+

‎README‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
===
2+
dtm
3+
===
4+
5+
Distributed transaction management tools for PostgreSQL.
6+
7+
--------------------
8+
Communication scheme
9+
--------------------
10+
11+
.- Backend -.
12+
/ \
13+
/ \
14+
DTM ---- Backend ---- Coordinator
15+
\ /
16+
\ /
17+
`- Backend -´
18+
19+
-----------------------
20+
Coordinator-Backend API
21+
-----------------------
22+
23+
This API includes a set of postgres procedures that
24+
the coordinator can call with "select" statement.
25+
26+
extend_transaction (n integer) -> (higcid gcid)
27+
join_transaction (higcid gcid) -> ()
28+
FIXME: add procedures that would start and finish 2pc
29+
30+
----------
31+
libdtm api
32+
----------
33+
34+
typedef unsigned long long cid_t;
35+
36+
// Connects to the specified DTM.
37+
DTMConn DtmConnect(char *host, int port);
38+
39+
// Disconnects from the DTM. Do not use the 'dtm' pointer after this call, or
40+
// bad things will happen.
41+
void DtmDisconnect(DTMConn dtm);
42+
43+
// Asks DTM for the first 'gcid' with unknown status. This 'gcid' is used as a
44+
// kind of snapshot. Returns the 'gcid' on success, or INVALID_GCID otherwise.
45+
cid_t DtmGlobalGetNextCid(DTMConn dtm);
46+
47+
// Prepares a commit. Returns the 'gcid' on success, or INVALID_GCID otherwise.
48+
cid_t DtmGlobalPrepare(DTMConn dtm);
49+
50+
// Finishes a given commit with 'committed' status. Returns 'true' on success,
51+
// 'false' otherwise.
52+
bool DtmGlobalCommit(DTMConn dtm, cid_t gcid);
53+
54+
// Finishes a given commit with 'aborted' status.
55+
void DtmGlobalRollback(DTMConn dtm, cid_t gcid);
56+
57+
// Gets the status of the commit identified by 'gcid'. Returns the status on
58+
// success, or -1 otherwise.
59+
int DtmGlobalGetTransStatus(DTMConn dtm, cid_t gcid);
60+
61+
--------------------
62+
Backend-DTM Protocol
63+
--------------------
64+
65+
DTM <--> Backend:
66+
67+
<- 'p'<hex16 self> - "prepare"
68+
-> '+'<hex16 gcid> - "commit prepared"
69+
-> '-' - "something went wrong"
70+
71+
<- 'c'<hex16 gcid> - "commit"
72+
-> '+' - "commit saved"
73+
-> '-' - "something went wrong"
74+
75+
<- 'a'<hex16 gcid> - "abort"
76+
-> '+' - "abort saved"
77+
-> '-' - "something went wrong"
78+
79+
<- 'h' - "horizon"
80+
-> '+'<hex16 gcid> - "here is a gcid you can use as a snapshot"
81+
-> '-' - "something went wrong"
82+
83+
<- 's'<hex16 gcid> - "status"
84+
-> '+''c|a|?' - "here is the transaction status"
85+
(c)ommitted, (a)borted or (?)unknown
86+
-> '-' - "something went wrong"
87+
88+
Backend disconnection is considered as an abort of all incomplete commits
89+
prepared by that backend.

‎pg_dtm--1.0.sql‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
2+
\echo Use"CREATE EXTENSION pg_dtm" to load this file. \quit
3+
4+
CREATEFUNCTIONdtm_extend(gtid cstring defaultnull) RETURNSbigint
5+
AS'MODULE_PATHNAME','dtm_extend'
6+
LANGUAGE C;
7+
8+
CREATEFUNCTIONdtm_access(snapshotbigint, gtid cstring defaultnull) RETURNSbigint
9+
AS'MODULE_PATHNAME','dtm_access'
10+
LANGUAGE C;
11+
12+
CREATEFUNCTIONdtm_begin_prepare(gtid cstring) RETURNS void
13+
AS'MODULE_PATHNAME','dtm_begin_prepare'
14+
LANGUAGE C;
15+
16+
CREATEFUNCTIONdtm_prepare(gtid cstring, csnbigint) RETURNSbigint
17+
AS'MODULE_PATHNAME','dtm_prepare'
18+
LANGUAGE C;
19+
20+
CREATEFUNCTIONdtm_end_prepare(gtid cstring, csnbigint) RETURNS void
21+
AS'MODULE_PATHNAME','dtm_end_prepare'
22+
LANGUAGE C;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp