-
Notifications
You must be signed in to change notification settings - Fork 89
Closed
Labels
Description
The Database Change Notification docs seem to indicate that transaction ID should be available on a change message. I would like to request this be plumbed through to the odpi layer (next I'll ask for it in cx_Oracle.
I see DPI_OCI_ATTR_CHDES_XID exists in the headers, so I've been stumbling around in the code seeing if it is populated.
/tmp/cx_Oracle/odpi ((v2.0.0))$ git diff
diff --git a/include/dpi.h b/include/dpi.h
index d8f8a60..6739766 100644
--- a/include/dpi.h
+++ b/include/dpi.h
@@ -587,6 +587,8 @@ struct dpiSubscrMessage {
dpiEventType eventType;
const char *dbName;
uint32_t dbNameLength;
+ const char *TxID;
+ uint32_t TxIDLength;
dpiSubscrMessageTable *tables;
uint32_t numTables;
dpiSubscrMessageQuery *queries;
diff --git a/src/dpiSubscr.c b/src/dpiSubscr.c
index e35c29d..8eb9cdc 100644
--- a/src/dpiSubscr.c
+++ b/src/dpiSubscr.c
@@ -289,6 +289,13 @@ static int dpiSubscr__populateMessage(dpiSubscr *subscr,
DPI_OCI_ATTR_CHDES_DBNAME, "get DB name", error) < 0)
return DPI_FAILURE;
+ // determine transaction id
+ if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_CHDES,
+ (void*) &message->TxID, &message->TxIDLength,
+ DPI_OCI_ATTR_CHDES_XID, "get transaction id", error) < 0)
+ return DPI_FAILURE;
+
+
// populate event specific attributes
switch (message->eventType) {
case DPI_EVENT_OBJCHANGE:This seems to give the transaction ID, but not quite correclty. For a transaxction ID of 4.22.470 I get back 0x80 0x00 0x00 0x00 THEN the transaction 0x04 0x00 0x16 0x00 0x68 0x04 0x00 0x00.
In other words if I look in message->TxID+4 I see what seem like a transaction ID.
So, any chance of getting this added, and any idea why my test returned a weird shifted result?