提交 dad4ceb6 编写于 作者: haoranc's avatar haoranc

Merge branch 'develop' of github.com:taosdata/TDengine into dev/chr

......@@ -440,7 +440,7 @@ int tsParseSql(SSqlObj *pSql, bool initial);
void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet);
int tscBuildAndSendRequest(SSqlObj *pSql, SQueryInfo* pQueryInfo);
int tscRenewTableMeta(SSqlObj *pSql, int32_t tableIndex);
int tscRenewTableMeta(SSqlObj *pSql);
void tscAsyncResultOnError(SSqlObj *pSql);
void tscQueueAsyncError(void(*fp), void *param, int32_t code);
......
......@@ -444,7 +444,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
}
pSql->retryReason = rpcMsg->code;
rpcMsg->code = tscRenewTableMeta(pSql, 0);
rpcMsg->code = tscRenewTableMeta(pSql);
// if there is an error occurring, proceed to the following error handling procedure.
if (rpcMsg->code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
taosReleaseRef(tscObjRef, handle);
......@@ -3074,28 +3074,46 @@ static void freeElem(void* p) {
/**
* retrieve table meta from mnode, and then update the local table meta hashmap.
* @param pSql sql object
* @param tableIndex table index
* @return status code
*/
int tscRenewTableMeta(SSqlObj *pSql, int32_t tableIndex) {
int tscRenewTableMeta(SSqlObj *pSql) {
int32_t code = TSDB_CODE_SUCCESS;
SSqlCmd* pCmd = &pSql->cmd;
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd);
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableIndex);
SArray* pNameList = taosArrayInit(1, POINTER_BYTES);
SArray* vgroupList = taosArrayInit(1, POINTER_BYTES);
SHashObj *nameTable = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
while (pQueryInfo) {
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
char name[TSDB_TABLE_FNAME_LEN] = {0};
int32_t code = tNameExtractFullName(&pTableMetaInfo->name, name);
code = tNameExtractFullName(&pTableMetaInfo->name, name);
if (code != TSDB_CODE_SUCCESS) {
tscError("0x%"PRIx64" failed to generate the table full name", pSql->self);
return TSDB_CODE_TSC_INVALID_OPERATION;
}
//do not add duplicate names
if (!taosHashGet(nameTable, name, strlen(name))) {
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
if (pTableMeta) {
tscDebug("0x%"PRIx64" update table meta:%s, old meta numOfTags:%d, numOfCols:%d, uid:%" PRIu64, pSql->self, name,
tscGetNumOfTags(pTableMeta), tscGetNumOfColumns(pTableMeta), pTableMeta->id.uid);
}
char* n = strdup(name);
taosArrayPush(pNameList, &n);
uint8_t dummy_val = 0;
taosHashPut(nameTable, name, strlen(name), &dummy_val, sizeof(uint8_t));
}
pQueryInfo = pQueryInfo->sibling;
}
taosHashCleanup(nameTable);
// remove stored tableMeta info in hash table
tscResetSqlCmd(pCmd, true, pSql->self);
......@@ -3110,11 +3128,6 @@ int tscRenewTableMeta(SSqlObj *pSql, int32_t tableIndex) {
tscFreeSubobj(pSql->rootObj);
tfree(tmpSql->pSubs);
SArray* pNameList = taosArrayInit(1, POINTER_BYTES);
SArray* vgroupList = taosArrayInit(1, POINTER_BYTES);
char* n = strdup(name);
taosArrayPush(pNameList, &n);
code = getMultiTableMetaFromMnode(tmpSql, pNameList, vgroupList, NULL, tscTableMetaCallBack, true);
taosArrayDestroyEx(pNameList, freeElem);
taosArrayDestroyEx(vgroupList, freeElem);
......
......@@ -5522,6 +5522,11 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
varDataSetLen(tagData, outLen);
tdAddColToKVRow(kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_NCHAR, tagVal, true);
}else if(item->type == cJSON_Number){
if(!isfinite(item->valuedouble)){
tscError("json value is invalidate");
retCode = tscSQLSyntaxErrMsg(errMsg, "json value number is illegal", NULL);
goto end;
}
char tagVal[LONG_BYTES + CHAR_BYTES] = {0};
*tagVal = jsonType2DbType(item->valuedouble, item->type); // type
char* tagData = POINTER_SHIFT(tagVal,CHAR_BYTES);
......
Subproject commit 7eae58a0fbf7c7321dd1bdc96e375d4c832cf373
Subproject commit dca4059d87c3f5c678a5e946978d40daec204e27
......@@ -1003,7 +1003,6 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
newCfg.daysToKeep0 = daysToKeep0;
}
#ifdef _STORAGE
if (daysToKeep1 > 0 && (daysToKeep1 != pDb->cfg.daysToKeep1 || newCfg.daysToKeep1 != pDb->cfg.daysToKeep1)) {
mDebug("db:%s, daysToKeep1:%d change to %d", pDb->name, pDb->cfg.daysToKeep1, daysToKeep1);
newCfg.daysToKeep1 = daysToKeep1;
......@@ -1013,7 +1012,6 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
mDebug("db:%s, daysToKeep2:%d change to %d", pDb->name, pDb->cfg.daysToKeep2, daysToKeep2);
newCfg.daysToKeep2 = daysToKeep2;
}
#endif
if (minRows > 0 && minRows != pDb->cfg.minRowsPerFileBlock) {
mError("db:%s, can't alter minRows option", pDb->name);
......@@ -1102,7 +1100,6 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
// community version can only change daysToKeep
// but enterprise version can change all daysToKeep options
#ifndef _STORAGE
newCfg.daysToKeep1 = newCfg.daysToKeep0;
newCfg.daysToKeep2 = newCfg.daysToKeep0;
......
......@@ -298,7 +298,7 @@ void mnodeCheckUnCreatedVgroup(SDnodeObj *pDnode, SVnodeLoad *pVloads, int32_t o
if (have) continue;
if (pVgroup->status == TAOS_VG_STATUS_CREATING || pVgroup->status == TAOS_VG_STATUS_DROPPING) {
if (/*pVgroup->status == TAOS_VG_STATUS_CREATING ||*/ pVgroup->status == TAOS_VG_STATUS_DROPPING) {
mDebug("vgId:%d, not exist in dnode:%d and status is %s, do nothing", pVgroup->vgId, pDnode->dnodeId,
vgroupStatus[pVgroup->status]);
} else {
......
Subproject commit 88346a2e4e2e9282d2ec8b8c5264ca1ec23698a1
Subproject commit 826f3d3b7820a5c007d301854d56db003b424d0a
......@@ -57,36 +57,32 @@ int32_t strdequote(char *z) {
return j + 1; // only one quote, do nothing
}
// delete escape character: \\, \', \"
int32_t strRmquote(char *z, int32_t len){
// delete escape character: \\, \', \"
char delim = z[0];
if (delim != '\'' && delim != '\"') {
return len;
}
char delim = 0;
int32_t cnt = 0;
int32_t j = 0;
for (uint32_t k = 1; k < len - 1; ++k) {
if (z[k] == '\\' || (z[k] == delim && z[k + 1] == delim)) {
for (size_t k = 0; k < len; ++k) {
if (!delim && (z[k] == '\'' || z[k] == '"')){ // find the start ' or "
delim = z[k];
}
if ((z[k] == '\\' && z[k + 1] == '_') || (z[k] == '\\' && z[k + 1] == '%')) {
//match '_' self
} else {
//match '_' '%' self
}else if(z[k] == '\\'){
z[j] = z[k + 1];
cnt++;
j++;
k++;
continue;
}else if(z[k] == delim){
continue;
}
}
z[j] = z[k];
j++;
}
z[j] = 0;
return len - 2 - cnt;
return j;
}
int32_t strRmquoteEscape(char *z, int32_t len) {
......
......@@ -6,6 +6,44 @@
#include "taos.h"
#include "tutil.h"
TEST(testCase, str_rmquote_test) {
char t1[] = "\"\".dd";
int32_t len = strRmquote(t1, strlen(t1));
printf("t1:%s, len:%d\n", t1, len);
EXPECT_EQ(3, len);
EXPECT_STRCASEEQ(t1, ".dd");
char t2[] = "\"fsd\\\"fs\".dd";
len = strRmquote(t2, strlen(t2));
printf("t2:%s, len:%d\n", t2, len);
EXPECT_EQ(9, len);
EXPECT_STRCASEEQ(t2, "fsd\"fs.dd");
char t3[] = "fs\\_d\\%.d\\d";
len = strRmquote(t3, strlen(t3));
printf("t3:%s, len:%d\n", t3, len);
EXPECT_EQ(10, len);
EXPECT_STRCASEEQ(t3, "fs\\_d\\%.dd");
char t4[] = "\"fs\\_d\\%\".dd";
len = strRmquote(t4, strlen(t4));
printf("t4:%s, len:%d\n", t4, len);
EXPECT_EQ(10, len);
EXPECT_STRCASEEQ(t4, "fs\\_d\\%.dd");
char t5[] = "\"fs\\_d\\%\"";
len = strRmquote(t5, strlen(t5));
printf("t5:%s, len:%d\n", t5, len);
EXPECT_EQ(7, len);
EXPECT_STRCASEEQ(t5, "fs\\_d\\%");
char t6[] = "'fs\\_d\\%'";
len = strRmquote(t6, strlen(t6));
printf("t6:%s, len:%d\n", t6, len);
EXPECT_EQ(7, len);
EXPECT_STRCASEEQ(t6, "fs\\_d\\%");
}
TEST(testCase, string_dequote_test) {
char t1[] = "'abc'";
int32_t len = strdequote(t1);
......
......@@ -75,6 +75,10 @@ class TDTestCase:
tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"\t\":\"fff\"}')")
tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"试试\":\"fff\"}')")
# test invalidate json value, value number can not be inf,nan TD-12166
tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"k\":1.8e308}')")
tdSql.error("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"k\":-1.8e308}')")
#test length limit
char1= ''.join(['abcd']*64)
char3= ''.join(['abcd']*1022)
......
......@@ -53,7 +53,7 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
<!-- proxool -->
<dependency>
......
......@@ -961,9 +961,9 @@ sql create database test11943;
sql use test11943;
sql create stable st (ts timestamp , id int ) tags (ind int );
sql insert into sub1 using st tags(1) values(now ,1);
sql insert into sub1 using st tags(1) values(now ,2);
sql insert into sub2 using st tags(2) values(now ,3);
sql insert into sub2 using st tags(2) values(now ,4);
sql insert into sub1 using st tags(1) values(now+1s ,2);
sql insert into sub2 using st tags(2) values(now+2s ,3);
sql insert into sub2 using st tags(2) values(now+3s ,4);
sql select tbname ,max(id)+5 from sub1;
if $data00 != @sub1@ then
return -1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册