Merge branch 'enh/mainnn' into fix/main

This commit is contained in:
yihaoDeng 2023-02-15 23:48:31 +08:00
commit a2982d7c25
6 changed files with 40 additions and 24 deletions

View File

@ -53,20 +53,12 @@ extern "C" {
#define dDebug(...) { if (dDebugFlag & DEBUG_DEBUG) { taosPrintLog("DND ", DEBUG_DEBUG, dDebugFlag, __VA_ARGS__); }}
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", DEBUG_TRACE, dDebugFlag, __VA_ARGS__); }}
//#define dGFatal(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dFatal(param ", gtid:%s", __VA_ARGS__, buf);}
//#define dGError(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dError(param ", gtid:%s", __VA_ARGS__, buf);}
//#define dGWarn(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dWarn (param ", gtid:%s", __VA_ARGS__, buf);}
//#define dGInfo(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dInfo (param ", gtid:%s", __VA_ARGS__, buf);}
//#define dGDebug(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dDebug(param ", gtid:%s", __VA_ARGS__, buf);}
//#define dGTrace(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dTrace(param ", gtid:%s", __VA_ARGS__, buf);}
// TODO: disable it temporarily
#define dGFatal(param, ...)
#define dGError(param, ...)
#define dGWarn(param, ...)
#define dGInfo(param, ...)
#define dGDebug(param, ...)
#define dGTrace(param, ...)
#define dGFatal(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dFatal(param ", gtid:%s", __VA_ARGS__, buf);}
#define dGError(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dError(param ", gtid:%s", __VA_ARGS__, buf);}
#define dGWarn(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dWarn (param ", gtid:%s", __VA_ARGS__, buf);}
#define dGInfo(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dInfo (param ", gtid:%s", __VA_ARGS__, buf);}
#define dGDebug(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dDebug(param ", gtid:%s", __VA_ARGS__, buf);}
#define dGTrace(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dTrace(param ", gtid:%s", __VA_ARGS__, buf);}
// clang-format on

View File

@ -1467,6 +1467,15 @@ static int32_t translateInterpFunc(STranslateContext* pCxt, SFunctionNode* pFunc
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
}
SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
SNode* pTable = pSelect->pFromTable;
if ((NULL != pTable && (QUERY_NODE_REAL_TABLE != nodeType(pTable) ||
(TSDB_CHILD_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType &&
TSDB_NORMAL_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType)))) {
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE,
"%s is only supported in single table query", pFunc->functionName);
}
if (pSelect->hasAggFuncs || pSelect->hasMultiRowsFunc || pSelect->hasIndefiniteRowsFunc) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
}

View File

@ -1850,15 +1850,16 @@ class TDTestCase:
tdSql.error(f"select interp('abcd') from {dbname}.{tbname} range('2020-02-10 00:00:05', '2020-02-15 00:00:05') every(1d) fill(null)")
tdSql.error(f"select interp('中文字符') from {dbname}.{tbname} range('2020-02-10 00:00:05', '2020-02-15 00:00:05') every(1d) fill(null)")
tdLog.printNoPrefix("==========step13:stable cases")
#tdSql.query(f"select interp(c0) from {dbname}.{stbname} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(null)")
tdSql.error(f"select interp(c0) from {dbname}.{stbname} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(null)")
#tdSql.checkRows(13)
#tdSql.query(f"select interp(c0) from {dbname}.{ctbname1} range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill(null)")
#tdSql.checkRows(13)
#tdSql.query(f"select interp(c0) from {dbname}.{stbname} partition by tbname range('2020-02-01 00:00:04', '2020-02-02 00:00:16') every(1s) fill(null)")
tdSql.error(f"select interp(c0) from {dbname}.{stbname} partition by tbname range('2020-02-01 00:00:04', '2020-02-02 00:00:16') every(1s) fill(null)")
#tdSql.checkRows(13)
#tdSql.query(f"select _irowts,interp(c0) from {dbname}.{stbname} partition by tbname range('2020-02-01 00:00:04', '2020-02-02 00:00:16') every(1h) fill(prev)")

View File

@ -28,7 +28,7 @@ void pressOtherKey(char c);
bool shellAutoInit();
// set conn
void shellSetConn(TAOS* conn);
void shellSetConn(TAOS* conn, bool runOnce);
// exit shell auto funciton, shell exit call once
void shellAutoExit();

View File

@ -332,6 +332,7 @@ bool varMode = false; // enter var names list mode
TAOS* varCon = NULL;
SShellCmd* varCmd = NULL;
bool varRunOnce = false;
SMatch* lastMatch = NULL; // save last match result
int cntDel = 0; // delete byte count after next press tab
@ -375,7 +376,7 @@ void showHelp() {
----- C ----- \n\
create table <tb_name> using <stb_name> tags ...\n\
create database <db_name> <db_options> ...\n\
create dnode \"fqdn:port\"n\
create dnode \"fqdn:port\" ...\n\
create index ...\n\
create mnode on dnode <dnode_id> ;\n\
create qnode on dnode <dnode_id> ;\n\
@ -637,10 +638,11 @@ bool shellAutoInit() {
}
// set conn
void shellSetConn(TAOS* conn) {
void shellSetConn(TAOS* conn, bool runOnce) {
varCon = conn;
varRunOnce = runOnce;
// init database and stable
updateTireValue(WT_VAR_DBNAME, false);
if (!runOnce) updateTireValue(WT_VAR_DBNAME, false);
}
// exit shell auto funciton, shell exit call once
@ -784,6 +786,12 @@ int writeVarNames(int type, TAOS_RES* tres) {
return numOfRows;
}
void setThreadNull(int type) {
taosThreadMutexLock(&tiresMutex);
threads[type] = NULL;
taosThreadMutexUnlock(&tiresMutex);
}
bool firstMatchCommand(TAOS* con, SShellCmd* cmd);
//
// thread obtain var thread from db server
@ -799,6 +807,7 @@ void* varObtainThread(void* param) {
TAOS_RES* pSql = taos_query(varCon, varSqls[type]);
if (taos_errno(pSql)) {
taos_free_result(pSql);
setThreadNull(type);
return NULL;
}
@ -814,6 +823,7 @@ void* varObtainThread(void* param) {
firstMatchCommand(varCon, varCmd);
}
setThreadNull(type);
return NULL;
}
@ -1977,7 +1987,7 @@ void callbackAutoTab(char* sqlstr, TAOS* pSql, bool usedb) {
if (dealUseDB(sql)) {
// change to new db
updateTireValue(WT_VAR_STABLE, false);
if (!varRunOnce) updateTireValue(WT_VAR_STABLE, false);
return;
}

View File

@ -1097,10 +1097,11 @@ int32_t shellExecute() {
}
#endif
shellSetConn(shell.conn);
bool runOnce = pArgs->commands != NULL || pArgs->file[0] != 0;
shellSetConn(shell.conn, runOnce);
shellReadHistory();
if (pArgs->commands != NULL || pArgs->file[0] != 0) {
if (runOnce) {
if (pArgs->commands != NULL) {
printf("%s%s\r\n", shell.info.promptHeader, pArgs->commands);
char *cmd = strdup(pArgs->commands);
@ -1160,5 +1161,8 @@ int32_t shellExecute() {
taosThreadJoin(spid, NULL);
shellCleanupHistory();
taos_kill_query(shell.conn);
taos_close(shell.conn);
return 0;
}