add stvm-SQL function
parent
e94d8617d9
commit
2565c4c767
|
@ -48,7 +48,7 @@ cd src目录 **./make**
|
||||||
如果不使用多机集群,无需配置域文件,缺省本地启动。
|
如果不使用多机集群,无需配置域文件,缺省本地启动。
|
||||||
|
|
||||||
启动系统
|
启动系统
|
||||||
> stvm -w [^1]
|
> stvm -w
|
||||||
|
|
||||||
停止系统
|
停止系统
|
||||||
> stvm -s
|
> stvm -s
|
||||||
|
@ -115,8 +115,6 @@ STVM也提供一个类型sqlpuls类型简单工具。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[^1]: 常见错误集合 ↑↑
|
|
||||||
|
|
||||||
---
|
---
|
||||||
#### *常见错误集合* ####
|
#### *常见错误集合* ####
|
||||||
```
|
```
|
||||||
|
|
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.
|
@ -32,7 +32,7 @@ long lInsertUserInfo()
|
||||||
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"); // 对结构体赋值
|
||||||
insertinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量
|
defineinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量
|
||||||
|
|
||||||
if(RC_SUCC != lInsert(pstSavm)) // 插入记录
|
if(RC_SUCC != lInsert(pstSavm)) // 插入记录
|
||||||
{
|
{
|
||||||
|
|
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.
|
@ -25,7 +25,7 @@ long lUpdateUserInfo()
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateinit(stUpd);
|
updateinit(pstSavm, stUpd);
|
||||||
conditinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量
|
conditinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量
|
||||||
stringset(pstSavm, stUser, user_type, "1"); // 查询条件赋值
|
stringset(pstSavm, stUser, user_type, "1"); // 查询条件赋值
|
||||||
stringset(pstSavm, stUser, user_no, "20180224"); // 查询条件赋值
|
stringset(pstSavm, stUser, user_no, "20180224"); // 查询条件赋值
|
||||||
|
|
|
@ -33,7 +33,7 @@ typedef long CREATE;
|
||||||
//#pragma pack(4)
|
//#pragma pack(4)
|
||||||
|
|
||||||
#define TVM_VKERNEL "1.2.0.0"
|
#define TVM_VKERNEL "1.2.0.0"
|
||||||
#define TVM_VERSION "1.2.2.0"
|
#define TVM_VERSION "1.2.3.0"
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
custom macro
|
custom macro
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
|
@ -322,12 +322,6 @@ typedef long CREATE;
|
||||||
p->pstVoid = (void *)&(s); \
|
p->pstVoid = (void *)&(s); \
|
||||||
}while(0);
|
}while(0);
|
||||||
|
|
||||||
#define insertinit(p,s,t) do{ \
|
|
||||||
p->lSize = sizeof(s); \
|
|
||||||
p->tblName = t; \
|
|
||||||
p->pstVoid = (void *)&(s); \
|
|
||||||
}while(0);
|
|
||||||
|
|
||||||
#define conditinit(p,s,t) do{ \
|
#define conditinit(p,s,t) do{ \
|
||||||
p->stCond.uFldcmp = 0; \
|
p->stCond.uFldcmp = 0; \
|
||||||
p->stUpdt.uFldcmp = 0; \
|
p->stUpdt.uFldcmp = 0; \
|
||||||
|
@ -362,15 +356,26 @@ typedef long CREATE;
|
||||||
#define decorate(p,d,f,v) vSetDecorate(&p->stUpdt, FLEN(d, f), FPOS(d, f), v); \
|
#define decorate(p,d,f,v) vSetDecorate(&p->stUpdt, FLEN(d, f), FPOS(d, f), v); \
|
||||||
p->lFind = (v) & FIRST_ROW;
|
p->lFind = (v) & FIRST_ROW;
|
||||||
|
|
||||||
#define conditset(p,s,f) vSetCodField(&p->stCond, sizeof((s).f), (char *)&(s).f - (char *)&(s));
|
|
||||||
|
|
||||||
#define stringreset(s,f,v) strncpy((s).f, v, sizeof((s).f));
|
#define stringreset(s,f,v) strncpy((s).f, v, sizeof((s).f));
|
||||||
#define stringresetv(s,f,...) snprintf((s).f, sizeof((s).f), __VA_ARGS__);
|
#define stringresetv(s,f,...) snprintf((s).f, sizeof((s).f), __VA_ARGS__);
|
||||||
#define stringrecpy(s,f,v) memcpy((s).f, v, sizeof((s).f));
|
#define stringrecpy(s,f,v) memcpy((s).f, v, sizeof((s).f));
|
||||||
#define numberreset(s,f,v) (s).f = v;
|
#define numberreset(s,f,v) (s).f = v;
|
||||||
|
#define conditset(p,s,f) vSetCodField(&p->stCond, sizeof((s).f), (char *)&(s).f - (char *)&(s));
|
||||||
|
|
||||||
|
#define conditbind defineinit
|
||||||
|
#define conditfld conditset
|
||||||
|
#define conditnum numberset
|
||||||
|
#define conditstr stringset
|
||||||
|
#define conditcpy stringcpy
|
||||||
|
#define conditstv stringsetv
|
||||||
|
#define conditrenum numberreset
|
||||||
|
#define conditrestr stringreset
|
||||||
|
#define conditrecpy stringrecpy
|
||||||
|
#define conditrestv stringresetv
|
||||||
|
|
||||||
// UPDATE Field assignment
|
// UPDATE Field assignment
|
||||||
#define updateinit(s) memset(&(s), 0, sizeof(s));
|
#define updateinit(p, s) memset(&(s), 0, sizeof(s));
|
||||||
|
//#define updateinit(p, s) p->stUpdt.uFldcmp = 0; memset(&(s), 0, sizeof(s));
|
||||||
|
|
||||||
#define stringupd(p,s,f,v) vSetCodField(&p->stUpdt, sizeof((s).f), (char *)(s).f - (char *)&(s)); \
|
#define stringupd(p,s,f,v) vSetCodField(&p->stUpdt, sizeof((s).f), (char *)(s).f - (char *)&(s)); \
|
||||||
strncpy((s).f, v, sizeof((s).f));
|
strncpy((s).f, v, sizeof((s).f));
|
||||||
|
@ -381,8 +386,23 @@ typedef long CREATE;
|
||||||
#define numberupd(p,s,f,v) vSetCodField(&p->stUpdt, sizeof((s).f), (char *)&(s).f - (char *)&(s)); \
|
#define numberupd(p,s,f,v) vSetCodField(&p->stUpdt, sizeof((s).f), (char *)&(s).f - (char *)&(s)); \
|
||||||
(s).f = v;
|
(s).f = v;
|
||||||
|
|
||||||
#define updateset(p,s,f) vSetCodField(&p->stUpdt, sizeof((s).f), (char *)&(s).f - (char *)&(s));
|
#define updatestrv(p,s,f,...) vSetCodField(&p->stUpdt, sizeof((s).f), (char *)(s).f - (char *)&(s)); \
|
||||||
|
snprintf((s).f, sizeof((s).f), __VA_ARGS__);
|
||||||
|
|
||||||
|
#define updateset(p,s,f) vSetCodField(&p->stUpdt, sizeof((s).f), (char *)&(s).f - (char *)&(s));
|
||||||
|
#define updatefld updateset
|
||||||
|
#define updatenum numberupd
|
||||||
|
#define updatestr stringupd
|
||||||
|
#define updatecpy stringupy
|
||||||
|
#define updatestv updatestrv
|
||||||
|
#define updaterenum(s,f,v) (s).f = v;
|
||||||
|
#define updaterestr(s,f,v) strncpy((s).f, v, sizeof((s).f));
|
||||||
|
#define updaterecpy(s,f,v) memcpy((s).f, v, sizeof((s).f));
|
||||||
|
#define updaterestv(s,f,...) snprintf((s).f, sizeof((s).f), __VA_ARGS__);
|
||||||
|
|
||||||
|
#define aliasreset(p,t) lResetDefine(p, t);
|
||||||
|
#define aliasvalue(p,t,s,a,v) lSetTructByAlias(p, t, s, a, v);
|
||||||
|
#define aliasset(p,t,s,f,v) lSetAlias(p, t, FLEN(s, f), FPOS(s, f), v);
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
Table structure & index definition area
|
Table structure & index definition area
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
|
@ -653,6 +673,7 @@ extern char* sGetTableName(TABLE t);
|
||||||
extern void* pGetAddr(SATvm *pstSavm, TABLE t);
|
extern void* pGetAddr(SATvm *pstSavm, TABLE t);
|
||||||
extern RunTime* pGetRunTime(SATvm *pstSavm, TABLE t);
|
extern RunTime* pGetRunTime(SATvm *pstSavm, TABLE t);
|
||||||
extern void* pGetNode(void *pvData, size_t lOfs);
|
extern void* pGetNode(void *pvData, size_t lOfs);
|
||||||
|
extern long lResetDefine(SATvm *pstSavm, TABLE t);
|
||||||
extern void* pInitMemTable(SATvm *pstSavm, TABLE t);
|
extern void* pInitMemTable(SATvm *pstSavm, TABLE t);
|
||||||
extern void* pInitHitTest(SATvm *pstSavm, TABLE t);
|
extern void* pInitHitTest(SATvm *pstSavm, TABLE t);
|
||||||
extern long lTableMaxRow(SATvm *pstSavm, TABLE t);
|
extern long lTableMaxRow(SATvm *pstSavm, TABLE t);
|
||||||
|
@ -665,6 +686,7 @@ extern TblKey* pFindField(TblKey *pstIdx, long lNum, char *pszField);
|
||||||
extern long lGetTblField(TABLE t, size_t *plOut, TField **ppstField);
|
extern long lGetTblField(TABLE t, size_t *plOut, TField **ppstField);
|
||||||
extern void vSetCodField(FdCond *pstCond, uint ulen, uint uPos);
|
extern void vSetCodField(FdCond *pstCond, uint ulen, uint uPos);
|
||||||
extern bool bSetCondAttr(FdCond *pstCond, TABLE t, Uenum eCheck);
|
extern bool bSetCondAttr(FdCond *pstCond, TABLE t, Uenum eCheck);
|
||||||
|
extern long lSetAlias(SATvm *pstSavm, TABLE t, uint ulen, uint uPos, char *alias);
|
||||||
extern void vSetDecorate(FdCond *pstCond, uint ulen, uint uPos, Uenum em);
|
extern void vSetDecorate(FdCond *pstCond, uint ulen, uint uPos, Uenum em);
|
||||||
extern long lGetDomainIndex(SATvm *pstSavm, long *plOut, TIndex **ppstIndex);
|
extern long lGetDomainIndex(SATvm *pstSavm, long *plOut, TIndex **ppstIndex);
|
||||||
extern long lGetDomainTable(SATvm *pstSavm, long *plOut, TDomain **ppstDomain);
|
extern long lGetDomainTable(SATvm *pstSavm, long *plOut, TDomain **ppstDomain);
|
||||||
|
@ -729,6 +751,7 @@ extern long lExportFile(TABLE t, char *pszFile, char *pszFlag);
|
||||||
extern long lImportTable(TABLE t, size_t lCount, void *psvOut);
|
extern long lImportTable(TABLE t, size_t lCount, void *psvOut);
|
||||||
extern long lExportTable(TABLE t, size_t *plOut, void **ppsvOut);
|
extern long lExportTable(TABLE t, size_t *plOut, void **ppsvOut);
|
||||||
extern long lDumpTable(SATvm *pstSavm, TABLE t);
|
extern long lDumpTable(SATvm *pstSavm, TABLE t);
|
||||||
|
extern void vSetTructByAlias(SATvm *pstSavm, TABLE t, void *pvData, const char *key, char *v);
|
||||||
|
|
||||||
extern long lRenameTable(SATvm *pstSavm, TABLE to, TABLE tn);
|
extern long lRenameTable(SATvm *pstSavm, TABLE to, TABLE tn);
|
||||||
extern long lCreateSeque(SATvm *pstSavm, char *pszSQName, uint uIncre);
|
extern long lCreateSeque(SATvm *pstSavm, char *pszSQName, uint uIncre);
|
||||||
|
|
241
src/stvm.c
241
src/stvm.c
|
@ -68,7 +68,7 @@ static char* sGetTVMVers()
|
||||||
sprintf(szVersion + strlen(szVersion), "Release STVM %s Production on %s %s\n",
|
sprintf(szVersion + strlen(szVersion), "Release STVM %s Production on %s %s\n",
|
||||||
TVM_VERSION, sinf.sysname, sinf.machine);
|
TVM_VERSION, sinf.sysname, sinf.machine);
|
||||||
|
|
||||||
strcat(szVersion, "Author:DeffPuzzL\n");
|
strcat(szVersion, "Author:Savens Liu\n");
|
||||||
strcat(szVersion, "Mail:deffpuzzl@qq.com\n");
|
strcat(szVersion, "Mail:deffpuzzl@qq.com\n");
|
||||||
|
|
||||||
return szVersion;
|
return szVersion;
|
||||||
|
@ -1175,6 +1175,139 @@ SQLFld* pSortSQLField(SQLFld *pstRoot)
|
||||||
return pstRoot;
|
return pstRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************
|
||||||
|
description:show stvm tables
|
||||||
|
parameters:
|
||||||
|
RC_SUCC --success
|
||||||
|
RC_FAIL --failure
|
||||||
|
*************************************************************************************************/
|
||||||
|
long lShowTables(SATvm *pstSavm)
|
||||||
|
{
|
||||||
|
char szTable[128];
|
||||||
|
TIndex stIndex, *pstIndex = NULL;
|
||||||
|
long i, lRows = 0, lTime = lGetTiskTime();
|
||||||
|
|
||||||
|
if(RC_SUCC != lInitSATvm(pstSavm, SYS_TVM_INDEX))
|
||||||
|
return RC_FAIL;
|
||||||
|
|
||||||
|
conditinit(pstSavm, stIndex, SYS_TVM_INDEX);
|
||||||
|
conditnum(pstSavm, stIndex, m_lLocal, RES_LOCAL_SID);
|
||||||
|
|
||||||
|
if(RC_SUCC != lQuery(pstSavm, &lRows, (void **)&pstIndex))
|
||||||
|
return RC_FAIL;
|
||||||
|
|
||||||
|
fprintf(stdout, "table table_name\n");
|
||||||
|
for(i = 0; i < lRows; i ++)
|
||||||
|
{
|
||||||
|
memset(szTable, 0, sizeof(szTable));
|
||||||
|
if(!strcmp(pstIndex[i].m_szPart, pstIndex[i].m_szOwner))
|
||||||
|
strcpy(szTable, pstIndex[i].m_szTable);
|
||||||
|
else
|
||||||
|
snprintf(szTable, sizeof(szTable), "%s@%s", pstIndex[i].m_szPart, pstIndex[i].m_szTable);
|
||||||
|
fprintf(stdout, "%3d %s\n", pstIndex[i].m_table, szTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
lTime -= lGetTiskTime();
|
||||||
|
TFree(pstIndex);
|
||||||
|
fprintf(stdout, "---(%ld) records selected, ep(%d), %s---\n", pstSavm->m_lEffect,
|
||||||
|
pstSavm->m_lEType, sGetCostTime(-1 * lTime));
|
||||||
|
return RC_SUCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
description:Output table space Usage
|
||||||
|
parameters:
|
||||||
|
return:
|
||||||
|
**************************************************************************************************/
|
||||||
|
void vPrintAmount(int t, char *pszTable, int nValid, int nMax)
|
||||||
|
{
|
||||||
|
double dPer;
|
||||||
|
int i, nPer;
|
||||||
|
|
||||||
|
if(nValid < 0 || nMax <= 0) return ;
|
||||||
|
|
||||||
|
dPer = nValid * 100.0 / nMax;
|
||||||
|
nPer = nValid * 50 / nMax > 0 ? nValid * 50 / nMax : 1;
|
||||||
|
|
||||||
|
fprintf(stdout, "TABLE:[%3d][%-20s]: [", t, pszTable);
|
||||||
|
if(dPer < 60.00)
|
||||||
|
fprintf(stdout, "\033[42;32m");
|
||||||
|
else if(dPer < 70.00)
|
||||||
|
fprintf(stdout, "\033[45;35m");
|
||||||
|
else if(dPer < 80.00)
|
||||||
|
fprintf(stdout, "\033[46;36m");
|
||||||
|
else if(dPer < 90.00)
|
||||||
|
fprintf(stdout, "\033[43;33m");
|
||||||
|
else
|
||||||
|
fprintf(stdout, "\033[41;31m");
|
||||||
|
|
||||||
|
fflush(stdout);
|
||||||
|
for(i = 0; i < nPer; i ++)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "|");
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stdout, "\033[0m");
|
||||||
|
for(i; i < 50; i ++)
|
||||||
|
fprintf(stdout, " ");
|
||||||
|
fprintf(stdout, "] %.4f%%, (%d/%d)\n", dPer, nValid, nMax);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************************
|
||||||
|
description:print system table space usage
|
||||||
|
parameters:
|
||||||
|
return:
|
||||||
|
**************************************************************************************************/
|
||||||
|
void vTableAmount()
|
||||||
|
{
|
||||||
|
size_t i, lOut = 0;
|
||||||
|
char szTable[128];
|
||||||
|
RunTime *pstRun = NULL;
|
||||||
|
TIndex stIndex, *pstIndex = NULL;
|
||||||
|
SATvm *pstSavm = (SATvm *)pGetSATvm();
|
||||||
|
|
||||||
|
memset(&stIndex, 0, sizeof(TIndex));
|
||||||
|
stIndex.m_lLocal = RES_LOCAL_SID;
|
||||||
|
|
||||||
|
pstSavm->pstVoid = &stIndex;
|
||||||
|
pstSavm->bSearch = TYPE_SYSTEM;
|
||||||
|
pstSavm->tblName = SYS_TVM_INDEX;
|
||||||
|
pstSavm->lSize = sizeof(TIndex);
|
||||||
|
if(RC_SUCC != lQuery(pstSavm, &lOut, (void *)&pstIndex))
|
||||||
|
{
|
||||||
|
if(NO_DATA_FOUND == pstSavm->m_lErrno)
|
||||||
|
pstSavm->m_lErrno = TBL_NOT_FOUND;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lOut <= 0) return ;
|
||||||
|
|
||||||
|
fprintf(stdout, "The amount of table is using as follows:\n\n");
|
||||||
|
for(i = 0; i < lOut; i ++)
|
||||||
|
{
|
||||||
|
pstRun = (RunTime *)pGetRunTime(pstSavm, pstIndex[i].m_table);
|
||||||
|
pstRun->m_shmID = pstIndex[i].m_shmID;
|
||||||
|
if(NULL == (pstRun = pInitHitTest(pstSavm, pstIndex[i].m_table)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
memset(szTable, 0, sizeof(szTable));
|
||||||
|
if(!strcmp(pstIndex[i].m_szPart, pstIndex[i].m_szOwner))
|
||||||
|
strcpy(szTable, pstIndex[i].m_szTable);
|
||||||
|
else
|
||||||
|
snprintf(szTable, sizeof(szTable), "%s@%s", pstIndex[i].m_szPart, pstIndex[i].m_szTable);
|
||||||
|
|
||||||
|
vPrintAmount(pstIndex[i].m_table, szTable, lGetTblValid(pstIndex[i].m_table),
|
||||||
|
lGetTblRow(pstIndex[i].m_table));
|
||||||
|
vTblDisconnect(pstSavm, pstIndex[i].m_table);
|
||||||
|
}
|
||||||
|
TFree(pstIndex);
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
description:Printing system index
|
description:Printing system index
|
||||||
parameters:
|
parameters:
|
||||||
|
@ -3474,6 +3607,13 @@ long lExecuteSQL(SATvm *pstSavm, char *pszSQL)
|
||||||
sGetTError(pstSavm->m_lErrno));
|
sGetTError(pstSavm->m_lErrno));
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
}
|
}
|
||||||
|
else if(!strcasecmp(pszSQL, "show tables"))
|
||||||
|
return lShowTables(pstSavm);
|
||||||
|
else if(!strcasecmp(pszSQL, "show info"))
|
||||||
|
{
|
||||||
|
vTableAmount();
|
||||||
|
return RC_SUCC;
|
||||||
|
}
|
||||||
else if(!strncasecmp(pszSQL, "comment ", 8))
|
else if(!strncasecmp(pszSQL, "comment ", 8))
|
||||||
return _lCommentSyntax(pstSavm, pszSQL + 8, false);
|
return _lCommentSyntax(pstSavm, pszSQL + 8, false);
|
||||||
else if(!strncasecmp(pszSQL, "select ", 7))
|
else if(!strncasecmp(pszSQL, "select ", 7))
|
||||||
|
@ -3716,93 +3856,6 @@ void vPrintParam(char *pszOpt)
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************************************
|
|
||||||
description:Output table space Usage
|
|
||||||
parameters:
|
|
||||||
return:
|
|
||||||
**************************************************************************************************/
|
|
||||||
void vPrintAmount(int t, char *pszTable, int nValid, int nMax)
|
|
||||||
{
|
|
||||||
double dPer;
|
|
||||||
int i, nPer;
|
|
||||||
|
|
||||||
if(nValid < 0 || nMax <= 0) return ;
|
|
||||||
|
|
||||||
dPer = nValid * 100.0 / nMax;
|
|
||||||
nPer = nValid * 50 / nMax > 0 ? nValid * 50 / nMax : 1;
|
|
||||||
|
|
||||||
fprintf(stdout, "TABLE:[%3d][%-20s]: [", t, pszTable);
|
|
||||||
if(dPer < 60.00)
|
|
||||||
fprintf(stdout, "\033[42;32m");
|
|
||||||
else if(dPer < 70.00)
|
|
||||||
fprintf(stdout, "\033[45;35m");
|
|
||||||
else if(dPer < 80.00)
|
|
||||||
fprintf(stdout, "\033[46;36m");
|
|
||||||
else if(dPer < 90.00)
|
|
||||||
fprintf(stdout, "\033[43;33m");
|
|
||||||
else
|
|
||||||
fprintf(stdout, "\033[41;31m");
|
|
||||||
|
|
||||||
fflush(stdout);
|
|
||||||
for(i = 0; i < nPer; i ++)
|
|
||||||
{
|
|
||||||
fprintf(stdout, "|");
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stdout, "\033[0m");
|
|
||||||
for(i; i < 50; i ++)
|
|
||||||
fprintf(stdout, " ");
|
|
||||||
fprintf(stdout, "] %.4f%%, (%d/%d)\n", dPer, nValid, nMax);
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************************************
|
|
||||||
description:print system table space usage
|
|
||||||
parameters:
|
|
||||||
return:
|
|
||||||
**************************************************************************************************/
|
|
||||||
void vTableAmount()
|
|
||||||
{
|
|
||||||
size_t i, lOut = 0;
|
|
||||||
RunTime *pstRun = NULL;
|
|
||||||
TIndex stIndex, *pstIndex = NULL;
|
|
||||||
SATvm *pstSavm = (SATvm *)pGetSATvm();
|
|
||||||
|
|
||||||
memset(&stIndex, 0, sizeof(TIndex));
|
|
||||||
stIndex.m_lLocal = RES_LOCAL_SID;
|
|
||||||
|
|
||||||
pstSavm->pstVoid = &stIndex;
|
|
||||||
pstSavm->bSearch = TYPE_SYSTEM;
|
|
||||||
pstSavm->tblName = SYS_TVM_INDEX;
|
|
||||||
pstSavm->lSize = sizeof(TIndex);
|
|
||||||
if(RC_SUCC != lQuery(pstSavm, &lOut, (void *)&pstIndex))
|
|
||||||
{
|
|
||||||
if(NO_DATA_FOUND == pstSavm->m_lErrno)
|
|
||||||
pstSavm->m_lErrno = TBL_NOT_FOUND;
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(lOut <= 0) return ;
|
|
||||||
|
|
||||||
fprintf(stdout, "The amount of table is using as follows:\n\n");
|
|
||||||
for(i = 0; i < lOut; i ++)
|
|
||||||
{
|
|
||||||
pstRun = (RunTime *)pGetRunTime(pstSavm, pstIndex[i].m_table);
|
|
||||||
pstRun->m_shmID = pstIndex[i].m_shmID;
|
|
||||||
if(NULL == (pstRun = pInitHitTest(pstSavm, pstIndex[i].m_table)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
vPrintAmount(pstIndex[i].m_table, pstIndex[i].m_szTable, lGetTblValid(pstIndex[i].m_table),
|
|
||||||
lGetTblRow(pstIndex[i].m_table));
|
|
||||||
vTblDisconnect(pstSavm, pstIndex[i].m_table);
|
|
||||||
}
|
|
||||||
TFree(pstIndex);
|
|
||||||
fprintf(stdout, "\n");
|
|
||||||
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************************************
|
/**************************************************************************************************
|
||||||
description:STVM operation function description
|
description:STVM operation function description
|
||||||
parameters:
|
parameters:
|
||||||
|
@ -4014,7 +4067,9 @@ void vSQLStatement(int argc, char *argv[])
|
||||||
strimcrlf(szSQL);
|
strimcrlf(szSQL);
|
||||||
sltrim(szSQL);
|
sltrim(szSQL);
|
||||||
srtrim(szSQL);
|
srtrim(szSQL);
|
||||||
if(!strlen(szSQL)) continue;
|
if(!strlen(szSQL) || !strncmp(szSQL, "--", 2) || !strncmp(szSQL, "//", 2) ||
|
||||||
|
'#' == szSQL[0])
|
||||||
|
continue;
|
||||||
|
|
||||||
add_history(szSQL);
|
add_history(szSQL);
|
||||||
sfieldreplace(szSQL, '\t', ' ');
|
sfieldreplace(szSQL, '\t', ' ');
|
||||||
|
@ -4110,7 +4165,7 @@ void vConnectDomain(char *pszDomain, TBoot *pstBoot)
|
||||||
}
|
}
|
||||||
|
|
||||||
conditinit(pstSavm, stDomain, SYS_TVM_DOMAIN);
|
conditinit(pstSavm, stDomain, SYS_TVM_DOMAIN);
|
||||||
stringset(pstSavm, stDomain, m_szOwner, pszDomain);
|
conditstr(pstSavm, stDomain, m_szOwner, pszDomain);
|
||||||
decorate(pstSavm, TDomain, m_szOwner, FIRST_ROW);
|
decorate(pstSavm, TDomain, m_szOwner, FIRST_ROW);
|
||||||
if(RC_SUCC != lSelect(pstSavm, (void *)&stDomain))
|
if(RC_SUCC != lSelect(pstSavm, (void *)&stDomain))
|
||||||
{
|
{
|
||||||
|
@ -4157,7 +4212,7 @@ void vPullTableDomain(char *pszParam)
|
||||||
}
|
}
|
||||||
|
|
||||||
conditinit(pstSavm, stDomain, SYS_TVM_DOMAIN);
|
conditinit(pstSavm, stDomain, SYS_TVM_DOMAIN);
|
||||||
stringset(pstSavm, stDomain, m_szOwner, sgetvalue(pszParam, "/", 1));
|
conditstr(pstSavm, stDomain, m_szOwner, sgetvalue(pszParam, "/", 1));
|
||||||
if(!strlen(strimall(stDomain.m_szOwner)))
|
if(!strlen(strimall(stDomain.m_szOwner)))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "*illegal domain name\n");
|
fprintf(stderr, "*illegal domain name\n");
|
||||||
|
@ -4169,7 +4224,7 @@ void vPullTableDomain(char *pszParam)
|
||||||
strncpy(szTable, sgetvalue(szCmd, " ", 1), sizeof(szTable));
|
strncpy(szTable, sgetvalue(szCmd, " ", 1), sizeof(szTable));
|
||||||
strimall(szTable);
|
strimall(szTable);
|
||||||
|
|
||||||
stringset(pstSavm, stDomain, m_szTable, sgetvalue(szTable, "@", 1));
|
conditstr(pstSavm, stDomain, m_szTable, sgetvalue(szTable, "@", 1));
|
||||||
supper(stDomain.m_szTable);
|
supper(stDomain.m_szTable);
|
||||||
if(!strlen(stDomain.m_szTable))
|
if(!strlen(stDomain.m_szTable))
|
||||||
{
|
{
|
||||||
|
@ -4177,7 +4232,7 @@ void vPullTableDomain(char *pszParam)
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
stringset(pstSavm, stDomain, m_szPart, sgetvalue(szTable, "@", 2));
|
conditstr(pstSavm, stDomain, m_szPart, sgetvalue(szTable, "@", 2));
|
||||||
if(!strlen(stDomain.m_szPart))
|
if(!strlen(stDomain.m_szPart))
|
||||||
strcpy(stDomain.m_szPart, stDomain.m_szOwner);
|
strcpy(stDomain.m_szPart, stDomain.m_szOwner);
|
||||||
|
|
||||||
|
|
64
src/tcp.c
64
src/tcp.c
|
@ -775,14 +775,14 @@ long lUpdateDomain(SATvm *pstSavm, char *pszIp, long lPort, long lStatus)
|
||||||
if(RC_SUCC != lInitSATvm(pstSavm, SYS_TVM_DOMAIN))
|
if(RC_SUCC != lInitSATvm(pstSavm, SYS_TVM_DOMAIN))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
updateinit(stUpdate);
|
updateinit(pstSavm, stUpdate);
|
||||||
conditinit(pstSavm, stDomain, SYS_TVM_DOMAIN);
|
conditinit(pstSavm, stDomain, SYS_TVM_DOMAIN);
|
||||||
numberset(pstSavm, stDomain, m_lPort, lPort)
|
conditnum(pstSavm, stDomain, m_lPort, lPort)
|
||||||
stringset(pstSavm, stDomain, m_szIp, pszIp);
|
conditstr(pstSavm, stDomain, m_szIp, pszIp);
|
||||||
|
|
||||||
numberupd(pstSavm, stUpdate, m_lStatus, lStatus);
|
updatenum(pstSavm, stUpdate, m_lStatus, lStatus);
|
||||||
if(RESOURCE_ABLE != lStatus)
|
if(RESOURCE_ABLE != lStatus)
|
||||||
numberupd(pstSavm, stUpdate, m_lPers, 0);
|
updatenum(pstSavm, stUpdate, m_lPers, 0);
|
||||||
if(RC_SUCC != lUpdate(pstSavm, (void *)&stUpdate))
|
if(RC_SUCC != lUpdate(pstSavm, (void *)&stUpdate))
|
||||||
{
|
{
|
||||||
Tlog("update domain (%s:%d) failure, %s\n", pszIp, lPort, sGetTError(pstSavm->m_lErrno));
|
Tlog("update domain (%s:%d) failure, %s\n", pszIp, lPort, sGetTError(pstSavm->m_lErrno));
|
||||||
|
@ -813,10 +813,10 @@ long _lRemodeIndex(SATvm *pstSavm, TFace *pstFace, TDomain *pstDom, TIndex *p
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
conditinit(pstSavm, stDomain, SYS_TVM_DOMAIN);
|
conditinit(pstSavm, stDomain, SYS_TVM_DOMAIN);
|
||||||
numberset(pstSavm, stDomain, m_lPort, pstDom->m_lPort);
|
conditnum(pstSavm, stDomain, m_lPort, pstDom->m_lPort);
|
||||||
stringset(pstSavm, stDomain, m_szIp, pstDom->m_szIp);
|
conditstr(pstSavm, stDomain, m_szIp, pstDom->m_szIp);
|
||||||
numberupd(pstSavm, stRemote, m_lStatus, RESOURCE_AUTH);
|
updatenum(pstSavm, stRemote, m_lStatus, RESOURCE_AUTH);
|
||||||
numberupd(pstSavm, stRemote, m_lPers, 0);
|
updatenum(pstSavm, stRemote, m_lPers, 0);
|
||||||
if(RC_SUCC != lUpdate(pstSavm, (void *)&stRemote))
|
if(RC_SUCC != lUpdate(pstSavm, (void *)&stRemote))
|
||||||
{
|
{
|
||||||
if(NO_DATA_FOUND != pstSavm->m_lErrno)
|
if(NO_DATA_FOUND != pstSavm->m_lErrno)
|
||||||
|
@ -826,20 +826,20 @@ long _lRemodeIndex(SATvm *pstSavm, TFace *pstFace, TDomain *pstDom, TIndex *p
|
||||||
conditinit(pstSavm, stDomain, SYS_TVM_DOMAIN);
|
conditinit(pstSavm, stDomain, SYS_TVM_DOMAIN);
|
||||||
for(i = 0; i < pstFace->m_lRows; i ++)
|
for(i = 0; i < pstFace->m_lRows; i ++)
|
||||||
{
|
{
|
||||||
numberset(pstSavm, stDomain, m_lPort, pstDom->m_lPort);
|
conditnum(pstSavm, stDomain, m_lPort, pstDom->m_lPort);
|
||||||
numberset(pstSavm, stDomain, m_mtable, pstIndex[i].m_table);
|
conditnum(pstSavm, stDomain, m_mtable, pstIndex[i].m_table);
|
||||||
stringset(pstSavm, stDomain, m_szIp, pstDom->m_szIp);
|
conditstr(pstSavm, stDomain, m_szIp, pstDom->m_szIp);
|
||||||
|
|
||||||
updateinit(stRemote);
|
updateinit(pstSavm, stRemote);
|
||||||
numberupd(pstSavm, stRemote, m_lLastTime, time(NULL));
|
updatenum(pstSavm, stRemote, m_lLastTime, time(NULL));
|
||||||
numberupd(pstSavm, stRemote, m_lTryTimes, 0);
|
updatenum(pstSavm, stRemote, m_lTryTimes, 0);
|
||||||
numberupd(pstSavm, stRemote, m_lStatus, RESOURCE_ABLE);
|
updatenum(pstSavm, stRemote, m_lStatus, RESOURCE_ABLE);
|
||||||
numberupd(pstSavm, stRemote, m_skSock, pstDom->m_skSock);
|
updatenum(pstSavm, stRemote, m_skSock, pstDom->m_skSock);
|
||||||
numberupd(pstSavm, stRemote, m_lPers, pstIndex[i].m_lPers);
|
updatenum(pstSavm, stRemote, m_lPers, pstIndex[i].m_lPers);
|
||||||
numberupd(pstSavm, stRemote, m_mtable, pstIndex[i].m_table);
|
updatenum(pstSavm, stRemote, m_mtable, pstIndex[i].m_table);
|
||||||
numberupd(pstSavm, stRemote, m_lRowSize, pstIndex[i].m_lRowSize);
|
updatenum(pstSavm, stRemote, m_lRowSize, pstIndex[i].m_lRowSize);
|
||||||
stringupd(pstSavm, stRemote, m_szPart, pstIndex[i].m_szPart);
|
updatestr(pstSavm, stRemote, m_szPart, pstIndex[i].m_szPart);
|
||||||
stringupd(pstSavm, stRemote, m_szTable, pstIndex[i].m_szTable);
|
updatestr(pstSavm, stRemote, m_szTable, pstIndex[i].m_szTable);
|
||||||
|
|
||||||
if(RC_SUCC != lUpdate(pstSavm, (void *)&stRemote))
|
if(RC_SUCC != lUpdate(pstSavm, (void *)&stRemote))
|
||||||
{
|
{
|
||||||
|
@ -879,8 +879,8 @@ long _lLocalIndex(SATvm *pstSavm, TFace *pstFace, BSock skSock)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
conditinit(pstSavm, stIndex, SYS_TVM_INDEX);
|
conditinit(pstSavm, stIndex, SYS_TVM_INDEX);
|
||||||
numberset(pstSavm, stIndex, m_lType, TYPE_CLIENT);
|
conditnum(pstSavm, stIndex, m_lType, TYPE_CLIENT);
|
||||||
numberset(pstSavm, stIndex, m_lLocal, RES_LOCAL_SID);
|
conditnum(pstSavm, stIndex, m_lLocal, RES_LOCAL_SID);
|
||||||
if(RC_SUCC != lQuery(pstSavm, (size_t *)&pstFace->m_lRows, (void *)&pvOut))
|
if(RC_SUCC != lQuery(pstSavm, (size_t *)&pstFace->m_lRows, (void *)&pvOut))
|
||||||
{
|
{
|
||||||
if(NO_DATA_FOUND != pstSavm->m_lErrno)
|
if(NO_DATA_FOUND != pstSavm->m_lErrno)
|
||||||
|
@ -2208,7 +2208,7 @@ long lCacheDomain(SATvm *pstSavm, Benum eMode, long lPort)
|
||||||
for(list = pGetTblgrp(); list; list = list->pstNext)
|
for(list = pGetTblgrp(); list; list = list->pstNext)
|
||||||
{
|
{
|
||||||
conditinit(pstSavm, stDomain, SYS_TVM_DOMAIN);
|
conditinit(pstSavm, stDomain, SYS_TVM_DOMAIN);
|
||||||
numberset(pstSavm, stDomain, m_table, *((TABLE *)list->psvData));
|
conditnum(pstSavm, stDomain, m_table, *((TABLE *)list->psvData));
|
||||||
if(RC_SUCC != lQuery(pstSavm, &lOut, (void *)&pstDom))
|
if(RC_SUCC != lQuery(pstSavm, &lOut, (void *)&pstDom))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
|
@ -3471,10 +3471,10 @@ long _lRenameTableByRt(SATvm *pstSavm, TABLE to, TABLE tn)
|
||||||
if(RC_SUCC != lInitSATvm(pstSavm, SYS_TVM_DOMAIN))
|
if(RC_SUCC != lInitSATvm(pstSavm, SYS_TVM_DOMAIN))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
updateinit(stUpd);
|
updateinit(pstSavm, stUpd);
|
||||||
conditinit(pstSavm, stDom, SYS_TVM_DOMAIN);
|
conditinit(pstSavm, stDom, SYS_TVM_DOMAIN);
|
||||||
numberset(pstSavm, stDom, m_table, to)
|
conditnum(pstSavm, stDom, m_table, to)
|
||||||
numberupd(pstSavm, stUpd, m_table, tn);
|
updatenum(pstSavm, stUpd, m_table, tn);
|
||||||
|
|
||||||
if(RC_SUCC != lUpdate(pstSavm, &stUpd))
|
if(RC_SUCC != lUpdate(pstSavm, &stUpd))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
@ -5077,9 +5077,9 @@ long lTvmGetTblIndex(SATvm *pstSavm, char *pszTable, char *pszPart, TIndex *p
|
||||||
|
|
||||||
pstSavm->bSearch = TYPE_SYSTEM;
|
pstSavm->bSearch = TYPE_SYSTEM;
|
||||||
conditinit(pstSavm, stIndex, SYS_TVM_INDEX);
|
conditinit(pstSavm, stIndex, SYS_TVM_INDEX);
|
||||||
stringset(pstSavm, stIndex, m_szPart, pszPart);
|
conditstr(pstSavm, stIndex, m_szPart, pszPart);
|
||||||
stringset(pstSavm, stIndex, m_szTable, pszTable);
|
conditstr(pstSavm, stIndex, m_szTable, pszTable);
|
||||||
numberset(pstSavm, stIndex, m_lLocal, RES_LOCAL_SID);
|
conditnum(pstSavm, stIndex, m_lLocal, RES_LOCAL_SID);
|
||||||
if(RC_SUCC != lTvmSelect(pstSavm, (void *)pstIndex))
|
if(RC_SUCC != lTvmSelect(pstSavm, (void *)pstIndex))
|
||||||
{
|
{
|
||||||
if(NO_DATA_FOUND == pstSavm->m_lErrno)
|
if(NO_DATA_FOUND == pstSavm->m_lErrno)
|
||||||
|
@ -5106,7 +5106,7 @@ long lTvmGetTblField(SATvm *pstSavm, TABLE t, size_t *plOut, TField **ppstFie
|
||||||
TField stField;
|
TField stField;
|
||||||
|
|
||||||
conditinit(pstSavm, stField, SYS_TVM_FIELD)
|
conditinit(pstSavm, stField, SYS_TVM_FIELD)
|
||||||
numberset(pstSavm, stField, m_table, t);
|
conditnum(pstSavm, stField, m_table, t);
|
||||||
|
|
||||||
return lTvmQuery(pstSavm, plOut, (void **)ppstField);
|
return lTvmQuery(pstSavm, plOut, (void **)ppstField);
|
||||||
}
|
}
|
||||||
|
|
185
src/tree.c
185
src/tree.c
|
@ -1512,8 +1512,8 @@ void* pPartSATvm(SATvm *pstSavm, char *pszTable, char *pszPart)
|
||||||
|
|
||||||
pstSavm->bSearch = TYPE_SYSTEM;
|
pstSavm->bSearch = TYPE_SYSTEM;
|
||||||
conditinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
conditinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
||||||
stringset(pstSavm, stIndex, m_szPart, pszPart);
|
conditstr(pstSavm, stIndex, m_szPart, pszPart);
|
||||||
stringset(pstSavm, stIndex, m_szTable, pszTable);
|
conditstr(pstSavm, stIndex, m_szTable, pszTable);
|
||||||
if(RC_SUCC != lSelect(pstSavm, (void *)&stIndex))
|
if(RC_SUCC != lSelect(pstSavm, (void *)&stIndex))
|
||||||
{
|
{
|
||||||
if(NO_DATA_FOUND == pstSavm->m_lErrno)
|
if(NO_DATA_FOUND == pstSavm->m_lErrno)
|
||||||
|
@ -1559,7 +1559,7 @@ long lInitSATvm(SATvm *pstSavm, TABLE t)
|
||||||
|
|
||||||
pstSavm->bSearch = TYPE_SYSTEM;
|
pstSavm->bSearch = TYPE_SYSTEM;
|
||||||
conditinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
conditinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
||||||
numberset(pstSavm, stIndex, m_table, t)
|
conditnum(pstSavm, stIndex, m_table, t)
|
||||||
if(RC_SUCC != lSelect(pstSavm, (void *)&stIndex))
|
if(RC_SUCC != lSelect(pstSavm, (void *)&stIndex))
|
||||||
{
|
{
|
||||||
if(NO_DATA_FOUND == pstSavm->m_lErrno)
|
if(NO_DATA_FOUND == pstSavm->m_lErrno)
|
||||||
|
@ -1619,6 +1619,118 @@ key_t yGetIPCPath(SATvm *pstSavm, Benum em)
|
||||||
return tKey;
|
return tKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************
|
||||||
|
description:set alise
|
||||||
|
parameters:
|
||||||
|
pstSavm --stvm handle
|
||||||
|
t --table
|
||||||
|
return:
|
||||||
|
RC_SUCC --success
|
||||||
|
RC_FAIL --failure
|
||||||
|
*************************************************************************************************/
|
||||||
|
long lSetAlias(SATvm *pstSavm, TABLE t, uint ulen, uint uPos, char *alias)
|
||||||
|
{
|
||||||
|
register int i;
|
||||||
|
TblKey *pstKey = (TblKey *)pGetTblKey(t);
|
||||||
|
|
||||||
|
for(i = 0; i < lGetFldNum(t); i ++)
|
||||||
|
{
|
||||||
|
if(pstKey[i].m_lLen != ulen || pstKey[i].m_lFrom != uPos)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
strncpy(pstKey[i].m_szAlias, alias, sizeof(pstKey[i].m_szAlias));
|
||||||
|
return RC_SUCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RC_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************
|
||||||
|
description:map the member of struct value by alias
|
||||||
|
parameters:
|
||||||
|
pstSavm --stvm handle
|
||||||
|
t --table
|
||||||
|
return:
|
||||||
|
RC_SUCC --success
|
||||||
|
RC_FAIL --failure
|
||||||
|
*************************************************************************************************/
|
||||||
|
long lSetTructByAlias(SATvm *pstSavm, TABLE t, void *pvData, const char *key, char *v)
|
||||||
|
{
|
||||||
|
register int i;
|
||||||
|
TblKey *pstKey = (TblKey *)pGetTblKey(t);
|
||||||
|
|
||||||
|
for(i = 0; i < lGetFldNum(t); i ++)
|
||||||
|
{
|
||||||
|
if(strcmp(pstKey[i].m_szAlias, key))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
switch(pstKey[i].m_lAttr)
|
||||||
|
{
|
||||||
|
case FIELD_CHAR:
|
||||||
|
switch(pstKey[i].m_lLen)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
memcpy(v + pstKey[i].m_lFrom, v, pstKey[i].m_lLen);
|
||||||
|
return RC_SUCC;
|
||||||
|
default:
|
||||||
|
strncpy(v + pstKey[i].m_lFrom, v, pstKey[i].m_lLen);
|
||||||
|
return RC_SUCC;
|
||||||
|
}
|
||||||
|
return RC_SUCC;
|
||||||
|
case FIELD_DOUB:
|
||||||
|
switch(pstKey[i].m_lLen)
|
||||||
|
{
|
||||||
|
case 4:
|
||||||
|
*((float *)(v + pstKey[i].m_lFrom)) = atof(v);
|
||||||
|
return RC_SUCC;
|
||||||
|
case 8:
|
||||||
|
*((double *)(v + pstKey[i].m_lFrom)) = atof(v);
|
||||||
|
return RC_SUCC;
|
||||||
|
default:
|
||||||
|
return RC_SUCC;
|
||||||
|
}
|
||||||
|
return RC_SUCC;
|
||||||
|
case FIELD_LONG:
|
||||||
|
switch(pstKey[i].m_lLen)
|
||||||
|
{
|
||||||
|
case 2:
|
||||||
|
*((sint *)(v + pstKey[i].m_lFrom)) = atoi(v);
|
||||||
|
return RC_SUCC;
|
||||||
|
case 4:
|
||||||
|
*((int *)(v + pstKey[i].m_lFrom)) = atoi(v);
|
||||||
|
return RC_SUCC;
|
||||||
|
case 8:
|
||||||
|
*((llong *)(v + pstKey[i].m_lFrom)) = atol(v);
|
||||||
|
return RC_SUCC;
|
||||||
|
default:
|
||||||
|
return RC_SUCC;
|
||||||
|
}
|
||||||
|
return RC_SUCC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return RC_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************
|
||||||
|
description:restore the table define from memory
|
||||||
|
parameters:
|
||||||
|
pstSavm --stvm handle
|
||||||
|
t --table
|
||||||
|
return:
|
||||||
|
RC_SUCC --success
|
||||||
|
RC_FAIL --failure
|
||||||
|
*************************************************************************************************/
|
||||||
|
long lResetDefine(SATvm *pstSavm, TABLE t)
|
||||||
|
{
|
||||||
|
RunTime *pstRun = (RunTime *)pGetRunTime(pstSavm, t);
|
||||||
|
|
||||||
|
if(!pstRun->m_pvAddr) return RC_FAIL;
|
||||||
|
|
||||||
|
memcpy((void *)pGetTblDef(t), pstRun->m_pvAddr, sizeof(TblDef));
|
||||||
|
return RC_SUCC;
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
description:Connect to Shared memory click test
|
description:Connect to Shared memory click test
|
||||||
parameters:
|
parameters:
|
||||||
|
@ -1929,6 +2041,7 @@ long lSetTableIdx(TABLE t, long lFrom, long lLen, char *pszDesc, long lAttr,
|
||||||
pstKey[lGetFldNum(t)].m_lAttr = lAttr;
|
pstKey[lGetFldNum(t)].m_lAttr = lAttr;
|
||||||
pstKey[lGetFldNum(t)].m_lIsPk = lType;
|
pstKey[lGetFldNum(t)].m_lIsPk = lType;
|
||||||
strncpy(pstKey[lGetFldNum(t)].m_szField, pszDesc, sizeof(pstKey[lGetFldNum(t)].m_szField));
|
strncpy(pstKey[lGetFldNum(t)].m_szField, pszDesc, sizeof(pstKey[lGetFldNum(t)].m_szField));
|
||||||
|
strcpy(pstKey[lGetFldNum(t)].m_szAlias, pstKey[lGetFldNum(t)].m_szField);
|
||||||
((TblDef *)pGetTblDef(t))->m_lIdxNum ++;
|
((TblDef *)pGetTblDef(t))->m_lIdxNum ++;
|
||||||
|
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
|
@ -1974,7 +2087,7 @@ long lInsertField(SATvm *pstSavm, TABLE t)
|
||||||
if(NULL == (pstSavm = (SATvm *)pInitSATvm(SYS_TVM_FIELD)))
|
if(NULL == (pstSavm = (SATvm *)pInitSATvm(SYS_TVM_FIELD)))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
insertinit(pstSavm, stField, SYS_TVM_FIELD)
|
defineinit(pstSavm, stField, SYS_TVM_FIELD)
|
||||||
for(i = 0; i < lIdx; i ++)
|
for(i = 0; i < lIdx; i ++)
|
||||||
{
|
{
|
||||||
memset(&stField, 0, sizeof(TField));
|
memset(&stField, 0, sizeof(TField));
|
||||||
|
@ -8262,7 +8375,7 @@ long lInitDomain(SATvm *pstSavm)
|
||||||
if(RC_SUCC != lGetDomainIndex(pstSavm, &lCount, &pstIndex))
|
if(RC_SUCC != lGetDomainIndex(pstSavm, &lCount, &pstIndex))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
insertinit(pstSavm, pstIndex[i], SYS_TVM_INDEX)
|
defineinit(pstSavm, pstIndex[i], SYS_TVM_INDEX)
|
||||||
for(i = 0; i < lCount; i ++)
|
for(i = 0; i < lCount; i ++)
|
||||||
{
|
{
|
||||||
pstIndex[i].m_lValid = 0;
|
pstIndex[i].m_lValid = 0;
|
||||||
|
@ -8289,7 +8402,7 @@ long lInitDomain(SATvm *pstSavm)
|
||||||
{
|
{
|
||||||
pstDomain[i].m_lStatus = RESOURCE_STOP;
|
pstDomain[i].m_lStatus = RESOURCE_STOP;
|
||||||
|
|
||||||
insertinit(pstSavm, pstDomain[i], SYS_TVM_DOMAIN)
|
defineinit(pstSavm, pstDomain[i], SYS_TVM_DOMAIN)
|
||||||
if(RC_SUCC != lInsert(pstSavm))
|
if(RC_SUCC != lInsert(pstSavm))
|
||||||
{
|
{
|
||||||
TFree(pstDomain);
|
TFree(pstDomain);
|
||||||
|
@ -8382,7 +8495,7 @@ long lStartupTvm(TBoot *pstBoot)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
insertinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
defineinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
||||||
if(RC_SUCC != lInsert(pstSavm))
|
if(RC_SUCC != lInsert(pstSavm))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
|
@ -8407,7 +8520,7 @@ long lStartupTvm(TBoot *pstBoot)
|
||||||
strncpy(stIndex.m_szPart, pstBoot->m_szNode, sizeof(stIndex.m_szPart));
|
strncpy(stIndex.m_szPart, pstBoot->m_szNode, sizeof(stIndex.m_szPart));
|
||||||
strncpy(stIndex.m_szTable, sGetTableName(SYS_TVM_FIELD), sizeof(stIndex.m_szTable));
|
strncpy(stIndex.m_szTable, sGetTableName(SYS_TVM_FIELD), sizeof(stIndex.m_szTable));
|
||||||
|
|
||||||
insertinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
defineinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
||||||
if(RC_SUCC != lInsert(pstSavm))
|
if(RC_SUCC != lInsert(pstSavm))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
|
@ -8435,7 +8548,7 @@ long lStartupTvm(TBoot *pstBoot)
|
||||||
strncpy(stIndex.m_szPart, pstBoot->m_szNode, sizeof(stIndex.m_szPart));
|
strncpy(stIndex.m_szPart, pstBoot->m_szNode, sizeof(stIndex.m_szPart));
|
||||||
strncpy(stIndex.m_szTable, sGetTableName(SYS_TVM_DOMAIN), sizeof(stIndex.m_szTable));
|
strncpy(stIndex.m_szTable, sGetTableName(SYS_TVM_DOMAIN), sizeof(stIndex.m_szTable));
|
||||||
|
|
||||||
insertinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
defineinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
||||||
if(RC_SUCC != lInsert(pstSavm))
|
if(RC_SUCC != lInsert(pstSavm))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
|
@ -8463,7 +8576,7 @@ long lStartupTvm(TBoot *pstBoot)
|
||||||
strncpy(stIndex.m_szPart, pstBoot->m_szNode, sizeof(stIndex.m_szPart));
|
strncpy(stIndex.m_szPart, pstBoot->m_szNode, sizeof(stIndex.m_szPart));
|
||||||
strncpy(stIndex.m_szTable, sGetTableName(SYS_TVM_SEQUE), sizeof(stIndex.m_szTable));
|
strncpy(stIndex.m_szTable, sGetTableName(SYS_TVM_SEQUE), sizeof(stIndex.m_szTable));
|
||||||
|
|
||||||
insertinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
defineinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
||||||
if(RC_SUCC != lInsert(pstSavm))
|
if(RC_SUCC != lInsert(pstSavm))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
|
@ -8526,8 +8639,8 @@ long lDropTable(SATvm *pstSavm, TABLE t)
|
||||||
|
|
||||||
pstSavm->bSearch = TYPE_SYSTEM;
|
pstSavm->bSearch = TYPE_SYSTEM;
|
||||||
conditinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
conditinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
||||||
numberset(pstSavm, stIndex, m_table, t)
|
conditnum(pstSavm, stIndex, m_table, t)
|
||||||
numberset(pstSavm, stIndex, m_lType, TYPE_CLIENT)
|
conditnum(pstSavm, stIndex, m_lType, TYPE_CLIENT)
|
||||||
if(RC_SUCC != lSelect(pstSavm, (void *)&stIndex))
|
if(RC_SUCC != lSelect(pstSavm, (void *)&stIndex))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
|
@ -8535,8 +8648,8 @@ long lDropTable(SATvm *pstSavm, TABLE t)
|
||||||
if(RES_REMOT_SID == pstRun->m_lLocal)
|
if(RES_REMOT_SID == pstRun->m_lLocal)
|
||||||
{
|
{
|
||||||
conditinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
conditinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
||||||
numberset(pstSavm, stIndex, m_table, t)
|
conditnum(pstSavm, stIndex, m_table, t)
|
||||||
numberset(pstSavm, stIndex, m_lType, TYPE_CLIENT)
|
conditnum(pstSavm, stIndex, m_lType, TYPE_CLIENT)
|
||||||
if(RC_SUCC != lDelete(pstSavm))
|
if(RC_SUCC != lDelete(pstSavm))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
|
@ -8560,8 +8673,8 @@ long lDropTable(SATvm *pstSavm, TABLE t)
|
||||||
semctl(stIndex.m_semID, 0, IPC_RMID, 0);
|
semctl(stIndex.m_semID, 0, IPC_RMID, 0);
|
||||||
|
|
||||||
conditinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
conditinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
||||||
numberset(pstSavm, stIndex, m_table, t)
|
conditnum(pstSavm, stIndex, m_table, t)
|
||||||
numberset(pstSavm, stIndex, m_lType, TYPE_CLIENT)
|
conditnum(pstSavm, stIndex, m_lType, TYPE_CLIENT)
|
||||||
if(RC_SUCC != lDelete(pstSavm)) return RC_FAIL;
|
if(RC_SUCC != lDelete(pstSavm)) return RC_FAIL;
|
||||||
|
|
||||||
// Delete the field table
|
// Delete the field table
|
||||||
|
@ -8569,7 +8682,7 @@ long lDropTable(SATvm *pstSavm, TABLE t)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
conditinit(pstSavm, stField, SYS_TVM_FIELD)
|
conditinit(pstSavm, stField, SYS_TVM_FIELD)
|
||||||
numberset(pstSavm, stField, m_table, t)
|
conditnum(pstSavm, stField, m_table, t)
|
||||||
if(RC_SUCC != lDelete(pstSavm)) return RC_FAIL;
|
if(RC_SUCC != lDelete(pstSavm)) return RC_FAIL;
|
||||||
|
|
||||||
memset(pstRun, 0, sizeof(RunTime));
|
memset(pstRun, 0, sizeof(RunTime));
|
||||||
|
@ -8979,7 +9092,7 @@ long lGetTblField(TABLE t, size_t *plOut, TField **ppstField)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
conditinit(pstSavm, stField, SYS_TVM_FIELD)
|
conditinit(pstSavm, stField, SYS_TVM_FIELD)
|
||||||
numberset(pstSavm, stField, m_table, t)
|
conditnum(pstSavm, stField, m_table, t)
|
||||||
return lQuery(pstSavm, plOut, (void **)ppstField);
|
return lQuery(pstSavm, plOut, (void **)ppstField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9006,9 +9119,9 @@ long lGetTblIndex(SATvm *pstSavm, char *pszTable, char *pszPart, TIndex *pstI
|
||||||
|
|
||||||
pstSavm->bSearch = TYPE_SYSTEM;
|
pstSavm->bSearch = TYPE_SYSTEM;
|
||||||
conditinit(pstSavm, stIndex, SYS_TVM_INDEX);
|
conditinit(pstSavm, stIndex, SYS_TVM_INDEX);
|
||||||
stringset(pstSavm, stIndex, m_szPart, pszPart);
|
conditstr(pstSavm, stIndex, m_szPart, pszPart);
|
||||||
stringset(pstSavm, stIndex, m_szTable, pszTable);
|
conditstr(pstSavm, stIndex, m_szTable, pszTable);
|
||||||
numberset(pstSavm, stIndex, m_lLocal, RES_LOCAL_SID);
|
conditnum(pstSavm, stIndex, m_lLocal, RES_LOCAL_SID);
|
||||||
if(RC_SUCC != lSelect(pstSavm, (void *)pstIndex))
|
if(RC_SUCC != lSelect(pstSavm, (void *)pstIndex))
|
||||||
{
|
{
|
||||||
if(NO_DATA_FOUND == pstSavm->m_lErrno)
|
if(NO_DATA_FOUND == pstSavm->m_lErrno)
|
||||||
|
@ -9040,12 +9153,12 @@ long lUpdIndexPart(SATvm *pstSavm, TABLE t, char *pszPart)
|
||||||
}
|
}
|
||||||
|
|
||||||
pstSavm->bSearch = TYPE_SYSTEM;
|
pstSavm->bSearch = TYPE_SYSTEM;
|
||||||
updateinit(stUpdate);
|
updateinit(pstSavm, stUpdate);
|
||||||
conditinit(pstSavm, stIndex, SYS_TVM_INDEX);
|
conditinit(pstSavm, stIndex, SYS_TVM_INDEX);
|
||||||
numberset(pstSavm, stIndex, m_table, t)
|
conditnum(pstSavm, stIndex, m_table, t)
|
||||||
numberset(pstSavm, stIndex, m_lLocal, RES_LOCAL_SID);
|
conditnum(pstSavm, stIndex, m_lLocal, RES_LOCAL_SID);
|
||||||
|
|
||||||
stringupd(pstSavm, stUpdate, m_szPart, pszPart);
|
updatestr(pstSavm, stUpdate, m_szPart, pszPart);
|
||||||
return lUpdate(pstSavm, &stUpdate);
|
return lUpdate(pstSavm, &stUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9064,7 +9177,7 @@ bool bTableIsExist(TABLE t)
|
||||||
|
|
||||||
pstSavm->bSearch = TYPE_SYSTEM;
|
pstSavm->bSearch = TYPE_SYSTEM;
|
||||||
conditinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
conditinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
||||||
numberset(pstSavm, stIndex, m_table, t)
|
conditnum(pstSavm, stIndex, m_table, t)
|
||||||
if(RC_SUCC != lSelect(pstSavm, (void *)&stIndex))
|
if(RC_SUCC != lSelect(pstSavm, (void *)&stIndex))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -9088,10 +9201,10 @@ long lRenameTable(SATvm *pstSavm, TABLE to, TABLE tn)
|
||||||
TField stField, stNFld;
|
TField stField, stNFld;
|
||||||
|
|
||||||
pstSavm->bSearch = TYPE_SYSTEM;
|
pstSavm->bSearch = TYPE_SYSTEM;
|
||||||
updateinit(stNIdx);
|
updateinit(pstSavm, stNIdx);
|
||||||
conditinit(pstSavm, stIndex, SYS_TVM_INDEX);
|
conditinit(pstSavm, stIndex, SYS_TVM_INDEX);
|
||||||
numberset(pstSavm, stIndex, m_table, to);
|
conditnum(pstSavm, stIndex, m_table, to);
|
||||||
numberupd(pstSavm, stNIdx, m_table, tn);
|
updatenum(pstSavm, stNIdx, m_table, tn);
|
||||||
|
|
||||||
if(RC_SUCC != lUpdate(pstSavm, &stNIdx))
|
if(RC_SUCC != lUpdate(pstSavm, &stNIdx))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
@ -9114,10 +9227,10 @@ long lRenameTable(SATvm *pstSavm, TABLE to, TABLE tn)
|
||||||
if(RC_SUCC != lInitSATvm(pstSavm, SYS_TVM_FIELD))
|
if(RC_SUCC != lInitSATvm(pstSavm, SYS_TVM_FIELD))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
updateinit(stNFld);
|
updateinit(pstSavm, stNFld);
|
||||||
conditinit(pstSavm, stField, SYS_TVM_FIELD);
|
conditinit(pstSavm, stField, SYS_TVM_FIELD);
|
||||||
numberset(pstSavm, stField, m_table, to);
|
conditnum(pstSavm, stField, m_table, to);
|
||||||
numberupd(pstSavm, stNFld, m_table, tn);
|
updatenum(pstSavm, stNFld, m_table, tn);
|
||||||
return lUpdate(pstSavm, &stNFld);
|
return lUpdate(pstSavm, &stNFld);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9136,9 +9249,9 @@ bool bPartIsExist(char *pszTable, char *pszPart)
|
||||||
|
|
||||||
pstSavm->bSearch = TYPE_SYSTEM;
|
pstSavm->bSearch = TYPE_SYSTEM;
|
||||||
conditinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
conditinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
||||||
stringset(pstSavm, stIndex, m_szPart, pszPart)
|
conditstr(pstSavm, stIndex, m_szPart, pszPart)
|
||||||
stringset(pstSavm, stIndex, m_szTable, pszTable)
|
conditstr(pstSavm, stIndex, m_szTable, pszTable)
|
||||||
numberset(pstSavm, stIndex, m_lLocal, RES_LOCAL_SID)
|
conditnum(pstSavm, stIndex, m_lLocal, RES_LOCAL_SID)
|
||||||
if(RC_SUCC != lSelect(pstSavm, (void *)&stIndex))
|
if(RC_SUCC != lSelect(pstSavm, (void *)&stIndex))
|
||||||
{
|
{
|
||||||
if(MORE_ROWS_SEL == pstSavm->m_lErrno)
|
if(MORE_ROWS_SEL == pstSavm->m_lErrno)
|
||||||
|
@ -9171,7 +9284,7 @@ long lTableMaxRow(SATvm *pstSavm, TABLE t)
|
||||||
|
|
||||||
pstSavm->bSearch = TYPE_SYSTEM;
|
pstSavm->bSearch = TYPE_SYSTEM;
|
||||||
conditinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
conditinit(pstSavm, stIndex, SYS_TVM_INDEX)
|
||||||
numberset(pstSavm, stIndex, m_table, t)
|
conditnum(pstSavm, stIndex, m_table, t)
|
||||||
if(RC_SUCC != lSelect(pstSavm, (void *)&stIndex))
|
if(RC_SUCC != lSelect(pstSavm, (void *)&stIndex))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue