fix M-SQL select data disorder from queue
parent
09a47596f3
commit
acd4542b0c
|
@ -20,9 +20,9 @@ STVM(truck of Virtual memory table)是一个开源的使用ANSI C语言编
|
||||||
* 多机集群无法使用事务。
|
* 多机集群无法使用事务。
|
||||||
* 数据无法持久化(宕机情况)。
|
* 数据无法持久化(宕机情况)。
|
||||||
* 索引长度限制(默认64字节),修改需编译项目。
|
* 索引长度限制(默认64字节),修改需编译项目。
|
||||||
* 启动后不能修改表字段
|
* 启动后不能修改表字段,但可以修改字段别名
|
||||||
|
|
||||||
建议使用场景:***数据库缓存、数据缓存***
|
建议使用场景:***数据库缓存、数据缓存、事件驱动***
|
||||||
|
|
||||||
不定时更新 https://my.oschina.net/deffpuzzl/blog/1627626
|
不定时更新 https://my.oschina.net/deffpuzzl/blog/1627626
|
||||||
|
|
||||||
|
|
2
bin/msql
2
bin/msql
|
@ -1,2 +1,2 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
stvm SQL --showmode=row --showsize=5
|
stvm SQL --showmode=row --showsize=8
|
||||||
|
|
|
@ -32,7 +32,7 @@ int main(int argc, char *argv[])
|
||||||
SATvm *pstSavm = (SATvm *)pGetSATvm();
|
SATvm *pstSavm = (SATvm *)pGetSATvm();
|
||||||
|
|
||||||
// if(RC_SUCC != lCreateQueue(pstSavm, QUEUE_USER_INFO, 1000000, sizeof(szMsg), ""))
|
// if(RC_SUCC != lCreateQueue(pstSavm, QUEUE_USER_INFO, 1000000, sizeof(szMsg), ""))
|
||||||
if(RC_SUCC != lTableQueue(pstSavm, QUEUE_USER_INFO, 50000, lQueueUserInfo))
|
if(RC_SUCC != lTableQueue(pstSavm, QUEUE_USER_INFO, 30, lQueueUserInfo))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "create queue %d failed, err: %s\n", QUEUE_USER_INFO, sGetTError(pstSavm->m_lErrno));
|
fprintf(stderr, "create queue %d failed, err: %s\n", QUEUE_USER_INFO, sGetTError(pstSavm->m_lErrno));
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
typedef struct __TBL_USER_INFO
|
typedef struct __TBL_USER_INFO
|
||||||
{
|
{
|
||||||
long acct_id;
|
llong acct_id;
|
||||||
char user_no[21];
|
char user_no[21];
|
||||||
char user_type[2];
|
char user_type[2];
|
||||||
char user_nm[81];
|
char user_nm[81];
|
||||||
|
@ -27,8 +27,8 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
conditinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量
|
conditinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量
|
||||||
// stUser.acct_id = time(NULL); // 对结构体赋值
|
// stUser.acct_id = 7; // 对结构体赋值
|
||||||
strcpy(stUser.user_no, "20180224"); // 对结构体赋值
|
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"); // 对结构体赋值
|
||||||
|
|
|
@ -312,6 +312,7 @@ typedef long CREATE;
|
||||||
#define MQUE_CRTE_BIG 99 // created queue is too big
|
#define MQUE_CRTE_BIG 99 // created queue is too big
|
||||||
#define NOT_SUPPT_OPT 100 // queue does not support this operation
|
#define NOT_SUPPT_OPT 100 // queue does not support this operation
|
||||||
#define SERV_NOT_CONN 101 // not connect server
|
#define SERV_NOT_CONN 101 // not connect server
|
||||||
|
#define PART_AR_EXIST 102 // partion already exist
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
创建表宏函数
|
创建表宏函数
|
||||||
|
|
|
@ -206,7 +206,7 @@ long _lPops(SATvm *pstSavm, void *pvAddr, size_t lExpect, Timesp *tm, size_t
|
||||||
void **ppsvOut)
|
void **ppsvOut)
|
||||||
{
|
{
|
||||||
Timesp tms;
|
Timesp tms;
|
||||||
int nPos;
|
int nPos, i = 0;
|
||||||
SHTruck *ps = NULL;
|
SHTruck *ps = NULL;
|
||||||
extern int errno;
|
extern int errno;
|
||||||
TblDef *pv = (TblDef *)pvAddr;
|
TblDef *pv = (TblDef *)pvAddr;
|
||||||
|
@ -264,6 +264,7 @@ long _lPops(SATvm *pstSavm, void *pvAddr, size_t lExpect, Timesp *tm, size_t
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retrys:
|
||||||
/* at least cost one vaild */
|
/* at least cost one vaild */
|
||||||
if(pv->m_lMaxRow > (nPos = __sync_add_and_fetch(&pv->m_lListOfs, 1)))
|
if(pv->m_lMaxRow > (nPos = __sync_add_and_fetch(&pv->m_lListOfs, 1)))
|
||||||
;
|
;
|
||||||
|
@ -272,6 +273,8 @@ long _lPops(SATvm *pstSavm, void *pvAddr, size_t lExpect, Timesp *tm, size_t
|
||||||
|
|
||||||
ps = (PSHTruck)pGetNode(pvAddr, pv->m_lData + pv->m_lTruck * nPos);
|
ps = (PSHTruck)pGetNode(pvAddr, pv->m_lData + pv->m_lTruck * nPos);
|
||||||
if(IS_TRUCK_NULL(ps))
|
if(IS_TRUCK_NULL(ps))
|
||||||
|
{
|
||||||
|
if((++ i) > pv->m_lMaxRow)
|
||||||
{
|
{
|
||||||
*plOut = 0;
|
*plOut = 0;
|
||||||
TFree(*ppsvOut);
|
TFree(*ppsvOut);
|
||||||
|
@ -279,6 +282,9 @@ long _lPops(SATvm *pstSavm, void *pvAddr, size_t lExpect, Timesp *tm, size_t
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
goto retrys;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(*ppsvOut + (*plOut) * pv->m_lReSize, ps->m_pvData, pv->m_lReSize);
|
memcpy(*ppsvOut + (*plOut) * pv->m_lReSize, ps->m_pvData, pv->m_lReSize);
|
||||||
SET_DATA_TRUCK(ps, DATA_TRUCK_NULL);
|
SET_DATA_TRUCK(ps, DATA_TRUCK_NULL);
|
||||||
++ (*plOut);
|
++ (*plOut);
|
||||||
|
|
183
src/stvm.c
183
src/stvm.c
|
@ -288,12 +288,12 @@ int sizecn(TblKey *pstKey, long lfld)
|
||||||
parameters:
|
parameters:
|
||||||
s --string
|
s --string
|
||||||
len --strlen length
|
len --strlen length
|
||||||
pstTde --Table define
|
ps --Table define
|
||||||
return:
|
return:
|
||||||
RC_SUCC --success
|
RC_SUCC --success
|
||||||
RC_FAIL --failure
|
RC_FAIL --failure
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
long lAnalysHead(char *s, long len, TblDef *pstTde)
|
long lAnalysHead(char *s, long len, TblDef *ps)
|
||||||
{
|
{
|
||||||
long i, n;
|
long i, n;
|
||||||
char szTemp[512], szHead[512], szTar[64], *p = NULL;
|
char szTemp[512], szHead[512], szTar[64], *p = NULL;
|
||||||
|
@ -324,34 +324,34 @@ long lAnalysHead(char *s, long len, TblDef *pstTde)
|
||||||
sltrim(szTar);
|
sltrim(szTar);
|
||||||
if(!strcasecmp(szTar, "TABLE"))
|
if(!strcasecmp(szTar, "TABLE"))
|
||||||
{
|
{
|
||||||
pstTde->m_table = atol(sfieldvalue(szTemp + 4, "=", 2));
|
ps->m_table = atol(sfieldvalue(szTemp + 4, "=", 2));
|
||||||
if(pstTde->m_table < 5)
|
if(ps->m_table < 5)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "definition table error\n");
|
fprintf(stderr, "definition table error\n");
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!strcasecmp(szTar, "TABLESPACE"))
|
else if(!strcasecmp(szTar, "TABLESPACE"))
|
||||||
pstTde->m_lMaxRow = atol(sfieldvalue(szTemp + 4, "=", 2));
|
ps->m_lMaxRow = atol(sfieldvalue(szTemp + 4, "=", 2));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Unrecognized command\n*%s\n", szTemp);
|
fprintf(stderr, "Unrecognized command\n*%s\n", szTemp);
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(pstTde->m_table < 5)
|
if(ps->m_table < 5)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "table not define\n");
|
fprintf(stderr, "table not define\n");
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pstTde->m_lMaxRow <= 0)
|
if(ps->m_lMaxRow <= 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "table size node define\n");
|
fprintf(stderr, "table size node define\n");
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(pstTde->m_szPart, sGetNode());
|
strcpy(ps->m_szPart, sGetNode());
|
||||||
|
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
}
|
}
|
||||||
|
@ -359,21 +359,21 @@ long lAnalysHead(char *s, long len, TblDef *pstTde)
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
description:alias table field name
|
description:alias table field name
|
||||||
parameters:
|
parameters:
|
||||||
pstTde --Table define
|
ps --Table define
|
||||||
pszField --string
|
pszField --string
|
||||||
pszAlias --string
|
pszAlias --string
|
||||||
return:
|
return:
|
||||||
RC_SUCC --success
|
RC_SUCC --success
|
||||||
RC_FAIL --failure
|
RC_FAIL --failure
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
long lTableAliase(TblDef *pstTde, char *pszField, char *pszAlias)
|
long lTableAliase(TblDef *ps, char *pszField, char *pszAlias)
|
||||||
{
|
{
|
||||||
long i = 0;
|
long i = 0;
|
||||||
TblKey *pv = NULL;
|
TblKey *pv = NULL;
|
||||||
|
|
||||||
for(i = 0; i < pstTde->m_lIdxNum; i ++)
|
for(i = 0; i < ps->m_lIdxNum; i ++)
|
||||||
{
|
{
|
||||||
pv = &pstTde->m_stKey[i];
|
pv = &ps->m_stKey[i];
|
||||||
if(strcmp(pv->m_szField, pszField))
|
if(strcmp(pv->m_szField, pszField))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -388,7 +388,6 @@ long lTableAliase(TblDef *pstTde, char *pszField, char *pszAlias)
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
description:alias the table field name
|
description:alias the table field name
|
||||||
parameters:
|
parameters:
|
||||||
pstTde --Table define
|
|
||||||
pszField --string
|
pszField --string
|
||||||
pszAlias --string
|
pszAlias --string
|
||||||
return:
|
return:
|
||||||
|
@ -435,12 +434,12 @@ long _lParseAlias(SATvm *pstSavm, char *pszTable, char *pszField, char *pszAl
|
||||||
parameters:
|
parameters:
|
||||||
s --string
|
s --string
|
||||||
len --strlen length
|
len --strlen length
|
||||||
pstTde --Table define
|
ps --Table define
|
||||||
return:
|
return:
|
||||||
RC_SUCC --success
|
RC_SUCC --success
|
||||||
RC_FAIL --failure
|
RC_FAIL --failure
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
long lAnalysTable(char *s, long len, TblDef *pstTde)
|
long lAnalysTable(char *s, long len, TblDef *ps)
|
||||||
{
|
{
|
||||||
long i, n, k;
|
long i, n, k;
|
||||||
TblKey *pv = NULL;
|
TblKey *pv = NULL;
|
||||||
|
@ -455,7 +454,7 @@ long lAnalysTable(char *s, long len, TblDef *pstTde)
|
||||||
|
|
||||||
strncpy(szField, s, len);
|
strncpy(szField, s, len);
|
||||||
strimabout(szField, "(", ")");
|
strimabout(szField, "(", ")");
|
||||||
for(i = 0, n = lgetstrnum(szField, "\n"), pstTde->m_lIdxNum = 0; i < n; i ++)
|
for(i = 0, n = lgetstrnum(szField, "\n"), ps->m_lIdxNum = 0; i < n; i ++)
|
||||||
{
|
{
|
||||||
memset(szTemp, 0, sizeof(szTemp));
|
memset(szTemp, 0, sizeof(szTemp));
|
||||||
strncpy(szTemp, sfieldvalue(szField, "\n", i + 1), sizeof(szTemp));
|
strncpy(szTemp, sfieldvalue(szField, "\n", i + 1), sizeof(szTemp));
|
||||||
|
@ -466,7 +465,7 @@ long lAnalysTable(char *s, long len, TblDef *pstTde)
|
||||||
if('#' == szTemp[0] || !strncmp(szTemp, "--", 2) || !strlen(szTemp))
|
if('#' == szTemp[0] || !strncmp(szTemp, "--", 2) || !strlen(szTemp))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pv = &pstTde->m_stKey[pstTde->m_lIdxNum];
|
pv = &ps->m_stKey[ps->m_lIdxNum];
|
||||||
strncpy(pv->m_szField, sfieldvalue(szTemp, " ", 1), MAX_FIELD_LEN);
|
strncpy(pv->m_szField, sfieldvalue(szTemp, " ", 1), MAX_FIELD_LEN);
|
||||||
strcpy(pv->m_szAlias, pv->m_szField);
|
strcpy(pv->m_szAlias, pv->m_szField);
|
||||||
if(!strlen(pv->m_szField))
|
if(!strlen(pv->m_szField))
|
||||||
|
@ -535,7 +534,7 @@ long lAnalysTable(char *s, long len, TblDef *pstTde)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pstTde->m_lIdxNum ++;
|
ps->m_lIdxNum ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
|
@ -545,13 +544,13 @@ long lAnalysTable(char *s, long len, TblDef *pstTde)
|
||||||
description:creates the table index
|
description:creates the table index
|
||||||
parameters:
|
parameters:
|
||||||
s --string
|
s --string
|
||||||
pstTde --Table define
|
ps --Table define
|
||||||
em --index type
|
em --index type
|
||||||
return:
|
return:
|
||||||
RC_SUCC --success
|
RC_SUCC --success
|
||||||
RC_FAIL --failure
|
RC_FAIL --failure
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
long lIndexField(char *s, TblDef *pstTde, Uenum em)
|
long lIndexField(char *s, TblDef *ps, Uenum em)
|
||||||
{
|
{
|
||||||
long i, n;
|
long i, n;
|
||||||
TblKey *pstKey = NULL;
|
TblKey *pstKey = NULL;
|
||||||
|
@ -560,68 +559,68 @@ long lIndexField(char *s, TblDef *pstTde, Uenum em)
|
||||||
n = lfieldnum(s, ",");
|
n = lfieldnum(s, ",");
|
||||||
if(UNQIUE == em)
|
if(UNQIUE == em)
|
||||||
{
|
{
|
||||||
for(i = 0, pstTde->m_lIType |= UNQIUE, pstTde->m_lIdxUp = 0; i < n; i ++)
|
for(i = 0, ps->m_lIType |= UNQIUE, ps->m_lIdxUp = 0; i < n; i ++)
|
||||||
{
|
{
|
||||||
memset(szField, 0, MAX_FIELD_LEN);
|
memset(szField, 0, MAX_FIELD_LEN);
|
||||||
strncpy(szField, sfieldvalue(s, ",", i + 1), MAX_FIELD_LEN);
|
strncpy(szField, sfieldvalue(s, ",", i + 1), MAX_FIELD_LEN);
|
||||||
strimcrlf(szField);
|
strimcrlf(szField);
|
||||||
strimall(szField);
|
strimall(szField);
|
||||||
if(NULL == (pstKey = pFindField(pstTde->m_stKey, pstTde->m_lIdxNum, szField)))
|
if(NULL == (pstKey = pFindField(ps->m_stKey, ps->m_lIdxNum, szField)))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
strcpy(pstTde->m_stIdxUp[pstTde->m_lIdxUp].m_szField, szField);
|
strcpy(ps->m_stIdxUp[ps->m_lIdxUp].m_szField, szField);
|
||||||
pstTde->m_stIdxUp[pstTde->m_lIdxUp].m_lFrom = pstKey->m_lFrom;
|
ps->m_stIdxUp[ps->m_lIdxUp].m_lFrom = pstKey->m_lFrom;
|
||||||
pstTde->m_stIdxUp[pstTde->m_lIdxUp].m_lLen = pstKey->m_lLen;
|
ps->m_stIdxUp[ps->m_lIdxUp].m_lLen = pstKey->m_lLen;
|
||||||
pstTde->m_stIdxUp[pstTde->m_lIdxUp].m_lAttr = pstKey->m_lAttr;
|
ps->m_stIdxUp[ps->m_lIdxUp].m_lAttr = pstKey->m_lAttr;
|
||||||
pstTde->m_lIdxLen += pstKey->m_lLen;
|
ps->m_lIdxLen += pstKey->m_lLen;
|
||||||
pstTde->m_lIdxUp ++;
|
ps->m_lIdxUp ++;
|
||||||
}
|
}
|
||||||
if(0 == pstTde->m_lIdxUp)
|
if(0 == ps->m_lIdxUp)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
}
|
}
|
||||||
else if(NORMAL == em)
|
else if(NORMAL == em)
|
||||||
{
|
{
|
||||||
for(i = 0, pstTde->m_lIType |= NORMAL, pstTde->m_lGrpUp = 0; i < n; i ++)
|
for(i = 0, ps->m_lIType |= NORMAL, ps->m_lGrpUp = 0; i < n; i ++)
|
||||||
{
|
{
|
||||||
memset(szField, 0, MAX_FIELD_LEN);
|
memset(szField, 0, MAX_FIELD_LEN);
|
||||||
strncpy(szField, sfieldvalue(s, ",", i + 1), MAX_FIELD_LEN);
|
strncpy(szField, sfieldvalue(s, ",", i + 1), MAX_FIELD_LEN);
|
||||||
strimcrlf(szField);
|
strimcrlf(szField);
|
||||||
strimall(szField);
|
strimall(szField);
|
||||||
if(NULL == (pstKey = pFindField(pstTde->m_stKey, pstTde->m_lIdxNum, szField)))
|
if(NULL == (pstKey = pFindField(ps->m_stKey, ps->m_lIdxNum, szField)))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
strcpy(pstTde->m_stGrpUp[pstTde->m_lGrpUp].m_szField, szField);
|
strcpy(ps->m_stGrpUp[ps->m_lGrpUp].m_szField, szField);
|
||||||
pstTde->m_stGrpUp[pstTde->m_lGrpUp].m_lFrom = pstKey->m_lFrom;
|
ps->m_stGrpUp[ps->m_lGrpUp].m_lFrom = pstKey->m_lFrom;
|
||||||
pstTde->m_stGrpUp[pstTde->m_lGrpUp].m_lLen = pstKey->m_lLen;
|
ps->m_stGrpUp[ps->m_lGrpUp].m_lLen = pstKey->m_lLen;
|
||||||
pstTde->m_stGrpUp[pstTde->m_lGrpUp].m_lAttr = pstKey->m_lAttr;
|
ps->m_stGrpUp[ps->m_lGrpUp].m_lAttr = pstKey->m_lAttr;
|
||||||
pstTde->m_lGrpLen += pstKey->m_lLen;
|
ps->m_lGrpLen += pstKey->m_lLen;
|
||||||
pstTde->m_lGrpUp ++;
|
ps->m_lGrpUp ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(0 == pstTde->m_lGrpUp)
|
if(0 == ps->m_lGrpUp)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
}
|
}
|
||||||
else if(HASHID == em)
|
else if(HASHID == em)
|
||||||
{
|
{
|
||||||
for(i = 0, pstTde->m_lIType |= HASHID, pstTde->m_lGrpUp = 0; i < n; i ++)
|
for(i = 0, ps->m_lIType |= HASHID, ps->m_lGrpUp = 0; i < n; i ++)
|
||||||
{
|
{
|
||||||
memset(szField, 0, MAX_FIELD_LEN);
|
memset(szField, 0, MAX_FIELD_LEN);
|
||||||
strncpy(szField, sfieldvalue(s, ",", i + 1), MAX_FIELD_LEN);
|
strncpy(szField, sfieldvalue(s, ",", i + 1), MAX_FIELD_LEN);
|
||||||
strimcrlf(szField);
|
strimcrlf(szField);
|
||||||
strimall(szField);
|
strimall(szField);
|
||||||
if(NULL == (pstKey = pFindField(pstTde->m_stKey, pstTde->m_lIdxNum, szField)))
|
if(NULL == (pstKey = pFindField(ps->m_stKey, ps->m_lIdxNum, szField)))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
strcpy(pstTde->m_stGrpUp[pstTde->m_lGrpUp].m_szField, szField);
|
strcpy(ps->m_stGrpUp[ps->m_lGrpUp].m_szField, szField);
|
||||||
pstTde->m_stGrpUp[pstTde->m_lGrpUp].m_lFrom = pstKey->m_lFrom;
|
ps->m_stGrpUp[ps->m_lGrpUp].m_lFrom = pstKey->m_lFrom;
|
||||||
pstTde->m_stGrpUp[pstTde->m_lGrpUp].m_lLen = pstKey->m_lLen;
|
ps->m_stGrpUp[ps->m_lGrpUp].m_lLen = pstKey->m_lLen;
|
||||||
pstTde->m_stGrpUp[pstTde->m_lGrpUp].m_lAttr = pstKey->m_lAttr;
|
ps->m_stGrpUp[ps->m_lGrpUp].m_lAttr = pstKey->m_lAttr;
|
||||||
pstTde->m_lGrpLen += pstKey->m_lLen;
|
ps->m_lGrpLen += pstKey->m_lLen;
|
||||||
pstTde->m_lGrpUp ++;
|
ps->m_lGrpUp ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(0 == pstTde->m_lGrpUp)
|
if(0 == ps->m_lGrpUp)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
}
|
}
|
||||||
|
@ -633,13 +632,13 @@ long lIndexField(char *s, TblDef *pstTde, Uenum em)
|
||||||
description:analysis of the header index
|
description:analysis of the header index
|
||||||
parameters:
|
parameters:
|
||||||
s --string
|
s --string
|
||||||
pstTde --Table define
|
ps --Table define
|
||||||
em --index type
|
em --index type
|
||||||
return:
|
return:
|
||||||
RC_SUCC --success
|
RC_SUCC --success
|
||||||
RC_FAIL --failure
|
RC_FAIL --failure
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
long lAnalysIndex(char *s, long len, TblDef *pstTde)
|
long lAnalysIndex(char *s, long len, TblDef *ps)
|
||||||
{
|
{
|
||||||
long i, n, k, lRet;
|
long i, n, k, lRet;
|
||||||
char szIndex[1024], szTemp[256], *p = NULL;
|
char szIndex[1024], szTemp[256], *p = NULL;
|
||||||
|
@ -657,7 +656,7 @@ long lAnalysIndex(char *s, long len, TblDef *pstTde)
|
||||||
|
|
||||||
strncpy(szIndex, s, len);
|
strncpy(szIndex, s, len);
|
||||||
strcat(szIndex, "\n");
|
strcat(szIndex, "\n");
|
||||||
for(i = 0, k = 0, n = lgetstrnum(szIndex, "\n"), pstTde->m_lIType = 0; i < n; i ++)
|
for(i = 0, k = 0, n = lgetstrnum(szIndex, "\n"), ps->m_lIType = 0; i < n; i ++)
|
||||||
{
|
{
|
||||||
memset(szTemp, 0, sizeof(szTemp));
|
memset(szTemp, 0, sizeof(szTemp));
|
||||||
strncpy(szTemp, sfieldvalue(szIndex, "\n", i + 1), sizeof(szTemp));
|
strncpy(szTemp, sfieldvalue(szIndex, "\n", i + 1), sizeof(szTemp));
|
||||||
|
@ -678,7 +677,7 @@ long lAnalysIndex(char *s, long len, TblDef *pstTde)
|
||||||
}
|
}
|
||||||
|
|
||||||
k |= UNQIUE;
|
k |= UNQIUE;
|
||||||
lRet = lIndexField(p, pstTde, UNQIUE);
|
lRet = lIndexField(p, ps, UNQIUE);
|
||||||
}
|
}
|
||||||
else if(p = strcasestr(szTemp, "create index"))
|
else if(p = strcasestr(szTemp, "create index"))
|
||||||
{
|
{
|
||||||
|
@ -690,7 +689,7 @@ long lAnalysIndex(char *s, long len, TblDef *pstTde)
|
||||||
}
|
}
|
||||||
|
|
||||||
k |= NORMAL;
|
k |= NORMAL;
|
||||||
lRet = lIndexField(p, pstTde, NORMAL);
|
lRet = lIndexField(p, ps, NORMAL);
|
||||||
}
|
}
|
||||||
else if(p = strcasestr(szTemp, "create hash"))
|
else if(p = strcasestr(szTemp, "create hash"))
|
||||||
{
|
{
|
||||||
|
@ -702,7 +701,7 @@ long lAnalysIndex(char *s, long len, TblDef *pstTde)
|
||||||
}
|
}
|
||||||
|
|
||||||
k |= NORMAL;
|
k |= NORMAL;
|
||||||
lRet = lIndexField(p, pstTde, HASHID);
|
lRet = lIndexField(p, ps, HASHID);
|
||||||
}
|
}
|
||||||
else if(p = strcasestr(szTemp, "comment on "))
|
else if(p = strcasestr(szTemp, "comment on "))
|
||||||
{
|
{
|
||||||
|
@ -735,9 +734,9 @@ long lAnalysIndex(char *s, long len, TblDef *pstTde)
|
||||||
p = szComm + strlen(szTable) + 1;
|
p = szComm + strlen(szTable) + 1;
|
||||||
strimabout(p, "'", "'");
|
strimabout(p, "'", "'");
|
||||||
strimabout(p, "\"", "\"");
|
strimabout(p, "\"", "\"");
|
||||||
if(!strcmp(szTable, pstTde->m_szTable)) // current table
|
if(!strcmp(szTable, ps->m_szTable)) // current table
|
||||||
{
|
{
|
||||||
if(RC_SUCC != (lRet = lTableAliase(pstTde, p, szAlias)))
|
if(RC_SUCC != (lRet = lTableAliase(ps, p, szAlias)))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "table %s field:%s not exist\n", szTable, p);
|
fprintf(stderr, "table %s field:%s not exist\n", szTable, p);
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
@ -755,7 +754,7 @@ long lAnalysIndex(char *s, long len, TblDef *pstTde)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(RC_SUCC != (lRet = lTableAliase(pstTde, szComm, szAlias)))
|
if(RC_SUCC != (lRet = lTableAliase(ps, szComm, szAlias)))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "table %s field:%s not exist\n", szTable, szComm);
|
fprintf(stderr, "table %s field:%s not exist\n", szTable, szComm);
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
@ -814,11 +813,11 @@ char* sGetTabName(char *pszTable)
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
description:creates the table struck
|
description:creates the table struck
|
||||||
parameters:
|
parameters:
|
||||||
pstTde --Table define
|
ps --Table define
|
||||||
em --index type
|
em --index type
|
||||||
return:
|
return:
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
void vCreateStruck(TblDef *pstTde, bool bf)
|
void vCreateStruck(TblDef *ps, bool bf)
|
||||||
{
|
{
|
||||||
long i;
|
long i;
|
||||||
TblKey *pv = NULL;
|
TblKey *pv = NULL;
|
||||||
|
@ -826,14 +825,14 @@ void vCreateStruck(TblDef *pstTde, bool bf)
|
||||||
fprintf(stdout, "\n#Table definition\n");
|
fprintf(stdout, "\n#Table definition\n");
|
||||||
if(bf)
|
if(bf)
|
||||||
{
|
{
|
||||||
fprintf(stdout, "\nset TABLE=%d\n", pstTde->m_table);
|
fprintf(stdout, "\nset TABLE=%d\n", ps->m_table);
|
||||||
fprintf(stdout, "set TABLESPACE=%ld\n\n", pstTde->m_lMaxRow);
|
fprintf(stdout, "set TABLESPACE=%ld\n\n", ps->m_lMaxRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stdout, "typedef struct __%s\n{\n", supper(pstTde->m_szTable));
|
fprintf(stdout, "typedef struct __%s\n{\n", supper(ps->m_szTable));
|
||||||
for(i = 0; i < pstTde->m_lIdxNum; i ++)
|
for(i = 0; i < ps->m_lIdxNum; i ++)
|
||||||
{
|
{
|
||||||
pv = &pstTde->m_stKey[i];
|
pv = &ps->m_stKey[i];
|
||||||
if(FIELD_CHAR == pv->m_lAttr)
|
if(FIELD_CHAR == pv->m_lAttr)
|
||||||
{
|
{
|
||||||
if(1 == pv->m_lLen)
|
if(1 == pv->m_lLen)
|
||||||
|
@ -877,42 +876,42 @@ void vCreateStruck(TblDef *pstTde, bool bf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stdout, "}%s;\n", sGetTabName(supper(pstTde->m_szTable)));
|
fprintf(stdout, "}%s;\n", sGetTabName(supper(ps->m_szTable)));
|
||||||
|
|
||||||
if(bf)
|
if(bf)
|
||||||
{
|
{
|
||||||
fprintf(stdout, "\n-- Create indexes\n");
|
fprintf(stdout, "\n-- Create indexes\n");
|
||||||
if(pstTde->m_lIType & UNQIUE)
|
if(ps->m_lIType & UNQIUE)
|
||||||
{
|
{
|
||||||
pv = &pstTde->m_stIdxUp[0];
|
pv = &ps->m_stIdxUp[0];
|
||||||
fprintf(stdout, "create unique index (%s", pv->m_szField);
|
fprintf(stdout, "create unique index (%s", pv->m_szField);
|
||||||
for(i = 1; i < pstTde->m_lIdxUp; i ++)
|
for(i = 1; i < ps->m_lIdxUp; i ++)
|
||||||
{
|
{
|
||||||
pv = &pstTde->m_stKey[i];
|
pv = &ps->m_stKey[i];
|
||||||
fprintf(stdout, ", %s", pv->m_szField);
|
fprintf(stdout, ", %s", pv->m_szField);
|
||||||
}
|
}
|
||||||
fprintf(stdout, ");\n");
|
fprintf(stdout, ");\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pstTde->m_lIType & NORMAL)
|
if(ps->m_lIType & NORMAL)
|
||||||
{
|
{
|
||||||
pv = &pstTde->m_stGrpUp[0];
|
pv = &ps->m_stGrpUp[0];
|
||||||
fprintf(stdout, "create index (%s", pv->m_szField);
|
fprintf(stdout, "create index (%s", pv->m_szField);
|
||||||
for(i = 1; i < pstTde->m_lGrpUp; i ++)
|
for(i = 1; i < ps->m_lGrpUp; i ++)
|
||||||
{
|
{
|
||||||
pv = &pstTde->m_stKey[i];
|
pv = &ps->m_stKey[i];
|
||||||
fprintf(stdout, ", %s", pv->m_szField);
|
fprintf(stdout, ", %s", pv->m_szField);
|
||||||
}
|
}
|
||||||
fprintf(stdout, ");\n");
|
fprintf(stdout, ");\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(pstTde->m_lIType & HASHID)
|
else if(ps->m_lIType & HASHID)
|
||||||
{
|
{
|
||||||
pv = &pstTde->m_stGrpUp[0];
|
pv = &ps->m_stGrpUp[0];
|
||||||
fprintf(stdout, "create hash (%s", pv->m_szField);
|
fprintf(stdout, "create hash (%s", pv->m_szField);
|
||||||
for(i = 1; i < pstTde->m_lGrpUp; i ++)
|
for(i = 1; i < ps->m_lGrpUp; i ++)
|
||||||
{
|
{
|
||||||
pv = &pstTde->m_stKey[i];
|
pv = &ps->m_stKey[i];
|
||||||
fprintf(stdout, ", %s", pv->m_szField);
|
fprintf(stdout, ", %s", pv->m_szField);
|
||||||
}
|
}
|
||||||
fprintf(stdout, ");\n");
|
fprintf(stdout, ");\n");
|
||||||
|
@ -961,7 +960,7 @@ void vTableStruck(TABLE t)
|
||||||
long lDefineTable(char *pszCreate, char *pszTable)
|
long lDefineTable(char *pszCreate, char *pszTable)
|
||||||
{
|
{
|
||||||
long i;
|
long i;
|
||||||
TblDef stTde;
|
TblDef sf;
|
||||||
char *p = NULL, *q = NULL;
|
char *p = NULL, *q = NULL;
|
||||||
SATvm *pstSavm = (SATvm *)pGetSATvm();
|
SATvm *pstSavm = (SATvm *)pGetSATvm();
|
||||||
|
|
||||||
|
@ -972,14 +971,14 @@ long lDefineTable(char *pszCreate, char *pszTable)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&stTde, 0, sizeof(TblDef));
|
memset(&sf, 0, sizeof(TblDef));
|
||||||
if(RC_SUCC != lAnalysHead(pszCreate, p - pszCreate, &stTde))
|
if(RC_SUCC != lAnalysHead(pszCreate, p - pszCreate, &sf))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
strncpy(stTde.m_szTable, sfieldvalue(p + 12, "\n", 1), sizeof(stTde.m_szTable));
|
strncpy(sf.m_szTable, sfieldvalue(p + 12, "\n", 1), sizeof(sf.m_szTable));
|
||||||
srtrim(stTde.m_szTable);
|
srtrim(sf.m_szTable);
|
||||||
sltrim(stTde.m_szTable);
|
sltrim(sf.m_szTable);
|
||||||
supper(stTde.m_szTable);
|
supper(sf.m_szTable);
|
||||||
|
|
||||||
if(NULL == (q = strcasestr(p, ";")))
|
if(NULL == (q = strcasestr(p, ";")))
|
||||||
{
|
{
|
||||||
|
@ -987,22 +986,22 @@ long lDefineTable(char *pszCreate, char *pszTable)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(RC_SUCC != lAnalysTable(p + 12, q - p - 12, &stTde))
|
if(RC_SUCC != lAnalysTable(p + 12, q - p - 12, &sf))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
stTde.m_lReSize = sizecn(stTde.m_stKey, stTde.m_lIdxNum);
|
sf.m_lReSize = sizecn(sf.m_stKey, sf.m_lIdxNum);
|
||||||
stTde.m_lTruck = stTde.m_lReSize + sizeof(SHTruck);
|
sf.m_lTruck = sf.m_lReSize + sizeof(SHTruck);
|
||||||
|
|
||||||
if(RC_SUCC != lAnalysIndex(q + 1, strlen(q + 1), &stTde))
|
if(RC_SUCC != lAnalysIndex(q + 1, strlen(q + 1), &sf))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
if(RC_SUCC != lCustomTable(pstSavm, stTde.m_table, stTde.m_lMaxRow, &stTde))
|
if(RC_SUCC != lCustomTable(pstSavm, sf.m_table, sf.m_lMaxRow, &sf))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "create table error: %s\n", sGetTError(pstSavm->m_lErrno));
|
fprintf(stderr, "create table error: %s\n", sGetTError(pstSavm->m_lErrno));
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(pszTable, stTde.m_szTable);
|
strcpy(pszTable, sf.m_szTable);
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1223,7 +1222,7 @@ long lShowTables(SATvm *pstSavm)
|
||||||
if(!strcmp(pstIndex[i].m_szPart, pstIndex[i].m_szOwner))
|
if(!strcmp(pstIndex[i].m_szPart, pstIndex[i].m_szOwner))
|
||||||
strcpy(szTable, pstIndex[i].m_szTable);
|
strcpy(szTable, pstIndex[i].m_szTable);
|
||||||
else
|
else
|
||||||
snprintf(szTable, sizeof(szTable), "%s@%s", pstIndex[i].m_szPart, pstIndex[i].m_szTable);
|
snprintf(szTable, sizeof(szTable), "%s@%s", pstIndex[i].m_szTable, pstIndex[i].m_szPart);
|
||||||
fprintf(stdout, "%3d %s\n", pstIndex[i].m_table, szTable);
|
fprintf(stdout, "%3d %s\n", pstIndex[i].m_table, szTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1321,7 +1320,7 @@ void vTableAmount()
|
||||||
if(!strcmp(pstIndex[i].m_szPart, pstIndex[i].m_szOwner))
|
if(!strcmp(pstIndex[i].m_szPart, pstIndex[i].m_szOwner))
|
||||||
strcpy(szTable, pstIndex[i].m_szTable);
|
strcpy(szTable, pstIndex[i].m_szTable);
|
||||||
else
|
else
|
||||||
snprintf(szTable, sizeof(szTable), "%s@%s", pstIndex[i].m_szPart, pstIndex[i].m_szTable);
|
snprintf(szTable, sizeof(szTable), "%s@%s", pstIndex[i].m_szTable, pstIndex[i].m_szPart);
|
||||||
|
|
||||||
vPrintAmount(pstIndex[i].m_table, pstIndex[i].m_lType, szTable,
|
vPrintAmount(pstIndex[i].m_table, pstIndex[i].m_lType, szTable,
|
||||||
lGetTblValid(pstIndex[i].m_table), lGetTblRow(pstIndex[i].m_table));
|
lGetTblValid(pstIndex[i].m_table), lGetTblRow(pstIndex[i].m_table));
|
||||||
|
@ -4363,7 +4362,7 @@ void vInitialCustom()
|
||||||
//select nextval from SEQUENCE@SEQ_TEST
|
//select nextval from SEQUENCE@SEQ_TEST
|
||||||
snprintf(g_stCustom.m_pszWord, ALLOC_CMD_LEN, "SET,FROM,WHERE,COUNT(1),MAX,MIN,NEXTVAL,"
|
snprintf(g_stCustom.m_pszWord, ALLOC_CMD_LEN, "SET,FROM,WHERE,COUNT(1),MAX,MIN,NEXTVAL,"
|
||||||
"ORDER BY,GROUP BY,SEQUENCE@,SYS_TVM_FIELD,SYS_TVM_DOMAIN,SYS_TVM_SEQUE,TABLE,INTO,"
|
"ORDER BY,GROUP BY,SEQUENCE@,SYS_TVM_FIELD,SYS_TVM_DOMAIN,SYS_TVM_SEQUE,TABLE,INTO,"
|
||||||
"ON,INFO,INDEX,VALUES,DEBUG [ON|OFF],SHOWMODE [ROW|COLUMN],SHOWSIZE [NUM],CLICK,");
|
"ON,INFO,INDEX,VALUES,DEBUG [ON|OFF],SHOWMODE [ROW|COLUMN],SHOWSIZE [NUM],CLICK,TO,");
|
||||||
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;
|
||||||
|
|
28
src/tcp.c
28
src/tcp.c
|
@ -1939,8 +1939,8 @@ void* vEpollListen(void *pvParam)
|
||||||
}
|
}
|
||||||
pstCon->m_pstWork = NULL;
|
pstCon->m_pstWork = NULL;
|
||||||
epoll_ctl(pstTrd->m_epfd, EPOLL_CTL_DEL, pstCon->m_skSock, &events[i]);
|
epoll_ctl(pstTrd->m_epfd, EPOLL_CTL_DEL, pstCon->m_skSock, &events[i]);
|
||||||
TFree(pstCon->pstFace);
|
|
||||||
TFree(pstCon->pstVoid);
|
TFree(pstCon->pstVoid);
|
||||||
|
TFree(pstCon->pstFace);
|
||||||
close(pstCon->m_skSock);
|
close(pstCon->m_skSock);
|
||||||
TFree(pstCon);
|
TFree(pstCon);
|
||||||
continue;
|
continue;
|
||||||
|
@ -1975,8 +1975,8 @@ void* vEpollListen(void *pvParam)
|
||||||
}
|
}
|
||||||
pstCon->m_pstWork = NULL;
|
pstCon->m_pstWork = NULL;
|
||||||
epoll_ctl(pstTrd->m_epfd, EPOLL_CTL_DEL, pstCon->m_skSock, &events[i]);
|
epoll_ctl(pstTrd->m_epfd, EPOLL_CTL_DEL, pstCon->m_skSock, &events[i]);
|
||||||
TFree(pstCon->pstFace);
|
|
||||||
TFree(pstCon->pstVoid);
|
TFree(pstCon->pstVoid);
|
||||||
|
TFree(pstCon->pstFace);
|
||||||
close(pstCon->m_skSock);
|
close(pstCon->m_skSock);
|
||||||
TFree(pstCon);
|
TFree(pstCon);
|
||||||
}
|
}
|
||||||
|
@ -2665,12 +2665,12 @@ long lOfflineNotify(SATvm *pstSavm, long lPort)
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
long lPullNotify(SATvm *pstSavm, TDomain *pstDom, size_t lCount)
|
long lPullNotify(SATvm *pstSavm, TDomain *pstDom, size_t lCount)
|
||||||
{
|
{
|
||||||
TblDef stDet;
|
TblDef sf;
|
||||||
TFace stFace;
|
TFace stFace;
|
||||||
void *pvData = NULL;
|
void *pvData = NULL;
|
||||||
size_t lRecv, i, lRow = 0, lValid;
|
size_t lRecv, i, lRow = 0, lValid;
|
||||||
|
|
||||||
memset(&stDet, 0, sizeof(TblDef));
|
memset(&sf, 0, sizeof(TblDef));
|
||||||
memset(&stFace, 0, sizeof(TFace));
|
memset(&stFace, 0, sizeof(TFace));
|
||||||
stFace.m_lRows = 0;
|
stFace.m_lRows = 0;
|
||||||
stFace.m_lFind = lCount;
|
stFace.m_lFind = lCount;
|
||||||
|
@ -2697,13 +2697,13 @@ long lPullNotify(SATvm *pstSavm, TDomain *pstDom, size_t lCount)
|
||||||
fprintf(stdout, "\nCopying table(%s)(%d) define ..", pstDom->m_szTable, pstDom->m_table);
|
fprintf(stdout, "\nCopying table(%s)(%d) define ..", pstDom->m_szTable, pstDom->m_table);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
if(sizeof(TblDef) != lRecvBuffer(pstDom->m_skSock, (void *)&stDet, sizeof(TblDef)))
|
if(sizeof(TblDef) != lRecvBuffer(pstDom->m_skSock, (void *)&sf, sizeof(TblDef)))
|
||||||
goto ERR_PULLNOTIFY;
|
goto ERR_PULLNOTIFY;
|
||||||
|
|
||||||
lValid = stDet.m_lValid;
|
lValid = sf.m_lValid;
|
||||||
stDet.m_lValid = 0;
|
sf.m_lValid = 0;
|
||||||
stDet.m_lGroup = 0;
|
sf.m_lGroup = 0;
|
||||||
if(RC_SUCC != lCustomTable(pstSavm, pstDom->m_table, stDet.m_lMaxRow, &stDet))
|
if(RC_SUCC != lCustomTable(pstSavm, pstDom->m_table, sf.m_lMaxRow, &sf))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Create table(%d) failed, err:(%d)(%s)\n", pstDom->m_table,
|
fprintf(stderr, "Create table(%d) failed, err:(%d)(%s)\n", pstDom->m_table,
|
||||||
pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno));
|
pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno));
|
||||||
|
@ -2711,7 +2711,7 @@ long lPullNotify(SATvm *pstSavm, TDomain *pstDom, size_t lCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stdout, "\b\bcompleted .\nCopy table(%s) success, table maxrow:%ld, valid:%ld "
|
fprintf(stdout, "\b\bcompleted .\nCopy table(%s) success, table maxrow:%ld, valid:%ld "
|
||||||
" completed .\n", stDet.m_szTable, stDet.m_lMaxRow, lValid);
|
" completed .\n", sf.m_szTable, sf.m_lMaxRow, lValid);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if(NULL == (pstSavm = (SATvm *)pInitSATvm(pstDom->m_table)))
|
if(NULL == (pstSavm = (SATvm *)pInitSATvm(pstDom->m_table)))
|
||||||
{
|
{
|
||||||
|
@ -2723,10 +2723,10 @@ long lPullNotify(SATvm *pstSavm, TDomain *pstDom, size_t lCount)
|
||||||
fprintf(stdout, "Start Copy table(%s)(%s)rows:[", pstDom->m_szTable, pstDom->m_szPart);
|
fprintf(stdout, "Start Copy table(%s)(%s)rows:[", pstDom->m_szTable, pstDom->m_szPart);
|
||||||
fprintf(stdout, "\033[?25l");
|
fprintf(stdout, "\033[?25l");
|
||||||
|
|
||||||
if(NULL == (pvData = (char *)malloc(lCount * stDet.m_lReSize)))
|
if(NULL == (pvData = (char *)malloc(lCount * sf.m_lReSize)))
|
||||||
goto ERR_PULLNOTIFY;
|
goto ERR_PULLNOTIFY;
|
||||||
|
|
||||||
pstSavm->lSize = stDet.m_lReSize;
|
pstSavm->lSize = sf.m_lReSize;
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
if(sizeof(TFace) != lRecvBuffer(pstDom->m_skSock, (void *)&stFace, sizeof(TFace)))
|
if(sizeof(TFace) != lRecvBuffer(pstDom->m_skSock, (void *)&stFace, sizeof(TFace)))
|
||||||
|
@ -2735,13 +2735,13 @@ long lPullNotify(SATvm *pstSavm, TDomain *pstDom, size_t lCount)
|
||||||
if(0 == stFace.m_lRows)
|
if(0 == stFace.m_lRows)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
lRecv = stDet.m_lReSize * stFace.m_lRows;
|
lRecv = sf.m_lReSize * stFace.m_lRows;
|
||||||
if(lRecv != lRecvBuffer(pstDom->m_skSock, (char *)pvData, lRecv))
|
if(lRecv != lRecvBuffer(pstDom->m_skSock, (char *)pvData, lRecv))
|
||||||
goto ERR_PULLNOTIFY;
|
goto ERR_PULLNOTIFY;
|
||||||
|
|
||||||
for(i = 0; i < stFace.m_lRows; i ++)
|
for(i = 0; i < stFace.m_lRows; i ++)
|
||||||
{
|
{
|
||||||
pstSavm->pstVoid = (void *)pvData + i * stDet.m_lReSize;
|
pstSavm->pstVoid = (void *)pvData + i * sf.m_lReSize;
|
||||||
if(RC_SUCC != lInsert(pstSavm))
|
if(RC_SUCC != lInsert(pstSavm))
|
||||||
goto ERR_PULLNOTIFY;
|
goto ERR_PULLNOTIFY;
|
||||||
|
|
||||||
|
|
379
src/tree.c
379
src/tree.c
|
@ -154,6 +154,7 @@ static char tvmerr[128][MAX_INDEX_LEN] = {
|
||||||
"created queue is too big",
|
"created queue is too big",
|
||||||
"queue does not support this operation",
|
"queue does not support this operation",
|
||||||
"not connect to server",
|
"not connect to server",
|
||||||
|
"partion already exist",
|
||||||
"",
|
"",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3195,12 +3196,13 @@ SHTree* _pFixupInsert(void *pvData, SHTree *pstRoot, SHTree *pstCur)
|
||||||
return:
|
return:
|
||||||
SHTree*
|
SHTree*
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
SHTree* pInsertTree(SATvm *pstSavm, SHTree *pstRoot, void *psvIdx, long lIdx, SHTruck **ppstTruck)
|
SHTree* pInsertTree(SATvm *pstSavm, void *pvAddr, SHTree *pstRoot, void *psvIdx, long lIdx,
|
||||||
|
SHTruck **ppstTruck)
|
||||||
{
|
{
|
||||||
int nRet = 0;
|
int nRet;
|
||||||
size_t lOffset;
|
size_t lOffset;
|
||||||
|
void *pvData = NULL;
|
||||||
SHTree *pstNode = NULL, *pstCur = NULL, *pstTree = pstRoot;
|
SHTree *pstNode = NULL, *pstCur = NULL, *pstTree = pstRoot;
|
||||||
void *pvData = NULL, *pvAddr = pGetAddr(pstSavm, pstSavm->tblName);
|
|
||||||
|
|
||||||
while(SELF_POS_UNUSE != pstTree->m_lSePos && NODE_NULL != pstTree->m_lSePos)
|
while(SELF_POS_UNUSE != pstTree->m_lSePos && NODE_NULL != pstTree->m_lSePos)
|
||||||
{
|
{
|
||||||
|
@ -3338,12 +3340,12 @@ long __lInsertHash(SATvm *pstSavm, void *pvAddr, TABLE t, SHTree *pstTree, si
|
||||||
RC_SUCC --success
|
RC_SUCC --success
|
||||||
RC_FAIL --failure
|
RC_FAIL --failure
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
SHTree* pInsertGroup(SATvm *pstSavm, SHTree *pstRoot, void *psvIdx, long lIdx, SHTruck **ppstTruck)
|
SHTree* pInsertGroup(SATvm *pstSavm, void *pvAddr, SHTree *pstRoot, void *psvIdx, long lIdx,
|
||||||
|
SHTruck **ppstTruck)
|
||||||
{
|
{
|
||||||
int nRet = 0;
|
int nRet = 0;
|
||||||
size_t lOffset;
|
size_t lOffset;
|
||||||
SHTruck *pstTruck = NULL;
|
SHTruck *pstTruck = NULL;
|
||||||
void *pvData = pGetAddr(pstSavm, pstSavm->tblName);
|
|
||||||
SHTree *pstNode = NULL, *pstCur = NULL, *pstTree = pstRoot;
|
SHTree *pstNode = NULL, *pstCur = NULL, *pstTree = pstRoot;
|
||||||
|
|
||||||
while(SELF_POS_UNUSE != pstTree->m_lSePos && NODE_NULL != pstTree->m_lSePos)
|
while(SELF_POS_UNUSE != pstTree->m_lSePos && NODE_NULL != pstTree->m_lSePos)
|
||||||
|
@ -3354,17 +3356,17 @@ SHTree* pInsertGroup(SATvm *pstSavm, SHTree *pstRoot, void *psvIdx, long lIdx, S
|
||||||
{
|
{
|
||||||
if(NODE_NULL == pstTree->m_lLeft)
|
if(NODE_NULL == pstTree->m_lLeft)
|
||||||
break;
|
break;
|
||||||
pstTree = (SHTree *)pGetNode(pvData, pstTree->m_lLeft);
|
pstTree = (SHTree *)pGetNode(pvAddr, pstTree->m_lLeft);
|
||||||
}
|
}
|
||||||
else if(0 > nRet)
|
else if(0 > nRet)
|
||||||
{
|
{
|
||||||
if(NODE_NULL == pstTree->m_lRight)
|
if(NODE_NULL == pstTree->m_lRight)
|
||||||
break;
|
break;
|
||||||
pstTree = (SHTree *)pGetNode(pvData, pstTree->m_lRight);
|
pstTree = (SHTree *)pGetNode(pvAddr, pstTree->m_lRight);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pCreateGroup(pvData, pstSavm->tblName, pstTree, 0, &pstTruck);
|
pCreateGroup(pvAddr, pstSavm->tblName, pstTree, 0, &pstTruck);
|
||||||
if(!IS_TRUCK_NULL(pstTruck) || ((*ppstTruck) && (*ppstTruck != pstTruck)))
|
if(!IS_TRUCK_NULL(pstTruck) || ((*ppstTruck) && (*ppstTruck != pstTruck)))
|
||||||
{
|
{
|
||||||
pstSavm->m_lErrno = SVR_EXCEPTION;
|
pstSavm->m_lErrno = SVR_EXCEPTION;
|
||||||
|
@ -3375,8 +3377,8 @@ SHTree* pInsertGroup(SATvm *pstSavm, SHTree *pstRoot, void *psvIdx, long lIdx, S
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lOffset = sizeof(SHTree) * ((TblDef *)pvData)->m_lGroup + lGetGrpPos(pstSavm->tblName);
|
lOffset = sizeof(SHTree) * ((TblDef *)pvAddr)->m_lGroup + lGetGrpPos(pstSavm->tblName);
|
||||||
if(NULL == (pstCur = pCreateGroup(pvData, pstSavm->tblName, NULL, lOffset, &pstTruck)))
|
if(NULL == (pstCur = pCreateGroup(pvAddr, pstSavm->tblName, NULL, lOffset, &pstTruck)))
|
||||||
{
|
{
|
||||||
pstSavm->m_lErrno = SVR_EXCEPTION;
|
pstSavm->m_lErrno = SVR_EXCEPTION;
|
||||||
return pstRoot;
|
return pstRoot;
|
||||||
|
@ -3389,7 +3391,7 @@ SHTree* pInsertGroup(SATvm *pstSavm, SHTree *pstRoot, void *psvIdx, long lIdx, S
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
((TblDef *)pvData)->m_lGroup ++;
|
((TblDef *)pvAddr)->m_lGroup ++;
|
||||||
*ppstTruck = pstTruck;
|
*ppstTruck = pstTruck;
|
||||||
|
|
||||||
pstCur->m_lIdx = lIdx;
|
pstCur->m_lIdx = lIdx;
|
||||||
|
@ -3413,7 +3415,7 @@ SHTree* pInsertGroup(SATvm *pstSavm, SHTree *pstRoot, void *psvIdx, long lIdx, S
|
||||||
return pstRoot;
|
return pstRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _pFixupInsert(pvData, pstRoot, pstCur);
|
return _pFixupInsert(pvAddr, pstRoot, pstCur);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
|
@ -3694,12 +3696,12 @@ SHTree* _pDeleteGroup(void *pvData, TABLE t, SHTree *pstRoot, SHTree *pstTree
|
||||||
return:
|
return:
|
||||||
SHTree*
|
SHTree*
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
SHTree* pDeleteTree(SATvm *pstSavm, SHTree *pstRoot, void *psvIdx, long lIdx, size_t *plData)
|
SHTree* pDeleteTree(SATvm *pstSavm, void *pvAddr, SHTree *pstRoot, void *psvIdx, long lIdx,
|
||||||
|
size_t *plData)
|
||||||
{
|
{
|
||||||
SHTree *pstTree = NULL;
|
SHTree *pstTree = NULL;
|
||||||
void *pvData = pGetAddr(pstSavm, pstSavm->tblName);
|
|
||||||
|
|
||||||
if(NULL == (pstTree = pSearchTree(pvData, pstRoot, psvIdx, lIdx)))
|
if(NULL == (pstTree = pSearchTree(pvAddr, pstRoot, psvIdx, lIdx)))
|
||||||
{
|
{
|
||||||
pstSavm->m_lErrno = NO_DATA_FOUND;
|
pstSavm->m_lErrno = NO_DATA_FOUND;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -3707,7 +3709,7 @@ SHTree* pDeleteTree(SATvm *pstSavm, SHTree *pstRoot, void *psvIdx, long lIdx,
|
||||||
|
|
||||||
*plData = pstTree->m_lData;
|
*plData = pstTree->m_lData;
|
||||||
|
|
||||||
return _pDeleteTree(pvData, pstSavm->tblName, pstRoot, pstTree);
|
return _pDeleteTree(pvAddr, pstSavm->tblName, pstRoot, pstTree);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
|
@ -3769,14 +3771,13 @@ long _lPurgedHash(SATvm *pstSavm, void *pvAddr, SHTree *pstTree, void *pvData
|
||||||
return:
|
return:
|
||||||
SHTree*
|
SHTree*
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
SHTree* _pRemoveGroup(SATvm *pstSavm, SHTree *pstRoot, void *psvIdx, long lIdx, void *pvData,
|
SHTree* _pRemoveGroup(SATvm *pstSavm, void *pvAddr, SHTree *pstRoot, void *psvIdx, long lIdx,
|
||||||
long *plOut, long eType)
|
void *pvData, long *plOut, long eType)
|
||||||
{
|
{
|
||||||
SHList *pstList = NULL;
|
SHList *pstList = NULL;
|
||||||
SHTree *pstTree = NULL;
|
SHTree *pstTree = NULL;
|
||||||
SHTruck *pstTruck = NULL;
|
SHTruck *pstTruck = NULL;
|
||||||
size_t lNext = 0, lOffset;
|
size_t lNext = 0, lOffset;
|
||||||
void *pvAddr = pGetAddr(pstSavm, pstSavm->tblName);
|
|
||||||
|
|
||||||
if(NULL == (pstTree = pSearchTree(pvAddr, pstRoot, psvIdx, lIdx)))
|
if(NULL == (pstTree = pSearchTree(pvAddr, pstRoot, psvIdx, lIdx)))
|
||||||
{
|
{
|
||||||
|
@ -3846,10 +3847,10 @@ SHTree* _pRemoveGroup(SATvm *pstSavm, SHTree *pstRoot, void *psvIdx, long lId
|
||||||
return:
|
return:
|
||||||
SHTree*
|
SHTree*
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
SHTree* pDeleteGroup(SATvm *pstSavm, SHTree *pstRoot, void *psvIdx, long lIdx, void *pvData,
|
SHTree* pDeleteGroup(SATvm *pstSavm, void *pvAddr, SHTree *pstRoot, void *psvIdx, long lIdx,
|
||||||
long *plOut)
|
void *pvData, long *plOut)
|
||||||
{
|
{
|
||||||
return _pRemoveGroup(pstSavm, pstRoot, psvIdx, lIdx, pvData, plOut, 0);
|
return _pRemoveGroup(pstSavm, pvAddr, pstRoot, psvIdx, lIdx, pvData, plOut, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
|
@ -3865,10 +3866,10 @@ SHTree* pDeleteGroup(SATvm *pstSavm, SHTree *pstRoot, void *psvIdx, long lIdx
|
||||||
return:
|
return:
|
||||||
SHTree*
|
SHTree*
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
SHTree* pRemoveGroup(SATvm *pstSavm, SHTree *pstRoot, void *psvIdx, long lIdx, void *pvData,
|
SHTree* pRemoveGroup(SATvm *pstSavm, void *pvAddr, SHTree *pstRoot, void *psvIdx, long lIdx,
|
||||||
long *plOut)
|
void *pvData, long *plOut)
|
||||||
{
|
{
|
||||||
return _pRemoveGroup(pstSavm, pstRoot, psvIdx, lIdx, pvData, plOut, 1);
|
return _pRemoveGroup(pstSavm, pvAddr, pstRoot, psvIdx, lIdx, pvData, plOut, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
|
@ -3928,7 +3929,7 @@ long __lDeleteHash(SATvm *pstSavm, void *pvAddr, SHTree *pstTree, TABLE t)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pstRoot = pDeleteTree(pstSavm, pstRoot, szIdx, lGetIdxLen(t), &lData);
|
pstRoot = pDeleteTree(pstSavm, pvAddr, pstRoot, szIdx, lGetIdxLen(t), &lData);
|
||||||
if(!pstRoot || pstList->m_lData != lData)
|
if(!pstRoot || pstList->m_lData != lData)
|
||||||
{
|
{
|
||||||
pthread_rwlock_unlock(prwLock);
|
pthread_rwlock_unlock(prwLock);
|
||||||
|
@ -4076,7 +4077,8 @@ long __lDeleteIndex(SATvm *pstSavm, void *pvAddr, TABLE t, void *psvIdx)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL == (pstRoot = pDeleteGroup(pstSavm, pstRoot, szIdx, lGetGrpLen(t), &lData, &lRow)))
|
if(NULL == (pstRoot = pDeleteGroup(pstSavm, pvAddr, pstRoot, szIdx, lGetGrpLen(t),
|
||||||
|
&lData, &lRow)))
|
||||||
{
|
{
|
||||||
pthread_rwlock_unlock(prwLock);
|
pthread_rwlock_unlock(prwLock);
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
@ -4234,7 +4236,7 @@ long __lDeleteGroup(SATvm *pstSavm, void *pvAddr, TABLE t, void *psvIdx)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pstIRoot = pDeleteTree(pstSavm, pstIRoot, szIdx, lGetIdxLen(t), &lData);
|
pstIRoot = pDeleteTree(pstSavm, pvAddr, pstIRoot, szIdx, lGetIdxLen(t), &lData);
|
||||||
if(!pstIRoot || pstList->m_lData != lData)
|
if(!pstIRoot || pstList->m_lData != lData)
|
||||||
{
|
{
|
||||||
pthread_rwlock_unlock(prwLock);
|
pthread_rwlock_unlock(prwLock);
|
||||||
|
@ -4362,7 +4364,7 @@ long _lDeleteTruck(SATvm *pstSavm, void *pvAddr, TABLE t)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pstRoot = pDeleteTree(pstSavm, pstRoot, szIdx, lGetIdxLen(t), &lData);
|
pstRoot = pDeleteTree(pstSavm, pvAddr, pstRoot, szIdx, lGetIdxLen(t), &lData);
|
||||||
if(!pstRoot || lOffset != lData)
|
if(!pstRoot || lOffset != lData)
|
||||||
{
|
{
|
||||||
pthread_rwlock_unlock(prwLock);
|
pthread_rwlock_unlock(prwLock);
|
||||||
|
@ -4390,8 +4392,10 @@ long _lDeleteTruck(SATvm *pstSavm, void *pvAddr, TABLE t)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pstRoot = pDeleteGroup(pstSavm, pstRoot, szIdx, lGetGrpLen(t), &lOffset, (long *)&lData);
|
if(NULL == (pstRoot = pDeleteGroup(pstSavm, pvAddr, pstRoot, szIdx, lGetGrpLen(t),
|
||||||
if(!pstRoot) return RC_FAIL;
|
&lOffset, (long *)&lData)))
|
||||||
|
return RC_FAIL;
|
||||||
|
|
||||||
if(1 != lData)
|
if(1 != lData)
|
||||||
{
|
{
|
||||||
pthread_rwlock_unlock(prwLock);
|
pthread_rwlock_unlock(prwLock);
|
||||||
|
@ -4829,11 +4833,12 @@ long lCount(SATvm *pstSavm, size_t *plCount)
|
||||||
RC_SUCC --success
|
RC_SUCC --success
|
||||||
RC_FAIL --failure
|
RC_FAIL --failure
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
SHTree* pRebuildTree(SATvm *pstSavm, SHTree *pstRoot, void *psvIdx, long lIdx, long lRow, size_t lData)
|
SHTree* pRebuildTree(SATvm *pstSavm, void *pvAddr, SHTree *pstRoot, void *psvIdx, long lIdx,
|
||||||
|
long lRow, size_t lData)
|
||||||
{
|
{
|
||||||
int nRet = 0;
|
int nRet = 0;
|
||||||
|
void *pvData = NULL;
|
||||||
size_t lOffset, lPos = 0, lNext = 0;
|
size_t lOffset, lPos = 0, lNext = 0;
|
||||||
void *pvData = NULL, *pvAddr = pGetAddr(pstSavm, pstSavm->tblName);
|
|
||||||
SHTree *pstNode = NULL, *pstCur = NULL, *pstNext = NULL, *pstTree = pstRoot;
|
SHTree *pstNode = NULL, *pstCur = NULL, *pstNext = NULL, *pstTree = pstRoot;
|
||||||
|
|
||||||
while(SELF_POS_UNUSE != pstTree->m_lSePos && NODE_NULL != pstTree->m_lSePos)
|
while(SELF_POS_UNUSE != pstTree->m_lSePos && NODE_NULL != pstTree->m_lSePos)
|
||||||
|
@ -5014,12 +5019,12 @@ long lRebuildHash(SATvm *pstSavm, TABLE t, void *pvAddr, SHTree *pstTree, siz
|
||||||
RC_SUCC --success
|
RC_SUCC --success
|
||||||
RC_FAIL --failure
|
RC_FAIL --failure
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
SHTree* pRebuildGroup(SATvm *pstSavm, SHTree *pstRoot, char *psvIdx, long lIdx, long lRow, size_t lData)
|
SHTree* pRebuildGroup(SATvm *pstSavm, void *pvAddr, SHTree *pstRoot, char *psvIdx, long lIdx,
|
||||||
|
long lRow, size_t lData)
|
||||||
{
|
{
|
||||||
int nRet;
|
int nRet;
|
||||||
size_t lOffset;
|
size_t lOffset;
|
||||||
SHTruck *pstTruck = NULL;
|
SHTruck *pstTruck = NULL;
|
||||||
void *pvAddr = pGetAddr(pstSavm, pstSavm->tblName);
|
|
||||||
SHTree *pstNode = NULL, *pstCur = NULL, *pstTree = pstRoot;
|
SHTree *pstNode = NULL, *pstCur = NULL, *pstTree = pstRoot;
|
||||||
|
|
||||||
while(SELF_POS_UNUSE != pstTree->m_lSePos && NODE_NULL != pstTree->m_lSePos)
|
while(SELF_POS_UNUSE != pstTree->m_lSePos && NODE_NULL != pstTree->m_lSePos)
|
||||||
|
@ -5199,7 +5204,7 @@ long _lRebuildIndex(SATvm *pstSavm, void *pvAddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
pstIRoot = (SHTree *)pGetNode(pvAddr, ((TblDef *)pvAddr)->m_lTreeRoot);
|
pstIRoot = (SHTree *)pGetNode(pvAddr, ((TblDef *)pvAddr)->m_lTreeRoot);
|
||||||
pstIRoot = pRebuildTree(pstSavm, pstIRoot, szIdx, lGetIdxLen(t), lRow, lOffset);
|
pstIRoot = pRebuildTree(pstSavm, pvAddr, pstIRoot, szIdx, lGetIdxLen(t), lRow, lOffset);
|
||||||
if(!pstIRoot) return RC_FAIL;
|
if(!pstIRoot) return RC_FAIL;
|
||||||
|
|
||||||
((TblDef *)pvAddr)->m_lTreeRoot = pstIRoot->m_lSePos;
|
((TblDef *)pvAddr)->m_lTreeRoot = pstIRoot->m_lSePos;
|
||||||
|
@ -5215,7 +5220,7 @@ long _lRebuildIndex(SATvm *pstSavm, void *pvAddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
pstGRoot = (SHTree *)pGetNode(pvAddr, ((TblDef *)pvAddr)->m_lGroupRoot);
|
pstGRoot = (SHTree *)pGetNode(pvAddr, ((TblDef *)pvAddr)->m_lGroupRoot);
|
||||||
pstGRoot = pRebuildGroup(pstSavm, pstGRoot, szIdx, lGetGrpLen(t), lRow, lOffset);
|
pstGRoot = pRebuildGroup(pstSavm, pvAddr, pstGRoot, szIdx, lGetGrpLen(t), lRow, lOffset);
|
||||||
if(!pstGRoot) return RC_FAIL;
|
if(!pstGRoot) return RC_FAIL;
|
||||||
|
|
||||||
((TblDef *)pvAddr)->m_lGroupRoot = pstGRoot->m_lSePos;
|
((TblDef *)pvAddr)->m_lGroupRoot = pstGRoot->m_lSePos;
|
||||||
|
@ -6171,14 +6176,39 @@ long _lQueryGroup(SATvm *pstSavm, void *pvAddr, TABLE t, size_t *plOut, void
|
||||||
RC_SUCC --success
|
RC_SUCC --success
|
||||||
RC_FAIL --failure
|
RC_FAIL --failure
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
long _lQueryTruck(SATvm *pstSavm, void *pvAddr, TABLE t, size_t *plOut, void **ppsvOut)
|
long _lQueryTruck(SATvm *pstSavm, RunTime *pstRun, TABLE t, size_t *plOut, void **ppsvOut)
|
||||||
{
|
{
|
||||||
SHTruck *pstTruck = NULL;
|
SHTruck *pstTruck = NULL;
|
||||||
size_t lRow = 0, lOffset = lGetTblData(t), lPos = 0;
|
size_t lRow = 0, lOffset, lPos = 0;
|
||||||
|
TblDef *pv = (TblDef *)pstRun->m_pvAddr;
|
||||||
|
|
||||||
pstTruck = (PSHTruck)pGetNode(pvAddr, lOffset);
|
if(TYPE_MQUEUE == pstRun->m_lType)
|
||||||
for(lRow = 0, *plOut = 0; (lRow < ((TblDef *)pvAddr)->m_lValid) && (lOffset < lGetTableSize(t));
|
{
|
||||||
pstTruck = (PSHTruck)pGetNode(pvAddr, lOffset))
|
lOffset = pv->m_lListOfs + 1;
|
||||||
|
for((*plOut) = 0, lRow = 0; lRow < pv->m_lMaxRow; lOffset ++, lRow ++)
|
||||||
|
{
|
||||||
|
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr,
|
||||||
|
pv->m_lData + pv->m_lTruck * (lOffset % pv->m_lMaxRow));
|
||||||
|
if(IS_TRUCK_NULL(pstTruck))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
lPos = (++ (*plOut)) * pv->m_lReSize;
|
||||||
|
if(NULL == (*ppsvOut = (char *)realloc(*ppsvOut, lPos)))
|
||||||
|
{
|
||||||
|
pstSavm->m_lErrno = MALLC_MEM_ERR;
|
||||||
|
return RC_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pstTruck->m_lTimes ++;
|
||||||
|
memcpy(*ppsvOut + (lPos - pv->m_lReSize), pstTruck->m_pvData, pv->m_lReSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lOffset = lGetTblData(t);
|
||||||
|
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr, lOffset);
|
||||||
|
for(lRow = 0, *plOut = 0; (lRow < pv->m_lValid) && (lOffset < lGetTableSize(t));
|
||||||
|
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr, lOffset))
|
||||||
{
|
{
|
||||||
if(IS_TRUCK_NULL(pstTruck))
|
if(IS_TRUCK_NULL(pstTruck))
|
||||||
{
|
{
|
||||||
|
@ -6193,7 +6223,7 @@ long _lQueryTruck(SATvm *pstSavm, void *pvAddr, TABLE t, size_t *plOut, void
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
lPos = (++ (*plOut)) * lGetRowSize(t);
|
lPos = (++ (*plOut)) * pv->m_lReSize;
|
||||||
if(NULL == (*ppsvOut = (char *)realloc(*ppsvOut, lPos)))
|
if(NULL == (*ppsvOut = (char *)realloc(*ppsvOut, lPos)))
|
||||||
{
|
{
|
||||||
pstSavm->m_lErrno = MALLC_MEM_ERR;
|
pstSavm->m_lErrno = MALLC_MEM_ERR;
|
||||||
|
@ -6201,9 +6231,10 @@ long _lQueryTruck(SATvm *pstSavm, void *pvAddr, TABLE t, size_t *plOut, void
|
||||||
}
|
}
|
||||||
|
|
||||||
pstTruck->m_lTimes ++;
|
pstTruck->m_lTimes ++;
|
||||||
memcpy(*ppsvOut + (lPos - lGetRowSize(t)), pstTruck->m_pvData, lGetRowSize(t));
|
memcpy(*ppsvOut + (lPos - pv->m_lReSize), pstTruck->m_pvData, pv->m_lReSize);
|
||||||
lOffset += lGetRowTruck(t);
|
lOffset += lGetRowTruck(t);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(0 == (pstSavm->m_lEffect = *plOut))
|
if(0 == (pstSavm->m_lEffect = *plOut))
|
||||||
{
|
{
|
||||||
|
@ -6269,7 +6300,7 @@ long _lQuery(SATvm *pstSavm, RunTime *pstRun, size_t *plOut, void **ppsvOut)
|
||||||
}
|
}
|
||||||
|
|
||||||
pstSavm->m_lEType = EXE_PLAN_ALL;
|
pstSavm->m_lEType = EXE_PLAN_ALL;
|
||||||
lRet = _lQueryTruck(pstSavm, pstRun->m_pvAddr, pstSavm->tblName, plOut, ppsvOut);
|
lRet = _lQueryTruck(pstSavm, pstRun, pstSavm->tblName, plOut, ppsvOut);
|
||||||
pthread_rwlock_unlock(prwLock);
|
pthread_rwlock_unlock(prwLock);
|
||||||
|
|
||||||
return lRet;
|
return lRet;
|
||||||
|
@ -6416,7 +6447,7 @@ long _lInsertIndex(SATvm *pstSavm, void *pvAddr, TABLE t, SHTruck **ppstTruck
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pstRoot = pInsertTree(pstSavm, pstRoot, szIdx, lGetIdxLen(t), ppstTruck);
|
pstRoot = pInsertTree(pstSavm, pvAddr, pstRoot, szIdx, lGetIdxLen(t), ppstTruck);
|
||||||
if(!pstRoot) return RC_FAIL;
|
if(!pstRoot) return RC_FAIL;
|
||||||
|
|
||||||
((TblDef *)pvAddr)->m_lTreeRoot = pstRoot->m_lSePos;
|
((TblDef *)pvAddr)->m_lTreeRoot = pstRoot->m_lSePos;
|
||||||
|
@ -6488,7 +6519,7 @@ long _lInsertGroup(SATvm *pstSavm, void *pvAddr, TABLE t, SHTruck **ppstTruck
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pstRoot = pInsertGroup(pstSavm, pstRoot, szIdx, lGetGrpLen(t), ppstTruck);
|
pstRoot = pInsertGroup(pstSavm, pvAddr, pstRoot, szIdx, lGetGrpLen(t), ppstTruck);
|
||||||
if(!pstRoot) return RC_FAIL;
|
if(!pstRoot) return RC_FAIL;
|
||||||
|
|
||||||
((TblDef *)pvAddr)->m_lGroupRoot = pstRoot->m_lSePos;
|
((TblDef *)pvAddr)->m_lGroupRoot = pstRoot->m_lSePos;
|
||||||
|
@ -6580,24 +6611,44 @@ long __lInsert(SATvm *pstSavm, RunTime *pstRun, TABLE t, ulong uTimes)
|
||||||
vIncrease(&pstSavm->stUpdt, (char *)pstSavm->pstVoid, (TblDef *)pstRun->m_pvAddr);
|
vIncrease(&pstSavm->stUpdt, (char *)pstSavm->pstVoid, (TblDef *)pstRun->m_pvAddr);
|
||||||
|
|
||||||
if(TYPE_MQUEUE == pstRun->m_lType)
|
if(TYPE_MQUEUE == pstRun->m_lType)
|
||||||
return _lPush(pstSavm, pstRun->m_pvAddr);
|
{
|
||||||
|
if(RC_SUCC != _lPush(pstSavm, pstRun->m_pvAddr))
|
||||||
|
{
|
||||||
|
if(FIELD_INCR & pstSavm->lFind)
|
||||||
|
((TblDef *)pstRun->m_pvAddr)->m_lExSeQ --;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RC_SUCC;
|
||||||
|
}
|
||||||
|
|
||||||
if(HAVE_UNIQ_IDX(t))
|
if(HAVE_UNIQ_IDX(t))
|
||||||
{
|
{
|
||||||
if(RC_SUCC != _lInsertIndex(pstSavm, pstRun->m_pvAddr, t, &pstTruck))
|
if(RC_SUCC != _lInsertIndex(pstSavm, pstRun->m_pvAddr, t, &pstTruck))
|
||||||
|
{
|
||||||
|
if(FIELD_INCR & pstSavm->lFind)
|
||||||
|
((TblDef *)pstRun->m_pvAddr)->m_lExSeQ --;
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(HAVE_NORL_IDX(t))
|
if(HAVE_NORL_IDX(t))
|
||||||
{
|
{
|
||||||
if(RC_SUCC != _lInsertGroup(pstSavm, pstRun->m_pvAddr, t, &pstTruck))
|
if(RC_SUCC != _lInsertGroup(pstSavm, pstRun->m_pvAddr, t, &pstTruck))
|
||||||
|
{
|
||||||
|
if(FIELD_INCR & pstSavm->lFind)
|
||||||
|
((TblDef *)pstRun->m_pvAddr)->m_lExSeQ --;
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if(HAVE_HASH_IDX(t))
|
else if(HAVE_HASH_IDX(t))
|
||||||
{
|
{
|
||||||
if(RC_SUCC != _lInsertHash(pstSavm, pstRun->m_pvAddr, t, &pstTruck))
|
if(RC_SUCC != _lInsertHash(pstSavm, pstRun->m_pvAddr, t, &pstTruck))
|
||||||
|
{
|
||||||
|
if(FIELD_INCR & pstSavm->lFind)
|
||||||
|
((TblDef *)pstRun->m_pvAddr)->m_lExSeQ --;
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return _lInsertTruck(pstSavm, pstRun->m_pvAddr, t, pstTruck, uTimes);
|
return _lInsertTruck(pstSavm, pstRun->m_pvAddr, t, pstTruck, uTimes);
|
||||||
}
|
}
|
||||||
|
@ -6786,12 +6837,12 @@ ErrInsert:
|
||||||
RC_SUCC --success
|
RC_SUCC --success
|
||||||
RC_FAIL --failure
|
RC_FAIL --failure
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
long _llFetchIndex(SATvm *pstSavm, RunTime *pstRun, TABLE t, void *psvOut)
|
long _lFetchIndex(SATvm *pstSavm, RunTime *pstRun, TABLE t, void *psvOut)
|
||||||
{
|
{
|
||||||
SHTree *pstTree = NULL;
|
SHTree *pstTree = NULL;
|
||||||
SHTruck *pstTruck = NULL;
|
SHTruck *pstTruck = NULL;
|
||||||
char szIdx[MAX_INDEX_LEN];
|
char szIdx[MAX_INDEX_LEN];
|
||||||
void *pvAddr = pGetAddr(pstSavm, t);
|
void *pvAddr = pstRun->m_pvAddr;
|
||||||
|
|
||||||
memset(szIdx, 0, sizeof(szIdx));
|
memset(szIdx, 0, sizeof(szIdx));
|
||||||
if(NULL == pPickIndex(lGetIdxNum(t), pGetTblIdx(t), pstRun->pstVoid, szIdx))
|
if(NULL == pPickIndex(lGetIdxNum(t), pGetTblIdx(t), pstRun->pstVoid, szIdx))
|
||||||
|
@ -6838,17 +6889,16 @@ long _llFetchIndex(SATvm *pstSavm, RunTime *pstRun, TABLE t, void *psvOut)
|
||||||
RC_SUCC --success
|
RC_SUCC --success
|
||||||
RC_FAIL --failure
|
RC_FAIL --failure
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
long _llFetchGroup(SATvm *pstSavm, RunTime *pstRun, TABLE t, void *psvOut)
|
long _lFetchGroup(SATvm *pstSavm, RunTime *pstRun, TABLE t, void *psvOut)
|
||||||
{
|
{
|
||||||
SHList *pstList = NULL;
|
SHList *pstList = NULL;
|
||||||
SHTruck *pstTruck = NULL;
|
SHTruck *pstTruck = NULL;
|
||||||
char szIdx[MAX_INDEX_LEN];
|
char szIdx[MAX_INDEX_LEN];
|
||||||
void *pvAddr = pGetAddr(pstSavm, t);
|
|
||||||
|
|
||||||
for(pstList = (SHList *)pstRun->m_pvCurAddr; pstList && (SELF_POS_UNUSE != pstList->m_lPos);
|
for(pstList = (SHList *)pstRun->m_pvCurAddr; pstList && (SELF_POS_UNUSE != pstList->m_lPos);
|
||||||
pstList = (SHList *)pGetNode(pvAddr, pstList->m_lNext))
|
pstList = (SHList *)pGetNode(pstRun->m_pvAddr, pstList->m_lNext))
|
||||||
{
|
{
|
||||||
pstTruck = (PSHTruck)pGetNode(pvAddr, pstList->m_lData);
|
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr, pstList->m_lData);
|
||||||
if(IS_TRUCK_NULL(pstTruck))
|
if(IS_TRUCK_NULL(pstTruck))
|
||||||
{
|
{
|
||||||
if(SELF_POS_UNUSE == pstList->m_lNext) break;
|
if(SELF_POS_UNUSE == pstList->m_lNext) break;
|
||||||
|
@ -6866,7 +6916,7 @@ long _llFetchGroup(SATvm *pstSavm, RunTime *pstRun, TABLE t, void *psvOut)
|
||||||
if(SELF_POS_UNUSE == pstList->m_lNext)
|
if(SELF_POS_UNUSE == pstList->m_lNext)
|
||||||
pstRun->m_pvCurAddr = NULL;
|
pstRun->m_pvCurAddr = NULL;
|
||||||
else
|
else
|
||||||
pstRun->m_pvCurAddr = (void *)pGetNode(pvAddr, pstList->m_lNext);
|
pstRun->m_pvCurAddr = (void *)pGetNode(pstRun->m_pvAddr, pstList->m_lNext);
|
||||||
|
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
}
|
}
|
||||||
|
@ -6885,25 +6935,24 @@ long _llFetchGroup(SATvm *pstSavm, RunTime *pstRun, TABLE t, void *psvOut)
|
||||||
RC_SUCC --success
|
RC_SUCC --success
|
||||||
RC_FAIL --failure
|
RC_FAIL --failure
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
long _llFetchTruck(SATvm *pstSavm, RunTime *pstRun, TABLE t, void *psvOut)
|
long _lFetchTruck(SATvm *pstSavm, RunTime *pstRun, TABLE t, void *psvOut)
|
||||||
{
|
{
|
||||||
SHTruck *pstTruck = NULL;
|
SHTruck *pstTruck = NULL;
|
||||||
long lRow = 0, lOffset;
|
long lRow = 0, lOffset;
|
||||||
void *pvAddr = pGetAddr(pstSavm, t);
|
|
||||||
|
|
||||||
if(1 == pstRun->m_lCurLine)
|
if(1 == pstRun->m_lCurLine)
|
||||||
{
|
{
|
||||||
lOffset = lGetTblData(t);
|
lOffset = lGetTblData(t);
|
||||||
pstTruck = (PSHTruck)pGetNode(pvAddr, lOffset);
|
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr, lOffset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lOffset = pstRun->m_pvCurAddr - pvAddr;
|
lOffset = pstRun->m_pvCurAddr - pstRun->m_pvAddr;
|
||||||
pstTruck = (PSHTruck)pstRun->m_pvCurAddr;
|
pstTruck = (PSHTruck)pstRun->m_pvCurAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(lRow = 0; (lRow < ((TblDef *)pvAddr)->m_lValid) && (lOffset < lGetTableSize(t));
|
for(lRow = 0; (lRow < ((TblDef *)pstRun->m_pvAddr)->m_lValid) && (lOffset < lGetTableSize(t));
|
||||||
pstTruck = (PSHTruck)pGetNode(pvAddr, lOffset))
|
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr, lOffset))
|
||||||
{
|
{
|
||||||
if(IS_TRUCK_NULL(pstTruck))
|
if(IS_TRUCK_NULL(pstTruck))
|
||||||
{
|
{
|
||||||
|
@ -6920,7 +6969,7 @@ long _llFetchTruck(SATvm *pstSavm, RunTime *pstRun, TABLE t, void *psvOut)
|
||||||
|
|
||||||
pstRun->m_lCurLine ++;
|
pstRun->m_lCurLine ++;
|
||||||
lOffset += lGetRowTruck(t);
|
lOffset += lGetRowTruck(t);
|
||||||
pstRun->m_pvCurAddr = pGetNode(pvAddr, lOffset);
|
pstRun->m_pvCurAddr = pGetNode(pstRun->m_pvAddr, lOffset);
|
||||||
memcpy(psvOut, pstTruck->m_pvData, lGetRowSize(t));
|
memcpy(psvOut, pstTruck->m_pvData, lGetRowSize(t));
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
}
|
}
|
||||||
|
@ -7053,11 +7102,11 @@ long lTableFetch(SATvm *pstSavm, void *psvOut)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(EXE_PLAN_IDX == pstRun->m_lCurType)
|
if(EXE_PLAN_IDX == pstRun->m_lCurType)
|
||||||
lRet = _llFetchIndex(pstSavm, pstRun, pstSavm->tblName, psvOut);
|
lRet = _lFetchIndex(pstSavm, pstRun, pstSavm->tblName, psvOut);
|
||||||
else if(EXE_PLAN_GRP == pstRun->m_lCurType)
|
else if(EXE_PLAN_GRP == pstRun->m_lCurType)
|
||||||
lRet = _llFetchGroup(pstSavm, pstRun, pstSavm->tblName, psvOut);
|
lRet = _lFetchGroup(pstSavm, pstRun, pstSavm->tblName, psvOut);
|
||||||
else
|
else
|
||||||
lRet = _llFetchTruck(pstSavm, pstRun, pstSavm->tblName, psvOut);
|
lRet = _lFetchTruck(pstSavm, pstRun, pstSavm->tblName, psvOut);
|
||||||
if(RC_NOTFOUND == lRet)
|
if(RC_NOTFOUND == lRet)
|
||||||
{
|
{
|
||||||
pstRun->m_pvCurAddr = NULL;
|
pstRun->m_pvCurAddr = NULL;
|
||||||
|
@ -7082,21 +7131,20 @@ long _lNextTruck(SATvm *pstSavm, RunTime *pstRun, TABLE t, void **ppvOAddr)
|
||||||
{
|
{
|
||||||
SHTruck *pstTruck = NULL;
|
SHTruck *pstTruck = NULL;
|
||||||
long lRow = 0, lOffset;
|
long lRow = 0, lOffset;
|
||||||
void *pvAddr = pGetAddr(pstSavm, t);
|
|
||||||
|
|
||||||
if(1 == pstRun->m_lCurLine)
|
if(1 == pstRun->m_lCurLine)
|
||||||
{
|
{
|
||||||
lOffset = lGetTblData(t);
|
lOffset = lGetTblData(t);
|
||||||
pstTruck = (PSHTruck)pGetNode(pvAddr, lOffset);
|
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr, lOffset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lOffset = pstRun->m_pvCurAddr - pvAddr;
|
lOffset = pstRun->m_pvCurAddr - pstRun->m_pvAddr;
|
||||||
pstTruck = (PSHTruck)pstRun->m_pvCurAddr;
|
pstTruck = (PSHTruck)pstRun->m_pvCurAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(lRow = 0; (lRow < ((TblDef *)pvAddr)->m_lValid) && (lOffset < lGetTableSize(t));
|
for(lRow = 0; (lRow < ((TblDef *)pstRun->m_pvAddr)->m_lValid) && (lOffset < lGetTableSize(t));
|
||||||
pstTruck = (PSHTruck)pGetNode(pvAddr, lOffset))
|
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr, lOffset))
|
||||||
{
|
{
|
||||||
if(IS_TRUCK_NULL(pstTruck))
|
if(IS_TRUCK_NULL(pstTruck))
|
||||||
{
|
{
|
||||||
|
@ -7114,7 +7162,7 @@ long _lNextTruck(SATvm *pstSavm, RunTime *pstRun, TABLE t, void **ppvOAddr)
|
||||||
pstRun->m_lCurLine ++;
|
pstRun->m_lCurLine ++;
|
||||||
*ppvOAddr = pstTruck->m_pvData;
|
*ppvOAddr = pstTruck->m_pvData;
|
||||||
lOffset += lGetRowTruck(t);
|
lOffset += lGetRowTruck(t);
|
||||||
pstRun->m_pvCurAddr = pGetNode(pvAddr, lOffset);
|
pstRun->m_pvCurAddr = pGetNode(pstRun->m_pvAddr, lOffset);
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7137,12 +7185,11 @@ long _lNextGroup(SATvm *pstSavm, RunTime *pstRun, TABLE t, void **ppvOAddr)
|
||||||
SHList *pstList = NULL;
|
SHList *pstList = NULL;
|
||||||
SHTruck *pstTruck = NULL;
|
SHTruck *pstTruck = NULL;
|
||||||
char szIdx[MAX_INDEX_LEN];
|
char szIdx[MAX_INDEX_LEN];
|
||||||
void *pvAddr = pGetAddr(pstSavm, t);
|
|
||||||
|
|
||||||
for(pstList = (SHList *)pstRun->m_pvCurAddr; pstList && (SELF_POS_UNUSE != pstList->m_lPos);
|
for(pstList = (SHList *)pstRun->m_pvCurAddr; pstList && (SELF_POS_UNUSE != pstList->m_lPos);
|
||||||
pstList = (SHList *)pGetNode(pvAddr, pstList->m_lNext))
|
pstList = (SHList *)pGetNode(pstRun->m_pvAddr, pstList->m_lNext))
|
||||||
{
|
{
|
||||||
pstTruck = (PSHTruck)pGetNode(pvAddr, pstList->m_lData);
|
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr, pstList->m_lData);
|
||||||
if(RC_MISMA == lFeildMatch(&pstSavm->stCond, pstTruck->m_pvData, pstRun->pstVoid))
|
if(RC_MISMA == lFeildMatch(&pstSavm->stCond, pstTruck->m_pvData, pstRun->pstVoid))
|
||||||
{
|
{
|
||||||
if(SELF_POS_UNUSE == pstList->m_lNext) break;
|
if(SELF_POS_UNUSE == pstList->m_lNext) break;
|
||||||
|
@ -7154,7 +7201,7 @@ long _lNextGroup(SATvm *pstSavm, RunTime *pstRun, TABLE t, void **ppvOAddr)
|
||||||
if(SELF_POS_UNUSE == pstList->m_lNext)
|
if(SELF_POS_UNUSE == pstList->m_lNext)
|
||||||
pstRun->m_pvCurAddr = NULL;
|
pstRun->m_pvCurAddr = NULL;
|
||||||
else
|
else
|
||||||
pstRun->m_pvCurAddr = (void *)pGetNode(pvAddr, pstList->m_lNext);
|
pstRun->m_pvCurAddr = (void *)pGetNode(pstRun->m_pvAddr, pstList->m_lNext);
|
||||||
|
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
}
|
}
|
||||||
|
@ -7178,7 +7225,6 @@ long _lNextIndex(SATvm *pstSavm, RunTime *pstRun, TABLE t, void **ppvOAddr)
|
||||||
SHTree *pstTree = NULL;
|
SHTree *pstTree = NULL;
|
||||||
SHTruck *pstTruck = NULL;
|
SHTruck *pstTruck = NULL;
|
||||||
char szIdx[MAX_INDEX_LEN];
|
char szIdx[MAX_INDEX_LEN];
|
||||||
void *pvAddr = pGetAddr(pstSavm, t);
|
|
||||||
|
|
||||||
memset(szIdx, 0, sizeof(szIdx));
|
memset(szIdx, 0, sizeof(szIdx));
|
||||||
if(NULL == pPickIndex(lGetIdxNum(t), pGetTblIdx(t), pstSavm->pstVoid, szIdx))
|
if(NULL == pPickIndex(lGetIdxNum(t), pGetTblIdx(t), pstSavm->pstVoid, szIdx))
|
||||||
|
@ -7187,20 +7233,21 @@ long _lNextIndex(SATvm *pstSavm, RunTime *pstRun, TABLE t, void **ppvOAddr)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL == (pstTree = (SHTree *)pGetNode(pvAddr, ((TblDef *)pvAddr)->m_lTreeRoot)))
|
if(NULL == (pstTree = (SHTree *)pGetNode(pstRun->m_pvAddr,
|
||||||
|
((TblDef *)pstRun->m_pvAddr)->m_lTreeRoot)))
|
||||||
{
|
{
|
||||||
pstSavm->m_lErrno = SVR_EXCEPTION;
|
pstSavm->m_lErrno = SVR_EXCEPTION;
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pstTree = (SHTree *)pSearchTree(pvAddr, pstTree, szIdx, lGetIdxLen(t));
|
pstTree = (SHTree *)pSearchTree(pstRun->m_pvAddr, pstTree, szIdx, lGetIdxLen(t));
|
||||||
if(!pstTree)
|
if(!pstTree)
|
||||||
{
|
{
|
||||||
pstSavm->m_lErrno = NO_DATA_FOUND;
|
pstSavm->m_lErrno = NO_DATA_FOUND;
|
||||||
return RC_NOTFOUND;
|
return RC_NOTFOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
pstTruck = (PSHTruck)pGetNode(pvAddr, pstTree->m_lData);
|
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr, pstTree->m_lData);
|
||||||
if(RC_MISMA == lFeildMatch(&pstSavm->stCond, pstTruck->m_pvData, pstRun->pstVoid))
|
if(RC_MISMA == lFeildMatch(&pstSavm->stCond, pstTruck->m_pvData, pstRun->pstVoid))
|
||||||
{
|
{
|
||||||
pstSavm->m_lErrno = NO_DATA_FOUND;
|
pstSavm->m_lErrno = NO_DATA_FOUND;
|
||||||
|
@ -7445,7 +7492,7 @@ long __lUpdateGroup(SATvm *pstSavm, void *pvAddr, TABLE t, SHTruck *pstTruck,
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL == (pstRoot = pInsertGroup(pstSavm, pstRoot, szIdx, lGetGrpLen(t), &pstTruck)))
|
if(NULL == (pstRoot = pInsertGroup(pstSavm, pvAddr, pstRoot, szIdx, lGetGrpLen(t), &pstTruck)))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
|
|
||||||
((TblDef *)pvAddr)->m_lValid ++;
|
((TblDef *)pvAddr)->m_lValid ++;
|
||||||
|
@ -7520,7 +7567,7 @@ long __lIndexUpdate(SATvm *pstSavm, void *pvAddr, TABLE t, SHTruck *pstTruck,
|
||||||
}
|
}
|
||||||
((TblDef *)pvAddr)->m_lValid --;
|
((TblDef *)pvAddr)->m_lValid --;
|
||||||
|
|
||||||
if(NULL == (pstRoot = pInsertTree(pstSavm, pstRoot, szIdx, lGetIdxLen(t), &pstTruck)))
|
if(NULL == (pstRoot = pInsertTree(pstSavm, pvAddr, pstRoot, szIdx, lGetIdxLen(t), &pstTruck)))
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
((TblDef *)pvAddr)->m_lValid ++;
|
((TblDef *)pvAddr)->m_lValid ++;
|
||||||
((TblDef *)pvAddr)->m_lTreeRoot = pstRoot->m_lSePos;
|
((TblDef *)pvAddr)->m_lTreeRoot = pstRoot->m_lSePos;
|
||||||
|
@ -7640,7 +7687,7 @@ long _lUpdateIndex(SATvm *pstSavm, void *pvAddr, TABLE t, void *pvUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
((TblDef *)pvAddr)->m_lValid --;
|
((TblDef *)pvAddr)->m_lValid --;
|
||||||
if(NULL == (pstRoot = pInsertTree(pstSavm, pstRoot, szIdx, lGetIdxLen(t), &pstTruck)))
|
if(NULL == (pstRoot = pInsertTree(pstSavm, pvAddr, pstRoot, szIdx, lGetIdxLen(t), &pstTruck)))
|
||||||
{
|
{
|
||||||
SET_DATA_TRUCK(pstTruck, DATA_TRUCK_NRML);
|
SET_DATA_TRUCK(pstTruck, DATA_TRUCK_NRML);
|
||||||
pthread_rwlock_unlock(prwLock);
|
pthread_rwlock_unlock(prwLock);
|
||||||
|
@ -7783,7 +7830,8 @@ long _lUpdateGroup(SATvm *pstSavm, void *pvAddr, TABLE t, void *pvUpdate)
|
||||||
((TblDef *)pvAddr)->m_lGroupRoot = pstRoot->m_lSePos;
|
((TblDef *)pvAddr)->m_lGroupRoot = pstRoot->m_lSePos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL == (pstRoot = pInsertGroup(pstSavm, pstRoot, szIdx, lGetGrpLen(t), &pstTruck)))
|
if(NULL == (pstRoot = pInsertGroup(pstSavm, pvAddr, pstRoot, szIdx,
|
||||||
|
lGetGrpLen(t), &pstTruck)))
|
||||||
{
|
{
|
||||||
SET_DATA_TRUCK(pstTruck, DATA_TRUCK_NRML);
|
SET_DATA_TRUCK(pstTruck, DATA_TRUCK_NRML);
|
||||||
goto REPGROUP_ERROR;
|
goto REPGROUP_ERROR;
|
||||||
|
@ -8149,7 +8197,7 @@ long lUpdate(SATvm *pstSavm, void *pvUpdate)
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
long lRegisterTable(SATvm *pstSavm, RunTime *pstRun, TABLE t, long lType)
|
long lRegisterTable(SATvm *pstSavm, RunTime *pstRun, TABLE t, long lType)
|
||||||
{
|
{
|
||||||
TIndex stIndex;
|
TIndex stIndex, stPartion;
|
||||||
TBoot *pstBoot = (TBoot *)pBootInitial();
|
TBoot *pstBoot = (TBoot *)pBootInitial();
|
||||||
|
|
||||||
if(TYPE_SYSTEM == lType || TYPE_INCORE == lType)
|
if(TYPE_SYSTEM == lType || TYPE_INCORE == lType)
|
||||||
|
@ -8163,6 +8211,17 @@ long lRegisterTable(SATvm *pstSavm, RunTime *pstRun, TABLE t, long lType)
|
||||||
|
|
||||||
pstRun->m_semID = semget(pstSavm->m_ySey, pstBoot->m_lMaxTable, IPC_CREAT|0660);
|
pstRun->m_semID = semget(pstSavm->m_ySey, pstBoot->m_lMaxTable, IPC_CREAT|0660);
|
||||||
|
|
||||||
|
conditinit(pstSavm, stPartion, SYS_TVM_INDEX);
|
||||||
|
conditstr(pstSavm, stPartion, m_szTable, sGetTableName(t));
|
||||||
|
conditstr(pstSavm, stPartion, m_szPart, sGetTablePart(t, pstSavm->m_szNode));
|
||||||
|
if(RC_SUCC == lSelect(pstSavm, (void *)&stPartion))
|
||||||
|
{
|
||||||
|
pstSavm->m_lErrno = PART_AR_EXIST;
|
||||||
|
return RC_FAIL;
|
||||||
|
}
|
||||||
|
else if(NO_DATA_FOUND != pstSavm->m_lErrno)
|
||||||
|
return RC_FAIL;
|
||||||
|
|
||||||
conditinit(pstSavm, stIndex, SYS_TVM_INDEX);
|
conditinit(pstSavm, stIndex, SYS_TVM_INDEX);
|
||||||
stIndex.m_lValid = 0;
|
stIndex.m_lValid = 0;
|
||||||
stIndex.m_yKey = 0;
|
stIndex.m_yKey = 0;
|
||||||
|
@ -8177,8 +8236,8 @@ long lRegisterTable(SATvm *pstSavm, RunTime *pstRun, TABLE t, long lType)
|
||||||
|
|
||||||
strncpy(stIndex.m_szOwner, pstSavm->m_szNode, sizeof(stIndex.m_szOwner));
|
strncpy(stIndex.m_szOwner, pstSavm->m_szNode, sizeof(stIndex.m_szOwner));
|
||||||
strncpy(stIndex.m_szTime, sGetUpdTime(), sizeof(stIndex.m_szTime));
|
strncpy(stIndex.m_szTime, sGetUpdTime(), sizeof(stIndex.m_szTime));
|
||||||
strncpy(stIndex.m_szTable, sGetTableName(t), sizeof(stIndex.m_szTable));
|
strncpy(stIndex.m_szTable, stPartion.m_szTable, sizeof(stIndex.m_szTable));
|
||||||
strncpy(stIndex.m_szPart, sGetTablePart(t, pstSavm->m_szNode), sizeof(stIndex.m_szPart));
|
strncpy(stIndex.m_szPart, stPartion.m_szPart, sizeof(stIndex.m_szPart));
|
||||||
|
|
||||||
if(RC_SUCC != lInsert(pstSavm))
|
if(RC_SUCC != lInsert(pstSavm))
|
||||||
{
|
{
|
||||||
|
@ -9190,7 +9249,7 @@ long lExportTable(TABLE t, size_t *plOut, void **ppsvOut)
|
||||||
}
|
}
|
||||||
|
|
||||||
pstSavm->pstVoid = NULL;
|
pstSavm->pstVoid = NULL;
|
||||||
lRet = _lQueryTruck(pstSavm, pstRun->m_pvAddr, t, plOut, ppsvOut);
|
lRet = _lQueryTruck(pstSavm, pstRun, t, plOut, ppsvOut);
|
||||||
vTblDisconnect(pstSavm, pstSavm->tblName);
|
vTblDisconnect(pstSavm, pstSavm->tblName);
|
||||||
if(NO_DATA_FOUND == pstSavm->m_lErrno)
|
if(NO_DATA_FOUND == pstSavm->m_lErrno)
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
|
@ -9253,6 +9312,37 @@ long lImportTable(TABLE t, size_t lCount, void *psvData)
|
||||||
return lRet;
|
return lRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************
|
||||||
|
description:Queue-fetch the data as truck
|
||||||
|
parameters:
|
||||||
|
pstSavm --stvm handle
|
||||||
|
pstRun --table handle
|
||||||
|
t --table
|
||||||
|
psvout --result data
|
||||||
|
return:
|
||||||
|
RC_SUCC --success
|
||||||
|
RC_FAIL --failure
|
||||||
|
*************************************************************************************************/
|
||||||
|
long _lFetchQueue(SATvm *pstSavm, RunTime *pstRun, TABLE t, void *psvOut)
|
||||||
|
{
|
||||||
|
SHTruck *pstTruck = NULL;
|
||||||
|
TblDef *pv = (TblDef *)pstRun->m_pvAddr;
|
||||||
|
size_t lRow, lOffset = pv->m_lListOfs + 1;
|
||||||
|
|
||||||
|
for(; pstRun->m_lCurLine <= pv->m_lMaxRow; lOffset ++, pstRun->m_lCurLine ++)
|
||||||
|
{
|
||||||
|
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr,
|
||||||
|
pv->m_lData + pv->m_lTruck * (lOffset % pv->m_lMaxRow));
|
||||||
|
if(IS_TRUCK_NULL(pstTruck))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
memcpy(psvOut, pstTruck->m_pvData, pv->m_lReSize);
|
||||||
|
return RC_SUCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RC_NOTFOUND;
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
description:Export the memory table to a file
|
description:Export the memory table to a file
|
||||||
parameters:
|
parameters:
|
||||||
|
@ -9312,7 +9402,7 @@ long lExportFile(TABLE t, char *pszFile, char *pszFlag)
|
||||||
pstRun->m_pvCurAddr = pstRun->m_pvAddr;
|
pstRun->m_pvCurAddr = pstRun->m_pvAddr;
|
||||||
if(TYPE_MQUEUE == pstRun->m_lType)
|
if(TYPE_MQUEUE == pstRun->m_lType)
|
||||||
{
|
{
|
||||||
while(RC_NOTFOUND != _llFetchTruck(pstSavm, pstRun, t, psvOut))
|
while(RC_NOTFOUND != _lFetchQueue(pstSavm, pstRun, t, psvOut))
|
||||||
{
|
{
|
||||||
fwrite(psvOut, 1, lGetRowSize(t), fp);
|
fwrite(psvOut, 1, lGetRowSize(t), fp);
|
||||||
fprintf(fp, "\n");
|
fprintf(fp, "\n");
|
||||||
|
@ -9320,7 +9410,7 @@ long lExportFile(TABLE t, char *pszFile, char *pszFlag)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while(RC_NOTFOUND != _llFetchTruck(pstSavm, pstRun, t, psvOut))
|
while(RC_NOTFOUND != _lFetchTruck(pstSavm, pstRun, t, psvOut))
|
||||||
{
|
{
|
||||||
_lExportContext(fp, psvOut, lGetFldNum(t), pGetTblKey(t), pszFlag);
|
_lExportContext(fp, psvOut, lGetFldNum(t), pGetTblKey(t), pszFlag);
|
||||||
fprintf(fp, "\n");
|
fprintf(fp, "\n");
|
||||||
|
@ -10405,7 +10495,7 @@ long _lReplaceIndex(SATvm *pstSavm, RunTime *pstRun, TABLE t, void *pvUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
((TblDef *)pvAddr)->m_lValid --;
|
((TblDef *)pvAddr)->m_lValid --;
|
||||||
if(NULL == (pstRoot = pInsertTree(pstSavm, pstRoot, szIdx, lGetIdxLen(t), &pstTruck)))
|
if(NULL == (pstRoot = pInsertTree(pstSavm, pvAddr, pstRoot, szIdx, lGetIdxLen(t), &pstTruck)))
|
||||||
{
|
{
|
||||||
SET_DATA_TRUCK(pstTruck, DATA_TRUCK_NRML);
|
SET_DATA_TRUCK(pstTruck, DATA_TRUCK_NRML);
|
||||||
pthread_rwlock_unlock(prwLock);
|
pthread_rwlock_unlock(prwLock);
|
||||||
|
@ -10552,7 +10642,8 @@ long _lReplaceGroup(SATvm *pstSavm, RunTime *pstRun, TABLE t, void *pvUpdate)
|
||||||
((TblDef *)pvAddr)->m_lGroupRoot = pstRoot->m_lSePos;
|
((TblDef *)pvAddr)->m_lGroupRoot = pstRoot->m_lSePos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL == (pstRoot = pInsertGroup(pstSavm, pstRoot, szIdx, lGetGrpLen(t), &pstTruck)))
|
if(NULL == (pstRoot = pInsertGroup(pstSavm, pvAddr, pstRoot, szIdx,
|
||||||
|
lGetGrpLen(t), &pstTruck)))
|
||||||
{
|
{
|
||||||
SET_DATA_TRUCK(pstTruck, DATA_TRUCK_NRML);
|
SET_DATA_TRUCK(pstTruck, DATA_TRUCK_NRML);
|
||||||
goto GROUP_ERROR;
|
goto GROUP_ERROR;
|
||||||
|
@ -10912,6 +11003,66 @@ long lReplace(SATvm *pstSavm, void *pvReplace)
|
||||||
return lRet;
|
return lRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************
|
||||||
|
description:dump the table data to file
|
||||||
|
parameters:
|
||||||
|
pstSavm --stvm handle
|
||||||
|
t --table
|
||||||
|
return:
|
||||||
|
RC_SUCC --success
|
||||||
|
RC_FAIL --failure
|
||||||
|
*************************************************************************************************/
|
||||||
|
void _vDumpTable(SATvm *pstSavm, void *pvAddr, FILE *fp)
|
||||||
|
{
|
||||||
|
SHTruck *pstTruck = NULL;
|
||||||
|
TblDef *pv = (TblDef *)pvAddr;
|
||||||
|
size_t lRow, lOffset = pv->m_lData;
|
||||||
|
|
||||||
|
for(lRow = 0; (lRow < pv->m_lValid) && (lOffset < pv->m_lTable); lOffset += pv->m_lTruck)
|
||||||
|
{
|
||||||
|
pstTruck = (PSHTruck)pGetNode(pvAddr, lOffset);
|
||||||
|
if(IS_TRUCK_NULL(pstTruck))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
lRow ++;
|
||||||
|
fwrite(pstTruck->m_pvData, pv->m_lReSize, 1, fp);
|
||||||
|
fwrite((void *)&pstTruck->m_lTimes, sizeof(ulong), 1, fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
pstSavm->m_lEffect = lRow;
|
||||||
|
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************
|
||||||
|
description:dump the queue data to file
|
||||||
|
parameters:
|
||||||
|
pstSavm --stvm handle
|
||||||
|
t --table
|
||||||
|
return:
|
||||||
|
RC_SUCC --success
|
||||||
|
RC_FAIL --failure
|
||||||
|
*************************************************************************************************/
|
||||||
|
void _vDumpQueue(SATvm *pstSavm, void *pvAddr, FILE *fp)
|
||||||
|
{
|
||||||
|
SHTruck *pstTruck = NULL;
|
||||||
|
TblDef *pv = (TblDef *)pvAddr;
|
||||||
|
size_t lRow, lOffset = pv->m_lListOfs;
|
||||||
|
|
||||||
|
for(pstSavm->m_lEffect = 0, lRow = 0; lRow < pv->m_lMaxRow; lOffset ++, lRow ++)
|
||||||
|
{
|
||||||
|
pstTruck = (PSHTruck)pGetNode(pvAddr, pv->m_lData + pv->m_lTruck * (lOffset % pv->m_lMaxRow));
|
||||||
|
if(IS_TRUCK_NULL(pstTruck))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
pstSavm->m_lEffect ++;
|
||||||
|
fwrite(pstTruck->m_pvData, pv->m_lReSize, 1, fp);
|
||||||
|
fwrite((void *)&pstTruck->m_lTimes, sizeof(ulong), 1, fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************************************
|
/*************************************************************************************************
|
||||||
description:dump the table data
|
description:dump the table data
|
||||||
parameters:
|
parameters:
|
||||||
|
@ -10926,8 +11077,6 @@ long lDumpTable(SATvm *pstSavm, TABLE t)
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
char szFile[512];
|
char szFile[512];
|
||||||
RunTime *pstRun = NULL;
|
RunTime *pstRun = NULL;
|
||||||
SHTruck *pstTruck = NULL;
|
|
||||||
size_t lRow = 0, lOffset;
|
|
||||||
|
|
||||||
if(!pstSavm)
|
if(!pstSavm)
|
||||||
{
|
{
|
||||||
|
@ -10956,25 +11105,11 @@ long lDumpTable(SATvm *pstSavm, TABLE t)
|
||||||
}
|
}
|
||||||
fwrite(pGetTblDef(t), sizeof(TblDef), 1, fp);
|
fwrite(pGetTblDef(t), sizeof(TblDef), 1, fp);
|
||||||
|
|
||||||
lOffset = lGetTblData(t);
|
|
||||||
pstRun->m_lCurLine = 0;
|
|
||||||
pstSavm->lSize = lGetRowSize(t);
|
pstSavm->lSize = lGetRowSize(t);
|
||||||
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr, lOffset);
|
if(TYPE_MQUEUE == pstRun->m_lType)
|
||||||
for(lRow = 0; (lRow < ((TblDef *)pstRun->m_pvAddr)->m_lValid) && (lOffset < lGetTableSize(t));
|
_vDumpQueue(pstSavm, pstRun->m_pvAddr, fp);
|
||||||
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr, lOffset))
|
else
|
||||||
{
|
_vDumpTable(pstSavm, pstRun->m_pvAddr, fp);
|
||||||
if(IS_TRUCK_NULL(pstTruck))
|
|
||||||
{
|
|
||||||
lOffset += lGetRowTruck(t);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
fwrite(pstTruck->m_pvData, lGetRowSize(t), 1, fp);
|
|
||||||
fwrite((void *)&pstTruck->m_lTimes, sizeof(ulong), 1, fp);
|
|
||||||
|
|
||||||
pstSavm->m_lEffect ++;
|
|
||||||
lOffset += lGetRowTruck(t);
|
|
||||||
}
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
vTableClose(pstSavm);
|
vTableClose(pstSavm);
|
||||||
|
|
||||||
|
@ -10994,7 +11129,7 @@ long lDumpTable(SATvm *pstSavm, TABLE t)
|
||||||
*************************************************************************************************/
|
*************************************************************************************************/
|
||||||
long lMountTable(SATvm *pstSavm, char *pszFile)
|
long lMountTable(SATvm *pstSavm, char *pszFile)
|
||||||
{
|
{
|
||||||
TblDef stTde;
|
TblDef sf;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
long lEffect = 0;
|
long lEffect = 0;
|
||||||
void *pvData = NULL;
|
void *pvData = NULL;
|
||||||
|
@ -11014,21 +11149,21 @@ long lMountTable(SATvm *pstSavm, char *pszFile)
|
||||||
return RC_FAIL;
|
return RC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fread(&stTde, sizeof(TblDef), 1, fp);
|
fread(&sf, sizeof(TblDef), 1, fp);
|
||||||
if(RC_SUCC != lInitSATvm(pstSavm, stTde.m_table))
|
if(RC_SUCC != lInitSATvm(pstSavm, sf.m_table))
|
||||||
goto MOUNT_ERROR;
|
goto MOUNT_ERROR;
|
||||||
|
|
||||||
if(NULL == (pstRun = (RunTime *)pInitHitTest(pstSavm, stTde.m_table)))
|
if(NULL == (pstRun = (RunTime *)pInitHitTest(pstSavm, sf.m_table)))
|
||||||
goto MOUNT_ERROR;
|
goto MOUNT_ERROR;
|
||||||
|
|
||||||
if(stTde.m_lReSize != lGetRowSize(stTde.m_table))
|
if(sf.m_lReSize != lGetRowSize(sf.m_table))
|
||||||
{
|
{
|
||||||
vTblDisconnect(pstSavm, pstSavm->tblName);
|
vTblDisconnect(pstSavm, pstSavm->tblName);
|
||||||
pstSavm->m_lErrno = VER_NOT_MATCH;
|
pstSavm->m_lErrno = VER_NOT_MATCH;
|
||||||
goto MOUNT_ERROR;
|
goto MOUNT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL == (pvData = (void *)malloc(stTde.m_lReSize)))
|
if(NULL == (pvData = (void *)malloc(sf.m_lReSize)))
|
||||||
{
|
{
|
||||||
vTblDisconnect(pstSavm, pstSavm->tblName);
|
vTblDisconnect(pstSavm, pstSavm->tblName);
|
||||||
pstSavm->m_lErrno = MALLC_MEM_ERR;
|
pstSavm->m_lErrno = MALLC_MEM_ERR;
|
||||||
|
@ -11036,7 +11171,7 @@ long lMountTable(SATvm *pstSavm, char *pszFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
pstSavm->pstVoid = pvData;
|
pstSavm->pstVoid = pvData;
|
||||||
pstSavm->lSize = stTde.m_lReSize;
|
pstSavm->lSize = sf.m_lReSize;
|
||||||
prwLock = (RWLock *)pGetRWLock(pstRun->m_pvAddr);
|
prwLock = (RWLock *)pGetRWLock(pstRun->m_pvAddr);
|
||||||
if(RC_SUCC != pthread_rwlock_wrlock(prwLock))
|
if(RC_SUCC != pthread_rwlock_wrlock(prwLock))
|
||||||
{
|
{
|
||||||
|
@ -11045,10 +11180,10 @@ long lMountTable(SATvm *pstSavm, char *pszFile)
|
||||||
goto MOUNT_ERROR;
|
goto MOUNT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(1 == fread(pvData, stTde.m_lReSize, 1, fp))
|
while(1 == fread(pvData, sf.m_lReSize, 1, fp))
|
||||||
{
|
{
|
||||||
fread((void *)&uTimes, sizeof(ulong), 1, fp);
|
fread((void *)&uTimes, sizeof(ulong), 1, fp);
|
||||||
if(lGetTblRow(stTde.m_table) <= ((TblDef *)pstRun->m_pvAddr)->m_lValid)
|
if(lGetTblRow(sf.m_table) <= ((TblDef *)pstRun->m_pvAddr)->m_lValid)
|
||||||
{
|
{
|
||||||
pthread_rwlock_unlock(prwLock);
|
pthread_rwlock_unlock(prwLock);
|
||||||
vTblDisconnect(pstSavm, pstSavm->tblName);
|
vTblDisconnect(pstSavm, pstSavm->tblName);
|
||||||
|
@ -11060,7 +11195,7 @@ long lMountTable(SATvm *pstSavm, char *pszFile)
|
||||||
if(RC_SUCC != __lInsert(pstSavm, pstRun, pstSavm->tblName, uTimes))
|
if(RC_SUCC != __lInsert(pstSavm, pstRun, pstSavm->tblName, uTimes))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "=>警告, 导入表:%s 第(%ld)条记录错误, %s, 跳过..\n",
|
fprintf(stderr, "=>警告, 导入表:%s 第(%ld)条记录错误, %s, 跳过..\n",
|
||||||
sGetTableName(stTde.m_table), lEffect, sGetTError(pstSavm->m_lErrno));
|
sGetTableName(sf.m_table), lEffect, sGetTError(pstSavm->m_lErrno));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11072,7 +11207,7 @@ long lMountTable(SATvm *pstSavm, char *pszFile)
|
||||||
vTblDisconnect(pstSavm, pstSavm->tblName);
|
vTblDisconnect(pstSavm, pstSavm->tblName);
|
||||||
|
|
||||||
fprintf(stdout, "导入表:%s 有效记录:%ld, completed successfully !!\n",
|
fprintf(stdout, "导入表:%s 有效记录:%ld, completed successfully !!\n",
|
||||||
sGetTableName(stTde.m_table), lEffect);
|
sGetTableName(sf.m_table), lEffect);
|
||||||
return RC_SUCC;
|
return RC_SUCC;
|
||||||
|
|
||||||
MOUNT_ERROR:
|
MOUNT_ERROR:
|
||||||
|
|
Loading…
Reference in New Issue