34 #include "lixa_trace.h"
35 #include "liblixapq.h"
42 #ifdef LIXA_TRACE_MODULE
43 # undef LIXA_TRACE_MODULE
45 #define LIXA_TRACE_MODULE LIXA_TRACE_MOD_XTA
70 PGconn *connection,
const char *
name,
const char *open_info)
72 enum Exception { G_TRY_MALLOC_ERROR
73 , XTA_POSTGRESQL_XA_RESOURCE_INIT_ERROR
78 LIXA_TRACE((
"xta_postgresql_xa_resource_new\n"));
83 THROW(G_TRY_MALLOC_ERROR);
86 this, connection, name, open_info)))
87 THROW(XTA_POSTGRESQL_XA_RESOURCE_INIT_ERROR);
92 case G_TRY_MALLOC_ERROR:
95 case XTA_POSTGRESQL_XA_RESOURCE_INIT_ERROR:
104 LIXA_TRACE((
"xta_postgresql_xa_resource_new/excp=%d/"
105 "ret_cod=%d/errno=%d\n", excp, ret_cod, errno));
114 enum Exception { NONE } excp;
117 LIXA_TRACE((
"xta_postgresql_xa_resource_delete\n"));
134 LIXA_TRACE((
"xta_postgresql_xa_resource_delete/excp=%d/"
135 "ret_cod=%d/errno=%d\n", excp, ret_cod, errno));
143 PGconn *connection,
const char *
name,
const char *open_info)
145 enum Exception { XTA_ACQUIRED_XA_RESOURCE_INIT_ERROR
149 LIXA_TRACE((
"xta_postgresql_xa_resource_init\n"));
154 &xta_postgresql_iface,
156 THROW(XTA_ACQUIRED_XA_RESOURCE_INIT_ERROR);
164 memset(&xa_resource->
lssr, 0,
sizeof(
struct lixa_sw_status_rm_s));
169 case XTA_ACQUIRED_XA_RESOURCE_INIT_ERROR:
178 LIXA_TRACE((
"xta_postgresql_xa_resource_init/excp=%d/"
179 "ret_cod=%d/errno=%d\n", excp, ret_cod, errno));
187 enum Exception { NONE } excp;
190 LIXA_TRACE((
"xta_postgresql_xa_resource_clean\n"));
208 LIXA_TRACE((
"xta_postgresql_xa_resource_clean/excp=%d/"
209 "ret_cod=%d/errno=%d\n", excp, ret_cod, errno));
216 int rmid,
long flags)
218 enum Exception { OBJ_CORRUPTED
222 LIXA_TRACE((
"xta_postgresql_xa_open\n"));
226 if (NULL != this->connection) {
227 LIXA_TRACE((
"xta_postgresql_xa_open: PostgreSQL connection is "
228 "already open (%p)\n", this->connection));
230 LIXA_TRACE((
"xta_postgresql_xa_open: PostgreSQL connection is "
232 THROW(OBJ_CORRUPTED);
236 this->lssr.rmid = rmid;
237 this->lssr.rm_type = LIXA_SW_STATUS_RM_TYPE_POSTGRESQL;
238 this->lssr.state.R = 1;
239 this->lssr.conn = (gpointer)this->connection;
253 LIXA_TRACE((
"xta_postgresql_xa_open/excp=%d/"
254 "ret_cod=%d/errno=%d\n", excp, ret_cod, errno));
261 int rmid,
long flags)
263 enum Exception { OBJ_CORRUPTED
267 LIXA_TRACE((
"xta_postgresql_xa_close\n"));
271 if (NULL != this->connection) {
272 LIXA_TRACE((
"xta_postgresql_xa_close: PostgreSQL connection (%p) "
273 "must be closed by the Application Program\n",
276 LIXA_TRACE((
"xta_postgresql_xa_close: PostgreSQL connection is "
278 THROW(OBJ_CORRUPTED);
293 LIXA_TRACE((
"xta_postgresql_xa_close/excp=%d/"
294 "ret_cod=%d/errno=%d\n", excp, ret_cod, errno));
301 int rmid,
long flags)
303 enum Exception { OBJ_CORRUPTED
307 LIXA_TRACE((
"xta_postgresql_xa_start\n"));
311 if (NULL == this->connection) {
312 LIXA_TRACE((
"xta_postgresql_xa_start: PostgreSQL connection is "
314 THROW(OBJ_CORRUPTED);
317 ret_cod = lixa_pq_start_core(&this->lssr, xid, rmid, flags);
330 LIXA_TRACE((
"xta_postgresql_xa_start/excp=%d/"
331 "ret_cod=%d/errno=%d\n", excp, ret_cod, errno));
338 int rmid,
long flags)
340 enum Exception { OBJ_CORRUPTED
344 LIXA_TRACE((
"xta_postgresql_xa_end\n"));
348 if (NULL == this->connection) {
349 LIXA_TRACE((
"xta_postgresql_xa_end: PostgreSQL connection is "
351 THROW(OBJ_CORRUPTED);
354 ret_cod = lixa_pq_end_core(&this->lssr, xid, rmid, flags);
367 LIXA_TRACE((
"xta_postgresql_xa_end/excp=%d/"
368 "ret_cod=%d/errno=%d\n", excp, ret_cod, errno));
376 int rmid,
long flags)
378 enum Exception { OBJ_CORRUPTED
382 LIXA_TRACE((
"xta_postgresql_xa_rollback\n"));
386 if (NULL == this->connection) {
387 LIXA_TRACE((
"xta_postgresql_xa_rollback: PostgreSQL connection is "
389 THROW(OBJ_CORRUPTED);
392 ret_cod = lixa_pq_rollback_core(&this->lssr, xid, rmid, flags);
405 LIXA_TRACE((
"xta_postgresql_xa_rollback/excp=%d/"
406 "ret_cod=%d/errno=%d\n", excp, ret_cod, errno));
413 int rmid,
long flags)
415 enum Exception { OBJ_CORRUPTED
419 LIXA_TRACE((
"xta_postgresql_xa_prepare\n"));
423 if (NULL == this->connection) {
424 LIXA_TRACE((
"xta_postgresql_xa_prepare: PostgreSQL connection is "
426 THROW(OBJ_CORRUPTED);
429 ret_cod = lixa_pq_prepare_core(&this->lssr, xid, rmid, flags);
442 LIXA_TRACE((
"xta_postgresql_xa_prepare/excp=%d/"
443 "ret_cod=%d/errno=%d\n", excp, ret_cod, errno));
450 int rmid,
long flags)
452 enum Exception { OBJ_CORRUPTED
456 LIXA_TRACE((
"xta_postgresql_xa_commit\n"));
460 if (NULL == this->connection) {
461 LIXA_TRACE((
"xta_postgresql_xa_commit: PostgreSQL connection is "
463 THROW(OBJ_CORRUPTED);
466 ret_cod = lixa_pq_commit_core(&this->lssr, xid, rmid, flags);
479 LIXA_TRACE((
"xta_postgresql_xa_commit/excp=%d/"
480 "ret_cod=%d/errno=%d\n", excp, ret_cod, errno));
487 XID *xids,
long count,
int rmid,
long flags)
489 enum Exception { OBJ_CORRUPTED
493 LIXA_TRACE((
"xta_postgresql_xa_recover\n"));
497 if (NULL == this->connection) {
498 LIXA_TRACE((
"xta_postgresql_xa_recover: PostgreSQL connection is "
500 THROW(OBJ_CORRUPTED);
503 ret_cod = lixa_pq_recover_core(&this->lssr, xids, count, rmid, flags);
516 LIXA_TRACE((
"xta_postgresql_xa_recover/excp=%d/"
517 "ret_cod=%d/errno=%d\n", excp, ret_cod, errno));
524 int rmid,
long flags)
526 enum Exception { OBJ_CORRUPTED
530 LIXA_TRACE((
"xta_postgresql_xa_forget\n"));
534 if (NULL == this->connection) {
535 LIXA_TRACE((
"xta_postgresql_xa_forget: PostgreSQL connection is "
537 THROW(OBJ_CORRUPTED);
540 ret_cod = lixa_pq_forget_core(&this->lssr, xid, rmid, flags);
553 LIXA_TRACE((
"xta_postgresql_xa_forget/excp=%d/"
554 "ret_cod=%d/errno=%d\n", excp, ret_cod, errno));
void xta_postgresql_xa_resource_delete(xta_postgresql_xa_resource_t *xa_resource)
xta_postgresql_xa_resource_t * xta_postgresql_xa_resource_new(PGconn *connection, const char *name, const char *open_info)
#define LIXA_RC_INTERNAL_ERROR
int xta_postgresql_xa_close(xta_xa_resource_t *context, char *xa_info, int rmid, long flags)
void xta_acquired_xa_resource_clean(xta_acquired_xa_resource_t *xa_resource)
int xta_postgresql_xa_end(xta_xa_resource_t *context, const XID *xid, int rmid, long flags)
void xta_postgresql_xa_resource_clean(xta_postgresql_xa_resource_t *xa_resource)
int xta_postgresql_xa_prepare(xta_xa_resource_t *context, const XID *xid, int rmid, long flags)
int xta_postgresql_xa_resource_init(xta_postgresql_xa_resource_t *xa_resource, PGconn *connection, const char *name, const char *open_info)
int xta_postgresql_xa_recover(xta_xa_resource_t *context, XID *xids, long count, int rmid, long flags)
struct lixa_sw_status_rm_s lssr
#define LIXA_RC_G_TRY_MALLOC_ERROR
void lixa_iface_set_xta(lixa_iface_t *iface, const struct xta_iface_s *xta, xta_xa_resource_t *context)
int xta_postgresql_xa_commit(xta_xa_resource_t *context, const XID *xid, int rmid, long flags)
int xta_postgresql_xa_forget(xta_xa_resource_t *context, const XID *xid, int rmid, long flags)
struct act_rsrmgr_config_s act_rsrmgr_config
int xta_acquired_xa_resource_init(xta_acquired_xa_resource_t *xa_resource, const struct xta_iface_s *iface, const char *name, const char *open_info)
xta_xa_resource_t xa_resource
int xta_postgresql_xa_start(xta_xa_resource_t *context, const XID *xid, int rmid, long flags)
static const struct xta_iface_s xta_postgresql_iface
int xta_postgresql_xa_rollback(xta_xa_resource_t *context, const XID *xid, int rmid, long flags)
int xta_postgresql_xa_open(xta_xa_resource_t *context, char *xa_info, int rmid, long flags)