transaction object
This commit is contained in:
parent
622cdc3907
commit
82ad9a911b
|
@ -23,8 +23,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct STrans STrans;
|
||||||
} STrans;
|
|
||||||
|
|
||||||
int32_t trnInit();
|
int32_t trnInit();
|
||||||
void trnCleanup();
|
void trnCleanup();
|
||||||
|
@ -33,11 +32,11 @@ STrans *trnCreate();
|
||||||
int32_t trnCommit(STrans *);
|
int32_t trnCommit(STrans *);
|
||||||
void trnDrop(STrans *);
|
void trnDrop(STrans *);
|
||||||
|
|
||||||
void trnAppendRedoLog(STrans *, SSdbRawData *);
|
int32_t trnAppendRedoLog(STrans *, SSdbRawData *);
|
||||||
void trnAppendUndoLog(STrans *, SSdbRawData *);
|
int32_t trnAppendUndoLog(STrans *, SSdbRawData *);
|
||||||
void trnAppendCommitLog(STrans *, SSdbRawData *);
|
int32_t trnAppendCommitLog(STrans *, SSdbRawData *);
|
||||||
void trnAppendRedoAction(STrans *, SEpSet *, void *pMsg);
|
int32_t trnAppendRedoAction(STrans *, SEpSet *, void *pMsg);
|
||||||
void trnAppendUndoAction(STrans *, SEpSet *, void *pMsg);
|
int32_t trnAppendUndoAction(STrans *, SEpSet *, void *pMsg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "trn.h"
|
#include "trn.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
|
#include "tarray.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -32,6 +33,14 @@ extern "C" {
|
||||||
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }}
|
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }}
|
||||||
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }}
|
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }}
|
||||||
|
|
||||||
|
typedef struct STrans {
|
||||||
|
SArray *redoLogs;
|
||||||
|
SArray *undoLogs;
|
||||||
|
SArray *commitLogs;
|
||||||
|
SArray *redoActions;
|
||||||
|
SArray *undoActions;
|
||||||
|
} STrans;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,15 +16,78 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "trnInt.h"
|
#include "trnInt.h"
|
||||||
|
|
||||||
|
#define TRN_DEFAULT_ARRAY_SIZE 8
|
||||||
|
|
||||||
int32_t trnInit() { return 0; }
|
int32_t trnInit() { return 0; }
|
||||||
void trnCleanup();
|
void trnCleanup();
|
||||||
|
|
||||||
STrans *trnCreate() { return NULL; }
|
STrans *trnCreate() {
|
||||||
|
STrans *pTrans = calloc(1, sizeof(STrans));
|
||||||
|
if (pTrans == NULL) {
|
||||||
|
terrno = TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pTrans->redoLogs = taosArrayInit(TRN_DEFAULT_ARRAY_SIZE, sizeof(void *));
|
||||||
|
pTrans->undoLogs = taosArrayInit(TRN_DEFAULT_ARRAY_SIZE, sizeof(void *));
|
||||||
|
pTrans->commitLogs = taosArrayInit(TRN_DEFAULT_ARRAY_SIZE, sizeof(void *));
|
||||||
|
pTrans->redoActions = taosArrayInit(TRN_DEFAULT_ARRAY_SIZE, sizeof(void *));
|
||||||
|
pTrans->undoActions = taosArrayInit(TRN_DEFAULT_ARRAY_SIZE, sizeof(void *));
|
||||||
|
|
||||||
|
if (pTrans->redoLogs == NULL || pTrans->undoLogs == NULL || pTrans->commitLogs == NULL ||
|
||||||
|
pTrans->redoActions == NULL || pTrans->undoActions == NULL) {
|
||||||
|
taosArrayDestroy(pTrans->redoLogs);
|
||||||
|
taosArrayDestroy(pTrans->undoLogs);
|
||||||
|
taosArrayDestroy(pTrans->commitLogs);
|
||||||
|
taosArrayDestroy(pTrans->redoActions);
|
||||||
|
taosArrayDestroy(pTrans->undoActions);
|
||||||
|
free(pTrans);
|
||||||
|
terrno = TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pTrans;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t trnCommit(STrans *pTrans) { return 0; }
|
int32_t trnCommit(STrans *pTrans) { return 0; }
|
||||||
void trnDrop(STrans *pTrans) {}
|
void trnDrop(STrans *pTrans) {}
|
||||||
|
|
||||||
void trnAppendRedoLog(STrans *pTrans, SSdbRawData *pRaw) {}
|
int32_t trnAppendRedoLog(STrans *pTrans, SSdbRawData *pRaw) {
|
||||||
void trnAppendUndoLog(STrans *pTrans, SSdbRawData *pRaw) {}
|
void *ptr = taosArrayPush(pTrans->redoLogs, &pRaw);
|
||||||
void trnAppendCommitLog(STrans *pTrans, SSdbRawData *pRaw) {}
|
if (ptr == NULL) {
|
||||||
void trnAppendRedoAction(STrans *pTrans, SEpSet *pEpSet, void *pMsg) {}
|
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
void trnAppendUndoAction(STrans *pTrans, SEpSet *pEpSet, void *pMsg) {}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t trnAppendUndoLog(STrans *pTrans, SSdbRawData *pRaw) {
|
||||||
|
void *ptr = taosArrayPush(pTrans->undoLogs, &pRaw);
|
||||||
|
if (ptr == NULL) {
|
||||||
|
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t trnAppendCommitLog(STrans *pTrans, SSdbRawData *pRaw) {
|
||||||
|
void *ptr = taosArrayPush(pTrans->commitLogs, &pRaw);
|
||||||
|
if (ptr == NULL) {
|
||||||
|
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t trnAppendRedoAction(STrans *pTrans, SEpSet *pEpSet, void *pMsg) {
|
||||||
|
void *ptr = taosArrayPush(pTrans->redoActions, &pMsg);
|
||||||
|
if (ptr == NULL) {
|
||||||
|
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t trnAppendUndoAction(STrans *pTrans, SEpSet *pEpSet, void *pMsg) {
|
||||||
|
void *ptr = taosArrayPush(pTrans->undoActions, &pMsg);
|
||||||
|
if (ptr == NULL) {
|
||||||
|
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue