add increase

pull/1/head
deffpuzzl 2018-06-01 13:04:49 +08:00
parent 2a92ba8a4b
commit 1ce47a8d64
17 changed files with 87 additions and 29 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
demo/drop

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -26,13 +26,14 @@ long lInsertUserInfo()
} }
memset(&stUser, 0, sizeof(dbUser)); memset(&stUser, 0, sizeof(dbUser));
stUser.acct_id = 10021; // 对结构体赋值 // stUser.acct_id = 10021; // 对结构体赋值
strcpy(stUser.user_no, "20180223"); // 对结构体赋值 strcpy(stUser.user_no, "20180223"); // 对结构体赋值
strcpy(stUser.user_type, "1"); // 对结构体赋值 strcpy(stUser.user_type, "1"); // 对结构体赋值
strcpy(stUser.user_nm, "Savens Liu"); // 对结构体赋值 strcpy(stUser.user_nm, "Savens Liu"); // 对结构体赋值
strcpy(stUser.user_addr, "China"); // 对结构体赋值 strcpy(stUser.user_addr, "China"); // 对结构体赋值
strcpy(stUser.user_phone, "18672911111"); // 对结构体赋值 strcpy(stUser.user_phone, "18672911111"); // 对结构体赋值
defineinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量 defineinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量
decorate(pstSavm, dbUser, acct_id, FIELD_INCR); // 自增llong型
if(RC_SUCC != lInsert(pstSavm)) // 插入记录 if(RC_SUCC != lInsert(pstSavm)) // 插入记录
{ {

View File

@ -1,6 +1,6 @@
INCDIR= -I/usr/include -I$(HOME)/include -I./ -I./include -I../include INCDIR= -I/usr/include -I$(HOME)/include -I./ -I./include -I../include
LIBDIR= -L$(HOME)/lib -L../lib -lstvm -lm -lc -ldl -lpthread LIBDIR= -L$(HOME)/lib -L../lib -lstvm -lm -lc -ldl -lpthread
CC=cc -fPIC CC=cc -fPIC -g
CO=-c -pg CO=-c -pg
OUTLIB=../lib OUTLIB=../lib
OUTBIN=../bin OUTBIN=../bin

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -4,8 +4,9 @@ AR=ar
LD=ld LD=ld
LN=ln LN=ln
#CC=cc -fPIC -O2 -Wno-unused-result -m64 -march=native #CC=cc -fPIC -O2 -Wno-unused-result -m64 -march=native
CC=cc -fPIC -O2 -Wno-unused-result -march=native #CC=cc -fPIC -O2 -Wno-unused-result -march=native
CO=-c -g -O2 -DMAX_INDEX_LEN=64 -DMAX_FILED_NUM=64 -Wno-unused-result CC=cc -fPIC -Wno-unused-result
CO=-c -g -DMAX_INDEX_LEN=64 -DMAX_FILED_NUM=64 -Wno-unused-result
LDFLAG=-shared -g LDFLAG=-shared -g
OUTLIB=../lib OUTLIB=../lib
OUTBIN=../bin OUTBIN=../bin

View File

@ -1006,6 +1006,26 @@ long lDefineTable(char *pszCreate, char *pszTable)
return RC_SUCC; return RC_SUCC;
} }
/**************************************************************************************************
descriptionappend table to tab list
parameters
return
**************************************************************************************************/
void vAppendTabList(char *pszTable)
{
long lLen = 0;
lLen = strlen(g_stCustom.m_pszWord);
lLen += strlen(pszTable) + 1;
if(lLen > ALLOC_CMD_LEN)
return ;
strcat(g_stCustom.m_pszWord, supper(pszTable));
strcat(g_stCustom.m_pszWord, ",");
g_stCustom.m_lWord = lgetstrnum(g_stCustom.m_pszWord, ",");
return ;
}
/************************************************************************************************* /*************************************************************************************************
descriptioncreate table by file descriptioncreate table by file
parameters parameters
@ -1067,7 +1087,7 @@ long lCreateByFile(char *pszFile)
return RC_FAIL; return RC_FAIL;
fprintf(stdout, "---(%s) was created ---\n", szTable); fprintf(stdout, "---(%s) was created ---\n", szTable);
vAppendTabList(szTable);
TFree(pszCreate); TFree(pszCreate);
return RC_SUCC; return RC_SUCC;
@ -3770,15 +3790,8 @@ void vInitTableList(SATvm *pstSavm, bool bRmt)
return ; return ;
for(i = 0, lRet = strlen(g_stCustom.m_pszWord); i < lRows; i ++) for(i = 0, lRet = strlen(g_stCustom.m_pszWord); i < lRows; i ++)
{ vAppendTabList(pstIndex[i].m_szTable);
lRet += strlen(pstIndex[i].m_szTable) + 1;
if(lRet > ALLOC_CMD_LEN)
break;
strcat(g_stCustom.m_pszWord, pstIndex[i].m_szTable);
strcat(g_stCustom.m_pszWord, ",");
}
g_stCustom.m_lWord = lgetstrnum(g_stCustom.m_pszWord, ",");
TFree(pstIndex); TFree(pstIndex);
return ; return ;
} }

View File

@ -1339,7 +1339,8 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
else else
{ {
lData = pstFace->m_lDLen + sizeof(TFace); lData = pstFace->m_lDLen + sizeof(TFace);
pstFace->m_lRows = pstSavm->m_lEffect; pstFace->m_lRows = pstSavm->m_lEffect;
pstFace->m_lDLen = pstSavm->m_lEType;
} }
lSendBuffer(pstCon->m_skSock, (void *)pstFace, lData); lSendBuffer(pstCon->m_skSock, (void *)pstFace, lData);
@ -1347,8 +1348,12 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
case OPERATE_QUERY: case OPERATE_QUERY:
if(RC_SUCC != lQuery(pstSavm, (size_t *)&pstFace->m_lRows, (void *)&pvOut)) if(RC_SUCC != lQuery(pstSavm, (size_t *)&pstFace->m_lRows, (void *)&pvOut))
pstFace->m_lErrno = pstSavm->m_lErrno; pstFace->m_lErrno = pstSavm->m_lErrno;
else
{
lData = pstFace->m_lDLen * pstFace->m_lRows;
pstFace->m_lDLen = pstSavm->m_lEType;
}
lData = pstFace->m_lDLen * pstFace->m_lRows;
if(sizeof(TFace) != lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace))) if(sizeof(TFace) != lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace)))
{ {
TFree(pvOut); TFree(pvOut);
@ -1359,14 +1364,29 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
TFree(pvOut); TFree(pvOut);
return RC_SUCC; return RC_SUCC;
case OPERATE_REPLACE: case OPERATE_REPLACE:
pstSavm->m_bWork = pstCon->m_bWork;
pstSavm->m_pstWork = pstCon->m_pstWork;
if(RC_SUCC != lReplace(pstSavm, pvData))
pstFace->m_lErrno = pstSavm->m_lErrno;
else
{
pstFace->m_lRows = pstSavm->m_lEffect;
pstFace->m_lDLen = pstSavm->m_lEType;
}
pstCon->m_pstWork = pstSavm->m_pstWork;
lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace));
return RC_SUCC;
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;
if(RC_SUCC != lUpdate(pstSavm, pvData)) if(RC_SUCC != lUpdate(pstSavm, pvData))
pstFace->m_lErrno = pstSavm->m_lErrno; pstFace->m_lErrno = pstSavm->m_lErrno;
else else
pstFace->m_lRows = pstSavm->m_lEffect; {
pstCon->m_pstWork = pstSavm->m_pstWork; pstFace->m_lRows = pstSavm->m_lEffect;
pstFace->m_lDLen = pstSavm->m_lEType;
}
pstCon->m_pstWork = pstSavm->m_pstWork;
lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace)); lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace));
return RC_SUCC; return RC_SUCC;
case OPERATE_DELETE: case OPERATE_DELETE:
@ -1374,12 +1394,20 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
pstSavm->m_pstWork = pstCon->m_pstWork; pstSavm->m_pstWork = pstCon->m_pstWork;
if(RC_SUCC != lDelete(pstSavm)) if(RC_SUCC != lDelete(pstSavm))
pstFace->m_lErrno = pstSavm->m_lErrno; pstFace->m_lErrno = pstSavm->m_lErrno;
else
{
pstFace->m_lDLen = pstSavm->m_lEType;
pstFace->m_lRows = pstSavm->m_lEffect;
}
pstCon->m_pstWork = pstSavm->m_pstWork; pstCon->m_pstWork = pstSavm->m_pstWork;
pstFace->m_lRows = pstSavm->m_lEffect;
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 OPERATS_REPLACE:
pstSavm->m_bWork = pstCon->m_bWork;
pstSavm->m_pstWork = pstCon->m_pstWork;
if(RC_SUCC == lReplace(pstSavm, pvData))
pstCon->m_pstWork = pstSavm->m_pstWork;
return RC_SUCC;
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;
@ -1405,7 +1433,7 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
pstFace->m_lErrno = pstSavm->m_lErrno; pstFace->m_lErrno = pstSavm->m_lErrno;
else else
pstFace->m_lRows = pstSavm->m_lEffect; pstFace->m_lRows = pstSavm->m_lEffect;
pstCon->m_pstWork = pstSavm->m_pstWork; pstCon->m_pstWork = pstSavm->m_pstWork;
lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace)); lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace));
return RC_SUCC; return RC_SUCC;
case OPERATE_TRCATE: case OPERATE_TRCATE:
@ -1418,6 +1446,8 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
case OPERATE_COUNT: case OPERATE_COUNT:
if(RC_SUCC != lCount(pstSavm, (size_t *)&pstFace->m_lRows)) if(RC_SUCC != lCount(pstSavm, (size_t *)&pstFace->m_lRows))
pstFace->m_lErrno = pstSavm->m_lErrno; pstFace->m_lErrno = pstSavm->m_lErrno;
else
pstFace->m_lDLen = pstSavm->m_lEType;
lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace)); lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace));
return RC_SUCC; return RC_SUCC;
@ -1431,7 +1461,8 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
else else
{ {
lData = pstFace->m_lDLen + sizeof(TFace); lData = pstFace->m_lDLen + sizeof(TFace);
pstFace->m_lRows = pstSavm->m_lEffect; pstFace->m_lRows = pstSavm->m_lEffect;
pstFace->m_lDLen = pstSavm->m_lEType;
} }
lSendBuffer(pstCon->m_skSock, (void *)pstFace, lData); lSendBuffer(pstCon->m_skSock, (void *)pstFace, lData);
return RC_SUCC; return RC_SUCC;
@ -1479,8 +1510,12 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
case OPERATE_GROUP: case OPERATE_GROUP:
if(RC_SUCC != lGroup(pstSavm, (size_t *)&pstFace->m_lRows, (void *)&pvOut)) if(RC_SUCC != lGroup(pstSavm, (size_t *)&pstFace->m_lRows, (void *)&pvOut))
pstFace->m_lErrno = pstSavm->m_lErrno; pstFace->m_lErrno = pstSavm->m_lErrno;
else
{
lData = pstFace->m_lDLen * pstFace->m_lRows;
pstFace->m_lDLen = pstSavm->m_lEType;
}
lData = pstFace->m_lDLen * pstFace->m_lRows;
if(sizeof(TFace) != lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace))) if(sizeof(TFace) != lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace)))
{ {
TFree(pvOut); TFree(pvOut);
@ -4002,6 +4037,7 @@ long lTvmSelect(SATvm *pstSavm, void *pvOut)
return RC_FAIL; return RC_FAIL;
pstSavm->m_lEffect = pstFace->m_lRows; pstSavm->m_lEffect = pstFace->m_lRows;
pstSavm->m_lEType = pstFace->m_lDLen;
if(pstSavm->lSize != lRecvBuffer(pstSavm->m_skSock, (char *)pvOut, pstSavm->lSize)) if(pstSavm->lSize != lRecvBuffer(pstSavm->m_skSock, (char *)pvOut, pstSavm->lSize))
{ {
pstSavm->m_lErrno = SOCK_COM_EXCP; pstSavm->m_lErrno = SOCK_COM_EXCP;
@ -4083,6 +4119,7 @@ long lTvmQuery(SATvm *pstSavm, size_t *plOut, void **ppvOut)
*plOut = pstFace->m_lRows; *plOut = pstFace->m_lRows;
pstSavm->m_lEffect = pstFace->m_lRows; pstSavm->m_lEffect = pstFace->m_lRows;
pstSavm->m_lEType = pstFace->m_lDLen;
return RC_SUCC; return RC_SUCC;
} }
@ -4406,11 +4443,12 @@ long lTvmDelete(SATvm *pstSavm)
return RC_FAIL; return RC_FAIL;
} }
pstSavm->m_lErrno = ((TFace *)pstRun->pstVoid)->m_lErrno; pstSavm->m_lErrno = pstFace->m_lErrno;
if(0 != pstSavm->m_lErrno) if(0 != pstSavm->m_lErrno)
return RC_FAIL; return RC_FAIL;
pstSavm->m_lEffect = ((TFace *)pstRun->pstVoid)->m_lRows; pstSavm->m_lEffect = pstFace->m_lRows;
pstSavm->m_lEType = pstFace->m_lDLen;
return RC_SUCC; return RC_SUCC;
} }
@ -4474,11 +4512,12 @@ long lTvmUpdate(SATvm *pstSavm, void *pvData)
return RC_FAIL; return RC_FAIL;
} }
pstSavm->m_lErrno = ((TFace *)pstRun->pstVoid)->m_lErrno; pstSavm->m_lErrno = pstFace->m_lErrno;
if(0 != pstSavm->m_lErrno) if(0 != pstSavm->m_lErrno)
return RC_FAIL; return RC_FAIL;
pstSavm->m_lEffect = ((TFace *)pstRun->pstVoid)->m_lRows; pstSavm->m_lEffect = pstFace->m_lRows;
pstSavm->m_lEType = pstFace->m_lDLen;
return RC_SUCC; return RC_SUCC;
} }
@ -4528,7 +4567,7 @@ long lTvmReplace(SATvm *pstSavm, void *pvData)
vBuildPacket(pstRun->pstVoid, pstSavm->pstVoid, &pstSavm->stCond, &lWrite); vBuildPacket(pstRun->pstVoid, pstSavm->pstVoid, &pstSavm->stCond, &lWrite);
vBuildPacket(pstRun->pstVoid, pvData, pstCond, &lWrite); vBuildPacket(pstRun->pstVoid, pvData, pstCond, &lWrite);
pstFace->m_lRows = lWrite - sizeof(TFace); pstFace->m_lRows = lWrite - sizeof(TFace);
if(lWrite != lSendBuffer(pstSavm->m_skSock, (void *)pstRun->pstVoid, lWrite)) if(lWrite != lSendBuffer(pstSavm->m_skSock, (void *)pstRun->pstVoid, lWrite))
{ {
@ -4542,11 +4581,12 @@ long lTvmReplace(SATvm *pstSavm, void *pvData)
return RC_FAIL; return RC_FAIL;
} }
pstSavm->m_lErrno = ((TFace *)pstRun->pstVoid)->m_lErrno; pstSavm->m_lErrno = pstFace->m_lErrno;
if(0 != pstSavm->m_lErrno) if(0 != pstSavm->m_lErrno)
return RC_FAIL; return RC_FAIL;
pstSavm->m_lEffect = ((TFace *)pstRun->pstVoid)->m_lRows; pstSavm->m_lEffect = pstFace->m_lRows;
pstSavm->m_lEType = pstFace->m_lDLen;
return RC_SUCC; return RC_SUCC;
} }
@ -4682,6 +4722,7 @@ long lTvmGroup(SATvm *pstSavm, size_t *plOut, void **ppvOut)
*plOut = pstFace->m_lRows; *plOut = pstFace->m_lRows;
pstSavm->m_lEffect = pstFace->m_lRows; pstSavm->m_lEffect = pstFace->m_lRows;
pstSavm->m_lEType = pstFace->m_lDLen;
return RC_SUCC; return RC_SUCC;
} }
@ -4742,6 +4783,7 @@ long lTvmCount(SATvm *pstSavm, size_t *plCount)
return RC_FAIL; return RC_FAIL;
*plCount = pstFace->m_lRows; *plCount = pstFace->m_lRows;
pstSavm->m_lEType = pstFace->m_lDLen;
return RC_SUCC; return RC_SUCC;
} }
@ -4809,6 +4851,7 @@ long lTvmExtreme(SATvm *pstSavm, void *pvOut)
if(0 != pstSavm->m_lErrno) if(0 != pstSavm->m_lErrno)
return RC_FAIL; return RC_FAIL;
pstSavm->m_lEType = pstFace->m_lDLen;
if(pstSavm->lSize != lRecvBuffer(pstSavm->m_skSock, (char *)pvOut, pstSavm->lSize)) if(pstSavm->lSize != lRecvBuffer(pstSavm->m_skSock, (char *)pvOut, pstSavm->lSize))
{ {
pstSavm->m_lErrno = SOCK_COM_EXCP; pstSavm->m_lErrno = SOCK_COM_EXCP;