add show command
parent
2f5eb0ed4f
commit
7ace2a63d2
BIN
demo/create
BIN
demo/create
Binary file not shown.
|
@ -15,13 +15,13 @@ typedef struct __TBL_USER_INFO
|
||||||
|
|
||||||
CREATE lCreateUserInfo()
|
CREATE lCreateUserInfo()
|
||||||
{
|
{
|
||||||
DEFINE(TBL_USER_INFO, "TBL_USER_INFO", "", dbUser)
|
DEFINE(TBL_USER_INFO, "", dbUser)
|
||||||
FIELD(dbUser, acct_id, "acct_id", FIELD_LONG)
|
FIELD(dbUser, acct_id, FIELD_LONG)
|
||||||
FIELD(dbUser, user_no, "user_no", FIELD_CHAR)
|
FIELD(dbUser, user_no, FIELD_CHAR)
|
||||||
FIELD(dbUser, user_type, "user_type", FIELD_CHAR)
|
FIELD(dbUser, user_type, FIELD_CHAR)
|
||||||
FIELD(dbUser, user_nm, "user_nm", FIELD_CHAR)
|
FIELD(dbUser, user_nm, FIELD_CHAR)
|
||||||
FIELD(dbUser, user_addr, "user_addr", FIELD_CHAR)
|
FIELD(dbUser, user_addr, FIELD_CHAR)
|
||||||
FIELD(dbUser, user_phone, "user_phone", FIELD_CHAR)
|
FIELD(dbUser, user_phone, FIELD_CHAR)
|
||||||
|
|
||||||
CREATE_IDX(NORMAL) // 创建查询索引
|
CREATE_IDX(NORMAL) // 创建查询索引
|
||||||
IDX_FIELD(dbUser, acct_id, FIELD_LONG)
|
IDX_FIELD(dbUser, acct_id, FIELD_LONG)
|
||||||
|
|
|
@ -125,6 +125,7 @@ extern long lTvmInsert(SATvm *pstSavm);
|
||||||
extern long lTvmSelect(SATvm *pstSavm, void *pvOut);
|
extern long lTvmSelect(SATvm *pstSavm, void *pvOut);
|
||||||
extern long lTvmQuery(SATvm *pstSavm, size_t *plOut, void **ppvOut);
|
extern long lTvmQuery(SATvm *pstSavm, size_t *plOut, void **ppvOut);
|
||||||
extern long lTvmUpdate(SATvm *pstSavm, void *pvData);
|
extern long lTvmUpdate(SATvm *pstSavm, void *pvData);
|
||||||
|
extern long lTvmReplace(SATvm *pstSavm, void *pvData);
|
||||||
extern long lTvmDelete(SATvm *pstSavm);
|
extern long lTvmDelete(SATvm *pstSavm);
|
||||||
extern long lTvmExtreme(SATvm *pstSavm, void *pvOut);
|
extern long lTvmExtreme(SATvm *pstSavm, void *pvOut);
|
||||||
extern long lTvmDropTable(SATvm *pstSavm, TABLE t);
|
extern long lTvmDropTable(SATvm *pstSavm, TABLE t);
|
||||||
|
@ -138,6 +139,7 @@ extern long lTvmResetLock(SATvm *pstSavm, TABLE t);
|
||||||
extern long lAsyInsert(SATvm *pstSavm);
|
extern long lAsyInsert(SATvm *pstSavm);
|
||||||
extern long lAsyDelete(SATvm *pstSavm);
|
extern long lAsyDelete(SATvm *pstSavm);
|
||||||
extern long lAsyUpdate(SATvm *pstSavm, void *pvData);
|
extern long lAsyUpdate(SATvm *pstSavm, void *pvData);
|
||||||
|
extern long lAsyReplace(SATvm *pstSavm, void *pvData);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -70,7 +70,9 @@ typedef long CREATE;
|
||||||
#define OPERAYS_INSERT 1025
|
#define OPERAYS_INSERT 1025
|
||||||
#define OPERAYS_DELETE 1026
|
#define OPERAYS_DELETE 1026
|
||||||
#define OPERAYS_UPDATE 1027
|
#define OPERAYS_UPDATE 1027
|
||||||
|
#define OPERATS_REPLACE 1028
|
||||||
|
|
||||||
|
#define OPERATE_REPLACE 13
|
||||||
#define OPERATE_TRCATE 14
|
#define OPERATE_TRCATE 14
|
||||||
#define OPERATE_COUNT 15
|
#define OPERATE_COUNT 15
|
||||||
#define OPERATE_GROUP 16
|
#define OPERATE_GROUP 16
|
||||||
|
@ -295,21 +297,21 @@ typedef long CREATE;
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
创建表宏函数
|
创建表宏函数
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
#define DEFINE(t, n, p, s) TABLE tbl = t; long type = 0; \
|
#define DEFINE(t, p, s) TABLE tbl = t; long type = 0; \
|
||||||
((TblDef *)pGetTblDef(t))->m_table = t; \
|
((TblDef *)pGetTblDef(t))->m_table = t; \
|
||||||
((TblDef *)pGetTblDef(t))->m_lReSize = sizeof(s); \
|
((TblDef *)pGetTblDef(t))->m_lReSize = sizeof(s); \
|
||||||
strncpy(((TblDef *)pGetTblDef(t))->m_szPart, p, MAX_FIELD_LEN); \
|
strncpy(((TblDef *)pGetTblDef(t))->m_szPart, p, MAX_FIELD_LEN); \
|
||||||
strncpy(((TblDef *)pGetTblDef(t))->m_szTable, n, MAX_FIELD_LEN); \
|
strncpy(((TblDef *)pGetTblDef(t))->m_szTable, #t, MAX_FIELD_LEN); \
|
||||||
((TblDef *)pGetTblDef(t))->m_lTruck = sizeof(s) + sizeof(SHTruck);
|
((TblDef *)pGetTblDef(t))->m_lTruck = sizeof(s) + sizeof(SHTruck);
|
||||||
|
|
||||||
#define CREATE_IDX(t) type = t;
|
#define CREATE_IDX(t) type = t;
|
||||||
#define IDX_FIELD(t, f, a) if(RC_SUCC != lAddIdxField(tbl, type, FPOS(t, f), FLEN(t, f), a)) \
|
#define IDX_FIELD(t, f, a) if(RC_SUCC != lAddIdxField(tbl, type, FPOS(t, f), FLEN(t, f), a, #f)) \
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
#define FIELD(t, f, d, a) if(RC_SUCC != lSetTableIdx(tbl, FPOS(t, f), FLEN(t, f), d, a, CHK_SELECT)) \
|
#define FIELD(t, f, a) if(RC_SUCC != lSetTableIdx(tbl, FPOS(t, f), FLEN(t, f), #f, a, CHK_SELECT)) \
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
#define FIELU(t, f, d, a) if(RC_SUCC != lSetTableIdx(tbl, FPOS(t, f), FLEN(t, f), d, a, IDX_SELECT)) \
|
#define FIELU(t, f, a) if(RC_SUCC != lSetTableIdx(tbl, FPOS(t, f), FLEN(t, f), #f, a, IDX_SELECT)) \
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
#define FIELR(t, f, d, a) if(RC_SUCC != lSetTableIdx(tbl, FPOS(t, f), FLEN(t, f), d, a, RCD_SELECT)) \
|
#define FIELR(t, f, a) if(RC_SUCC != lSetTableIdx(tbl, FPOS(t, f), FLEN(t, f), #f, a, RCD_SELECT)) \
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
#define FINISH return RC_SUCC;
|
#define FINISH return RC_SUCC;
|
||||||
|
|
||||||
|
@ -696,7 +698,7 @@ extern void* pInitHitTest(SATvm *pstSavm, TABLE t);
|
||||||
extern long lTableMaxRow(SATvm *pstSavm, TABLE t);
|
extern long lTableMaxRow(SATvm *pstSavm, TABLE t);
|
||||||
extern key_t yGetIPCPath(SATvm *pstSavm, Benum em);
|
extern key_t yGetIPCPath(SATvm *pstSavm, Benum em);
|
||||||
extern long lGetBootConfig(SATvm *pstSavm, TBoot *pstBoot);
|
extern long lGetBootConfig(SATvm *pstSavm, TBoot *pstBoot);
|
||||||
extern long lAddIdxField(TABLE, long, long, long, long);
|
extern long lAddIdxField(TABLE, long, long, long, long, const char *);
|
||||||
extern long lSetTableIdx(TABLE, long, long, char*, long, long);
|
extern long lSetTableIdx(TABLE, long, long, char*, long, long);
|
||||||
extern long lUpdIndexPart(SATvm *pstSavm, TABLE t, char *pszPart);
|
extern long lUpdIndexPart(SATvm *pstSavm, TABLE t, char *pszPart);
|
||||||
extern TblKey* pFindField(TblKey *pstIdx, long lNum, char *pszField);
|
extern TblKey* pFindField(TblKey *pstIdx, long lNum, char *pszField);
|
||||||
|
|
16
src/stvm.c
16
src/stvm.c
|
@ -4186,8 +4186,7 @@ void vSetHistory()
|
||||||
**************************************************************************************************/
|
**************************************************************************************************/
|
||||||
void vCustomization(SATvm *pstSavm, char *s)
|
void vCustomization(SATvm *pstSavm, char *s)
|
||||||
{
|
{
|
||||||
strimall(s);
|
sltrim(s);
|
||||||
strimcrlf(s);
|
|
||||||
|
|
||||||
if(!strcasecmp(s, "debug on"))
|
if(!strcasecmp(s, "debug on"))
|
||||||
g_stCustom.m_eDebug = 1;
|
g_stCustom.m_eDebug = 1;
|
||||||
|
@ -4307,16 +4306,15 @@ void vInitialCustom()
|
||||||
if(NULL == g_stCustom.m_pszKey || NULL == g_stCustom.m_pszWord)
|
if(NULL == g_stCustom.m_pszKey || NULL == g_stCustom.m_pszWord)
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
|
||||||
snprintf(g_stCustom.m_pszKey, ALLOC_CMD_LEN, "SELECT,INSERT,"
|
snprintf(g_stCustom.m_pszKey, ALLOC_CMD_LEN, "SELECT,INSERT,UPDATE,DELETE,DROP,RENAME,"
|
||||||
"UPDATE,DELETE,DROP,RENAME,TRUNCATE,REPLACE,CLEAR,EXIT,CREATE,BEGIN WORK,"
|
"TRUNCATE,REPLACE,CLEAR,EXIT,CREATE,BEGIN WORK,END WORK,COMMIT WORK,ROLLBACK WORK,"
|
||||||
"END WORK,COMMIT WORK,ROLLBACK WORK,SHOW,COMMENT,LOAD,UNLOAD,SET,");
|
"SHOW,COMMENT,LOAD,UNLOAD,SET,");
|
||||||
g_stCustom.m_lKey = lgetstrnum(g_stCustom.m_pszKey, ",");
|
g_stCustom.m_lKey = lgetstrnum(g_stCustom.m_pszKey, ",");
|
||||||
|
|
||||||
//select nextval from SEQUENCE@SEQ_TEST
|
//select nextval from SEQUENCE@SEQ_TEST
|
||||||
snprintf(g_stCustom.m_pszWord, ALLOC_CMD_LEN, "SET,FROM,WHERE,"
|
snprintf(g_stCustom.m_pszWord, ALLOC_CMD_LEN, "SET,FROM,WHERE,COUNT(1),MAX,MIN,NEXTVAL,"
|
||||||
"COUNT(1),MAX,MIN,NEXTVAL,ORDER BY,GROUP BY,SEQUENCE@,SYS_TVM_FIELD,"
|
"ORDER BY,GROUP BY,SEQUENCE@,SYS_TVM_FIELD,SYS_TVM_DOMAIN,SYS_TVM_SEQUE,TABLE,INTO,"
|
||||||
"SYS_TVM_DOMAIN,SYS_TVM_SEQUE,TABLES,INTO,INFO,INDEX,VALUES,DEBUG [ON|OFF],"
|
"ON,INFO,INDEX,VALUES,DEBUG [ON|OFF],SHOWMODE [ROW|COLUMN],SHOWSIZE [NUM],");
|
||||||
"SHOWMODE [ROW|COLUMN],SHOWSIZE [NUM],");
|
|
||||||
g_stCustom.m_lWord = lgetstrnum(g_stCustom.m_pszWord, ",");
|
g_stCustom.m_lWord = lgetstrnum(g_stCustom.m_pszWord, ",");
|
||||||
|
|
||||||
rl_attempted_completion_function = pMatchCompletion;
|
rl_attempted_completion_function = pMatchCompletion;
|
||||||
|
|
218
src/tcp.c
218
src/tcp.c
|
@ -1358,6 +1358,7 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
|
||||||
lSendBuffer(pstCon->m_skSock, pvOut, lData);
|
lSendBuffer(pstCon->m_skSock, pvOut, lData);
|
||||||
TFree(pvOut);
|
TFree(pvOut);
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
|
case OPERATE_REPLACE:
|
||||||
case OPERATE_UPDATE:
|
case OPERATE_UPDATE:
|
||||||
pstSavm->m_bWork = pstCon->m_bWork;
|
pstSavm->m_bWork = pstCon->m_bWork;
|
||||||
pstSavm->m_pstWork = pstCon->m_pstWork;
|
pstSavm->m_pstWork = pstCon->m_pstWork;
|
||||||
|
@ -1378,6 +1379,7 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
|
||||||
lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace));
|
lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace));
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
|
|
||||||
|
case OPERATS_REPLACE:
|
||||||
case OPERAYS_UPDATE:
|
case OPERAYS_UPDATE:
|
||||||
pstSavm->m_bWork = pstCon->m_bWork;
|
pstSavm->m_bWork = pstCon->m_bWork;
|
||||||
pstSavm->m_pstWork = pstCon->m_pstWork;
|
pstSavm->m_pstWork = pstCon->m_pstWork;
|
||||||
|
@ -3180,6 +3182,94 @@ long _lUpdateByRt(SATvm *pstSavm, void *pvUpdate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************
|
||||||
|
description:remote - Replace
|
||||||
|
parameters:
|
||||||
|
pstSavm --stvm handle
|
||||||
|
psvUpdate --update
|
||||||
|
return:
|
||||||
|
RC_SUCC --success
|
||||||
|
RC_FAIL --failure
|
||||||
|
*************************************************************************************************/
|
||||||
|
long _lReplaceByRt(SATvm *pstSavm, void *pvReplace)
|
||||||
|
{
|
||||||
|
TDomain *pvm, *pnoe;
|
||||||
|
long lRet = RC_FAIL;
|
||||||
|
Rowgrp *list = NULL, *node = NULL;
|
||||||
|
|
||||||
|
if(NULL == (node = pGetTblNode(pstSavm->tblName)))
|
||||||
|
{
|
||||||
|
pstSavm->m_lErrno = DOM_NOT_INITL;
|
||||||
|
return RC_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pstSavm->m_lErrno = RESOU_DISABLE;
|
||||||
|
switch(lGetBootType())
|
||||||
|
{
|
||||||
|
case TVM_BOOT_CLUSTER:
|
||||||
|
for(list = node->pstSSet; list; list = list->pstNext)
|
||||||
|
{
|
||||||
|
if(!list->pstFset)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(NULL == (pvm = (TDomain *)(list->pstFset->psvData)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
pnoe = (TDomain *)list->psvData;
|
||||||
|
if(0 == (OPERATE_UPDATE & pnoe->m_lPers) || 0 == (OPERATE_INSERT & pnoe->m_lPers)
|
||||||
|
|| RESOURCE_ABLE != pvm->m_lStatus)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
pstSavm->m_skSock = pvm->m_skSock;
|
||||||
|
pstSavm->tblName = pnoe->m_mtable;
|
||||||
|
pthread_mutex_lock(&list->pstFset->lock);
|
||||||
|
if(RC_SUCC == lTvmReplace(pstSavm, pvReplace))
|
||||||
|
{
|
||||||
|
lRet = RC_SUCC;
|
||||||
|
pvm->m_lTryTimes = 0;
|
||||||
|
pvm->m_lLastTime = time(NULL);
|
||||||
|
}
|
||||||
|
else if(SOCK_COM_EXCP == pstSavm->m_lErrno)
|
||||||
|
{
|
||||||
|
pnoe->m_lRelia --;
|
||||||
|
Tlog("Update err: %s, T(%d), F(%s:%d), R(%d)", sGetTError(pstSavm->m_lErrno),
|
||||||
|
pstSavm->tblName, pvm->m_szIp, pvm->m_lPort, pnoe->m_lRelia);
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&list->pstFset->lock);
|
||||||
|
}
|
||||||
|
return lRet;
|
||||||
|
default:
|
||||||
|
for(list = node->pstSSet; list; list = list->pstNext)
|
||||||
|
{
|
||||||
|
if(NULL == (pvm = (TDomain *)(list->psvData)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(0 == (OPERATE_UPDATE & pnoe->m_lPers) || 0 == (OPERATE_INSERT & pnoe->m_lPers))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(RC_SUCC != lTvmConnect(pstSavm, pvm->m_szIp, pvm->m_lPort, pvm->m_lTimeOut))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
pstSavm->tblName = pvm->m_mtable;
|
||||||
|
lRet = lTvmReplace(pstSavm, pvReplace);
|
||||||
|
if(RC_SUCC == lRet || SOCK_COM_EXCP != pstSavm->m_lErrno)
|
||||||
|
{
|
||||||
|
close(pstSavm->m_skSock);
|
||||||
|
((RunTime *)pGetRunTime(pstSavm, 0))->m_lRowSize = 0;
|
||||||
|
TFree(((RunTime *)pGetRunTime(pstSavm, 0))->pstVoid);
|
||||||
|
return lRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
close(pstSavm->m_skSock);
|
||||||
|
}
|
||||||
|
|
||||||
|
((RunTime *)pGetRunTime(pstSavm, 0))->m_lRowSize = 0;
|
||||||
|
TFree(((RunTime *)pGetRunTime(pstSavm, 0))->pstVoid);
|
||||||
|
return lRet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
description:remote - Group
|
description:remote - Group
|
||||||
parameters:
|
parameters:
|
||||||
|
@ -3597,6 +3687,7 @@ void* pProtocaJava(SATvm *pstSavm, void *pstVoid, TFace *pstFace, void *pvBuf
|
||||||
{
|
{
|
||||||
case OPERATE_INSERT:
|
case OPERATE_INSERT:
|
||||||
return pvBuffer;
|
return pvBuffer;
|
||||||
|
case OPERATE_REPLACE:
|
||||||
case OPERATE_UPDATE:
|
case OPERATE_UPDATE:
|
||||||
pstCond = &pstSavm->stUpdt;
|
pstCond = &pstSavm->stUpdt;
|
||||||
pstCond->uFldcmp = 0;
|
pstCond->uFldcmp = 0;
|
||||||
|
@ -3731,6 +3822,8 @@ void* pParsePacket(SATvm *pstSavm, void *pstVoid, TFace *pstFace, void *pvBuf
|
||||||
return memcpy(pstVoid, pvData, pstFace->m_lDLen);
|
return memcpy(pstVoid, pvData, pstFace->m_lDLen);
|
||||||
case OPERAYS_UPDATE:
|
case OPERAYS_UPDATE:
|
||||||
case OPERATE_UPDATE:
|
case OPERATE_UPDATE:
|
||||||
|
case OPERATS_REPLACE:
|
||||||
|
case OPERATE_REPLACE:
|
||||||
memcpy(&pstCond->uFldcmp, pvData, sizeof(uint));
|
memcpy(&pstCond->uFldcmp, pvData, sizeof(uint));
|
||||||
for(i = 0, pvData += sizeof(uint); i < pstCond->uFldcmp; i ++)
|
for(i = 0, pvData += sizeof(uint); i < pstCond->uFldcmp; i ++)
|
||||||
{
|
{
|
||||||
|
@ -4098,6 +4191,63 @@ long lAsyUpdate(SATvm *pstSavm, void *pvData)
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************
|
||||||
|
description:API - replace by asynch
|
||||||
|
parameters:
|
||||||
|
pstSavm --stvm handle
|
||||||
|
pvData --update data
|
||||||
|
return:
|
||||||
|
RC_SUCC --success
|
||||||
|
RC_FAIL --failure
|
||||||
|
*************************************************************************************************/
|
||||||
|
long lAsyReplace(SATvm *pstSavm, void *pvData)
|
||||||
|
{
|
||||||
|
RunTime *pstRun;
|
||||||
|
FdCond *pstCond;
|
||||||
|
TFace *pstFace;
|
||||||
|
uint lWrite = sizeof(TFace);
|
||||||
|
|
||||||
|
if(!pstSavm || !pvData)
|
||||||
|
{
|
||||||
|
pstSavm->m_lErrno = CONDIT_IS_NIL;
|
||||||
|
return RC_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pstRun = (RunTime *)pGetRunTime(pstSavm, 0);
|
||||||
|
if(!pstRun->pstVoid)
|
||||||
|
{
|
||||||
|
pstSavm->m_lErrno = DOM_NOT_INITL;
|
||||||
|
return RC_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pstFace = (TFace *)pstRun->pstVoid;
|
||||||
|
pstFace->m_lFind = pstSavm->lFind;
|
||||||
|
pstFace->m_lDLen = pstSavm->lSize;
|
||||||
|
pstFace->m_lErrno = TVM_DONE_SUCC;
|
||||||
|
pstFace->m_enum = OPERATS_REPLACE;
|
||||||
|
pstFace->m_table = pstSavm->tblName;
|
||||||
|
|
||||||
|
checkbuffer(pstSavm, pstRun, 2);
|
||||||
|
pstCond = &pstSavm->stUpdt;
|
||||||
|
if(0 == pstCond->uFldcmp)
|
||||||
|
{
|
||||||
|
pstSavm->m_lErrno = UPDFD_NOT_SET;
|
||||||
|
return RC_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
vBuildPacket(pstRun->pstVoid, pstSavm->pstVoid, &pstSavm->stCond, &lWrite);
|
||||||
|
vBuildPacket(pstRun->pstVoid, pvData, pstCond, &lWrite);
|
||||||
|
pstFace->m_lRows = lWrite - sizeof(TFace);
|
||||||
|
|
||||||
|
if(lWrite != lSendBuffer(pstSavm->m_skSock, (void *)pstRun->pstVoid, lWrite))
|
||||||
|
{
|
||||||
|
pstSavm->m_lErrno = SOCK_COM_EXCP;
|
||||||
|
return RC_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RC_SUCC;
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
description:API - insert by asynch
|
description:API - insert by asynch
|
||||||
parameters:
|
parameters:
|
||||||
|
@ -4332,6 +4482,74 @@ long lTvmUpdate(SATvm *pstSavm, void *pvData)
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************
|
||||||
|
description:API - update
|
||||||
|
parameters:
|
||||||
|
pstSavm --stvm handle
|
||||||
|
pvData --update data
|
||||||
|
return:
|
||||||
|
RC_SUCC --success
|
||||||
|
RC_FAIL --failure
|
||||||
|
*************************************************************************************************/
|
||||||
|
long lTvmReplace(SATvm *pstSavm, void *pvData)
|
||||||
|
{
|
||||||
|
RunTime *pstRun;
|
||||||
|
FdCond *pstCond;
|
||||||
|
TFace *pstFace;
|
||||||
|
uint lWrite = sizeof(TFace);
|
||||||
|
|
||||||
|
if(!pstSavm || !pvData)
|
||||||
|
{
|
||||||
|
pstSavm->m_lErrno = CONDIT_IS_NIL;
|
||||||
|
return RC_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pstRun = (RunTime *)pGetRunTime(pstSavm, 0);
|
||||||
|
if(!pstRun->pstVoid)
|
||||||
|
{
|
||||||
|
pstSavm->m_lErrno = DOM_NOT_INITL;
|
||||||
|
return RC_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pstFace = (TFace *)pstRun->pstVoid;
|
||||||
|
pstFace->m_lFind = pstSavm->lFind;
|
||||||
|
pstFace->m_lDLen = pstSavm->lSize;
|
||||||
|
pstFace->m_lErrno = TVM_DONE_SUCC;
|
||||||
|
pstFace->m_enum = OPERATE_REPLACE;
|
||||||
|
pstFace->m_table = pstSavm->tblName;
|
||||||
|
|
||||||
|
checkbuffer(pstSavm, pstRun, 2);
|
||||||
|
pstCond = &pstSavm->stUpdt;
|
||||||
|
if(0 == pstCond->uFldcmp)
|
||||||
|
{
|
||||||
|
pstSavm->m_lErrno = UPDFD_NOT_SET;
|
||||||
|
return RC_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
vBuildPacket(pstRun->pstVoid, pstSavm->pstVoid, &pstSavm->stCond, &lWrite);
|
||||||
|
vBuildPacket(pstRun->pstVoid, pvData, pstCond, &lWrite);
|
||||||
|
pstFace->m_lRows = lWrite - sizeof(TFace);
|
||||||
|
|
||||||
|
if(lWrite != lSendBuffer(pstSavm->m_skSock, (void *)pstRun->pstVoid, lWrite))
|
||||||
|
{
|
||||||
|
pstSavm->m_lErrno = SOCK_COM_EXCP;
|
||||||
|
return RC_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(sizeof(TFace) != lRecvBuffer(pstSavm->m_skSock, (char *)pstRun->pstVoid, sizeof(TFace)))
|
||||||
|
{
|
||||||
|
pstSavm->m_lErrno = SOCK_COM_EXCP;
|
||||||
|
return RC_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pstSavm->m_lErrno = ((TFace *)pstRun->pstVoid)->m_lErrno;
|
||||||
|
if(0 != pstSavm->m_lErrno)
|
||||||
|
return RC_FAIL;
|
||||||
|
|
||||||
|
pstSavm->m_lEffect = ((TFace *)pstRun->pstVoid)->m_lRows;
|
||||||
|
return RC_SUCC;
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
description:API - truncate
|
description:API - truncate
|
||||||
parameters:
|
parameters:
|
||||||
|
|
109
src/tree.c
109
src/tree.c
|
@ -34,6 +34,7 @@ extern long _lSelectByRt(SATvm *pstSavm, void *psvOut);
|
||||||
extern long _lCountByRt(SATvm *pstSavm, size_t *plCount);
|
extern long _lCountByRt(SATvm *pstSavm, size_t *plCount);
|
||||||
extern long _lDeleteByRt(SATvm *pstSavm);
|
extern long _lDeleteByRt(SATvm *pstSavm);
|
||||||
extern long _lUpdateByRt(SATvm *pstSavm, void *pvUpdate);
|
extern long _lUpdateByRt(SATvm *pstSavm, void *pvUpdate);
|
||||||
|
extern long _lReplaceByRt(SATvm *pstSavm, void *pvReplace);
|
||||||
extern long _lTruncateByRt(SATvm *pstSavm, TABLE t);
|
extern long _lTruncateByRt(SATvm *pstSavm, TABLE t);
|
||||||
extern long _lQueryByRt(SATvm *pstSavm, size_t *plOut, void **ppsvOut);
|
extern long _lQueryByRt(SATvm *pstSavm, size_t *plOut, void **ppsvOut);
|
||||||
extern long _lExtremeByRt(SATvm *pstSavm, void *psvOut);
|
extern long _lExtremeByRt(SATvm *pstSavm, void *psvOut);
|
||||||
|
@ -207,23 +208,23 @@ void vPrintHex(char *s, long lIdx, bool bf)
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
CREATE lCreateTvmIndex()
|
CREATE lCreateTvmIndex()
|
||||||
{
|
{
|
||||||
DEFINE(SYS_TVM_INDEX, "SYS_TVM_INDEX", "", TIndex)
|
DEFINE(SYS_TVM_INDEX, "", TIndex)
|
||||||
FIELD(TIndex, m_table, "m_table", FIELD_LONG)
|
FIELD(TIndex, m_table, FIELD_LONG)
|
||||||
FIELD(TIndex, m_lType, "m_lType", FIELD_LONG)
|
FIELD(TIndex, m_lType, FIELD_LONG)
|
||||||
FIELD(TIndex, m_szTable, "m_szTable", FIELD_CHAR)
|
FIELD(TIndex, m_szTable, FIELD_CHAR)
|
||||||
FIELD(TIndex, m_szPart, "m_szPart", FIELD_CHAR)
|
FIELD(TIndex, m_szPart, FIELD_CHAR)
|
||||||
FIELD(TIndex, m_szOwner, "m_szOwner", FIELD_CHAR)
|
FIELD(TIndex, m_szOwner, FIELD_CHAR)
|
||||||
FIELD(TIndex, m_yKey, "m_yKey", FIELD_LONG)
|
FIELD(TIndex, m_yKey, FIELD_LONG)
|
||||||
FIELD(TIndex, m_shmID, "m_shmID", FIELD_LONG)
|
FIELD(TIndex, m_shmID, FIELD_LONG)
|
||||||
FIELD(TIndex, m_semID, "m_semID", FIELD_LONG)
|
FIELD(TIndex, m_semID, FIELD_LONG)
|
||||||
FIELD(TIndex, m_lPid, "m_lPid", FIELD_LONG)
|
FIELD(TIndex, m_lPid, FIELD_LONG)
|
||||||
FIELD(TIndex, m_lValid, "m_lValid", FIELD_LONG)
|
FIELD(TIndex, m_lValid, FIELD_LONG)
|
||||||
FIELD(TIndex, m_lMaxRows, "m_lMaxRows", FIELD_LONG)
|
FIELD(TIndex, m_lMaxRows, FIELD_LONG)
|
||||||
FIELD(TIndex, m_lRowSize, "m_lRowSize", FIELD_LONG)
|
FIELD(TIndex, m_lRowSize, FIELD_LONG)
|
||||||
FIELD(TIndex, m_lLocal, "m_lLocal", FIELD_LONG)
|
FIELD(TIndex, m_lLocal, FIELD_LONG)
|
||||||
FIELD(TIndex, m_lState, "m_lState", FIELD_LONG)
|
FIELD(TIndex, m_lState, FIELD_LONG)
|
||||||
FIELD(TIndex, m_lPers, "m_lPers", FIELD_LONG)
|
FIELD(TIndex, m_lPers, FIELD_LONG)
|
||||||
FIELR(TIndex, m_szTime, "m_szTime", FIELD_LONG)
|
FIELR(TIndex, m_szTime, FIELD_LONG)
|
||||||
|
|
||||||
CREATE_IDX(NORMAL)
|
CREATE_IDX(NORMAL)
|
||||||
IDX_FIELD(TIndex, m_szTable, FIELD_CHAR);
|
IDX_FIELD(TIndex, m_szTable, FIELD_CHAR);
|
||||||
|
@ -243,16 +244,16 @@ CREATE lCreateTvmIndex()
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
CREATE lCreateTvmField()
|
CREATE lCreateTvmField()
|
||||||
{
|
{
|
||||||
DEFINE(SYS_TVM_FIELD, "SYS_TVM_FIELD", "", TField)
|
DEFINE(SYS_TVM_FIELD, "", TField)
|
||||||
FIELD(TField, m_table, "m_table", FIELD_LONG)
|
FIELD(TField, m_table, FIELD_LONG)
|
||||||
FIELD(TField, m_szOwner, "m_szOwner", FIELD_CHAR)
|
FIELD(TField, m_szOwner, FIELD_CHAR)
|
||||||
FIELD(TField, m_szTable, "m_szTable", FIELD_CHAR)
|
FIELD(TField, m_szTable, FIELD_CHAR)
|
||||||
FIELD(TField, m_szField, "m_szField", FIELD_CHAR)
|
FIELD(TField, m_szField, FIELD_CHAR)
|
||||||
FIELD(TField, m_lSeq, "m_lSeq", FIELD_LONG)
|
FIELD(TField, m_lSeq, FIELD_LONG)
|
||||||
FIELD(TField, m_lAttr, "m_lAttr", FIELD_LONG)
|
FIELD(TField, m_lAttr, FIELD_LONG)
|
||||||
FIELD(TField, m_lFrom, "m_lFrom", FIELD_LONG)
|
FIELD(TField, m_lFrom, FIELD_LONG)
|
||||||
FIELD(TField, m_lLen, "m_lLen", FIELD_LONG)
|
FIELD(TField, m_lLen, FIELD_LONG)
|
||||||
FIELD(TField, m_lIsPk, "m_lIsPk", FIELD_LONG)
|
FIELD(TField, m_lIsPk, FIELD_LONG)
|
||||||
|
|
||||||
CREATE_IDX(NORMAL)
|
CREATE_IDX(NORMAL)
|
||||||
IDX_FIELD(TField, m_table, FIELD_LONG);
|
IDX_FIELD(TField, m_table, FIELD_LONG);
|
||||||
|
@ -272,25 +273,25 @@ CREATE lCreateTvmField()
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
CREATE lCreateTvmDomain()
|
CREATE lCreateTvmDomain()
|
||||||
{
|
{
|
||||||
DEFINE(SYS_TVM_DOMAIN, "SYS_TVM_DOMAIN", "", TDomain)
|
DEFINE(SYS_TVM_DOMAIN, "", TDomain)
|
||||||
FIELD(TDomain, m_skSock, "m_skSock", FIELD_LONG)
|
FIELD(TDomain, m_skSock, FIELD_LONG)
|
||||||
FIELD(TDomain, m_table, "m_table", FIELD_LONG)
|
FIELD(TDomain, m_table, FIELD_LONG)
|
||||||
FIELD(TDomain, m_mtable, "m_mtable", FIELD_LONG)
|
FIELD(TDomain, m_mtable, FIELD_LONG)
|
||||||
FIELD(TDomain, m_lLock, "m_lLock", FIELD_LONG)
|
FIELD(TDomain, m_lLock, FIELD_LONG)
|
||||||
FIELD(TDomain, m_lGroup, "m_lGroup", FIELD_LONG)
|
FIELD(TDomain, m_lGroup, FIELD_LONG)
|
||||||
FIELD(TDomain, m_lKeepLive, "m_lKeepLive", FIELD_LONG)
|
FIELD(TDomain, m_lKeepLive, FIELD_LONG)
|
||||||
FIELD(TDomain, m_lLastTime, "m_lLastTime", FIELD_LONG)
|
FIELD(TDomain, m_lLastTime, FIELD_LONG)
|
||||||
FIELD(TDomain, m_lTimeOut, "m_lTimeOut", FIELD_LONG)
|
FIELD(TDomain, m_lTimeOut, FIELD_LONG)
|
||||||
FIELD(TDomain, m_lTryMax, "m_lTryMax", FIELD_LONG)
|
FIELD(TDomain, m_lTryMax, FIELD_LONG)
|
||||||
FIELD(TDomain, m_lTryTimes, "m_lTryTimes", FIELD_LONG)
|
FIELD(TDomain, m_lTryTimes, FIELD_LONG)
|
||||||
FIELD(TDomain, m_lRowSize, "m_lRowSize", FIELD_LONG)
|
FIELD(TDomain, m_lRowSize, FIELD_LONG)
|
||||||
FIELD(TDomain, m_lStatus, "m_lStatus", FIELD_LONG)
|
FIELD(TDomain, m_lStatus, FIELD_LONG)
|
||||||
FIELD(TDomain, m_lPers, "m_lPers", FIELD_LONG)
|
FIELD(TDomain, m_lPers, FIELD_LONG)
|
||||||
FIELD(TDomain, m_lPort, "m_lPort", FIELD_LONG)
|
FIELD(TDomain, m_lPort, FIELD_LONG)
|
||||||
FIELD(TDomain, m_szIp, "m_szIp", FIELD_CHAR)
|
FIELD(TDomain, m_szIp, FIELD_CHAR)
|
||||||
FIELD(TDomain, m_szTable, "m_szTable", FIELD_CHAR)
|
FIELD(TDomain, m_szTable, FIELD_CHAR)
|
||||||
FIELD(TDomain, m_szPart, "m_szPart", FIELD_CHAR)
|
FIELD(TDomain, m_szPart, FIELD_CHAR)
|
||||||
FIELD(TDomain, m_szOwner, "m_szOwner", FIELD_CHAR)
|
FIELD(TDomain, m_szOwner, FIELD_CHAR)
|
||||||
|
|
||||||
CREATE_IDX(NORMAL)
|
CREATE_IDX(NORMAL)
|
||||||
IDX_FIELD(TDomain, m_szTable, FIELD_CHAR)
|
IDX_FIELD(TDomain, m_szTable, FIELD_CHAR)
|
||||||
|
@ -313,9 +314,9 @@ CREATE lCreateTvmDomain()
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
CREATE lCreateTvmSeque()
|
CREATE lCreateTvmSeque()
|
||||||
{
|
{
|
||||||
DEFINE(SYS_TVM_SEQUE, "SYS_TVM_SEQUE", "", TSeque)
|
DEFINE(SYS_TVM_SEQUE, "", TSeque)
|
||||||
FIELD(TSeque, m_szSQName, "m_szSQName", FIELD_CHAR)
|
FIELD(TSeque, m_szSQName, FIELD_CHAR)
|
||||||
FIELD(TSeque, m_uIncrement, "m_uIncrement", FIELD_LONG)
|
FIELD(TSeque, m_uIncrement, FIELD_LONG)
|
||||||
|
|
||||||
CREATE_IDX(UNQIUE)
|
CREATE_IDX(UNQIUE)
|
||||||
IDX_FIELD(TSeque, m_szSQName, FIELD_CHAR)
|
IDX_FIELD(TSeque, m_szSQName, FIELD_CHAR)
|
||||||
|
@ -1937,7 +1938,7 @@ void* pCreateBlock(SATvm *pstSavm, TABLE t, size_t lSize, bool bCreate)
|
||||||
RC_SUCC --success
|
RC_SUCC --success
|
||||||
RC_FAIL --failure
|
RC_FAIL --failure
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
long lAddIdxField(TABLE t, long type, long lFrom, long lLen, long lAttr)
|
long lAddIdxField(TABLE t, long type, long lFrom, long lLen, long lAttr, const char *pszDesc)
|
||||||
{
|
{
|
||||||
long lIdx = 0;
|
long lIdx = 0;
|
||||||
TblKey *pstKey = NULL;
|
TblKey *pstKey = NULL;
|
||||||
|
@ -1967,6 +1968,9 @@ long lAddIdxField(TABLE t, long type, long lFrom, long lLen, long lAttr)
|
||||||
pstKey[lGetIdxNum(t)].m_lFrom = lFrom;
|
pstKey[lGetIdxNum(t)].m_lFrom = lFrom;
|
||||||
pstKey[lGetIdxNum(t)].m_lLen = lLen;
|
pstKey[lGetIdxNum(t)].m_lLen = lLen;
|
||||||
pstKey[lGetIdxNum(t)].m_lAttr = lAttr;
|
pstKey[lGetIdxNum(t)].m_lAttr = lAttr;
|
||||||
|
strncpy(pstKey[lGetIdxNum(t)].m_szField, pszDesc, sizeof(pstKey[lGetIdxNum(t)].m_szField));
|
||||||
|
strcpy(pstKey[lGetIdxNum(t)].m_szAlias, pstKey[lGetIdxNum(t)].m_szField);
|
||||||
|
|
||||||
((TblDef *)pGetTblDef(t))->m_lIdxUp ++;
|
((TblDef *)pGetTblDef(t))->m_lIdxUp ++;
|
||||||
((TblDef *)pGetTblDef(t))->m_lIType |= type;
|
((TblDef *)pGetTblDef(t))->m_lIType |= type;
|
||||||
|
|
||||||
|
@ -1996,6 +2000,8 @@ long lAddIdxField(TABLE t, long type, long lFrom, long lLen, long lAttr)
|
||||||
pstKey[lGetGrpNum(t)].m_lFrom = lFrom;
|
pstKey[lGetGrpNum(t)].m_lFrom = lFrom;
|
||||||
pstKey[lGetGrpNum(t)].m_lLen = lLen;
|
pstKey[lGetGrpNum(t)].m_lLen = lLen;
|
||||||
pstKey[lGetGrpNum(t)].m_lAttr = lAttr;
|
pstKey[lGetGrpNum(t)].m_lAttr = lAttr;
|
||||||
|
strncpy(pstKey[lGetGrpNum(t)].m_szField, pszDesc, sizeof(pstKey[lGetGrpNum(t)].m_szField));
|
||||||
|
strcpy(pstKey[lGetGrpNum(t)].m_szAlias, pstKey[lGetGrpNum(t)].m_szField);
|
||||||
((TblDef *)pGetTblDef(t))->m_lGrpUp ++;
|
((TblDef *)pGetTblDef(t))->m_lGrpUp ++;
|
||||||
((TblDef *)pGetTblDef(t))->m_lIType |= type;
|
((TblDef *)pGetTblDef(t))->m_lIType |= type;
|
||||||
|
|
||||||
|
@ -10596,8 +10602,7 @@ long lReplace(SATvm *pstSavm, void *pvReplace)
|
||||||
if(RES_REMOT_SID == pstRun->m_lLocal)
|
if(RES_REMOT_SID == pstRun->m_lLocal)
|
||||||
{
|
{
|
||||||
Tremohold(pstSavm, pstRun);
|
Tremohold(pstSavm, pstRun);
|
||||||
return RC_FAIL;
|
return _lReplaceByRt(pstSavm, pvReplace);
|
||||||
// return _lReplaceByRt(pstSavm, psvOut);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(HAVE_UNIQ_IDX(pstSavm->tblName))
|
if(HAVE_UNIQ_IDX(pstSavm->tblName))
|
||||||
|
|
Loading…
Reference in New Issue