add increase
parent
2a92ba8a4b
commit
1ce47a8d64
BIN
demo/count
BIN
demo/count
Binary file not shown.
BIN
demo/create
BIN
demo/create
Binary file not shown.
BIN
demo/delete
BIN
demo/delete
Binary file not shown.
BIN
demo/extreme
BIN
demo/extreme
Binary file not shown.
BIN
demo/group
BIN
demo/group
Binary file not shown.
BIN
demo/insert
BIN
demo/insert
Binary file not shown.
|
@ -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)) // 插入记录
|
||||||
{
|
{
|
||||||
|
|
|
@ -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
|
||||||
|
|
BIN
demo/press_demo
BIN
demo/press_demo
Binary file not shown.
BIN
demo/query
BIN
demo/query
Binary file not shown.
BIN
demo/select
BIN
demo/select
Binary file not shown.
BIN
demo/truncate
BIN
demo/truncate
Binary file not shown.
BIN
demo/update
BIN
demo/update
Binary file not shown.
|
@ -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
|
||||||
|
|
31
src/stvm.c
31
src/stvm.c
|
@ -1006,6 +1006,26 @@ long lDefineTable(char *pszCreate, char *pszTable)
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
description:append 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 ;
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
description:create table by file
|
description:create 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 ;
|
||||||
}
|
}
|
||||||
|
|
63
src/tcp.c
63
src/tcp.c
|
@ -1340,6 +1340,7 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
|
||||||
{
|
{
|
||||||
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;
|
lData = pstFace->m_lDLen * pstFace->m_lRows;
|
||||||
|
pstFace->m_lDLen = pstSavm->m_lEType;
|
||||||
|
}
|
||||||
|
|
||||||
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,13 +1364,28 @@ 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;
|
pstFace->m_lRows = pstSavm->m_lEffect;
|
||||||
|
pstFace->m_lDLen = pstSavm->m_lEType;
|
||||||
|
}
|
||||||
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;
|
||||||
|
@ -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;
|
||||||
pstCon->m_pstWork = pstSavm->m_pstWork;
|
else
|
||||||
|
{
|
||||||
|
pstFace->m_lDLen = pstSavm->m_lEType;
|
||||||
pstFace->m_lRows = pstSavm->m_lEffect;
|
pstFace->m_lRows = pstSavm->m_lEffect;
|
||||||
|
}
|
||||||
|
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 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;
|
||||||
|
@ -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;
|
||||||
|
@ -1432,6 +1462,7 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
|
||||||
{
|
{
|
||||||
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;
|
lData = pstFace->m_lDLen * pstFace->m_lRows;
|
||||||
|
pstFace->m_lDLen = pstSavm->m_lEType;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue