未验证 提交 c8f1f7ca 编写于 作者: H Haojun Liao 提交者: GitHub

Merge pull request #6846 from taosdata/feature/szhou/sync_home_office

Feature/szhou/sync home office
......@@ -1129,6 +1129,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
SSqlCmd *pCmd = &pSql->cmd;
SInsertStatementParam* pInsertParam = &pCmd->insertParam;
pInsertParam->objectId = pSql->self;
char* str = pInsertParam->sql;
int32_t totalNum = 0;
......
此差异已折叠。
......@@ -1200,9 +1200,11 @@ static int insertBatchStmtExecute(STscStmt* pStmt) {
// wait for the callback function to post the semaphore
tsem_wait(&pStmt->pSql->rspSem);
code = pStmt->pSql->res.code;
insertBatchClean(pStmt);
return pStmt->pSql->res.code;
return code;
}
int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
......@@ -1470,6 +1472,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
pSql->fetchFp = waitForQueryRsp;
pCmd->insertParam.insertType = TSDB_QUERY_TYPE_STMT_INSERT;
pCmd->insertParam.objectId = pSql->self;
pSql->sqlstr = realloc(pSql->sqlstr, sqlLen + 1);
......@@ -1646,7 +1649,11 @@ int taos_stmt_close(TAOS_STMT* stmt) {
} else {
if (pStmt->multiTbInsert) {
taosHashCleanup(pStmt->mtb.pTableHash);
pStmt->mtb.pTableBlockHashList = tscDestroyBlockHashTable(pStmt->mtb.pTableBlockHashList, false);
bool rmMeta = false;
if (pStmt->pSql && pStmt->pSql->res.code != 0) {
rmMeta = true;
}
pStmt->mtb.pTableBlockHashList = tscDestroyBlockHashTable(pStmt->mtb.pTableBlockHashList, rmMeta);
taosHashCleanup(pStmt->pSql->cmd.insertParam.pTableBlockHashList);
pStmt->pSql->cmd.insertParam.pTableBlockHashList = NULL;
taosArrayDestroy(pStmt->mtb.tags);
......
......@@ -3342,6 +3342,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t
pnCmd->insertParam.numOfTables = 0;
pnCmd->insertParam.pTableNameList = NULL;
pnCmd->insertParam.pTableBlockHashList = NULL;
pnCmd->insertParam.objectId = pNew->self;
memset(&pnCmd->insertParam.tagData, 0, sizeof(STagData));
......
......@@ -169,6 +169,8 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr);
DLL_EXPORT int taos_load_table_info(TAOS *taos, const char* tableNameList);
DLL_EXPORT int taos_insert_lines(TAOS* taos, char* lines[], int numLines);
#ifdef __cplusplus
}
#endif
......
......@@ -12,7 +12,7 @@ static void prepare_data(TAOS* taos) {
result = taos_query(taos, "drop database if exists test;");
taos_free_result(result);
usleep(100000);
result = taos_query(taos, "create database test;");
result = taos_query(taos, "create database test precision 'us';");
taos_free_result(result);
usleep(100000);
taos_select_db(taos, "test");
......@@ -949,13 +949,45 @@ void verify_stream(TAOS* taos) {
taos_close_stream(strm);
}
int32_t verify_schema_less(TAOS* taos) {
TAOS_RES *result;
result = taos_query(taos, "drop database if exists test;");
taos_free_result(result);
usleep(100000);
result = taos_query(taos, "create database test precision 'us';");
taos_free_result(result);
usleep(100000);
taos_select_db(taos, "test");
result = taos_query(taos, "create stable ste(ts timestamp, f int) tags(t1 bigint)");
taos_free_result(result);
usleep(100000);
char* lines[] = {
"st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639000000",
"st,t1=4i,t3=\"t4\",t2=5,t4=5 c1=3i,c3=L\"passitagin\",c2=true,c4=5,c5=5 1626006833640000000",
"ste,t2=5,t3=L\"ste\" c1=true,c2=4,c3=\"iam\" 1626056811823316532",
"st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642000000",
"ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532",
"ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32b,c6=64s,c7=32w,c8=88.88f 1626056812843316532",
"st,t1=4i,t3=\"t4\",t2=5,t4=5 c1=3i,c3=L\"passitagin\",c2=true,c4=5,c5=5,c6=7u 1626006933640000000",
"stf,t1=4i,t3=\"t4\",t2=5,t4=5 c1=3i,c3=L\"passitagin\",c2=true,c4=5,c5=5,c6=7u 1626006933640000000",
"stf,t1=4i,t3=\"t4\",t2=5,t4=5 c1=3i,c3=L\"passitagin_stf\",c2=false,c5=5,c6=7u 1626006933641a"
};
// int code = taos_insert_lines(taos, lines , sizeof(lines)/sizeof(char*));
int code = taos_insert_lines(taos, &lines[0], 1);
code = taos_insert_lines(taos, &lines[1], 1);
return code;
}
int main(int argc, char *argv[]) {
const char* host = "127.0.0.1";
const char* user = "root";
const char* passwd = "taosdata";
taos_options(TSDB_OPTION_TIMEZONE, "GMT-8");
TAOS* taos = taos_connect(host, user, passwd, "", 0);
if (taos == NULL) {
printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos));
......@@ -967,6 +999,12 @@ int main(int argc, char *argv[]) {
info = taos_get_client_info(taos);
printf("client info: %s\n", info);
printf("************ verify shemaless *************\n");
int code = verify_schema_less(taos);
if (code == 0) {
return code;
}
printf("************ verify query *************\n");
verify_query(taos);
......
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print =============== step1
$db = testlp
$mte = ste
$mt = st
sql drop database $db -x step1
step1:
sql create database $db precision 'us'
sql use $db
sql create stable $mte (ts timestamp, f int) TAGS(t1 bigint)
line_insert st,t1=3i,t2=4,t3="t3" c1=3i,c3=L"passit",c2=false,c4=4 1626006833639000000
line_insert st,t1=4i,t3="t41",t2=5 c1=3i,c3=L"passiT",c2=true,c4=5 1626006833640000000
line_insert stf,t1=4i,t2=5,t3="t4" c1=3i,c3=L"passitagain",c2=true,c4=5 1626006833642000000
line_insert ste,t2=5,t3=L"ste" c1=true,c2=4,c3="iam" 1626056811823316532
sql select * from st
if $rows != 2 then
return -1
endi
if $data00 != @21-07-11 20:33:53.639000@ then
return -1
endi
if $data03 != @passit@ then
return -1
endi
sql select * from stf
if $rows != 1 then
return -1
endi
sql select * from ste
if $rows != 1 then
return -1
endi
#print =============== clear
sql drop database $db
sql show databases
if $rows != 0 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
......@@ -87,6 +87,8 @@ enum {
SIM_CMD_RESTFUL,
SIM_CMD_TEST,
SIM_CMD_RETURN,
SIM_CMD_LINE_INSERT,
SIM_CMD_LINE_INSERT_ERROR,
SIM_CMD_END
};
......@@ -172,6 +174,8 @@ bool simExecuteSqlCmd(SScript *script, char *option);
bool simExecuteSqlErrorCmd(SScript *script, char *rest);
bool simExecuteSqlSlowCmd(SScript *script, char *option);
bool simExecuteRestfulCmd(SScript *script, char *rest);
bool simExecuteLineInsertCmd(SScript *script, char *option);
bool simExecuteLineInsertErrorCmd(SScript *script, char *option);
void simVisuallizeOption(SScript *script, char *src, char *dst);
#endif
\ No newline at end of file
......@@ -1067,3 +1067,49 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
return false;
}
bool simExecuteLineInsertCmd(SScript *script, char *rest) {
char buf[TSDB_MAX_BINARY_LEN];
simVisuallizeOption(script, rest, buf);
rest = buf;
SCmdLine *line = &script->lines[script->linePos];
simInfo("script:%s, %s", script->fileName, rest);
simLogSql(buf, true);
char * lines[] = {rest};
int32_t ret = taos_insert_lines(script->taos, lines, 1);
if (ret == TSDB_CODE_SUCCESS) {
simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest);
script->linePos++;
return true;
} else {
sprintf(script->error, "lineNum: %d. line: %s failed, ret:%d:%s", line->lineNum, rest,
ret & 0XFFFF, tstrerror(ret));
return false;
}
}
bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) {
char buf[TSDB_MAX_BINARY_LEN];
simVisuallizeOption(script, rest, buf);
rest = buf;
SCmdLine *line = &script->lines[script->linePos];
simInfo("script:%s, %s", script->fileName, rest);
simLogSql(buf, true);
char * lines[] = {rest};
int32_t ret = taos_insert_lines(script->taos, lines, 1);
if (ret == TSDB_CODE_SUCCESS) {
sprintf(script->error, "script:%s, taos:%p, %s executed. expect failed, but success.", script->fileName, script->taos, rest);
script->linePos++;
return false;
} else {
simDebug("lineNum: %d. line: %s failed, ret:%d:%s. Expect failed, so success", line->lineNum, rest,
ret & 0XFFFF, tstrerror(ret));
return true;
}
}
......@@ -838,6 +838,38 @@ bool simParseRunBackCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
return true;
}
bool simParseLineInsertCmd(char* rest, SCommand* pCmd, int32_t lineNum) {
int32_t expLen;
rest++;
cmdLine[numOfLines].cmdno = SIM_CMD_LINE_INSERT;
cmdLine[numOfLines].lineNum = lineNum;
cmdLine[numOfLines].optionOffset = optionOffset;
expLen = (int32_t)strlen(rest);
memcpy(optionBuffer + optionOffset, rest, expLen);
optionOffset += expLen + 1;
*(optionBuffer + optionOffset - 1) = 0;
numOfLines++;
return true;
}
bool simParseLineInsertErrorCmd(char* rest, SCommand* pCmd, int32_t lineNum) {
int32_t expLen;
rest++;
cmdLine[numOfLines].cmdno = SIM_CMD_LINE_INSERT;
cmdLine[numOfLines].lineNum = lineNum;
cmdLine[numOfLines].optionOffset = optionOffset;
expLen = (int32_t)strlen(rest);
memcpy(optionBuffer + optionOffset, rest, expLen);
optionOffset += expLen + 1;
*(optionBuffer + optionOffset - 1) = 0;
numOfLines++;
return true;
}
void simInitsimCmdList() {
int32_t cmdno;
memset(simCmdList, 0, SIM_CMD_END * sizeof(SCommand));
......@@ -1049,4 +1081,20 @@ void simInitsimCmdList() {
simCmdList[cmdno].parseCmd = simParseReturnCmd;
simCmdList[cmdno].executeCmd = simExecuteReturnCmd;
simAddCmdIntoHash(&(simCmdList[cmdno]));
cmdno = SIM_CMD_LINE_INSERT;
simCmdList[cmdno].cmdno = cmdno;
strcpy(simCmdList[cmdno].name, "line_insert");
simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name);
simCmdList[cmdno].parseCmd = simParseLineInsertCmd;
simCmdList[cmdno].executeCmd = simExecuteLineInsertCmd;
simAddCmdIntoHash(&(simCmdList[cmdno]));
cmdno = SIM_CMD_LINE_INSERT_ERROR;
simCmdList[cmdno].cmdno = cmdno;
strcpy(simCmdList[cmdno].name, "line_insert_error");
simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name);
simCmdList[cmdno].parseCmd = simParseLineInsertErrorCmd;
simCmdList[cmdno].executeCmd = simExecuteLineInsertErrorCmd;
simAddCmdIntoHash(&(simCmdList[cmdno]));
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册