From d81d784a4ae4ca21813b79d4f82aa8393d2316e8 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Mon, 19 Apr 2021 10:04:57 +0800 Subject: [PATCH 01/23] fix bug --- src/client/src/tscProfile.c | 2 +- src/client/src/tscStream.c | 4 ++++ src/cq/src/cqMain.c | 2 +- src/kit/shell/src/shellEngine.c | 5 +++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c index 3b0e1b5775..6492075bbd 100644 --- a/src/client/src/tscProfile.c +++ b/src/client/src/tscProfile.c @@ -273,7 +273,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { pSdesc->num = htobe64(pStream->num); pSdesc->useconds = htobe64(pStream->useconds); - pSdesc->stime = htobe64(pStream->stime - pStream->interval.interval); + pSdesc->stime = (pStream->stime == INT64_MIN) ? htobe64(pStream->stime) : htobe64(pStream->stime - pStream->interval.interval); pSdesc->ctime = htobe64(pStream->ctime); pSdesc->slidingTime = htobe64(pStream->interval.sliding); diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index 7699e6f459..89fc1c2621 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -473,6 +473,10 @@ static int32_t tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) { static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, int64_t stime) { SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + + if (stime == INT64_MIN) { + return stime; + } if (pStream->isProject) { // no data in table, flush all data till now to destination meter, 10sec delay diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index d4d202267c..854fbf2ec9 100644 --- a/src/cq/src/cqMain.c +++ b/src/cq/src/cqMain.c @@ -430,7 +430,7 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) { pObj->tmrId = 0; if (pObj->pStream == NULL) { - pObj->pStream = taos_open_stream(pContext->dbConn, pObj->sqlStr, cqProcessStreamRes, 0, (void *)pObj->rid, NULL); + pObj->pStream = taos_open_stream(pContext->dbConn, pObj->sqlStr, cqProcessStreamRes, INT64_MIN, (void *)pObj->rid, NULL); // TODO the pObj->pStream may be released if error happens if (pObj->pStream) { diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index 0eb1248fad..899a0af615 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -391,6 +391,11 @@ int regex_match(const char *s, const char *reg, int cflags) { static char* formatTimestamp(char* buf, int64_t val, int precision) { + if (val == INT64_MIN) { + memset(buf, ' ', 23); + return buf; + } + if (args.is_raw_time) { sprintf(buf, "%" PRId64, val); return buf; From a7efe043a66dbfbd5e86e4364f4fbd828f46e642 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Mon, 19 Apr 2021 11:13:36 +0800 Subject: [PATCH 02/23] fix bug --- src/client/src/tscStream.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index d90b5fead1..abfe272a49 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -101,11 +101,19 @@ static void doLaunchQuery(void* param, TAOS_RES* tres, int32_t code) { return; } + if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo) && (pTableMetaInfo->pVgroupTables == NULL) && (pTableMetaInfo->vgroupList == NULL || pTableMetaInfo->vgroupList->numOfVgroups <= 0)) { + tscDebug("%p empty vgroup list", pSql); + pTableMetaInfo->vgroupList = tscVgroupInfoClear(pTableMetaInfo->vgroupList); + code = TSDB_CODE_TSC_APP_ERROR; + } + // failed to get table Meta or vgroup list, retry in 10sec. if (code == TSDB_CODE_SUCCESS) { tscTansformFuncForSTableQuery(pQueryInfo); tscDebug("%p stream:%p, start stream query on:%s", pSql, pStream, tNameGetTableName(&pTableMetaInfo->name)); + pQueryInfo->command = TSDB_SQL_SELECT; + pSql->fp = tscProcessStreamQueryCallback; pSql->fetchFp = tscProcessStreamQueryCallback; tscDoQuery(pSql); From 091720cfa9258b7f117297dcebb07f9c169ab0c4 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Mon, 19 Apr 2021 13:44:09 +0800 Subject: [PATCH 03/23] fix bug --- src/kit/shell/src/shellEngine.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index 899a0af615..0eb1248fad 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -391,11 +391,6 @@ int regex_match(const char *s, const char *reg, int cflags) { static char* formatTimestamp(char* buf, int64_t val, int precision) { - if (val == INT64_MIN) { - memset(buf, ' ', 23); - return buf; - } - if (args.is_raw_time) { sprintf(buf, "%" PRId64, val); return buf; From 3976e1d0726adf441cf9e7b5e92398e340e3e309 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Mon, 19 Apr 2021 14:59:39 +0800 Subject: [PATCH 04/23] add test case --- tests/script/general/stream/stream_1970.sim | 73 +++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 tests/script/general/stream/stream_1970.sim diff --git a/tests/script/general/stream/stream_1970.sim b/tests/script/general/stream/stream_1970.sim new file mode 100644 index 0000000000..30a733c08f --- /dev/null +++ b/tests/script/general/stream/stream_1970.sim @@ -0,0 +1,73 @@ +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 ======================== dnode1 start + +$dbPrefix = s3_db +$tbPrefix = s3_tb +$mtPrefix = s3_mt +$stPrefix = s3_st +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$st = $stPrefix . $i + +sql drop databae $db -x step1 +step1: +sql create database $db keep 36500 +sql use $db +sql create stable $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int) + +sql create table cq1 as select count(*) from $mt interval(10s); + +sleep 1000 + +sql create table $st using $mt tags(1); + +sql insert into $st values (-50000, 1, 1.0); +sql insert into $st values (-10000, 1, 1.0); +sql insert into $st values (10000, 1, 1.0); + + +$i = 0 +while $i < 12 + sql select * from cq1; + + if $rows != 3 then + sleep 10000 + else + if $data00 != @70-01-01 07:59:10.000@ then + return -1 + endi + if $data01 != 1 then + return -1 + endi + if $data10 != @70-01-01 07:59:50.000@ then + return -1 + endi + if $data11 != 1 then + return -1 + endi + if $data20 != @70-01-01 08:00:10.000@ then + return -1 + endi + if $data21 != 1 then + return -1 + endi + $i = 12 + endi + + $i = $i + 1 +endw + From 7e6009071a630bb9990da12ba0b74b18fe9038e3 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Mon, 19 Apr 2021 17:08:44 +0800 Subject: [PATCH 05/23] fix bug --- src/query/src/qAggMain.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 505057ef33..f312b4ab64 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -2615,6 +2615,10 @@ static void top_function_f(SQLFunctionCtx *pCtx, int32_t index) { STopBotInfo *pRes = getTopBotOutputInfo(pCtx); assert(pRes->num >= 0); + + if ((void *)pRes->res[0] != (void *)((char *)pRes + sizeof(STopBotInfo) + POINTER_BYTES * pCtx->param[0].i64)) { + buildTopBotStruct(pRes, pCtx); + } SET_VAL(pCtx, 1, 1); TSKEY ts = GET_TS_DATA(pCtx, index); From acee0af58f7d307421ba885513fcac5bf9852e35 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Tue, 20 Apr 2021 11:24:42 +0800 Subject: [PATCH 06/23] fix case issue --- tests/pytest/stream/stream2.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/pytest/stream/stream2.py b/tests/pytest/stream/stream2.py index d71742048a..9b4eb8725c 100644 --- a/tests/pytest/stream/stream2.py +++ b/tests/pytest/stream/stream2.py @@ -88,6 +88,8 @@ class TDTestCase: except Exception as e: tdLog.info(repr(e)) + + time.sleep(5) tdSql.query("show streams") tdSql.checkRows(1) tdSql.checkData(0, 2, 's0') @@ -146,6 +148,7 @@ class TDTestCase: except Exception as e: tdLog.info(repr(e)) + time.sleep(5) tdSql.query("show streams") tdSql.checkRows(2) tdSql.checkData(0, 2, 's1') From b5194e4cf3d84501f9cb7073e1a075d99d2b4431 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Tue, 20 Apr 2021 17:40:43 +0800 Subject: [PATCH 07/23] add test case for unsigned tag --- tests/pytest/fulltest.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index e7e0586636..eef7a64fbe 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -303,6 +303,11 @@ python3 ./test.py -f insert/unsignedSmallint.py python3 ./test.py -f insert/unsignedTinyint.py python3 ./test.py -f query/filterAllUnsignedIntTypes.py +python3 ./test.py -f tag_lite/unsignedInt.py +python3 ./test.py -f tag_lite/unsignedBigint.py +python3 ./test.py -f tag_lite/unsignedSmallint.py +python3 ./test.py -f tag_lite/unsignedTinyint.py + python3 ./test.py -f functions/function_percentile2.py python3 ./test.py -f insert/boundary2.py python3 ./test.py -f alter/alter_debugFlag.py From 6038a4791e5c87147e5e147692aa7645f34ea077 Mon Sep 17 00:00:00 2001 From: wu champion Date: Wed, 21 Apr 2021 14:56:38 +0800 Subject: [PATCH 08/23] [TD-3891] fix the bug: not 1st timestamp column,when insert data < 0,data process error --- .../alter/alterTimestampColDataProcess.py | 73 +++++++++++++++++++ tests/pytest/fulltest.sh | 1 + 2 files changed, 74 insertions(+) create mode 100644 tests/pytest/alter/alterTimestampColDataProcess.py diff --git a/tests/pytest/alter/alterTimestampColDataProcess.py b/tests/pytest/alter/alterTimestampColDataProcess.py new file mode 100644 index 0000000000..b235a8bf4c --- /dev/null +++ b/tests/pytest/alter/alterTimestampColDataProcess.py @@ -0,0 +1,73 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to execute {__file__}") + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.execute("drop database if exists db") + tdSql.execute("create database if not exists db keep 36500") + tdSql.execute("use db") + + tdLog.printNoPrefix("==========step1:create table && insert data") + # timestamp list: + # 0 -> "1970-01-01 08:00:00" | -28800000 -> "1970-01-01 00:00:00" | -946800000000 -> "1940-01-01 00:00:00" + # -631180800000 -> "1950-01-01 00:00:00" + ts1 = 0 + ts2 = -28800000 + ts3 = -946800000000 + ts4 = "1950-01-01 00:00:00" + tdSql.execute( + "create table stb2ts (ts timestamp, ts1 timestamp, ts2 timestamp, c1 int, ts3 timestamp) TAGS(t1 int)" + ) + tdSql.execute("create table t2ts1 using stb2ts tags(1)") + + tdSql.execute(f"insert into t2ts1 values ({ts1}, {ts1}, {ts1}, 1, {ts1})") + tdSql.execute(f"insert into t2ts1 values ({ts2}, {ts2}, {ts2}, 2, {ts2})") + tdSql.execute(f"insert into t2ts1 values ({ts3}, {ts3}, {ts3}, 4, {ts3})") + tdSql.execute(f"insert into t2ts1 values ('{ts4}', '{ts4}', '{ts4}', 3, '{ts4}')") + + tdLog.printNoPrefix("==========step2:check inserted data") + tdSql.query("select * from stb2ts where ts1=0 and ts2='1970-01-01 08:00:00' ") + tdSql.checkRows(1) + tdSql.checkData(0, 4,'1970-01-01 08:00:00') + + tdSql.query("select * from stb2ts where ts1=-28800000 and ts2='1970-01-01 00:00:00' ") + tdSql.checkRows(1) + tdSql.checkData(0, 4, '1970-01-01 00:00:00') + + tdSql.query("select * from stb2ts where ts1=-946800000000 and ts2='1940-01-01 00:00:00' ") + tdSql.checkRows(1) + tdSql.checkData(0, 4, '1940-01-01 00:00:00') + + tdSql.query("select * from stb2ts where ts1=-631180800000 and ts2='1950-01-01 00:00:00' ") + tdSql.checkRows(1) + tdSql.checkData(0, 4, '1950-01-01 00:00:00') + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index c26dc8ae2f..b7c3bfe4ac 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -238,6 +238,7 @@ python3 ./test.py -f stream/table_n.py #alter table python3 ./test.py -f alter/alter_table_crash.py python3 ./test.py -f alter/alterTabAddTagWithNULL.py +python3 ./test.py -f alter/alterTimestampColDataProcess.py # client python3 ./test.py -f client/client.py From c8262d44d16890b551ee463d8a641bcb653f2528 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Wed, 21 Apr 2021 19:08:03 +0800 Subject: [PATCH 09/23] fix bug --- src/client/src/tscSQLParser.c | 15 ++++++++++++--- src/query/inc/qSqlparser.h | 7 ++++++- src/query/src/qSqlParser.c | 2 ++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index f83e7fe79d..3ede49c71e 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -3078,7 +3078,7 @@ static SColumnFilterInfo* addColumnFilterInfo(SColumn* pColumn) { return pColFilterInfo; } -static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SColumnFilterInfo* pColumnFilter, +static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, STableMeta* pTableMeta, SColumnFilterInfo* pColumnFilter, int16_t colType, tSqlExpr* pExpr) { const char* msg = "not supported filter condition"; @@ -3093,6 +3093,12 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, if (TSDB_CODE_SUCCESS != retVal) { return retVal; } + } else if ((colType == TSDB_DATA_TYPE_TIMESTAMP) && (TSDB_DATA_TYPE_BIGINT == pRight->value.nType)) { + STableComInfo tinfo = tscGetTableInfo(pTableMeta); + + if ((tinfo.precision == TSDB_TIME_PRECISION_MILLI) && (pRight->flags & (1 << EXPR_FLAG_NOW))) { + pRight->value.i64 /= 1000; + } } int32_t retVal = TSDB_CODE_SUCCESS; @@ -3291,7 +3297,7 @@ static int32_t extractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SC int16_t colType = pSchema->type; - return doExtractColumnFilterInfo(pCmd, pQueryInfo, pColFilter, colType, pExpr); + return doExtractColumnFilterInfo(pCmd, pQueryInfo, pTableMeta, pColFilter, colType, pExpr); } static int32_t getTablenameCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr* pTableCond, SStringBuilder* sb) { @@ -6927,7 +6933,10 @@ static int32_t handleExprInHavingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t } } - int32_t ret = doExtractColumnFilterInfo(pCmd, pQueryInfo, pColFilter, pInfo->field.type, pExpr); + STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; + + int32_t ret = doExtractColumnFilterInfo(pCmd, pQueryInfo, pTableMeta, pColFilter, pInfo->field.type, pExpr); if (ret) { return ret; } diff --git a/src/query/inc/qSqlparser.h b/src/query/inc/qSqlparser.h index c5ee172c40..8c96ac2b94 100644 --- a/src/query/inc/qSqlparser.h +++ b/src/query/inc/qSqlparser.h @@ -44,6 +44,10 @@ enum SQL_NODE_FROM_TYPE { SQL_NODE_FROM_NAMELIST = 2, }; +enum SQL_EXPR_FLAG { + EXPR_FLAG_NOW = 1 +}; + extern char tTokenTypeSwitcher[13]; #define toTSDBType(x) \ @@ -237,7 +241,8 @@ typedef struct tSqlExpr { SStrToken colInfo; // table column info tVariant value; // the use input value SStrToken token; // original sql expr string - + uint32_t flags; + struct tSqlExpr *pLeft; // left child struct tSqlExpr *pRight; // right child struct SArray *pParam; // function parameters list diff --git a/src/query/src/qSqlParser.c b/src/query/src/qSqlParser.c index b75032967a..1dde47e876 100644 --- a/src/query/src/qSqlParser.c +++ b/src/query/src/qSqlParser.c @@ -144,6 +144,7 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) { pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT; pSqlExpr->tokenId = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond pSqlExpr->type = SQL_NODE_VALUE; + pSqlExpr->flags |= 1 << EXPR_FLAG_NOW; } else if (optrType == TK_VARIABLE) { int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSqlExpr->value.i64); if (ret != TSDB_CODE_SUCCESS) { @@ -217,6 +218,7 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) { pExpr->value.nType = TSDB_DATA_TYPE_BIGINT; pExpr->tokenId = pLeft->tokenId; pExpr->type = SQL_NODE_VALUE; + pExpr->flags = pLeft->flags | pRight->flags; switch (optrType) { case TK_PLUS: { From 23f23a445da65e9d95d9c5da237351a2cd4984ae Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Wed, 21 Apr 2021 19:36:46 +0800 Subject: [PATCH 10/23] modify case --- tests/pytest/stream/new.py | 2 +- tests/pytest/util/sql.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/pytest/stream/new.py b/tests/pytest/stream/new.py index 70f300e937..4a0e47c01a 100644 --- a/tests/pytest/stream/new.py +++ b/tests/pytest/stream/new.py @@ -42,7 +42,7 @@ class TDTestCase: tdLog.info("=============== step3") start = time.time() - tdSql.waitedQuery("select * from st", 1, 120) + tdSql.waitedQuery("select * from st", 1, 180) delay = int(time.time() - start) + 80 v = tdSql.getData(0, 3) if v >= 51: diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index 16931cca33..9d1d3a5703 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -87,6 +87,7 @@ class TDSql: self.queryResult = self.cursor.fetchall() self.queryRows = len(self.queryResult) self.queryCols = len(self.cursor.description) + tdLog.info("sql: %s, try to retrieve %d rows,get %d rows" % (sql, expectRows, self.queryRows)) if self.queryRows >= expectRows: return (self.queryRows, i) time.sleep(1) From 2bfc6a90a5ce889e26f946b02cd493a4b781276e Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Thu, 22 Apr 2021 09:50:44 +0800 Subject: [PATCH 11/23] fix bug --- src/client/src/tscStream.c | 10 ++++++---- tests/pytest/stream/sys.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index 89fc1c2621..a598e5eec9 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -402,10 +402,12 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) { taos_close_stream(pStream); return; } - - timer = pStream->stime - taosGetTimestamp(pStream->precision); - if (timer < 0) { - timer = 0; + + if (pStream->stime > 0) { + timer = pStream->stime - taosGetTimestamp(pStream->precision); + if (timer < 0) { + timer = 0; + } } } diff --git a/tests/pytest/stream/sys.py b/tests/pytest/stream/sys.py index a73e7043e8..c9a3fccfe6 100644 --- a/tests/pytest/stream/sys.py +++ b/tests/pytest/stream/sys.py @@ -47,7 +47,7 @@ class TDTestCase: "select * from iostrm", ] for sql in sqls: - (rows, _) = tdSql.waitedQuery(sql, 1, 120) + (rows, _) = tdSql.waitedQuery(sql, 1, 240) if rows < 1: tdLog.exit("failed: sql:%s, expect at least one row" % sql) From 7199b01f3d7f2d1f642b66fd8fff4ee19b9e3af8 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Thu, 22 Apr 2021 11:32:32 +0800 Subject: [PATCH 12/23] fix bug --- src/client/src/tscSQLParser.c | 2 +- src/query/inc/qSqlparser.h | 2 +- src/query/src/qSqlParser.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 3ede49c71e..16523571c6 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -3096,7 +3096,7 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, } else if ((colType == TSDB_DATA_TYPE_TIMESTAMP) && (TSDB_DATA_TYPE_BIGINT == pRight->value.nType)) { STableComInfo tinfo = tscGetTableInfo(pTableMeta); - if ((tinfo.precision == TSDB_TIME_PRECISION_MILLI) && (pRight->flags & (1 << EXPR_FLAG_NOW))) { + if ((tinfo.precision == TSDB_TIME_PRECISION_MILLI) && (pRight->flags & (1 << EXPR_FLAG_US_TIMESTAMP))) { pRight->value.i64 /= 1000; } } diff --git a/src/query/inc/qSqlparser.h b/src/query/inc/qSqlparser.h index 8c96ac2b94..1d62b10c37 100644 --- a/src/query/inc/qSqlparser.h +++ b/src/query/inc/qSqlparser.h @@ -45,7 +45,7 @@ enum SQL_NODE_FROM_TYPE { }; enum SQL_EXPR_FLAG { - EXPR_FLAG_NOW = 1 + EXPR_FLAG_US_TIMESTAMP = 1 }; extern char tTokenTypeSwitcher[13]; diff --git a/src/query/src/qSqlParser.c b/src/query/src/qSqlParser.c index 1dde47e876..45b0fb0ec2 100644 --- a/src/query/src/qSqlParser.c +++ b/src/query/src/qSqlParser.c @@ -144,13 +144,14 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) { pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT; pSqlExpr->tokenId = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond pSqlExpr->type = SQL_NODE_VALUE; - pSqlExpr->flags |= 1 << EXPR_FLAG_NOW; + pSqlExpr->flags |= 1 << EXPR_FLAG_US_TIMESTAMP; } else if (optrType == TK_VARIABLE) { int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSqlExpr->value.i64); if (ret != TSDB_CODE_SUCCESS) { terrno = TSDB_CODE_TSC_SQL_SYNTAX_ERROR; } + pSqlExpr->flags |= 1 << EXPR_FLAG_US_TIMESTAMP; pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT; pSqlExpr->tokenId = TK_TIMESTAMP; pSqlExpr->type = SQL_NODE_VALUE; From 2ab82ca4083b88b7d487dc1156582b34b0d987d3 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Thu, 22 Apr 2021 15:01:02 +0800 Subject: [PATCH 13/23] filter timestamp --- src/client/src/tscSQLParser.c | 12 + src/inc/ttokendef.h | 2 + src/query/inc/qSqlparser.h | 4 +- src/query/inc/sql.y | 2 + src/query/src/qSqlParser.c | 10 +- src/query/src/sql.c | 733 +++++++++++++++++----------------- 6 files changed, 399 insertions(+), 364 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 16523571c6..2bfa2189d6 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -3922,6 +3922,10 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr const char* msg1 = "query condition between different columns must use 'AND'"; + if ((*pExpr)->flags & (1 << EXPR_FLAG_TS_ERROR)) { + return TSDB_CODE_TSC_INVALID_SQL; + } + tSqlExpr* pLeft = (*pExpr)->pLeft; tSqlExpr* pRight = (*pExpr)->pRight; @@ -3959,6 +3963,14 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr exchangeExpr(*pExpr); + if (pLeft->tokenId == TK_ID && pRight->tokenId == TK_TIMESTAMP && (pRight->flags & (1 << EXPR_FLAG_TIMESTAMP_VAR))) { + return TSDB_CODE_TSC_INVALID_SQL; + } + + if ((pLeft->flags & (1 << EXPR_FLAG_TS_ERROR)) || (pRight->flags & (1 << EXPR_FLAG_TS_ERROR))) { + return TSDB_CODE_TSC_INVALID_SQL; + } + return handleExprInQueryCond(pCmd, pQueryInfo, pExpr, pCondExpr, type, parentOptr); } diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h index 5f47d9896f..c7c4b5968b 100644 --- a/src/inc/ttokendef.h +++ b/src/inc/ttokendef.h @@ -210,6 +210,8 @@ + + #define TK_SPACE 300 #define TK_COMMENT 301 #define TK_ILLEGAL 302 diff --git a/src/query/inc/qSqlparser.h b/src/query/inc/qSqlparser.h index 1d62b10c37..0a0587f701 100644 --- a/src/query/inc/qSqlparser.h +++ b/src/query/inc/qSqlparser.h @@ -45,7 +45,9 @@ enum SQL_NODE_FROM_TYPE { }; enum SQL_EXPR_FLAG { - EXPR_FLAG_US_TIMESTAMP = 1 + EXPR_FLAG_TS_ERROR = 1, + EXPR_FLAG_US_TIMESTAMP = 2, + EXPR_FLAG_TIMESTAMP_VAR = 3, }; extern char tTokenTypeSwitcher[13]; diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index f9a4f1b51d..5a42b3a631 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -674,6 +674,8 @@ expr(A) ::= PLUS(X) FLOAT(Y). { X.n += Y.n; X.type = TK_FLOAT; A = tSqlExprCr expr(A) ::= STRING(X). { A = tSqlExprCreateIdValue(&X, TK_STRING);} expr(A) ::= NOW(X). { A = tSqlExprCreateIdValue(&X, TK_NOW); } expr(A) ::= VARIABLE(X). { A = tSqlExprCreateIdValue(&X, TK_VARIABLE);} +expr(A) ::= PLUS(X) VARIABLE(Y). { X.n += Y.n; X.type = TK_VARIABLE; A = tSqlExprCreateIdValue(&X, TK_VARIABLE);} +expr(A) ::= MINUS(X) VARIABLE(Y). { X.n += Y.n; X.type = TK_VARIABLE; A = tSqlExprCreateIdValue(&X, TK_VARIABLE);} expr(A) ::= BOOL(X). { A = tSqlExprCreateIdValue(&X, TK_BOOL);} expr(A) ::= NULL(X). { A = tSqlExprCreateIdValue(&X, TK_NULL);} diff --git a/src/query/src/qSqlParser.c b/src/query/src/qSqlParser.c index 45b0fb0ec2..6b38536b15 100644 --- a/src/query/src/qSqlParser.c +++ b/src/query/src/qSqlParser.c @@ -152,6 +152,7 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) { } pSqlExpr->flags |= 1 << EXPR_FLAG_US_TIMESTAMP; + pSqlExpr->flags |= 1 << EXPR_FLAG_TIMESTAMP_VAR; pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT; pSqlExpr->tokenId = TK_TIMESTAMP; pSqlExpr->type = SQL_NODE_VALUE; @@ -221,6 +222,14 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) { pExpr->type = SQL_NODE_VALUE; pExpr->flags = pLeft->flags | pRight->flags; + if ((pLeft->flags & (1 << EXPR_FLAG_TIMESTAMP_VAR)) && (pRight->flags & (1 << EXPR_FLAG_TIMESTAMP_VAR))) { + pExpr->flags |= 1 << EXPR_FLAG_TS_ERROR; + } else { + pExpr->flags &= ~(1 << EXPR_FLAG_TIMESTAMP_VAR); + pExpr->flags &= ~(1 << EXPR_FLAG_TS_ERROR); + } + + switch (optrType) { case TK_PLUS: { pExpr->value.i64 = pLeft->value.i64 + pRight->value.i64; @@ -248,7 +257,6 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) { tSqlExprDestroy(pLeft); tSqlExprDestroy(pRight); - } else if ((pLeft->tokenId == TK_FLOAT && pRight->tokenId == TK_INTEGER) || (pLeft->tokenId == TK_INTEGER && pRight->tokenId == TK_FLOAT) || (pLeft->tokenId == TK_FLOAT && pRight->tokenId == TK_FLOAT)) { diff --git a/src/query/src/sql.c b/src/query/src/sql.c index 3c22bd85cc..96d33a8ed6 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -138,17 +138,17 @@ typedef union { #define ParseCTX_STORE #define YYFALLBACK 1 #define YYNSTATE 315 -#define YYNRULE 267 -#define YYNRULE_WITH_ACTION 267 +#define YYNRULE 269 +#define YYNRULE_WITH_ACTION 269 #define YYNTOKEN 187 #define YY_MAX_SHIFT 314 -#define YY_MIN_SHIFTREDUCE 506 -#define YY_MAX_SHIFTREDUCE 772 -#define YY_ERROR_ACTION 773 -#define YY_ACCEPT_ACTION 774 -#define YY_NO_ACTION 775 -#define YY_MIN_REDUCE 776 -#define YY_MAX_REDUCE 1042 +#define YY_MIN_SHIFTREDUCE 508 +#define YY_MAX_SHIFTREDUCE 776 +#define YY_ERROR_ACTION 777 +#define YY_ACCEPT_ACTION 778 +#define YY_NO_ACTION 779 +#define YY_MIN_REDUCE 780 +#define YY_MAX_REDUCE 1048 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -215,77 +215,76 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (681) +#define YY_ACTTAB_COUNT (672) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 133, 553, 202, 312, 206, 140, 943, 17, 85, 554, - /* 10 */ 774, 314, 179, 47, 48, 140, 51, 52, 30, 181, - /* 20 */ 214, 41, 181, 50, 262, 55, 53, 57, 54, 1023, - /* 30 */ 922, 209, 1024, 46, 45, 185, 181, 44, 43, 42, - /* 40 */ 47, 48, 910, 51, 52, 208, 1024, 214, 41, 553, - /* 50 */ 50, 262, 55, 53, 57, 54, 934, 554, 1020, 203, - /* 60 */ 46, 45, 919, 247, 44, 43, 42, 48, 940, 51, - /* 70 */ 52, 242, 974, 214, 41, 553, 50, 262, 55, 53, - /* 80 */ 57, 54, 975, 554, 257, 278, 46, 45, 298, 225, - /* 90 */ 44, 43, 42, 507, 508, 509, 510, 511, 512, 513, - /* 100 */ 514, 515, 516, 517, 518, 519, 313, 632, 1019, 231, - /* 110 */ 70, 553, 30, 47, 48, 1018, 51, 52, 821, 554, + /* 0 */ 133, 555, 204, 312, 208, 140, 947, 17, 85, 556, + /* 10 */ 778, 314, 179, 47, 48, 140, 51, 52, 30, 181, + /* 20 */ 214, 41, 181, 50, 262, 55, 53, 57, 54, 1029, + /* 30 */ 926, 211, 1030, 46, 45, 185, 181, 44, 43, 42, + /* 40 */ 47, 48, 914, 51, 52, 210, 1030, 214, 41, 555, + /* 50 */ 50, 262, 55, 53, 57, 54, 938, 556, 1026, 205, + /* 60 */ 46, 45, 923, 247, 44, 43, 42, 48, 944, 51, + /* 70 */ 52, 242, 978, 214, 41, 555, 50, 262, 55, 53, + /* 80 */ 57, 54, 979, 556, 257, 278, 46, 45, 298, 225, + /* 90 */ 44, 43, 42, 509, 510, 511, 512, 513, 514, 515, + /* 100 */ 516, 517, 518, 519, 520, 521, 313, 634, 1025, 231, + /* 110 */ 70, 555, 30, 47, 48, 1024, 51, 52, 825, 556, /* 120 */ 214, 41, 166, 50, 262, 55, 53, 57, 54, 44, - /* 130 */ 43, 42, 718, 46, 45, 288, 287, 44, 43, 42, - /* 140 */ 47, 49, 830, 51, 52, 198, 166, 214, 41, 234, - /* 150 */ 50, 262, 55, 53, 57, 54, 918, 238, 237, 227, + /* 130 */ 43, 42, 720, 46, 45, 288, 287, 44, 43, 42, + /* 140 */ 47, 49, 834, 51, 52, 198, 166, 214, 41, 234, + /* 150 */ 50, 262, 55, 53, 57, 54, 922, 238, 237, 227, /* 160 */ 46, 45, 285, 284, 44, 43, 42, 23, 276, 307, /* 170 */ 306, 275, 274, 273, 305, 272, 304, 303, 302, 271, - /* 180 */ 301, 300, 882, 140, 870, 871, 872, 873, 874, 875, - /* 190 */ 876, 877, 878, 879, 880, 881, 883, 884, 51, 52, - /* 200 */ 822, 219, 214, 41, 166, 50, 262, 55, 53, 57, - /* 210 */ 54, 223, 18, 82, 25, 46, 45, 199, 226, 44, - /* 220 */ 43, 42, 213, 731, 934, 221, 722, 922, 725, 190, - /* 230 */ 728, 183, 213, 731, 140, 191, 722, 908, 725, 204, - /* 240 */ 728, 118, 117, 189, 905, 906, 29, 909, 259, 74, - /* 250 */ 78, 922, 30, 920, 210, 211, 308, 36, 261, 69, - /* 260 */ 23, 916, 307, 306, 210, 211, 61, 305, 30, 304, - /* 270 */ 303, 302, 74, 301, 300, 890, 3, 167, 888, 889, - /* 280 */ 36, 224, 922, 891, 280, 893, 894, 892, 62, 895, - /* 290 */ 896, 907, 656, 217, 12, 653, 919, 654, 84, 655, - /* 300 */ 81, 79, 241, 220, 68, 55, 53, 57, 54, 218, - /* 310 */ 197, 184, 919, 46, 45, 30, 278, 44, 43, 42, - /* 320 */ 80, 103, 108, 228, 229, 56, 263, 97, 107, 113, - /* 330 */ 116, 106, 732, 71, 671, 56, 186, 110, 730, 30, - /* 340 */ 180, 30, 732, 5, 156, 30, 699, 700, 730, 33, - /* 350 */ 155, 92, 87, 91, 729, 668, 281, 678, 105, 919, - /* 360 */ 174, 170, 24, 298, 729, 245, 172, 169, 121, 120, - /* 370 */ 119, 46, 45, 1, 154, 44, 43, 42, 720, 724, - /* 380 */ 282, 727, 286, 919, 243, 919, 290, 187, 31, 919, - /* 390 */ 311, 310, 126, 684, 212, 64, 690, 135, 691, 752, - /* 400 */ 60, 657, 20, 19, 733, 723, 642, 726, 19, 265, - /* 410 */ 31, 188, 675, 31, 721, 65, 96, 95, 194, 644, - /* 420 */ 267, 643, 735, 60, 83, 60, 28, 14, 13, 268, - /* 430 */ 102, 101, 67, 660, 631, 661, 195, 658, 6, 659, - /* 440 */ 16, 15, 115, 114, 131, 129, 193, 178, 192, 182, - /* 450 */ 1034, 921, 985, 984, 215, 981, 980, 239, 216, 289, - /* 460 */ 132, 942, 39, 950, 952, 134, 138, 935, 246, 967, - /* 470 */ 130, 966, 917, 150, 151, 915, 299, 152, 683, 248, - /* 480 */ 886, 104, 291, 149, 147, 153, 833, 142, 932, 141, - /* 490 */ 270, 66, 205, 37, 250, 176, 34, 279, 829, 1039, - /* 500 */ 93, 255, 1038, 1036, 143, 63, 58, 157, 283, 1033, - /* 510 */ 99, 1032, 260, 1030, 158, 851, 256, 35, 258, 32, - /* 520 */ 38, 177, 818, 109, 254, 816, 111, 112, 252, 814, - /* 530 */ 813, 230, 168, 811, 810, 809, 808, 807, 806, 171, - /* 540 */ 173, 803, 801, 799, 797, 795, 175, 249, 244, 72, - /* 550 */ 75, 251, 40, 968, 292, 293, 294, 295, 296, 200, - /* 560 */ 297, 222, 269, 309, 772, 233, 232, 771, 88, 201, - /* 570 */ 235, 196, 89, 236, 770, 758, 757, 240, 245, 8, - /* 580 */ 264, 73, 663, 136, 812, 161, 165, 685, 852, 159, - /* 590 */ 160, 162, 164, 163, 122, 123, 805, 76, 124, 804, - /* 600 */ 4, 688, 137, 125, 796, 77, 146, 144, 148, 145, - /* 610 */ 207, 2, 898, 253, 26, 692, 139, 9, 10, 734, - /* 620 */ 27, 7, 11, 21, 736, 22, 86, 266, 595, 591, - /* 630 */ 84, 589, 588, 587, 584, 557, 277, 90, 94, 31, - /* 640 */ 634, 59, 633, 630, 579, 98, 100, 577, 569, 575, - /* 650 */ 571, 573, 567, 565, 598, 597, 596, 594, 593, 592, - /* 660 */ 590, 586, 585, 60, 555, 523, 521, 776, 775, 775, - /* 670 */ 775, 775, 775, 775, 775, 775, 775, 775, 775, 127, - /* 680 */ 128, + /* 180 */ 301, 300, 886, 140, 874, 875, 876, 877, 878, 879, + /* 190 */ 880, 881, 882, 883, 884, 885, 887, 888, 51, 52, + /* 200 */ 826, 219, 214, 41, 166, 50, 262, 55, 53, 57, + /* 210 */ 54, 223, 18, 82, 25, 46, 45, 1, 154, 44, + /* 220 */ 43, 42, 213, 735, 938, 722, 724, 926, 727, 190, + /* 230 */ 730, 226, 213, 735, 140, 191, 724, 912, 727, 206, + /* 240 */ 730, 118, 117, 189, 909, 910, 29, 913, 259, 74, + /* 250 */ 78, 726, 30, 729, 200, 201, 221, 36, 261, 199, + /* 260 */ 23, 723, 307, 306, 200, 201, 924, 305, 30, 304, + /* 270 */ 303, 302, 74, 301, 300, 894, 183, 308, 892, 893, + /* 280 */ 36, 224, 926, 895, 280, 897, 898, 896, 184, 899, + /* 290 */ 900, 920, 658, 217, 69, 655, 923, 656, 725, 657, + /* 300 */ 728, 79, 241, 926, 68, 55, 53, 57, 54, 218, + /* 310 */ 197, 212, 923, 46, 45, 30, 278, 44, 43, 42, + /* 320 */ 673, 103, 108, 228, 229, 56, 911, 97, 107, 113, + /* 330 */ 116, 106, 736, 220, 263, 56, 186, 110, 732, 30, + /* 340 */ 180, 30, 736, 5, 156, 30, 3, 167, 732, 33, + /* 350 */ 155, 92, 87, 91, 731, 6, 281, 701, 702, 923, + /* 360 */ 174, 170, 28, 733, 731, 268, 172, 169, 121, 120, + /* 370 */ 119, 46, 45, 105, 80, 44, 43, 42, 298, 662, + /* 380 */ 282, 663, 286, 923, 670, 923, 290, 71, 12, 923, + /* 390 */ 187, 24, 84, 188, 81, 311, 310, 126, 677, 243, + /* 400 */ 680, 659, 660, 31, 661, 686, 1040, 692, 245, 135, + /* 410 */ 734, 60, 693, 756, 737, 61, 20, 19, 19, 64, + /* 420 */ 644, 265, 646, 267, 31, 31, 60, 83, 645, 67, + /* 430 */ 739, 633, 60, 925, 96, 95, 194, 62, 195, 65, + /* 440 */ 193, 14, 13, 102, 101, 115, 114, 131, 129, 16, + /* 450 */ 15, 178, 192, 182, 989, 988, 215, 239, 985, 132, + /* 460 */ 984, 216, 289, 946, 39, 971, 954, 956, 134, 138, + /* 470 */ 970, 939, 246, 130, 921, 151, 919, 150, 152, 153, + /* 480 */ 248, 837, 270, 685, 890, 299, 104, 291, 148, 37, + /* 490 */ 145, 176, 936, 141, 34, 58, 207, 250, 255, 66, + /* 500 */ 63, 142, 279, 833, 1045, 260, 143, 258, 144, 256, + /* 510 */ 93, 1044, 1042, 254, 157, 146, 283, 1039, 99, 1038, + /* 520 */ 1036, 252, 158, 855, 35, 32, 38, 177, 249, 822, + /* 530 */ 109, 820, 111, 112, 818, 817, 230, 168, 815, 814, + /* 540 */ 813, 812, 811, 810, 171, 173, 807, 805, 803, 801, + /* 550 */ 799, 175, 40, 244, 72, 75, 251, 292, 972, 293, + /* 560 */ 294, 296, 295, 297, 309, 776, 202, 222, 269, 232, + /* 570 */ 233, 203, 775, 235, 88, 89, 236, 196, 774, 762, + /* 580 */ 761, 240, 245, 8, 73, 264, 209, 665, 687, 816, + /* 590 */ 165, 856, 161, 159, 160, 122, 162, 163, 123, 164, + /* 600 */ 809, 2, 76, 124, 125, 808, 800, 136, 137, 4, + /* 610 */ 690, 149, 147, 77, 253, 26, 694, 139, 902, 9, + /* 620 */ 10, 27, 738, 7, 11, 740, 21, 22, 266, 86, + /* 630 */ 597, 593, 84, 591, 590, 589, 586, 559, 277, 90, + /* 640 */ 94, 31, 636, 59, 635, 632, 581, 579, 571, 577, + /* 650 */ 573, 575, 569, 567, 98, 100, 600, 599, 598, 596, + /* 660 */ 595, 594, 592, 588, 587, 60, 557, 525, 523, 780, + /* 670 */ 127, 128, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 190, 1, 189, 190, 209, 190, 190, 251, 196, 9, @@ -309,54 +308,54 @@ static const YYCODETYPE yy_lookahead[] = { /* 180 */ 101, 102, 208, 190, 210, 211, 212, 213, 214, 215, /* 190 */ 216, 217, 218, 219, 220, 221, 222, 223, 16, 17, /* 200 */ 195, 209, 20, 21, 199, 23, 24, 25, 26, 27, - /* 210 */ 28, 67, 44, 196, 104, 33, 34, 251, 190, 37, - /* 220 */ 38, 39, 1, 2, 233, 209, 5, 235, 7, 61, - /* 230 */ 9, 251, 1, 2, 190, 67, 5, 0, 7, 248, + /* 210 */ 28, 67, 44, 196, 104, 33, 34, 197, 198, 37, + /* 220 */ 38, 39, 1, 2, 233, 1, 5, 235, 7, 61, + /* 230 */ 9, 190, 1, 2, 190, 67, 5, 0, 7, 248, /* 240 */ 9, 73, 74, 75, 227, 228, 229, 230, 255, 104, - /* 250 */ 257, 235, 190, 225, 33, 34, 209, 112, 37, 196, - /* 260 */ 88, 190, 90, 91, 33, 34, 109, 95, 190, 97, - /* 270 */ 98, 99, 104, 101, 102, 208, 193, 194, 211, 212, - /* 280 */ 112, 137, 235, 216, 140, 218, 219, 220, 131, 222, - /* 290 */ 223, 228, 2, 231, 104, 5, 234, 7, 108, 9, - /* 300 */ 110, 257, 134, 232, 136, 25, 26, 27, 28, 231, - /* 310 */ 142, 251, 234, 33, 34, 190, 79, 37, 38, 39, - /* 320 */ 236, 62, 63, 33, 34, 104, 15, 68, 69, 70, - /* 330 */ 71, 72, 111, 249, 37, 104, 251, 78, 117, 190, - /* 340 */ 251, 190, 111, 62, 63, 190, 124, 125, 117, 68, - /* 350 */ 69, 70, 71, 72, 133, 109, 231, 105, 76, 234, - /* 360 */ 62, 63, 116, 81, 133, 113, 68, 69, 70, 71, - /* 370 */ 72, 33, 34, 197, 198, 37, 38, 39, 1, 5, - /* 380 */ 231, 7, 231, 234, 105, 234, 231, 251, 109, 234, - /* 390 */ 64, 65, 66, 105, 60, 109, 105, 109, 105, 105, - /* 400 */ 109, 111, 109, 109, 105, 5, 105, 7, 109, 105, - /* 410 */ 109, 251, 115, 109, 37, 129, 138, 139, 251, 105, - /* 420 */ 105, 105, 111, 109, 109, 109, 104, 138, 139, 107, - /* 430 */ 138, 139, 104, 5, 106, 7, 251, 5, 104, 7, - /* 440 */ 138, 139, 76, 77, 62, 63, 251, 251, 251, 251, - /* 450 */ 235, 235, 226, 226, 226, 226, 226, 190, 226, 226, - /* 460 */ 190, 190, 250, 190, 190, 190, 190, 233, 233, 258, - /* 470 */ 60, 258, 233, 237, 190, 190, 103, 190, 117, 254, - /* 480 */ 224, 87, 86, 238, 240, 190, 190, 245, 247, 246, - /* 490 */ 190, 128, 254, 190, 254, 190, 190, 190, 190, 190, - /* 500 */ 190, 254, 190, 190, 244, 130, 127, 190, 190, 190, - /* 510 */ 190, 190, 122, 190, 190, 190, 121, 190, 126, 190, - /* 520 */ 190, 190, 190, 190, 120, 190, 190, 190, 119, 190, + /* 250 */ 257, 5, 190, 7, 33, 34, 209, 112, 37, 251, + /* 260 */ 88, 37, 90, 91, 33, 34, 225, 95, 190, 97, + /* 270 */ 98, 99, 104, 101, 102, 208, 251, 209, 211, 212, + /* 280 */ 112, 137, 235, 216, 140, 218, 219, 220, 251, 222, + /* 290 */ 223, 190, 2, 231, 196, 5, 234, 7, 5, 9, + /* 300 */ 7, 257, 134, 235, 136, 25, 26, 27, 28, 231, + /* 310 */ 142, 60, 234, 33, 34, 190, 79, 37, 38, 39, + /* 320 */ 37, 62, 63, 33, 34, 104, 228, 68, 69, 70, + /* 330 */ 71, 72, 111, 232, 15, 104, 251, 78, 117, 190, + /* 340 */ 251, 190, 111, 62, 63, 190, 193, 194, 117, 68, + /* 350 */ 69, 70, 71, 72, 133, 104, 231, 124, 125, 234, + /* 360 */ 62, 63, 104, 117, 133, 107, 68, 69, 70, 71, + /* 370 */ 72, 33, 34, 76, 236, 37, 38, 39, 81, 5, + /* 380 */ 231, 7, 231, 234, 109, 234, 231, 249, 104, 234, + /* 390 */ 251, 116, 108, 251, 110, 64, 65, 66, 115, 105, + /* 400 */ 105, 111, 5, 109, 7, 105, 235, 105, 113, 109, + /* 410 */ 117, 109, 105, 105, 105, 109, 109, 109, 109, 109, + /* 420 */ 105, 105, 105, 105, 109, 109, 109, 109, 105, 104, + /* 430 */ 111, 106, 109, 235, 138, 139, 251, 131, 251, 129, + /* 440 */ 251, 138, 139, 138, 139, 76, 77, 62, 63, 138, + /* 450 */ 139, 251, 251, 251, 226, 226, 226, 190, 226, 190, + /* 460 */ 226, 226, 226, 190, 250, 258, 190, 190, 190, 190, + /* 470 */ 258, 233, 233, 60, 233, 190, 190, 237, 190, 190, + /* 480 */ 254, 190, 190, 117, 224, 103, 87, 86, 239, 190, + /* 490 */ 242, 190, 247, 246, 190, 127, 254, 254, 254, 128, + /* 500 */ 130, 245, 190, 190, 190, 122, 244, 126, 243, 121, + /* 510 */ 190, 190, 190, 120, 190, 241, 190, 190, 190, 190, + /* 520 */ 190, 119, 190, 190, 190, 190, 190, 190, 118, 190, /* 530 */ 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, - /* 540 */ 190, 190, 190, 190, 190, 190, 190, 118, 191, 191, - /* 550 */ 191, 191, 132, 191, 50, 83, 85, 54, 84, 191, - /* 560 */ 82, 191, 191, 79, 5, 5, 145, 5, 196, 191, - /* 570 */ 145, 191, 196, 5, 5, 90, 89, 135, 113, 104, - /* 580 */ 107, 114, 105, 104, 191, 201, 200, 105, 207, 206, - /* 590 */ 205, 204, 203, 202, 192, 192, 191, 109, 192, 191, - /* 600 */ 193, 105, 109, 192, 191, 104, 241, 243, 239, 242, - /* 610 */ 1, 197, 224, 104, 109, 105, 104, 123, 123, 105, - /* 620 */ 109, 104, 104, 104, 111, 104, 76, 107, 9, 5, - /* 630 */ 108, 5, 5, 5, 5, 80, 15, 76, 139, 109, - /* 640 */ 5, 16, 5, 105, 5, 139, 139, 5, 5, 5, - /* 650 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - /* 660 */ 5, 5, 5, 109, 80, 60, 59, 0, 262, 262, - /* 670 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 21, - /* 680 */ 21, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 540 */ 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, + /* 550 */ 190, 190, 132, 191, 191, 191, 191, 50, 191, 83, + /* 560 */ 85, 84, 54, 82, 79, 5, 191, 191, 191, 145, + /* 570 */ 5, 191, 5, 145, 196, 196, 5, 191, 5, 90, + /* 580 */ 89, 135, 113, 104, 114, 107, 1, 105, 105, 191, + /* 590 */ 200, 207, 201, 206, 205, 192, 204, 202, 192, 203, + /* 600 */ 191, 197, 109, 192, 192, 191, 191, 104, 109, 193, + /* 610 */ 105, 238, 240, 104, 104, 109, 105, 104, 224, 123, + /* 620 */ 123, 109, 105, 104, 104, 111, 104, 104, 107, 76, + /* 630 */ 9, 5, 108, 5, 5, 5, 5, 80, 15, 76, + /* 640 */ 139, 109, 5, 16, 5, 105, 5, 5, 5, 5, + /* 650 */ 5, 5, 5, 5, 139, 139, 5, 5, 5, 5, + /* 660 */ 5, 5, 5, 5, 5, 109, 80, 60, 59, 0, + /* 670 */ 21, 21, 262, 262, 262, 262, 262, 262, 262, 262, + /* 680 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, /* 690 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, /* 700 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, /* 710 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, @@ -373,102 +372,101 @@ static const YYCODETYPE yy_lookahead[] = { /* 820 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, /* 830 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, /* 840 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - /* 850 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - /* 860 */ 262, 262, 262, 262, 262, 262, 262, 262, + /* 850 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, }; #define YY_SHIFT_COUNT (314) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (667) +#define YY_SHIFT_MAX (669) static const unsigned short int yy_shift_ofst[] = { /* 0 */ 168, 79, 79, 172, 172, 6, 221, 231, 74, 74, /* 10 */ 74, 74, 74, 74, 74, 74, 74, 0, 48, 231, /* 20 */ 290, 290, 290, 290, 110, 145, 74, 74, 74, 237, - /* 30 */ 74, 74, 282, 6, 7, 7, 681, 681, 681, 231, + /* 30 */ 74, 74, 297, 6, 7, 7, 672, 672, 672, 231, /* 40 */ 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, /* 50 */ 231, 231, 231, 231, 231, 231, 231, 231, 231, 290, /* 60 */ 290, 102, 102, 102, 102, 102, 102, 102, 74, 74, - /* 70 */ 74, 297, 74, 145, 145, 74, 74, 74, 222, 222, - /* 80 */ 246, 145, 74, 74, 74, 74, 74, 74, 74, 74, + /* 70 */ 74, 283, 74, 145, 145, 74, 74, 74, 233, 233, + /* 80 */ 275, 145, 74, 74, 74, 74, 74, 74, 74, 74, /* 90 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, /* 100 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, /* 110 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, /* 120 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, - /* 130 */ 74, 74, 410, 410, 410, 361, 361, 361, 410, 361, - /* 140 */ 410, 363, 375, 379, 390, 392, 395, 404, 409, 429, - /* 150 */ 420, 410, 410, 410, 373, 6, 6, 410, 410, 394, - /* 160 */ 396, 504, 472, 471, 503, 474, 478, 373, 410, 484, - /* 170 */ 484, 410, 484, 410, 484, 410, 681, 681, 27, 100, + /* 130 */ 74, 74, 413, 413, 413, 366, 366, 366, 413, 366, + /* 140 */ 413, 371, 370, 368, 383, 381, 388, 393, 402, 410, + /* 150 */ 420, 413, 413, 413, 382, 6, 6, 413, 413, 399, + /* 160 */ 401, 507, 476, 475, 508, 477, 481, 382, 413, 485, + /* 170 */ 485, 413, 485, 413, 485, 413, 672, 672, 27, 100, /* 180 */ 127, 100, 100, 53, 182, 280, 280, 280, 280, 259, /* 190 */ 281, 298, 338, 338, 338, 338, 22, 14, 92, 92, - /* 200 */ 190, 144, 326, 279, 252, 288, 291, 293, 294, 299, - /* 210 */ 374, 400, 377, 334, 311, 157, 286, 301, 304, 314, - /* 220 */ 315, 316, 322, 278, 289, 292, 328, 302, 428, 432, - /* 230 */ 366, 382, 559, 421, 560, 562, 425, 568, 569, 485, - /* 240 */ 487, 442, 465, 473, 475, 467, 477, 488, 482, 479, - /* 250 */ 496, 493, 501, 609, 509, 510, 512, 505, 494, 511, - /* 260 */ 495, 514, 517, 513, 518, 473, 519, 520, 521, 522, - /* 270 */ 550, 619, 624, 626, 627, 628, 629, 555, 621, 561, - /* 280 */ 499, 530, 530, 625, 506, 507, 530, 635, 637, 538, - /* 290 */ 530, 639, 642, 643, 644, 645, 646, 647, 648, 649, - /* 300 */ 650, 651, 652, 653, 654, 655, 656, 657, 554, 584, - /* 310 */ 658, 659, 605, 607, 667, + /* 200 */ 246, 293, 284, 144, 331, 294, 295, 300, 302, 307, + /* 210 */ 308, 309, 224, 251, 319, 306, 310, 315, 316, 317, + /* 220 */ 318, 323, 258, 296, 303, 305, 325, 311, 374, 397, + /* 230 */ 369, 385, 560, 424, 565, 567, 428, 571, 573, 489, + /* 240 */ 491, 446, 469, 478, 479, 470, 482, 493, 483, 503, + /* 250 */ 505, 499, 509, 585, 510, 511, 513, 506, 496, 512, + /* 260 */ 497, 517, 519, 514, 520, 478, 522, 521, 523, 524, + /* 270 */ 553, 621, 626, 628, 629, 630, 631, 557, 623, 563, + /* 280 */ 501, 532, 532, 627, 515, 516, 532, 637, 639, 540, + /* 290 */ 532, 641, 642, 643, 644, 645, 646, 647, 648, 651, + /* 300 */ 652, 653, 654, 655, 656, 657, 658, 659, 556, 586, + /* 310 */ 649, 650, 607, 609, 669, }; #define YY_REDUCE_COUNT (177) #define YY_REDUCE_MIN (-244) -#define YY_REDUCE_MAX (414) +#define YY_REDUCE_MAX (416) static const short yy_reduce_ofst[] = { /* 0 */ -177, -26, -26, 67, 67, 17, -229, -215, -172, -175, /* 10 */ -7, 62, 78, 125, 149, 151, 155, -184, -187, -232, - /* 20 */ -205, -8, 16, 47, -190, -9, -185, 44, 71, -188, - /* 30 */ 28, -78, -77, 63, -53, 5, 84, 176, 83, -244, - /* 40 */ -239, -216, -193, -143, -136, -106, -34, -20, 60, 85, - /* 50 */ 89, 136, 160, 167, 185, 195, 196, 197, 198, 215, - /* 60 */ 216, 226, 227, 228, 229, 230, 232, 233, 267, 270, - /* 70 */ 271, 212, 273, 234, 235, 274, 275, 276, 211, 213, - /* 80 */ 236, 239, 284, 285, 287, 295, 296, 300, 303, 305, - /* 90 */ 306, 307, 308, 309, 310, 312, 313, 317, 318, 319, - /* 100 */ 320, 321, 323, 324, 325, 327, 329, 330, 331, 332, - /* 110 */ 333, 335, 336, 337, 339, 340, 341, 342, 343, 344, - /* 120 */ 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, - /* 130 */ 355, 356, 357, 358, 359, 225, 238, 240, 360, 247, - /* 140 */ 362, 241, 243, 242, 260, 364, 367, 365, 244, 369, - /* 150 */ 245, 368, 370, 371, 256, 372, 376, 378, 380, 381, - /* 160 */ 383, 385, 384, 387, 391, 389, 386, 388, 393, 402, - /* 170 */ 403, 405, 406, 408, 411, 413, 414, 407, + /* 20 */ -205, -8, 47, 68, -190, -9, -185, 44, 101, -188, + /* 30 */ 41, -78, -77, 98, -53, 5, 138, 20, 153, -244, + /* 40 */ -239, -216, -193, -143, -136, -106, 8, 25, 37, 85, + /* 50 */ 89, 139, 142, 185, 187, 189, 200, 201, 202, 171, + /* 60 */ 198, 228, 229, 230, 232, 234, 235, 236, 267, 269, + /* 70 */ 273, 214, 276, 238, 239, 277, 278, 279, 207, 212, + /* 80 */ 240, 241, 285, 286, 288, 289, 291, 292, 299, 301, + /* 90 */ 304, 312, 313, 314, 320, 321, 322, 324, 326, 327, + /* 100 */ 328, 329, 330, 332, 333, 334, 335, 336, 337, 339, + /* 110 */ 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, + /* 120 */ 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, + /* 130 */ 360, 361, 362, 363, 364, 226, 242, 243, 365, 244, + /* 140 */ 367, 245, 247, 256, 262, 265, 248, 274, 372, 249, + /* 150 */ 373, 375, 376, 377, 260, 378, 379, 380, 386, 384, + /* 160 */ 387, 389, 391, 392, 395, 396, 390, 394, 398, 403, + /* 170 */ 406, 409, 411, 414, 412, 415, 404, 416, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 773, 885, 831, 897, 819, 828, 1026, 1026, 773, 773, - /* 10 */ 773, 773, 773, 773, 773, 773, 773, 944, 792, 1026, - /* 20 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 828, - /* 30 */ 773, 773, 834, 828, 834, 834, 939, 869, 887, 773, - /* 40 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, - /* 50 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, - /* 60 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, - /* 70 */ 773, 946, 949, 773, 773, 951, 773, 773, 971, 971, - /* 80 */ 937, 773, 773, 773, 773, 773, 773, 773, 773, 773, - /* 90 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, - /* 100 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 817, - /* 110 */ 773, 815, 773, 773, 773, 773, 773, 773, 773, 773, - /* 120 */ 773, 773, 773, 773, 773, 773, 802, 773, 773, 773, - /* 130 */ 773, 773, 794, 794, 794, 773, 773, 773, 794, 773, - /* 140 */ 794, 978, 982, 976, 964, 972, 963, 959, 957, 956, - /* 150 */ 986, 794, 794, 794, 832, 828, 828, 794, 794, 850, - /* 160 */ 848, 846, 838, 844, 840, 842, 836, 820, 794, 826, - /* 170 */ 826, 794, 826, 794, 826, 794, 869, 887, 773, 987, - /* 180 */ 773, 1025, 977, 1015, 1014, 1021, 1013, 1012, 1011, 773, - /* 190 */ 773, 773, 1007, 1008, 1010, 1009, 773, 773, 1017, 1016, - /* 200 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, - /* 210 */ 773, 773, 773, 989, 773, 983, 979, 773, 773, 773, - /* 220 */ 773, 773, 773, 773, 773, 773, 899, 773, 773, 773, - /* 230 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, - /* 240 */ 773, 773, 936, 773, 773, 773, 773, 947, 773, 773, - /* 250 */ 773, 773, 773, 773, 773, 773, 773, 973, 773, 965, - /* 260 */ 773, 773, 773, 773, 773, 911, 773, 773, 773, 773, - /* 270 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, - /* 280 */ 773, 1037, 1035, 773, 773, 773, 1031, 773, 773, 773, - /* 290 */ 1029, 773, 773, 773, 773, 773, 773, 773, 773, 773, - /* 300 */ 773, 773, 773, 773, 773, 773, 773, 773, 853, 773, - /* 310 */ 800, 798, 773, 790, 773, + /* 0 */ 777, 889, 835, 901, 823, 832, 1032, 1032, 777, 777, + /* 10 */ 777, 777, 777, 777, 777, 777, 777, 948, 796, 1032, + /* 20 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 832, + /* 30 */ 777, 777, 838, 832, 838, 838, 943, 873, 891, 777, + /* 40 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, + /* 50 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, + /* 60 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, + /* 70 */ 777, 950, 953, 777, 777, 955, 777, 777, 975, 975, + /* 80 */ 941, 777, 777, 777, 777, 777, 777, 777, 777, 777, + /* 90 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, + /* 100 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 821, + /* 110 */ 777, 819, 777, 777, 777, 777, 777, 777, 777, 777, + /* 120 */ 777, 777, 777, 777, 777, 777, 806, 777, 777, 777, + /* 130 */ 777, 777, 798, 798, 798, 777, 777, 777, 798, 777, + /* 140 */ 798, 982, 986, 980, 968, 976, 967, 963, 961, 960, + /* 150 */ 990, 798, 798, 798, 836, 832, 832, 798, 798, 854, + /* 160 */ 852, 850, 842, 848, 844, 846, 840, 824, 798, 830, + /* 170 */ 830, 798, 830, 798, 830, 798, 873, 891, 777, 991, + /* 180 */ 777, 1031, 981, 1021, 1020, 1027, 1019, 1018, 1017, 777, + /* 190 */ 777, 777, 1013, 1014, 1016, 1015, 777, 777, 1023, 1022, + /* 200 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, + /* 210 */ 777, 777, 777, 993, 777, 987, 983, 777, 777, 777, + /* 220 */ 777, 777, 777, 777, 777, 777, 903, 777, 777, 777, + /* 230 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, + /* 240 */ 777, 777, 940, 777, 777, 777, 777, 951, 777, 777, + /* 250 */ 777, 777, 777, 777, 777, 777, 777, 977, 777, 969, + /* 260 */ 777, 777, 777, 777, 777, 915, 777, 777, 777, 777, + /* 270 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, + /* 280 */ 777, 1043, 1041, 777, 777, 777, 1037, 777, 777, 777, + /* 290 */ 1035, 777, 777, 777, 777, 777, 777, 777, 777, 777, + /* 300 */ 777, 777, 777, 777, 777, 777, 777, 777, 857, 777, + /* 310 */ 804, 802, 777, 794, 777, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1256,48 +1254,50 @@ static const char *const yyRuleName[] = { /* 222 */ "expr ::= STRING", /* 223 */ "expr ::= NOW", /* 224 */ "expr ::= VARIABLE", - /* 225 */ "expr ::= BOOL", - /* 226 */ "expr ::= NULL", - /* 227 */ "expr ::= ID LP exprlist RP", - /* 228 */ "expr ::= ID LP STAR RP", - /* 229 */ "expr ::= expr IS NULL", - /* 230 */ "expr ::= expr IS NOT NULL", - /* 231 */ "expr ::= expr LT expr", - /* 232 */ "expr ::= expr GT expr", - /* 233 */ "expr ::= expr LE expr", - /* 234 */ "expr ::= expr GE expr", - /* 235 */ "expr ::= expr NE expr", - /* 236 */ "expr ::= expr EQ expr", - /* 237 */ "expr ::= expr BETWEEN expr AND expr", - /* 238 */ "expr ::= expr AND expr", - /* 239 */ "expr ::= expr OR expr", - /* 240 */ "expr ::= expr PLUS expr", - /* 241 */ "expr ::= expr MINUS expr", - /* 242 */ "expr ::= expr STAR expr", - /* 243 */ "expr ::= expr SLASH expr", - /* 244 */ "expr ::= expr REM expr", - /* 245 */ "expr ::= expr LIKE expr", - /* 246 */ "expr ::= expr IN LP exprlist RP", - /* 247 */ "exprlist ::= exprlist COMMA expritem", - /* 248 */ "exprlist ::= expritem", - /* 249 */ "expritem ::= expr", - /* 250 */ "expritem ::=", - /* 251 */ "cmd ::= RESET QUERY CACHE", - /* 252 */ "cmd ::= SYNCDB ids REPLICA", - /* 253 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 254 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 255 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 256 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 257 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 258 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 259 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", - /* 260 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", - /* 261 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", - /* 262 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", - /* 263 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", - /* 264 */ "cmd ::= KILL CONNECTION INTEGER", - /* 265 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 266 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 225 */ "expr ::= PLUS VARIABLE", + /* 226 */ "expr ::= MINUS VARIABLE", + /* 227 */ "expr ::= BOOL", + /* 228 */ "expr ::= NULL", + /* 229 */ "expr ::= ID LP exprlist RP", + /* 230 */ "expr ::= ID LP STAR RP", + /* 231 */ "expr ::= expr IS NULL", + /* 232 */ "expr ::= expr IS NOT NULL", + /* 233 */ "expr ::= expr LT expr", + /* 234 */ "expr ::= expr GT expr", + /* 235 */ "expr ::= expr LE expr", + /* 236 */ "expr ::= expr GE expr", + /* 237 */ "expr ::= expr NE expr", + /* 238 */ "expr ::= expr EQ expr", + /* 239 */ "expr ::= expr BETWEEN expr AND expr", + /* 240 */ "expr ::= expr AND expr", + /* 241 */ "expr ::= expr OR expr", + /* 242 */ "expr ::= expr PLUS expr", + /* 243 */ "expr ::= expr MINUS expr", + /* 244 */ "expr ::= expr STAR expr", + /* 245 */ "expr ::= expr SLASH expr", + /* 246 */ "expr ::= expr REM expr", + /* 247 */ "expr ::= expr LIKE expr", + /* 248 */ "expr ::= expr IN LP exprlist RP", + /* 249 */ "exprlist ::= exprlist COMMA expritem", + /* 250 */ "exprlist ::= expritem", + /* 251 */ "expritem ::= expr", + /* 252 */ "expritem ::=", + /* 253 */ "cmd ::= RESET QUERY CACHE", + /* 254 */ "cmd ::= SYNCDB ids REPLICA", + /* 255 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 256 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 257 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 258 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 259 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 260 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 261 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", + /* 262 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", + /* 263 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", + /* 264 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", + /* 265 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", + /* 266 */ "cmd ::= KILL CONNECTION INTEGER", + /* 267 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 268 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1982,48 +1982,50 @@ static const YYCODETYPE yyRuleInfoLhs[] = { 251, /* (222) expr ::= STRING */ 251, /* (223) expr ::= NOW */ 251, /* (224) expr ::= VARIABLE */ - 251, /* (225) expr ::= BOOL */ - 251, /* (226) expr ::= NULL */ - 251, /* (227) expr ::= ID LP exprlist RP */ - 251, /* (228) expr ::= ID LP STAR RP */ - 251, /* (229) expr ::= expr IS NULL */ - 251, /* (230) expr ::= expr IS NOT NULL */ - 251, /* (231) expr ::= expr LT expr */ - 251, /* (232) expr ::= expr GT expr */ - 251, /* (233) expr ::= expr LE expr */ - 251, /* (234) expr ::= expr GE expr */ - 251, /* (235) expr ::= expr NE expr */ - 251, /* (236) expr ::= expr EQ expr */ - 251, /* (237) expr ::= expr BETWEEN expr AND expr */ - 251, /* (238) expr ::= expr AND expr */ - 251, /* (239) expr ::= expr OR expr */ - 251, /* (240) expr ::= expr PLUS expr */ - 251, /* (241) expr ::= expr MINUS expr */ - 251, /* (242) expr ::= expr STAR expr */ - 251, /* (243) expr ::= expr SLASH expr */ - 251, /* (244) expr ::= expr REM expr */ - 251, /* (245) expr ::= expr LIKE expr */ - 251, /* (246) expr ::= expr IN LP exprlist RP */ - 260, /* (247) exprlist ::= exprlist COMMA expritem */ - 260, /* (248) exprlist ::= expritem */ - 261, /* (249) expritem ::= expr */ - 261, /* (250) expritem ::= */ - 188, /* (251) cmd ::= RESET QUERY CACHE */ - 188, /* (252) cmd ::= SYNCDB ids REPLICA */ - 188, /* (253) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - 188, /* (254) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - 188, /* (255) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - 188, /* (256) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - 188, /* (257) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - 188, /* (258) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - 188, /* (259) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - 188, /* (260) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - 188, /* (261) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - 188, /* (262) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - 188, /* (263) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - 188, /* (264) cmd ::= KILL CONNECTION INTEGER */ - 188, /* (265) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - 188, /* (266) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + 251, /* (225) expr ::= PLUS VARIABLE */ + 251, /* (226) expr ::= MINUS VARIABLE */ + 251, /* (227) expr ::= BOOL */ + 251, /* (228) expr ::= NULL */ + 251, /* (229) expr ::= ID LP exprlist RP */ + 251, /* (230) expr ::= ID LP STAR RP */ + 251, /* (231) expr ::= expr IS NULL */ + 251, /* (232) expr ::= expr IS NOT NULL */ + 251, /* (233) expr ::= expr LT expr */ + 251, /* (234) expr ::= expr GT expr */ + 251, /* (235) expr ::= expr LE expr */ + 251, /* (236) expr ::= expr GE expr */ + 251, /* (237) expr ::= expr NE expr */ + 251, /* (238) expr ::= expr EQ expr */ + 251, /* (239) expr ::= expr BETWEEN expr AND expr */ + 251, /* (240) expr ::= expr AND expr */ + 251, /* (241) expr ::= expr OR expr */ + 251, /* (242) expr ::= expr PLUS expr */ + 251, /* (243) expr ::= expr MINUS expr */ + 251, /* (244) expr ::= expr STAR expr */ + 251, /* (245) expr ::= expr SLASH expr */ + 251, /* (246) expr ::= expr REM expr */ + 251, /* (247) expr ::= expr LIKE expr */ + 251, /* (248) expr ::= expr IN LP exprlist RP */ + 260, /* (249) exprlist ::= exprlist COMMA expritem */ + 260, /* (250) exprlist ::= expritem */ + 261, /* (251) expritem ::= expr */ + 261, /* (252) expritem ::= */ + 188, /* (253) cmd ::= RESET QUERY CACHE */ + 188, /* (254) cmd ::= SYNCDB ids REPLICA */ + 188, /* (255) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + 188, /* (256) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + 188, /* (257) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + 188, /* (258) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + 188, /* (259) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + 188, /* (260) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + 188, /* (261) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + 188, /* (262) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + 188, /* (263) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + 188, /* (264) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + 188, /* (265) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + 188, /* (266) cmd ::= KILL CONNECTION INTEGER */ + 188, /* (267) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + 188, /* (268) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -2254,48 +2256,50 @@ static const signed char yyRuleInfoNRhs[] = { -1, /* (222) expr ::= STRING */ -1, /* (223) expr ::= NOW */ -1, /* (224) expr ::= VARIABLE */ - -1, /* (225) expr ::= BOOL */ - -1, /* (226) expr ::= NULL */ - -4, /* (227) expr ::= ID LP exprlist RP */ - -4, /* (228) expr ::= ID LP STAR RP */ - -3, /* (229) expr ::= expr IS NULL */ - -4, /* (230) expr ::= expr IS NOT NULL */ - -3, /* (231) expr ::= expr LT expr */ - -3, /* (232) expr ::= expr GT expr */ - -3, /* (233) expr ::= expr LE expr */ - -3, /* (234) expr ::= expr GE expr */ - -3, /* (235) expr ::= expr NE expr */ - -3, /* (236) expr ::= expr EQ expr */ - -5, /* (237) expr ::= expr BETWEEN expr AND expr */ - -3, /* (238) expr ::= expr AND expr */ - -3, /* (239) expr ::= expr OR expr */ - -3, /* (240) expr ::= expr PLUS expr */ - -3, /* (241) expr ::= expr MINUS expr */ - -3, /* (242) expr ::= expr STAR expr */ - -3, /* (243) expr ::= expr SLASH expr */ - -3, /* (244) expr ::= expr REM expr */ - -3, /* (245) expr ::= expr LIKE expr */ - -5, /* (246) expr ::= expr IN LP exprlist RP */ - -3, /* (247) exprlist ::= exprlist COMMA expritem */ - -1, /* (248) exprlist ::= expritem */ - -1, /* (249) expritem ::= expr */ - 0, /* (250) expritem ::= */ - -3, /* (251) cmd ::= RESET QUERY CACHE */ - -3, /* (252) cmd ::= SYNCDB ids REPLICA */ - -7, /* (253) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (254) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - -7, /* (255) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - -7, /* (256) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - -8, /* (257) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - -9, /* (258) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - -7, /* (259) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (260) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - -7, /* (261) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - -7, /* (262) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - -8, /* (263) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - -3, /* (264) cmd ::= KILL CONNECTION INTEGER */ - -5, /* (265) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - -5, /* (266) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + -2, /* (225) expr ::= PLUS VARIABLE */ + -2, /* (226) expr ::= MINUS VARIABLE */ + -1, /* (227) expr ::= BOOL */ + -1, /* (228) expr ::= NULL */ + -4, /* (229) expr ::= ID LP exprlist RP */ + -4, /* (230) expr ::= ID LP STAR RP */ + -3, /* (231) expr ::= expr IS NULL */ + -4, /* (232) expr ::= expr IS NOT NULL */ + -3, /* (233) expr ::= expr LT expr */ + -3, /* (234) expr ::= expr GT expr */ + -3, /* (235) expr ::= expr LE expr */ + -3, /* (236) expr ::= expr GE expr */ + -3, /* (237) expr ::= expr NE expr */ + -3, /* (238) expr ::= expr EQ expr */ + -5, /* (239) expr ::= expr BETWEEN expr AND expr */ + -3, /* (240) expr ::= expr AND expr */ + -3, /* (241) expr ::= expr OR expr */ + -3, /* (242) expr ::= expr PLUS expr */ + -3, /* (243) expr ::= expr MINUS expr */ + -3, /* (244) expr ::= expr STAR expr */ + -3, /* (245) expr ::= expr SLASH expr */ + -3, /* (246) expr ::= expr REM expr */ + -3, /* (247) expr ::= expr LIKE expr */ + -5, /* (248) expr ::= expr IN LP exprlist RP */ + -3, /* (249) exprlist ::= exprlist COMMA expritem */ + -1, /* (250) exprlist ::= expritem */ + -1, /* (251) expritem ::= expr */ + 0, /* (252) expritem ::= */ + -3, /* (253) cmd ::= RESET QUERY CACHE */ + -3, /* (254) cmd ::= SYNCDB ids REPLICA */ + -7, /* (255) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + -7, /* (256) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + -7, /* (257) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + -7, /* (258) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + -8, /* (259) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + -9, /* (260) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + -7, /* (261) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + -7, /* (262) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + -7, /* (263) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + -7, /* (264) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + -8, /* (265) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + -3, /* (266) cmd ::= KILL CONNECTION INTEGER */ + -5, /* (267) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + -5, /* (268) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3090,7 +3094,7 @@ static YYACTIONTYPE yy_reduce( break; case 200: /* having_opt ::= */ case 210: /* where_opt ::= */ yytestcase(yyruleno==210); - case 250: /* expritem ::= */ yytestcase(yyruleno==250); + case 252: /* expritem ::= */ yytestcase(yyruleno==252); {yymsp[1].minor.yy170 = 0;} break; case 201: /* having_opt ::= HAVING expr */ @@ -3163,120 +3167,125 @@ static YYACTIONTYPE yy_reduce( { yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} yymsp[0].minor.yy170 = yylhsminor.yy170; break; - case 225: /* expr ::= BOOL */ + case 225: /* expr ::= PLUS VARIABLE */ + case 226: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==226); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} + yymsp[-1].minor.yy170 = yylhsminor.yy170; + break; + case 227: /* expr ::= BOOL */ { yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} yymsp[0].minor.yy170 = yylhsminor.yy170; break; - case 226: /* expr ::= NULL */ + case 228: /* expr ::= NULL */ { yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} yymsp[0].minor.yy170 = yylhsminor.yy170; break; - case 227: /* expr ::= ID LP exprlist RP */ + case 229: /* expr ::= ID LP exprlist RP */ { yylhsminor.yy170 = tSqlExprCreateFunction(yymsp[-1].minor.yy429, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy170 = yylhsminor.yy170; break; - case 228: /* expr ::= ID LP STAR RP */ + case 230: /* expr ::= ID LP STAR RP */ { yylhsminor.yy170 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy170 = yylhsminor.yy170; break; - case 229: /* expr ::= expr IS NULL */ + case 231: /* expr ::= expr IS NULL */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, NULL, TK_ISNULL);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 230: /* expr ::= expr IS NOT NULL */ + case 232: /* expr ::= expr IS NOT NULL */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-3].minor.yy170, NULL, TK_NOTNULL);} yymsp[-3].minor.yy170 = yylhsminor.yy170; break; - case 231: /* expr ::= expr LT expr */ + case 233: /* expr ::= expr LT expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_LT);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 232: /* expr ::= expr GT expr */ + case 234: /* expr ::= expr GT expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_GT);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 233: /* expr ::= expr LE expr */ + case 235: /* expr ::= expr LE expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_LE);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 234: /* expr ::= expr GE expr */ + case 236: /* expr ::= expr GE expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_GE);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 235: /* expr ::= expr NE expr */ + case 237: /* expr ::= expr NE expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_NE);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 236: /* expr ::= expr EQ expr */ + case 238: /* expr ::= expr EQ expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_EQ);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 237: /* expr ::= expr BETWEEN expr AND expr */ + case 239: /* expr ::= expr BETWEEN expr AND expr */ { tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy170); yylhsminor.yy170 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy170, yymsp[-2].minor.yy170, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy170, TK_LE), TK_AND);} yymsp[-4].minor.yy170 = yylhsminor.yy170; break; - case 238: /* expr ::= expr AND expr */ + case 240: /* expr ::= expr AND expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_AND);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 239: /* expr ::= expr OR expr */ + case 241: /* expr ::= expr OR expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_OR); } yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 240: /* expr ::= expr PLUS expr */ + case 242: /* expr ::= expr PLUS expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_PLUS); } yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 241: /* expr ::= expr MINUS expr */ + case 243: /* expr ::= expr MINUS expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_MINUS); } yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 242: /* expr ::= expr STAR expr */ + case 244: /* expr ::= expr STAR expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_STAR); } yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 243: /* expr ::= expr SLASH expr */ + case 245: /* expr ::= expr SLASH expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_DIVIDE);} yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 244: /* expr ::= expr REM expr */ + case 246: /* expr ::= expr REM expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_REM); } yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 245: /* expr ::= expr LIKE expr */ + case 247: /* expr ::= expr LIKE expr */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_LIKE); } yymsp[-2].minor.yy170 = yylhsminor.yy170; break; - case 246: /* expr ::= expr IN LP exprlist RP */ + case 248: /* expr ::= expr IN LP exprlist RP */ {yylhsminor.yy170 = tSqlExprCreate(yymsp[-4].minor.yy170, (tSqlExpr*)yymsp[-1].minor.yy429, TK_IN); } yymsp[-4].minor.yy170 = yylhsminor.yy170; break; - case 247: /* exprlist ::= exprlist COMMA expritem */ + case 249: /* exprlist ::= exprlist COMMA expritem */ {yylhsminor.yy429 = tSqlExprListAppend(yymsp[-2].minor.yy429,yymsp[0].minor.yy170,0, 0);} yymsp[-2].minor.yy429 = yylhsminor.yy429; break; - case 248: /* exprlist ::= expritem */ + case 250: /* exprlist ::= expritem */ {yylhsminor.yy429 = tSqlExprListAppend(0,yymsp[0].minor.yy170,0, 0);} yymsp[0].minor.yy429 = yylhsminor.yy429; break; - case 249: /* expritem ::= expr */ + case 251: /* expritem ::= expr */ {yylhsminor.yy170 = yymsp[0].minor.yy170;} yymsp[0].minor.yy170 = yylhsminor.yy170; break; - case 251: /* cmd ::= RESET QUERY CACHE */ + case 253: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 252: /* cmd ::= SYNCDB ids REPLICA */ + case 254: /* cmd ::= SYNCDB ids REPLICA */ { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} break; - case 253: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 255: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy429, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 254: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 256: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3287,14 +3296,14 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 255: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 257: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy429, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 256: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 258: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3305,7 +3314,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 257: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 259: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3319,7 +3328,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 258: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 260: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; @@ -3331,14 +3340,14 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 259: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + case 261: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy429, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 260: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + case 262: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3349,14 +3358,14 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 261: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + case 263: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy429, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 262: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + case 264: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3367,7 +3376,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 263: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + case 265: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3381,13 +3390,13 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 264: /* cmd ::= KILL CONNECTION INTEGER */ + case 266: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 265: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 267: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);} break; - case 266: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 268: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);} break; default: From d47b358b6146983b7a4b297ed2c8d2cf2e0408c2 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Thu, 22 Apr 2021 15:43:59 +0800 Subject: [PATCH 14/23] [TD-3909]: [http/race] fix singleCmd race issue --- src/plugins/http/inc/httpContext.h | 2 +- src/plugins/http/src/httpContext.c | 10 +++++----- src/plugins/http/src/httpServer.c | 6 +++--- src/plugins/http/src/httpSql.c | 2 ++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/plugins/http/inc/httpContext.h b/src/plugins/http/inc/httpContext.h index b016da2dd3..af52fdd1eb 100644 --- a/src/plugins/http/inc/httpContext.h +++ b/src/plugins/http/inc/httpContext.h @@ -25,7 +25,7 @@ const char *httpContextStateStr(HttpContextState state); HttpContext *httpCreateContext(SOCKET fd); bool httpInitContext(HttpContext *pContext); HttpContext *httpGetContext(void * pContext); -void httpReleaseContext(HttpContext *pContext, bool clearRes); +void httpReleaseContext(HttpContext *pContext/*, bool clearRes*/); void httpCloseContextByServer(HttpContext *pContext); void httpCloseContextByApp(HttpContext *pContext); void httpNotifyContextClose(HttpContext *pContext); diff --git a/src/plugins/http/src/httpContext.c b/src/plugins/http/src/httpContext.c index 13f706af65..51adef11b9 100644 --- a/src/plugins/http/src/httpContext.c +++ b/src/plugins/http/src/httpContext.c @@ -146,20 +146,20 @@ HttpContext *httpGetContext(void *ptr) { return NULL; } -void httpReleaseContext(HttpContext *pContext, bool clearRes) { +void httpReleaseContext(HttpContext *pContext/*, bool clearRes*/) { int32_t refCount = atomic_sub_fetch_32(&pContext->refCount, 1); if (refCount < 0) { httpError("context:%p, is already released, refCount:%d", pContext, refCount); return; } - + /* if (clearRes) { if (pContext->parser) { httpClearParser(pContext->parser); } memset(&pContext->singleCmd, 0, sizeof(HttpSqlCmd)); } - + */ HttpContext **ppContext = pContext->ppContext; httpTrace("context:%p, is released, data:%p refCount:%d", pContext, ppContext, refCount); @@ -217,7 +217,7 @@ void httpCloseContextByApp(HttpContext *pContext) { httpContextStateStr(pContext->state), pContext->state); } - httpReleaseContext(pContext, true); + httpReleaseContext(pContext/*, true*/); } void httpCloseContextByServer(HttpContext *pContext) { @@ -235,5 +235,5 @@ void httpCloseContextByServer(HttpContext *pContext) { pContext->parsed = false; httpRemoveContextFromEpoll(pContext); - httpReleaseContext(pContext, true); + httpReleaseContext(pContext/*, true*/); } diff --git a/src/plugins/http/src/httpServer.c b/src/plugins/http/src/httpServer.c index a5f40fdc4c..4dcf3d5501 100644 --- a/src/plugins/http/src/httpServer.c +++ b/src/plugins/http/src/httpServer.c @@ -177,7 +177,7 @@ static void httpProcessHttpData(void *param) { if (!httpAlterContextState(pContext, HTTP_CONTEXT_STATE_READY, HTTP_CONTEXT_STATE_READY)) { httpDebug("context:%p, fd:%d, state:%s, not in ready state, ignore read events", pContext, pContext->fd, httpContextStateStr(pContext->state)); - httpReleaseContext(pContext, true); + httpReleaseContext(pContext/*, true*/); continue; } @@ -191,7 +191,7 @@ static void httpProcessHttpData(void *param) { (*(pThread->processData))(pContext); atomic_fetch_add_32(&pServer->requestNum, 1); } else { - httpReleaseContext(pContext, false); + httpReleaseContext(pContext/*, false*/); } } } @@ -275,7 +275,7 @@ static void *httpAcceptHttpConnection(void *arg) { httpError("context:%p, fd:%d, ip:%s, thread:%s, failed to add http fd for epoll, error:%s", pContext, connFd, pContext->ipstr, pThread->label, strerror(errno)); taosCloseSocket(pContext->fd); - httpReleaseContext(pContext, true); + httpReleaseContext(pContext/*, true*/); continue; } diff --git a/src/plugins/http/src/httpSql.c b/src/plugins/http/src/httpSql.c index 4e9b54b7bd..b345c1531f 100644 --- a/src/plugins/http/src/httpSql.c +++ b/src/plugins/http/src/httpSql.c @@ -376,6 +376,8 @@ void httpExecCmd(HttpContext *pContext) { httpCloseContextByApp(pContext); break; } + + memset(&pContext->singleCmd, 0, sizeof(HttpSqlCmd)); } void httpProcessRequestCb(void *param, TAOS_RES *result, int32_t code) { From d4c024d779084661ff55b16bc167da952f93044d Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Thu, 22 Apr 2021 16:47:46 +0800 Subject: [PATCH 15/23] fix bug --- tests/examples/c/apitest.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 930a6075ca..f20c0321c4 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -435,11 +435,15 @@ void verify_async(TAOS* taos) { } void stream_callback(void *param, TAOS_RES *res, TAOS_ROW row) { + if (res == NULL || row == NULL) { + return; + } + int num_fields = taos_num_fields(res); TAOS_FIELD* fields = taos_fetch_fields(res); printf("got one row from stream_callback\n"); - char temp[256]; + char temp[256] = {0}; taos_print_row(temp, row, fields, num_fields); puts(temp); } From eb318dcd325520a21d4ed3d93720d4a459fb999c Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Thu, 22 Apr 2021 17:45:44 +0800 Subject: [PATCH 16/23] disable failed test --- tests/test-all.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test-all.sh b/tests/test-all.sh index 47e5de6aa0..efeecd1044 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -481,14 +481,14 @@ if [ "$2" != "sim" ] && [ "$2" != "python" ] && [ "$2" != "jdbc" ] && [ "$2" != totalExamplePass=0 echo "Running tests" - ./apitest > /dev/null 2>&1 - if [ $? != "0" ]; then - echo "apitest failed" - totalExampleFailed=`expr $totalExampleFailed + 1` - else - echo "apitest pass" - totalExamplePass=`expr $totalExamplePass + 1` - fi + # ./apitest > /dev/null 2>&1 + # if [ $? != "0" ]; then + # echo "apitest failed" + # totalExampleFailed=`expr $totalExampleFailed + 1` + # else + # echo "apitest pass" + # totalExamplePass=`expr $totalExamplePass + 1` + # fi ./prepare 127.0.0.1 > /dev/null 2>&1 if [ $? != "0" ]; then From f8cc5d8bd1ac638ad5c66aabd5b53380e29d5195 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Thu, 22 Apr 2021 18:13:09 +0800 Subject: [PATCH 17/23] [TD-3879]add stmt mode for taodemo go --- tests/examples/go/taosdemo.go | 150 +++++++++++++++++++++++++++++++++- 1 file changed, 148 insertions(+), 2 deletions(-) diff --git a/tests/examples/go/taosdemo.go b/tests/examples/go/taosdemo.go index 003f5aeddc..543cfcc0f6 100644 --- a/tests/examples/go/taosdemo.go +++ b/tests/examples/go/taosdemo.go @@ -18,6 +18,7 @@ import ( "database/sql" "flag" "fmt" + "log" "math/rand" "os" "runtime" @@ -26,8 +27,6 @@ import ( "time" _ "github.com/taosdata/driver-go/taosSql" - - //"golang.org/x/sys/unix" ) const ( @@ -48,6 +47,7 @@ type config struct { dbName string supTblName string tablePrefix string + mode string numOftables int numOfRecordsPerTable int numOfRecordsPerReq int @@ -70,6 +70,7 @@ func init() { flag.StringVar(&configPara.password, "P", "taosdata", "The password to use when connecting to the server.") flag.StringVar(&configPara.dbName, "d", "test", "Destination database.") flag.StringVar(&configPara.tablePrefix, "m", "d", "Table prefix name.") + flag.StringVar(&configPara.mode, "M", "r", "mode,r:raw,s:stmt") flag.IntVar(&configPara.numOftables, "t", 2, "The number of tables.") flag.IntVar(&configPara.numOfRecordsPerTable, "n", 10, "The number of records per table.") flag.IntVar(&configPara.numOfRecordsPerReq, "r", 3, "The number of records per request.") @@ -94,6 +95,7 @@ func printAllArgs() { fmt.Printf("usr: %v\n", configPara.user) fmt.Printf("password: %v\n", configPara.password) fmt.Printf("dbName: %v\n", configPara.dbName) + fmt.Printf("mode: %v\n", configPara.mode) fmt.Printf("tablePrefix: %v\n", configPara.tablePrefix) fmt.Printf("numOftables: %v\n", configPara.numOftables) fmt.Printf("numOfRecordsPerTable: %v\n", configPara.numOfRecordsPerTable) @@ -119,6 +121,24 @@ func main() { //defer db.Close() rand.Seed(time.Now().Unix()) + if configPara.mode == "s" { + fmt.Printf("\n======== start stmt mode test ========\n") + db, err := sql.Open("taosSql", url) + if err != nil { + log.Fatalf("Open database error: %s\n", err) + } + defer db.Close() + demodbStmt := configPara.dbName + demotStmt := "demotStmt" + drop_database_stmt(db, demodbStmt) + create_database_stmt(db, demodbStmt) + use_database_stmt(db, demodbStmt) + create_table_stmt(db, demotStmt) + insert_data_stmt(db, demotStmt) + select_data_stmt(db, demotStmt) + return + } + createDatabase(configPara.dbName, configPara.supTblName) fmt.Printf("======== create database success! ========\n\n") @@ -407,6 +427,132 @@ func selectTest(dbName string, tbPrefix string, supTblName string) { checkErr(err, "rows next iteration error") } } +func drop_database_stmt(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + // drop test db + res, err := db.Exec("drop database if exists " + demodb) + checkErr(err, "drop database "+demodb) + + affectd, err := res.RowsAffected() + checkErr(err, "drop db, res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("drop database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func create_database_stmt(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + // create database + //var stmt interface{} + stmt, err := db.Prepare("create database ?") + checkErr(err, "create db, db.Prepare") + + //var res driver.Result + res, err := stmt.Exec(demodb) + checkErr(err, "create db, stmt.Exec") + + //fmt.Printf("Query OK, %d row(s) affected()", res.RowsAffected()) + affectd, err := res.RowsAffected() + checkErr(err, "create db, res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("create database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func use_database_stmt(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + // create database + //var stmt interface{} + stmt, err := db.Prepare("use " + demodb) + checkErr(err, "use db, db.Prepare") + + res, err := stmt.Exec() + checkErr(err, "use db, stmt.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "use db, res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("use database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func create_table_stmt(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + // create table + // (ts timestamp, id int, name binary(8), len tinyint, flag bool, notes binary(8), fv float, dv double) + stmt, err := db.Prepare("create table ? (? timestamp, ? int, ? binary(10), ? tinyint, ? bool, ? binary(8), ? float, ? double)") + checkErr(err, "create table db.Prepare") + + res, err := stmt.Exec(demot, "ts", "id", "name", "len", "flag", "notes", "fv", "dv") + checkErr(err, "create table stmt.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "create table res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("create table result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func insert_data_stmt(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + // insert data into table + stmt, err := db.Prepare("insert into ? values(?, ?, ?, ?, ?, ?, ?, ?) (?, ?, ?, ?, ?, ?, ?, ?) (?, ?, ?, ?, ?, ?, ?, ?)") + checkErr(err, "insert db.Prepare") + + res, err := stmt.Exec(demot, "now", 1000, "'haidian'", 6, true, "'AI world'", 6987.654, 321.987, + "now+1s", 1001, "'changyang'", 7, false, "'DeepMode'", 12356.456, 128634.456, + "now+2s", 1002, "'chuangping'", 8, true, "'database'", 3879.456, 65433478.456) + checkErr(err, "insert data, stmt.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "res.RowsAffected") + + et := time.Now().Nanosecond() + fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} + +func select_data_stmt(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + + stmt, err := db.Prepare("select ?, ?, ?, ?, ?, ?, ?, ? from ?") // go binary mode + checkErr(err, "db.Prepare") + + rows, err := stmt.Query("ts", "id", "name", "len", "flag", "notes", "fv", "dv", demot) + checkErr(err, "stmt.Query") + + fmt.Printf("%10s%s%8s %5s %8s%s %s %10s%s %7s%s %8s%s %11s%s %14s%s\n", " ", "ts", " ", "id", " ", "name", " ", "len", " ", "flag", " ", "notes", " ", "fv", " ", " ", "dv") + var affectd int + for rows.Next() { + var ts string + var name string + var id int + var len int8 + var flag bool + var notes string + var fv float32 + var dv float64 + + err = rows.Scan(&ts, &id, &name, &len, &flag, ¬es, &fv, &dv) + //fmt.Println("start scan fields from row.rs, &fv:", &fv) + //err = rows.Scan(&fv) + checkErr(err, "rows.Scan") + + fmt.Printf("%s\t", ts) + fmt.Printf("%d\t", id) + fmt.Printf("%10s\t", name) + fmt.Printf("%d\t", len) + fmt.Printf("%t\t", flag) + fmt.Printf("%s\t", notes) + fmt.Printf("%06.3f\t", fv) + fmt.Printf("%09.6f\n", dv) + + affectd++ + + } + + et := time.Now().Nanosecond() + fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) +} func checkErr(err error, prompt string) { if err != nil { fmt.Printf("%s\n", prompt) From 56969c41e7be3e91753b544ef2b0f9a20b62bbb2 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Thu, 22 Apr 2021 18:35:14 +0800 Subject: [PATCH 18/23] [TD-3906]: taosdemo back to 4 INT columns. (#5883) * [TD-3906]: taosdemo back to 4 INT columns. * [TD-3906]: taosdemo back to 4 columns. test case need change correspondingly. Co-authored-by: Shuduo Sang --- src/kit/taosdemo/taosdemo.c | 36 ++++++++++-------------- tests/pytest/tools/taosdemoTestTblAlt.py | 4 +-- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index e1499f9e08..a11af4ba37 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -554,19 +554,13 @@ SArguments g_args = { "./output.txt", // output_file 0, // mode : sync or async { - "TINYINT", // datatype - "SMALLINT", - "INT", - "BIGINT", - "FLOAT", - "DOUBLE", - "BINARY", - "NCHAR", - "BOOL", - "TIMESTAMP" + "INT", // datatype + "INT", // datatype + "INT", // datatype + "INT", // datatype }, 16, // len_of_binary - 10, // num_of_CPR + 4, // num_of_CPR 10, // num_of_connections/thread 0, // insert_interval 1, // query_times @@ -2395,8 +2389,10 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName, return 0; } -static int createSuperTable(TAOS * taos, char* dbName, +static int createSuperTable( + TAOS * taos, char* dbName, SSuperTable* superTbl) { + char command[BUFFER_SIZE] = "\0"; char cols[STRING_LEN] = "\0"; @@ -2885,19 +2881,17 @@ static void createChildTables() { } else { // normal table len = snprintf(tblColsBuf, MAX_SQL_SIZE, "(TS TIMESTAMP"); - int j = 0; - while(g_args.datatype[j]) { + for (int j = 0; j < g_args.num_of_CPR; j++) { if ((strncasecmp(g_args.datatype[j], "BINARY", strlen("BINARY")) == 0) || (strncasecmp(g_args.datatype[j], "NCHAR", strlen("NCHAR")) == 0)) { snprintf(tblColsBuf + len, MAX_SQL_SIZE - len, - ", COL%d %s(60)", j, g_args.datatype[j]); + ", COL%d %s(%d)", j, g_args.datatype[j], g_args.len_of_binary); } else { snprintf(tblColsBuf + len, MAX_SQL_SIZE - len, ", COL%d %s", j, g_args.datatype[j]); } len = strlen(tblColsBuf); - j++; } snprintf(tblColsBuf + len, MAX_SQL_SIZE - len, ")"); @@ -4479,7 +4473,7 @@ static int32_t generateData(char *recBuf, char **data_type, exit(-1); } - for (int i = 0; i < num_of_cols; i++) { + for (int i = 0; i < c; i++) { if (strcasecmp(data_type[i % c], "tinyint") == 0) { pstr += sprintf(pstr, ", %d", rand_tinyint() ); } else if (strcasecmp(data_type[i % c], "smallint") == 0) { @@ -4501,7 +4495,7 @@ static int32_t generateData(char *recBuf, char **data_type, rand_string(s, lenOfBinary); pstr += sprintf(pstr, ", \"%s\"", s); free(s); - }else if (strcasecmp(data_type[i % c], "nchar") == 0) { + } else if (strcasecmp(data_type[i % c], "nchar") == 0) { char *s = malloc(lenOfBinary); rand_string(s, lenOfBinary); pstr += sprintf(pstr, ", \"%s\"", s); @@ -4685,7 +4679,7 @@ static int generateDataTail( if (len > remainderBufLen) break; - pstr += sprintf(pstr, " %s", data); + pstr += sprintf(pstr, "%s", data); k++; len += retLen; remainderBufLen -= retLen; @@ -5421,9 +5415,9 @@ static void startMultiThreadInsertData(int threads, char* db_name, if (superTblInfo) { int limit, offset; - if ((superTblInfo->childTblExists == TBL_NO_EXISTS) && + if ((NULL != g_args.sqlFile) && (superTblInfo->childTblExists == TBL_NO_EXISTS) && ((superTblInfo->childTblOffset != 0) || (superTblInfo->childTblLimit >= 0))) { - printf("WARNING: offset and limit will not be used since the child tables are not exists!\n"); + printf("WARNING: offset and limit will not be used since the child tables not exists!\n"); } if ((superTblInfo->childTblExists == TBL_ALREADY_EXISTS) diff --git a/tests/pytest/tools/taosdemoTestTblAlt.py b/tests/pytest/tools/taosdemoTestTblAlt.py index bb367817cf..9aa131624e 100644 --- a/tests/pytest/tools/taosdemoTestTblAlt.py +++ b/tests/pytest/tools/taosdemoTestTblAlt.py @@ -100,8 +100,8 @@ class TDTestCase: print("alter table test.meters add column col10 int") tdSql.execute("alter table test.meters add column col10 int") - print("insert into test.t9 values (now, 1, 2, 3, 4, 0.1, 0.01,'test', '测试', TRUE, 1610000000000, 0)") - tdSql.execute("insert into test.t9 values (now, 1, 2, 3, 4, 0.1, 0.01,'test', '测试', TRUE, 1610000000000, 0)") + print("insert into test.t9 values (now, 1, 2, 3, 4, 0)") + tdSql.execute("insert into test.t9 values (now, 1, 2, 3, 4, 0)") def run(self): tdSql.prepare() From 6b9cd6a31d5e2de698022ba7282920938aaf6a37 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Thu, 22 Apr 2021 18:38:07 +0800 Subject: [PATCH 19/23] [tscAsync/crash]: fix NULL pointer access --- src/client/src/tscAsync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 4326ac95f5..df13ca45fd 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -283,7 +283,7 @@ void tscQueueAsyncError(void(*fp), void *param, int32_t code) { static void tscAsyncResultCallback(SSchedMsg *pMsg) { SSqlObj* pSql = (SSqlObj*)taosAcquireRef(tscObjRef, (int64_t)pMsg->ahandle); if (pSql == NULL || pSql->signature != pSql) { - tscDebug("0x%"PRIx64" SqlObj is freed, not add into queue async res", pSql->self); + tscDebug("%p SqlObj is freed, not add into queue async res", pMsg->ahandle); return; } From 56dc7b73fcdab5726e1569ef18efec892d64f6fa Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Thu, 22 Apr 2021 18:55:14 +0800 Subject: [PATCH 20/23] enable apitest and add sleep time --- tests/perftest-scripts/perftest-query.sh | 2 +- tests/test-all.sh | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/perftest-scripts/perftest-query.sh b/tests/perftest-scripts/perftest-query.sh index 0325f552b1..9a16084683 100755 --- a/tests/perftest-scripts/perftest-query.sh +++ b/tests/perftest-scripts/perftest-query.sh @@ -64,7 +64,7 @@ function runQueryPerfTest { [ -f $PERFORMANCE_TEST_REPORT ] && rm $PERFORMANCE_TEST_REPORT nohup $WORK_DIR/TDengine/debug/build/bin/taosd -c /etc/taosperf/ > /dev/null 2>&1 & echoInfo "Wait TDengine to start" - sleep 120 + sleep 300 echoInfo "Run Performance Test" cd $WORK_DIR/TDengine/tests/pytest diff --git a/tests/test-all.sh b/tests/test-all.sh index efeecd1044..47e5de6aa0 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -481,14 +481,14 @@ if [ "$2" != "sim" ] && [ "$2" != "python" ] && [ "$2" != "jdbc" ] && [ "$2" != totalExamplePass=0 echo "Running tests" - # ./apitest > /dev/null 2>&1 - # if [ $? != "0" ]; then - # echo "apitest failed" - # totalExampleFailed=`expr $totalExampleFailed + 1` - # else - # echo "apitest pass" - # totalExamplePass=`expr $totalExamplePass + 1` - # fi + ./apitest > /dev/null 2>&1 + if [ $? != "0" ]; then + echo "apitest failed" + totalExampleFailed=`expr $totalExampleFailed + 1` + else + echo "apitest pass" + totalExamplePass=`expr $totalExamplePass + 1` + fi ./prepare 127.0.0.1 > /dev/null 2>&1 if [ $? != "0" ]; then From cde11227d9763962c73dd95fe6b699cbf114d8c4 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 23 Apr 2021 09:57:26 +0800 Subject: [PATCH 21/23] [TD-3580]: taosdump support human readable time format. (#5888) * [TD-3580]: taosdump support human readable time format. support -S too. * [TD-3580]: taosdump support human readable time format. provide more info about time format Co-authored-by: Shuduo Sang --- src/kit/taosdump/taosdump.c | 48 +++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index 3fa934c50b..96a1cd16f8 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -214,8 +214,8 @@ static struct argp_option options[] = { // dump format options {"schemaonly", 's', 0, 0, "Only dump schema.", 3}, {"with-property", 'M', 0, 0, "Dump schema with properties.", 3}, - {"start-time", 'S', "START_TIME", 0, "Start time to dump.", 3}, - {"end-time", 'E', "END_TIME", 0, "End time to dump. Epoch or ISO8601/RFC3339 format is acceptable. For example: 2017-10-01T18:00:00+0800", 3}, + {"start-time", 'S', "START_TIME", 0, "Start time to dump. Either Epoch or ISO8601/RFC3339 format is acceptable. Epoch precision millisecond. ISO8601 format example: 2017-10-01T18:00:00.000+0800 or 2017-10-0100:00:00.000+0800 or '2017-10-01 00:00:00.000+0800'", 3}, + {"end-time", 'E', "END_TIME", 0, "End time to dump. Either Epoch or ISO8601/RFC3339 format is acceptable. Epoch precision millisecond. ISO8601 format example: 2017-10-01T18:00:00.000+0800 or 2017-10-0100:00:00.000+0800 or '2017-10-01 00:00:00.000+0800'", 3}, {"data-batch", 'N', "DATA_BATCH", 0, "Number of data point per insert statement. Default is 1.", 3}, {"max-sql-len", 'L', "SQL_LEN", 0, "Max length of one sql. Default is 65480.", 3}, {"table-batch", 't', "TABLE_BATCH", 0, "Number of table dumpout into one output file. Default is 1.", 3}, @@ -482,29 +482,35 @@ static int queryDbImpl(TAOS *taos, char *command) { static void parse_args(int argc, char *argv[], SArguments *arguments) { for (int i = 1; i < argc; i++) { - if (strcmp(argv[i], "-E") == 0) { - char *tmp = strdup(argv[++i]); + if ((strcmp(argv[i], "-S") == 0) + || (strcmp(argv[i], "-E") == 0)) { + if (argv[i+1]) { + char *tmp = strdup(argv[++i]); - if (tmp) { - int64_t tmpEpoch; - if (strchr(tmp, ':') && strchr(tmp, '-')) { - if (TSDB_CODE_SUCCESS != taosParseTime( - tmp, &tmpEpoch, strlen(tmp), TSDB_TIME_PRECISION_MILLI, 0)) { - fprintf(stderr, "Input end time error!\n"); - free(tmp); - return; + if (tmp) { + int64_t tmpEpoch; + if (strchr(tmp, ':') && strchr(tmp, '-')) { + if (TSDB_CODE_SUCCESS != taosParseTime( + tmp, &tmpEpoch, strlen(tmp), TSDB_TIME_PRECISION_MILLI, 0)) { + fprintf(stderr, "Input end time error!\n"); + free(tmp); + return; + } + } else { + tmpEpoch = atoll(tmp); } - } else { - tmpEpoch = atoll(tmp); - } - - sprintf(argv[i], "%"PRId64"", tmpEpoch); - debugPrint("%s() LN%d, tmp is: %s, argv[%d]: %s\n", - __func__, __LINE__, tmp, i, argv[i]); - free(tmp); + sprintf(argv[i], "%"PRId64"", tmpEpoch); + debugPrint("%s() LN%d, tmp is: %s, argv[%d]: %s\n", + __func__, __LINE__, tmp, i, argv[i]); + + free(tmp); + } else { + errorPrint("%s() LN%d, strdup() cannot allocate memory\n", __func__, __LINE__); + exit(-1); + } } else { - errorPrint("%s() LN%d, strdup() cannot allocate memory\n", __func__, __LINE__); + errorPrint("%s need a valid value following!\n", argv[i]); exit(-1); } } else if (strcmp(argv[i], "-g") == 0) { From 7e7cc2e345ea71f40cb14613deeb45723dd1d6ae Mon Sep 17 00:00:00 2001 From: wu champion Date: Fri, 23 Apr 2021 10:31:20 +0800 Subject: [PATCH 22/23] [TD-3917] add case for the bug of TD-3907 --- tests/pytest/fulltest.sh | 1 + .../pytest/query/queryFilterTswithDateUnit.py | 166 ++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 tests/pytest/query/queryFilterTswithDateUnit.py diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index c26dc8ae2f..3323f6d8b6 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -220,6 +220,7 @@ python3 ./test.py -f query/bug3375.py python3 ./test.py -f query/queryJoin10tables.py python3 ./test.py -f query/queryStddevWithGroupby.py python3 ./test.py -f query/querySecondtscolumnTowherenow.py +python3 ./test.py -f query/queryFilterTswithDateUnit.py diff --git a/tests/pytest/query/queryFilterTswithDateUnit.py b/tests/pytest/query/queryFilterTswithDateUnit.py new file mode 100644 index 0000000000..90e30c5156 --- /dev/null +++ b/tests/pytest/query/queryFilterTswithDateUnit.py @@ -0,0 +1,166 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to execute {__file__}") + tdSql.init(conn.cursor(), logSql) + + def insertnow(self, tsp1, tsp2, tsp3): + + tdSql.execute( + "create table stbts (ts timestamp, ts1 timestamp, c1 int, ts2 timestamp) TAGS(t1 int)" + ) + tdSql.execute("create table tts1 using stbts tags(1)") + + tdSql.execute("insert into tts1 values (now+1d, now+1d, 6, now+1d)") + tdSql.execute("insert into tts1 values (now, now, 5, now)") + tdSql.execute("insert into tts1 values (now-1d, now-1d, 4, now-1d)") + tdSql.execute(f"insert into tts1 values ({tsp1}, {tsp1}, 3, {tsp1})") + tdSql.execute(f"insert into tts1 values ({tsp2}, {tsp2}, 2, {tsp2})") + tdSql.execute(f"insert into tts1 values ({tsp3}, {tsp3}, 1, {tsp3})") + + + def querynow(self): + + tdLog.printNoPrefix("==========step query: execute query operation") + time.sleep(1) + + cols = ["ts", "ts1", "ts2"] + + for col in cols: + tdSql.error(f" select * from tts1 where {col} = 1d ") + tdSql.error(f" select * from tts1 where {col} < 1d ") + tdSql.error(f" select * from tts1 where {col} > 1d ") + tdSql.error(f" select * from tts1 where {col} >= 1d ") + tdSql.error(f" select * from tts1 where {col} <= 1d ") + tdSql.error(f" select * from tts1 where {col} <> 1d ") + + tdSql.error(f" select * from tts1 where {col} = 1m ") + tdSql.error(f" select * from tts1 where {col} < 1m ") + tdSql.error(f" select * from tts1 where {col} > 1m ") + tdSql.error(f" select * from tts1 where {col} >= 1m ") + tdSql.error(f" select * from tts1 where {col} <= 1m ") + tdSql.error(f" select * from tts1 where {col} <> 1m ") + + tdSql.error(f" select * from tts1 where {col} = 1s ") + tdSql.error(f" select * from tts1 where {col} < 1s ") + tdSql.error(f" select * from tts1 where {col} > 1s ") + tdSql.error(f" select * from tts1 where {col} >= 1s ") + tdSql.error(f" select * from tts1 where {col} <= 1s ") + tdSql.error(f" select * from tts1 where {col} <> 1s ") + + tdSql.error(f" select * from tts1 where {col} = 1a ") + tdSql.error(f" select * from tts1 where {col} < 1a ") + tdSql.error(f" select * from tts1 where {col} > 1a ") + tdSql.error(f" select * from tts1 where {col} >= 1a ") + tdSql.error(f" select * from tts1 where {col} <= 1a ") + tdSql.error(f" select * from tts1 where {col} <> 1a ") + + tdSql.error(f" select * from tts1 where {col} = 1h ") + tdSql.error(f" select * from tts1 where {col} < 1h ") + tdSql.error(f" select * from tts1 where {col} > 1h ") + tdSql.error(f" select * from tts1 where {col} >= 1h ") + tdSql.error(f" select * from tts1 where {col} <= 1h ") + tdSql.error(f" select * from tts1 where {col} <> 1h ") + + tdSql.error(f" select * from tts1 where {col} = 1w ") + tdSql.error(f" select * from tts1 where {col} < 1w ") + tdSql.error(f" select * from tts1 where {col} > 1w ") + tdSql.error(f" select * from tts1 where {col} >= 1w ") + tdSql.error(f" select * from tts1 where {col} <= 1w ") + tdSql.error(f" select * from tts1 where {col} <> 1w ") + + tdSql.error(f" select * from tts1 where {col} = 1u ") + tdSql.error(f" select * from tts1 where {col} < 1u ") + tdSql.error(f" select * from tts1 where {col} > 1u ") + tdSql.error(f" select * from tts1 where {col} >= 1u ") + tdSql.error(f" select * from tts1 where {col} <= 1u ") + tdSql.error(f" select * from tts1 where {col} <> 1u ") + + tdSql.error(f" select * from tts1 where {col} = 0d ") + tdSql.error(f" select * from tts1 where {col} < 0s ") + tdSql.error(f" select * from tts1 where {col} > 0a ") + tdSql.error(f" select * from tts1 where {col} >= 0m ") + tdSql.error(f" select * from tts1 where {col} <= 0h ") + tdSql.error(f" select * from tts1 where {col} <> 0u ") + tdSql.error(f" select * from tts1 where {col} <> 0w ") + + tdSql.error(f" select * from tts1 where {col} = 1m+1h ") + tdSql.error(f" select * from tts1 where {col} < 1w-1d ") + tdSql.error(f" select * from tts1 where {col} > 0a/1u ") + tdSql.error(f" select * from tts1 where {col} >= 1d/0s ") + tdSql.error(f" select * from tts1 where {col} <= 1s*1a ") + tdSql.error(f" select * from tts1 where {col} <> 0w/0d ") + + tdSql.error(f" select * from tts1 where {col} = 1m+1h ") + tdSql.error(f" select * from tts1 where {col} < 1w-1d ") + tdSql.error(f" select * from tts1 where {col} > 0a/1u ") + tdSql.error(f" select * from tts1 where {col} >= 1d/0s ") + tdSql.error(f" select * from tts1 where {col} <= 1s*1a ") + tdSql.error(f" select * from tts1 where {col} <> 0w/0d ") + + tdSql.error(f" select * from tts1 where {col} = 1u+1 ") + tdSql.error(f" select * from tts1 where {col} < 1a-1 ") + tdSql.error(f" select * from tts1 where {col} > 1s*1 ") + tdSql.error(f" select * from tts1 where {col} >= 1m/1 ") + tdSql.error(f" select * from tts1 where {col} <= 1h/0 ") + tdSql.error(f" select * from tts1 where {col} <> 0/1d ") + tdSql.error(f" select * from tts1 where {col} <> 1w+'2010-01-01 00:00:00' ") + + + def run(self): + tdSql.execute("drop database if exists dbms") + tdSql.execute("drop database if exists dbus") + + # timestamp list: + # 0 -> "1970-01-01 08:00:00" | -28800000 -> "1970-01-01 00:00:00" | -946800000000 -> "1940-01-01 00:00:00" + # -631180800000 -> "1950-01-01 00:00:00" + + tdLog.printNoPrefix("==========step1:create table precision ms && insert data && query") + # create databases precision is ms + tdSql.execute("create database if not exists dbms keep 36500") + tdSql.execute("use dbms") + tsp1 = 0 + tsp2 = -28800000 + tsp3 = -946800000000 + self.insertnow(tsp1,tsp2,tsp3) + self.querynow() + + tdLog.printNoPrefix("==========step2:create table precision us && insert data && query") + # create databases precision is us + tdSql.execute("create database if not exists dbus keep 36500 precision 'us' ") + tdSql.execute("use dbus") + tsp2 = -28800000 * 1000 + tsp3 = -946800000000 * 1000 + self.insertnow(tsp1,tsp2,tsp3) + self.querynow() + + + + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file From beb7f55f2953c3bdf085fc9519d12d3f15639d58 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 23 Apr 2021 10:56:50 +0800 Subject: [PATCH 23/23] [TD-3913]: mips compile support. (#5894) * [TD-3913]: mips compile support. * [TD-3912]: support mips64 compile. add mips64 header file and modify tcrc32c.c for mips64. Co-authored-by: Shuduo Sang --- cmake/define.inc | 11 +++--- src/os/inc/os.h | 4 ++ src/os/inc/osMips64.h | 87 ++++++++++++++++++++++++++++++++++++++++++ src/util/src/tcrc32c.c | 8 ++-- 4 files changed, 101 insertions(+), 9 deletions(-) create mode 100644 src/os/inc/osMips64.h diff --git a/cmake/define.inc b/cmake/define.inc index 6f49630d5c..e825dce024 100755 --- a/cmake/define.inc +++ b/cmake/define.inc @@ -69,7 +69,6 @@ IF (TD_LINUX_32) ENDIF () IF (TD_ARM_64) - ADD_DEFINITIONS(-D_M_X64) ADD_DEFINITIONS(-D_TD_ARM_64) ADD_DEFINITIONS(-D_TD_ARM_) ADD_DEFINITIONS(-DUSE_LIBICONV) @@ -86,17 +85,19 @@ IF (TD_ARM_32) ENDIF () IF (TD_MIPS_64) - ADD_DEFINITIONS(-D_TD_MIPS_64_) + ADD_DEFINITIONS(-D_TD_MIPS_) + ADD_DEFINITIONS(-D_TD_MIPS_64) ADD_DEFINITIONS(-DUSE_LIBICONV) MESSAGE(STATUS "mips64 is defined") - SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") + SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") ENDIF () IF (TD_MIPS_32) - ADD_DEFINITIONS(-D_TD_MIPS_32_) + ADD_DEFINITIONS(-D_TD_MIPS_) + ADD_DEFINITIONS(-D_TD_MIPS_32) ADD_DEFINITIONS(-DUSE_LIBICONV) MESSAGE(STATUS "mips32 is defined") - SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") + SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") ENDIF () IF (TD_APLHINE) diff --git a/src/os/inc/os.h b/src/os/inc/os.h index 8312b74a50..c3e02b14db 100644 --- a/src/os/inc/os.h +++ b/src/os/inc/os.h @@ -32,6 +32,10 @@ extern "C" { #include "osArm32.h" #endif +#ifdef _TD_MIPS_64 +#include "osMips64.h" +#endif + #ifdef _TD_LINUX_64 #include "osLinux64.h" #endif diff --git a/src/os/inc/osMips64.h b/src/os/inc/osMips64.h new file mode 100644 index 0000000000..ed7b08a311 --- /dev/null +++ b/src/os/inc/osMips64.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_OS_MIPS64_H +#define TDENGINE_OS_MIPS64_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/util/src/tcrc32c.c b/src/util/src/tcrc32c.c index 502116f9c2..054b8f8171 100644 --- a/src/util/src/tcrc32c.c +++ b/src/util/src/tcrc32c.c @@ -736,7 +736,7 @@ static uint32_t table[16][256] = { 0x9c221d09, 0x6e2e10f7, 0x7dd67004, 0x8fda7dfa} }; -#ifndef _TD_ARM_ +#if !defined(_TD_ARM_) && !defined(_TD_MIPS_) static uint32_t long_shifts[4][256] = { {0x00000000, 0xe040e0ac, 0xc56db7a9, 0x252d5705, 0x8f3719a3, 0x6f77f90f, 0x4a5aae0a, 0xaa1a4ea6, 0x1b8245b7, 0xfbc2a51b, 0xdeeff21e, 0x3eaf12b2, @@ -1187,7 +1187,7 @@ uint32_t crc32c_sf(uint32_t crci, crc_stream input, size_t length) { } return (uint32_t)crc ^ 0xffffffff; } -#ifndef _TD_ARM_ +#if !defined(_TD_ARM_) && !defined(_TD_MIPS_) /* Apply the zeros operator table to crc. */ static uint32_t shift_crc(uint32_t shift_table[][256], uint32_t crc) { return shift_table[0][crc & 0xff] ^ shift_table[1][(crc >> 8) & 0xff] ^ @@ -1198,7 +1198,7 @@ static uint32_t shift_crc(uint32_t shift_table[][256], uint32_t crc) { version. Otherwise, use the software version. */ uint32_t (*crc32c)(uint32_t crci, crc_stream bytes, size_t len) = crc32c_sf; -#ifndef _TD_ARM_ +#if !defined(_TD_ARM_) && !defined(_TD_MIPS_) /* Compute CRC-32C using the Intel hardware instruction. */ uint32_t crc32c_hw(uint32_t crc, crc_stream buf, size_t len) { crc_stream next = buf; @@ -1353,7 +1353,7 @@ uint32_t crc32c_hw(uint32_t crc, crc_stream buf, size_t len) { #endif // #ifndef _TD_ARM_ void taosResolveCRC() { -#if defined _TD_ARM_ || defined WINDOWS +#if defined _TD_ARM_ || defined _TD_MIPS_ || defined WINDOWS crc32c = crc32c_sf; #else int sse42;