From 5ed10d3a4c0014ae590e8437baced296b74db97e Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sun, 13 Sep 2020 21:18:55 +0000 Subject: [PATCH 01/77] suppport cmd show-create-table and show-create-db --- src/client/inc/tsclient.h | 1 + src/client/src/tscLocal.c | 580 +++++++++++++++++++++++++++++++-- src/client/src/tscSQLParser.c | 33 ++ src/client/src/tscSchemaUtil.c | 1 + src/client/src/tscServer.c | 7 + src/client/src/tscSql.c | 2 + src/client/src/tscSubquery.c | 1 + src/common/inc/tcmdtype.h | 3 + src/inc/taosmsg.h | 1 + src/inc/ttokendef.h | 198 +++++------ src/mnode/src/mnodeTable.c | 3 + src/query/inc/sql.y | 10 + 12 files changed, 716 insertions(+), 124 deletions(-) diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 5f4a46ddad..8bb146b1ad 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -98,6 +98,7 @@ typedef struct STableMeta { uint8_t tableType; int16_t sversion; int16_t tversion; + char sTableId[TSDB_TABLE_FNAME_LEN]; SCMVgroupInfo vgroupInfo; SCMCorVgroupInfo corVgroupInfo; STableId id; diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index b240d357a8..6d48350f73 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -24,7 +24,30 @@ #include "tscUtil.h" #include "tschemautil.h" #include "tsclient.h" +#include "taos.h" +#include "tscSubquery.h" +#define STR_NOCASE_EQUAL(str1, len1, str2, len2) ((len1 == len2) && 0 == strncasecmp(str1, str2, len1)) + +typedef enum BuildType { + SCREATE_BUILD_TABLE = 1, + SCREATE_BUILD_DB = 2, +} BuildType; + +typedef enum Stage { + SCREATE_CALLBACK_QUERY = 1, + SCREATE_CALLBACK_RETRIEVE = 2, +} Stage; + +// support 'show create table' +typedef struct SCreateBuilder { + char sTableName[TSDB_TABLE_FNAME_LEN]; + char buf[TSDB_TABLE_FNAME_LEN]; + SSqlObj *pParentSql; + SSqlObj *pInterSql; + int32_t (*fp)(void *para, char* result); + Stage callStage; +} SCreateBuilder; static void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnName, int16_t type, size_t valueLength); static int32_t getToStringLength(const char *pData, int32_t length, int32_t type) { @@ -273,14 +296,512 @@ static int32_t tscProcessDescribeTable(SSqlObj *pSql) { tscFieldInfoUpdateOffset(pQueryInfo); return tscSetValueToResObj(pSql, rowLen); } +static int32_t tscGetNthFieldResult(TAOS_ROW row, TAOS_FIELD* fields, int *lengths, int idx, char *result) { + const char *val = row[idx]; + if (val == NULL) { + sprintf(result, "%s", TSDB_DATA_NULL_STR); + return -1; + } + uint8_t type = fields[idx].type; + int32_t length = lengths[idx]; + switch (type) { + case TSDB_DATA_TYPE_BOOL: + sprintf(result, "%s", ((((int)(*((char *)val))) == 1) ? "true" : "false")); + break; + case TSDB_DATA_TYPE_TINYINT: + sprintf(result, "%d", (int)(*((char *)val))); + break; + case TSDB_DATA_TYPE_SMALLINT: + sprintf(result, "%d", (int)(*((short *)val))); + break; + case TSDB_DATA_TYPE_INT: + sprintf(result, "%d", *((int *)val)); + break; + case TSDB_DATA_TYPE_BIGINT: + sprintf(result, "%"PRId64, *((int64_t *)val)); + break; + case TSDB_DATA_TYPE_FLOAT: + sprintf(result, "%f", GET_FLOAT_VAL(val)); + break; + case TSDB_DATA_TYPE_DOUBLE: + sprintf(result, "%f", GET_DOUBLE_VAL(val)); + break; + case TSDB_DATA_TYPE_NCHAR: + case TSDB_DATA_TYPE_BINARY: + memcpy(result, val, length); + break; + case TSDB_DATA_TYPE_TIMESTAMP: + ///formatTimestamp(buf, *(int64_t*)val, TSDB_TIME_PRECISION_MICRO); + //memcpy(result, val, strlen(buf)); + sprintf(result, "%"PRId64, *((int64_t *)val)); + break; + default: + break; + } + return 0; +} + +void tscSCreateCallBack(void *param, TAOS_RES *tres, int code) { + if (param == NULL || tres == NULL) { + return; + } + SCreateBuilder *builder = (SCreateBuilder *)(param); + SSqlObj *pParentSql = builder->pParentSql; + SSqlObj *pSql = (SSqlObj *)tres; + + SSqlRes *pRes = &pParentSql->res; + pRes->code = taos_errno(pSql); + if (pRes->code != TSDB_CODE_SUCCESS) { + taos_free_result(pSql); + free(builder); + tscQueueAsyncRes(pParentSql); + return; + } + + if (builder->callStage == SCREATE_CALLBACK_QUERY) { + taos_fetch_rows_a(tres, tscSCreateCallBack, param); + builder->callStage = SCREATE_CALLBACK_RETRIEVE; + } else { + char *result = calloc(1, TSDB_MAX_BINARY_LEN); + pRes->code = builder->fp(builder, result); + + taos_free_result(pSql); + free(builder); + free(result); + + if (pRes->code == TSDB_CODE_SUCCESS) { + (*pParentSql->fp)(pParentSql->param, pParentSql, code); + } else { + tscQueueAsyncRes(pParentSql); + } + } +} + +TAOS_ROW tscFetchRow(void *param) { + SCreateBuilder *builder = (SCreateBuilder *)param; + if (builder == NULL) { + return NULL; + } + SSqlObj *pSql = builder->pInterSql; + if (pSql == NULL || pSql->signature != pSql) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return NULL; + } + + SSqlCmd *pCmd = &pSql->cmd; + SSqlRes *pRes = &pSql->res; + + if (pRes->qhandle == 0 || + pCmd->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT || + pCmd->command == TSDB_SQL_INSERT) { + return NULL; + } + + // set the sql object owner + tscSetSqlOwner(pSql); + + // current data set are exhausted, fetch more data from node + if (pRes->row >= pRes->numOfRows && (pRes->completed != true || hasMoreVnodesToTry(pSql) || hasMoreClauseToTry(pSql)) && + (pCmd->command == TSDB_SQL_RETRIEVE || + pCmd->command == TSDB_SQL_RETRIEVE_LOCALMERGE || + pCmd->command == TSDB_SQL_TABLE_JOIN_RETRIEVE || + pCmd->command == TSDB_SQL_FETCH || + pCmd->command == TSDB_SQL_SHOW || + pCmd->command == TSDB_SQL_SHOW_CREATE_TABLE || + pCmd->command == TSDB_SQL_SHOW_CREATE_DATABASE || + pCmd->command == TSDB_SQL_SELECT || + pCmd->command == TSDB_SQL_DESCRIBE_TABLE || + pCmd->command == TSDB_SQL_SERV_STATUS || + pCmd->command == TSDB_SQL_CURRENT_DB || + pCmd->command == TSDB_SQL_SERV_VERSION || + pCmd->command == TSDB_SQL_CLI_VERSION || + pCmd->command == TSDB_SQL_CURRENT_USER )) { + taos_fetch_rows_a(pSql, tscSCreateCallBack, param); + return NULL; + } + + void* data = doSetResultRowData(pSql, true); + + tscClearSqlOwner(pSql); + return data; +} +static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) { + TAOS_ROW row = tscFetchRow(builder); + SSqlObj* pSql = builder->pInterSql; + + if (row == NULL) { + return TSDB_CODE_MND_INVALID_TABLE_NAME; + } + + int32_t* lengths = taos_fetch_lengths(pSql); + int num_fields = taos_num_fields(pSql); + TAOS_FIELD *fields = taos_fetch_fields(pSql); + + char buf[TSDB_COL_NAME_LEN + 16]; + for (int i = 0; i < num_fields; i++) { + memset(buf, 0, sizeof(buf)); + int32_t ret = tscGetNthFieldResult(row, fields, lengths, i, buf); + + if (i == 0) { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s", "("); + } + if ((fields[i].type == TSDB_DATA_TYPE_NCHAR + || fields[i].type == TSDB_DATA_TYPE_BINARY + || fields[i].type == TSDB_DATA_TYPE_TIMESTAMP) && 0 == ret) { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "\"%s\",", buf); + } else { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s,", buf); + } + if (i == num_fields - 1) { + sprintf(result + strlen(result) - 1, "%s", ")"); + } + } + + if (0 == strlen(result)) { + return TSDB_CODE_MND_INVALID_TABLE_NAME; + } + return TSDB_CODE_SUCCESS; +} + + +// build 'show create table/database' result fields +static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const char *ddl) { + int32_t rowLen = 0; + int16_t ddlLen = strlen(ddl); + SColumnIndex index = {0}; + pSql->cmd.numOfCols = 2; + + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + pQueryInfo->order.order = TSDB_ORDER_ASC; + + TAOS_FIELD f; + if (type == SCREATE_BUILD_TABLE) { + f.type = TSDB_DATA_TYPE_BINARY; + f.bytes = (TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE; + tstrncpy(f.name, "Table", sizeof(f.name)); + } else { + f.type = TSDB_DATA_TYPE_BINARY; + f.bytes = (TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE; + tstrncpy(f.name, "Database", sizeof(f.name)); + } + + SFieldSupInfo* pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); + pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, + f.bytes, f.bytes - VARSTR_HEADER_SIZE, false); + + rowLen += f.bytes; + + f.bytes = (int16_t)(ddlLen + VARSTR_HEADER_SIZE); + f.type = TSDB_DATA_TYPE_BINARY; + if (type == SCREATE_BUILD_TABLE) { + tstrncpy(f.name, "Create Table", sizeof(f.name)); + } else { + tstrncpy(f.name, "Create Database", sizeof(f.name)); + } + + pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); + pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, + (int16_t)(ddlLen + VARSTR_HEADER_SIZE), ddlLen, false); + + rowLen += ddlLen + VARSTR_HEADER_SIZE; + + return rowLen; +} +static int32_t tscSCreateSetValueToResObj(SSqlObj *pSql, int32_t rowLen, const char *tableName, const char *ddl) { + SSqlRes *pRes = &pSql->res; + + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + int32_t numOfRows = 1; + if (strlen(ddl) == 0) { + + } + tscInitResObjForLocalQuery(pSql, numOfRows, rowLen); + + TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 0); + char* dst = pRes->data + tscFieldInfoGetOffset(pQueryInfo, 0) * numOfRows; + STR_WITH_MAXSIZE_TO_VARSTR(dst, tableName, pField->bytes); + + pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 1); + dst = pRes->data + tscFieldInfoGetOffset(pQueryInfo, 1) * numOfRows; + STR_WITH_MAXSIZE_TO_VARSTR(dst, ddl, pField->bytes); + return 0; +} +static int32_t tscSCreateBuildResult(SSqlObj *pSql, BuildType type, const char *str, const char *result) { + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + int32_t rowLen = tscSCreateBuildResultFields(pSql, type, result); + + tscFieldInfoUpdateOffset(pQueryInfo); + return tscSCreateSetValueToResObj(pSql, rowLen, str, result); +} +int32_t tscRebuildCreateTableStatement(void *param,char *result) { + SCreateBuilder *builder = (SCreateBuilder *)param; + int32_t code = TSDB_CODE_SUCCESS; + + char *buf = calloc(1,TSDB_MAX_BINARY_LEN); + if (buf == NULL) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + code = tscGetTableTagValue(builder, buf); + if (code == TSDB_CODE_SUCCESS) { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "CREATE TABLE %s USING %s TAGS %s", builder->buf, builder->sTableName, buf); + code = tscSCreateBuildResult(builder->pParentSql, SCREATE_BUILD_TABLE, builder->buf, result); + } + free(buf); + return code; +} + +static int32_t tscGetDBInfo(SCreateBuilder *builder, char *result) { + TAOS_ROW row = tscFetchRow(builder); + if (row == NULL) { + return TSDB_CODE_MND_DB_NOT_SELECTED; + } + const char *showColumns[] = {"REPLICA", "QUORUM", "DAYS", "KEEP", "BLOCKS", NULL}; + + SSqlObj *pSql = builder->pInterSql; + TAOS_FIELD *fields = taos_fetch_fields(pSql); + int num_fields = taos_num_fields(pSql); + + char buf[TSDB_DB_NAME_LEN + 64] = {0}; + do { + int32_t* lengths = taos_fetch_lengths(pSql); + int32_t ret = tscGetNthFieldResult(row, fields, lengths, 0, buf); + if (0 == ret && STR_NOCASE_EQUAL(buf, strlen(buf), builder->buf, strlen(builder->buf))) { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "CREATE DATABASE %s", buf); + for (int i = 1; i < num_fields; i++) { + for (int j = 0; showColumns[j] != NULL; j++) { + if (STR_NOCASE_EQUAL(fields[i].name, strlen(fields[i].name), showColumns[j], strlen(showColumns[j]))) { + memset(buf, 0, sizeof(buf)); + ret = tscGetNthFieldResult(row, fields, lengths, i, buf); + if (ret == 0) { + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), " %s %s", showColumns[j], buf); + } + } + } + } + break; + } + + row = tscFetchRow(builder); + } while (row != NULL); + + if (0 == strlen(result)) { + return TSDB_CODE_MND_DB_NOT_SELECTED; + } + + return TSDB_CODE_SUCCESS; +} +int32_t tscRebuildCreateDBStatement(void *param,char *result) { + SCreateBuilder *builder = (SCreateBuilder *)param; + int32_t code = TSDB_CODE_SUCCESS; + + char *buf = calloc(1, TSDB_MAX_BINARY_LEN); + if (buf == NULL) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + code = tscGetDBInfo(param, buf); + if (code == TSDB_CODE_SUCCESS) { + code = tscSCreateBuildResult(builder->pParentSql, SCREATE_BUILD_DB, builder->buf, buf); + } + free(buf); + return code; +} + +static int32_t tscGetTableTagColumnName(SSqlObj *pSql, char **result) { + char *buf = (char *)malloc(TSDB_MAX_BINARY_LEN); + if (buf == NULL) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + buf[0] = 0; + + STableMeta *pMeta = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0)->pTableMeta; + if (pMeta->tableType == TSDB_SUPER_TABLE || pMeta->tableType == TSDB_NORMAL_TABLE || + pMeta->tableType == TSDB_STREAM_TABLE) { + free(buf); + return TSDB_CODE_TSC_INVALID_VALUE; + } + + SSchema *pTagsSchema = tscGetTableTagSchema(pMeta); + int32_t numOfTags = tscGetNumOfTags(pMeta); + for (int32_t i = 0; i < numOfTags; i++) { + if (i != numOfTags - 1) { + snprintf(buf + strlen(buf), TSDB_MAX_BINARY_LEN - strlen(buf), "%s,", pTagsSchema[i].name); + } else { + snprintf(buf + strlen(buf), TSDB_MAX_BINARY_LEN - strlen(buf), "%s", pTagsSchema[i].name); + } + } + + *result = buf; + return TSDB_CODE_SUCCESS; +} +static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, char *ddl) { + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + + STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + STableMeta * pMeta = pTableMetaInfo->pTableMeta; + + SSqlObj *pInterSql = (SSqlObj *)calloc(1, sizeof(SSqlObj)); + if (pInterSql == NULL) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + SCreateBuilder *param = (SCreateBuilder *)malloc(sizeof(SCreateBuilder)); + if (param == NULL) { + free(pInterSql); + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + char fullName[TSDB_TABLE_FNAME_LEN] = {0}; + extractDBName(pTableMetaInfo->name, fullName); + extractTableName(pMeta->sTableId, param->sTableName); + snprintf(fullName + strlen(fullName), TSDB_TABLE_FNAME_LEN - strlen(fullName), ".%s", param->sTableName); + extractTableName(pTableMetaInfo->name, param->buf); + + //tstrncpy(param->tableName, pTableMetaInfo->name, TSDB_TABLE_FNAME_LEN); + param->pParentSql = pSql; + param->pInterSql = pInterSql; + param->fp = tscRebuildCreateTableStatement; + param->callStage = SCREATE_CALLBACK_QUERY; + + char *query = (char *)calloc(1, TSDB_MAX_BINARY_LEN); + if (query == NULL) { + free(param); + free(pInterSql); + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + char *columns = NULL; + int32_t code = tscGetTableTagColumnName(pSql, &columns) ; + if (code != TSDB_CODE_SUCCESS) { + free(param); + free(pInterSql); + return code; + } + + snprintf(query + strlen(query), TSDB_MAX_BINARY_LEN - strlen(query), "SELECT %s FROM %s WHERE TBNAME IN(\'%s\')", columns, fullName, param->buf); + doAsyncQuery(pSql->pTscObj, pInterSql, tscSCreateCallBack, param, query, strlen(query)); + free(query); + free(columns); + + return TSDB_CODE_TSC_ACTION_IN_PROGRESS; +} +static int32_t tscRebuildDDLForNormalTable(SSqlObj *pSql, const char *tableName, char *ddl) { + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + STableMeta * pMeta = pTableMetaInfo->pTableMeta; + + int32_t numOfRows = tscGetNumOfColumns(pMeta); + SSchema *pSchema = tscGetTableSchema(pMeta); + + char *result = ddl; + sprintf(result, "create table %s (", tableName); + for (int32_t i = 0; i < numOfRows; ++i) { + uint8_t type = pSchema[i].type; + if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { + sprintf(result + strlen(result), "%s %s(%d),", pSchema[i].name,tDataTypeDesc[pSchema[i].type].aName,pSchema->bytes); + } else { + sprintf(result + strlen(result), "%s %s,", pSchema[i].name, tDataTypeDesc[pSchema[i].type].aName); + } + } + sprintf(result + strlen(result) - 1, "%s", ")"); + + return TSDB_CODE_SUCCESS; +} +static int32_t tscRebuildDDLForSuperTable(SSqlObj *pSql, const char *tableName, char *ddl) { + char *result = ddl; + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + STableMeta * pMeta = pTableMetaInfo->pTableMeta; + + int32_t numOfRows = tscGetNumOfColumns(pMeta); + int32_t totalRows = numOfRows + tscGetNumOfTags(pMeta); + SSchema *pSchema = tscGetTableSchema(pMeta); + + sprintf(result, "create table %s (", tableName); + for (int32_t i = 0; i < numOfRows; ++i) { + uint8_t type = pSchema[i].type; + if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { + sprintf(result + strlen(result), "%s %s(%d),", pSchema[i].name,tDataTypeDesc[pSchema[i].type].aName,pSchema->bytes); + } else { + sprintf(result + strlen(result), "%s %s,", pSchema[i].name, tDataTypeDesc[type].aName); + } + } + sprintf(result + strlen(result) - 1, "%s ", ")"); + + sprintf(result + strlen(result), "TAGS ("); + for (int32_t i = numOfRows; i < totalRows; i++) { + uint8_t type = pSchema[i].type; + if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { + sprintf(result + strlen(result), "%s %s(%d),", pSchema[i].name,tDataTypeDesc[pSchema[i].type].aName,pSchema->bytes); + } else { + sprintf(result + strlen(result), "%s %s,", pSchema[i].name, tDataTypeDesc[type].aName); + } + + } + sprintf(result + strlen(result) - 1, "%s", ")"); + + return TSDB_CODE_SUCCESS; +} + +static int32_t tscProcessShowCreateTable(SSqlObj *pSql) { + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + assert(pTableMetaInfo->pTableMeta != NULL); + + char tableName[TSDB_TABLE_NAME_LEN] = {0}; + extractTableName(pTableMetaInfo->name, tableName); + + char result[TSDB_MAX_BYTES_PER_ROW] = {0}; + int32_t code = TSDB_CODE_SUCCESS; + if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { + code = tscRebuildDDLForSuperTable(pSql, tableName, result); + } else if (UTIL_TABLE_IS_NORMAL_TABLE(pTableMetaInfo)) { + code = tscRebuildDDLForNormalTable(pSql, tableName, result); + } else if (UTIL_TABLE_IS_CHILD_TABLE(pTableMetaInfo)) { + code = tscRebuildDDLForSubTable(pSql, tableName, result); + } else { + code = TSDB_CODE_TSC_INVALID_VALUE; + } + + if (code != TSDB_CODE_SUCCESS) { + return code; + } + return tscSCreateBuildResult(pSql, SCREATE_BUILD_TABLE, tableName, result); +} + +static int32_t tscProcessShowCreateDatabase(SSqlObj *pSql) { + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + + STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + + SSqlObj *pInterSql = (SSqlObj *)calloc(1, sizeof(SSqlObj)); + if (pInterSql == NULL) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + SCreateBuilder *param = (SCreateBuilder *)malloc(sizeof(SCreateBuilder)); + if (param == NULL) { + free(pInterSql); + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + extractTableName(pTableMetaInfo->name, param->buf); + param->pParentSql = pSql; + param->pInterSql = pInterSql; + param->fp = tscRebuildCreateDBStatement; + param->callStage = SCREATE_CALLBACK_QUERY; + + const char *query = "show databases"; + doAsyncQuery(pSql->pTscObj, pInterSql, tscSCreateCallBack, param, query, strlen(query)); + return TSDB_CODE_TSC_ACTION_IN_PROGRESS; +} static int32_t tscProcessCurrentUser(SSqlObj *pSql) { SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); - + SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, 0); pExpr->resBytes = TSDB_USER_LEN + TSDB_DATA_TYPE_BINARY; pExpr->resType = TSDB_DATA_TYPE_BINARY; - + char* vx = calloc(1, pExpr->resBytes); if (vx == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; @@ -288,7 +809,7 @@ static int32_t tscProcessCurrentUser(SSqlObj *pSql) { size_t size = sizeof(pSql->pTscObj->user); STR_WITH_MAXSIZE_TO_VARSTR(vx, pSql->pTscObj->user, size); - + tscSetLocalQueryResult(pSql, vx, pExpr->aliasName, pExpr->resType, pExpr->resBytes); free(vx); @@ -298,15 +819,15 @@ static int32_t tscProcessCurrentUser(SSqlObj *pSql) { static int32_t tscProcessCurrentDB(SSqlObj *pSql) { char db[TSDB_DB_NAME_LEN] = {0}; extractDBName(pSql->pTscObj->db, db); - + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, pSql->cmd.clauseIndex); - + SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, 0); pExpr->resType = TSDB_DATA_TYPE_BINARY; - + size_t t = strlen(db); pExpr->resBytes = TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE; - + char* vx = calloc(1, pExpr->resBytes); if (vx == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; @@ -317,7 +838,7 @@ static int32_t tscProcessCurrentDB(SSqlObj *pSql) { } else { STR_WITH_SIZE_TO_VARSTR(vx, db, (VarDataLenT)t); } - + tscSetLocalQueryResult(pSql, vx, pExpr->aliasName, pExpr->resType, pExpr->resBytes); free(vx); @@ -327,49 +848,53 @@ static int32_t tscProcessCurrentDB(SSqlObj *pSql) { static int32_t tscProcessServerVer(SSqlObj *pSql) { const char* v = pSql->pTscObj->sversion; SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, pSql->cmd.clauseIndex); - + SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, 0); pExpr->resType = TSDB_DATA_TYPE_BINARY; - + size_t t = strlen(v); pExpr->resBytes = (int16_t)(t + VARSTR_HEADER_SIZE); - + char* vx = calloc(1, pExpr->resBytes); if (vx == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; + } STR_WITH_SIZE_TO_VARSTR(vx, v, (VarDataLenT)t); tscSetLocalQueryResult(pSql, vx, pExpr->aliasName, pExpr->resType, pExpr->resBytes); - + free(vx); return TSDB_CODE_SUCCESS; + } static int32_t tscProcessClientVer(SSqlObj *pSql) { SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); - + SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, 0); pExpr->resType = TSDB_DATA_TYPE_BINARY; - + size_t t = strlen(version); pExpr->resBytes = (int16_t)(t + VARSTR_HEADER_SIZE); - + char* v = calloc(1, pExpr->resBytes); if (v == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; + } STR_WITH_SIZE_TO_VARSTR(v, version, (VarDataLenT)t); tscSetLocalQueryResult(pSql, v, pExpr->aliasName, pExpr->resType, pExpr->resBytes); - + free(v); return TSDB_CODE_SUCCESS; + } static int32_t tscProcessServStatus(SSqlObj *pSql) { STscObj* pObj = pSql->pTscObj; - + if (pObj->pHb != NULL) { if (pObj->pHb->res.code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { pSql->res.code = TSDB_CODE_RPC_NETWORK_UNAVAIL; @@ -380,9 +905,9 @@ static int32_t tscProcessServStatus(SSqlObj *pSql) { return pSql->res.code; } } - + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); - + SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, 0); int32_t val = 1; tscSetLocalQueryResult(pSql, (char*) &val, pExpr->aliasName, TSDB_DATA_TYPE_INT, sizeof(int32_t)); @@ -394,23 +919,23 @@ void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnNa SSqlRes *pRes = &pSql->res; pCmd->numOfCols = 1; - + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); pQueryInfo->order.order = TSDB_ORDER_ASC; - + tscFieldInfoClear(&pQueryInfo->fieldsInfo); pQueryInfo->fieldsInfo.pFields = taosArrayInit(1, sizeof(TAOS_FIELD)); pQueryInfo->fieldsInfo.pSupportInfo = taosArrayInit(1, sizeof(SFieldSupInfo)); - + TAOS_FIELD f = tscCreateField((int8_t)type, columnName, (int16_t)valueLength); tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f); - + tscInitResObjForLocalQuery(pSql, 1, (int32_t)valueLength); TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 0); SFieldSupInfo* pInfo = tscFieldInfoGetSupp(&pQueryInfo->fieldsInfo, 0); pInfo->pSqlExpr = taosArrayGetP(pQueryInfo->exprList, 0); - + memcpy(pRes->data, val, pField->bytes); } @@ -429,6 +954,10 @@ int tscProcessLocalCmd(SSqlObj *pSql) { */ pRes->qhandle = 0x1; pRes->numOfRows = 0; + } else if (pCmd->command == TSDB_SQL_SHOW_CREATE_TABLE) { + pRes->code = tscProcessShowCreateTable(pSql); + } else if (pCmd->command == TSDB_SQL_SHOW_CREATE_DATABASE) { + pRes->code = tscProcessShowCreateDatabase(pSql); } else if (pCmd->command == TSDB_SQL_RESET_CACHE) { taosCacheEmpty(tscCacheHandle); pRes->code = TSDB_CODE_SUCCESS; @@ -448,12 +977,13 @@ int tscProcessLocalCmd(SSqlObj *pSql) { } // keep the code in local variable in order to avoid invalid read in case of async query + int32_t code = pRes->code; if (code == TSDB_CODE_SUCCESS) { (*pSql->fp)(pSql->param, pSql, code); + } else if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS){ } else { tscQueueAsyncRes(pSql); } - return code; } diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index c248b08ddd..631ee4acc1 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -366,7 +366,40 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { return tscGetTableMeta(pSql, pTableMetaInfo); } + case TSDB_SQL_SHOW_CREATE_TABLE: { + SStrToken* pToken = &pInfo->pDCLInfo->a[0]; + const char* msg1 = "invalid table name"; + const char* msg2 = "table name is too long"; + if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); + } + + if (!tscValidateTableNameLength(pToken->n)) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); + } + + if (tscSetTableFullName(pTableMetaInfo, pToken, pSql) != TSDB_CODE_SUCCESS) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); + } + return tscGetTableMeta(pSql, pTableMetaInfo); + } + case TSDB_SQL_SHOW_CREATE_DATABASE: { + const char* msg1 = "invalid database name"; + const char* msg2 = "table name is too long"; + SStrToken* pToken = &pInfo->pDCLInfo->a[0]; + + if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); + } + if (pToken->n > TSDB_DB_NAME_LEN) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); + } + if (tscSetTableFullName(pTableMetaInfo, pToken, pSql) != TSDB_CODE_SUCCESS) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); + } + return TSDB_CODE_SUCCESS; + } case TSDB_SQL_CFG_DNODE: { const char* msg2 = "invalid configure options or values, such as resetlog / debugFlag 135 / balance 'vnode:2-dnode:2' / monitor 1 "; const char* msg3 = "invalid dnode ep"; diff --git a/src/client/src/tscSchemaUtil.c b/src/client/src/tscSchemaUtil.c index 244bb81164..1e841c68fd 100644 --- a/src/client/src/tscSchemaUtil.c +++ b/src/client/src/tscSchemaUtil.c @@ -170,6 +170,7 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size pTableMeta->sversion = pTableMetaMsg->sversion; pTableMeta->tversion = pTableMetaMsg->tversion; + tstrncpy(pTableMeta->sTableId, pTableMetaMsg->sTableId, TSDB_TABLE_FNAME_LEN); memcpy(pTableMeta->schema, pTableMetaMsg->schema, schemaSize); diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index ae2013cd2b..9c8b94cc2d 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -2072,6 +2072,9 @@ int tscProcessAlterDbMsgRsp(SSqlObj *pSql) { UNUSED(pSql); return 0; } +int tscProcessShowCreateRsp(SSqlObj *pSql) { + return tscLocalResultCommonBuilder(pSql, 1); +} int tscProcessQueryRsp(SSqlObj *pSql) { SSqlRes *pRes = &pSql->res; @@ -2343,6 +2346,10 @@ void tscInitMsgsFp() { tscProcessMsgRsp[TSDB_SQL_ALTER_TABLE] = tscProcessAlterTableMsgRsp; tscProcessMsgRsp[TSDB_SQL_ALTER_DB] = tscProcessAlterDbMsgRsp; + tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_TABLE] = tscProcessShowCreateRsp; + tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_DATABASE] = tscProcessShowCreateRsp; + + tscKeepConn[TSDB_SQL_SHOW] = 1; tscKeepConn[TSDB_SQL_RETRIEVE] = 1; tscKeepConn[TSDB_SQL_SELECT] = 1; diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 9fa4db999f..24768c243b 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -451,6 +451,8 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) { pCmd->command == TSDB_SQL_TABLE_JOIN_RETRIEVE || pCmd->command == TSDB_SQL_FETCH || pCmd->command == TSDB_SQL_SHOW || + pCmd->command == TSDB_SQL_SHOW_CREATE_TABLE || + pCmd->command == TSDB_SQL_SHOW_CREATE_DATABASE || pCmd->command == TSDB_SQL_SELECT || pCmd->command == TSDB_SQL_DESCRIBE_TABLE || pCmd->command == TSDB_SQL_SERV_STATUS || diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index e264fa9b33..abfe8b8813 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -23,6 +23,7 @@ #include "tscSubquery.h" #include "tschemautil.h" #include "tsclient.h" +#include "tscSubquery.h" typedef struct SInsertSupporter { SSubqueryState* pState; diff --git a/src/common/inc/tcmdtype.h b/src/common/inc/tcmdtype.h index 90fb5bf478..69bbccd67e 100644 --- a/src/common/inc/tcmdtype.h +++ b/src/common/inc/tcmdtype.h @@ -78,6 +78,9 @@ enum { TSDB_DEFINE_SQL_TYPE( TSDB_SQL_RETRIEVE_LOCALMERGE, "retrieve-localmerge" ) TSDB_DEFINE_SQL_TYPE( TSDB_SQL_TABLE_JOIN_RETRIEVE, "join-retrieve" ) + TSDB_DEFINE_SQL_TYPE( TSDB_SQL_SHOW_CREATE_TABLE, "show-create-table") + TSDB_DEFINE_SQL_TYPE( TSDB_SQL_SHOW_CREATE_DATABASE, "show-create-database") + /* * build empty result instead of accessing dnode to fetch result * reset the client cache diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index e2df886320..f33d26c53b 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -677,6 +677,7 @@ typedef struct { typedef struct STableMetaMsg { int32_t contLen; char tableId[TSDB_TABLE_FNAME_LEN]; // table id + char sTableId[TSDB_TABLE_FNAME_LEN]; uint8_t numOfTags; uint8_t precision; uint8_t tableType; diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h index c5831a9b8a..bc49d3c81b 100644 --- a/src/inc/ttokendef.h +++ b/src/inc/ttokendef.h @@ -16,105 +16,105 @@ #ifndef TDENGINE_TTOKENDEF_H #define TDENGINE_TTOKENDEF_H -#define TK_ID 1 -#define TK_BOOL 2 -#define TK_TINYINT 3 -#define TK_SMALLINT 4 -#define TK_INTEGER 5 -#define TK_BIGINT 6 -#define TK_FLOAT 7 -#define TK_DOUBLE 8 -#define TK_STRING 9 -#define TK_TIMESTAMP 10 -#define TK_BINARY 11 -#define TK_NCHAR 12 -#define TK_OR 13 -#define TK_AND 14 -#define TK_NOT 15 -#define TK_EQ 16 -#define TK_NE 17 -#define TK_ISNULL 18 -#define TK_NOTNULL 19 -#define TK_IS 20 -#define TK_LIKE 21 -#define TK_GLOB 22 -#define TK_BETWEEN 23 -#define TK_IN 24 -#define TK_GT 25 -#define TK_GE 26 -#define TK_LT 27 -#define TK_LE 28 -#define TK_BITAND 29 -#define TK_BITOR 30 -#define TK_LSHIFT 31 -#define TK_RSHIFT 32 -#define TK_PLUS 33 -#define TK_MINUS 34 -#define TK_DIVIDE 35 -#define TK_TIMES 36 -#define TK_STAR 37 -#define TK_SLASH 38 -#define TK_REM 39 -#define TK_CONCAT 40 -#define TK_UMINUS 41 -#define TK_UPLUS 42 -#define TK_BITNOT 43 -#define TK_SHOW 44 -#define TK_DATABASES 45 -#define TK_MNODES 46 -#define TK_DNODES 47 -#define TK_ACCOUNTS 48 -#define TK_USERS 49 -#define TK_MODULES 50 -#define TK_QUERIES 51 -#define TK_CONNECTIONS 52 -#define TK_STREAMS 53 -#define TK_VARIABLES 54 -#define TK_SCORES 55 -#define TK_GRANTS 56 -#define TK_VNODES 57 -#define TK_IPTOKEN 58 -#define TK_DOT 59 -#define TK_TABLES 60 -#define TK_STABLES 61 -#define TK_VGROUPS 62 -#define TK_DROP 63 -#define TK_TABLE 64 -#define TK_DATABASE 65 -#define TK_DNODE 66 -#define TK_USER 67 -#define TK_ACCOUNT 68 -#define TK_USE 69 -#define TK_DESCRIBE 70 -#define TK_ALTER 71 -#define TK_PASS 72 -#define TK_PRIVILEGE 73 -#define TK_LOCAL 74 -#define TK_IF 75 -#define TK_EXISTS 76 -#define TK_CREATE 77 -#define TK_PPS 78 -#define TK_TSERIES 79 -#define TK_DBS 80 -#define TK_STORAGE 81 -#define TK_QTIME 82 -#define TK_CONNS 83 -#define TK_STATE 84 -#define TK_KEEP 85 -#define TK_CACHE 86 -#define TK_REPLICA 87 -#define TK_QUORUM 88 -#define TK_DAYS 89 -#define TK_MINROWS 90 -#define TK_MAXROWS 91 -#define TK_BLOCKS 92 -#define TK_CTIME 93 -#define TK_WAL 94 -#define TK_FSYNC 95 -#define TK_COMP 96 -#define TK_PRECISION 97 -#define TK_LP 98 -#define TK_RP 99 +#define TK_ID 1 +#define TK_BOOL 2 +#define TK_TINYINT 3 +#define TK_SMALLINT 4 +#define TK_INTEGER 5 +#define TK_BIGINT 6 +#define TK_FLOAT 7 +#define TK_DOUBLE 8 +#define TK_STRING 9 +#define TK_TIMESTAMP 10 +#define TK_BINARY 11 +#define TK_NCHAR 12 +#define TK_OR 13 +#define TK_AND 14 +#define TK_NOT 15 +#define TK_EQ 16 +#define TK_NE 17 +#define TK_ISNULL 18 +#define TK_NOTNULL 19 +#define TK_IS 20 +#define TK_LIKE 21 +#define TK_GLOB 22 +#define TK_BETWEEN 23 +#define TK_IN 24 +#define TK_GT 25 +#define TK_GE 26 +#define TK_LT 27 +#define TK_LE 28 +#define TK_BITAND 29 +#define TK_BITOR 30 +#define TK_LSHIFT 31 +#define TK_RSHIFT 32 +#define TK_PLUS 33 +#define TK_MINUS 34 +#define TK_DIVIDE 35 +#define TK_TIMES 36 +#define TK_STAR 37 +#define TK_SLASH 38 +#define TK_REM 39 +#define TK_CONCAT 40 +#define TK_UMINUS 41 +#define TK_UPLUS 42 +#define TK_BITNOT 43 +#define TK_SHOW 44 +#define TK_DATABASES 45 +#define TK_MNODES 46 +#define TK_DNODES 47 +#define TK_ACCOUNTS 48 +#define TK_USERS 49 +#define TK_MODULES 50 +#define TK_QUERIES 51 +#define TK_CONNECTIONS 52 +#define TK_STREAMS 53 +#define TK_VARIABLES 54 +#define TK_SCORES 55 +#define TK_GRANTS 56 +#define TK_VNODES 57 +#define TK_IPTOKEN 58 +#define TK_DOT 59 +#define TK_CREATE 60 +#define TK_TABLE 61 +#define TK_DATABASE 62 +#define TK_TABLES 63 +#define TK_STABLES 64 +#define TK_VGROUPS 65 +#define TK_DROP 66 +#define TK_DNODE 67 +#define TK_USER 68 +#define TK_ACCOUNT 69 +#define TK_USE 70 +#define TK_DESCRIBE 71 +#define TK_ALTER 72 +#define TK_PASS 73 +#define TK_PRIVILEGE 74 +#define TK_LOCAL 75 +#define TK_IF 76 +#define TK_EXISTS 77 +#define TK_PPS 78 +#define TK_TSERIES 79 +#define TK_DBS 80 +#define TK_STORAGE 81 +#define TK_QTIME 82 +#define TK_CONNS 83 +#define TK_STATE 84 +#define TK_KEEP 85 +#define TK_CACHE 86 +#define TK_REPLICA 87 +#define TK_QUORUM 88 +#define TK_DAYS 89 +#define TK_MINROWS 90 +#define TK_MAXROWS 91 +#define TK_BLOCKS 92 +#define TK_CTIME 93 +#define TK_WAL 94 +#define TK_FSYNC 95 +#define TK_COMP 96 +#define TK_PRECISION 97 +#define TK_LP 98 +#define TK_RP 99 #define TK_TAGS 100 #define TK_USING 101 #define TK_AS 102 diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 4400927e9b..72e4f196a7 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -2090,6 +2090,9 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) { pMeta->precision = pDb->cfg.precision; pMeta->tableType = pTable->info.type; tstrncpy(pMeta->tableId, pTable->info.tableId, TSDB_TABLE_FNAME_LEN); + if (pTable->superTable) { + tstrncpy(pMeta->sTableId, pTable->superTable->info.tableId, TSDB_TABLE_FNAME_LEN); + } if (pTable->info.type == TSDB_CHILD_TABLE) { pMeta->sversion = htons(pTable->superTable->sversion); diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 79aec2f349..0196ff68a2 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -80,6 +80,7 @@ cmd ::= SHOW GRANTS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_GRANTS, 0, 0); cmd ::= SHOW VNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, 0, 0); } cmd ::= SHOW VNODES IPTOKEN(X). { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, &X, 0); } + %type dbPrefix {SStrToken} dbPrefix(A) ::=. {A.n = 0; A.type = 0;} dbPrefix(A) ::= ids(X) DOT. {A = X; } @@ -88,6 +89,15 @@ dbPrefix(A) ::= ids(X) DOT. {A = X; } cpxName(A) ::= . {A.n = 0; } cpxName(A) ::= DOT ids(Y). {A = Y; A.n += 1; } +cmd ::= SHOW CREATE TABLE ids(X) cpxName(Y). { + X.n += Y.n; + setDCLSQLElems(pInfo, TSDB_SQL_SHOW_CREATE_TABLE, 1, &X); +} + +cmd ::= SHOW CREATE DATABASE ids(X). { + setDCLSQLElems(pInfo, TSDB_SQL_SHOW_CREATE_DATABASE, 1, &X); +} + cmd ::= SHOW dbPrefix(X) TABLES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_TABLE, &X, 0); } From 48ac122e4ab17f08f262d0d1a77fc473d90d560e Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sun, 13 Sep 2020 21:42:47 +0000 Subject: [PATCH 02/77] fix bug --- src/client/src/tscLocal.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index 6d48350f73..b25573e255 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -699,9 +699,9 @@ static int32_t tscRebuildDDLForNormalTable(SSqlObj *pSql, const char *tableName, for (int32_t i = 0; i < numOfRows; ++i) { uint8_t type = pSchema[i].type; if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { - sprintf(result + strlen(result), "%s %s(%d),", pSchema[i].name,tDataTypeDesc[pSchema[i].type].aName,pSchema->bytes); + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s(%d),", pSchema[i].name,tDataTypeDesc[pSchema[i].type].aName,pSchema->bytes); } else { - sprintf(result + strlen(result), "%s %s,", pSchema[i].name, tDataTypeDesc[pSchema[i].type].aName); + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s,", pSchema[i].name, tDataTypeDesc[pSchema[i].type].aName); } } sprintf(result + strlen(result) - 1, "%s", ")"); @@ -722,22 +722,20 @@ static int32_t tscRebuildDDLForSuperTable(SSqlObj *pSql, const char *tableName, for (int32_t i = 0; i < numOfRows; ++i) { uint8_t type = pSchema[i].type; if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { - sprintf(result + strlen(result), "%s %s(%d),", pSchema[i].name,tDataTypeDesc[pSchema[i].type].aName,pSchema->bytes); + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result),"%s %s(%d),", pSchema[i].name,tDataTypeDesc[pSchema[i].type].aName,pSchema->bytes); } else { - sprintf(result + strlen(result), "%s %s,", pSchema[i].name, tDataTypeDesc[type].aName); + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s,", pSchema[i].name, tDataTypeDesc[type].aName); } } - sprintf(result + strlen(result) - 1, "%s ", ")"); + snprintf(result + strlen(result) - 1, TSDB_MAX_BINARY_LEN - strlen(result), "%s %s", ")", "TAGS ("); - sprintf(result + strlen(result), "TAGS ("); for (int32_t i = numOfRows; i < totalRows; i++) { uint8_t type = pSchema[i].type; if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { - sprintf(result + strlen(result), "%s %s(%d),", pSchema[i].name,tDataTypeDesc[pSchema[i].type].aName,pSchema->bytes); + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s(%d),", pSchema[i].name,tDataTypeDesc[pSchema[i].type].aName,pSchema->bytes); } else { - sprintf(result + strlen(result), "%s %s,", pSchema[i].name, tDataTypeDesc[type].aName); + snprintf(result + strlen(result), TSDB_MAX_BINARY_LEN - strlen(result), "%s %s,", pSchema[i].name, tDataTypeDesc[type].aName); } - } sprintf(result + strlen(result) - 1, "%s", ")"); @@ -752,7 +750,7 @@ static int32_t tscProcessShowCreateTable(SSqlObj *pSql) { char tableName[TSDB_TABLE_NAME_LEN] = {0}; extractTableName(pTableMetaInfo->name, tableName); - char result[TSDB_MAX_BYTES_PER_ROW] = {0}; + char *result = (char *)calloc(1, TSDB_MAX_BINARY_LEN); int32_t code = TSDB_CODE_SUCCESS; if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { code = tscRebuildDDLForSuperTable(pSql, tableName, result); @@ -764,10 +762,11 @@ static int32_t tscProcessShowCreateTable(SSqlObj *pSql) { code = TSDB_CODE_TSC_INVALID_VALUE; } - if (code != TSDB_CODE_SUCCESS) { - return code; - } - return tscSCreateBuildResult(pSql, SCREATE_BUILD_TABLE, tableName, result); + if (code == TSDB_CODE_SUCCESS) { + code = tscSCreateBuildResult(pSql, SCREATE_BUILD_TABLE, tableName, result); + } + free(result); + return code; } static int32_t tscProcessShowCreateDatabase(SSqlObj *pSql) { From 670c6c7d87b97baefde6332bd4cae63b28a7c0b7 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sun, 13 Sep 2020 21:59:59 +0000 Subject: [PATCH 03/77] fix bug --- src/client/src/tscLocal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index b25573e255..c0a958a2c8 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -658,7 +658,6 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch snprintf(fullName + strlen(fullName), TSDB_TABLE_FNAME_LEN - strlen(fullName), ".%s", param->sTableName); extractTableName(pTableMetaInfo->name, param->buf); - //tstrncpy(param->tableName, pTableMetaInfo->name, TSDB_TABLE_FNAME_LEN); param->pParentSql = pSql; param->pInterSql = pInterSql; param->fp = tscRebuildCreateTableStatement; @@ -676,6 +675,7 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch if (code != TSDB_CODE_SUCCESS) { free(param); free(pInterSql); + free(query); return code; } From ed1267a0d75a84dc68f604a233fb4cbf0d9b6c34 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sun, 13 Sep 2020 23:12:29 +0000 Subject: [PATCH 04/77] update sql.c --- src/inc/ttokendef.h | 200 +++--- src/query/src/sql.c | 1679 ++++++++++++++++++++++--------------------- 2 files changed, 948 insertions(+), 931 deletions(-) diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h index bc49d3c81b..a94cdaad15 100644 --- a/src/inc/ttokendef.h +++ b/src/inc/ttokendef.h @@ -16,105 +16,106 @@ #ifndef TDENGINE_TTOKENDEF_H #define TDENGINE_TTOKENDEF_H -#define TK_ID 1 -#define TK_BOOL 2 -#define TK_TINYINT 3 -#define TK_SMALLINT 4 -#define TK_INTEGER 5 -#define TK_BIGINT 6 -#define TK_FLOAT 7 -#define TK_DOUBLE 8 -#define TK_STRING 9 -#define TK_TIMESTAMP 10 -#define TK_BINARY 11 -#define TK_NCHAR 12 -#define TK_OR 13 -#define TK_AND 14 -#define TK_NOT 15 -#define TK_EQ 16 -#define TK_NE 17 -#define TK_ISNULL 18 -#define TK_NOTNULL 19 -#define TK_IS 20 -#define TK_LIKE 21 -#define TK_GLOB 22 -#define TK_BETWEEN 23 -#define TK_IN 24 -#define TK_GT 25 -#define TK_GE 26 -#define TK_LT 27 -#define TK_LE 28 -#define TK_BITAND 29 -#define TK_BITOR 30 -#define TK_LSHIFT 31 -#define TK_RSHIFT 32 -#define TK_PLUS 33 -#define TK_MINUS 34 -#define TK_DIVIDE 35 -#define TK_TIMES 36 -#define TK_STAR 37 -#define TK_SLASH 38 -#define TK_REM 39 -#define TK_CONCAT 40 -#define TK_UMINUS 41 -#define TK_UPLUS 42 -#define TK_BITNOT 43 -#define TK_SHOW 44 -#define TK_DATABASES 45 -#define TK_MNODES 46 -#define TK_DNODES 47 -#define TK_ACCOUNTS 48 -#define TK_USERS 49 -#define TK_MODULES 50 -#define TK_QUERIES 51 -#define TK_CONNECTIONS 52 -#define TK_STREAMS 53 -#define TK_VARIABLES 54 -#define TK_SCORES 55 -#define TK_GRANTS 56 -#define TK_VNODES 57 -#define TK_IPTOKEN 58 -#define TK_DOT 59 -#define TK_CREATE 60 -#define TK_TABLE 61 -#define TK_DATABASE 62 -#define TK_TABLES 63 -#define TK_STABLES 64 -#define TK_VGROUPS 65 -#define TK_DROP 66 -#define TK_DNODE 67 -#define TK_USER 68 -#define TK_ACCOUNT 69 -#define TK_USE 70 -#define TK_DESCRIBE 71 -#define TK_ALTER 72 -#define TK_PASS 73 -#define TK_PRIVILEGE 74 -#define TK_LOCAL 75 -#define TK_IF 76 -#define TK_EXISTS 77 -#define TK_PPS 78 -#define TK_TSERIES 79 -#define TK_DBS 80 -#define TK_STORAGE 81 -#define TK_QTIME 82 -#define TK_CONNS 83 -#define TK_STATE 84 -#define TK_KEEP 85 -#define TK_CACHE 86 -#define TK_REPLICA 87 -#define TK_QUORUM 88 -#define TK_DAYS 89 -#define TK_MINROWS 90 -#define TK_MAXROWS 91 -#define TK_BLOCKS 92 -#define TK_CTIME 93 -#define TK_WAL 94 -#define TK_FSYNC 95 -#define TK_COMP 96 -#define TK_PRECISION 97 -#define TK_LP 98 -#define TK_RP 99 + +#define TK_ID 1 +#define TK_BOOL 2 +#define TK_TINYINT 3 +#define TK_SMALLINT 4 +#define TK_INTEGER 5 +#define TK_BIGINT 6 +#define TK_FLOAT 7 +#define TK_DOUBLE 8 +#define TK_STRING 9 +#define TK_TIMESTAMP 10 +#define TK_BINARY 11 +#define TK_NCHAR 12 +#define TK_OR 13 +#define TK_AND 14 +#define TK_NOT 15 +#define TK_EQ 16 +#define TK_NE 17 +#define TK_ISNULL 18 +#define TK_NOTNULL 19 +#define TK_IS 20 +#define TK_LIKE 21 +#define TK_GLOB 22 +#define TK_BETWEEN 23 +#define TK_IN 24 +#define TK_GT 25 +#define TK_GE 26 +#define TK_LT 27 +#define TK_LE 28 +#define TK_BITAND 29 +#define TK_BITOR 30 +#define TK_LSHIFT 31 +#define TK_RSHIFT 32 +#define TK_PLUS 33 +#define TK_MINUS 34 +#define TK_DIVIDE 35 +#define TK_TIMES 36 +#define TK_STAR 37 +#define TK_SLASH 38 +#define TK_REM 39 +#define TK_CONCAT 40 +#define TK_UMINUS 41 +#define TK_UPLUS 42 +#define TK_BITNOT 43 +#define TK_SHOW 44 +#define TK_DATABASES 45 +#define TK_MNODES 46 +#define TK_DNODES 47 +#define TK_ACCOUNTS 48 +#define TK_USERS 49 +#define TK_MODULES 50 +#define TK_QUERIES 51 +#define TK_CONNECTIONS 52 +#define TK_STREAMS 53 +#define TK_VARIABLES 54 +#define TK_SCORES 55 +#define TK_GRANTS 56 +#define TK_VNODES 57 +#define TK_IPTOKEN 58 +#define TK_DOT 59 +#define TK_CREATE 60 +#define TK_TABLE 61 +#define TK_DATABASE 62 +#define TK_TABLES 63 +#define TK_STABLES 64 +#define TK_VGROUPS 65 +#define TK_DROP 66 +#define TK_DNODE 67 +#define TK_USER 68 +#define TK_ACCOUNT 69 +#define TK_USE 70 +#define TK_DESCRIBE 71 +#define TK_ALTER 72 +#define TK_PASS 73 +#define TK_PRIVILEGE 74 +#define TK_LOCAL 75 +#define TK_IF 76 +#define TK_EXISTS 77 +#define TK_PPS 78 +#define TK_TSERIES 79 +#define TK_DBS 80 +#define TK_STORAGE 81 +#define TK_QTIME 82 +#define TK_CONNS 83 +#define TK_STATE 84 +#define TK_KEEP 85 +#define TK_CACHE 86 +#define TK_REPLICA 87 +#define TK_QUORUM 88 +#define TK_DAYS 89 +#define TK_MINROWS 90 +#define TK_MAXROWS 91 +#define TK_BLOCKS 92 +#define TK_CTIME 93 +#define TK_WAL 94 +#define TK_FSYNC 95 +#define TK_COMP 96 +#define TK_PRECISION 97 +#define TK_LP 98 +#define TK_RP 99 #define TK_TAGS 100 #define TK_USING 101 #define TK_AS 102 @@ -222,7 +223,6 @@ #define TK_INTO 204 #define TK_VALUES 205 - #define TK_SPACE 300 #define TK_COMMENT 301 #define TK_ILLEGAL 302 diff --git a/src/query/src/sql.c b/src/query/src/sql.c index 373e57963c..3c160aab3b 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -126,17 +126,17 @@ typedef union { #define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo #define ParseARG_STORE yypParser->pInfo = pInfo #define YYFALLBACK 1 -#define YYNSTATE 244 -#define YYNRULE 225 +#define YYNSTATE 248 +#define YYNRULE 227 #define YYNTOKEN 206 -#define YY_MAX_SHIFT 243 -#define YY_MIN_SHIFTREDUCE 403 -#define YY_MAX_SHIFTREDUCE 627 -#define YY_ERROR_ACTION 628 -#define YY_ACCEPT_ACTION 629 -#define YY_NO_ACTION 630 -#define YY_MIN_REDUCE 631 -#define YY_MAX_REDUCE 855 +#define YY_MAX_SHIFT 247 +#define YY_MIN_SHIFTREDUCE 409 +#define YY_MAX_SHIFTREDUCE 635 +#define YY_ERROR_ACTION 636 +#define YY_ACCEPT_ACTION 637 +#define YY_NO_ACTION 638 +#define YY_MIN_REDUCE 639 +#define YY_MAX_REDUCE 865 /************* End control #defines *******************************************/ /* Define the yytestcase() macro to be a no-op if is not already defined @@ -202,121 +202,122 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (549) +#define YY_ACTTAB_COUNT (555) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 731, 444, 221, 729, 730, 629, 243, 510, 732, 445, - /* 10 */ 734, 735, 733, 41, 43, 526, 35, 36, 523, 11, - /* 20 */ 524, 29, 525, 444, 199, 39, 37, 40, 38, 155, - /* 30 */ 241, 445, 748, 34, 33, 219, 218, 32, 31, 30, - /* 40 */ 41, 43, 761, 35, 36, 136, 172, 173, 29, 137, - /* 50 */ 21, 199, 39, 37, 40, 38, 184, 141, 160, 843, - /* 60 */ 34, 33, 839, 772, 32, 31, 30, 404, 405, 406, - /* 70 */ 407, 408, 409, 410, 411, 412, 413, 414, 415, 242, - /* 80 */ 41, 43, 230, 35, 36, 746, 62, 137, 29, 137, - /* 90 */ 21, 199, 39, 37, 40, 38, 159, 843, 27, 842, - /* 100 */ 34, 33, 56, 838, 32, 31, 30, 105, 43, 8, - /* 110 */ 35, 36, 63, 115, 769, 29, 761, 527, 199, 39, - /* 120 */ 37, 40, 38, 168, 539, 747, 583, 34, 33, 18, - /* 130 */ 156, 32, 31, 30, 16, 210, 236, 235, 209, 208, - /* 140 */ 207, 234, 206, 233, 232, 231, 205, 727, 105, 715, - /* 150 */ 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, - /* 160 */ 726, 35, 36, 798, 837, 194, 29, 177, 157, 199, - /* 170 */ 39, 37, 40, 38, 181, 180, 21, 21, 34, 33, - /* 180 */ 444, 12, 32, 31, 30, 164, 596, 750, 445, 587, - /* 190 */ 153, 590, 154, 593, 105, 164, 596, 21, 17, 587, - /* 200 */ 150, 590, 196, 593, 60, 26, 90, 89, 144, 169, - /* 210 */ 217, 747, 747, 16, 149, 236, 235, 161, 162, 167, - /* 220 */ 234, 198, 233, 232, 231, 142, 670, 161, 162, 128, - /* 230 */ 222, 542, 747, 164, 596, 17, 143, 587, 750, 590, - /* 240 */ 105, 593, 26, 39, 37, 40, 38, 100, 170, 145, - /* 250 */ 797, 34, 33, 101, 26, 32, 31, 30, 32, 31, - /* 260 */ 30, 78, 183, 564, 565, 161, 162, 230, 589, 152, - /* 270 */ 592, 76, 80, 85, 88, 79, 240, 239, 97, 34, - /* 280 */ 33, 82, 42, 32, 31, 30, 118, 119, 70, 66, - /* 290 */ 69, 237, 42, 595, 679, 163, 61, 128, 132, 130, - /* 300 */ 93, 92, 91, 595, 671, 187, 585, 128, 594, 588, - /* 310 */ 750, 591, 171, 534, 47, 216, 215, 146, 594, 555, - /* 320 */ 186, 147, 556, 46, 613, 148, 14, 597, 13, 139, - /* 330 */ 42, 13, 50, 48, 3, 135, 75, 74, 140, 516, - /* 340 */ 515, 595, 586, 46, 22, 138, 203, 10, 9, 51, - /* 350 */ 22, 852, 530, 528, 531, 529, 594, 87, 86, 749, - /* 360 */ 808, 807, 165, 804, 803, 166, 771, 741, 220, 776, - /* 370 */ 763, 778, 102, 790, 789, 116, 117, 114, 681, 204, - /* 380 */ 133, 24, 213, 678, 214, 851, 72, 850, 848, 26, - /* 390 */ 120, 699, 25, 23, 185, 95, 134, 668, 81, 551, - /* 400 */ 666, 83, 84, 664, 188, 663, 174, 129, 661, 660, - /* 410 */ 659, 658, 657, 649, 131, 655, 653, 192, 52, 651, - /* 420 */ 760, 57, 49, 58, 791, 44, 197, 195, 193, 191, - /* 430 */ 189, 28, 212, 77, 223, 224, 225, 226, 227, 228, - /* 440 */ 229, 238, 627, 176, 175, 626, 201, 178, 179, 53, - /* 450 */ 625, 618, 182, 536, 64, 151, 186, 67, 552, 55, - /* 460 */ 103, 158, 662, 59, 200, 94, 96, 123, 700, 121, - /* 470 */ 126, 106, 107, 122, 124, 125, 127, 112, 108, 109, - /* 480 */ 113, 745, 110, 656, 111, 1, 2, 190, 5, 557, - /* 490 */ 104, 19, 6, 598, 20, 4, 15, 7, 65, 485, - /* 500 */ 202, 481, 479, 478, 477, 474, 448, 211, 68, 45, - /* 510 */ 71, 73, 22, 512, 511, 509, 54, 469, 467, 459, - /* 520 */ 465, 461, 463, 457, 455, 484, 483, 482, 480, 476, - /* 530 */ 475, 46, 446, 419, 417, 631, 630, 630, 630, 630, - /* 540 */ 630, 630, 630, 630, 630, 630, 630, 98, 99, + /* 0 */ 11, 452, 140, 452, 158, 245, 21, 139, 144, 453, + /* 10 */ 140, 453, 852, 41, 43, 771, 35, 36, 849, 163, + /* 20 */ 853, 29, 452, 848, 203, 39, 37, 40, 38, 159, + /* 30 */ 453, 782, 741, 34, 33, 739, 740, 32, 31, 30, + /* 40 */ 742, 756, 744, 745, 743, 107, 160, 410, 411, 412, + /* 50 */ 413, 414, 415, 416, 417, 418, 419, 420, 421, 246, + /* 60 */ 637, 247, 178, 41, 43, 760, 35, 36, 225, 107, + /* 70 */ 140, 29, 170, 847, 203, 39, 37, 40, 38, 162, + /* 80 */ 853, 518, 779, 34, 33, 103, 156, 32, 31, 30, + /* 90 */ 234, 760, 41, 43, 157, 35, 36, 771, 758, 200, + /* 100 */ 29, 60, 56, 203, 39, 37, 40, 38, 17, 223, + /* 110 */ 222, 188, 34, 33, 145, 26, 32, 31, 30, 43, + /* 120 */ 8, 35, 36, 63, 117, 808, 29, 198, 146, 203, + /* 130 */ 39, 37, 40, 38, 32, 31, 30, 191, 34, 33, + /* 140 */ 181, 107, 32, 31, 30, 241, 21, 185, 184, 591, + /* 150 */ 16, 214, 240, 239, 213, 212, 211, 238, 210, 237, + /* 160 */ 236, 235, 209, 737, 760, 725, 726, 727, 728, 729, + /* 170 */ 730, 731, 732, 733, 734, 735, 736, 35, 36, 171, + /* 180 */ 680, 757, 29, 130, 148, 203, 39, 37, 40, 38, + /* 190 */ 244, 243, 96, 149, 34, 33, 107, 807, 32, 31, + /* 200 */ 30, 167, 604, 78, 12, 595, 62, 598, 234, 601, + /* 210 */ 689, 167, 604, 130, 150, 595, 173, 598, 27, 601, + /* 220 */ 152, 167, 604, 572, 573, 595, 153, 598, 151, 601, + /* 230 */ 90, 89, 147, 164, 165, 34, 33, 202, 142, 32, + /* 240 */ 31, 30, 681, 164, 165, 130, 818, 550, 39, 37, + /* 250 */ 40, 38, 61, 164, 165, 563, 34, 33, 17, 46, + /* 260 */ 32, 31, 30, 102, 16, 26, 240, 239, 564, 21, + /* 270 */ 26, 238, 14, 237, 236, 235, 597, 174, 600, 547, + /* 280 */ 220, 219, 76, 80, 18, 187, 166, 21, 85, 88, + /* 290 */ 79, 138, 155, 120, 121, 21, 82, 593, 42, 70, + /* 300 */ 66, 69, 172, 542, 757, 134, 132, 143, 42, 603, + /* 310 */ 190, 93, 92, 91, 596, 141, 599, 621, 42, 603, + /* 320 */ 221, 13, 757, 605, 602, 3, 862, 13, 226, 603, + /* 330 */ 757, 47, 534, 594, 602, 531, 50, 532, 538, 533, + /* 340 */ 539, 524, 523, 817, 602, 46, 22, 207, 87, 86, + /* 350 */ 48, 22, 759, 51, 75, 74, 101, 99, 10, 9, + /* 360 */ 536, 168, 537, 175, 176, 814, 813, 169, 781, 786, + /* 370 */ 751, 800, 224, 773, 788, 26, 104, 799, 118, 189, + /* 380 */ 116, 119, 691, 208, 136, 24, 100, 217, 688, 559, + /* 390 */ 218, 861, 72, 860, 858, 122, 709, 25, 23, 137, + /* 400 */ 678, 81, 676, 83, 84, 674, 673, 177, 131, 671, + /* 410 */ 192, 670, 196, 669, 770, 668, 667, 133, 665, 663, + /* 420 */ 52, 661, 659, 657, 135, 49, 57, 58, 801, 44, + /* 430 */ 201, 199, 197, 195, 535, 193, 28, 216, 77, 227, + /* 440 */ 228, 230, 229, 231, 232, 233, 242, 635, 180, 205, + /* 450 */ 53, 179, 634, 182, 183, 64, 67, 154, 633, 626, + /* 460 */ 186, 161, 105, 672, 190, 94, 544, 666, 658, 125, + /* 470 */ 710, 123, 124, 126, 127, 108, 128, 109, 129, 110, + /* 480 */ 95, 755, 111, 112, 115, 113, 114, 2, 1, 55, + /* 490 */ 59, 560, 194, 5, 565, 106, 19, 6, 606, 20, + /* 500 */ 4, 15, 65, 7, 204, 493, 206, 489, 487, 486, + /* 510 */ 485, 482, 456, 215, 68, 45, 22, 71, 73, 520, + /* 520 */ 519, 517, 54, 477, 475, 467, 473, 469, 471, 465, + /* 530 */ 463, 492, 491, 490, 488, 484, 483, 46, 454, 425, + /* 540 */ 423, 639, 638, 638, 638, 638, 638, 638, 638, 638, + /* 550 */ 638, 638, 638, 97, 98, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 226, 1, 210, 229, 230, 207, 208, 5, 234, 9, - /* 10 */ 236, 237, 238, 13, 14, 2, 16, 17, 5, 260, - /* 20 */ 7, 21, 9, 1, 24, 25, 26, 27, 28, 209, - /* 30 */ 210, 9, 240, 33, 34, 33, 34, 37, 38, 39, - /* 40 */ 13, 14, 244, 16, 17, 260, 33, 34, 21, 260, - /* 50 */ 210, 24, 25, 26, 27, 28, 258, 260, 269, 270, - /* 60 */ 33, 34, 260, 210, 37, 38, 39, 45, 46, 47, - /* 70 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - /* 80 */ 13, 14, 78, 16, 17, 245, 247, 260, 21, 260, - /* 90 */ 210, 24, 25, 26, 27, 28, 269, 270, 259, 270, - /* 100 */ 33, 34, 102, 260, 37, 38, 39, 210, 14, 98, - /* 110 */ 16, 17, 101, 102, 261, 21, 244, 104, 24, 25, - /* 120 */ 26, 27, 28, 243, 103, 245, 99, 33, 34, 108, - /* 130 */ 258, 37, 38, 39, 85, 86, 87, 88, 89, 90, - /* 140 */ 91, 92, 93, 94, 95, 96, 97, 226, 210, 228, - /* 150 */ 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, - /* 160 */ 239, 16, 17, 266, 260, 268, 21, 126, 227, 24, - /* 170 */ 25, 26, 27, 28, 133, 134, 210, 210, 33, 34, - /* 180 */ 1, 44, 37, 38, 39, 1, 2, 246, 9, 5, - /* 190 */ 260, 7, 260, 9, 210, 1, 2, 210, 98, 5, - /* 200 */ 63, 7, 264, 9, 266, 105, 69, 70, 71, 243, - /* 210 */ 243, 245, 245, 85, 77, 87, 88, 33, 34, 227, - /* 220 */ 92, 37, 94, 95, 96, 260, 214, 33, 34, 217, - /* 230 */ 243, 37, 245, 1, 2, 98, 260, 5, 246, 7, - /* 240 */ 210, 9, 105, 25, 26, 27, 28, 98, 63, 260, - /* 250 */ 266, 33, 34, 210, 105, 37, 38, 39, 37, 38, - /* 260 */ 39, 72, 125, 115, 116, 33, 34, 78, 5, 132, - /* 270 */ 7, 64, 65, 66, 67, 68, 60, 61, 62, 33, - /* 280 */ 34, 74, 98, 37, 38, 39, 64, 65, 66, 67, - /* 290 */ 68, 227, 98, 109, 214, 59, 266, 217, 64, 65, - /* 300 */ 66, 67, 68, 109, 214, 262, 1, 217, 124, 5, - /* 310 */ 246, 7, 127, 99, 103, 130, 131, 260, 124, 99, - /* 320 */ 106, 260, 99, 103, 99, 260, 103, 99, 103, 260, - /* 330 */ 98, 103, 103, 122, 98, 260, 128, 129, 260, 99, - /* 340 */ 99, 109, 37, 103, 103, 260, 99, 128, 129, 120, - /* 350 */ 103, 246, 5, 5, 7, 7, 124, 72, 73, 246, - /* 360 */ 241, 241, 241, 241, 241, 241, 210, 242, 241, 210, - /* 370 */ 244, 210, 210, 267, 267, 210, 210, 248, 210, 210, - /* 380 */ 210, 210, 210, 210, 210, 210, 210, 210, 210, 105, - /* 390 */ 210, 210, 210, 210, 244, 59, 210, 210, 210, 109, - /* 400 */ 210, 210, 210, 210, 263, 210, 210, 210, 210, 210, - /* 410 */ 210, 210, 210, 210, 210, 210, 210, 263, 119, 210, - /* 420 */ 257, 211, 121, 211, 211, 118, 113, 117, 112, 111, - /* 430 */ 110, 123, 75, 84, 83, 49, 80, 82, 53, 81, - /* 440 */ 79, 75, 5, 5, 135, 5, 211, 135, 5, 211, - /* 450 */ 5, 86, 126, 99, 215, 211, 106, 215, 99, 107, - /* 460 */ 98, 1, 211, 103, 100, 212, 212, 219, 225, 224, - /* 470 */ 221, 256, 255, 223, 222, 220, 218, 250, 254, 253, - /* 480 */ 249, 244, 252, 211, 251, 216, 213, 98, 114, 99, - /* 490 */ 98, 103, 114, 99, 103, 98, 98, 98, 72, 9, - /* 500 */ 100, 5, 5, 5, 5, 5, 76, 15, 72, 16, - /* 510 */ 129, 129, 103, 5, 5, 99, 98, 5, 5, 5, - /* 520 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - /* 530 */ 5, 103, 76, 59, 58, 0, 271, 271, 271, 271, - /* 540 */ 271, 271, 271, 271, 271, 271, 271, 21, 21, 271, - /* 550 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 0 */ 260, 1, 260, 1, 209, 210, 210, 260, 260, 9, + /* 10 */ 260, 9, 270, 13, 14, 244, 16, 17, 260, 269, + /* 20 */ 270, 21, 1, 260, 24, 25, 26, 27, 28, 258, + /* 30 */ 9, 210, 226, 33, 34, 229, 230, 37, 38, 39, + /* 40 */ 234, 245, 236, 237, 238, 210, 227, 45, 46, 47, + /* 50 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + /* 60 */ 207, 208, 60, 13, 14, 246, 16, 17, 210, 210, + /* 70 */ 260, 21, 227, 260, 24, 25, 26, 27, 28, 269, + /* 80 */ 270, 5, 261, 33, 34, 210, 260, 37, 38, 39, + /* 90 */ 78, 246, 13, 14, 260, 16, 17, 244, 240, 264, + /* 100 */ 21, 266, 102, 24, 25, 26, 27, 28, 98, 33, + /* 110 */ 34, 258, 33, 34, 260, 105, 37, 38, 39, 14, + /* 120 */ 98, 16, 17, 101, 102, 266, 21, 268, 260, 24, + /* 130 */ 25, 26, 27, 28, 37, 38, 39, 262, 33, 34, + /* 140 */ 126, 210, 37, 38, 39, 227, 210, 133, 134, 99, + /* 150 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + /* 160 */ 95, 96, 97, 226, 246, 228, 229, 230, 231, 232, + /* 170 */ 233, 234, 235, 236, 237, 238, 239, 16, 17, 243, + /* 180 */ 214, 245, 21, 217, 260, 24, 25, 26, 27, 28, + /* 190 */ 63, 64, 65, 260, 33, 34, 210, 266, 37, 38, + /* 200 */ 39, 1, 2, 73, 44, 5, 247, 7, 78, 9, + /* 210 */ 214, 1, 2, 217, 260, 5, 66, 7, 259, 9, + /* 220 */ 60, 1, 2, 115, 116, 5, 66, 7, 260, 9, + /* 230 */ 70, 71, 72, 33, 34, 33, 34, 37, 260, 37, + /* 240 */ 38, 39, 214, 33, 34, 217, 241, 37, 25, 26, + /* 250 */ 27, 28, 266, 33, 34, 99, 33, 34, 98, 103, + /* 260 */ 37, 38, 39, 98, 85, 105, 87, 88, 99, 210, + /* 270 */ 105, 92, 103, 94, 95, 96, 5, 127, 7, 103, + /* 280 */ 130, 131, 61, 62, 108, 125, 59, 210, 67, 68, + /* 290 */ 69, 260, 132, 61, 62, 210, 75, 1, 98, 67, + /* 300 */ 68, 69, 243, 99, 245, 61, 62, 260, 98, 109, + /* 310 */ 106, 67, 68, 69, 5, 260, 7, 99, 98, 109, + /* 320 */ 243, 103, 245, 99, 124, 98, 246, 103, 243, 109, + /* 330 */ 245, 103, 2, 37, 124, 5, 103, 7, 5, 9, + /* 340 */ 7, 99, 99, 241, 124, 103, 103, 99, 73, 74, + /* 350 */ 122, 103, 246, 120, 128, 129, 61, 62, 128, 129, + /* 360 */ 5, 241, 7, 33, 34, 241, 241, 241, 210, 210, + /* 370 */ 242, 267, 241, 244, 210, 105, 210, 267, 210, 244, + /* 380 */ 248, 210, 210, 210, 210, 210, 59, 210, 210, 109, + /* 390 */ 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, + /* 400 */ 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, + /* 410 */ 263, 210, 263, 210, 257, 210, 210, 210, 210, 210, + /* 420 */ 119, 210, 210, 210, 210, 121, 211, 211, 211, 118, + /* 430 */ 113, 117, 112, 111, 104, 110, 123, 76, 84, 83, + /* 440 */ 49, 82, 80, 53, 81, 79, 76, 5, 5, 211, + /* 450 */ 211, 135, 5, 135, 5, 215, 215, 211, 5, 86, + /* 460 */ 126, 1, 98, 211, 106, 212, 99, 211, 211, 219, + /* 470 */ 225, 224, 223, 222, 220, 256, 221, 255, 218, 254, + /* 480 */ 212, 244, 253, 252, 249, 251, 250, 213, 216, 107, + /* 490 */ 103, 99, 98, 114, 99, 98, 103, 114, 99, 103, + /* 500 */ 98, 98, 73, 98, 100, 9, 100, 5, 5, 5, + /* 510 */ 5, 5, 77, 15, 73, 16, 103, 129, 129, 5, + /* 520 */ 5, 99, 98, 5, 5, 5, 5, 5, 5, 5, + /* 530 */ 5, 5, 5, 5, 5, 5, 5, 103, 77, 59, + /* 540 */ 58, 0, 271, 271, 271, 271, 271, 271, 271, 271, + /* 550 */ 271, 271, 271, 21, 21, 271, 271, 271, 271, 271, /* 560 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 570 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 580 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, @@ -336,83 +337,84 @@ static const YYCODETYPE yy_lookahead[] = { /* 720 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 730 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 740 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - /* 750 */ 271, 271, 271, 271, 271, + /* 750 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 760 */ 271, }; -#define YY_SHIFT_COUNT (243) +#define YY_SHIFT_COUNT (247) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (535) +#define YY_SHIFT_MAX (541) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 137, 49, 128, 184, 232, 179, 179, 179, 179, 179, - /* 10 */ 179, 0, 22, 232, 13, 13, 13, 100, 179, 179, - /* 20 */ 179, 179, 179, 189, 4, 4, 549, 194, 232, 232, - /* 30 */ 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, - /* 40 */ 232, 232, 232, 232, 232, 13, 13, 2, 2, 2, - /* 50 */ 2, 2, 2, 11, 2, 149, 179, 179, 179, 179, - /* 60 */ 148, 148, 21, 179, 179, 179, 179, 179, 179, 179, - /* 70 */ 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, - /* 80 */ 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, - /* 90 */ 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, - /* 100 */ 284, 336, 336, 290, 290, 336, 299, 301, 307, 313, - /* 110 */ 310, 316, 318, 320, 308, 284, 336, 336, 357, 357, - /* 120 */ 336, 349, 351, 386, 356, 355, 385, 358, 361, 336, - /* 130 */ 366, 336, 366, 549, 549, 27, 67, 67, 67, 94, - /* 140 */ 145, 218, 218, 218, 207, 246, 246, 246, 246, 222, - /* 150 */ 234, 185, 41, 221, 221, 216, 214, 220, 223, 225, - /* 160 */ 228, 263, 304, 305, 236, 211, 229, 240, 241, 247, - /* 170 */ 208, 219, 347, 348, 285, 437, 309, 438, 440, 312, - /* 180 */ 443, 445, 365, 326, 350, 354, 352, 360, 359, 362, - /* 190 */ 460, 389, 390, 392, 388, 374, 391, 378, 394, 397, - /* 200 */ 398, 364, 399, 400, 426, 490, 496, 497, 498, 499, - /* 210 */ 500, 430, 492, 436, 493, 381, 382, 409, 508, 509, - /* 220 */ 416, 418, 409, 512, 513, 514, 515, 516, 517, 518, - /* 230 */ 519, 520, 521, 522, 523, 524, 525, 428, 456, 526, - /* 240 */ 527, 474, 476, 535, + /* 0 */ 160, 65, 179, 200, 220, 21, 21, 21, 21, 21, + /* 10 */ 21, 0, 2, 220, 330, 330, 330, 10, 21, 21, + /* 20 */ 21, 21, 21, 130, 12, 12, 555, 210, 220, 220, + /* 30 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 40 */ 220, 220, 220, 220, 220, 330, 330, 76, 76, 76, + /* 50 */ 76, 76, 76, 22, 76, 165, 21, 21, 21, 21, + /* 60 */ 108, 108, 176, 21, 21, 21, 21, 21, 21, 21, + /* 70 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + /* 80 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + /* 90 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + /* 100 */ 21, 21, 270, 327, 327, 280, 280, 327, 301, 304, + /* 110 */ 311, 317, 314, 320, 322, 325, 313, 270, 327, 327, + /* 120 */ 361, 361, 327, 354, 356, 391, 362, 359, 390, 363, + /* 130 */ 366, 327, 370, 327, 370, 327, 555, 555, 50, 79, + /* 140 */ 79, 79, 105, 161, 223, 223, 223, 221, 202, 202, + /* 150 */ 202, 202, 232, 244, 150, 14, 97, 97, 127, 204, + /* 160 */ 156, 169, 218, 224, 271, 309, 296, 227, 228, 233, + /* 170 */ 242, 243, 248, 226, 230, 333, 355, 275, 295, 442, + /* 180 */ 316, 443, 447, 318, 449, 453, 373, 334, 358, 367, + /* 190 */ 382, 387, 392, 364, 460, 394, 395, 397, 393, 379, + /* 200 */ 396, 383, 399, 402, 403, 404, 405, 406, 429, 496, + /* 210 */ 502, 503, 504, 505, 506, 435, 498, 441, 499, 388, + /* 220 */ 389, 413, 514, 515, 422, 424, 413, 518, 519, 520, + /* 230 */ 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, + /* 240 */ 531, 434, 461, 532, 533, 480, 482, 541, }; -#define YY_REDUCE_COUNT (134) -#define YY_REDUCE_MIN (-241) -#define YY_REDUCE_MAX (273) +#define YY_REDUCE_COUNT (137) +#define YY_REDUCE_MIN (-260) +#define YY_REDUCE_MAX (274) static const short yy_reduce_ofst[] = { - /* 0 */ -202, -79, -226, -211, -173, -103, -62, -120, -34, -33, - /* 10 */ -13, -147, -180, -171, -59, -8, 64, -128, 43, -16, - /* 20 */ 30, -208, -160, 12, 80, 90, -161, -241, -215, -203, - /* 30 */ -198, -157, -96, -70, -68, -35, -24, -11, 57, 61, - /* 40 */ 65, 69, 75, 78, 85, 105, 113, 119, 120, 121, - /* 50 */ 122, 123, 124, 125, 127, 126, 156, 159, 161, 162, - /* 60 */ 106, 107, 129, 165, 166, 168, 169, 170, 171, 172, - /* 70 */ 173, 174, 175, 176, 177, 178, 180, 181, 182, 183, - /* 80 */ 186, 187, 188, 190, 191, 192, 193, 195, 196, 197, - /* 90 */ 198, 199, 200, 201, 202, 203, 204, 205, 206, 209, - /* 100 */ 150, 210, 212, 141, 154, 213, 163, 215, 217, 224, - /* 110 */ 226, 230, 233, 227, 231, 237, 235, 238, 239, 242, - /* 120 */ 244, 243, 245, 250, 248, 252, 255, 249, 258, 251, - /* 130 */ 253, 272, 254, 269, 273, + /* 0 */ -147, -63, -194, -250, -190, -141, -165, -64, 59, 77, + /* 10 */ 85, -179, -205, -258, -181, -155, -82, -229, -125, -69, + /* 20 */ -14, -142, -204, -34, -4, 28, -41, -260, -253, -252, + /* 30 */ -242, -237, -187, -174, -166, -146, -132, -76, -67, -46, + /* 40 */ -32, -22, 31, 47, 55, 80, 106, 5, 102, 120, + /* 50 */ 124, 125, 126, 128, 131, 129, 158, 159, 164, 166, + /* 60 */ 104, 110, 132, 168, 171, 172, 173, 174, 175, 177, + /* 70 */ 178, 180, 181, 182, 183, 184, 185, 186, 187, 188, + /* 80 */ 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, + /* 90 */ 199, 201, 203, 205, 206, 207, 208, 209, 211, 212, + /* 100 */ 213, 214, 135, 215, 216, 147, 149, 217, 157, 219, + /* 110 */ 222, 225, 229, 231, 234, 236, 235, 237, 238, 239, + /* 120 */ 240, 241, 246, 245, 247, 249, 250, 251, 254, 255, + /* 130 */ 260, 252, 253, 256, 268, 257, 272, 274, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 628, 680, 669, 845, 845, 628, 628, 628, 628, 628, - /* 10 */ 628, 773, 646, 845, 628, 628, 628, 628, 628, 628, - /* 20 */ 628, 628, 628, 682, 682, 682, 768, 628, 628, 628, - /* 30 */ 628, 628, 628, 628, 628, 628, 628, 628, 628, 628, - /* 40 */ 628, 628, 628, 628, 628, 628, 628, 628, 628, 628, - /* 50 */ 628, 628, 628, 628, 628, 628, 628, 775, 777, 628, - /* 60 */ 794, 794, 766, 628, 628, 628, 628, 628, 628, 628, - /* 70 */ 628, 628, 628, 628, 628, 628, 628, 628, 628, 628, - /* 80 */ 628, 667, 628, 665, 628, 628, 628, 628, 628, 628, - /* 90 */ 628, 628, 628, 628, 628, 628, 628, 654, 628, 628, - /* 100 */ 628, 648, 648, 628, 628, 648, 801, 805, 799, 787, - /* 110 */ 795, 786, 782, 781, 809, 628, 648, 648, 677, 677, - /* 120 */ 648, 698, 696, 694, 686, 692, 688, 690, 684, 648, - /* 130 */ 675, 648, 675, 714, 728, 628, 810, 844, 800, 828, - /* 140 */ 827, 840, 834, 833, 628, 832, 831, 830, 829, 628, - /* 150 */ 628, 628, 628, 836, 835, 628, 628, 628, 628, 628, - /* 160 */ 628, 628, 628, 628, 812, 806, 802, 628, 628, 628, - /* 170 */ 628, 628, 628, 628, 628, 628, 628, 628, 628, 628, - /* 180 */ 628, 628, 628, 628, 765, 628, 628, 774, 628, 628, - /* 190 */ 628, 628, 628, 628, 796, 628, 788, 628, 628, 628, - /* 200 */ 628, 628, 628, 742, 628, 628, 628, 628, 628, 628, - /* 210 */ 628, 628, 628, 628, 628, 628, 628, 849, 628, 628, - /* 220 */ 628, 736, 847, 628, 628, 628, 628, 628, 628, 628, - /* 230 */ 628, 628, 628, 628, 628, 628, 628, 701, 628, 652, - /* 240 */ 650, 628, 644, 628, + /* 0 */ 636, 690, 679, 855, 855, 636, 636, 636, 636, 636, + /* 10 */ 636, 783, 654, 855, 636, 636, 636, 636, 636, 636, + /* 20 */ 636, 636, 636, 692, 692, 692, 778, 636, 636, 636, + /* 30 */ 636, 636, 636, 636, 636, 636, 636, 636, 636, 636, + /* 40 */ 636, 636, 636, 636, 636, 636, 636, 636, 636, 636, + /* 50 */ 636, 636, 636, 636, 636, 636, 636, 785, 787, 636, + /* 60 */ 804, 804, 776, 636, 636, 636, 636, 636, 636, 636, + /* 70 */ 636, 636, 636, 636, 636, 636, 636, 636, 636, 636, + /* 80 */ 636, 677, 636, 675, 636, 636, 636, 636, 636, 636, + /* 90 */ 636, 636, 636, 636, 636, 636, 664, 636, 636, 636, + /* 100 */ 636, 636, 636, 656, 656, 636, 636, 656, 811, 815, + /* 110 */ 809, 797, 805, 796, 792, 791, 819, 636, 656, 656, + /* 120 */ 687, 687, 656, 708, 706, 704, 696, 702, 698, 700, + /* 130 */ 694, 656, 685, 656, 685, 656, 724, 738, 636, 820, + /* 140 */ 854, 810, 838, 837, 850, 844, 843, 636, 842, 841, + /* 150 */ 840, 839, 636, 636, 636, 636, 846, 845, 636, 636, + /* 160 */ 636, 636, 636, 636, 636, 636, 636, 822, 816, 812, + /* 170 */ 636, 636, 636, 636, 636, 636, 636, 636, 636, 636, + /* 180 */ 636, 636, 636, 636, 636, 636, 636, 636, 775, 636, + /* 190 */ 636, 784, 636, 636, 636, 636, 636, 636, 806, 636, + /* 200 */ 798, 636, 636, 636, 636, 636, 636, 752, 636, 636, + /* 210 */ 636, 636, 636, 636, 636, 636, 636, 636, 636, 636, + /* 220 */ 636, 859, 636, 636, 636, 746, 857, 636, 636, 636, + /* 230 */ 636, 636, 636, 636, 636, 636, 636, 636, 636, 636, + /* 240 */ 636, 711, 636, 662, 660, 636, 652, 636, }; /********** End of lemon-generated parsing tables *****************************/ @@ -492,12 +494,13 @@ static const YYCODETYPE yyFallback[] = { 0, /* VNODES => nothing */ 1, /* IPTOKEN => ID */ 0, /* DOT => nothing */ + 0, /* CREATE => nothing */ + 0, /* TABLE => nothing */ + 1, /* DATABASE => ID */ 0, /* TABLES => nothing */ 0, /* STABLES => nothing */ 0, /* VGROUPS => nothing */ 0, /* DROP => nothing */ - 0, /* TABLE => nothing */ - 1, /* DATABASE => ID */ 0, /* DNODE => nothing */ 0, /* USER => nothing */ 0, /* ACCOUNT => nothing */ @@ -509,7 +512,6 @@ static const YYCODETYPE yyFallback[] = { 0, /* LOCAL => nothing */ 0, /* IF => nothing */ 0, /* EXISTS => nothing */ - 0, /* CREATE => nothing */ 0, /* PPS => nothing */ 0, /* TSERIES => nothing */ 0, /* DBS => nothing */ @@ -784,24 +786,24 @@ static const char *const yyTokenName[] = { /* 57 */ "VNODES", /* 58 */ "IPTOKEN", /* 59 */ "DOT", - /* 60 */ "TABLES", - /* 61 */ "STABLES", - /* 62 */ "VGROUPS", - /* 63 */ "DROP", - /* 64 */ "TABLE", - /* 65 */ "DATABASE", - /* 66 */ "DNODE", - /* 67 */ "USER", - /* 68 */ "ACCOUNT", - /* 69 */ "USE", - /* 70 */ "DESCRIBE", - /* 71 */ "ALTER", - /* 72 */ "PASS", - /* 73 */ "PRIVILEGE", - /* 74 */ "LOCAL", - /* 75 */ "IF", - /* 76 */ "EXISTS", - /* 77 */ "CREATE", + /* 60 */ "CREATE", + /* 61 */ "TABLE", + /* 62 */ "DATABASE", + /* 63 */ "TABLES", + /* 64 */ "STABLES", + /* 65 */ "VGROUPS", + /* 66 */ "DROP", + /* 67 */ "DNODE", + /* 68 */ "USER", + /* 69 */ "ACCOUNT", + /* 70 */ "USE", + /* 71 */ "DESCRIBE", + /* 72 */ "ALTER", + /* 73 */ "PASS", + /* 74 */ "PRIVILEGE", + /* 75 */ "LOCAL", + /* 76 */ "IF", + /* 77 */ "EXISTS", /* 78 */ "PPS", /* 79 */ "TSERIES", /* 80 */ "DBS", @@ -1021,212 +1023,214 @@ static const char *const yyRuleName[] = { /* 16 */ "dbPrefix ::= ids DOT", /* 17 */ "cpxName ::=", /* 18 */ "cpxName ::= DOT ids", - /* 19 */ "cmd ::= SHOW dbPrefix TABLES", - /* 20 */ "cmd ::= SHOW dbPrefix TABLES LIKE ids", - /* 21 */ "cmd ::= SHOW dbPrefix STABLES", - /* 22 */ "cmd ::= SHOW dbPrefix STABLES LIKE ids", - /* 23 */ "cmd ::= SHOW dbPrefix VGROUPS", - /* 24 */ "cmd ::= SHOW dbPrefix VGROUPS ids", - /* 25 */ "cmd ::= DROP TABLE ifexists ids cpxName", - /* 26 */ "cmd ::= DROP DATABASE ifexists ids", - /* 27 */ "cmd ::= DROP DNODE ids", - /* 28 */ "cmd ::= DROP USER ids", - /* 29 */ "cmd ::= DROP ACCOUNT ids", - /* 30 */ "cmd ::= USE ids", - /* 31 */ "cmd ::= DESCRIBE ids cpxName", - /* 32 */ "cmd ::= ALTER USER ids PASS ids", - /* 33 */ "cmd ::= ALTER USER ids PRIVILEGE ids", - /* 34 */ "cmd ::= ALTER DNODE ids ids", - /* 35 */ "cmd ::= ALTER DNODE ids ids ids", - /* 36 */ "cmd ::= ALTER LOCAL ids", - /* 37 */ "cmd ::= ALTER LOCAL ids ids", - /* 38 */ "cmd ::= ALTER DATABASE ids alter_db_optr", - /* 39 */ "cmd ::= ALTER ACCOUNT ids acct_optr", - /* 40 */ "cmd ::= ALTER ACCOUNT ids PASS ids acct_optr", - /* 41 */ "ids ::= ID", - /* 42 */ "ids ::= STRING", - /* 43 */ "ifexists ::= IF EXISTS", - /* 44 */ "ifexists ::=", - /* 45 */ "ifnotexists ::= IF NOT EXISTS", - /* 46 */ "ifnotexists ::=", - /* 47 */ "cmd ::= CREATE DNODE ids", - /* 48 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr", - /* 49 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr", - /* 50 */ "cmd ::= CREATE USER ids PASS ids", - /* 51 */ "pps ::=", - /* 52 */ "pps ::= PPS INTEGER", - /* 53 */ "tseries ::=", - /* 54 */ "tseries ::= TSERIES INTEGER", - /* 55 */ "dbs ::=", - /* 56 */ "dbs ::= DBS INTEGER", - /* 57 */ "streams ::=", - /* 58 */ "streams ::= STREAMS INTEGER", - /* 59 */ "storage ::=", - /* 60 */ "storage ::= STORAGE INTEGER", - /* 61 */ "qtime ::=", - /* 62 */ "qtime ::= QTIME INTEGER", - /* 63 */ "users ::=", - /* 64 */ "users ::= USERS INTEGER", - /* 65 */ "conns ::=", - /* 66 */ "conns ::= CONNS INTEGER", - /* 67 */ "state ::=", - /* 68 */ "state ::= STATE ids", - /* 69 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state", - /* 70 */ "keep ::= KEEP tagitemlist", - /* 71 */ "cache ::= CACHE INTEGER", - /* 72 */ "replica ::= REPLICA INTEGER", - /* 73 */ "quorum ::= QUORUM INTEGER", - /* 74 */ "days ::= DAYS INTEGER", - /* 75 */ "minrows ::= MINROWS INTEGER", - /* 76 */ "maxrows ::= MAXROWS INTEGER", - /* 77 */ "blocks ::= BLOCKS INTEGER", - /* 78 */ "ctime ::= CTIME INTEGER", - /* 79 */ "wal ::= WAL INTEGER", - /* 80 */ "fsync ::= FSYNC INTEGER", - /* 81 */ "comp ::= COMP INTEGER", - /* 82 */ "prec ::= PRECISION STRING", - /* 83 */ "db_optr ::=", - /* 84 */ "db_optr ::= db_optr cache", - /* 85 */ "db_optr ::= db_optr replica", - /* 86 */ "db_optr ::= db_optr quorum", - /* 87 */ "db_optr ::= db_optr days", - /* 88 */ "db_optr ::= db_optr minrows", - /* 89 */ "db_optr ::= db_optr maxrows", - /* 90 */ "db_optr ::= db_optr blocks", - /* 91 */ "db_optr ::= db_optr ctime", - /* 92 */ "db_optr ::= db_optr wal", - /* 93 */ "db_optr ::= db_optr fsync", - /* 94 */ "db_optr ::= db_optr comp", - /* 95 */ "db_optr ::= db_optr prec", - /* 96 */ "db_optr ::= db_optr keep", - /* 97 */ "alter_db_optr ::=", - /* 98 */ "alter_db_optr ::= alter_db_optr replica", - /* 99 */ "alter_db_optr ::= alter_db_optr quorum", - /* 100 */ "alter_db_optr ::= alter_db_optr keep", - /* 101 */ "alter_db_optr ::= alter_db_optr blocks", - /* 102 */ "alter_db_optr ::= alter_db_optr comp", - /* 103 */ "alter_db_optr ::= alter_db_optr wal", - /* 104 */ "alter_db_optr ::= alter_db_optr fsync", - /* 105 */ "typename ::= ids", - /* 106 */ "typename ::= ids LP signed RP", - /* 107 */ "signed ::= INTEGER", - /* 108 */ "signed ::= PLUS INTEGER", - /* 109 */ "signed ::= MINUS INTEGER", - /* 110 */ "cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args", - /* 111 */ "create_table_args ::= LP columnlist RP", - /* 112 */ "create_table_args ::= LP columnlist RP TAGS LP columnlist RP", - /* 113 */ "create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP", - /* 114 */ "create_table_args ::= AS select", - /* 115 */ "columnlist ::= columnlist COMMA column", - /* 116 */ "columnlist ::= column", - /* 117 */ "column ::= ids typename", - /* 118 */ "tagitemlist ::= tagitemlist COMMA tagitem", - /* 119 */ "tagitemlist ::= tagitem", - /* 120 */ "tagitem ::= INTEGER", - /* 121 */ "tagitem ::= FLOAT", - /* 122 */ "tagitem ::= STRING", - /* 123 */ "tagitem ::= BOOL", - /* 124 */ "tagitem ::= NULL", - /* 125 */ "tagitem ::= MINUS INTEGER", - /* 126 */ "tagitem ::= MINUS FLOAT", - /* 127 */ "tagitem ::= PLUS INTEGER", - /* 128 */ "tagitem ::= PLUS FLOAT", - /* 129 */ "select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt", - /* 130 */ "union ::= select", - /* 131 */ "union ::= LP union RP", - /* 132 */ "union ::= union UNION ALL select", - /* 133 */ "union ::= union UNION ALL LP select RP", - /* 134 */ "cmd ::= union", - /* 135 */ "select ::= SELECT selcollist", - /* 136 */ "sclp ::= selcollist COMMA", - /* 137 */ "sclp ::=", - /* 138 */ "selcollist ::= sclp expr as", - /* 139 */ "selcollist ::= sclp STAR", - /* 140 */ "as ::= AS ids", - /* 141 */ "as ::= ids", - /* 142 */ "as ::=", - /* 143 */ "from ::= FROM tablelist", - /* 144 */ "tablelist ::= ids cpxName", - /* 145 */ "tablelist ::= ids cpxName ids", - /* 146 */ "tablelist ::= tablelist COMMA ids cpxName", - /* 147 */ "tablelist ::= tablelist COMMA ids cpxName ids", - /* 148 */ "tmvar ::= VARIABLE", - /* 149 */ "interval_opt ::= INTERVAL LP tmvar RP", - /* 150 */ "interval_opt ::=", - /* 151 */ "fill_opt ::=", - /* 152 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", - /* 153 */ "fill_opt ::= FILL LP ID RP", - /* 154 */ "sliding_opt ::= SLIDING LP tmvar RP", - /* 155 */ "sliding_opt ::=", - /* 156 */ "orderby_opt ::=", - /* 157 */ "orderby_opt ::= ORDER BY sortlist", - /* 158 */ "sortlist ::= sortlist COMMA item sortorder", - /* 159 */ "sortlist ::= item sortorder", - /* 160 */ "item ::= ids cpxName", - /* 161 */ "sortorder ::= ASC", - /* 162 */ "sortorder ::= DESC", - /* 163 */ "sortorder ::=", - /* 164 */ "groupby_opt ::=", - /* 165 */ "groupby_opt ::= GROUP BY grouplist", - /* 166 */ "grouplist ::= grouplist COMMA item", - /* 167 */ "grouplist ::= item", - /* 168 */ "having_opt ::=", - /* 169 */ "having_opt ::= HAVING expr", - /* 170 */ "limit_opt ::=", - /* 171 */ "limit_opt ::= LIMIT signed", - /* 172 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 173 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 174 */ "slimit_opt ::=", - /* 175 */ "slimit_opt ::= SLIMIT signed", - /* 176 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", - /* 177 */ "slimit_opt ::= SLIMIT signed COMMA signed", - /* 178 */ "where_opt ::=", - /* 179 */ "where_opt ::= WHERE expr", - /* 180 */ "expr ::= LP expr RP", - /* 181 */ "expr ::= ID", - /* 182 */ "expr ::= ID DOT ID", - /* 183 */ "expr ::= ID DOT STAR", - /* 184 */ "expr ::= INTEGER", - /* 185 */ "expr ::= MINUS INTEGER", - /* 186 */ "expr ::= PLUS INTEGER", - /* 187 */ "expr ::= FLOAT", - /* 188 */ "expr ::= MINUS FLOAT", - /* 189 */ "expr ::= PLUS FLOAT", - /* 190 */ "expr ::= STRING", - /* 191 */ "expr ::= NOW", - /* 192 */ "expr ::= VARIABLE", - /* 193 */ "expr ::= BOOL", - /* 194 */ "expr ::= ID LP exprlist RP", - /* 195 */ "expr ::= ID LP STAR RP", - /* 196 */ "expr ::= expr AND expr", - /* 197 */ "expr ::= expr OR expr", - /* 198 */ "expr ::= expr LT expr", - /* 199 */ "expr ::= expr GT expr", - /* 200 */ "expr ::= expr LE expr", - /* 201 */ "expr ::= expr GE expr", - /* 202 */ "expr ::= expr NE expr", - /* 203 */ "expr ::= expr EQ expr", - /* 204 */ "expr ::= expr PLUS expr", - /* 205 */ "expr ::= expr MINUS expr", - /* 206 */ "expr ::= expr STAR expr", - /* 207 */ "expr ::= expr SLASH expr", - /* 208 */ "expr ::= expr REM expr", - /* 209 */ "expr ::= expr LIKE expr", - /* 210 */ "expr ::= expr IN LP exprlist RP", - /* 211 */ "exprlist ::= exprlist COMMA expritem", - /* 212 */ "exprlist ::= expritem", - /* 213 */ "expritem ::= expr", - /* 214 */ "expritem ::=", - /* 215 */ "cmd ::= RESET QUERY CACHE", - /* 216 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 217 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 218 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 219 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 220 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 221 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 222 */ "cmd ::= KILL CONNECTION INTEGER", - /* 223 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 224 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 19 */ "cmd ::= SHOW CREATE TABLE ids cpxName", + /* 20 */ "cmd ::= SHOW CREATE DATABASE ids", + /* 21 */ "cmd ::= SHOW dbPrefix TABLES", + /* 22 */ "cmd ::= SHOW dbPrefix TABLES LIKE ids", + /* 23 */ "cmd ::= SHOW dbPrefix STABLES", + /* 24 */ "cmd ::= SHOW dbPrefix STABLES LIKE ids", + /* 25 */ "cmd ::= SHOW dbPrefix VGROUPS", + /* 26 */ "cmd ::= SHOW dbPrefix VGROUPS ids", + /* 27 */ "cmd ::= DROP TABLE ifexists ids cpxName", + /* 28 */ "cmd ::= DROP DATABASE ifexists ids", + /* 29 */ "cmd ::= DROP DNODE ids", + /* 30 */ "cmd ::= DROP USER ids", + /* 31 */ "cmd ::= DROP ACCOUNT ids", + /* 32 */ "cmd ::= USE ids", + /* 33 */ "cmd ::= DESCRIBE ids cpxName", + /* 34 */ "cmd ::= ALTER USER ids PASS ids", + /* 35 */ "cmd ::= ALTER USER ids PRIVILEGE ids", + /* 36 */ "cmd ::= ALTER DNODE ids ids", + /* 37 */ "cmd ::= ALTER DNODE ids ids ids", + /* 38 */ "cmd ::= ALTER LOCAL ids", + /* 39 */ "cmd ::= ALTER LOCAL ids ids", + /* 40 */ "cmd ::= ALTER DATABASE ids alter_db_optr", + /* 41 */ "cmd ::= ALTER ACCOUNT ids acct_optr", + /* 42 */ "cmd ::= ALTER ACCOUNT ids PASS ids acct_optr", + /* 43 */ "ids ::= ID", + /* 44 */ "ids ::= STRING", + /* 45 */ "ifexists ::= IF EXISTS", + /* 46 */ "ifexists ::=", + /* 47 */ "ifnotexists ::= IF NOT EXISTS", + /* 48 */ "ifnotexists ::=", + /* 49 */ "cmd ::= CREATE DNODE ids", + /* 50 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr", + /* 51 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr", + /* 52 */ "cmd ::= CREATE USER ids PASS ids", + /* 53 */ "pps ::=", + /* 54 */ "pps ::= PPS INTEGER", + /* 55 */ "tseries ::=", + /* 56 */ "tseries ::= TSERIES INTEGER", + /* 57 */ "dbs ::=", + /* 58 */ "dbs ::= DBS INTEGER", + /* 59 */ "streams ::=", + /* 60 */ "streams ::= STREAMS INTEGER", + /* 61 */ "storage ::=", + /* 62 */ "storage ::= STORAGE INTEGER", + /* 63 */ "qtime ::=", + /* 64 */ "qtime ::= QTIME INTEGER", + /* 65 */ "users ::=", + /* 66 */ "users ::= USERS INTEGER", + /* 67 */ "conns ::=", + /* 68 */ "conns ::= CONNS INTEGER", + /* 69 */ "state ::=", + /* 70 */ "state ::= STATE ids", + /* 71 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state", + /* 72 */ "keep ::= KEEP tagitemlist", + /* 73 */ "cache ::= CACHE INTEGER", + /* 74 */ "replica ::= REPLICA INTEGER", + /* 75 */ "quorum ::= QUORUM INTEGER", + /* 76 */ "days ::= DAYS INTEGER", + /* 77 */ "minrows ::= MINROWS INTEGER", + /* 78 */ "maxrows ::= MAXROWS INTEGER", + /* 79 */ "blocks ::= BLOCKS INTEGER", + /* 80 */ "ctime ::= CTIME INTEGER", + /* 81 */ "wal ::= WAL INTEGER", + /* 82 */ "fsync ::= FSYNC INTEGER", + /* 83 */ "comp ::= COMP INTEGER", + /* 84 */ "prec ::= PRECISION STRING", + /* 85 */ "db_optr ::=", + /* 86 */ "db_optr ::= db_optr cache", + /* 87 */ "db_optr ::= db_optr replica", + /* 88 */ "db_optr ::= db_optr quorum", + /* 89 */ "db_optr ::= db_optr days", + /* 90 */ "db_optr ::= db_optr minrows", + /* 91 */ "db_optr ::= db_optr maxrows", + /* 92 */ "db_optr ::= db_optr blocks", + /* 93 */ "db_optr ::= db_optr ctime", + /* 94 */ "db_optr ::= db_optr wal", + /* 95 */ "db_optr ::= db_optr fsync", + /* 96 */ "db_optr ::= db_optr comp", + /* 97 */ "db_optr ::= db_optr prec", + /* 98 */ "db_optr ::= db_optr keep", + /* 99 */ "alter_db_optr ::=", + /* 100 */ "alter_db_optr ::= alter_db_optr replica", + /* 101 */ "alter_db_optr ::= alter_db_optr quorum", + /* 102 */ "alter_db_optr ::= alter_db_optr keep", + /* 103 */ "alter_db_optr ::= alter_db_optr blocks", + /* 104 */ "alter_db_optr ::= alter_db_optr comp", + /* 105 */ "alter_db_optr ::= alter_db_optr wal", + /* 106 */ "alter_db_optr ::= alter_db_optr fsync", + /* 107 */ "typename ::= ids", + /* 108 */ "typename ::= ids LP signed RP", + /* 109 */ "signed ::= INTEGER", + /* 110 */ "signed ::= PLUS INTEGER", + /* 111 */ "signed ::= MINUS INTEGER", + /* 112 */ "cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args", + /* 113 */ "create_table_args ::= LP columnlist RP", + /* 114 */ "create_table_args ::= LP columnlist RP TAGS LP columnlist RP", + /* 115 */ "create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP", + /* 116 */ "create_table_args ::= AS select", + /* 117 */ "columnlist ::= columnlist COMMA column", + /* 118 */ "columnlist ::= column", + /* 119 */ "column ::= ids typename", + /* 120 */ "tagitemlist ::= tagitemlist COMMA tagitem", + /* 121 */ "tagitemlist ::= tagitem", + /* 122 */ "tagitem ::= INTEGER", + /* 123 */ "tagitem ::= FLOAT", + /* 124 */ "tagitem ::= STRING", + /* 125 */ "tagitem ::= BOOL", + /* 126 */ "tagitem ::= NULL", + /* 127 */ "tagitem ::= MINUS INTEGER", + /* 128 */ "tagitem ::= MINUS FLOAT", + /* 129 */ "tagitem ::= PLUS INTEGER", + /* 130 */ "tagitem ::= PLUS FLOAT", + /* 131 */ "select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt", + /* 132 */ "union ::= select", + /* 133 */ "union ::= LP union RP", + /* 134 */ "union ::= union UNION ALL select", + /* 135 */ "union ::= union UNION ALL LP select RP", + /* 136 */ "cmd ::= union", + /* 137 */ "select ::= SELECT selcollist", + /* 138 */ "sclp ::= selcollist COMMA", + /* 139 */ "sclp ::=", + /* 140 */ "selcollist ::= sclp expr as", + /* 141 */ "selcollist ::= sclp STAR", + /* 142 */ "as ::= AS ids", + /* 143 */ "as ::= ids", + /* 144 */ "as ::=", + /* 145 */ "from ::= FROM tablelist", + /* 146 */ "tablelist ::= ids cpxName", + /* 147 */ "tablelist ::= ids cpxName ids", + /* 148 */ "tablelist ::= tablelist COMMA ids cpxName", + /* 149 */ "tablelist ::= tablelist COMMA ids cpxName ids", + /* 150 */ "tmvar ::= VARIABLE", + /* 151 */ "interval_opt ::= INTERVAL LP tmvar RP", + /* 152 */ "interval_opt ::=", + /* 153 */ "fill_opt ::=", + /* 154 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", + /* 155 */ "fill_opt ::= FILL LP ID RP", + /* 156 */ "sliding_opt ::= SLIDING LP tmvar RP", + /* 157 */ "sliding_opt ::=", + /* 158 */ "orderby_opt ::=", + /* 159 */ "orderby_opt ::= ORDER BY sortlist", + /* 160 */ "sortlist ::= sortlist COMMA item sortorder", + /* 161 */ "sortlist ::= item sortorder", + /* 162 */ "item ::= ids cpxName", + /* 163 */ "sortorder ::= ASC", + /* 164 */ "sortorder ::= DESC", + /* 165 */ "sortorder ::=", + /* 166 */ "groupby_opt ::=", + /* 167 */ "groupby_opt ::= GROUP BY grouplist", + /* 168 */ "grouplist ::= grouplist COMMA item", + /* 169 */ "grouplist ::= item", + /* 170 */ "having_opt ::=", + /* 171 */ "having_opt ::= HAVING expr", + /* 172 */ "limit_opt ::=", + /* 173 */ "limit_opt ::= LIMIT signed", + /* 174 */ "limit_opt ::= LIMIT signed OFFSET signed", + /* 175 */ "limit_opt ::= LIMIT signed COMMA signed", + /* 176 */ "slimit_opt ::=", + /* 177 */ "slimit_opt ::= SLIMIT signed", + /* 178 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", + /* 179 */ "slimit_opt ::= SLIMIT signed COMMA signed", + /* 180 */ "where_opt ::=", + /* 181 */ "where_opt ::= WHERE expr", + /* 182 */ "expr ::= LP expr RP", + /* 183 */ "expr ::= ID", + /* 184 */ "expr ::= ID DOT ID", + /* 185 */ "expr ::= ID DOT STAR", + /* 186 */ "expr ::= INTEGER", + /* 187 */ "expr ::= MINUS INTEGER", + /* 188 */ "expr ::= PLUS INTEGER", + /* 189 */ "expr ::= FLOAT", + /* 190 */ "expr ::= MINUS FLOAT", + /* 191 */ "expr ::= PLUS FLOAT", + /* 192 */ "expr ::= STRING", + /* 193 */ "expr ::= NOW", + /* 194 */ "expr ::= VARIABLE", + /* 195 */ "expr ::= BOOL", + /* 196 */ "expr ::= ID LP exprlist RP", + /* 197 */ "expr ::= ID LP STAR RP", + /* 198 */ "expr ::= expr AND expr", + /* 199 */ "expr ::= expr OR expr", + /* 200 */ "expr ::= expr LT expr", + /* 201 */ "expr ::= expr GT expr", + /* 202 */ "expr ::= expr LE expr", + /* 203 */ "expr ::= expr GE expr", + /* 204 */ "expr ::= expr NE expr", + /* 205 */ "expr ::= expr EQ expr", + /* 206 */ "expr ::= expr PLUS expr", + /* 207 */ "expr ::= expr MINUS expr", + /* 208 */ "expr ::= expr STAR expr", + /* 209 */ "expr ::= expr SLASH expr", + /* 210 */ "expr ::= expr REM expr", + /* 211 */ "expr ::= expr LIKE expr", + /* 212 */ "expr ::= expr IN LP exprlist RP", + /* 213 */ "exprlist ::= exprlist COMMA expritem", + /* 214 */ "exprlist ::= expritem", + /* 215 */ "expritem ::= expr", + /* 216 */ "expritem ::=", + /* 217 */ "cmd ::= RESET QUERY CACHE", + /* 218 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 219 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 220 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 221 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 222 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 223 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 224 */ "cmd ::= KILL CONNECTION INTEGER", + /* 225 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 226 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1703,212 +1707,214 @@ static const struct { { 209, -2 }, /* (16) dbPrefix ::= ids DOT */ { 211, 0 }, /* (17) cpxName ::= */ { 211, -2 }, /* (18) cpxName ::= DOT ids */ - { 208, -3 }, /* (19) cmd ::= SHOW dbPrefix TABLES */ - { 208, -5 }, /* (20) cmd ::= SHOW dbPrefix TABLES LIKE ids */ - { 208, -3 }, /* (21) cmd ::= SHOW dbPrefix STABLES */ - { 208, -5 }, /* (22) cmd ::= SHOW dbPrefix STABLES LIKE ids */ - { 208, -3 }, /* (23) cmd ::= SHOW dbPrefix VGROUPS */ - { 208, -4 }, /* (24) cmd ::= SHOW dbPrefix VGROUPS ids */ - { 208, -5 }, /* (25) cmd ::= DROP TABLE ifexists ids cpxName */ - { 208, -4 }, /* (26) cmd ::= DROP DATABASE ifexists ids */ - { 208, -3 }, /* (27) cmd ::= DROP DNODE ids */ - { 208, -3 }, /* (28) cmd ::= DROP USER ids */ - { 208, -3 }, /* (29) cmd ::= DROP ACCOUNT ids */ - { 208, -2 }, /* (30) cmd ::= USE ids */ - { 208, -3 }, /* (31) cmd ::= DESCRIBE ids cpxName */ - { 208, -5 }, /* (32) cmd ::= ALTER USER ids PASS ids */ - { 208, -5 }, /* (33) cmd ::= ALTER USER ids PRIVILEGE ids */ - { 208, -4 }, /* (34) cmd ::= ALTER DNODE ids ids */ - { 208, -5 }, /* (35) cmd ::= ALTER DNODE ids ids ids */ - { 208, -3 }, /* (36) cmd ::= ALTER LOCAL ids */ - { 208, -4 }, /* (37) cmd ::= ALTER LOCAL ids ids */ - { 208, -4 }, /* (38) cmd ::= ALTER DATABASE ids alter_db_optr */ - { 208, -4 }, /* (39) cmd ::= ALTER ACCOUNT ids acct_optr */ - { 208, -6 }, /* (40) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - { 210, -1 }, /* (41) ids ::= ID */ - { 210, -1 }, /* (42) ids ::= STRING */ - { 212, -2 }, /* (43) ifexists ::= IF EXISTS */ - { 212, 0 }, /* (44) ifexists ::= */ - { 215, -3 }, /* (45) ifnotexists ::= IF NOT EXISTS */ - { 215, 0 }, /* (46) ifnotexists ::= */ - { 208, -3 }, /* (47) cmd ::= CREATE DNODE ids */ - { 208, -6 }, /* (48) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - { 208, -5 }, /* (49) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - { 208, -5 }, /* (50) cmd ::= CREATE USER ids PASS ids */ - { 217, 0 }, /* (51) pps ::= */ - { 217, -2 }, /* (52) pps ::= PPS INTEGER */ - { 218, 0 }, /* (53) tseries ::= */ - { 218, -2 }, /* (54) tseries ::= TSERIES INTEGER */ - { 219, 0 }, /* (55) dbs ::= */ - { 219, -2 }, /* (56) dbs ::= DBS INTEGER */ - { 220, 0 }, /* (57) streams ::= */ - { 220, -2 }, /* (58) streams ::= STREAMS INTEGER */ - { 221, 0 }, /* (59) storage ::= */ - { 221, -2 }, /* (60) storage ::= STORAGE INTEGER */ - { 222, 0 }, /* (61) qtime ::= */ - { 222, -2 }, /* (62) qtime ::= QTIME INTEGER */ - { 223, 0 }, /* (63) users ::= */ - { 223, -2 }, /* (64) users ::= USERS INTEGER */ - { 224, 0 }, /* (65) conns ::= */ - { 224, -2 }, /* (66) conns ::= CONNS INTEGER */ - { 225, 0 }, /* (67) state ::= */ - { 225, -2 }, /* (68) state ::= STATE ids */ - { 214, -9 }, /* (69) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - { 226, -2 }, /* (70) keep ::= KEEP tagitemlist */ - { 228, -2 }, /* (71) cache ::= CACHE INTEGER */ - { 229, -2 }, /* (72) replica ::= REPLICA INTEGER */ - { 230, -2 }, /* (73) quorum ::= QUORUM INTEGER */ - { 231, -2 }, /* (74) days ::= DAYS INTEGER */ - { 232, -2 }, /* (75) minrows ::= MINROWS INTEGER */ - { 233, -2 }, /* (76) maxrows ::= MAXROWS INTEGER */ - { 234, -2 }, /* (77) blocks ::= BLOCKS INTEGER */ - { 235, -2 }, /* (78) ctime ::= CTIME INTEGER */ - { 236, -2 }, /* (79) wal ::= WAL INTEGER */ - { 237, -2 }, /* (80) fsync ::= FSYNC INTEGER */ - { 238, -2 }, /* (81) comp ::= COMP INTEGER */ - { 239, -2 }, /* (82) prec ::= PRECISION STRING */ - { 216, 0 }, /* (83) db_optr ::= */ - { 216, -2 }, /* (84) db_optr ::= db_optr cache */ - { 216, -2 }, /* (85) db_optr ::= db_optr replica */ - { 216, -2 }, /* (86) db_optr ::= db_optr quorum */ - { 216, -2 }, /* (87) db_optr ::= db_optr days */ - { 216, -2 }, /* (88) db_optr ::= db_optr minrows */ - { 216, -2 }, /* (89) db_optr ::= db_optr maxrows */ - { 216, -2 }, /* (90) db_optr ::= db_optr blocks */ - { 216, -2 }, /* (91) db_optr ::= db_optr ctime */ - { 216, -2 }, /* (92) db_optr ::= db_optr wal */ - { 216, -2 }, /* (93) db_optr ::= db_optr fsync */ - { 216, -2 }, /* (94) db_optr ::= db_optr comp */ - { 216, -2 }, /* (95) db_optr ::= db_optr prec */ - { 216, -2 }, /* (96) db_optr ::= db_optr keep */ - { 213, 0 }, /* (97) alter_db_optr ::= */ - { 213, -2 }, /* (98) alter_db_optr ::= alter_db_optr replica */ - { 213, -2 }, /* (99) alter_db_optr ::= alter_db_optr quorum */ - { 213, -2 }, /* (100) alter_db_optr ::= alter_db_optr keep */ - { 213, -2 }, /* (101) alter_db_optr ::= alter_db_optr blocks */ - { 213, -2 }, /* (102) alter_db_optr ::= alter_db_optr comp */ - { 213, -2 }, /* (103) alter_db_optr ::= alter_db_optr wal */ - { 213, -2 }, /* (104) alter_db_optr ::= alter_db_optr fsync */ - { 240, -1 }, /* (105) typename ::= ids */ - { 240, -4 }, /* (106) typename ::= ids LP signed RP */ - { 241, -1 }, /* (107) signed ::= INTEGER */ - { 241, -2 }, /* (108) signed ::= PLUS INTEGER */ - { 241, -2 }, /* (109) signed ::= MINUS INTEGER */ - { 208, -6 }, /* (110) cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */ - { 242, -3 }, /* (111) create_table_args ::= LP columnlist RP */ - { 242, -7 }, /* (112) create_table_args ::= LP columnlist RP TAGS LP columnlist RP */ - { 242, -7 }, /* (113) create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */ - { 242, -2 }, /* (114) create_table_args ::= AS select */ - { 243, -3 }, /* (115) columnlist ::= columnlist COMMA column */ - { 243, -1 }, /* (116) columnlist ::= column */ - { 245, -2 }, /* (117) column ::= ids typename */ - { 227, -3 }, /* (118) tagitemlist ::= tagitemlist COMMA tagitem */ - { 227, -1 }, /* (119) tagitemlist ::= tagitem */ - { 246, -1 }, /* (120) tagitem ::= INTEGER */ - { 246, -1 }, /* (121) tagitem ::= FLOAT */ - { 246, -1 }, /* (122) tagitem ::= STRING */ - { 246, -1 }, /* (123) tagitem ::= BOOL */ - { 246, -1 }, /* (124) tagitem ::= NULL */ - { 246, -2 }, /* (125) tagitem ::= MINUS INTEGER */ - { 246, -2 }, /* (126) tagitem ::= MINUS FLOAT */ - { 246, -2 }, /* (127) tagitem ::= PLUS INTEGER */ - { 246, -2 }, /* (128) tagitem ::= PLUS FLOAT */ - { 244, -12 }, /* (129) select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ - { 258, -1 }, /* (130) union ::= select */ - { 258, -3 }, /* (131) union ::= LP union RP */ - { 258, -4 }, /* (132) union ::= union UNION ALL select */ - { 258, -6 }, /* (133) union ::= union UNION ALL LP select RP */ - { 208, -1 }, /* (134) cmd ::= union */ - { 244, -2 }, /* (135) select ::= SELECT selcollist */ - { 259, -2 }, /* (136) sclp ::= selcollist COMMA */ - { 259, 0 }, /* (137) sclp ::= */ - { 247, -3 }, /* (138) selcollist ::= sclp expr as */ - { 247, -2 }, /* (139) selcollist ::= sclp STAR */ - { 261, -2 }, /* (140) as ::= AS ids */ - { 261, -1 }, /* (141) as ::= ids */ - { 261, 0 }, /* (142) as ::= */ - { 248, -2 }, /* (143) from ::= FROM tablelist */ - { 262, -2 }, /* (144) tablelist ::= ids cpxName */ - { 262, -3 }, /* (145) tablelist ::= ids cpxName ids */ - { 262, -4 }, /* (146) tablelist ::= tablelist COMMA ids cpxName */ - { 262, -5 }, /* (147) tablelist ::= tablelist COMMA ids cpxName ids */ - { 263, -1 }, /* (148) tmvar ::= VARIABLE */ - { 250, -4 }, /* (149) interval_opt ::= INTERVAL LP tmvar RP */ - { 250, 0 }, /* (150) interval_opt ::= */ - { 251, 0 }, /* (151) fill_opt ::= */ - { 251, -6 }, /* (152) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - { 251, -4 }, /* (153) fill_opt ::= FILL LP ID RP */ - { 252, -4 }, /* (154) sliding_opt ::= SLIDING LP tmvar RP */ - { 252, 0 }, /* (155) sliding_opt ::= */ - { 254, 0 }, /* (156) orderby_opt ::= */ - { 254, -3 }, /* (157) orderby_opt ::= ORDER BY sortlist */ - { 264, -4 }, /* (158) sortlist ::= sortlist COMMA item sortorder */ - { 264, -2 }, /* (159) sortlist ::= item sortorder */ - { 266, -2 }, /* (160) item ::= ids cpxName */ - { 267, -1 }, /* (161) sortorder ::= ASC */ - { 267, -1 }, /* (162) sortorder ::= DESC */ - { 267, 0 }, /* (163) sortorder ::= */ - { 253, 0 }, /* (164) groupby_opt ::= */ - { 253, -3 }, /* (165) groupby_opt ::= GROUP BY grouplist */ - { 268, -3 }, /* (166) grouplist ::= grouplist COMMA item */ - { 268, -1 }, /* (167) grouplist ::= item */ - { 255, 0 }, /* (168) having_opt ::= */ - { 255, -2 }, /* (169) having_opt ::= HAVING expr */ - { 257, 0 }, /* (170) limit_opt ::= */ - { 257, -2 }, /* (171) limit_opt ::= LIMIT signed */ - { 257, -4 }, /* (172) limit_opt ::= LIMIT signed OFFSET signed */ - { 257, -4 }, /* (173) limit_opt ::= LIMIT signed COMMA signed */ - { 256, 0 }, /* (174) slimit_opt ::= */ - { 256, -2 }, /* (175) slimit_opt ::= SLIMIT signed */ - { 256, -4 }, /* (176) slimit_opt ::= SLIMIT signed SOFFSET signed */ - { 256, -4 }, /* (177) slimit_opt ::= SLIMIT signed COMMA signed */ - { 249, 0 }, /* (178) where_opt ::= */ - { 249, -2 }, /* (179) where_opt ::= WHERE expr */ - { 260, -3 }, /* (180) expr ::= LP expr RP */ - { 260, -1 }, /* (181) expr ::= ID */ - { 260, -3 }, /* (182) expr ::= ID DOT ID */ - { 260, -3 }, /* (183) expr ::= ID DOT STAR */ - { 260, -1 }, /* (184) expr ::= INTEGER */ - { 260, -2 }, /* (185) expr ::= MINUS INTEGER */ - { 260, -2 }, /* (186) expr ::= PLUS INTEGER */ - { 260, -1 }, /* (187) expr ::= FLOAT */ - { 260, -2 }, /* (188) expr ::= MINUS FLOAT */ - { 260, -2 }, /* (189) expr ::= PLUS FLOAT */ - { 260, -1 }, /* (190) expr ::= STRING */ - { 260, -1 }, /* (191) expr ::= NOW */ - { 260, -1 }, /* (192) expr ::= VARIABLE */ - { 260, -1 }, /* (193) expr ::= BOOL */ - { 260, -4 }, /* (194) expr ::= ID LP exprlist RP */ - { 260, -4 }, /* (195) expr ::= ID LP STAR RP */ - { 260, -3 }, /* (196) expr ::= expr AND expr */ - { 260, -3 }, /* (197) expr ::= expr OR expr */ - { 260, -3 }, /* (198) expr ::= expr LT expr */ - { 260, -3 }, /* (199) expr ::= expr GT expr */ - { 260, -3 }, /* (200) expr ::= expr LE expr */ - { 260, -3 }, /* (201) expr ::= expr GE expr */ - { 260, -3 }, /* (202) expr ::= expr NE expr */ - { 260, -3 }, /* (203) expr ::= expr EQ expr */ - { 260, -3 }, /* (204) expr ::= expr PLUS expr */ - { 260, -3 }, /* (205) expr ::= expr MINUS expr */ - { 260, -3 }, /* (206) expr ::= expr STAR expr */ - { 260, -3 }, /* (207) expr ::= expr SLASH expr */ - { 260, -3 }, /* (208) expr ::= expr REM expr */ - { 260, -3 }, /* (209) expr ::= expr LIKE expr */ - { 260, -5 }, /* (210) expr ::= expr IN LP exprlist RP */ - { 269, -3 }, /* (211) exprlist ::= exprlist COMMA expritem */ - { 269, -1 }, /* (212) exprlist ::= expritem */ - { 270, -1 }, /* (213) expritem ::= expr */ - { 270, 0 }, /* (214) expritem ::= */ - { 208, -3 }, /* (215) cmd ::= RESET QUERY CACHE */ - { 208, -7 }, /* (216) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - { 208, -7 }, /* (217) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - { 208, -7 }, /* (218) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - { 208, -7 }, /* (219) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - { 208, -8 }, /* (220) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - { 208, -9 }, /* (221) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - { 208, -3 }, /* (222) cmd ::= KILL CONNECTION INTEGER */ - { 208, -5 }, /* (223) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - { 208, -5 }, /* (224) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + { 208, -5 }, /* (19) cmd ::= SHOW CREATE TABLE ids cpxName */ + { 208, -4 }, /* (20) cmd ::= SHOW CREATE DATABASE ids */ + { 208, -3 }, /* (21) cmd ::= SHOW dbPrefix TABLES */ + { 208, -5 }, /* (22) cmd ::= SHOW dbPrefix TABLES LIKE ids */ + { 208, -3 }, /* (23) cmd ::= SHOW dbPrefix STABLES */ + { 208, -5 }, /* (24) cmd ::= SHOW dbPrefix STABLES LIKE ids */ + { 208, -3 }, /* (25) cmd ::= SHOW dbPrefix VGROUPS */ + { 208, -4 }, /* (26) cmd ::= SHOW dbPrefix VGROUPS ids */ + { 208, -5 }, /* (27) cmd ::= DROP TABLE ifexists ids cpxName */ + { 208, -4 }, /* (28) cmd ::= DROP DATABASE ifexists ids */ + { 208, -3 }, /* (29) cmd ::= DROP DNODE ids */ + { 208, -3 }, /* (30) cmd ::= DROP USER ids */ + { 208, -3 }, /* (31) cmd ::= DROP ACCOUNT ids */ + { 208, -2 }, /* (32) cmd ::= USE ids */ + { 208, -3 }, /* (33) cmd ::= DESCRIBE ids cpxName */ + { 208, -5 }, /* (34) cmd ::= ALTER USER ids PASS ids */ + { 208, -5 }, /* (35) cmd ::= ALTER USER ids PRIVILEGE ids */ + { 208, -4 }, /* (36) cmd ::= ALTER DNODE ids ids */ + { 208, -5 }, /* (37) cmd ::= ALTER DNODE ids ids ids */ + { 208, -3 }, /* (38) cmd ::= ALTER LOCAL ids */ + { 208, -4 }, /* (39) cmd ::= ALTER LOCAL ids ids */ + { 208, -4 }, /* (40) cmd ::= ALTER DATABASE ids alter_db_optr */ + { 208, -4 }, /* (41) cmd ::= ALTER ACCOUNT ids acct_optr */ + { 208, -6 }, /* (42) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ + { 210, -1 }, /* (43) ids ::= ID */ + { 210, -1 }, /* (44) ids ::= STRING */ + { 212, -2 }, /* (45) ifexists ::= IF EXISTS */ + { 212, 0 }, /* (46) ifexists ::= */ + { 215, -3 }, /* (47) ifnotexists ::= IF NOT EXISTS */ + { 215, 0 }, /* (48) ifnotexists ::= */ + { 208, -3 }, /* (49) cmd ::= CREATE DNODE ids */ + { 208, -6 }, /* (50) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + { 208, -5 }, /* (51) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + { 208, -5 }, /* (52) cmd ::= CREATE USER ids PASS ids */ + { 217, 0 }, /* (53) pps ::= */ + { 217, -2 }, /* (54) pps ::= PPS INTEGER */ + { 218, 0 }, /* (55) tseries ::= */ + { 218, -2 }, /* (56) tseries ::= TSERIES INTEGER */ + { 219, 0 }, /* (57) dbs ::= */ + { 219, -2 }, /* (58) dbs ::= DBS INTEGER */ + { 220, 0 }, /* (59) streams ::= */ + { 220, -2 }, /* (60) streams ::= STREAMS INTEGER */ + { 221, 0 }, /* (61) storage ::= */ + { 221, -2 }, /* (62) storage ::= STORAGE INTEGER */ + { 222, 0 }, /* (63) qtime ::= */ + { 222, -2 }, /* (64) qtime ::= QTIME INTEGER */ + { 223, 0 }, /* (65) users ::= */ + { 223, -2 }, /* (66) users ::= USERS INTEGER */ + { 224, 0 }, /* (67) conns ::= */ + { 224, -2 }, /* (68) conns ::= CONNS INTEGER */ + { 225, 0 }, /* (69) state ::= */ + { 225, -2 }, /* (70) state ::= STATE ids */ + { 214, -9 }, /* (71) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + { 226, -2 }, /* (72) keep ::= KEEP tagitemlist */ + { 228, -2 }, /* (73) cache ::= CACHE INTEGER */ + { 229, -2 }, /* (74) replica ::= REPLICA INTEGER */ + { 230, -2 }, /* (75) quorum ::= QUORUM INTEGER */ + { 231, -2 }, /* (76) days ::= DAYS INTEGER */ + { 232, -2 }, /* (77) minrows ::= MINROWS INTEGER */ + { 233, -2 }, /* (78) maxrows ::= MAXROWS INTEGER */ + { 234, -2 }, /* (79) blocks ::= BLOCKS INTEGER */ + { 235, -2 }, /* (80) ctime ::= CTIME INTEGER */ + { 236, -2 }, /* (81) wal ::= WAL INTEGER */ + { 237, -2 }, /* (82) fsync ::= FSYNC INTEGER */ + { 238, -2 }, /* (83) comp ::= COMP INTEGER */ + { 239, -2 }, /* (84) prec ::= PRECISION STRING */ + { 216, 0 }, /* (85) db_optr ::= */ + { 216, -2 }, /* (86) db_optr ::= db_optr cache */ + { 216, -2 }, /* (87) db_optr ::= db_optr replica */ + { 216, -2 }, /* (88) db_optr ::= db_optr quorum */ + { 216, -2 }, /* (89) db_optr ::= db_optr days */ + { 216, -2 }, /* (90) db_optr ::= db_optr minrows */ + { 216, -2 }, /* (91) db_optr ::= db_optr maxrows */ + { 216, -2 }, /* (92) db_optr ::= db_optr blocks */ + { 216, -2 }, /* (93) db_optr ::= db_optr ctime */ + { 216, -2 }, /* (94) db_optr ::= db_optr wal */ + { 216, -2 }, /* (95) db_optr ::= db_optr fsync */ + { 216, -2 }, /* (96) db_optr ::= db_optr comp */ + { 216, -2 }, /* (97) db_optr ::= db_optr prec */ + { 216, -2 }, /* (98) db_optr ::= db_optr keep */ + { 213, 0 }, /* (99) alter_db_optr ::= */ + { 213, -2 }, /* (100) alter_db_optr ::= alter_db_optr replica */ + { 213, -2 }, /* (101) alter_db_optr ::= alter_db_optr quorum */ + { 213, -2 }, /* (102) alter_db_optr ::= alter_db_optr keep */ + { 213, -2 }, /* (103) alter_db_optr ::= alter_db_optr blocks */ + { 213, -2 }, /* (104) alter_db_optr ::= alter_db_optr comp */ + { 213, -2 }, /* (105) alter_db_optr ::= alter_db_optr wal */ + { 213, -2 }, /* (106) alter_db_optr ::= alter_db_optr fsync */ + { 240, -1 }, /* (107) typename ::= ids */ + { 240, -4 }, /* (108) typename ::= ids LP signed RP */ + { 241, -1 }, /* (109) signed ::= INTEGER */ + { 241, -2 }, /* (110) signed ::= PLUS INTEGER */ + { 241, -2 }, /* (111) signed ::= MINUS INTEGER */ + { 208, -6 }, /* (112) cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */ + { 242, -3 }, /* (113) create_table_args ::= LP columnlist RP */ + { 242, -7 }, /* (114) create_table_args ::= LP columnlist RP TAGS LP columnlist RP */ + { 242, -7 }, /* (115) create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */ + { 242, -2 }, /* (116) create_table_args ::= AS select */ + { 243, -3 }, /* (117) columnlist ::= columnlist COMMA column */ + { 243, -1 }, /* (118) columnlist ::= column */ + { 245, -2 }, /* (119) column ::= ids typename */ + { 227, -3 }, /* (120) tagitemlist ::= tagitemlist COMMA tagitem */ + { 227, -1 }, /* (121) tagitemlist ::= tagitem */ + { 246, -1 }, /* (122) tagitem ::= INTEGER */ + { 246, -1 }, /* (123) tagitem ::= FLOAT */ + { 246, -1 }, /* (124) tagitem ::= STRING */ + { 246, -1 }, /* (125) tagitem ::= BOOL */ + { 246, -1 }, /* (126) tagitem ::= NULL */ + { 246, -2 }, /* (127) tagitem ::= MINUS INTEGER */ + { 246, -2 }, /* (128) tagitem ::= MINUS FLOAT */ + { 246, -2 }, /* (129) tagitem ::= PLUS INTEGER */ + { 246, -2 }, /* (130) tagitem ::= PLUS FLOAT */ + { 244, -12 }, /* (131) select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ + { 258, -1 }, /* (132) union ::= select */ + { 258, -3 }, /* (133) union ::= LP union RP */ + { 258, -4 }, /* (134) union ::= union UNION ALL select */ + { 258, -6 }, /* (135) union ::= union UNION ALL LP select RP */ + { 208, -1 }, /* (136) cmd ::= union */ + { 244, -2 }, /* (137) select ::= SELECT selcollist */ + { 259, -2 }, /* (138) sclp ::= selcollist COMMA */ + { 259, 0 }, /* (139) sclp ::= */ + { 247, -3 }, /* (140) selcollist ::= sclp expr as */ + { 247, -2 }, /* (141) selcollist ::= sclp STAR */ + { 261, -2 }, /* (142) as ::= AS ids */ + { 261, -1 }, /* (143) as ::= ids */ + { 261, 0 }, /* (144) as ::= */ + { 248, -2 }, /* (145) from ::= FROM tablelist */ + { 262, -2 }, /* (146) tablelist ::= ids cpxName */ + { 262, -3 }, /* (147) tablelist ::= ids cpxName ids */ + { 262, -4 }, /* (148) tablelist ::= tablelist COMMA ids cpxName */ + { 262, -5 }, /* (149) tablelist ::= tablelist COMMA ids cpxName ids */ + { 263, -1 }, /* (150) tmvar ::= VARIABLE */ + { 250, -4 }, /* (151) interval_opt ::= INTERVAL LP tmvar RP */ + { 250, 0 }, /* (152) interval_opt ::= */ + { 251, 0 }, /* (153) fill_opt ::= */ + { 251, -6 }, /* (154) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + { 251, -4 }, /* (155) fill_opt ::= FILL LP ID RP */ + { 252, -4 }, /* (156) sliding_opt ::= SLIDING LP tmvar RP */ + { 252, 0 }, /* (157) sliding_opt ::= */ + { 254, 0 }, /* (158) orderby_opt ::= */ + { 254, -3 }, /* (159) orderby_opt ::= ORDER BY sortlist */ + { 264, -4 }, /* (160) sortlist ::= sortlist COMMA item sortorder */ + { 264, -2 }, /* (161) sortlist ::= item sortorder */ + { 266, -2 }, /* (162) item ::= ids cpxName */ + { 267, -1 }, /* (163) sortorder ::= ASC */ + { 267, -1 }, /* (164) sortorder ::= DESC */ + { 267, 0 }, /* (165) sortorder ::= */ + { 253, 0 }, /* (166) groupby_opt ::= */ + { 253, -3 }, /* (167) groupby_opt ::= GROUP BY grouplist */ + { 268, -3 }, /* (168) grouplist ::= grouplist COMMA item */ + { 268, -1 }, /* (169) grouplist ::= item */ + { 255, 0 }, /* (170) having_opt ::= */ + { 255, -2 }, /* (171) having_opt ::= HAVING expr */ + { 257, 0 }, /* (172) limit_opt ::= */ + { 257, -2 }, /* (173) limit_opt ::= LIMIT signed */ + { 257, -4 }, /* (174) limit_opt ::= LIMIT signed OFFSET signed */ + { 257, -4 }, /* (175) limit_opt ::= LIMIT signed COMMA signed */ + { 256, 0 }, /* (176) slimit_opt ::= */ + { 256, -2 }, /* (177) slimit_opt ::= SLIMIT signed */ + { 256, -4 }, /* (178) slimit_opt ::= SLIMIT signed SOFFSET signed */ + { 256, -4 }, /* (179) slimit_opt ::= SLIMIT signed COMMA signed */ + { 249, 0 }, /* (180) where_opt ::= */ + { 249, -2 }, /* (181) where_opt ::= WHERE expr */ + { 260, -3 }, /* (182) expr ::= LP expr RP */ + { 260, -1 }, /* (183) expr ::= ID */ + { 260, -3 }, /* (184) expr ::= ID DOT ID */ + { 260, -3 }, /* (185) expr ::= ID DOT STAR */ + { 260, -1 }, /* (186) expr ::= INTEGER */ + { 260, -2 }, /* (187) expr ::= MINUS INTEGER */ + { 260, -2 }, /* (188) expr ::= PLUS INTEGER */ + { 260, -1 }, /* (189) expr ::= FLOAT */ + { 260, -2 }, /* (190) expr ::= MINUS FLOAT */ + { 260, -2 }, /* (191) expr ::= PLUS FLOAT */ + { 260, -1 }, /* (192) expr ::= STRING */ + { 260, -1 }, /* (193) expr ::= NOW */ + { 260, -1 }, /* (194) expr ::= VARIABLE */ + { 260, -1 }, /* (195) expr ::= BOOL */ + { 260, -4 }, /* (196) expr ::= ID LP exprlist RP */ + { 260, -4 }, /* (197) expr ::= ID LP STAR RP */ + { 260, -3 }, /* (198) expr ::= expr AND expr */ + { 260, -3 }, /* (199) expr ::= expr OR expr */ + { 260, -3 }, /* (200) expr ::= expr LT expr */ + { 260, -3 }, /* (201) expr ::= expr GT expr */ + { 260, -3 }, /* (202) expr ::= expr LE expr */ + { 260, -3 }, /* (203) expr ::= expr GE expr */ + { 260, -3 }, /* (204) expr ::= expr NE expr */ + { 260, -3 }, /* (205) expr ::= expr EQ expr */ + { 260, -3 }, /* (206) expr ::= expr PLUS expr */ + { 260, -3 }, /* (207) expr ::= expr MINUS expr */ + { 260, -3 }, /* (208) expr ::= expr STAR expr */ + { 260, -3 }, /* (209) expr ::= expr SLASH expr */ + { 260, -3 }, /* (210) expr ::= expr REM expr */ + { 260, -3 }, /* (211) expr ::= expr LIKE expr */ + { 260, -5 }, /* (212) expr ::= expr IN LP exprlist RP */ + { 269, -3 }, /* (213) exprlist ::= exprlist COMMA expritem */ + { 269, -1 }, /* (214) exprlist ::= expritem */ + { 270, -1 }, /* (215) expritem ::= expr */ + { 270, 0 }, /* (216) expritem ::= */ + { 208, -3 }, /* (217) cmd ::= RESET QUERY CACHE */ + { 208, -7 }, /* (218) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + { 208, -7 }, /* (219) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + { 208, -7 }, /* (220) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + { 208, -7 }, /* (221) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + { 208, -8 }, /* (222) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + { 208, -9 }, /* (223) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + { 208, -3 }, /* (224) cmd ::= KILL CONNECTION INTEGER */ + { 208, -5 }, /* (225) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + { 208, -5 }, /* (226) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2046,146 +2052,157 @@ static void yy_reduce( case 18: /* cpxName ::= DOT ids */ {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n += 1; } break; - case 19: /* cmd ::= SHOW dbPrefix TABLES */ + case 19: /* cmd ::= SHOW CREATE TABLE ids cpxName */ +{ + yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; + setDCLSQLElems(pInfo, TSDB_SQL_SHOW_CREATE_TABLE, 1, &yymsp[-1].minor.yy0); +} + break; + case 20: /* cmd ::= SHOW CREATE DATABASE ids */ +{ + setDCLSQLElems(pInfo, TSDB_SQL_SHOW_CREATE_DATABASE, 1, &yymsp[0].minor.yy0); +} + break; + case 21: /* cmd ::= SHOW dbPrefix TABLES */ { setShowOptions(pInfo, TSDB_MGMT_TABLE_TABLE, &yymsp[-1].minor.yy0, 0); } break; - case 20: /* cmd ::= SHOW dbPrefix TABLES LIKE ids */ + case 22: /* cmd ::= SHOW dbPrefix TABLES LIKE ids */ { setShowOptions(pInfo, TSDB_MGMT_TABLE_TABLE, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0); } break; - case 21: /* cmd ::= SHOW dbPrefix STABLES */ + case 23: /* cmd ::= SHOW dbPrefix STABLES */ { setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &yymsp[-1].minor.yy0, 0); } break; - case 22: /* cmd ::= SHOW dbPrefix STABLES LIKE ids */ + case 24: /* cmd ::= SHOW dbPrefix STABLES LIKE ids */ { SStrToken token; setDBName(&token, &yymsp[-3].minor.yy0); setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &token, &yymsp[0].minor.yy0); } break; - case 23: /* cmd ::= SHOW dbPrefix VGROUPS */ + case 25: /* cmd ::= SHOW dbPrefix VGROUPS */ { SStrToken token; setDBName(&token, &yymsp[-1].minor.yy0); setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, 0); } break; - case 24: /* cmd ::= SHOW dbPrefix VGROUPS ids */ + case 26: /* cmd ::= SHOW dbPrefix VGROUPS ids */ { SStrToken token; setDBName(&token, &yymsp[-2].minor.yy0); setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, &yymsp[0].minor.yy0); } break; - case 25: /* cmd ::= DROP TABLE ifexists ids cpxName */ + case 27: /* cmd ::= DROP TABLE ifexists ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; setDropDBTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &yymsp[-1].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 26: /* cmd ::= DROP DATABASE ifexists ids */ + case 28: /* cmd ::= DROP DATABASE ifexists ids */ { setDropDBTableInfo(pInfo, TSDB_SQL_DROP_DB, &yymsp[0].minor.yy0, &yymsp[-1].minor.yy0); } break; - case 27: /* cmd ::= DROP DNODE ids */ + case 29: /* cmd ::= DROP DNODE ids */ { setDCLSQLElems(pInfo, TSDB_SQL_DROP_DNODE, 1, &yymsp[0].minor.yy0); } break; - case 28: /* cmd ::= DROP USER ids */ + case 30: /* cmd ::= DROP USER ids */ { setDCLSQLElems(pInfo, TSDB_SQL_DROP_USER, 1, &yymsp[0].minor.yy0); } break; - case 29: /* cmd ::= DROP ACCOUNT ids */ + case 31: /* cmd ::= DROP ACCOUNT ids */ { setDCLSQLElems(pInfo, TSDB_SQL_DROP_ACCT, 1, &yymsp[0].minor.yy0); } break; - case 30: /* cmd ::= USE ids */ + case 32: /* cmd ::= USE ids */ { setDCLSQLElems(pInfo, TSDB_SQL_USE_DB, 1, &yymsp[0].minor.yy0);} break; - case 31: /* cmd ::= DESCRIBE ids cpxName */ + case 33: /* cmd ::= DESCRIBE ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; setDCLSQLElems(pInfo, TSDB_SQL_DESCRIBE_TABLE, 1, &yymsp[-1].minor.yy0); } break; - case 32: /* cmd ::= ALTER USER ids PASS ids */ + case 34: /* cmd ::= ALTER USER ids PASS ids */ { setAlterUserSQL(pInfo, TSDB_ALTER_USER_PASSWD, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, NULL); } break; - case 33: /* cmd ::= ALTER USER ids PRIVILEGE ids */ + case 35: /* cmd ::= ALTER USER ids PRIVILEGE ids */ { setAlterUserSQL(pInfo, TSDB_ALTER_USER_PRIVILEGES, &yymsp[-2].minor.yy0, NULL, &yymsp[0].minor.yy0);} break; - case 34: /* cmd ::= ALTER DNODE ids ids */ + case 36: /* cmd ::= ALTER DNODE ids ids */ { setDCLSQLElems(pInfo, TSDB_SQL_CFG_DNODE, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 35: /* cmd ::= ALTER DNODE ids ids ids */ + case 37: /* cmd ::= ALTER DNODE ids ids ids */ { setDCLSQLElems(pInfo, TSDB_SQL_CFG_DNODE, 3, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 36: /* cmd ::= ALTER LOCAL ids */ + case 38: /* cmd ::= ALTER LOCAL ids */ { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 1, &yymsp[0].minor.yy0); } break; - case 37: /* cmd ::= ALTER LOCAL ids ids */ + case 39: /* cmd ::= ALTER LOCAL ids ids */ { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 38: /* cmd ::= ALTER DATABASE ids alter_db_optr */ + case 40: /* cmd ::= ALTER DATABASE ids alter_db_optr */ { SStrToken t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy158, &t);} break; - case 39: /* cmd ::= ALTER ACCOUNT ids acct_optr */ + case 41: /* cmd ::= ALTER ACCOUNT ids acct_optr */ { setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy73);} break; - case 40: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ + case 42: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ { setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy73);} break; - case 41: /* ids ::= ID */ - case 42: /* ids ::= STRING */ yytestcase(yyruleno==42); + case 43: /* ids ::= ID */ + case 44: /* ids ::= STRING */ yytestcase(yyruleno==44); {yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 43: /* ifexists ::= IF EXISTS */ + case 45: /* ifexists ::= IF EXISTS */ {yymsp[-1].minor.yy0.n = 1;} break; - case 44: /* ifexists ::= */ - case 46: /* ifnotexists ::= */ yytestcase(yyruleno==46); + case 46: /* ifexists ::= */ + case 48: /* ifnotexists ::= */ yytestcase(yyruleno==48); {yymsp[1].minor.yy0.n = 0;} break; - case 45: /* ifnotexists ::= IF NOT EXISTS */ + case 47: /* ifnotexists ::= IF NOT EXISTS */ {yymsp[-2].minor.yy0.n = 1;} break; - case 47: /* cmd ::= CREATE DNODE ids */ + case 49: /* cmd ::= CREATE DNODE ids */ { setDCLSQLElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);} break; - case 48: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + case 50: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ { setCreateAcctSQL(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy73);} break; - case 49: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + case 51: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ { setCreateDBSQL(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy158, &yymsp[-2].minor.yy0);} break; - case 50: /* cmd ::= CREATE USER ids PASS ids */ + case 52: /* cmd ::= CREATE USER ids PASS ids */ { setCreateUserSQL(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} break; - case 51: /* pps ::= */ - case 53: /* tseries ::= */ yytestcase(yyruleno==53); - case 55: /* dbs ::= */ yytestcase(yyruleno==55); - case 57: /* streams ::= */ yytestcase(yyruleno==57); - case 59: /* storage ::= */ yytestcase(yyruleno==59); - case 61: /* qtime ::= */ yytestcase(yyruleno==61); - case 63: /* users ::= */ yytestcase(yyruleno==63); - case 65: /* conns ::= */ yytestcase(yyruleno==65); - case 67: /* state ::= */ yytestcase(yyruleno==67); + case 53: /* pps ::= */ + case 55: /* tseries ::= */ yytestcase(yyruleno==55); + case 57: /* dbs ::= */ yytestcase(yyruleno==57); + case 59: /* streams ::= */ yytestcase(yyruleno==59); + case 61: /* storage ::= */ yytestcase(yyruleno==61); + case 63: /* qtime ::= */ yytestcase(yyruleno==63); + case 65: /* users ::= */ yytestcase(yyruleno==65); + case 67: /* conns ::= */ yytestcase(yyruleno==67); + case 69: /* state ::= */ yytestcase(yyruleno==69); {yymsp[1].minor.yy0.n = 0; } break; - case 52: /* pps ::= PPS INTEGER */ - case 54: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==54); - case 56: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==56); - case 58: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==58); - case 60: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==60); - case 62: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==62); - case 64: /* users ::= USERS INTEGER */ yytestcase(yyruleno==64); - case 66: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==66); - case 68: /* state ::= STATE ids */ yytestcase(yyruleno==68); + case 54: /* pps ::= PPS INTEGER */ + case 56: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==56); + case 58: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==58); + case 60: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==60); + case 62: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==62); + case 64: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==64); + case 66: /* users ::= USERS INTEGER */ yytestcase(yyruleno==66); + case 68: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==68); + case 70: /* state ::= STATE ids */ yytestcase(yyruleno==70); {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 69: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + case 71: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { yylhsminor.yy73.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; yylhsminor.yy73.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; @@ -2199,96 +2216,96 @@ static void yy_reduce( } yymsp[-8].minor.yy73 = yylhsminor.yy73; break; - case 70: /* keep ::= KEEP tagitemlist */ + case 72: /* keep ::= KEEP tagitemlist */ { yymsp[-1].minor.yy494 = yymsp[0].minor.yy494; } break; - case 71: /* cache ::= CACHE INTEGER */ - case 72: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==72); - case 73: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==73); - case 74: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==74); - case 75: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==75); - case 76: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==76); - case 77: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==77); - case 78: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==78); - case 79: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==79); - case 80: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==80); - case 81: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==81); - case 82: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==82); + case 73: /* cache ::= CACHE INTEGER */ + case 74: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==74); + case 75: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==75); + case 76: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==76); + case 77: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==77); + case 78: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==78); + case 79: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==79); + case 80: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==80); + case 81: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==81); + case 82: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==82); + case 83: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==83); + case 84: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==84); { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 83: /* db_optr ::= */ + case 85: /* db_optr ::= */ {setDefaultCreateDbOption(&yymsp[1].minor.yy158);} break; - case 84: /* db_optr ::= db_optr cache */ + case 86: /* db_optr ::= db_optr cache */ { yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 85: /* db_optr ::= db_optr replica */ - case 98: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==98); + case 87: /* db_optr ::= db_optr replica */ + case 100: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==100); { yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 86: /* db_optr ::= db_optr quorum */ - case 99: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==99); + case 88: /* db_optr ::= db_optr quorum */ + case 101: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==101); { yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 87: /* db_optr ::= db_optr days */ + case 89: /* db_optr ::= db_optr days */ { yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 88: /* db_optr ::= db_optr minrows */ + case 90: /* db_optr ::= db_optr minrows */ { yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 89: /* db_optr ::= db_optr maxrows */ + case 91: /* db_optr ::= db_optr maxrows */ { yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 90: /* db_optr ::= db_optr blocks */ - case 101: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==101); + case 92: /* db_optr ::= db_optr blocks */ + case 103: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==103); { yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 91: /* db_optr ::= db_optr ctime */ + case 93: /* db_optr ::= db_optr ctime */ { yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 92: /* db_optr ::= db_optr wal */ - case 103: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==103); + case 94: /* db_optr ::= db_optr wal */ + case 105: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==105); { yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 93: /* db_optr ::= db_optr fsync */ - case 104: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==104); + case 95: /* db_optr ::= db_optr fsync */ + case 106: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==106); { yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 94: /* db_optr ::= db_optr comp */ - case 102: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==102); + case 96: /* db_optr ::= db_optr comp */ + case 104: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==104); { yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 95: /* db_optr ::= db_optr prec */ + case 97: /* db_optr ::= db_optr prec */ { yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.precision = yymsp[0].minor.yy0; } yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 96: /* db_optr ::= db_optr keep */ - case 100: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==100); + case 98: /* db_optr ::= db_optr keep */ + case 102: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==102); { yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.keep = yymsp[0].minor.yy494; } yymsp[-1].minor.yy158 = yylhsminor.yy158; break; - case 97: /* alter_db_optr ::= */ + case 99: /* alter_db_optr ::= */ { setDefaultCreateDbOption(&yymsp[1].minor.yy158);} break; - case 105: /* typename ::= ids */ + case 107: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; tSQLSetColumnType (&yylhsminor.yy181, &yymsp[0].minor.yy0); } yymsp[0].minor.yy181 = yylhsminor.yy181; break; - case 106: /* typename ::= ids LP signed RP */ + case 108: /* typename ::= ids LP signed RP */ { if (yymsp[-1].minor.yy271 <= 0) { yymsp[-3].minor.yy0.type = 0; @@ -2300,84 +2317,84 @@ static void yy_reduce( } yymsp[-3].minor.yy181 = yylhsminor.yy181; break; - case 107: /* signed ::= INTEGER */ + case 109: /* signed ::= INTEGER */ { yylhsminor.yy271 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[0].minor.yy271 = yylhsminor.yy271; break; - case 108: /* signed ::= PLUS INTEGER */ + case 110: /* signed ::= PLUS INTEGER */ { yymsp[-1].minor.yy271 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 109: /* signed ::= MINUS INTEGER */ + case 111: /* signed ::= MINUS INTEGER */ { yymsp[-1].minor.yy271 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; - case 110: /* cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */ + case 112: /* cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-2].minor.yy0, &yymsp[-3].minor.yy0); } break; - case 111: /* create_table_args ::= LP columnlist RP */ + case 113: /* create_table_args ::= LP columnlist RP */ { yymsp[-2].minor.yy374 = tSetCreateSQLElems(yymsp[-1].minor.yy449, NULL, NULL, NULL, NULL, TSQL_CREATE_TABLE); setSQLInfo(pInfo, yymsp[-2].minor.yy374, NULL, TSDB_SQL_CREATE_TABLE); } break; - case 112: /* create_table_args ::= LP columnlist RP TAGS LP columnlist RP */ + case 114: /* create_table_args ::= LP columnlist RP TAGS LP columnlist RP */ { yymsp[-6].minor.yy374 = tSetCreateSQLElems(yymsp[-5].minor.yy449, yymsp[-1].minor.yy449, NULL, NULL, NULL, TSQL_CREATE_STABLE); setSQLInfo(pInfo, yymsp[-6].minor.yy374, NULL, TSDB_SQL_CREATE_TABLE); } break; - case 113: /* create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */ + case 115: /* create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-6].minor.yy374 = tSetCreateSQLElems(NULL, NULL, &yymsp[-5].minor.yy0, yymsp[-1].minor.yy494, NULL, TSQL_CREATE_TABLE_FROM_STABLE); setSQLInfo(pInfo, yymsp[-6].minor.yy374, NULL, TSDB_SQL_CREATE_TABLE); } break; - case 114: /* create_table_args ::= AS select */ + case 116: /* create_table_args ::= AS select */ { yymsp[-1].minor.yy374 = tSetCreateSQLElems(NULL, NULL, NULL, NULL, yymsp[0].minor.yy150, TSQL_CREATE_STREAM); setSQLInfo(pInfo, yymsp[-1].minor.yy374, NULL, TSDB_SQL_CREATE_TABLE); } break; - case 115: /* columnlist ::= columnlist COMMA column */ + case 117: /* columnlist ::= columnlist COMMA column */ {yylhsminor.yy449 = tFieldListAppend(yymsp[-2].minor.yy449, &yymsp[0].minor.yy181); } yymsp[-2].minor.yy449 = yylhsminor.yy449; break; - case 116: /* columnlist ::= column */ + case 118: /* columnlist ::= column */ {yylhsminor.yy449 = tFieldListAppend(NULL, &yymsp[0].minor.yy181);} yymsp[0].minor.yy449 = yylhsminor.yy449; break; - case 117: /* column ::= ids typename */ + case 119: /* column ::= ids typename */ { tSQLSetColumnInfo(&yylhsminor.yy181, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy181); } yymsp[-1].minor.yy181 = yylhsminor.yy181; break; - case 118: /* tagitemlist ::= tagitemlist COMMA tagitem */ + case 120: /* tagitemlist ::= tagitemlist COMMA tagitem */ { yylhsminor.yy494 = tVariantListAppend(yymsp[-2].minor.yy494, &yymsp[0].minor.yy312, -1); } yymsp[-2].minor.yy494 = yylhsminor.yy494; break; - case 119: /* tagitemlist ::= tagitem */ + case 121: /* tagitemlist ::= tagitem */ { yylhsminor.yy494 = tVariantListAppend(NULL, &yymsp[0].minor.yy312, -1); } yymsp[0].minor.yy494 = yylhsminor.yy494; break; - case 120: /* tagitem ::= INTEGER */ - case 121: /* tagitem ::= FLOAT */ yytestcase(yyruleno==121); - case 122: /* tagitem ::= STRING */ yytestcase(yyruleno==122); - case 123: /* tagitem ::= BOOL */ yytestcase(yyruleno==123); + case 122: /* tagitem ::= INTEGER */ + case 123: /* tagitem ::= FLOAT */ yytestcase(yyruleno==123); + case 124: /* tagitem ::= STRING */ yytestcase(yyruleno==124); + case 125: /* tagitem ::= BOOL */ yytestcase(yyruleno==125); {toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy312, &yymsp[0].minor.yy0); } yymsp[0].minor.yy312 = yylhsminor.yy312; break; - case 124: /* tagitem ::= NULL */ + case 126: /* tagitem ::= NULL */ { yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy312, &yymsp[0].minor.yy0); } yymsp[0].minor.yy312 = yylhsminor.yy312; break; - case 125: /* tagitem ::= MINUS INTEGER */ - case 126: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==126); - case 127: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==127); - case 128: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==128); + case 127: /* tagitem ::= MINUS INTEGER */ + case 128: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==128); + case 129: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==129); + case 130: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==130); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; @@ -2386,70 +2403,70 @@ static void yy_reduce( } yymsp[-1].minor.yy312 = yylhsminor.yy312; break; - case 129: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ + case 131: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ { yylhsminor.yy150 = tSetQuerySQLElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy224, yymsp[-9].minor.yy494, yymsp[-8].minor.yy66, yymsp[-4].minor.yy494, yymsp[-3].minor.yy494, &yymsp[-7].minor.yy0, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy494, &yymsp[0].minor.yy188, &yymsp[-1].minor.yy188); } yymsp[-11].minor.yy150 = yylhsminor.yy150; break; - case 130: /* union ::= select */ + case 132: /* union ::= select */ { yylhsminor.yy25 = setSubclause(NULL, yymsp[0].minor.yy150); } yymsp[0].minor.yy25 = yylhsminor.yy25; break; - case 131: /* union ::= LP union RP */ + case 133: /* union ::= LP union RP */ { yymsp[-2].minor.yy25 = yymsp[-1].minor.yy25; } break; - case 132: /* union ::= union UNION ALL select */ + case 134: /* union ::= union UNION ALL select */ { yylhsminor.yy25 = appendSelectClause(yymsp[-3].minor.yy25, yymsp[0].minor.yy150); } yymsp[-3].minor.yy25 = yylhsminor.yy25; break; - case 133: /* union ::= union UNION ALL LP select RP */ + case 135: /* union ::= union UNION ALL LP select RP */ { yylhsminor.yy25 = appendSelectClause(yymsp[-5].minor.yy25, yymsp[-1].minor.yy150); } yymsp[-5].minor.yy25 = yylhsminor.yy25; break; - case 134: /* cmd ::= union */ + case 136: /* cmd ::= union */ { setSQLInfo(pInfo, yymsp[0].minor.yy25, NULL, TSDB_SQL_SELECT); } break; - case 135: /* select ::= SELECT selcollist */ + case 137: /* select ::= SELECT selcollist */ { yylhsminor.yy150 = tSetQuerySQLElems(&yymsp[-1].minor.yy0, yymsp[0].minor.yy224, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } yymsp[-1].minor.yy150 = yylhsminor.yy150; break; - case 136: /* sclp ::= selcollist COMMA */ + case 138: /* sclp ::= selcollist COMMA */ {yylhsminor.yy224 = yymsp[-1].minor.yy224;} yymsp[-1].minor.yy224 = yylhsminor.yy224; break; - case 137: /* sclp ::= */ + case 139: /* sclp ::= */ {yymsp[1].minor.yy224 = 0;} break; - case 138: /* selcollist ::= sclp expr as */ + case 140: /* selcollist ::= sclp expr as */ { yylhsminor.yy224 = tSQLExprListAppend(yymsp[-2].minor.yy224, yymsp[-1].minor.yy66, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } yymsp[-2].minor.yy224 = yylhsminor.yy224; break; - case 139: /* selcollist ::= sclp STAR */ + case 141: /* selcollist ::= sclp STAR */ { tSQLExpr *pNode = tSQLExprIdValueCreate(NULL, TK_ALL); yylhsminor.yy224 = tSQLExprListAppend(yymsp[-1].minor.yy224, pNode, 0); } yymsp[-1].minor.yy224 = yylhsminor.yy224; break; - case 140: /* as ::= AS ids */ + case 142: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 141: /* as ::= ids */ + case 143: /* as ::= ids */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 142: /* as ::= */ + case 144: /* as ::= */ { yymsp[1].minor.yy0.n = 0; } break; - case 143: /* from ::= FROM tablelist */ + case 145: /* from ::= FROM tablelist */ {yymsp[-1].minor.yy494 = yymsp[0].minor.yy494;} break; - case 144: /* tablelist ::= ids cpxName */ + case 146: /* tablelist ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; @@ -2458,7 +2475,7 @@ static void yy_reduce( } yymsp[-1].minor.yy494 = yylhsminor.yy494; break; - case 145: /* tablelist ::= ids cpxName ids */ + case 147: /* tablelist ::= ids cpxName ids */ { toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type); @@ -2468,7 +2485,7 @@ static void yy_reduce( } yymsp[-2].minor.yy494 = yylhsminor.yy494; break; - case 146: /* tablelist ::= tablelist COMMA ids cpxName */ + case 148: /* tablelist ::= tablelist COMMA ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; @@ -2477,7 +2494,7 @@ static void yy_reduce( } yymsp[-3].minor.yy494 = yylhsminor.yy494; break; - case 147: /* tablelist ::= tablelist COMMA ids cpxName ids */ + case 149: /* tablelist ::= tablelist COMMA ids cpxName ids */ { toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type); @@ -2487,22 +2504,22 @@ static void yy_reduce( } yymsp[-4].minor.yy494 = yylhsminor.yy494; break; - case 148: /* tmvar ::= VARIABLE */ + case 150: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 149: /* interval_opt ::= INTERVAL LP tmvar RP */ - case 154: /* sliding_opt ::= SLIDING LP tmvar RP */ yytestcase(yyruleno==154); + case 151: /* interval_opt ::= INTERVAL LP tmvar RP */ + case 156: /* sliding_opt ::= SLIDING LP tmvar RP */ yytestcase(yyruleno==156); {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } break; - case 150: /* interval_opt ::= */ - case 155: /* sliding_opt ::= */ yytestcase(yyruleno==155); + case 152: /* interval_opt ::= */ + case 157: /* sliding_opt ::= */ yytestcase(yyruleno==157); {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; - case 151: /* fill_opt ::= */ + case 153: /* fill_opt ::= */ {yymsp[1].minor.yy494 = 0; } break; - case 152: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + case 154: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { tVariant A = {0}; toTSDBType(yymsp[-3].minor.yy0.type); @@ -2512,33 +2529,33 @@ static void yy_reduce( yymsp[-5].minor.yy494 = yymsp[-1].minor.yy494; } break; - case 153: /* fill_opt ::= FILL LP ID RP */ + case 155: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-3].minor.yy494 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } break; - case 156: /* orderby_opt ::= */ - case 164: /* groupby_opt ::= */ yytestcase(yyruleno==164); + case 158: /* orderby_opt ::= */ + case 166: /* groupby_opt ::= */ yytestcase(yyruleno==166); {yymsp[1].minor.yy494 = 0;} break; - case 157: /* orderby_opt ::= ORDER BY sortlist */ - case 165: /* groupby_opt ::= GROUP BY grouplist */ yytestcase(yyruleno==165); + case 159: /* orderby_opt ::= ORDER BY sortlist */ + case 167: /* groupby_opt ::= GROUP BY grouplist */ yytestcase(yyruleno==167); {yymsp[-2].minor.yy494 = yymsp[0].minor.yy494;} break; - case 158: /* sortlist ::= sortlist COMMA item sortorder */ + case 160: /* sortlist ::= sortlist COMMA item sortorder */ { yylhsminor.yy494 = tVariantListAppend(yymsp[-3].minor.yy494, &yymsp[-1].minor.yy312, yymsp[0].minor.yy82); } yymsp[-3].minor.yy494 = yylhsminor.yy494; break; - case 159: /* sortlist ::= item sortorder */ + case 161: /* sortlist ::= item sortorder */ { yylhsminor.yy494 = tVariantListAppend(NULL, &yymsp[-1].minor.yy312, yymsp[0].minor.yy82); } yymsp[-1].minor.yy494 = yylhsminor.yy494; break; - case 160: /* item ::= ids cpxName */ + case 162: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; @@ -2547,196 +2564,196 @@ static void yy_reduce( } yymsp[-1].minor.yy312 = yylhsminor.yy312; break; - case 161: /* sortorder ::= ASC */ + case 163: /* sortorder ::= ASC */ {yymsp[0].minor.yy82 = TSDB_ORDER_ASC; } break; - case 162: /* sortorder ::= DESC */ + case 164: /* sortorder ::= DESC */ {yymsp[0].minor.yy82 = TSDB_ORDER_DESC;} break; - case 163: /* sortorder ::= */ + case 165: /* sortorder ::= */ {yymsp[1].minor.yy82 = TSDB_ORDER_ASC;} break; - case 166: /* grouplist ::= grouplist COMMA item */ + case 168: /* grouplist ::= grouplist COMMA item */ { yylhsminor.yy494 = tVariantListAppend(yymsp[-2].minor.yy494, &yymsp[0].minor.yy312, -1); } yymsp[-2].minor.yy494 = yylhsminor.yy494; break; - case 167: /* grouplist ::= item */ + case 169: /* grouplist ::= item */ { yylhsminor.yy494 = tVariantListAppend(NULL, &yymsp[0].minor.yy312, -1); } yymsp[0].minor.yy494 = yylhsminor.yy494; break; - case 168: /* having_opt ::= */ - case 178: /* where_opt ::= */ yytestcase(yyruleno==178); - case 214: /* expritem ::= */ yytestcase(yyruleno==214); + case 170: /* having_opt ::= */ + case 180: /* where_opt ::= */ yytestcase(yyruleno==180); + case 216: /* expritem ::= */ yytestcase(yyruleno==216); {yymsp[1].minor.yy66 = 0;} break; - case 169: /* having_opt ::= HAVING expr */ - case 179: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==179); + case 171: /* having_opt ::= HAVING expr */ + case 181: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==181); {yymsp[-1].minor.yy66 = yymsp[0].minor.yy66;} break; - case 170: /* limit_opt ::= */ - case 174: /* slimit_opt ::= */ yytestcase(yyruleno==174); + case 172: /* limit_opt ::= */ + case 176: /* slimit_opt ::= */ yytestcase(yyruleno==176); {yymsp[1].minor.yy188.limit = -1; yymsp[1].minor.yy188.offset = 0;} break; - case 171: /* limit_opt ::= LIMIT signed */ - case 175: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==175); + case 173: /* limit_opt ::= LIMIT signed */ + case 177: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==177); {yymsp[-1].minor.yy188.limit = yymsp[0].minor.yy271; yymsp[-1].minor.yy188.offset = 0;} break; - case 172: /* limit_opt ::= LIMIT signed OFFSET signed */ - case 176: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ yytestcase(yyruleno==176); + case 174: /* limit_opt ::= LIMIT signed OFFSET signed */ + case 178: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ yytestcase(yyruleno==178); {yymsp[-3].minor.yy188.limit = yymsp[-2].minor.yy271; yymsp[-3].minor.yy188.offset = yymsp[0].minor.yy271;} break; - case 173: /* limit_opt ::= LIMIT signed COMMA signed */ - case 177: /* slimit_opt ::= SLIMIT signed COMMA signed */ yytestcase(yyruleno==177); + case 175: /* limit_opt ::= LIMIT signed COMMA signed */ + case 179: /* slimit_opt ::= SLIMIT signed COMMA signed */ yytestcase(yyruleno==179); {yymsp[-3].minor.yy188.limit = yymsp[0].minor.yy271; yymsp[-3].minor.yy188.offset = yymsp[-2].minor.yy271;} break; - case 180: /* expr ::= LP expr RP */ + case 182: /* expr ::= LP expr RP */ {yymsp[-2].minor.yy66 = yymsp[-1].minor.yy66; } break; - case 181: /* expr ::= ID */ + case 183: /* expr ::= ID */ {yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);} yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 182: /* expr ::= ID DOT ID */ + case 184: /* expr ::= ID DOT ID */ {yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 183: /* expr ::= ID DOT STAR */ + case 185: /* expr ::= ID DOT STAR */ {yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 184: /* expr ::= INTEGER */ + case 186: /* expr ::= INTEGER */ {yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);} yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 185: /* expr ::= MINUS INTEGER */ - case 186: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==186); + case 187: /* expr ::= MINUS INTEGER */ + case 188: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==188); {yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);} yymsp[-1].minor.yy66 = yylhsminor.yy66; break; - case 187: /* expr ::= FLOAT */ + case 189: /* expr ::= FLOAT */ {yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);} yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 188: /* expr ::= MINUS FLOAT */ - case 189: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==189); + case 190: /* expr ::= MINUS FLOAT */ + case 191: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==191); {yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);} yymsp[-1].minor.yy66 = yylhsminor.yy66; break; - case 190: /* expr ::= STRING */ + case 192: /* expr ::= STRING */ {yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);} yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 191: /* expr ::= NOW */ + case 193: /* expr ::= NOW */ {yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); } yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 192: /* expr ::= VARIABLE */ + case 194: /* expr ::= VARIABLE */ {yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);} yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 193: /* expr ::= BOOL */ + case 195: /* expr ::= BOOL */ {yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);} yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 194: /* expr ::= ID LP exprlist RP */ + case 196: /* expr ::= ID LP exprlist RP */ { yylhsminor.yy66 = tSQLExprCreateFunction(yymsp[-1].minor.yy224, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy66 = yylhsminor.yy66; break; - case 195: /* expr ::= ID LP STAR RP */ + case 197: /* expr ::= ID LP STAR RP */ { yylhsminor.yy66 = tSQLExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy66 = yylhsminor.yy66; break; - case 196: /* expr ::= expr AND expr */ + case 198: /* expr ::= expr AND expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_AND);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 197: /* expr ::= expr OR expr */ + case 199: /* expr ::= expr OR expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_OR); } yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 198: /* expr ::= expr LT expr */ + case 200: /* expr ::= expr LT expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_LT);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 199: /* expr ::= expr GT expr */ + case 201: /* expr ::= expr GT expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_GT);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 200: /* expr ::= expr LE expr */ + case 202: /* expr ::= expr LE expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_LE);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 201: /* expr ::= expr GE expr */ + case 203: /* expr ::= expr GE expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_GE);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 202: /* expr ::= expr NE expr */ + case 204: /* expr ::= expr NE expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_NE);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 203: /* expr ::= expr EQ expr */ + case 205: /* expr ::= expr EQ expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_EQ);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 204: /* expr ::= expr PLUS expr */ + case 206: /* expr ::= expr PLUS expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_PLUS); } yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 205: /* expr ::= expr MINUS expr */ + case 207: /* expr ::= expr MINUS expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_MINUS); } yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 206: /* expr ::= expr STAR expr */ + case 208: /* expr ::= expr STAR expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_STAR); } yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 207: /* expr ::= expr SLASH expr */ + case 209: /* expr ::= expr SLASH expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_DIVIDE);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 208: /* expr ::= expr REM expr */ + case 210: /* expr ::= expr REM expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_REM); } yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 209: /* expr ::= expr LIKE expr */ + case 211: /* expr ::= expr LIKE expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_LIKE); } yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 210: /* expr ::= expr IN LP exprlist RP */ + case 212: /* expr ::= expr IN LP exprlist RP */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-4].minor.yy66, (tSQLExpr*)yymsp[-1].minor.yy224, TK_IN); } yymsp[-4].minor.yy66 = yylhsminor.yy66; break; - case 211: /* exprlist ::= exprlist COMMA expritem */ + case 213: /* exprlist ::= exprlist COMMA expritem */ {yylhsminor.yy224 = tSQLExprListAppend(yymsp[-2].minor.yy224,yymsp[0].minor.yy66,0);} yymsp[-2].minor.yy224 = yylhsminor.yy224; break; - case 212: /* exprlist ::= expritem */ + case 214: /* exprlist ::= expritem */ {yylhsminor.yy224 = tSQLExprListAppend(0,yymsp[0].minor.yy66,0);} yymsp[0].minor.yy224 = yylhsminor.yy224; break; - case 213: /* expritem ::= expr */ + case 215: /* expritem ::= expr */ {yylhsminor.yy66 = yymsp[0].minor.yy66;} yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 215: /* cmd ::= RESET QUERY CACHE */ + case 217: /* cmd ::= RESET QUERY CACHE */ { setDCLSQLElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 216: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 218: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy449, NULL, TSDB_ALTER_TABLE_ADD_COLUMN); setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 217: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 219: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -2747,14 +2764,14 @@ static void yy_reduce( setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 218: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 220: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy449, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN); setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 219: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 221: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -2765,7 +2782,7 @@ static void yy_reduce( setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 220: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 222: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -2779,7 +2796,7 @@ static void yy_reduce( setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 221: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 223: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; @@ -2791,13 +2808,13 @@ static void yy_reduce( setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 222: /* cmd ::= KILL CONNECTION INTEGER */ + case 224: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSQL(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 223: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 225: /* 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 224: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 226: /* 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 2c988d9f80a07a6987cec9edbe13d2e2fe59063b Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 14 Sep 2020 00:45:18 +0000 Subject: [PATCH 05/77] add test --- tests/script/general/db/show_create_db.sim | 32 +++++++ tests/script/general/db/show_create_table.sim | 87 +++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 tests/script/general/db/show_create_db.sim create mode 100644 tests/script/general/db/show_create_table.sim diff --git a/tests/script/general/db/show_create_db.sim b/tests/script/general/db/show_create_db.sim new file mode 100644 index 0000000000..baa7b253e1 --- /dev/null +++ b/tests/script/general/db/show_create_db.sim @@ -0,0 +1,32 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 0 + +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print =============== step2 +sql create database db +sql show create database db + +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql use db +sql show create database db + +if $rows != 1 then + return -1 +endi + +if $data00 != db then + return -1 +endi + +sql drop database db + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/db/show_create_table.sim b/tests/script/general/db/show_create_table.sim new file mode 100644 index 0000000000..8338638709 --- /dev/null +++ b/tests/script/general/db/show_create_table.sim @@ -0,0 +1,87 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 0 + +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print ===============create three type table +sql create database db +sql use db +sql create table meters(ts timestamp, f binary(8)) tags(loc int, zone binary(8)) +sql create table t0 using meters tags(1,'ch') +sql create table normalTbl(ts timestamp, zone binary(8)) + +sql use db +sql show create table meters +if $rows != 1 then + return -1 +endi + +print ===============check sub table +sql show create table t0 +if $rows != 1 then + return -1 +endi +if $data00 == 't0' then + return -1 +endi + +print ===============check normal table + +sql show create table normalTbl +if $rows != 1 then + return -1 +endi + +if $data00 == 'normalTbl' then + return -1 +endi + +print ===============check super table +sql show create table meters +if $rows != 1 then + return -1 +endi + +if $data00 == 'meters' then + return -1 +endi + +print ===============check sub table with prefix + +sql show create table db.t0 +if $rows != 1 then + return -1 +endi + +if $data00 == 't0' then + return -1 +endi + +print ===============check normal table with prefix +sql show create table db.normalTbl +if $rows != 1 then + return -1 +endi + +if $data00 == 'normalTbl' then + return -1 +endi + + +print ===============check super table with prefix +sql show create table db.meters +if $rows != 1 then + return -1 +endi + +if $data00 == 'meters' then + return -1 +endi + +sql drop database db + +system sh/exec.sh -n dnode1 -s stop -x SIGINT From b4f6b07258c1e7845fea12e3f9e8d30513a89022 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 14 Sep 2020 00:51:22 +0000 Subject: [PATCH 06/77] add test for show-create test --- tests/script/fullGeneralSuite.sim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/script/fullGeneralSuite.sim b/tests/script/fullGeneralSuite.sim index d137e53d27..870a1ce3d0 100644 --- a/tests/script/fullGeneralSuite.sim +++ b/tests/script/fullGeneralSuite.sim @@ -221,3 +221,5 @@ run general/stream/table_del.sim run general/stream/metrics_del.sim run general/stream/table_replica1_vnoden.sim run general/stream/metrics_replica1_vnoden.sim +run general/db/show_create_db.sim +run general/db/show_create_table.sim From 6f908d0397e7a2d21fcc3bd2c4e084588156226d Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 17 Sep 2020 15:49:20 +0800 Subject: [PATCH 07/77] compile error in windows --- src/client/src/tscLocal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index 12ee052ef5..030b033653 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -467,7 +467,7 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) { // build 'show create table/database' result fields static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const char *ddl) { int32_t rowLen = 0; - int16_t ddlLen = strlen(ddl); + int16_t ddlLen = (int16_t)strlen(ddl); SColumnIndex index = {0}; pSql->cmd.numOfCols = 2; From 347a45e24fdc5a00e157b1507d94f011ba2ee20e Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 18 Sep 2020 10:53:58 +0800 Subject: [PATCH 08/77] minor changes --- src/plugins/http/src/httpSql.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/http/src/httpSql.c b/src/plugins/http/src/httpSql.c index 881fa55fb7..883fa574ff 100644 --- a/src/plugins/http/src/httpSql.c +++ b/src/plugins/http/src/httpSql.c @@ -257,20 +257,20 @@ void httpProcessSingleSqlCallBackImp(void *param, TAOS_RES *result, int unUsedCo HttpEncodeMethod *encode = pContext->encodeMethod; if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { - httpError("context:%p, fd:%d, user:%s, query error, taos:%p, code:%s:inprogress, sqlObj:%p", pContext, pContext->fd, - pContext->user, pContext->session->taos, tstrerror(code), (SSqlObj *)result); + httpError("context:%p, fd:%d, user:%s, query error, code:%s:inprogress, sqlObj:%p", pContext, pContext->fd, + pContext->user, tstrerror(code), (SSqlObj *)result); return; } if (code < 0) { SSqlObj *pObj = (SSqlObj *)result; if (code == TSDB_CODE_TSC_INVALID_SQL) { - httpError("context:%p, fd:%d, user:%s, query error, taos:%p, code:%s, sqlObj:%p, error:%s", pContext, - pContext->fd, pContext->user, pContext->session->taos, tstrerror(code), pObj, pObj->cmd.payload); + httpError("context:%p, fd:%d, user:%s, query error, code:%s, sqlObj:%p, error:%s", pContext, + pContext->fd, pContext->user, tstrerror(code), pObj, pObj->cmd.payload); httpSendTaosdInvalidSqlErrorResp(pContext, pObj->cmd.payload); } else { - httpError("context:%p, fd:%d, user:%s, query error, taos:%p, code:%s, sqlObj:%p", pContext, pContext->fd, - pContext->user, pContext->session->taos, tstrerror(code), pObj); + httpError("context:%p, fd:%d, user:%s, query error, code:%s, sqlObj:%p", pContext, pContext->fd, + pContext->user, tstrerror(code), pObj); httpSendErrorResp(pContext, code); } taos_free_result(result); From 4c834753ad3c419e88c1258ad5b52bf2f0e65fd1 Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Mon, 21 Sep 2020 10:37:20 +0800 Subject: [PATCH 09/77] Update cluster-ch.md --- documentation20/webdocs/markdowndocs/cluster-ch.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/documentation20/webdocs/markdowndocs/cluster-ch.md b/documentation20/webdocs/markdowndocs/cluster-ch.md index 25ab9b9107..c36819e5c7 100644 --- a/documentation20/webdocs/markdowndocs/cluster-ch.md +++ b/documentation20/webdocs/markdowndocs/cluster-ch.md @@ -31,8 +31,8 @@ TDengine的集群管理极其简单,除添加和删除节点需要人工干预 // firstEp 是每个数据节点首次启动后连接的第一个数据节点 firstEp h1.taosdata.com:6030 -// 配置本数据节点的FQDN,如果本机只有一个hostname, 无需配置 -fqdn h1.taosdata.com +// 必须配置为本数据节点的FQDN,如果本机只有一个hostname, 可注释掉本配置 +fqdn h1.taosdata.com // 配置本数据节点的端口号,缺省是6030 serverPort 6030 @@ -41,7 +41,7 @@ serverPort 6030 arbitrator ha.taosdata.com:6042 ``` -一定要修改的参数是firstEp和fqdn, 其他参数可不做任何修改,除非你很清楚为什么要修改。 +一定要修改的参数是firstEp和fqdn。在每个数据节点,firstEp需全部配置成一样,**但fqdn一定要配置成其所在数据节点的值**。其他参数可不做任何修改,除非你很清楚为什么要修改。 **加入到集群中的数据节点dnode,涉及集群相关的下表11项参数必须完全相同,否则不能成功加入到集群中。** From 77b86280fdaad249149d780bb5cd6446bd849b08 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 21 Sep 2020 11:45:31 +0800 Subject: [PATCH 10/77] [td-225] fix bugs in regression test. --- src/client/src/tscFunctionImpl.c | 6 ++++-- src/client/src/tscSQLParser.c | 21 ++++++++------------- src/query/src/qExecutor.c | 18 +++++++++++++----- tests/script/general/parser/where.sim | 18 +++++++++++++++--- 4 files changed, 40 insertions(+), 23 deletions(-) diff --git a/src/client/src/tscFunctionImpl.c b/src/client/src/tscFunctionImpl.c index d8ac0d3109..be38a7af71 100644 --- a/src/client/src/tscFunctionImpl.c +++ b/src/client/src/tscFunctionImpl.c @@ -326,7 +326,7 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI } else if (functionId == TSDB_FUNC_LAST_ROW) { *type = (int16_t)dataType; *bytes = (int16_t)dataBytes; - *interBytes = dataBytes + sizeof(SLastrowInfo); + *interBytes = dataBytes; } else { return TSDB_CODE_TSC_INVALID_SQL; } @@ -1843,8 +1843,10 @@ static void last_row_function(SQLFunctionCtx *pCtx) { pInfo1->hasResult = DATA_SET_FLAG; DO_UPDATE_TAG_COLUMNS(pCtx, pInfo1->ts); + } else { + DO_UPDATE_TAG_COLUMNS(pCtx, pCtx->ptsList[pCtx->size - 1]); } - + SET_VAL(pCtx, pCtx->size, 1); } diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index cceb876a06..4555b0e08d 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -5286,9 +5286,12 @@ void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex) { static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) { int32_t tagLength = 0; - size_t size = taosArrayGetSize(pQueryInfo->exprList); - + +//todo is 0?? + STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + bool isSTable = UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo); + for (int32_t i = 0; i < size; ++i) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); if (pExpr->functionId == TSDB_FUNC_TAGPRJ || pExpr->functionId == TSDB_FUNC_TAG) { @@ -5300,8 +5303,7 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) { } } - STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - SSchema* pSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta); + SSchema* pSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta); for (int32_t i = 0; i < size; ++i) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); @@ -5309,7 +5311,7 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) { !(pExpr->functionId == TSDB_FUNC_PRJ && TSDB_COL_IS_UD_COL(pExpr->colInfo.flag))) { SSchema* pColSchema = &pSchema[pExpr->colInfo.colIndex]; getResultDataInfo(pColSchema->type, pColSchema->bytes, pExpr->functionId, (int32_t)pExpr->param[0].i64Key, &pExpr->resType, - &pExpr->resBytes, &pExpr->interBytes, tagLength, true); + &pExpr->resBytes, &pExpr->interBytes, tagLength, isSTable); } } } @@ -5320,7 +5322,7 @@ static int32_t doUpdateSqlFunctionForColPrj(SQueryInfo* pQueryInfo) { for (int32_t i = 0; i < size; ++i) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); - if (pExpr->functionId == TSDB_FUNC_PRJ && (!TSDB_COL_IS_UD_COL(pExpr->colInfo.flag))) { + if (pExpr->functionId == TSDB_FUNC_PRJ && (!TSDB_COL_IS_UD_COL(pExpr->colInfo.flag) && (pExpr->colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX))) { bool qualifiedCol = false; for (int32_t j = 0; j < pQueryInfo->groupbyExpr.numOfGroupCols; ++j) { SColIndex* pColIndex = taosArrayGet(pQueryInfo->groupbyExpr.columnInfo, j); @@ -5418,13 +5420,6 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, SSqlCmd* pCmd) int16_t numOfSelectivity = 0; int16_t numOfAggregation = 0; - // todo is 0?? - STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - bool isSTable = UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo); - if (!isSTable) { - return TSDB_CODE_SUCCESS; - } - size_t numOfExprs = taosArrayGetSize(pQueryInfo->exprList); for (int32_t i = 0; i < numOfExprs; ++i) { SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, i); diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index d3f44cdcc7..f2d324e376 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -2120,7 +2120,7 @@ static bool needToLoadDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis *pDat } } - // no statistics data + // no statistics data, load the true data block if (index == -1) { return true; } @@ -2130,8 +2130,17 @@ static bool needToLoadDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis *pDat return true; } - // all points in current column are NULL, no need to check its boundary value + // all data in current column are NULL, no need to check its boundary value if (pDataStatis[index].numOfNull == numOfRows) { + + // if isNULL query exists, load the null data column + for (int32_t j = 0; j < pFilterInfo->numOfFilters; ++j) { + SColumnFilterElem *pFilterElem = &pFilterInfo->pFilters[j]; + if (pFilterElem->fp == isNull_filter) { + return true; + } + } + continue; } @@ -2957,11 +2966,10 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) { STableQueryInfo *item = taosArrayGetP(pGroup, i); SIDList list = getDataBufPagesIdList(pRuntimeEnv->pResultBuf, TSDB_TABLEID(item->pTable)->tid); - pageList = list; - tid = TSDB_TABLEID(item->pTable)->tid; - if (taosArrayGetSize(list) > 0 && item->windowResInfo.size > 0) { pTableList[numOfTables++] = item; + tid = TSDB_TABLEID(item->pTable)->tid; + pageList = list; } } diff --git a/tests/script/general/parser/where.sim b/tests/script/general/parser/where.sim index fb15fb6dbe..f9fd919bd6 100644 --- a/tests/script/general/parser/where.sim +++ b/tests/script/general/parser/where.sim @@ -308,13 +308,25 @@ sleep 2000 system sh/exec.sh -n dnode1 -s start -sql select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter'); +sql_error select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter'); + +sql select * from wh_mt0 where c3 = '1' and tbname in ('test_null_filter'); if $row != 0 then return -1 endi -sql select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter'); -if $row != 0 then +sql select * from wh_mt0 where c3 = '1'; +if $row == 0 then + return -1 +endi + +sql select * from wh_mt0 where c3 is null and tbname in ('test_null_filter'); +if $rows != 10000 then + return -1 +endi + +sql select * from wh_mt0 where c3 is not null and tbname in ('test_null_filter'); +if $rows != 0 then return -1 endi From 1f73c106b91e711880d772bbdae9d432bddcac69 Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Mon, 21 Sep 2020 11:56:33 +0800 Subject: [PATCH 11/77] TD-1529: stream async create db connection and also fix failed test cases related to stream. --- src/client/src/tscSql.c | 10 +++++++++- src/client/src/tscStream.c | 5 +++++ src/cq/CMakeLists.txt | 2 ++ src/cq/src/cqMain.c | 18 ++++++++++++------ 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 69bc69cd4a..1df77d1850 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -236,13 +236,21 @@ TAOS *taos_connect_c(const char *ip, uint8_t ipLen, const char *user, uint8_t us return taos_connect(ipBuf, userBuf, passBuf, dbBuf, port); } +static void asyncConnCallback(void *param, TAOS_RES *tres, int code) { + SSqlObj *pSql = (SSqlObj *) tres; + assert(pSql != NULL); + + pSql->fetchFp(pSql->param, tres, code); +} + TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int), void *param, void **taos) { - SSqlObj* pSql = taosConnectImpl(ip, user, pass, NULL, db, port, fp, param, taos); + SSqlObj* pSql = taosConnectImpl(ip, user, pass, NULL, db, port, asyncConnCallback, param, taos); if (pSql == NULL) { return NULL; } + pSql->fetchFp = fp; pSql->res.code = tscProcessSql(pSql); tscDebug("%p DB async connection is opening", taos); return taos; diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index 4a1f4d9d87..93a865a78b 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -515,6 +515,10 @@ static void tscCreateStream(void *param, TAOS_RES *res, int code) { return; } + uint64_t handle = (uint64_t) pSql; + pSql->self = taosCachePut(tscObjCache, &handle, sizeof(uint64_t), &pSql, sizeof(uint64_t), 2*3600*1000); + T_REF_INC(pSql->pTscObj); + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); @@ -608,6 +612,7 @@ void taos_close_stream(TAOS_STREAM *handle) { * Here, we need a check before release memory */ if (pSql->signature == pSql) { + T_REF_DEC(pSql->pTscObj); tscRemoveFromStreamList(pStream, pSql); taosTmrStopA(&(pStream->pTimer)); diff --git a/src/cq/CMakeLists.txt b/src/cq/CMakeLists.txt index db366639ef..e631397348 100644 --- a/src/cq/CMakeLists.txt +++ b/src/cq/CMakeLists.txt @@ -2,6 +2,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) INCLUDE_DIRECTORIES(inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SRC) IF (TD_LINUX) diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index d8f68f66a5..889cc84374 100644 --- a/src/cq/src/cqMain.c +++ b/src/cq/src/cqMain.c @@ -21,6 +21,7 @@ #include #include "taos.h" +#include "tsclient.h" #include "taosdef.h" #include "taosmsg.h" #include "ttimer.h" @@ -238,18 +239,23 @@ void cqDrop(void *handle) { pthread_mutex_unlock(&pContext->mutex); } +static void doCreateStream(void *param, TAOS_RES *result, int code) { + SCqObj* pObj = (SCqObj*)param; + SCqContext* pContext = pObj->pContext; + SSqlObj* pSql = (SSqlObj*)result; + pContext->dbConn = pSql->pTscObj; + cqCreateStream(pContext, pObj); +} + static void cqProcessCreateTimer(void *param, void *tmrId) { SCqObj* pObj = (SCqObj*)param; SCqContext* pContext = pObj->pContext; if (pContext->dbConn == NULL) { - pContext->dbConn = taos_connect("localhost", pContext->user, pContext->pass, pContext->db, 0); - if (pContext->dbConn == NULL) { - cError("vgId:%d, failed to connect to TDengine(%s)", pContext->vgId, tstrerror(terrno)); - } + taos_connect_a(NULL, pContext->user, pContext->pass, pContext->db, 0, doCreateStream, param, NULL); + } else { + cqCreateStream(pContext, pObj); } - - cqCreateStream(pContext, pObj); } static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) { From d5f21eda176d13f91414406ebfd6c0dd0295657e Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Mon, 21 Sep 2020 11:56:33 +0800 Subject: [PATCH 12/77] TD-1529: stream async create db connection and also fix failed test cases related to stream. --- src/client/src/tscSql.c | 10 +++++++++- src/client/src/tscStream.c | 5 +++++ src/cq/CMakeLists.txt | 2 ++ src/cq/src/cqMain.c | 18 ++++++++++++------ 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 69bc69cd4a..1df77d1850 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -236,13 +236,21 @@ TAOS *taos_connect_c(const char *ip, uint8_t ipLen, const char *user, uint8_t us return taos_connect(ipBuf, userBuf, passBuf, dbBuf, port); } +static void asyncConnCallback(void *param, TAOS_RES *tres, int code) { + SSqlObj *pSql = (SSqlObj *) tres; + assert(pSql != NULL); + + pSql->fetchFp(pSql->param, tres, code); +} + TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int), void *param, void **taos) { - SSqlObj* pSql = taosConnectImpl(ip, user, pass, NULL, db, port, fp, param, taos); + SSqlObj* pSql = taosConnectImpl(ip, user, pass, NULL, db, port, asyncConnCallback, param, taos); if (pSql == NULL) { return NULL; } + pSql->fetchFp = fp; pSql->res.code = tscProcessSql(pSql); tscDebug("%p DB async connection is opening", taos); return taos; diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index 4a1f4d9d87..93a865a78b 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -515,6 +515,10 @@ static void tscCreateStream(void *param, TAOS_RES *res, int code) { return; } + uint64_t handle = (uint64_t) pSql; + pSql->self = taosCachePut(tscObjCache, &handle, sizeof(uint64_t), &pSql, sizeof(uint64_t), 2*3600*1000); + T_REF_INC(pSql->pTscObj); + SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); @@ -608,6 +612,7 @@ void taos_close_stream(TAOS_STREAM *handle) { * Here, we need a check before release memory */ if (pSql->signature == pSql) { + T_REF_DEC(pSql->pTscObj); tscRemoveFromStreamList(pStream, pSql); taosTmrStopA(&(pStream->pTimer)); diff --git a/src/cq/CMakeLists.txt b/src/cq/CMakeLists.txt index db366639ef..e631397348 100644 --- a/src/cq/CMakeLists.txt +++ b/src/cq/CMakeLists.txt @@ -2,6 +2,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) INCLUDE_DIRECTORIES(inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SRC) IF (TD_LINUX) diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index d8f68f66a5..889cc84374 100644 --- a/src/cq/src/cqMain.c +++ b/src/cq/src/cqMain.c @@ -21,6 +21,7 @@ #include #include "taos.h" +#include "tsclient.h" #include "taosdef.h" #include "taosmsg.h" #include "ttimer.h" @@ -238,18 +239,23 @@ void cqDrop(void *handle) { pthread_mutex_unlock(&pContext->mutex); } +static void doCreateStream(void *param, TAOS_RES *result, int code) { + SCqObj* pObj = (SCqObj*)param; + SCqContext* pContext = pObj->pContext; + SSqlObj* pSql = (SSqlObj*)result; + pContext->dbConn = pSql->pTscObj; + cqCreateStream(pContext, pObj); +} + static void cqProcessCreateTimer(void *param, void *tmrId) { SCqObj* pObj = (SCqObj*)param; SCqContext* pContext = pObj->pContext; if (pContext->dbConn == NULL) { - pContext->dbConn = taos_connect("localhost", pContext->user, pContext->pass, pContext->db, 0); - if (pContext->dbConn == NULL) { - cError("vgId:%d, failed to connect to TDengine(%s)", pContext->vgId, tstrerror(terrno)); - } + taos_connect_a(NULL, pContext->user, pContext->pass, pContext->db, 0, doCreateStream, param, NULL); + } else { + cqCreateStream(pContext, pObj); } - - cqCreateStream(pContext, pObj); } static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) { From 1a5272a49f85994c6e7e10685e5ea5e5938fd692 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 21 Sep 2020 04:34:29 +0000 Subject: [PATCH 13/77] TD-1520 --- src/client/src/tscSQLParser.c | 1 + src/common/inc/tglobal.h | 1 + src/common/src/tglobal.c | 14 +++++++++++++- src/cq/src/cqMain.c | 4 ++-- src/mnode/src/mnodeTable.c | 4 ++-- tests/script/sh/deploy.sh | 1 + tests/script/tmp/prepare.sim | 4 ++-- tests/script/unique/cluster/vgroup100.sim | 4 +++- 8 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 4555b0e08d..a6efffe436 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -4873,6 +4873,7 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) { {"cDebugFlag", 10}, {"httpDebugFlag", 13}, {"qDebugflag", 10}, {"sdbDebugFlag", 12}, {"uDebugFlag", 10}, {"tsdbDebugFlag", 13}, {"sDebugflag", 10}, {"rpcDebugFlag", 12}, {"dDebugFlag", 10}, {"mqttDebugFlag", 13}, {"wDebugFlag", 10}, {"tmrDebugFlag", 12}, + {"cqDebugFlag", 11}, }; SStrToken* pOptionToken = &pOptions->a[1]; diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 77e8b76456..798e265455 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -174,6 +174,7 @@ extern int32_t rpcDebugFlag; extern int32_t odbcDebugFlag; extern int32_t qDebugFlag; extern int32_t wDebugFlag; +extern int32_t cqDebugFlag; extern int32_t debugFlag; #define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize) diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 7e46f58a93..94ec6fde0f 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -203,6 +203,7 @@ int32_t debugFlag = 0; int32_t sDebugFlag = 135; int32_t wDebugFlag = 135; int32_t tsdbDebugFlag = 131; +int32_t cqDebugFlag = 135; int32_t (*monitorStartSystemFp)() = NULL; void (*monitorStopSystemFp)() = NULL; @@ -222,12 +223,13 @@ void taosSetAllDebugFlag() { httpDebugFlag = debugFlag; mqttDebugFlag = debugFlag; monitorDebugFlag = debugFlag; + qDebugFlag = debugFlag; rpcDebugFlag = debugFlag; uDebugFlag = debugFlag; sDebugFlag = debugFlag; wDebugFlag = debugFlag; tsdbDebugFlag = debugFlag; - qDebugFlag = debugFlag; + cqDebugFlag = debugFlag; uInfo("all debug flag are set to %d", debugFlag); } } @@ -1209,6 +1211,16 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "cqDebugFlag"; + cfg.ptr = &cqDebugFlag; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG; + cfg.minValue = 0; + cfg.maxValue = 255; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + cfg.option = "tscEnableRecordSql"; cfg.ptr = &tsTscEnableRecordSql; cfg.valType = TAOS_CFG_VTYPE_INT32; diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index 889cc84374..1a99a84b8e 100644 --- a/src/cq/src/cqMain.c +++ b/src/cq/src/cqMain.c @@ -66,8 +66,6 @@ typedef struct SCqObj { SCqContext * pContext; } SCqObj; -int cqDebugFlag = 135; - static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row); static void cqCreateStream(SCqContext *pContext, SCqObj *pObj); @@ -252,6 +250,7 @@ static void cqProcessCreateTimer(void *param, void *tmrId) { SCqContext* pContext = pObj->pContext; if (pContext->dbConn == NULL) { + cDebug("vgId:%d, try connect to TDengine", pContext->vgId); taos_connect_a(NULL, pContext->user, pContext->pass, pContext->db, 0, doCreateStream, param, NULL); } else { cqCreateStream(pContext, pObj); @@ -262,6 +261,7 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) { pObj->pContext = pContext; if (pContext->dbConn == NULL) { + cDebug("vgId:%d, create dbConn after 1000 ms", pContext->vgId); pObj->tmrId = taosTmrStart(cqProcessCreateTimer, 1000, pObj, pContext->tmrCtrl); return; } diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 4400927e9b..a35f09cd8d 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -2122,8 +2122,8 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) { } pMeta->vgroup.vgId = htonl(pMsg->pVgroup->vgId); - mDebug("app:%p:%p, table:%s, uid:%" PRIu64 " table meta is retrieved", pMsg->rpcMsg.ahandle, pMsg, - pTable->info.tableId, pTable->uid); + mDebug("app:%p:%p, table:%s, uid:%" PRIu64 " table meta is retrieved, vgId:%d sid:%d", pMsg->rpcMsg.ahandle, pMsg, + pTable->info.tableId, pTable->uid, pTable->vgId, pTable->sid); return TSDB_CODE_SUCCESS; } diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index 0d444a5a6e..8fccb1442f 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -128,6 +128,7 @@ echo "tmrDebugFlag 131" >> $TAOS_CFG echo "udebugFlag 135" >> $TAOS_CFG echo "sdebugFlag 135" >> $TAOS_CFG echo "wdebugFlag 135" >> $TAOS_CFG +echo "cqdebugFlag 135" >> $TAOS_CFG echo "monitor 0" >> $TAOS_CFG echo "monitorInterval 1" >> $TAOS_CFG echo "http 0" >> $TAOS_CFG diff --git a/tests/script/tmp/prepare.sim b/tests/script/tmp/prepare.sim index 8b8f206233..343c422e9f 100644 --- a/tests/script/tmp/prepare.sim +++ b/tests/script/tmp/prepare.sim @@ -34,11 +34,11 @@ system sh/cfg.sh -n dnode4 -c http -v 1 return # for crash_gen -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 10 system sh/cfg.sh -n dnode1 -c rpcMaxTime -v 101 system sh/cfg.sh -n dnode1 -c cache -v 2 system sh/cfg.sh -n dnode1 -c keep -v 36500 -system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 # for windows diff --git a/tests/script/unique/cluster/vgroup100.sim b/tests/script/unique/cluster/vgroup100.sim index cddb38cefd..bde6dd2462 100644 --- a/tests/script/unique/cluster/vgroup100.sim +++ b/tests/script/unique/cluster/vgroup100.sim @@ -42,9 +42,11 @@ $count = 2 while $count < 102 $db = d . $count $tb = $db . .t + $tb2 = $db . .t2 sql create database $db replica 3 cache 1 blocks 3 sql create table $tb (ts timestamp, i int) sql insert into $tb values(now, 1) + sql create table $tb2 as select count(*) from $tb interval(10s) $count = $count + 1 print insert into $tb values(now, 1) ==> finished endw @@ -74,7 +76,7 @@ print ============================== step6 system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start -sleep 3000 +sleep 10000 print ============================== step7 From fbc4ebb915ea1e94b885fe2ce89d6f350a683642 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 21 Sep 2020 12:53:11 +0800 Subject: [PATCH 14/77] [td-225] fix bugs in regression test. --- src/client/src/tscServer.c | 9 ++++++--- src/rpc/src/rpcMain.c | 2 ++ src/util/src/tcache.c | 10 ++++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index c6e9cbafd7..12712c6542 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -1959,6 +1959,7 @@ int tscProcessShowRsp(SSqlObj *pSql) { return 0; } +// TODO multithread problem static void createHBObj(STscObj* pObj) { if (pObj->pHb != NULL) { return; @@ -1987,10 +1988,13 @@ static void createHBObj(STscObj* pObj) { pSql->pTscObj = pObj; pSql->signature = pSql; pObj->pHb = pSql; - T_REF_INC(pObj); tscAddSubqueryInfo(&pObj->pHb->cmd); + int64_t ad = (int64_t) pSql; + pSql->self = taosCachePut(tscObjCache, &ad, sizeof(int64_t), &pSql, sizeof(int64_t), 2 * 60 * 1000); + T_REF_INC(pObj); + tscDebug("%p HB is allocated, pObj:%p", pObj->pHb, pObj); } @@ -2017,8 +2021,7 @@ int tscProcessConnectRsp(SSqlObj *pSql) { pObj->connId = htonl(pConnect->connId); createHBObj(pObj); - -// taosTmrReset(tscProcessActivityTimer, tsShellActivityTimer * 500, pObj, tscTmr, &pObj->pTimer); + taosTmrReset(tscProcessActivityTimer, tsShellActivityTimer * 500, pObj, tscTmr, &pObj->pTimer); return 0; } diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index f59bf62ec5..cb318d5c24 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -580,6 +580,8 @@ static SRpcConn *rpcOpenConn(SRpcInfo *pRpc, char *peerFqdn, uint16_t peerPort, void *shandle = (connType & RPC_CONN_TCP)? pRpc->tcphandle:pRpc->udphandle; pConn->chandle = (*taosOpenConn[connType])(shandle, pConn, pConn->peerIp, pConn->peerPort); if (pConn->chandle == NULL) { + tError("failed to connect to:0x%x:%d", pConn->peerIp, pConn->peerPort); + terrno = TSDB_CODE_RPC_NETWORK_UNAVAIL; rpcCloseConn(pConn); pConn = NULL; diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index 4d737ebe66..e1dd521547 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -260,7 +260,13 @@ static void incRefFn(void* ptNode) { } void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen) { - if (pCacheObj == NULL || taosHashGetSize(pCacheObj->pHashTable) == 0 || pCacheObj->deleting == 1) { + if (pCacheObj == NULL || pCacheObj->deleting == 1) { + return NULL; + } + + if (taosHashGetSize(pCacheObj->pHashTable) == 0) { + atomic_add_fetch_32(&pCacheObj->statistics.missCount, 1); + uError("cache:%s, key:%p, not in cache, retrieved failed, reason: empty sqlObj cache", pCacheObj->name, key); return NULL; } @@ -274,7 +280,7 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen uDebug("cache:%s, key:%p, %p is retrieved from cache, refcnt:%d", pCacheObj->name, key, pData, T_REF_VAL_GET(ptNode)); } else { atomic_add_fetch_32(&pCacheObj->statistics.missCount, 1); - uDebug("cache:%s, key:%p, not in cache, retrieved failed", pCacheObj->name, key); + uError("cache:%s, key:%p, not in cache, retrieved failed", pCacheObj->name, key); } atomic_add_fetch_32(&pCacheObj->statistics.totalAccess, 1); From ad1c82b6db4f6736a4e48b2eea1eae7f11bb9268 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 21 Sep 2020 13:20:23 +0800 Subject: [PATCH 15/77] [td-225] fix bugs in regression test. --- src/client/src/tscServer.c | 4 ++-- src/client/src/tscSql.c | 29 ++++++----------------------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 12712c6542..ddbee3106d 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -188,8 +188,8 @@ void tscProcessActivityTimer(void *handle, void *tmrId) { if (tscShouldFreeHeartBeat(pHB)) { tscDebug("%p free HB object and release connection", pHB); - tscFreeSqlObj(pHB); - tscCloseTscObj(pObj); + pObj->pHb = 0; + taos_free_result(pHB); } else { int32_t code = tscProcessSql(pHB); if (code != TSDB_CODE_SUCCESS) { diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 69bc69cd4a..682211adbd 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -255,33 +255,16 @@ void taos_close(TAOS *taos) { return; } - if (pObj->pHb != NULL) { - if (pObj->pHb->pRpcCtx != NULL) { // wait for rsp from dnode - rpcCancelRequest(pObj->pHb->pRpcCtx); + SSqlObj* pHb = pObj->pHb; + if (pHb != NULL) { + if (pHb->pRpcCtx != NULL) { // wait for rsp from dnode + rpcCancelRequest(pHb->pRpcCtx); } - tscSetFreeHeatBeat(pObj); - tscFreeSqlObj(pObj->pHb); + pObj->pHb = NULL; + taos_free_result(pHb); } - // free all sqlObjs created by using this connect before free the STscObj -// while(1) { -// pthread_mutex_lock(&pObj->mutex); -// void* p = pObj->sqlList; -// pthread_mutex_unlock(&pObj->mutex); -// -// if (p == NULL) { -// break; -// } -// -// tscDebug("%p waiting for sqlObj to be freed, %p", pObj, p); -// taosMsleep(100); -// -// // todo fix me!! two threads call taos_free_result will cause problem. -// tscDebug("%p free :%p", pObj, p); -// taos_free_result(p); -// } - int32_t ref = T_REF_DEC(pObj); assert(ref >= 0); From f982f2df5edcd9c7a7421d9cdd19ae766a7fd9da Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 21 Sep 2020 15:17:27 +0800 Subject: [PATCH 16/77] [td-225] fix bugs in regression test. --- src/client/src/tscStream.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index 4a1f4d9d87..da9497dda5 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -615,10 +615,9 @@ void taos_close_stream(TAOS_STREAM *handle) { tscDebug("%p stream:%p is closed", pSql, pStream); // notify CQ to release the pStream object pStream->fp(pStream->param, NULL, NULL); + taos_free_result(pSql); - tscFreeSqlObj(pSql); pStream->pSql = NULL; - taosTFree(pStream); } } From 47d974994c0b8c2199518fc654ae2eb577d5a539 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 21 Sep 2020 15:23:17 +0800 Subject: [PATCH 17/77] [td-225] fix bugs in regression test. --- src/client/src/tscStream.c | 4 ++-- src/client/src/tscSubquery.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index da9497dda5..88dcfc2bb3 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -615,9 +615,9 @@ void taos_close_stream(TAOS_STREAM *handle) { tscDebug("%p stream:%p is closed", pSql, pStream); // notify CQ to release the pStream object pStream->fp(pStream->param, NULL, NULL); - taos_free_result(pSql); - pStream->pSql = NULL; + + taos_free_result(pSql); taosTFree(pStream); } } diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index f9bb180810..a6304c5ef3 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -1383,7 +1383,7 @@ static void doCleanupSubqueries(SSqlObj *pSql, int32_t numOfSubs, SSubqueryState taosTFree(pSupport->localBuffer); taosTFree(pSupport); - tscFreeSqlObj(pSub); + taos_free_result(pSub); } free(pState); From f91fccd82e53ea7735a608dcaafa439ab9228f05 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 21 Sep 2020 15:41:29 +0800 Subject: [PATCH 18/77] [td-225] fix bugs in regression test. --- src/client/src/tscSubquery.c | 2 +- src/client/src/tscUtil.c | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index a6304c5ef3..e66b361191 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -278,7 +278,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { tscDebug("%p subIndex: %d, no need to launch query, ignore it", pSql, i); tscDestroyJoinSupporter(pSupporter); - tscFreeSqlObj(pPrevSub); + taos_free_result(pPrevSub); pSql->pSubs[i] = NULL; continue; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 38fb63f18e..20c3bc2cb6 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1743,8 +1743,6 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm } pNew->pTscObj = pSql->pTscObj; - T_REF_INC(pNew->pTscObj); - pNew->signature = pNew; SSqlCmd* pCmd = &pNew->cmd; @@ -1777,7 +1775,6 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm tscAddTableMetaInfo(pQueryInfo, pMasterTableMetaInfo->name, NULL, NULL, NULL); T_REF_INC(pNew->pTscObj); - uint64_t p = (uint64_t) pNew; pNew->self = taosCachePut(tscObjCache, &p, sizeof(uint64_t), &pNew, sizeof(uint64_t), 2 * 600 * 1000); return pNew; From d8a9ead27a3a987adeb10b77a095b28f58afc4d3 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 21 Sep 2020 16:06:55 +0800 Subject: [PATCH 19/77] [td-225] fix bugs in regression test. --- src/client/src/tscStream.c | 3 ++- src/util/src/tcache.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index 478787671f..fed9caebbe 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -572,6 +572,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p pStream->pSql = pSql; pSql->pStream = pStream; pSql->param = pStream; + pSql->maxRetry = TSDB_MAX_REPLICA; pSql->sqlstr = calloc(1, strlen(sqlstr) + 1); if (pSql->sqlstr == NULL) { @@ -579,6 +580,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p tscFreeSqlObj(pSql); return NULL; } + strtolower(pSql->sqlstr, sqlstr); tscDebugL("%p SQL: %s", pSql, pSql->sqlstr); @@ -612,7 +614,6 @@ void taos_close_stream(TAOS_STREAM *handle) { * Here, we need a check before release memory */ if (pSql->signature == pSql) { - T_REF_DEC(pSql->pTscObj); tscRemoveFromStreamList(pStream, pSql); taosTmrStopA(&(pStream->pTimer)); diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index e1dd521547..a6376e49ad 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -266,7 +266,7 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen if (taosHashGetSize(pCacheObj->pHashTable) == 0) { atomic_add_fetch_32(&pCacheObj->statistics.missCount, 1); - uError("cache:%s, key:%p, not in cache, retrieved failed, reason: empty sqlObj cache", pCacheObj->name, key); + uError("cache:%s, key:%p, not in cache, retrieved failed, reason: empty cache", pCacheObj->name, key); return NULL; } From 595081eab0c910b37b826ded445f4b9e1781e91a Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Mon, 21 Sep 2020 16:20:21 +0800 Subject: [PATCH 20/77] Update insert-ch.md --- documentation20/webdocs/markdowndocs/insert-ch.md | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation20/webdocs/markdowndocs/insert-ch.md b/documentation20/webdocs/markdowndocs/insert-ch.md index 5e4532dfd0..a84b577622 100644 --- a/documentation20/webdocs/markdowndocs/insert-ch.md +++ b/documentation20/webdocs/markdowndocs/insert-ch.md @@ -25,6 +25,7 @@ INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31) (1538548695000, 12.6, - 要提高写入效率,需要批量写入。一批写入的记录条数越多,插入效率就越高。但一条记录不能超过16K,一条SQL语句总长度不能超过64K(可通过参数maxSQLLength配置,最大可配置为8M)。 - TDengine支持多线程同时写入,要进一步提高写入速度,一个客户端需要打开20个以上的线程同时写。但线程数达到一定数量后,无法再提高,甚至还会下降,因为线程切频繁切换,带来额外开销。 - 对同一张表,如果新插入记录的时间戳已经存在,新记录将被直接抛弃,也就是说,在一张表里,时间戳必须是唯一的。如果应用自动生成记录,很有可能生成的时间戳是一样的,这样,成功插入的记录条数会小于应用插入的记录条数。 +- 写入的数据的时间戳必须大于当前时间减去配置参数keep的时间。如果keep配置为3650天,那么无法写入比3650天还老的数据。写入数据的时间戳也不能大于当前时间加配置参数days。如果days配置为2,那么无法写入比当前时间还晚2天的数据。 ## Prometheus直接写入 [Prometheus](https://www.prometheus.io/)作为Cloud Native Computing Fundation毕业的项目,在性能监控以及K8S性能监控领域有着非常广泛的应用。TDengine提供一个小工具[Bailongma](https://github.com/taosdata/Bailongma),只需在Prometheus做简单配置,无需任何代码,就可将Prometheus采集的数据直接写入TDengine,并按规则在TDengine自动创建库和相关表项。博文[用Docker容器快速搭建一个Devops监控Demo](https://www.taosdata.com/blog/2020/02/03/1189.html)即是采用bailongma将Prometheus和Telegraf的数据写入TDengine中的示例,可以参考。 From 6e3d63727b27184acd0089a398621b18d39aa192 Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Mon, 21 Sep 2020 16:24:12 +0800 Subject: [PATCH 21/77] use cache in subscribe & prepare --- src/client/src/tscPrepare.c | 6 +++++- src/client/src/tscStream.c | 3 +-- src/client/src/tscSub.c | 14 +++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 620e8ea57a..c4ca6793ff 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -546,6 +546,10 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { pSql->cmd.numOfParams = 0; pSql->cmd.batchSize = 0; + uint64_t handle = (uint64_t) pSql; + pSql->self = taosCachePut(tscObjCache, &handle, sizeof(uint64_t), &pSql, sizeof(uint64_t), 2*3600*1000); + T_REF_INC(pSql->pTscObj); + int32_t code = tsParseSql(pSql, true); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { // wait for the callback function to post the semaphore @@ -574,7 +578,7 @@ int taos_stmt_close(TAOS_STMT* stmt) { free(normal->sql); } - tscFreeSqlObj(pStmt->pSql); + taos_free_result(pStmt->pSql); free(pStmt); return TSDB_CODE_SUCCESS; } diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index 93a865a78b..1ebef4ce0f 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -612,7 +612,6 @@ void taos_close_stream(TAOS_STREAM *handle) { * Here, we need a check before release memory */ if (pSql->signature == pSql) { - T_REF_DEC(pSql->pTscObj); tscRemoveFromStreamList(pStream, pSql); taosTmrStopA(&(pStream->pTimer)); @@ -621,7 +620,7 @@ void taos_close_stream(TAOS_STREAM *handle) { // notify CQ to release the pStream object pStream->fp(pStream->param, NULL, NULL); - tscFreeSqlObj(pSql); + taos_free_result(pSql); pStream->pSql = NULL; taosTFree(pStream); diff --git a/src/client/src/tscSub.c b/src/client/src/tscSub.c index 76bce19668..760c5f5a51 100644 --- a/src/client/src/tscSub.c +++ b/src/client/src/tscSub.c @@ -152,6 +152,10 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* goto fail; } + uint64_t handle = (uint64_t) pSql; + pSql->self = taosCachePut(tscObjCache, &handle, sizeof(uint64_t), &pSql, sizeof(uint64_t), 2*3600*1000); + T_REF_INC(pSql->pTscObj); + code = tsParseSql(pSql, false); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { tsem_wait(&pSub->sem); @@ -173,7 +177,11 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* fail: tscError("tscCreateSubscription failed at line %d, reason: %s", line, tstrerror(code)); if (pSql != NULL) { - tscFreeSqlObj(pSql); + if (pSql->self != NULL) { + taos_free_result(pSql); + } else { + tscFreeSqlObj(pSql); + } pSql = NULL; } if (pSub != NULL) { @@ -494,6 +502,10 @@ void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress) { } } + if (pSub->pSql != NULL) { + taos_free_result(pSub->pSql); + } + tscFreeSqlObj(pSub->pSql); taosArrayDestroy(pSub->progress); tsem_destroy(&pSub->sem); From c84ecd4c1bd2caad1d8ee8e7c94c8d31a58ab01b Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Mon, 21 Sep 2020 16:24:12 +0800 Subject: [PATCH 22/77] use cache in subscribe & prepare --- src/client/src/tscPrepare.c | 6 +++++- src/client/src/tscSub.c | 14 +++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 620e8ea57a..c4ca6793ff 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -546,6 +546,10 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { pSql->cmd.numOfParams = 0; pSql->cmd.batchSize = 0; + uint64_t handle = (uint64_t) pSql; + pSql->self = taosCachePut(tscObjCache, &handle, sizeof(uint64_t), &pSql, sizeof(uint64_t), 2*3600*1000); + T_REF_INC(pSql->pTscObj); + int32_t code = tsParseSql(pSql, true); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { // wait for the callback function to post the semaphore @@ -574,7 +578,7 @@ int taos_stmt_close(TAOS_STMT* stmt) { free(normal->sql); } - tscFreeSqlObj(pStmt->pSql); + taos_free_result(pStmt->pSql); free(pStmt); return TSDB_CODE_SUCCESS; } diff --git a/src/client/src/tscSub.c b/src/client/src/tscSub.c index 76bce19668..760c5f5a51 100644 --- a/src/client/src/tscSub.c +++ b/src/client/src/tscSub.c @@ -152,6 +152,10 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* goto fail; } + uint64_t handle = (uint64_t) pSql; + pSql->self = taosCachePut(tscObjCache, &handle, sizeof(uint64_t), &pSql, sizeof(uint64_t), 2*3600*1000); + T_REF_INC(pSql->pTscObj); + code = tsParseSql(pSql, false); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { tsem_wait(&pSub->sem); @@ -173,7 +177,11 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* fail: tscError("tscCreateSubscription failed at line %d, reason: %s", line, tstrerror(code)); if (pSql != NULL) { - tscFreeSqlObj(pSql); + if (pSql->self != NULL) { + taos_free_result(pSql); + } else { + tscFreeSqlObj(pSql); + } pSql = NULL; } if (pSub != NULL) { @@ -494,6 +502,10 @@ void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress) { } } + if (pSub->pSql != NULL) { + taos_free_result(pSub->pSql); + } + tscFreeSqlObj(pSub->pSql); taosArrayDestroy(pSub->progress); tsem_destroy(&pSub->sem); From 04c20b25ad22ebc843a82bacc0b9f766cd6ea56f Mon Sep 17 00:00:00 2001 From: Hui Li Date: Mon, 21 Sep 2020 18:28:36 +0800 Subject: [PATCH 23/77] fix binary length --- src/connector/go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connector/go b/src/connector/go index 8c58c512b6..f4f6b76812 160000 --- a/src/connector/go +++ b/src/connector/go @@ -1 +1 @@ -Subproject commit 8c58c512b6acda8bcdfa48fdc7140227b5221766 +Subproject commit f4f6b768124a634b3c2408351c4d91df20f8de3f From d7f0a598910c9ae25457c24f96e7c7b3fb7f785e Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Mon, 21 Sep 2020 19:00:27 +0800 Subject: [PATCH 24/77] [TD-1543] adjust CI cases --- tests/perftest-scripts/coverage_test.sh | 2 +- tests/pytest/fulltest.sh | 5 +++++ tests/test-all.sh | 7 ++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/perftest-scripts/coverage_test.sh b/tests/perftest-scripts/coverage_test.sh index a0c8fe4b3f..5085ec89d0 100755 --- a/tests/perftest-scripts/coverage_test.sh +++ b/tests/perftest-scripts/coverage_test.sh @@ -53,7 +53,7 @@ function buildTDengine { function runGeneralCaseOneByOne { while read -r line; do if [[ $line =~ ^./test.sh* ]]; then - case=`echo $line | grep -w "general\|unique\/mnode\/mgmt33.sim\|unique\/stable\/dnode3.sim\|unique\/cluster\/balance3.sim\|unique\/arbitrator\/offline_replica2_alterTable_online.sim"|awk '{print $NF}'` + case=`echo $line | grep sim$ |awk '{print $NF}'` if [ -n "$case" ]; then ./test.sh -f $case > /dev/null 2>&1 && \ diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 9ebf1584e2..d4ffb6663f 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -192,3 +192,8 @@ python3 test.py -f query/queryInterval.py # tools python3 test.py -f tools/taosdemo.py + +# subscribe +python3 test.py -f subscribe/singlemeter.py +python3 test.py -f subscribe/stability.py +python3 test.py -f subscribe/supertable.py \ No newline at end of file diff --git a/tests/test-all.sh b/tests/test-all.sh index 275c6b1677..84b663809d 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -9,8 +9,9 @@ NC='\033[0m' function runSimCaseOneByOne { while read -r line; do - if [[ $line =~ ^run.* ]]; then - case=`echo $line | awk '{print $NF}'` + if [[ $line =~ ^./test.sh* ]]; then + case=`echo $line | grep sim$ |awk '{print $NF}'` + start_time=`date +%s` ./test.sh -f $case > /dev/null 2>&1 && \ echo -e "${GREEN}$case success${NC}" | tee -a out.log || \ @@ -54,7 +55,7 @@ if [ "$2" != "python" ]; then runSimCaseOneByOne regressionSuite.sim elif [ "$1" == "full" ]; then echo "### run TSIM full test ###" - runSimCaseOneByOne fullGeneralSuite.sim + runSimCaseOneByOne jenkins/basic.txt elif [ "$1" == "smoke" ] || [ -z "$1" ]; then echo "### run TSIM smoke test ###" runSimCaseOneByOne basicSuite.sim From ba968b813c09b9f5be8efccb3d19228633f35631 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 21 Sep 2020 13:42:48 +0000 Subject: [PATCH 25/77] fix bug TD-1521 --- src/mnode/src/mnodeTable.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index a35f09cd8d..cb606df692 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -1384,6 +1384,9 @@ int32_t mnodeRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows, } pShow->numOfReads += numOfRows; + const int32_t NUM_OF_COLUMNS = 5; + + mnodeVacuumResult(data, NUM_OF_COLUMNS, numOfRows, rows, pShow); mnodeDecDbRef(pDb); return numOfRows; From d123d8001f7808d510852b2796a433fab6ddb403 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 22 Sep 2020 11:19:45 +0800 Subject: [PATCH 26/77] TD-1415 --- src/vnode/src/vnodeWrite.c | 11 ++++++++-- tests/test/c/CMakeLists.txt | 12 +++++------ tests/test/c/createNormalTable.c | 35 ++++++++++++++++++++++++-------- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 1a9b05ed34..0c310439bb 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -130,8 +130,15 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe int code = TSDB_CODE_SUCCESS; STableCfg *pCfg = tsdbCreateTableCfgFromMsg((SMDCreateTableMsg *)pCont); - if (pCfg == NULL) return terrno; - if (tsdbCreateTable(pVnode->tsdb, pCfg) < 0) code = terrno; + if (pCfg == NULL) { + ASSERT(terrno != 0); + return terrno; + } + + if (tsdbCreateTable(pVnode->tsdb, pCfg) < 0) { + code = terrno; + ASSERT(code != 0); + } tsdbClearTableCfg(pCfg); return code; diff --git a/tests/test/c/CMakeLists.txt b/tests/test/c/CMakeLists.txt index ffab39d41c..c75316de81 100644 --- a/tests/test/c/CMakeLists.txt +++ b/tests/test/c/CMakeLists.txt @@ -31,16 +31,16 @@ IF (TD_LINUX) #add_executable(createTablePerformance createTablePerformance.c) #target_link_libraries(createTablePerformance taos_static tutil common pthread) - #add_executable(createNormalTable createNormalTable.c) - #target_link_libraries(createNormalTable taos_static tutil common pthread) + add_executable(createNormalTable createNormalTable.c) + target_link_libraries(createNormalTable taos_static tutil common pthread) #add_executable(queryPerformance queryPerformance.c) #target_link_libraries(queryPerformance taos_static tutil common pthread) - add_executable(httpTest httpTest.c) - target_link_libraries(httpTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) + #add_executable(httpTest httpTest.c) + #target_link_libraries(httpTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) - add_executable(cacheTest cacheTest.c) - target_link_libraries(cacheTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) + #add_executable(cacheTest cacheTest.c) + #target_link_libraries(cacheTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) ENDIF() diff --git a/tests/test/c/createNormalTable.c b/tests/test/c/createNormalTable.c index 18a648b9e1..60253e2add 100644 --- a/tests/test/c/createNormalTable.c +++ b/tests/test/c/createNormalTable.c @@ -50,7 +50,9 @@ void createDbAndSTable(); int main(int argc, char *argv[]) { shellParseArgument(argc, argv); taos_init(); - createDbAndSTable(); + if (replica != 0) { + createDbAndSTable(); + } pPrint("%d threads are spawned to create table", numOfThreads); @@ -134,14 +136,31 @@ void *threadFunc(void *param) { int64_t startMs = taosGetTimestampMs(); - for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { - sprintf(qstr, "create table %s%d (ts timestamp, i int)", stableName, t); - TAOS_RES *pSql = taos_query(con, qstr); - code = taos_errno(pSql); - if (code != 0) { - pError("failed to create table %s%d, reason:%s", stableName, t, tstrerror(code)); + if (replica != 0) { + for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { + sprintf(qstr, "create table %s%d (ts timestamp, i int)", stableName, t); + TAOS_RES *pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to create table %s%d, reason:%s", stableName, t, tstrerror(code)); + } + taos_free_result(pSql); + } + } else { + for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { + sprintf(qstr, "insert into %s%d values(now, 1)", stableName, t); + TAOS_RES *pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + if (code != TSDB_CODE_MND_INVALID_TABLE_NAME) { + pError("failed to create table %s%d, reason:%s", stableName, t, tstrerror(code)); + } + if (code == TSDB_CODE_VND_INVALID_VGROUP_ID) { + exit(0); + } + } + taos_free_result(pSql); } - taos_free_result(pSql); } float createTableSpeed = 0; From 6b3dcdda9c1ece432fb6d653ebdff0464daf5e46 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 22 Sep 2020 11:42:50 +0800 Subject: [PATCH 27/77] TD-1453 --- src/vnode/src/vnodeRead.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c index 017eeaf426..58e97075ac 100644 --- a/src/vnode/src/vnodeRead.c +++ b/src/vnode/src/vnodeRead.c @@ -58,7 +58,8 @@ int32_t vnodeProcessRead(void *param, SReadMsg *pReadMsg) { return TSDB_CODE_APP_NOT_READY; // TODO: Later, let slave to support query - if (pVnode->syncCfg.replica > 1 && pVnode->role != TAOS_SYNC_ROLE_MASTER) { + // if (pVnode->syncCfg.replica > 1 && pVnode->role != TAOS_SYNC_ROLE_MASTER) { + if (pVnode->role != TAOS_SYNC_ROLE_SLAVE && pVnode->role != TAOS_SYNC_ROLE_MASTER) { vDebug("vgId:%d, msgType:%s not processed, replica:%d role:%d", pVnode->vgId, taosMsg[msgType], pVnode->syncCfg.replica, pVnode->role); return TSDB_CODE_APP_NOT_READY; } From 67efcff7adab751b043c6ad5c3762ff5fbf40a1d Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 22 Sep 2020 13:47:18 +0800 Subject: [PATCH 28/77] [td-225] fix bugs in regression test. --- src/client/src/tscSql.c | 5 +++-- src/util/src/tcache.c | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 598ec7e546..8b79b0278b 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -264,12 +264,13 @@ void taos_close(TAOS *taos) { } SSqlObj* pHb = pObj->pHb; - if (pHb != NULL) { + if (pHb != NULL && atomic_val_compare_exchange_ptr(&pObj->pHb, pHb, 0) == pHb) { if (pHb->pRpcCtx != NULL) { // wait for rsp from dnode rpcCancelRequest(pHb->pRpcCtx); + pHb->pRpcCtx = NULL; } - pObj->pHb = NULL; + tscDebug("%p, HB is freed", pHb); taos_free_result(pHb); } diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index a6376e49ad..337513940a 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -266,7 +266,6 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen if (taosHashGetSize(pCacheObj->pHashTable) == 0) { atomic_add_fetch_32(&pCacheObj->statistics.missCount, 1); - uError("cache:%s, key:%p, not in cache, retrieved failed, reason: empty cache", pCacheObj->name, key); return NULL; } From 7b2fbddfa7b4dae4a9c1e9b9627e2543fa8c808d Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Tue, 22 Sep 2020 14:06:22 +0800 Subject: [PATCH 29/77] [TD-1386] add test case for retention --- tests/pytest/insert/retentionpolicy.py | 108 +++++++++++++++++++++++++ tests/pytest/test.sh | 1 + 2 files changed, 109 insertions(+) create mode 100644 tests/pytest/insert/retentionpolicy.py diff --git a/tests/pytest/insert/retentionpolicy.py b/tests/pytest/insert/retentionpolicy.py new file mode 100644 index 0000000000..bd294a24f3 --- /dev/null +++ b/tests/pytest/insert/retentionpolicy.py @@ -0,0 +1,108 @@ +################################################################### +# 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 +import os +import datetime +sys.path.insert(0, os.getcwd()) +import taos +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestRetetion: + def init(self): + self.queryRows=0 + tdLog.debug("start to execute %s" % __file__) + tdLog.info("prepare cluster") + tdDnodes.init("") + tdDnodes.setTestCluster(False) + tdDnodes.setValgrind(False) + tdDnodes.stopAll() + tdDnodes.deploy(1) + tdDnodes.start(1) + print(tdDnodes.getDnodesRootDir()) + self.conn = taos.connect(config=tdDnodes.getSimCfgPath()) + tdSql.init(self.conn.cursor()) + tdSql.execute('reset query cache') + def checkRows(self, expectRows,sql): + if self.queryRows == expectRows: + tdLog.info("sql:%s, queryRows:%d == expect:%d" % (sql, self.queryRows, expectRows)) + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, self.queryRows, expectRows) + os.system("timedatectl set-ntp true") + tdLog.exit("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) + + def run(self): + + tdLog.info("=============== step1") + tdSql.execute('create database test keep 3 days 1;') + tdSql.execute('use test;') + tdSql.execute('create table test(ts timestamp,i int);') + + cmd = 'insert into test values(now-2d,11)(now-1d,11)(now,11)(now+1d,11);' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from test') + tdSql.checkRows(4) + + tdLog.info("=============== step2") + tdDnodes.stop(1) + os.system("timedatectl set-ntp false") + os.system("date -s $(date -d \"${DATE} 2 days\" \"+%Y%m%d\")") + tdDnodes.start(1) + cmd = 'insert into test values(now,11);' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from test') + tdSql.checkRows(5) + + tdLog.info("=============== step3") + tdDnodes.stop(1) + os.system("date -s $(date -d \"${DATE} 2 days\" \"+%Y%m%d\")") + tdDnodes.start(1) + cmd = 'insert into test values(now-1d,11);' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from test') + tdSql.checkRows(6) + tdLog.info("=============== step4") + tdDnodes.stop(1) + tdDnodes.start(1) + cmd = 'insert into test values(now,11);' + tdLog.info(cmd) + tdSql.execute(cmd) + tdSql.query('select * from test') + tdSql.checkRows(7) + + tdLog.info("=============== step5") + tdDnodes.stop(1) + tdDnodes.start(1) + cmd='select * from test where ts > now-1d' + queryRows=tdSql.query('select * from test where ts > now-1d') + self.checkRows(1,cmd) + + def stop(self): + os.system("timedatectl set-ntp true") + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +clients = TDTestRetetion() +clients.init() +clients.run() +clients.stop() + diff --git a/tests/pytest/test.sh b/tests/pytest/test.sh index fbb9ba9879..d76c88c6ea 100755 --- a/tests/pytest/test.sh +++ b/tests/pytest/test.sh @@ -12,6 +12,7 @@ else TAOS_DIR=$CURR_DIR/../.. fi TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1` +TAOS_BIN_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6|rev`/bin LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6|rev`/lib export PYTHONPATH=$(pwd)/../../src/connector/python/linux/python3 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB_DIR From 5fe097a4022677ac94d6fe9092f32f2b0854619c Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Tue, 22 Sep 2020 14:18:30 +0800 Subject: [PATCH 30/77] [TD-1386] add test case for retention --- tests/pytest/fulltest.sh | 1 + tests/pytest/test.sh | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 9ebf1584e2..1ed2f688a8 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -16,6 +16,7 @@ python3 ./test.py -f insert/nchar.py python3 ./test.py -f insert/nchar-unicode.py python3 ./test.py -f insert/multi.py python3 ./test.py -f insert/randomNullCommit.py +python3 insert/retentionpolicy.py python3 ./test.py -f table/column_name.py python3 ./test.py -f table/column_num.py diff --git a/tests/pytest/test.sh b/tests/pytest/test.sh index d76c88c6ea..fbb9ba9879 100755 --- a/tests/pytest/test.sh +++ b/tests/pytest/test.sh @@ -12,7 +12,6 @@ else TAOS_DIR=$CURR_DIR/../.. fi TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1` -TAOS_BIN_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6|rev`/bin LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6|rev`/lib export PYTHONPATH=$(pwd)/../../src/connector/python/linux/python3 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB_DIR From eb0f6a1e45504ffa54f28418252965c65a612e49 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 22 Sep 2020 14:22:45 +0800 Subject: [PATCH 31/77] [td-1544] --- src/mnode/src/mnodeShow.c | 6 ++++-- src/util/src/tcache.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mnode/src/mnodeShow.c b/src/mnode/src/mnodeShow.c index f66ef6b7a3..f2caf30564 100644 --- a/src/mnode/src/mnodeShow.c +++ b/src/mnode/src/mnodeShow.c @@ -65,7 +65,7 @@ int32_t mnodeInitShow() { mnodeAddReadMsgHandle(TSDB_MSG_TYPE_CM_CONNECT, mnodeProcessConnectMsg); mnodeAddReadMsgHandle(TSDB_MSG_TYPE_CM_USE_DB, mnodeProcessUseMsg); - tsMnodeShowCache = taosCacheInit(TSDB_DATA_TYPE_BIGINT, 5, false, mnodeFreeShowObj, "show"); + tsMnodeShowCache = taosCacheInit(TSDB_DATA_TYPE_BIGINT, 5, true, mnodeFreeShowObj, "show"); return 0; } @@ -389,10 +389,12 @@ static bool mnodeAccquireShowObj(SShowObj *pShow) { } static void* mnodePutShowObj(SShowObj *pShow) { + const int32_t DEFAULT_SHOWHANDLE_LIFE_SPAN = tsShellActivityTimer * 6 * 1000; + if (tsMnodeShowCache != NULL) { pShow->index = atomic_add_fetch_32(&tsShowObjIndex, 1); uint64_t handleVal = (uint64_t)pShow; - SShowObj **ppShow = taosCachePut(tsMnodeShowCache, &handleVal, sizeof(int64_t), &pShow, sizeof(int64_t), 6000); + SShowObj **ppShow = taosCachePut(tsMnodeShowCache, &handleVal, sizeof(int64_t), &pShow, sizeof(int64_t), DEFAULT_SHOWHANDLE_LIFE_SPAN); pShow->ppShow = (void**)ppShow; mDebug("%p, show is put into cache, data:%p index:%d", pShow, ppShow, pShow->index); return pShow; diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index 337513940a..49b9996cf4 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -279,7 +279,7 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen uDebug("cache:%s, key:%p, %p is retrieved from cache, refcnt:%d", pCacheObj->name, key, pData, T_REF_VAL_GET(ptNode)); } else { atomic_add_fetch_32(&pCacheObj->statistics.missCount, 1); - uError("cache:%s, key:%p, not in cache, retrieved failed", pCacheObj->name, key); + uDebug("cache:%s, key:%p, not in cache, retrieved failed", pCacheObj->name, key); } atomic_add_fetch_32(&pCacheObj->statistics.totalAccess, 1); From 8f610e98d124dea16306d4ec84d19d2a1f6c0132 Mon Sep 17 00:00:00 2001 From: Hui Li Date: Tue, 22 Sep 2020 14:54:25 +0800 Subject: [PATCH 32/77] [TD-1465] --- src/connector/go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connector/go b/src/connector/go index f4f6b76812..06ec30a0f1 160000 --- a/src/connector/go +++ b/src/connector/go @@ -1 +1 @@ -Subproject commit f4f6b768124a634b3c2408351c4d91df20f8de3f +Subproject commit 06ec30a0f1762e8169bf6b9045c82bcaa52bcdf0 From d10a3cdd113884c13f20c8a8c85d0ea868eef428 Mon Sep 17 00:00:00 2001 From: Hui Li Date: Tue, 22 Sep 2020 15:28:12 +0800 Subject: [PATCH 33/77] [update version info] --- cmake/version.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/version.inc b/cmake/version.inc index 52d62fca65..aa8a4b6463 100644 --- a/cmake/version.inc +++ b/cmake/version.inc @@ -4,7 +4,7 @@ PROJECT(TDengine) IF (DEFINED VERNUMBER) SET(TD_VER_NUMBER ${VERNUMBER}) ELSE () - SET(TD_VER_NUMBER "2.0.3.0") + SET(TD_VER_NUMBER "2.0.4.0") ENDIF () IF (DEFINED VERCOMPATIBLE) From f4605ba05ee1e5d1fff6dd312f8a6358c340e2bf Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 22 Sep 2020 15:28:35 +0800 Subject: [PATCH 34/77] TD-1451 --- src/common/src/tglobal.c | 2 +- src/plugins/http/inc/httpJson.h | 2 +- src/plugins/http/src/httpJson.c | 10 +++++----- src/plugins/http/src/httpUtil.c | 14 ++++++++++---- tests/script/general/http/gzip.sim | 16 ++++++++++++++-- tests/script/jenkins/basic.txt | 1 + 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 94ec6fde0f..a75e712f38 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -131,7 +131,7 @@ uint16_t tsHttpPort = 6041; // only tcp, range tcp[6041] int32_t tsHttpCacheSessions = 1000; int32_t tsHttpSessionExpire = 36000; int32_t tsHttpMaxThreads = 2; -int32_t tsHttpEnableCompress = 0; +int32_t tsHttpEnableCompress = 1; int32_t tsHttpEnableRecordSql = 0; int32_t tsTelegrafUseFieldNum = 0; diff --git a/src/plugins/http/inc/httpJson.h b/src/plugins/http/inc/httpJson.h index ac0a632137..fcb74253b9 100644 --- a/src/plugins/http/inc/httpJson.h +++ b/src/plugins/http/inc/httpJson.h @@ -19,7 +19,7 @@ #include #include -#define JSON_BUFFER_SIZE 10240 +#define JSON_BUFFER_SIZE 16384 struct HttpContext; enum { JsonNumber, JsonString, JsonBoolean, JsonArray, JsonObject, JsonNull }; diff --git a/src/plugins/http/src/httpJson.c b/src/plugins/http/src/httpJson.c index e9a8947df2..7600fb3e43 100644 --- a/src/plugins/http/src/httpJson.c +++ b/src/plugins/http/src/httpJson.c @@ -52,12 +52,12 @@ int32_t httpWriteBufByFd(struct HttpContext* pContext, const char* buf, int32_t } if (len < 0) { - httpDebug("context:%p, fd:%d, socket write errno:%d, times:%d", pContext, pContext->fd, errno, countWait); + httpDebug("context:%p, fd:%d, socket write errno:%d:%s, times:%d", pContext, pContext->fd, errno, strerror(errno), countWait); if (++countWait > HTTP_WRITE_RETRY_TIMES) break; taosMsleep(HTTP_WRITE_WAIT_TIME_MS); continue; } else if (len == 0) { - httpDebug("context:%p, fd:%d, socket write errno:%d, connect already closed", pContext, pContext->fd, errno); + httpDebug("context:%p, fd:%d, socket write errno:%d:%s, connect already closed", pContext, pContext->fd, errno, strerror(errno)); break; } else { countWait = 0; @@ -131,14 +131,14 @@ int32_t httpWriteJsonBufBody(JsonBuf* buf, bool isTheLast) { httpWriteBufNoTrace(buf->pContext, sLen, len); remain = httpWriteBufNoTrace(buf->pContext, (const char*)compressBuf, compressBufLen); } else { - httpTrace("context:%p, fd:%d, last:%d, compress already dumped, response:\n%s", buf->pContext, + httpDebug("context:%p, fd:%d, last:%d, compress already dumped, response:\n%s", buf->pContext, buf->pContext->fd, isTheLast, buf->buf); - return 0; // there is no data to dump. + remain = 0; // there is no data to dump. } } else { httpError("context:%p, fd:%d, failed to compress data, chunkSize:%" PRIu64 ", last:%d, error:%d, response:\n%s", buf->pContext, buf->pContext->fd, srcLen, isTheLast, ret, buf->buf); - return 0; + remain = 0; } } diff --git a/src/plugins/http/src/httpUtil.c b/src/plugins/http/src/httpUtil.c index 2c8879f880..39168ee96d 100644 --- a/src/plugins/http/src/httpUtil.c +++ b/src/plugins/http/src/httpUtil.c @@ -406,15 +406,21 @@ int32_t httpGzipCompressInit(HttpContext *pContext) { int32_t httpGzipCompress(HttpContext *pContext, char *srcData, int32_t nSrcData, char *destData, int32_t *nDestData, bool isTheLast) { int32_t err = 0; + int32_t lastTotalLen = (int32_t) (pContext->gzipStream.total_out); pContext->gzipStream.next_in = (Bytef *) srcData; pContext->gzipStream.avail_in = (uLong) nSrcData; pContext->gzipStream.next_out = (Bytef *) destData; pContext->gzipStream.avail_out = (uLong) (*nDestData); - while (pContext->gzipStream.avail_in != 0 && pContext->gzipStream.total_out < (uLong) (*nDestData)) { + while (pContext->gzipStream.avail_in != 0) { if (deflate(&pContext->gzipStream, Z_FULL_FLUSH) != Z_OK) { return -1; } + + int32_t cacheLen = pContext->gzipStream.total_out - lastTotalLen; + if (cacheLen >= *nDestData) { + return -2; + } } if (pContext->gzipStream.avail_in != 0) { @@ -427,16 +433,16 @@ int32_t httpGzipCompress(HttpContext *pContext, char *srcData, int32_t nSrcData, break; } if (err != Z_OK) { - return -2; + return -3; } } if (deflateEnd(&pContext->gzipStream) != Z_OK) { - return -3; + return -4; } } - *nDestData = (int32_t) (pContext->gzipStream.total_out); + *nDestData = (int32_t) (pContext->gzipStream.total_out) - lastTotalLen; return 0; } diff --git a/tests/script/general/http/gzip.sim b/tests/script/general/http/gzip.sim index 0289e337a6..9c77567abb 100644 --- a/tests/script/general/http/gzip.sim +++ b/tests/script/general/http/gzip.sim @@ -3,7 +3,7 @@ sleep 3000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c http -v 1 -system sh/cfg.sh -n dnode1 -c maxSQLLength -v 7340032 +system sh/cfg.sh -n dnode1 -c maxSQLLength -v 340032 system sh/exec.sh -n dnode1 -s start sleep 3000 @@ -18,10 +18,22 @@ sql use d1 sql create table table_rest (ts timestamp, i int) print sql length is 270KB restful d1 table_rest 1591072800 10000 gzip +restful d1 table_rest 1591172800 10000 gzip +restful d1 table_rest 1591272800 10000 gzip +restful d1 table_rest 1591372800 10000 gzip +restful d1 table_rest 1591472800 10000 gzip +restful d1 table_rest 1591572800 10000 gzip +restful d1 table_rest 1591672800 10000 gzip +restful d1 table_rest 1591772800 10000 gzip +restful d1 table_rest 1591872800 10000 gzip +restful d1 table_rest 1591972800 10000 gzip + sql select * from table_rest; print rows: $rows -if $rows != 10000 then +if $rows != 100000 then return -1 endi +system curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_rest' 127.0.0.1:7111/rest/sql --compressed + system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index adb22aa265..9e42adfea9 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -79,6 +79,7 @@ cd ../../../debug; make ./test.sh -f general/http/autocreate.sim ./test.sh -f general/http/chunked.sim +./test.sh -f general/http/gzip.sim ./test.sh -f general/http/restful.sim ./test.sh -f general/http/restful_insert.sim ./test.sh -f general/http/restful_limit.sim From 40b6ce676142816ac74be97ada419e7179abdd7e Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 22 Sep 2020 15:33:08 +0800 Subject: [PATCH 35/77] [td-225] fix coverity problem --- src/client/src/tscUtil.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 20c3bc2cb6..7387c23e1f 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -402,6 +402,8 @@ void tscFreeSqlObj(SSqlObj* pSql) { return; } + void *p = pSql; + tscDebug("%p start to free sqlObj", pSql); STscObj* pTscObj = pSql->pTscObj; @@ -421,7 +423,8 @@ void tscFreeSqlObj(SSqlObj* pSql) { tsem_destroy(&pSql->rspSem); free(pSql); - tscDebug("%p free sqlObj completed", pSql); + + tscDebug("%p free sqlObj completed", p); int32_t ref = T_REF_DEC(pTscObj); assert(ref >= 0); From 4a3104f7fe9d3342f98939f053be44feddc2f69d Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 22 Sep 2020 15:51:15 +0800 Subject: [PATCH 36/77] [td-1371] update the sql.c --- src/query/src/sql.c | 884 +++++++++++++++++++++++--------------------- 1 file changed, 453 insertions(+), 431 deletions(-) diff --git a/src/query/src/sql.c b/src/query/src/sql.c index 3c160aab3b..a18efdeb74 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -114,6 +114,7 @@ typedef union { tSQLExprList* yy224; int64_t yy271; tVariant yy312; + SIntervalVal yy314; SCreateTableSQL* yy374; tFieldList* yy449; tVariantList* yy494; @@ -126,17 +127,17 @@ typedef union { #define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo #define ParseARG_STORE yypParser->pInfo = pInfo #define YYFALLBACK 1 -#define YYNSTATE 248 -#define YYNRULE 227 +#define YYNSTATE 252 +#define YYNRULE 230 #define YYNTOKEN 206 -#define YY_MAX_SHIFT 247 -#define YY_MIN_SHIFTREDUCE 409 -#define YY_MAX_SHIFTREDUCE 635 -#define YY_ERROR_ACTION 636 -#define YY_ACCEPT_ACTION 637 -#define YY_NO_ACTION 638 -#define YY_MIN_REDUCE 639 -#define YY_MAX_REDUCE 865 +#define YY_MAX_SHIFT 251 +#define YY_MIN_SHIFTREDUCE 416 +#define YY_MAX_SHIFTREDUCE 645 +#define YY_ERROR_ACTION 646 +#define YY_ACCEPT_ACTION 647 +#define YY_NO_ACTION 648 +#define YY_MIN_REDUCE 649 +#define YY_MAX_REDUCE 878 /************* End control #defines *******************************************/ /* Define the yytestcase() macro to be a no-op if is not already defined @@ -202,123 +203,124 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (555) +#define YY_ACTTAB_COUNT (566) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 11, 452, 140, 452, 158, 245, 21, 139, 144, 453, - /* 10 */ 140, 453, 852, 41, 43, 771, 35, 36, 849, 163, - /* 20 */ 853, 29, 452, 848, 203, 39, 37, 40, 38, 159, - /* 30 */ 453, 782, 741, 34, 33, 739, 740, 32, 31, 30, - /* 40 */ 742, 756, 744, 745, 743, 107, 160, 410, 411, 412, - /* 50 */ 413, 414, 415, 416, 417, 418, 419, 420, 421, 246, - /* 60 */ 637, 247, 178, 41, 43, 760, 35, 36, 225, 107, - /* 70 */ 140, 29, 170, 847, 203, 39, 37, 40, 38, 162, - /* 80 */ 853, 518, 779, 34, 33, 103, 156, 32, 31, 30, - /* 90 */ 234, 760, 41, 43, 157, 35, 36, 771, 758, 200, - /* 100 */ 29, 60, 56, 203, 39, 37, 40, 38, 17, 223, - /* 110 */ 222, 188, 34, 33, 145, 26, 32, 31, 30, 43, - /* 120 */ 8, 35, 36, 63, 117, 808, 29, 198, 146, 203, - /* 130 */ 39, 37, 40, 38, 32, 31, 30, 191, 34, 33, - /* 140 */ 181, 107, 32, 31, 30, 241, 21, 185, 184, 591, - /* 150 */ 16, 214, 240, 239, 213, 212, 211, 238, 210, 237, - /* 160 */ 236, 235, 209, 737, 760, 725, 726, 727, 728, 729, - /* 170 */ 730, 731, 732, 733, 734, 735, 736, 35, 36, 171, - /* 180 */ 680, 757, 29, 130, 148, 203, 39, 37, 40, 38, - /* 190 */ 244, 243, 96, 149, 34, 33, 107, 807, 32, 31, - /* 200 */ 30, 167, 604, 78, 12, 595, 62, 598, 234, 601, - /* 210 */ 689, 167, 604, 130, 150, 595, 173, 598, 27, 601, - /* 220 */ 152, 167, 604, 572, 573, 595, 153, 598, 151, 601, - /* 230 */ 90, 89, 147, 164, 165, 34, 33, 202, 142, 32, - /* 240 */ 31, 30, 681, 164, 165, 130, 818, 550, 39, 37, - /* 250 */ 40, 38, 61, 164, 165, 563, 34, 33, 17, 46, - /* 260 */ 32, 31, 30, 102, 16, 26, 240, 239, 564, 21, - /* 270 */ 26, 238, 14, 237, 236, 235, 597, 174, 600, 547, - /* 280 */ 220, 219, 76, 80, 18, 187, 166, 21, 85, 88, - /* 290 */ 79, 138, 155, 120, 121, 21, 82, 593, 42, 70, - /* 300 */ 66, 69, 172, 542, 757, 134, 132, 143, 42, 603, - /* 310 */ 190, 93, 92, 91, 596, 141, 599, 621, 42, 603, - /* 320 */ 221, 13, 757, 605, 602, 3, 862, 13, 226, 603, - /* 330 */ 757, 47, 534, 594, 602, 531, 50, 532, 538, 533, - /* 340 */ 539, 524, 523, 817, 602, 46, 22, 207, 87, 86, - /* 350 */ 48, 22, 759, 51, 75, 74, 101, 99, 10, 9, - /* 360 */ 536, 168, 537, 175, 176, 814, 813, 169, 781, 786, - /* 370 */ 751, 800, 224, 773, 788, 26, 104, 799, 118, 189, - /* 380 */ 116, 119, 691, 208, 136, 24, 100, 217, 688, 559, - /* 390 */ 218, 861, 72, 860, 858, 122, 709, 25, 23, 137, - /* 400 */ 678, 81, 676, 83, 84, 674, 673, 177, 131, 671, - /* 410 */ 192, 670, 196, 669, 770, 668, 667, 133, 665, 663, - /* 420 */ 52, 661, 659, 657, 135, 49, 57, 58, 801, 44, - /* 430 */ 201, 199, 197, 195, 535, 193, 28, 216, 77, 227, - /* 440 */ 228, 230, 229, 231, 232, 233, 242, 635, 180, 205, - /* 450 */ 53, 179, 634, 182, 183, 64, 67, 154, 633, 626, - /* 460 */ 186, 161, 105, 672, 190, 94, 544, 666, 658, 125, - /* 470 */ 710, 123, 124, 126, 127, 108, 128, 109, 129, 110, - /* 480 */ 95, 755, 111, 112, 115, 113, 114, 2, 1, 55, - /* 490 */ 59, 560, 194, 5, 565, 106, 19, 6, 606, 20, - /* 500 */ 4, 15, 65, 7, 204, 493, 206, 489, 487, 486, - /* 510 */ 485, 482, 456, 215, 68, 45, 22, 71, 73, 520, - /* 520 */ 519, 517, 54, 477, 475, 467, 473, 469, 471, 465, - /* 530 */ 463, 492, 491, 490, 488, 484, 483, 46, 454, 425, - /* 540 */ 423, 639, 638, 638, 638, 638, 638, 638, 638, 638, - /* 550 */ 638, 638, 638, 97, 98, + /* 0 */ 751, 459, 11, 749, 750, 647, 251, 459, 752, 460, + /* 10 */ 754, 755, 753, 35, 36, 460, 37, 38, 159, 249, + /* 20 */ 170, 29, 141, 459, 206, 41, 39, 43, 40, 140, + /* 30 */ 145, 460, 865, 34, 33, 862, 141, 32, 31, 30, + /* 40 */ 35, 36, 781, 37, 38, 165, 866, 170, 29, 141, + /* 50 */ 62, 206, 41, 39, 43, 40, 191, 525, 164, 866, + /* 60 */ 34, 33, 27, 21, 32, 31, 30, 417, 418, 419, + /* 70 */ 420, 421, 422, 423, 424, 425, 426, 427, 428, 250, + /* 80 */ 35, 36, 181, 37, 38, 227, 226, 170, 29, 781, + /* 90 */ 176, 206, 41, 39, 43, 40, 174, 162, 767, 792, + /* 100 */ 34, 33, 56, 160, 32, 31, 30, 21, 36, 8, + /* 110 */ 37, 38, 63, 118, 170, 29, 770, 108, 206, 41, + /* 120 */ 39, 43, 40, 32, 31, 30, 599, 34, 33, 78, + /* 130 */ 875, 32, 31, 30, 238, 37, 38, 108, 238, 170, + /* 140 */ 29, 184, 766, 206, 41, 39, 43, 40, 188, 187, + /* 150 */ 789, 177, 34, 33, 224, 223, 32, 31, 30, 16, + /* 160 */ 218, 244, 243, 217, 216, 215, 242, 214, 241, 240, + /* 170 */ 239, 213, 747, 818, 735, 736, 737, 738, 739, 740, + /* 180 */ 741, 742, 743, 744, 745, 746, 169, 612, 103, 12, + /* 190 */ 603, 17, 606, 819, 609, 201, 169, 612, 26, 108, + /* 200 */ 603, 108, 606, 861, 609, 153, 169, 612, 173, 567, + /* 210 */ 603, 154, 606, 105, 609, 90, 89, 148, 166, 167, + /* 220 */ 34, 33, 205, 102, 32, 31, 30, 770, 166, 167, + /* 230 */ 26, 21, 557, 41, 39, 43, 40, 549, 166, 167, + /* 240 */ 194, 34, 33, 17, 193, 32, 31, 30, 860, 16, + /* 250 */ 26, 244, 243, 203, 21, 60, 242, 61, 241, 240, + /* 260 */ 239, 248, 247, 96, 175, 229, 767, 76, 80, 245, + /* 270 */ 190, 554, 21, 85, 88, 79, 18, 156, 121, 122, + /* 280 */ 605, 82, 608, 42, 70, 66, 69, 225, 770, 767, + /* 290 */ 135, 133, 601, 42, 611, 768, 93, 92, 91, 690, + /* 300 */ 168, 207, 131, 42, 611, 230, 545, 767, 546, 610, + /* 310 */ 699, 157, 691, 131, 611, 131, 604, 541, 607, 610, + /* 320 */ 538, 571, 539, 47, 540, 46, 580, 581, 602, 610, + /* 330 */ 572, 631, 613, 50, 14, 13, 13, 531, 543, 3, + /* 340 */ 544, 46, 48, 530, 75, 74, 811, 22, 178, 179, + /* 350 */ 51, 211, 10, 9, 829, 22, 87, 86, 101, 99, + /* 360 */ 158, 143, 144, 146, 147, 151, 152, 150, 139, 149, + /* 370 */ 769, 142, 828, 171, 825, 824, 172, 791, 761, 796, + /* 380 */ 228, 783, 798, 104, 810, 119, 120, 701, 117, 212, + /* 390 */ 615, 137, 24, 221, 698, 26, 222, 192, 874, 72, + /* 400 */ 873, 871, 123, 719, 25, 100, 23, 138, 566, 688, + /* 410 */ 81, 686, 83, 84, 684, 195, 780, 683, 161, 542, + /* 420 */ 180, 199, 132, 681, 680, 679, 52, 49, 678, 677, + /* 430 */ 109, 134, 44, 675, 204, 673, 671, 669, 667, 202, + /* 440 */ 200, 198, 196, 28, 136, 220, 57, 58, 812, 77, + /* 450 */ 231, 232, 233, 234, 235, 236, 237, 246, 209, 645, + /* 460 */ 53, 182, 183, 644, 110, 64, 67, 155, 186, 185, + /* 470 */ 682, 643, 94, 636, 676, 189, 126, 125, 720, 124, + /* 480 */ 127, 128, 130, 129, 95, 668, 1, 551, 193, 765, + /* 490 */ 2, 55, 113, 111, 114, 112, 115, 116, 59, 568, + /* 500 */ 163, 106, 197, 5, 573, 107, 6, 65, 614, 19, + /* 510 */ 4, 20, 15, 208, 616, 7, 210, 500, 496, 494, + /* 520 */ 493, 492, 489, 463, 219, 68, 45, 71, 73, 22, + /* 530 */ 527, 526, 524, 54, 484, 482, 474, 480, 476, 478, + /* 540 */ 472, 470, 499, 498, 497, 495, 491, 490, 46, 461, + /* 550 */ 432, 430, 649, 648, 648, 648, 648, 648, 648, 648, + /* 560 */ 648, 648, 648, 648, 97, 98, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 260, 1, 260, 1, 209, 210, 210, 260, 260, 9, - /* 10 */ 260, 9, 270, 13, 14, 244, 16, 17, 260, 269, - /* 20 */ 270, 21, 1, 260, 24, 25, 26, 27, 28, 258, - /* 30 */ 9, 210, 226, 33, 34, 229, 230, 37, 38, 39, - /* 40 */ 234, 245, 236, 237, 238, 210, 227, 45, 46, 47, - /* 50 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - /* 60 */ 207, 208, 60, 13, 14, 246, 16, 17, 210, 210, - /* 70 */ 260, 21, 227, 260, 24, 25, 26, 27, 28, 269, - /* 80 */ 270, 5, 261, 33, 34, 210, 260, 37, 38, 39, - /* 90 */ 78, 246, 13, 14, 260, 16, 17, 244, 240, 264, - /* 100 */ 21, 266, 102, 24, 25, 26, 27, 28, 98, 33, - /* 110 */ 34, 258, 33, 34, 260, 105, 37, 38, 39, 14, - /* 120 */ 98, 16, 17, 101, 102, 266, 21, 268, 260, 24, - /* 130 */ 25, 26, 27, 28, 37, 38, 39, 262, 33, 34, - /* 140 */ 126, 210, 37, 38, 39, 227, 210, 133, 134, 99, - /* 150 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, - /* 160 */ 95, 96, 97, 226, 246, 228, 229, 230, 231, 232, - /* 170 */ 233, 234, 235, 236, 237, 238, 239, 16, 17, 243, - /* 180 */ 214, 245, 21, 217, 260, 24, 25, 26, 27, 28, - /* 190 */ 63, 64, 65, 260, 33, 34, 210, 266, 37, 38, - /* 200 */ 39, 1, 2, 73, 44, 5, 247, 7, 78, 9, - /* 210 */ 214, 1, 2, 217, 260, 5, 66, 7, 259, 9, - /* 220 */ 60, 1, 2, 115, 116, 5, 66, 7, 260, 9, - /* 230 */ 70, 71, 72, 33, 34, 33, 34, 37, 260, 37, - /* 240 */ 38, 39, 214, 33, 34, 217, 241, 37, 25, 26, - /* 250 */ 27, 28, 266, 33, 34, 99, 33, 34, 98, 103, - /* 260 */ 37, 38, 39, 98, 85, 105, 87, 88, 99, 210, - /* 270 */ 105, 92, 103, 94, 95, 96, 5, 127, 7, 103, - /* 280 */ 130, 131, 61, 62, 108, 125, 59, 210, 67, 68, - /* 290 */ 69, 260, 132, 61, 62, 210, 75, 1, 98, 67, - /* 300 */ 68, 69, 243, 99, 245, 61, 62, 260, 98, 109, - /* 310 */ 106, 67, 68, 69, 5, 260, 7, 99, 98, 109, - /* 320 */ 243, 103, 245, 99, 124, 98, 246, 103, 243, 109, - /* 330 */ 245, 103, 2, 37, 124, 5, 103, 7, 5, 9, - /* 340 */ 7, 99, 99, 241, 124, 103, 103, 99, 73, 74, - /* 350 */ 122, 103, 246, 120, 128, 129, 61, 62, 128, 129, - /* 360 */ 5, 241, 7, 33, 34, 241, 241, 241, 210, 210, - /* 370 */ 242, 267, 241, 244, 210, 105, 210, 267, 210, 244, - /* 380 */ 248, 210, 210, 210, 210, 210, 59, 210, 210, 109, - /* 390 */ 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - /* 400 */ 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - /* 410 */ 263, 210, 263, 210, 257, 210, 210, 210, 210, 210, - /* 420 */ 119, 210, 210, 210, 210, 121, 211, 211, 211, 118, - /* 430 */ 113, 117, 112, 111, 104, 110, 123, 76, 84, 83, - /* 440 */ 49, 82, 80, 53, 81, 79, 76, 5, 5, 211, - /* 450 */ 211, 135, 5, 135, 5, 215, 215, 211, 5, 86, - /* 460 */ 126, 1, 98, 211, 106, 212, 99, 211, 211, 219, - /* 470 */ 225, 224, 223, 222, 220, 256, 221, 255, 218, 254, - /* 480 */ 212, 244, 253, 252, 249, 251, 250, 213, 216, 107, - /* 490 */ 103, 99, 98, 114, 99, 98, 103, 114, 99, 103, - /* 500 */ 98, 98, 73, 98, 100, 9, 100, 5, 5, 5, - /* 510 */ 5, 5, 77, 15, 73, 16, 103, 129, 129, 5, - /* 520 */ 5, 99, 98, 5, 5, 5, 5, 5, 5, 5, - /* 530 */ 5, 5, 5, 5, 5, 5, 5, 103, 77, 59, - /* 540 */ 58, 0, 271, 271, 271, 271, 271, 271, 271, 271, - /* 550 */ 271, 271, 271, 21, 21, 271, 271, 271, 271, 271, - /* 560 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 0 */ 226, 1, 260, 229, 230, 207, 208, 1, 234, 9, + /* 10 */ 236, 237, 238, 13, 14, 9, 16, 17, 209, 210, + /* 20 */ 20, 21, 260, 1, 24, 25, 26, 27, 28, 260, + /* 30 */ 260, 9, 270, 33, 34, 260, 260, 37, 38, 39, + /* 40 */ 13, 14, 244, 16, 17, 269, 270, 20, 21, 260, + /* 50 */ 247, 24, 25, 26, 27, 28, 258, 5, 269, 270, + /* 60 */ 33, 34, 259, 210, 37, 38, 39, 45, 46, 47, + /* 70 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + /* 80 */ 13, 14, 60, 16, 17, 33, 34, 20, 21, 244, + /* 90 */ 66, 24, 25, 26, 27, 28, 243, 227, 245, 210, + /* 100 */ 33, 34, 102, 258, 37, 38, 39, 210, 14, 98, + /* 110 */ 16, 17, 101, 102, 20, 21, 246, 210, 24, 25, + /* 120 */ 26, 27, 28, 37, 38, 39, 99, 33, 34, 73, + /* 130 */ 246, 37, 38, 39, 78, 16, 17, 210, 78, 20, + /* 140 */ 21, 126, 245, 24, 25, 26, 27, 28, 133, 134, + /* 150 */ 261, 127, 33, 34, 130, 131, 37, 38, 39, 85, + /* 160 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, + /* 170 */ 96, 97, 226, 266, 228, 229, 230, 231, 232, 233, + /* 180 */ 234, 235, 236, 237, 238, 239, 1, 2, 210, 44, + /* 190 */ 5, 98, 7, 266, 9, 268, 1, 2, 105, 210, + /* 200 */ 5, 210, 7, 260, 9, 60, 1, 2, 227, 99, + /* 210 */ 5, 66, 7, 103, 9, 70, 71, 72, 33, 34, + /* 220 */ 33, 34, 37, 98, 37, 38, 39, 246, 33, 34, + /* 230 */ 105, 210, 37, 25, 26, 27, 28, 99, 33, 34, + /* 240 */ 262, 33, 34, 98, 106, 37, 38, 39, 260, 85, + /* 250 */ 105, 87, 88, 264, 210, 266, 92, 266, 94, 95, + /* 260 */ 96, 63, 64, 65, 243, 210, 245, 61, 62, 227, + /* 270 */ 125, 103, 210, 67, 68, 69, 108, 132, 61, 62, + /* 280 */ 5, 75, 7, 98, 67, 68, 69, 243, 246, 245, + /* 290 */ 61, 62, 1, 98, 109, 240, 67, 68, 69, 214, + /* 300 */ 59, 15, 217, 98, 109, 243, 5, 245, 7, 124, + /* 310 */ 214, 260, 214, 217, 109, 217, 5, 2, 7, 124, + /* 320 */ 5, 99, 7, 103, 9, 103, 115, 116, 37, 124, + /* 330 */ 99, 99, 99, 103, 103, 103, 103, 99, 5, 98, + /* 340 */ 7, 103, 122, 99, 128, 129, 267, 103, 33, 34, + /* 350 */ 120, 99, 128, 129, 241, 103, 73, 74, 61, 62, + /* 360 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, + /* 370 */ 246, 260, 241, 241, 241, 241, 241, 210, 242, 210, + /* 380 */ 241, 244, 210, 210, 267, 210, 210, 210, 248, 210, + /* 390 */ 104, 210, 210, 210, 210, 105, 210, 244, 210, 210, + /* 400 */ 210, 210, 210, 210, 210, 59, 210, 210, 109, 210, + /* 410 */ 210, 210, 210, 210, 210, 263, 257, 210, 263, 104, + /* 420 */ 210, 263, 210, 210, 210, 210, 119, 121, 210, 210, + /* 430 */ 256, 210, 118, 210, 113, 210, 210, 210, 210, 117, + /* 440 */ 112, 111, 110, 123, 210, 76, 211, 211, 211, 84, + /* 450 */ 83, 49, 80, 82, 53, 81, 79, 76, 211, 5, + /* 460 */ 211, 135, 5, 5, 255, 215, 215, 211, 5, 135, + /* 470 */ 211, 5, 212, 86, 211, 126, 219, 223, 225, 224, + /* 480 */ 222, 220, 218, 221, 212, 211, 216, 99, 106, 244, + /* 490 */ 213, 107, 252, 254, 251, 253, 250, 249, 103, 99, + /* 500 */ 1, 98, 98, 114, 99, 98, 114, 73, 99, 103, + /* 510 */ 98, 103, 98, 100, 104, 98, 100, 9, 5, 5, + /* 520 */ 5, 5, 5, 77, 15, 73, 16, 129, 129, 103, + /* 530 */ 5, 5, 99, 98, 5, 5, 5, 5, 5, 5, + /* 540 */ 5, 5, 5, 5, 5, 5, 5, 5, 103, 77, + /* 550 */ 59, 58, 0, 271, 271, 271, 271, 271, 271, 271, + /* 560 */ 271, 271, 271, 271, 21, 21, 271, 271, 271, 271, /* 570 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 580 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 590 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, @@ -338,83 +340,86 @@ static const YYCODETYPE yy_lookahead[] = { /* 730 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 740 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 750 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, - /* 760 */ 271, + /* 760 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 770 */ 271, 271, }; -#define YY_SHIFT_COUNT (247) +#define YY_SHIFT_COUNT (251) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (541) +#define YY_SHIFT_MAX (552) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 160, 65, 179, 200, 220, 21, 21, 21, 21, 21, - /* 10 */ 21, 0, 2, 220, 330, 330, 330, 10, 21, 21, - /* 20 */ 21, 21, 21, 130, 12, 12, 555, 210, 220, 220, - /* 30 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, - /* 40 */ 220, 220, 220, 220, 220, 330, 330, 76, 76, 76, - /* 50 */ 76, 76, 76, 22, 76, 165, 21, 21, 21, 21, - /* 60 */ 108, 108, 176, 21, 21, 21, 21, 21, 21, 21, - /* 70 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - /* 80 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - /* 90 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - /* 100 */ 21, 21, 270, 327, 327, 280, 280, 327, 301, 304, - /* 110 */ 311, 317, 314, 320, 322, 325, 313, 270, 327, 327, - /* 120 */ 361, 361, 327, 354, 356, 391, 362, 359, 390, 363, - /* 130 */ 366, 327, 370, 327, 370, 327, 555, 555, 50, 79, - /* 140 */ 79, 79, 105, 161, 223, 223, 223, 221, 202, 202, - /* 150 */ 202, 202, 232, 244, 150, 14, 97, 97, 127, 204, - /* 160 */ 156, 169, 218, 224, 271, 309, 296, 227, 228, 233, - /* 170 */ 242, 243, 248, 226, 230, 333, 355, 275, 295, 442, - /* 180 */ 316, 443, 447, 318, 449, 453, 373, 334, 358, 367, - /* 190 */ 382, 387, 392, 364, 460, 394, 395, 397, 393, 379, - /* 200 */ 396, 383, 399, 402, 403, 404, 405, 406, 429, 496, - /* 210 */ 502, 503, 504, 505, 506, 435, 498, 441, 499, 388, - /* 220 */ 389, 413, 514, 515, 422, 424, 413, 518, 519, 520, - /* 230 */ 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, - /* 240 */ 531, 434, 461, 532, 533, 480, 482, 541, + /* 0 */ 145, 74, 164, 185, 205, 6, 6, 6, 6, 6, + /* 10 */ 6, 0, 22, 205, 315, 315, 315, 93, 6, 6, + /* 20 */ 6, 6, 6, 56, 60, 60, 566, 195, 205, 205, + /* 30 */ 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, + /* 40 */ 205, 205, 205, 205, 205, 315, 315, 52, 52, 52, + /* 50 */ 52, 52, 52, 11, 52, 125, 6, 6, 6, 6, + /* 60 */ 211, 211, 168, 6, 6, 6, 6, 6, 6, 6, + /* 70 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + /* 80 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + /* 90 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + /* 100 */ 6, 6, 290, 346, 346, 299, 299, 299, 346, 307, + /* 110 */ 306, 314, 321, 322, 328, 330, 332, 320, 290, 346, + /* 120 */ 346, 369, 369, 346, 365, 367, 402, 372, 371, 401, + /* 130 */ 374, 377, 346, 381, 346, 381, 346, 566, 566, 27, + /* 140 */ 67, 67, 67, 94, 119, 208, 208, 208, 206, 187, + /* 150 */ 187, 187, 187, 217, 229, 24, 15, 86, 86, 198, + /* 160 */ 138, 110, 222, 231, 232, 233, 275, 311, 291, 241, + /* 170 */ 286, 220, 230, 238, 244, 252, 216, 224, 301, 333, + /* 180 */ 283, 297, 454, 326, 457, 458, 334, 463, 466, 387, + /* 190 */ 349, 382, 388, 384, 395, 400, 403, 499, 404, 405, + /* 200 */ 407, 406, 389, 408, 392, 409, 412, 410, 414, 413, + /* 210 */ 417, 416, 434, 508, 513, 514, 515, 516, 517, 446, + /* 220 */ 509, 452, 510, 398, 399, 426, 525, 526, 433, 435, + /* 230 */ 426, 529, 530, 531, 532, 533, 534, 535, 536, 537, + /* 240 */ 538, 539, 540, 541, 542, 445, 472, 543, 544, 491, + /* 250 */ 493, 552, }; -#define YY_REDUCE_COUNT (137) -#define YY_REDUCE_MIN (-260) -#define YY_REDUCE_MAX (274) +#define YY_REDUCE_COUNT (138) +#define YY_REDUCE_MIN (-258) +#define YY_REDUCE_MAX (277) static const short yy_reduce_ofst[] = { - /* 0 */ -147, -63, -194, -250, -190, -141, -165, -64, 59, 77, - /* 10 */ 85, -179, -205, -258, -181, -155, -82, -229, -125, -69, - /* 20 */ -14, -142, -204, -34, -4, 28, -41, -260, -253, -252, - /* 30 */ -242, -237, -187, -174, -166, -146, -132, -76, -67, -46, - /* 40 */ -32, -22, 31, 47, 55, 80, 106, 5, 102, 120, - /* 50 */ 124, 125, 126, 128, 131, 129, 158, 159, 164, 166, - /* 60 */ 104, 110, 132, 168, 171, 172, 173, 174, 175, 177, - /* 70 */ 178, 180, 181, 182, 183, 184, 185, 186, 187, 188, - /* 80 */ 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, - /* 90 */ 199, 201, 203, 205, 206, 207, 208, 209, 211, 212, - /* 100 */ 213, 214, 135, 215, 216, 147, 149, 217, 157, 219, - /* 110 */ 222, 225, 229, 231, 234, 236, 235, 237, 238, 239, - /* 120 */ 240, 241, 246, 245, 247, 249, 250, 251, 254, 255, - /* 130 */ 260, 252, 253, 256, 268, 257, 272, 274, + /* 0 */ -202, -54, -226, -224, -211, -73, -11, -147, 21, 44, + /* 10 */ 62, -111, -191, -238, -130, -19, 42, -155, -22, -93, + /* 20 */ -9, 55, -103, 85, 96, 98, -197, -258, -231, -230, + /* 30 */ -225, -57, -12, 51, 100, 101, 102, 103, 104, 105, + /* 40 */ 106, 107, 108, 109, 111, -116, 124, 113, 131, 132, + /* 50 */ 133, 134, 135, 136, 139, 137, 167, 169, 172, 173, + /* 60 */ 79, 117, 140, 175, 176, 177, 179, 181, 182, 183, + /* 70 */ 184, 186, 188, 189, 190, 191, 192, 193, 194, 196, + /* 80 */ 197, 199, 200, 201, 202, 203, 204, 207, 210, 212, + /* 90 */ 213, 214, 215, 218, 219, 221, 223, 225, 226, 227, + /* 100 */ 228, 234, 153, 235, 236, 152, 155, 158, 237, 159, + /* 110 */ 174, 209, 239, 242, 240, 243, 246, 248, 245, 247, + /* 120 */ 249, 250, 251, 256, 253, 255, 254, 257, 258, 261, + /* 130 */ 262, 264, 259, 260, 263, 272, 274, 270, 277, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 636, 690, 679, 855, 855, 636, 636, 636, 636, 636, - /* 10 */ 636, 783, 654, 855, 636, 636, 636, 636, 636, 636, - /* 20 */ 636, 636, 636, 692, 692, 692, 778, 636, 636, 636, - /* 30 */ 636, 636, 636, 636, 636, 636, 636, 636, 636, 636, - /* 40 */ 636, 636, 636, 636, 636, 636, 636, 636, 636, 636, - /* 50 */ 636, 636, 636, 636, 636, 636, 636, 785, 787, 636, - /* 60 */ 804, 804, 776, 636, 636, 636, 636, 636, 636, 636, - /* 70 */ 636, 636, 636, 636, 636, 636, 636, 636, 636, 636, - /* 80 */ 636, 677, 636, 675, 636, 636, 636, 636, 636, 636, - /* 90 */ 636, 636, 636, 636, 636, 636, 664, 636, 636, 636, - /* 100 */ 636, 636, 636, 656, 656, 636, 636, 656, 811, 815, - /* 110 */ 809, 797, 805, 796, 792, 791, 819, 636, 656, 656, - /* 120 */ 687, 687, 656, 708, 706, 704, 696, 702, 698, 700, - /* 130 */ 694, 656, 685, 656, 685, 656, 724, 738, 636, 820, - /* 140 */ 854, 810, 838, 837, 850, 844, 843, 636, 842, 841, - /* 150 */ 840, 839, 636, 636, 636, 636, 846, 845, 636, 636, - /* 160 */ 636, 636, 636, 636, 636, 636, 636, 822, 816, 812, - /* 170 */ 636, 636, 636, 636, 636, 636, 636, 636, 636, 636, - /* 180 */ 636, 636, 636, 636, 636, 636, 636, 636, 775, 636, - /* 190 */ 636, 784, 636, 636, 636, 636, 636, 636, 806, 636, - /* 200 */ 798, 636, 636, 636, 636, 636, 636, 752, 636, 636, - /* 210 */ 636, 636, 636, 636, 636, 636, 636, 636, 636, 636, - /* 220 */ 636, 859, 636, 636, 636, 746, 857, 636, 636, 636, - /* 230 */ 636, 636, 636, 636, 636, 636, 636, 636, 636, 636, - /* 240 */ 636, 711, 636, 662, 660, 636, 652, 636, + /* 0 */ 646, 700, 689, 868, 868, 646, 646, 646, 646, 646, + /* 10 */ 646, 793, 664, 868, 646, 646, 646, 646, 646, 646, + /* 20 */ 646, 646, 646, 702, 702, 702, 788, 646, 646, 646, + /* 30 */ 646, 646, 646, 646, 646, 646, 646, 646, 646, 646, + /* 40 */ 646, 646, 646, 646, 646, 646, 646, 646, 646, 646, + /* 50 */ 646, 646, 646, 646, 646, 646, 646, 795, 797, 646, + /* 60 */ 815, 815, 786, 646, 646, 646, 646, 646, 646, 646, + /* 70 */ 646, 646, 646, 646, 646, 646, 646, 646, 646, 646, + /* 80 */ 646, 687, 646, 685, 646, 646, 646, 646, 646, 646, + /* 90 */ 646, 646, 646, 646, 646, 646, 674, 646, 646, 646, + /* 100 */ 646, 646, 646, 666, 666, 646, 646, 646, 666, 822, + /* 110 */ 826, 820, 808, 816, 807, 803, 802, 830, 646, 666, + /* 120 */ 666, 697, 697, 666, 718, 716, 714, 706, 712, 708, + /* 130 */ 710, 704, 666, 695, 666, 695, 666, 734, 748, 646, + /* 140 */ 831, 867, 821, 857, 856, 863, 855, 854, 646, 850, + /* 150 */ 851, 853, 852, 646, 646, 646, 646, 859, 858, 646, + /* 160 */ 646, 646, 646, 646, 646, 646, 646, 646, 646, 833, + /* 170 */ 646, 827, 823, 646, 646, 646, 646, 646, 646, 646, + /* 180 */ 646, 646, 646, 646, 646, 646, 646, 646, 646, 646, + /* 190 */ 646, 785, 646, 646, 794, 646, 646, 646, 646, 646, + /* 200 */ 646, 817, 646, 809, 646, 646, 646, 646, 646, 646, + /* 210 */ 646, 762, 646, 646, 646, 646, 646, 646, 646, 646, + /* 220 */ 646, 646, 646, 646, 646, 872, 646, 646, 646, 756, + /* 230 */ 870, 646, 646, 646, 646, 646, 646, 646, 646, 646, + /* 240 */ 646, 646, 646, 646, 646, 721, 646, 672, 670, 646, + /* 250 */ 662, 646, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1156,81 +1161,84 @@ static const char *const yyRuleName[] = { /* 149 */ "tablelist ::= tablelist COMMA ids cpxName ids", /* 150 */ "tmvar ::= VARIABLE", /* 151 */ "interval_opt ::= INTERVAL LP tmvar RP", - /* 152 */ "interval_opt ::=", - /* 153 */ "fill_opt ::=", - /* 154 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", - /* 155 */ "fill_opt ::= FILL LP ID RP", - /* 156 */ "sliding_opt ::= SLIDING LP tmvar RP", - /* 157 */ "sliding_opt ::=", - /* 158 */ "orderby_opt ::=", - /* 159 */ "orderby_opt ::= ORDER BY sortlist", - /* 160 */ "sortlist ::= sortlist COMMA item sortorder", - /* 161 */ "sortlist ::= item sortorder", - /* 162 */ "item ::= ids cpxName", - /* 163 */ "sortorder ::= ASC", - /* 164 */ "sortorder ::= DESC", - /* 165 */ "sortorder ::=", - /* 166 */ "groupby_opt ::=", - /* 167 */ "groupby_opt ::= GROUP BY grouplist", - /* 168 */ "grouplist ::= grouplist COMMA item", - /* 169 */ "grouplist ::= item", - /* 170 */ "having_opt ::=", - /* 171 */ "having_opt ::= HAVING expr", - /* 172 */ "limit_opt ::=", - /* 173 */ "limit_opt ::= LIMIT signed", - /* 174 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 175 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 176 */ "slimit_opt ::=", - /* 177 */ "slimit_opt ::= SLIMIT signed", - /* 178 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", - /* 179 */ "slimit_opt ::= SLIMIT signed COMMA signed", - /* 180 */ "where_opt ::=", - /* 181 */ "where_opt ::= WHERE expr", - /* 182 */ "expr ::= LP expr RP", - /* 183 */ "expr ::= ID", - /* 184 */ "expr ::= ID DOT ID", - /* 185 */ "expr ::= ID DOT STAR", - /* 186 */ "expr ::= INTEGER", - /* 187 */ "expr ::= MINUS INTEGER", - /* 188 */ "expr ::= PLUS INTEGER", - /* 189 */ "expr ::= FLOAT", - /* 190 */ "expr ::= MINUS FLOAT", - /* 191 */ "expr ::= PLUS FLOAT", - /* 192 */ "expr ::= STRING", - /* 193 */ "expr ::= NOW", - /* 194 */ "expr ::= VARIABLE", - /* 195 */ "expr ::= BOOL", - /* 196 */ "expr ::= ID LP exprlist RP", - /* 197 */ "expr ::= ID LP STAR RP", - /* 198 */ "expr ::= expr AND expr", - /* 199 */ "expr ::= expr OR expr", - /* 200 */ "expr ::= expr LT expr", - /* 201 */ "expr ::= expr GT expr", - /* 202 */ "expr ::= expr LE expr", - /* 203 */ "expr ::= expr GE expr", - /* 204 */ "expr ::= expr NE expr", - /* 205 */ "expr ::= expr EQ expr", - /* 206 */ "expr ::= expr PLUS expr", - /* 207 */ "expr ::= expr MINUS expr", - /* 208 */ "expr ::= expr STAR expr", - /* 209 */ "expr ::= expr SLASH expr", - /* 210 */ "expr ::= expr REM expr", - /* 211 */ "expr ::= expr LIKE expr", - /* 212 */ "expr ::= expr IN LP exprlist RP", - /* 213 */ "exprlist ::= exprlist COMMA expritem", - /* 214 */ "exprlist ::= expritem", - /* 215 */ "expritem ::= expr", - /* 216 */ "expritem ::=", - /* 217 */ "cmd ::= RESET QUERY CACHE", - /* 218 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 219 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 220 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 221 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 222 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 223 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 224 */ "cmd ::= KILL CONNECTION INTEGER", - /* 225 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 226 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 152 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", + /* 153 */ "interval_opt ::=", + /* 154 */ "fill_opt ::=", + /* 155 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", + /* 156 */ "fill_opt ::= FILL LP ID RP", + /* 157 */ "sliding_opt ::= SLIDING LP tmvar RP", + /* 158 */ "sliding_opt ::=", + /* 159 */ "orderby_opt ::=", + /* 160 */ "orderby_opt ::= ORDER BY sortlist", + /* 161 */ "sortlist ::= sortlist COMMA item sortorder", + /* 162 */ "sortlist ::= item sortorder", + /* 163 */ "item ::= ids cpxName", + /* 164 */ "sortorder ::= ASC", + /* 165 */ "sortorder ::= DESC", + /* 166 */ "sortorder ::=", + /* 167 */ "groupby_opt ::=", + /* 168 */ "groupby_opt ::= GROUP BY grouplist", + /* 169 */ "grouplist ::= grouplist COMMA item", + /* 170 */ "grouplist ::= item", + /* 171 */ "having_opt ::=", + /* 172 */ "having_opt ::= HAVING expr", + /* 173 */ "limit_opt ::=", + /* 174 */ "limit_opt ::= LIMIT signed", + /* 175 */ "limit_opt ::= LIMIT signed OFFSET signed", + /* 176 */ "limit_opt ::= LIMIT signed COMMA signed", + /* 177 */ "slimit_opt ::=", + /* 178 */ "slimit_opt ::= SLIMIT signed", + /* 179 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", + /* 180 */ "slimit_opt ::= SLIMIT signed COMMA signed", + /* 181 */ "where_opt ::=", + /* 182 */ "where_opt ::= WHERE expr", + /* 183 */ "expr ::= LP expr RP", + /* 184 */ "expr ::= ID", + /* 185 */ "expr ::= ID DOT ID", + /* 186 */ "expr ::= ID DOT STAR", + /* 187 */ "expr ::= INTEGER", + /* 188 */ "expr ::= MINUS INTEGER", + /* 189 */ "expr ::= PLUS INTEGER", + /* 190 */ "expr ::= FLOAT", + /* 191 */ "expr ::= MINUS FLOAT", + /* 192 */ "expr ::= PLUS FLOAT", + /* 193 */ "expr ::= STRING", + /* 194 */ "expr ::= NOW", + /* 195 */ "expr ::= VARIABLE", + /* 196 */ "expr ::= BOOL", + /* 197 */ "expr ::= ID LP exprlist RP", + /* 198 */ "expr ::= ID LP STAR RP", + /* 199 */ "expr ::= expr IS NULL", + /* 200 */ "expr ::= expr IS NOT NULL", + /* 201 */ "expr ::= expr LT expr", + /* 202 */ "expr ::= expr GT expr", + /* 203 */ "expr ::= expr LE expr", + /* 204 */ "expr ::= expr GE expr", + /* 205 */ "expr ::= expr NE expr", + /* 206 */ "expr ::= expr EQ expr", + /* 207 */ "expr ::= expr AND expr", + /* 208 */ "expr ::= expr OR expr", + /* 209 */ "expr ::= expr PLUS expr", + /* 210 */ "expr ::= expr MINUS expr", + /* 211 */ "expr ::= expr STAR expr", + /* 212 */ "expr ::= expr SLASH expr", + /* 213 */ "expr ::= expr REM expr", + /* 214 */ "expr ::= expr LIKE expr", + /* 215 */ "expr ::= expr IN LP exprlist RP", + /* 216 */ "exprlist ::= exprlist COMMA expritem", + /* 217 */ "exprlist ::= expritem", + /* 218 */ "expritem ::= expr", + /* 219 */ "expritem ::=", + /* 220 */ "cmd ::= RESET QUERY CACHE", + /* 221 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 222 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 223 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 224 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 225 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 226 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 227 */ "cmd ::= KILL CONNECTION INTEGER", + /* 228 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 229 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1840,81 +1848,84 @@ static const struct { { 262, -5 }, /* (149) tablelist ::= tablelist COMMA ids cpxName ids */ { 263, -1 }, /* (150) tmvar ::= VARIABLE */ { 250, -4 }, /* (151) interval_opt ::= INTERVAL LP tmvar RP */ - { 250, 0 }, /* (152) interval_opt ::= */ - { 251, 0 }, /* (153) fill_opt ::= */ - { 251, -6 }, /* (154) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - { 251, -4 }, /* (155) fill_opt ::= FILL LP ID RP */ - { 252, -4 }, /* (156) sliding_opt ::= SLIDING LP tmvar RP */ - { 252, 0 }, /* (157) sliding_opt ::= */ - { 254, 0 }, /* (158) orderby_opt ::= */ - { 254, -3 }, /* (159) orderby_opt ::= ORDER BY sortlist */ - { 264, -4 }, /* (160) sortlist ::= sortlist COMMA item sortorder */ - { 264, -2 }, /* (161) sortlist ::= item sortorder */ - { 266, -2 }, /* (162) item ::= ids cpxName */ - { 267, -1 }, /* (163) sortorder ::= ASC */ - { 267, -1 }, /* (164) sortorder ::= DESC */ - { 267, 0 }, /* (165) sortorder ::= */ - { 253, 0 }, /* (166) groupby_opt ::= */ - { 253, -3 }, /* (167) groupby_opt ::= GROUP BY grouplist */ - { 268, -3 }, /* (168) grouplist ::= grouplist COMMA item */ - { 268, -1 }, /* (169) grouplist ::= item */ - { 255, 0 }, /* (170) having_opt ::= */ - { 255, -2 }, /* (171) having_opt ::= HAVING expr */ - { 257, 0 }, /* (172) limit_opt ::= */ - { 257, -2 }, /* (173) limit_opt ::= LIMIT signed */ - { 257, -4 }, /* (174) limit_opt ::= LIMIT signed OFFSET signed */ - { 257, -4 }, /* (175) limit_opt ::= LIMIT signed COMMA signed */ - { 256, 0 }, /* (176) slimit_opt ::= */ - { 256, -2 }, /* (177) slimit_opt ::= SLIMIT signed */ - { 256, -4 }, /* (178) slimit_opt ::= SLIMIT signed SOFFSET signed */ - { 256, -4 }, /* (179) slimit_opt ::= SLIMIT signed COMMA signed */ - { 249, 0 }, /* (180) where_opt ::= */ - { 249, -2 }, /* (181) where_opt ::= WHERE expr */ - { 260, -3 }, /* (182) expr ::= LP expr RP */ - { 260, -1 }, /* (183) expr ::= ID */ - { 260, -3 }, /* (184) expr ::= ID DOT ID */ - { 260, -3 }, /* (185) expr ::= ID DOT STAR */ - { 260, -1 }, /* (186) expr ::= INTEGER */ - { 260, -2 }, /* (187) expr ::= MINUS INTEGER */ - { 260, -2 }, /* (188) expr ::= PLUS INTEGER */ - { 260, -1 }, /* (189) expr ::= FLOAT */ - { 260, -2 }, /* (190) expr ::= MINUS FLOAT */ - { 260, -2 }, /* (191) expr ::= PLUS FLOAT */ - { 260, -1 }, /* (192) expr ::= STRING */ - { 260, -1 }, /* (193) expr ::= NOW */ - { 260, -1 }, /* (194) expr ::= VARIABLE */ - { 260, -1 }, /* (195) expr ::= BOOL */ - { 260, -4 }, /* (196) expr ::= ID LP exprlist RP */ - { 260, -4 }, /* (197) expr ::= ID LP STAR RP */ - { 260, -3 }, /* (198) expr ::= expr AND expr */ - { 260, -3 }, /* (199) expr ::= expr OR expr */ - { 260, -3 }, /* (200) expr ::= expr LT expr */ - { 260, -3 }, /* (201) expr ::= expr GT expr */ - { 260, -3 }, /* (202) expr ::= expr LE expr */ - { 260, -3 }, /* (203) expr ::= expr GE expr */ - { 260, -3 }, /* (204) expr ::= expr NE expr */ - { 260, -3 }, /* (205) expr ::= expr EQ expr */ - { 260, -3 }, /* (206) expr ::= expr PLUS expr */ - { 260, -3 }, /* (207) expr ::= expr MINUS expr */ - { 260, -3 }, /* (208) expr ::= expr STAR expr */ - { 260, -3 }, /* (209) expr ::= expr SLASH expr */ - { 260, -3 }, /* (210) expr ::= expr REM expr */ - { 260, -3 }, /* (211) expr ::= expr LIKE expr */ - { 260, -5 }, /* (212) expr ::= expr IN LP exprlist RP */ - { 269, -3 }, /* (213) exprlist ::= exprlist COMMA expritem */ - { 269, -1 }, /* (214) exprlist ::= expritem */ - { 270, -1 }, /* (215) expritem ::= expr */ - { 270, 0 }, /* (216) expritem ::= */ - { 208, -3 }, /* (217) cmd ::= RESET QUERY CACHE */ - { 208, -7 }, /* (218) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - { 208, -7 }, /* (219) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - { 208, -7 }, /* (220) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - { 208, -7 }, /* (221) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - { 208, -8 }, /* (222) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - { 208, -9 }, /* (223) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - { 208, -3 }, /* (224) cmd ::= KILL CONNECTION INTEGER */ - { 208, -5 }, /* (225) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - { 208, -5 }, /* (226) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + { 250, -6 }, /* (152) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + { 250, 0 }, /* (153) interval_opt ::= */ + { 251, 0 }, /* (154) fill_opt ::= */ + { 251, -6 }, /* (155) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + { 251, -4 }, /* (156) fill_opt ::= FILL LP ID RP */ + { 252, -4 }, /* (157) sliding_opt ::= SLIDING LP tmvar RP */ + { 252, 0 }, /* (158) sliding_opt ::= */ + { 254, 0 }, /* (159) orderby_opt ::= */ + { 254, -3 }, /* (160) orderby_opt ::= ORDER BY sortlist */ + { 264, -4 }, /* (161) sortlist ::= sortlist COMMA item sortorder */ + { 264, -2 }, /* (162) sortlist ::= item sortorder */ + { 266, -2 }, /* (163) item ::= ids cpxName */ + { 267, -1 }, /* (164) sortorder ::= ASC */ + { 267, -1 }, /* (165) sortorder ::= DESC */ + { 267, 0 }, /* (166) sortorder ::= */ + { 253, 0 }, /* (167) groupby_opt ::= */ + { 253, -3 }, /* (168) groupby_opt ::= GROUP BY grouplist */ + { 268, -3 }, /* (169) grouplist ::= grouplist COMMA item */ + { 268, -1 }, /* (170) grouplist ::= item */ + { 255, 0 }, /* (171) having_opt ::= */ + { 255, -2 }, /* (172) having_opt ::= HAVING expr */ + { 257, 0 }, /* (173) limit_opt ::= */ + { 257, -2 }, /* (174) limit_opt ::= LIMIT signed */ + { 257, -4 }, /* (175) limit_opt ::= LIMIT signed OFFSET signed */ + { 257, -4 }, /* (176) limit_opt ::= LIMIT signed COMMA signed */ + { 256, 0 }, /* (177) slimit_opt ::= */ + { 256, -2 }, /* (178) slimit_opt ::= SLIMIT signed */ + { 256, -4 }, /* (179) slimit_opt ::= SLIMIT signed SOFFSET signed */ + { 256, -4 }, /* (180) slimit_opt ::= SLIMIT signed COMMA signed */ + { 249, 0 }, /* (181) where_opt ::= */ + { 249, -2 }, /* (182) where_opt ::= WHERE expr */ + { 260, -3 }, /* (183) expr ::= LP expr RP */ + { 260, -1 }, /* (184) expr ::= ID */ + { 260, -3 }, /* (185) expr ::= ID DOT ID */ + { 260, -3 }, /* (186) expr ::= ID DOT STAR */ + { 260, -1 }, /* (187) expr ::= INTEGER */ + { 260, -2 }, /* (188) expr ::= MINUS INTEGER */ + { 260, -2 }, /* (189) expr ::= PLUS INTEGER */ + { 260, -1 }, /* (190) expr ::= FLOAT */ + { 260, -2 }, /* (191) expr ::= MINUS FLOAT */ + { 260, -2 }, /* (192) expr ::= PLUS FLOAT */ + { 260, -1 }, /* (193) expr ::= STRING */ + { 260, -1 }, /* (194) expr ::= NOW */ + { 260, -1 }, /* (195) expr ::= VARIABLE */ + { 260, -1 }, /* (196) expr ::= BOOL */ + { 260, -4 }, /* (197) expr ::= ID LP exprlist RP */ + { 260, -4 }, /* (198) expr ::= ID LP STAR RP */ + { 260, -3 }, /* (199) expr ::= expr IS NULL */ + { 260, -4 }, /* (200) expr ::= expr IS NOT NULL */ + { 260, -3 }, /* (201) expr ::= expr LT expr */ + { 260, -3 }, /* (202) expr ::= expr GT expr */ + { 260, -3 }, /* (203) expr ::= expr LE expr */ + { 260, -3 }, /* (204) expr ::= expr GE expr */ + { 260, -3 }, /* (205) expr ::= expr NE expr */ + { 260, -3 }, /* (206) expr ::= expr EQ expr */ + { 260, -3 }, /* (207) expr ::= expr AND expr */ + { 260, -3 }, /* (208) expr ::= expr OR expr */ + { 260, -3 }, /* (209) expr ::= expr PLUS expr */ + { 260, -3 }, /* (210) expr ::= expr MINUS expr */ + { 260, -3 }, /* (211) expr ::= expr STAR expr */ + { 260, -3 }, /* (212) expr ::= expr SLASH expr */ + { 260, -3 }, /* (213) expr ::= expr REM expr */ + { 260, -3 }, /* (214) expr ::= expr LIKE expr */ + { 260, -5 }, /* (215) expr ::= expr IN LP exprlist RP */ + { 269, -3 }, /* (216) exprlist ::= exprlist COMMA expritem */ + { 269, -1 }, /* (217) exprlist ::= expritem */ + { 270, -1 }, /* (218) expritem ::= expr */ + { 270, 0 }, /* (219) expritem ::= */ + { 208, -3 }, /* (220) cmd ::= RESET QUERY CACHE */ + { 208, -7 }, /* (221) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + { 208, -7 }, /* (222) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + { 208, -7 }, /* (223) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + { 208, -7 }, /* (224) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + { 208, -8 }, /* (225) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + { 208, -9 }, /* (226) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + { 208, -3 }, /* (227) cmd ::= KILL CONNECTION INTEGER */ + { 208, -5 }, /* (228) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + { 208, -5 }, /* (229) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2405,7 +2416,7 @@ static void yy_reduce( break; case 131: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ { - yylhsminor.yy150 = tSetQuerySQLElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy224, yymsp[-9].minor.yy494, yymsp[-8].minor.yy66, yymsp[-4].minor.yy494, yymsp[-3].minor.yy494, &yymsp[-7].minor.yy0, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy494, &yymsp[0].minor.yy188, &yymsp[-1].minor.yy188); + yylhsminor.yy150 = tSetQuerySQLElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy224, yymsp[-9].minor.yy494, yymsp[-8].minor.yy66, yymsp[-4].minor.yy494, yymsp[-3].minor.yy494, &yymsp[-7].minor.yy314, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy494, &yymsp[0].minor.yy188, &yymsp[-1].minor.yy188); } yymsp[-11].minor.yy150 = yylhsminor.yy150; break; @@ -2509,17 +2520,18 @@ static void yy_reduce( yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 151: /* interval_opt ::= INTERVAL LP tmvar RP */ - case 156: /* sliding_opt ::= SLIDING LP tmvar RP */ yytestcase(yyruleno==156); -{yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } +{yymsp[-3].minor.yy314.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy314.offset.n = 0; yymsp[-3].minor.yy314.offset.z = NULL; yymsp[-3].minor.yy314.offset.type = 0;} break; - case 152: /* interval_opt ::= */ - case 157: /* sliding_opt ::= */ yytestcase(yyruleno==157); -{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } + case 152: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ +{yymsp[-5].minor.yy314.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy314.offset = yymsp[-1].minor.yy0;} break; - case 153: /* fill_opt ::= */ + case 153: /* interval_opt ::= */ +{memset(&yymsp[1].minor.yy314, 0, sizeof(yymsp[1].minor.yy314));} + break; + case 154: /* fill_opt ::= */ {yymsp[1].minor.yy494 = 0; } break; - case 154: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + case 155: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { tVariant A = {0}; toTSDBType(yymsp[-3].minor.yy0.type); @@ -2529,33 +2541,39 @@ static void yy_reduce( yymsp[-5].minor.yy494 = yymsp[-1].minor.yy494; } break; - case 155: /* fill_opt ::= FILL LP ID RP */ + case 156: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-3].minor.yy494 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } break; - case 158: /* orderby_opt ::= */ - case 166: /* groupby_opt ::= */ yytestcase(yyruleno==166); + case 157: /* sliding_opt ::= SLIDING LP tmvar RP */ +{yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } + break; + case 158: /* sliding_opt ::= */ +{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } + break; + case 159: /* orderby_opt ::= */ + case 167: /* groupby_opt ::= */ yytestcase(yyruleno==167); {yymsp[1].minor.yy494 = 0;} break; - case 159: /* orderby_opt ::= ORDER BY sortlist */ - case 167: /* groupby_opt ::= GROUP BY grouplist */ yytestcase(yyruleno==167); + case 160: /* orderby_opt ::= ORDER BY sortlist */ + case 168: /* groupby_opt ::= GROUP BY grouplist */ yytestcase(yyruleno==168); {yymsp[-2].minor.yy494 = yymsp[0].minor.yy494;} break; - case 160: /* sortlist ::= sortlist COMMA item sortorder */ + case 161: /* sortlist ::= sortlist COMMA item sortorder */ { yylhsminor.yy494 = tVariantListAppend(yymsp[-3].minor.yy494, &yymsp[-1].minor.yy312, yymsp[0].minor.yy82); } yymsp[-3].minor.yy494 = yylhsminor.yy494; break; - case 161: /* sortlist ::= item sortorder */ + case 162: /* sortlist ::= item sortorder */ { yylhsminor.yy494 = tVariantListAppend(NULL, &yymsp[-1].minor.yy312, yymsp[0].minor.yy82); } yymsp[-1].minor.yy494 = yylhsminor.yy494; break; - case 162: /* item ::= ids cpxName */ + case 163: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; @@ -2564,196 +2582,200 @@ static void yy_reduce( } yymsp[-1].minor.yy312 = yylhsminor.yy312; break; - case 163: /* sortorder ::= ASC */ + case 164: /* sortorder ::= ASC */ {yymsp[0].minor.yy82 = TSDB_ORDER_ASC; } break; - case 164: /* sortorder ::= DESC */ + case 165: /* sortorder ::= DESC */ {yymsp[0].minor.yy82 = TSDB_ORDER_DESC;} break; - case 165: /* sortorder ::= */ + case 166: /* sortorder ::= */ {yymsp[1].minor.yy82 = TSDB_ORDER_ASC;} break; - case 168: /* grouplist ::= grouplist COMMA item */ + case 169: /* grouplist ::= grouplist COMMA item */ { yylhsminor.yy494 = tVariantListAppend(yymsp[-2].minor.yy494, &yymsp[0].minor.yy312, -1); } yymsp[-2].minor.yy494 = yylhsminor.yy494; break; - case 169: /* grouplist ::= item */ + case 170: /* grouplist ::= item */ { yylhsminor.yy494 = tVariantListAppend(NULL, &yymsp[0].minor.yy312, -1); } yymsp[0].minor.yy494 = yylhsminor.yy494; break; - case 170: /* having_opt ::= */ - case 180: /* where_opt ::= */ yytestcase(yyruleno==180); - case 216: /* expritem ::= */ yytestcase(yyruleno==216); + case 171: /* having_opt ::= */ + case 181: /* where_opt ::= */ yytestcase(yyruleno==181); + case 219: /* expritem ::= */ yytestcase(yyruleno==219); {yymsp[1].minor.yy66 = 0;} break; - case 171: /* having_opt ::= HAVING expr */ - case 181: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==181); + case 172: /* having_opt ::= HAVING expr */ + case 182: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==182); {yymsp[-1].minor.yy66 = yymsp[0].minor.yy66;} break; - case 172: /* limit_opt ::= */ - case 176: /* slimit_opt ::= */ yytestcase(yyruleno==176); + case 173: /* limit_opt ::= */ + case 177: /* slimit_opt ::= */ yytestcase(yyruleno==177); {yymsp[1].minor.yy188.limit = -1; yymsp[1].minor.yy188.offset = 0;} break; - case 173: /* limit_opt ::= LIMIT signed */ - case 177: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==177); + case 174: /* limit_opt ::= LIMIT signed */ + case 178: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==178); {yymsp[-1].minor.yy188.limit = yymsp[0].minor.yy271; yymsp[-1].minor.yy188.offset = 0;} break; - case 174: /* limit_opt ::= LIMIT signed OFFSET signed */ - case 178: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ yytestcase(yyruleno==178); + case 175: /* limit_opt ::= LIMIT signed OFFSET signed */ + case 179: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ yytestcase(yyruleno==179); {yymsp[-3].minor.yy188.limit = yymsp[-2].minor.yy271; yymsp[-3].minor.yy188.offset = yymsp[0].minor.yy271;} break; - case 175: /* limit_opt ::= LIMIT signed COMMA signed */ - case 179: /* slimit_opt ::= SLIMIT signed COMMA signed */ yytestcase(yyruleno==179); + case 176: /* limit_opt ::= LIMIT signed COMMA signed */ + case 180: /* slimit_opt ::= SLIMIT signed COMMA signed */ yytestcase(yyruleno==180); {yymsp[-3].minor.yy188.limit = yymsp[0].minor.yy271; yymsp[-3].minor.yy188.offset = yymsp[-2].minor.yy271;} break; - case 182: /* expr ::= LP expr RP */ + case 183: /* expr ::= LP expr RP */ {yymsp[-2].minor.yy66 = yymsp[-1].minor.yy66; } break; - case 183: /* expr ::= ID */ + case 184: /* expr ::= ID */ {yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);} yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 184: /* expr ::= ID DOT ID */ + case 185: /* expr ::= ID DOT ID */ {yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 185: /* expr ::= ID DOT STAR */ + case 186: /* expr ::= ID DOT STAR */ {yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 186: /* expr ::= INTEGER */ + case 187: /* expr ::= INTEGER */ {yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);} yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 187: /* expr ::= MINUS INTEGER */ - case 188: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==188); + case 188: /* expr ::= MINUS INTEGER */ + case 189: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==189); {yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);} yymsp[-1].minor.yy66 = yylhsminor.yy66; break; - case 189: /* expr ::= FLOAT */ + case 190: /* expr ::= FLOAT */ {yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);} yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 190: /* expr ::= MINUS FLOAT */ - case 191: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==191); + case 191: /* expr ::= MINUS FLOAT */ + case 192: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==192); {yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);} yymsp[-1].minor.yy66 = yylhsminor.yy66; break; - case 192: /* expr ::= STRING */ + case 193: /* expr ::= STRING */ {yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);} yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 193: /* expr ::= NOW */ + case 194: /* expr ::= NOW */ {yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); } yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 194: /* expr ::= VARIABLE */ + case 195: /* expr ::= VARIABLE */ {yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);} yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 195: /* expr ::= BOOL */ + case 196: /* expr ::= BOOL */ {yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);} yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 196: /* expr ::= ID LP exprlist RP */ -{ - yylhsminor.yy66 = tSQLExprCreateFunction(yymsp[-1].minor.yy224, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); -} + case 197: /* expr ::= ID LP exprlist RP */ +{ yylhsminor.yy66 = tSQLExprCreateFunction(yymsp[-1].minor.yy224, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy66 = yylhsminor.yy66; break; - case 197: /* expr ::= ID LP STAR RP */ -{ - yylhsminor.yy66 = tSQLExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); -} + case 198: /* expr ::= ID LP STAR RP */ +{ yylhsminor.yy66 = tSQLExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy66 = yylhsminor.yy66; break; - case 198: /* expr ::= expr AND expr */ -{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_AND);} + case 199: /* expr ::= expr IS NULL */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, NULL, TK_ISNULL);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 199: /* expr ::= expr OR expr */ -{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_OR); } - yymsp[-2].minor.yy66 = yylhsminor.yy66; + case 200: /* expr ::= expr IS NOT NULL */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-3].minor.yy66, NULL, TK_NOTNULL);} + yymsp[-3].minor.yy66 = yylhsminor.yy66; break; - case 200: /* expr ::= expr LT expr */ + case 201: /* expr ::= expr LT expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_LT);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 201: /* expr ::= expr GT expr */ + case 202: /* expr ::= expr GT expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_GT);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 202: /* expr ::= expr LE expr */ + case 203: /* expr ::= expr LE expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_LE);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 203: /* expr ::= expr GE expr */ + case 204: /* expr ::= expr GE expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_GE);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 204: /* expr ::= expr NE expr */ + case 205: /* expr ::= expr NE expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_NE);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 205: /* expr ::= expr EQ expr */ + case 206: /* expr ::= expr EQ expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_EQ);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 206: /* expr ::= expr PLUS expr */ + case 207: /* expr ::= expr AND expr */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_AND);} + yymsp[-2].minor.yy66 = yylhsminor.yy66; + break; + case 208: /* expr ::= expr OR expr */ +{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_OR); } + yymsp[-2].minor.yy66 = yylhsminor.yy66; + break; + case 209: /* expr ::= expr PLUS expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_PLUS); } yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 207: /* expr ::= expr MINUS expr */ + case 210: /* expr ::= expr MINUS expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_MINUS); } yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 208: /* expr ::= expr STAR expr */ + case 211: /* expr ::= expr STAR expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_STAR); } yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 209: /* expr ::= expr SLASH expr */ + case 212: /* expr ::= expr SLASH expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_DIVIDE);} yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 210: /* expr ::= expr REM expr */ + case 213: /* expr ::= expr REM expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_REM); } yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 211: /* expr ::= expr LIKE expr */ + case 214: /* expr ::= expr LIKE expr */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_LIKE); } yymsp[-2].minor.yy66 = yylhsminor.yy66; break; - case 212: /* expr ::= expr IN LP exprlist RP */ + case 215: /* expr ::= expr IN LP exprlist RP */ {yylhsminor.yy66 = tSQLExprCreate(yymsp[-4].minor.yy66, (tSQLExpr*)yymsp[-1].minor.yy224, TK_IN); } yymsp[-4].minor.yy66 = yylhsminor.yy66; break; - case 213: /* exprlist ::= exprlist COMMA expritem */ + case 216: /* exprlist ::= exprlist COMMA expritem */ {yylhsminor.yy224 = tSQLExprListAppend(yymsp[-2].minor.yy224,yymsp[0].minor.yy66,0);} yymsp[-2].minor.yy224 = yylhsminor.yy224; break; - case 214: /* exprlist ::= expritem */ + case 217: /* exprlist ::= expritem */ {yylhsminor.yy224 = tSQLExprListAppend(0,yymsp[0].minor.yy66,0);} yymsp[0].minor.yy224 = yylhsminor.yy224; break; - case 215: /* expritem ::= expr */ + case 218: /* expritem ::= expr */ {yylhsminor.yy66 = yymsp[0].minor.yy66;} yymsp[0].minor.yy66 = yylhsminor.yy66; break; - case 217: /* cmd ::= RESET QUERY CACHE */ + case 220: /* cmd ::= RESET QUERY CACHE */ { setDCLSQLElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 218: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 221: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy449, NULL, TSDB_ALTER_TABLE_ADD_COLUMN); setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 219: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 222: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -2764,14 +2786,14 @@ static void yy_reduce( setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 220: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 223: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy449, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN); setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 221: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 224: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -2782,7 +2804,7 @@ static void yy_reduce( setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 222: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 225: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -2796,7 +2818,7 @@ static void yy_reduce( setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 223: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 226: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; @@ -2808,13 +2830,13 @@ static void yy_reduce( setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 224: /* cmd ::= KILL CONNECTION INTEGER */ + case 227: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSQL(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 225: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 228: /* 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 226: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 229: /* 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 49d279e4f7b66e363e0fb192f7f621d0a37d24ec Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Tue, 22 Sep 2020 16:06:40 +0800 Subject: [PATCH 37/77] td-1262: stream support history data --- src/client/src/tscStream.c | 19 ++++------ tests/pytest/fulltest.sh | 1 + tests/pytest/stream/history.py | 63 ++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 tests/pytest/stream/history.py diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index 1ebef4ce0f..ea5532cf48 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -136,7 +136,6 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) { etime = pStream->stime + (etime - pStream->stime) / pStream->interval.interval * pStream->interval.interval; } else { etime = taosTimeTruncate(etime, &pStream->interval, pStream->precision); - //etime = taosGetIntervalStartTimestamp(etime, pStream->interval.sliding, pStream->interval.sliding, pStream->interval.slidingUnit, pStream->precision); } pQueryInfo->window.ekey = etime; if (pQueryInfo->window.skey >= pQueryInfo->window.ekey) { @@ -454,17 +453,11 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in } } else { // timewindow based aggregation stream if (stime == 0) { // no data in meter till now - stime = pQueryInfo->window.skey; - if (stime == INT64_MIN) { - stime = (int64_t)taosGetTimestamp(pStream->precision); - stime = taosTimeTruncate(stime, &pStream->interval, pStream->precision); - stime = taosTimeTruncate(stime - 1, &pStream->interval, pStream->precision); - //stime = taosGetIntervalStartTimestamp(stime, pStream->interval.interval, pStream->interval.interval, pStream->interval.intervalUnit, pStream->precision); - //stime = taosGetIntervalStartTimestamp(stime - 1, pStream->interval.interval, pStream->interval.interval, pStream->interval.intervalUnit, pStream->precision); - tscWarn("%p stream:%p, last timestamp:0, reset to:%" PRId64, pSql, pStream, stime); + if (pQueryInfo->window.skey != INT64_MIN) { + stime = pQueryInfo->window.skey; } + stime = taosTimeTruncate(stime, &pStream->interval, pStream->precision); } else { - //int64_t newStime = taosGetIntervalStartTimestamp(stime, pStream->interval.interval, pStream->interval.interval, pStream->interval.intervalUnit, pStream->precision); int64_t newStime = taosTimeTruncate(stime, &pStream->interval, pStream->precision); if (newStime != stime) { tscWarn("%p stream:%p, last timestamp:%" PRId64 ", reset to:%" PRId64, pSql, pStream, stime, newStime); @@ -477,8 +470,10 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in } static int64_t tscGetLaunchTimestamp(const SSqlStream *pStream) { - int64_t timer = pStream->stime - taosGetTimestamp(pStream->precision); - if (timer < 0) timer = 0; + int64_t timer = 0, now = taosGetTimestamp(pStream->precision); + if (pStream->stime > now) { + timer = pStream->stime - now; + } int64_t startDelay = (pStream->precision == TSDB_TIME_PRECISION_MICRO) ? tsStreamCompStartDelay * 1000L : tsStreamCompStartDelay; diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 9ebf1584e2..ab8593a781 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -154,6 +154,7 @@ python3 ./test.py -f stream/new.py python3 ./test.py -f stream/stream1.py python3 ./test.py -f stream/stream2.py python3 ./test.py -f stream/parser.py +python3 ./test.py -f stream/history.py #alter table python3 ./test.py -f alter/alter_table_crash.py diff --git a/tests/pytest/stream/history.py b/tests/pytest/stream/history.py new file mode 100644 index 0000000000..890580001c --- /dev/null +++ b/tests/pytest/stream/history.py @@ -0,0 +1,63 @@ +################################################################### +# 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 +import time +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.execute("create table cars(ts timestamp, s int) tags(id int)") + tdSql.execute("create table car0 using cars tags(0)") + tdSql.execute("create table car1 using cars tags(1)") + tdSql.execute("create table car2 using cars tags(2)") + tdSql.execute("create table car3 using cars tags(3)") + tdSql.execute("create table car4 using cars tags(4)") + + tdSql.execute("insert into car0 values('2019-01-01 00:00:00.103', 1)") + tdSql.execute("insert into car1 values('2019-01-01 00:00:00.234', 1)") + tdSql.execute("insert into car0 values('2019-01-01 00:00:01.012', 1)") + tdSql.execute("insert into car0 values('2019-01-01 00:00:02.003', 1)") + tdSql.execute("insert into car2 values('2019-01-01 00:00:02.328', 1)") + tdSql.execute("insert into car0 values('2019-01-01 00:00:03.139', 1)") + tdSql.execute("insert into car0 values('2019-01-01 00:00:04.348', 1)") + tdSql.execute("insert into car0 values('2019-01-01 00:00:05.783', 1)") + tdSql.execute("insert into car1 values('2019-01-01 00:00:01.893', 1)") + tdSql.execute("insert into car1 values('2019-01-01 00:00:02.712', 1)") + tdSql.execute("insert into car1 values('2019-01-01 00:00:03.982', 1)") + tdSql.execute("insert into car3 values('2019-01-01 00:00:01.389', 1)") + tdSql.execute("insert into car4 values('2019-01-01 00:00:01.829', 1)") + + tdSql.execute("create table strm as select count(*) from cars interval(4s)") + tdSql.waitedQuery("select * from strm", 2, 100) + tdSql.checkData(0, 1, 11) + tdSql.checkData(1, 1, 2) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) From 3e57707227d76690f4a889b0c355a28f4b386641 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 22 Sep 2020 17:11:24 +0800 Subject: [PATCH 38/77] TD-1388 --- src/client/src/tscSQLParser.c | 2 +- src/inc/twal.h | 1 + src/mnode/src/mnodeDb.c | 8 ++-- src/vnode/src/vnodeMain.c | 6 +++ src/wal/src/walMain.c | 50 ++++++++++++++++++++++-- tests/script/general/db/alter_option.sim | 15 ++++--- 6 files changed, 69 insertions(+), 13 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index a6efffe436..f19381fb29 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -5722,7 +5722,7 @@ int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCMCreateDbMsg* pCreate) { char msg[512] = {0}; if (pCreate->walLevel != -1 && (pCreate->walLevel < TSDB_MIN_WAL_LEVEL || pCreate->walLevel > TSDB_MAX_WAL_LEVEL)) { - snprintf(msg, tListLen(msg), "invalid db option walLevel: %d, only 0-2 allowed", pCreate->walLevel); + snprintf(msg, tListLen(msg), "invalid db option walLevel: %d, only 1-2 allowed", pCreate->walLevel); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg); } diff --git a/src/inc/twal.h b/src/inc/twal.h index 4fdb7aa275..cf570aefdc 100644 --- a/src/inc/twal.h +++ b/src/inc/twal.h @@ -44,6 +44,7 @@ typedef void* twalh; // WAL HANDLE typedef int (*FWalWrite)(void *ahandle, void *pHead, int type); twalh walOpen(const char *path, const SWalCfg *pCfg); +int walAlter(twalh pWal, const SWalCfg *pCfg); void walClose(twalh); int walRenew(twalh); int walWrite(twalh, SWalHead *); diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index 54c049d242..8558350950 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -910,13 +910,13 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) { } if (walLevel > 0 && walLevel != pDb->cfg.walLevel) { - mError("db:%s, can't alter walLevel option", pDb->name); - terrno = TSDB_CODE_MND_INVALID_DB_OPTION; + mDebug("db:%s, walLevel:%d change to %d", pDb->name, pDb->cfg.walLevel, walLevel); + newCfg.walLevel = walLevel; } if (fsyncPeriod >= 0 && fsyncPeriod != pDb->cfg.fsyncPeriod) { - mError("db:%s, can't alter fsyncPeriod option", pDb->name); - terrno = TSDB_CODE_MND_INVALID_DB_OPTION; + mDebug("db:%s, fsyncPeriod:%d change to %d", pDb->name, pDb->cfg.fsyncPeriod, fsyncPeriod); + newCfg.fsyncPeriod = fsyncPeriod; } if (replications > 0 && replications != pDb->cfg.replications) { diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index a4e88fb946..353dbbf373 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -186,6 +186,12 @@ int32_t vnodeAlter(void *param, SMDCreateVnodeMsg *pVnodeCfg) { return code; } + code = walAlter(pVnode->wal, &pVnode->walCfg); + if (code != TSDB_CODE_SUCCESS) { + pVnode->status = TAOS_VN_STATUS_READY; + return code; + } + code = syncReconfig(pVnode->sync, &pVnode->syncCfg); if (code != TSDB_CODE_SUCCESS) { pVnode->status = TAOS_VN_STATUS_READY; diff --git a/src/wal/src/walMain.c b/src/wal/src/walMain.c index bebad69f32..a90c1b171c 100644 --- a/src/wal/src/walMain.c +++ b/src/wal/src/walMain.c @@ -69,6 +69,13 @@ static void walModuleInitFunc() { wDebug("WAL module is initialized"); } +static inline bool walNeedFsyncTimer(SWal *pWal) { + if (pWal->fsyncPeriod > 0 && pWal->level == TAOS_WAL_FSYNC) { + return true; + } + return false; +} + void *walOpen(const char *path, const SWalCfg *pCfg) { SWal *pWal = calloc(sizeof(SWal), 1); if (pWal == NULL) { @@ -95,7 +102,7 @@ void *walOpen(const char *path, const SWalCfg *pCfg) { tstrncpy(pWal->path, path, sizeof(pWal->path)); pthread_mutex_init(&pWal->mutex, NULL); - if (pWal->fsyncPeriod > 0 && pWal->level == TAOS_WAL_FSYNC) { + if (walNeedFsyncTimer(pWal)) { pWal->timer = taosTmrStart(walProcessFsyncTimer, pWal->fsyncPeriod, pWal, walTmrCtrl); if (pWal->timer == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); @@ -127,6 +134,37 @@ void *walOpen(const char *path, const SWalCfg *pCfg) { return pWal; } +int walAlter(twalh wal, const SWalCfg *pCfg) { + SWal *pWal = wal; + if (pWal == NULL) { + return TSDB_CODE_WAL_APP_ERROR; + } + + if (pWal->level == pCfg->walLevel && pWal->fsyncPeriod == pCfg->fsyncPeriod) { + wDebug("wal:%s, old walLevel:%d fsync:%d, new walLevel:%d fsync:%d not change", pWal->name, pWal->level, + pWal->fsyncPeriod, pCfg->walLevel, pCfg->fsyncPeriod); + return TSDB_CODE_SUCCESS; + } + + wInfo("wal:%s, change old walLevel:%d fsync:%d, new walLevel:%d fsync:%d", pWal->name, pWal->level, pWal->fsyncPeriod, + pCfg->walLevel, pCfg->fsyncPeriod); + + pthread_mutex_lock(&pWal->mutex); + pWal->level = pCfg->walLevel; + pWal->fsyncPeriod = pCfg->fsyncPeriod; + if (walNeedFsyncTimer(pWal)) { + wInfo("wal:%s, reset fsync timer, walLevel:%d fsyncPeriod:%d", pWal->name, pWal->level, pWal->fsyncPeriod); + taosTmrReset(walProcessFsyncTimer, pWal->fsyncPeriod, pWal, &pWal->timer,walTmrCtrl); + } else { + wInfo("wal:%s, stop fsync timer, walLevel:%d fsyncPeriod:%d", pWal->name, pWal->level, pWal->fsyncPeriod); + taosTmrStop(pWal->timer); + pWal->timer = NULL; + } + pthread_mutex_unlock(&pWal->mutex); + + return TSDB_CODE_SUCCESS; +} + void walClose(void *handle) { if (handle == NULL) return; @@ -484,6 +522,12 @@ static void walProcessFsyncTimer(void *param, void *tmrId) { if (fsync(pWal->fd) < 0) { wError("wal:%s, fsync failed(%s)", pWal->name, strerror(errno)); } - - pWal->timer = taosTmrStart(walProcessFsyncTimer, pWal->fsyncPeriod, pWal, walTmrCtrl); + + if (walNeedFsyncTimer(pWal)) { + pWal->timer = taosTmrStart(walProcessFsyncTimer, pWal->fsyncPeriod, pWal, walTmrCtrl); + } else { + wInfo("wal:%s, stop fsync timer for walLevel:%d fsyncPeriod:%d", pWal->name, pWal->level, pWal->fsyncPeriod); + taosTmrStop(pWal->timer); + pWal->timer = NULL; + } } diff --git a/tests/script/general/db/alter_option.sim b/tests/script/general/db/alter_option.sim index 49c75966ca..c8aa2480c5 100644 --- a/tests/script/general/db/alter_option.sim +++ b/tests/script/general/db/alter_option.sim @@ -218,7 +218,10 @@ if $data12_db != 1 then return -1 endi -sql_error alter database db wal 2 +sql alter database db wal 1 +sql alter database db wal 2 +sql alter database db wal 1 +sql alter database db wal 2 sql_error alter database db wal 0 sql_error alter database db wal 3 sql_error alter database db wal 4 @@ -226,11 +229,13 @@ sql_error alter database db wal -1 sql_error alter database db wal 1000 print ============== step fsync -sql_error alter database db fsync 2 -sql_error alter database db fsync 3 -sql_error alter database db fsync 4 +sql alter database db fsync 0 +sql alter database db fsync 1 +sql alter database db fsync 3600 +sql alter database db fsync 18000 +sql alter database db fsync 180000 +sql_error alter database db fsync 180001 sql_error alter database db fsync -1 -sql_error alter database db fsync 1000 print ============== step comp sql show databases From b8d0e57ae97b811f9fa9cdff48c183a4c21b39de Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Tue, 22 Sep 2020 17:22:23 +0800 Subject: [PATCH 39/77] [TD-1386] add test case for retention --- tests/pytest/insert/retentionpolicy.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/pytest/insert/retentionpolicy.py b/tests/pytest/insert/retentionpolicy.py index bd294a24f3..c50de31cc4 100644 --- a/tests/pytest/insert/retentionpolicy.py +++ b/tests/pytest/insert/retentionpolicy.py @@ -67,8 +67,12 @@ class TDTestRetetion: cmd = 'insert into test values(now,11);' tdLog.info(cmd) tdSql.execute(cmd) - tdSql.query('select * from test') - tdSql.checkRows(5) + queryRows=tdSql.query('select * from test') + if queryRows==4: + tdSql.checkRows(4) + return 0 + else: + tdSql.checkRows(5) tdLog.info("=============== step3") tdDnodes.stop(1) @@ -77,7 +81,7 @@ class TDTestRetetion: cmd = 'insert into test values(now-1d,11);' tdLog.info(cmd) tdSql.execute(cmd) - tdSql.query('select * from test') + queryRows=tdSql.query('select * from test') tdSql.checkRows(6) tdLog.info("=============== step4") tdDnodes.stop(1) From bec674296e65e642b55933f24eece27b4db86978 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 22 Sep 2020 18:01:11 +0800 Subject: [PATCH 40/77] TD-1368 --- src/vnode/src/vnodeMain.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 353dbbf373..d89c383d6a 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -396,6 +396,7 @@ void vnodeRelease(void *pVnodeRaw) { if (0 == tsEnableVnodeBak) { vInfo("vgId:%d, vnode backup not enabled", pVnode->vgId); } else { + taosRemoveDir(newDir); taosRename(rootDir, newDir); } From a9850f47d0f96cde5837927ae851e463d0e2adfa Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 23 Sep 2020 10:55:44 +0800 Subject: [PATCH 41/77] TD-1425 --- src/mnode/src/mnodeVgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index aa6631ff83..9345bdae2c 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -660,13 +660,13 @@ static int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p for (int32_t i = 0; i < pShow->maxReplica; ++i) { pShow->bytes[cols] = 2; pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT; - strcpy(pSchema[cols].name, "dnode"); + snprintf(pSchema[cols].name, TSDB_COL_NAME_LEN, "dnode%d", i + 1); pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; pShow->bytes[cols] = 9 + VARSTR_HEADER_SIZE; pSchema[cols].type = TSDB_DATA_TYPE_BINARY; - strcpy(pSchema[cols].name, "vstatus"); + snprintf(pSchema[cols].name, TSDB_COL_NAME_LEN, "v%dstatus", i + 1); pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; } From c346e0b0fc626b8180148abf01216f87b8ad6d85 Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Wed, 23 Sep 2020 11:09:41 +0800 Subject: [PATCH 42/77] fix TD-1469 --- src/client/inc/tscUtil.h | 1 + src/client/src/tscParseInsert.c | 3 +-- src/client/src/tscUtil.c | 46 +++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index c4fba06426..79a792ab65 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -191,6 +191,7 @@ SColumn* tscColumnListInsert(SArray* pColList, SColumnIndex* colIndex); SArray* tscColumnListClone(const SArray* src, int16_t tableIndex); void tscColumnListDestroy(SArray* pColList); +void tscDequoteAndTrimToken(SStrToken* pToken); int32_t tscValidateName(SStrToken* pToken); void tscIncStreamExecutionCount(void* pStream); diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 327aac22d1..6fd97c09e9 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -1192,8 +1192,7 @@ int tsParseInsertSql(SSqlObj *pSql) { str += index; if (TK_STRING == sToken.type) { - strdequote(sToken.z); - sToken.n = (uint32_t)strtrim(sToken.z); + tscDequoteAndTrimToken(&sToken); } if (sToken.type == TK_RP) { diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 38fb63f18e..de4a52aed4 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1265,6 +1265,51 @@ static int32_t validateQuoteToken(SStrToken* pToken) { return TSDB_CODE_SUCCESS; } +void tscDequoteAndTrimToken(SStrToken* pToken) { + assert(pToken->type == TK_STRING); + + uint32_t first = 0, last = pToken->n; + + // trim leading spaces + while (first < last) { + char c = pToken->z[first]; + if (c != ' ' && c != '\t') { + break; + } + first++; + } + + // trim ending spaces + while (first < last) { + char c = pToken->z[last - 1]; + if (c != ' ' && c != '\t') { + break; + } + last--; + } + + // there are still at least two characters + if (first < last - 1) { + char c = pToken->z[first]; + // dequote + if ((c == '\'' || c == '"') && c == pToken->z[last - 1]) { + first++; + last--; + } + } + + // left shift the string and pad spaces + for (uint32_t i = 0; i + first < last; i++) { + pToken->z[i] = pToken->z[first + i]; + } + for (uint32_t i = last - first; i < pToken->n; i++) { + pToken->z[i] = ' '; + } + + // adjust token length + pToken->n = last - first; +} + int32_t tscValidateName(SStrToken* pToken) { if (pToken->type != TK_STRING && pToken->type != TK_ID) { return TSDB_CODE_TSC_INVALID_SQL; @@ -1750,6 +1795,7 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm SSqlCmd* pCmd = &pNew->cmd; pCmd->command = cmd; pCmd->parseFinished = 1; + pCmd->autoCreated = pSql->cmd.autoCreated; if (tscAddSubqueryInfo(pCmd) != TSDB_CODE_SUCCESS) { tscFreeSqlObj(pNew); From c83f211c250c5b6b39f8b2a979abc23295df22fd Mon Sep 17 00:00:00 2001 From: zyyang Date: Wed, 23 Sep 2020 11:11:28 +0800 Subject: [PATCH 43/77] [TD-1533]: fix the parse jdbc url error --- .../main/java/com/taosdata/example/JDBCConnectorChecker.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCConnectorChecker.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCConnectorChecker.java index 1e801bc658..74e586d7fd 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCConnectorChecker.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCConnectorChecker.java @@ -11,7 +11,6 @@ public class JDBCConnectorChecker { private static String tbName = "weather"; private Connection connection; - /** * get connection **/ @@ -170,5 +169,4 @@ public class JDBCConnectorChecker { checker.close(); } - } From 5e7c1236e4429fc74734744e1324db795b3f3cf5 Mon Sep 17 00:00:00 2001 From: zyyang Date: Wed, 23 Sep 2020 11:15:25 +0800 Subject: [PATCH 44/77] [TD-1533]: fix the jdbc url parse error --- src/connector/jdbc/deploy-pom.xml | 3 +-- .../jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/connector/jdbc/deploy-pom.xml b/src/connector/jdbc/deploy-pom.xml index 766a58f9ba..3f6ebeff03 100755 --- a/src/connector/jdbc/deploy-pom.xml +++ b/src/connector/jdbc/deploy-pom.xml @@ -5,10 +5,9 @@ com.taosdata.jdbc taos-jdbcdriver - 2.0.0-SNAPSHOT + 2.0.6 jar - JDBCDriver https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc TDengine JDBC Driver diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java index bc649a31e1..13be9d538d 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java @@ -291,8 +291,8 @@ public class TSDBDriver implements java.sql.Driver { return null; } - String lowerUrl = url.toLowerCase(); - if (!lowerUrl.startsWith(URL_PREFIX) && !lowerUrl.startsWith(URL_PREFIX1)) { +// String lowerUrl = url.toLowerCase(); + if (!url.startsWith(URL_PREFIX) && !url.startsWith(URL_PREFIX1)) { return null; } From 0bf112a2589601eee102ea3937cbdf656147226f Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Wed, 23 Sep 2020 11:42:34 +0800 Subject: [PATCH 45/77] [TD-1532] fix taosdemo case bug --- tests/pytest/tools/taosdemo.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/pytest/tools/taosdemo.py b/tests/pytest/tools/taosdemo.py index 54d33c90f3..5bf8ebaf03 100644 --- a/tests/pytest/tools/taosdemo.py +++ b/tests/pytest/tools/taosdemo.py @@ -16,6 +16,7 @@ import os from util.log import * from util.cases import * from util.sql import * +from util.dnodes import * class TDTestCase: @@ -25,11 +26,30 @@ class TDTestCase: self.numberOfTables = 10000 self.numberOfRecords = 100 + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath def run(self): tdSql.prepare() - - os.system("yes | taosdemo -t %d -n %d" % (self.numberOfTables, self.numberOfRecords)) + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + os.system("yes | %staosdemo -t %d -n %d" % (binPath,self.numberOfTables, self.numberOfRecords)) tdSql.execute("use test") tdSql.query("select count(*) from meters") From 8ba206115a18239e43453abd11186648b04d16ef Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 23 Sep 2020 14:39:14 +0800 Subject: [PATCH 46/77] [td-1575] --- src/util/inc/tskiplist.h | 1 + src/util/src/tskiplist.c | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/util/inc/tskiplist.h b/src/util/inc/tskiplist.h index 4ba620dce0..a14a856561 100644 --- a/src/util/inc/tskiplist.h +++ b/src/util/inc/tskiplist.h @@ -136,6 +136,7 @@ typedef struct SSkipListIterator { SSkipListNode *cur; int32_t step; // the number of nodes that have been checked already int32_t order; // order of the iterator + SSkipListNode *next; // next points to the true qualified node in skip list } SSkipListIterator; /** diff --git a/src/util/src/tskiplist.c b/src/util/src/tskiplist.c index 303c2440bf..bacdaef6c8 100644 --- a/src/util/src/tskiplist.c +++ b/src/util/src/tskiplist.c @@ -79,9 +79,12 @@ static SSkipListIterator* doCreateSkipListIterator(SSkipList *pSkipList, int32_t // when order is TSDB_ORDER_ASC, return the last node with key less than val // when order is TSDB_ORDER_DESC, return the first node with key large than val -static SSkipListNode* getPriorNode(SSkipList* pSkipList, const char* val, int32_t order) { +static SSkipListNode* getPriorNode(SSkipList* pSkipList, const char* val, int32_t order, SSkipListNode** pCur) { __compar_fn_t comparFn = pSkipList->comparFn; SSkipListNode *pNode = NULL; + if (pCur != NULL) { + *pCur = NULL; + } if (order == TSDB_ORDER_ASC) { pNode = pSkipList->pHead; @@ -93,6 +96,9 @@ static SSkipListNode* getPriorNode(SSkipList* pSkipList, const char* val, int32_ pNode = p; p = SL_GET_FORWARD_POINTER(p, i); } else { + if (pCur != NULL) { + *pCur = p; + } break; } } @@ -107,6 +113,9 @@ static SSkipListNode* getPriorNode(SSkipList* pSkipList, const char* val, int32_ pNode = p; p = SL_GET_BACKWARD_POINTER(p, i); } else { + if (pCur != NULL) { + *pCur = p; + } break; } } @@ -295,7 +304,7 @@ SArray* tSkipListGet(SSkipList *pSkipList, SSkipListKey key) { pthread_rwlock_wrlock(pSkipList->lock); } - SSkipListNode* pNode = getPriorNode(pSkipList, key, TSDB_ORDER_ASC); + SSkipListNode* pNode = getPriorNode(pSkipList, key, TSDB_ORDER_ASC, NULL); while (1) { SSkipListNode *p = SL_GET_FORWARD_POINTER(pNode, 0); if (p == pSkipList->pTail) { @@ -452,7 +461,7 @@ uint32_t tSkipListRemove(SSkipList *pSkipList, SSkipListKey key) { pthread_rwlock_wrlock(pSkipList->lock); } - SSkipListNode* pNode = getPriorNode(pSkipList, key, TSDB_ORDER_ASC); + SSkipListNode* pNode = getPriorNode(pSkipList, key, TSDB_ORDER_ASC, NULL); while (1) { SSkipListNode *p = SL_GET_FORWARD_POINTER(pNode, 0); if (p == pSkipList->pTail) { @@ -545,7 +554,7 @@ SSkipListIterator *tSkipListCreateIterFromVal(SSkipList* pSkipList, const char* pthread_rwlock_rdlock(pSkipList->lock); } - iter->cur = getPriorNode(pSkipList, val, order); + iter->cur = getPriorNode(pSkipList, val, order, &iter->next); if (pSkipList->lock) { pthread_rwlock_unlock(pSkipList->lock); @@ -567,8 +576,22 @@ bool tSkipListIterNext(SSkipListIterator *iter) { if (iter->order == TSDB_ORDER_ASC) { // ascending order iterate iter->cur = SL_GET_FORWARD_POINTER(iter->cur, 0); + + // a new node is inserted into between iter->cur and iter->next, ignore it + if (iter->cur != iter->next && (iter->next != NULL)) { + iter->cur = iter->next; + } + + iter->next = SL_GET_FORWARD_POINTER(iter->cur, 0); } else { // descending order iterate iter->cur = SL_GET_BACKWARD_POINTER(iter->cur, 0); + + // a new node is inserted into between iter->cur and iter->next, ignore it + if (iter->cur != iter->next && (iter->next != NULL)) { + iter->cur = iter->next; + } + + iter->next = SL_GET_BACKWARD_POINTER(iter->cur, 0); } if (pSkipList->lock) { @@ -715,9 +738,11 @@ SSkipListIterator* doCreateSkipListIterator(SSkipList *pSkipList, int32_t order) iter->order = order; if(order == TSDB_ORDER_ASC) { iter->cur = pSkipList->pHead; + iter->next = SL_GET_FORWARD_POINTER(iter->cur, 0); } else { iter->cur = pSkipList->pTail; + iter->next = SL_GET_BACKWARD_POINTER(iter->cur, 0); } - + return iter; } \ No newline at end of file From 920343a0594b4531e07f41c706128a490a4ae991 Mon Sep 17 00:00:00 2001 From: Hui Li Date: Wed, 23 Sep 2020 15:21:31 +0800 Subject: [PATCH 47/77] [TD-1502] --- tests/gotest/batchtest.sh | 5 + tests/gotest/case001/case001.go | 308 ++++++++++++++++++++++++++++++++ tests/gotest/case001/case001.sh | 70 ++++++++ tests/gotest/test.sh | 42 +++++ 4 files changed, 425 insertions(+) create mode 100644 tests/gotest/batchtest.sh create mode 100644 tests/gotest/case001/case001.go create mode 100644 tests/gotest/case001/case001.sh create mode 100644 tests/gotest/test.sh diff --git a/tests/gotest/batchtest.sh b/tests/gotest/batchtest.sh new file mode 100644 index 0000000000..a027dd0d7c --- /dev/null +++ b/tests/gotest/batchtest.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +bash ./case001/case001.sh +#bash ./case002/case002.sh +#bash ./case003/case003.sh diff --git a/tests/gotest/case001/case001.go b/tests/gotest/case001/case001.go new file mode 100644 index 0000000000..1d5ede6d21 --- /dev/null +++ b/tests/gotest/case001/case001.go @@ -0,0 +1,308 @@ +/* + * 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 . + */ +package main + +import ( + "database/sql" + "fmt" + _ "github.com/taosdata/driver-go/taosSql" + "log" + "time" +) + +func main() { + taosDriverName := "taosSql" + demodb := "demodb" + demot := "demot" + + fmt.Printf("\n======== start demo test ========\n") + // open connect to taos server + db, err := sql.Open(taosDriverName, "root:taosdata@/tcp(192.168.1.217:7100)/") + if err != nil { + log.Fatalf("Open database error: %s\n", err) + } + defer db.Close() + + drop_database(db, demodb) + create_database(db, demodb) + use_database(db, demodb) + create_table(db, demot) + insert_data(db, demot) + select_data(db, demot) + + fmt.Printf("\n======== start stmt mode test ========\n") + + demodbStmt := "demodbStmt" + 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) + + fmt.Printf("\n======== end demo test ========\n") +} + +func drop_database(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + res, err := db.Exec("drop database if exists " + demodb) + checkErr(err, "drop database if exists "+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) + + //sleep 50毫秒 + time.Sleep(time.Duration(50)* time.Millisecond) +} + +func create_database(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + // create database + res, err := db.Exec("create database " + demodb) + checkErr(err, "create db, db.Exec") + + 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) + + return +} + +func use_database(db *sql.DB, demodb string) { + st := time.Now().Nanosecond() + // use database + res, err := db.Exec("use " + demodb) // notes: must no quote to db name + checkErr(err, "use db db.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(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + // create table + res, err := db.Exec("create table " + demot + " (ts timestamp, id int, name binary(8), len tinyint, flag bool, notes binary(8), fv float, dv double)") + checkErr(err, "create table db.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(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + // insert data + res, err := db.Exec("insert into " + demot + + " values (now, 100, 'beijing', 10, true, 'one', 123.456, 123.456)" + + " (now+1s, 101, 'shanghai', 11, true, 'two', 789.123, 789.123)" + + " (now+2s, 102, 'shenzhen', 12, false, 'three', 456.789, 456.789)") + + checkErr(err, "insert data, db.Exec") + + affectd, err := res.RowsAffected() + checkErr(err, "insert data 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(db *sql.DB, demot string) { + st := time.Now().Nanosecond() + + rows, err := db.Query("select * from ? ", demot) // go text mode + checkErr(err, "select db.Query") + + fmt.Printf("%10s%s%8s %5s %9s%s %s %8s%s %7s%s %8s%s %4s%s %5s%s\n", " ", "ts", " ", "id", " ", "name", " ", "len", " ", "flag", " ", "notes", " ", "fv", " ", " ", "dv") + var affectd int + + //decoder := mahonia.NewDecoder("gbk") // 把原来ANSI格式的文本文件里的字符,用gbk进行解码。 + + 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) + checkErr(err, "select 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\n", dv) + + affectd++ + } + + et := time.Now().Nanosecond() + fmt.Printf("select data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) + //fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9) +} + +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("select 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) + panic(err) + } +} diff --git a/tests/gotest/case001/case001.sh b/tests/gotest/case001/case001.sh new file mode 100644 index 0000000000..5a9034c4d1 --- /dev/null +++ b/tests/gotest/case001/case001.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +################################################## +# +# Do go test +# +################################################## + +set +e +#set -x + +script_dir="$(dirname $(readlink -f $0))" +#echo "pwd: $script_dir, para0: $0" + +execName=$0 +execName=`echo ${execName##*/}` +goName=`echo ${execName%.*}` + +###### step 1: start one taosd +scriptDir=$script_dir/../../script/sh +bash $scriptDir/stop_dnodes.sh +bash $scriptDir/deploy.sh -n dnode1 -i 1 +bash $scriptDir/cfg.sh -n dnode1 -c walLevel -v 0 +bash $scriptDir/exec.sh -n dnode1 -s start + +###### step 2: set config item +TAOS_CFG=/etc/taos/taos.cfg +HOSTNAME=`hostname -f` + +if [ ! -f ${TAOS_CFG} ]; then + touch -f $TAOS_CFG +fi + +echo " " > $TAOS_CFG +echo "firstEp ${HOSTNAME}:7100" >> $TAOS_CFG +echo "secondEp ${HOSTNAME}:7200" >> $TAOS_CFG +echo "serverPort 7100" >> $TAOS_CFG +#echo "dataDir $DATA_DIR" >> $TAOS_CFG +#echo "logDir $LOG_DIR" >> $TAOS_CFG +#echo "scriptDir ${CODE_DIR}/../script" >> $TAOS_CFG +echo "numOfLogLines 100000000" >> $TAOS_CFG +echo "dDebugFlag 135" >> $TAOS_CFG +echo "mDebugFlag 135" >> $TAOS_CFG +echo "sdbDebugFlag 135" >> $TAOS_CFG +echo "rpcDebugFlag 135" >> $TAOS_CFG +echo "tmrDebugFlag 131" >> $TAOS_CFG +echo "cDebugFlag 135" >> $TAOS_CFG +echo "httpDebugFlag 135" >> $TAOS_CFG +echo "monitorDebugFlag 135" >> $TAOS_CFG +echo "udebugFlag 135" >> $TAOS_CFG +echo "tablemetakeeptimer 5" >> $TAOS_CFG +echo "wal 0" >> $TAOS_CFG +echo "asyncLog 0" >> $TAOS_CFG +echo "locale en_US.UTF-8" >> $TAOS_CFG +echo "enableCoreFile 1" >> $TAOS_CFG +echo " " >> $TAOS_CFG + +ulimit -n 600000 +ulimit -c unlimited +# +##sudo sysctl -w kernel.core_pattern=$TOP_DIR/core.%p.%e +# + +###### step 3: start build +cd $script_dir +rm -f go.* +go mod init $goName +go build +sleep 1s +sudo ./$goName diff --git a/tests/gotest/test.sh b/tests/gotest/test.sh new file mode 100644 index 0000000000..fe80d44295 --- /dev/null +++ b/tests/gotest/test.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +################################################## +# +# Do go test +# +################################################## + +set +e +#set -x + +FILE_NAME= +RELEASE=0 +while getopts "f:" arg +do + case $arg in + f) + FILE_NAME=$OPTARG + echo "input file: $FILE_NAME" + ;; + ?) + echo "unknow argument" + ;; + esac +done + +# start one taosd +bash ../script/sh/stop_dnodes.sh +bash ../script/sh/deploy.sh -n dnode1 -i 1 +bash ../script/sh/cfg.sh -n dnode1 -c walLevel -v 0 +bash ../script/sh/exec.sh -n dnode1 -s start + +# start build test go file +caseDir=`echo ${FILE_NAME%/*}` +echo "caseDir: $caseDir" +cd $caseDir +rm go.* +go mod init $caseDir +go build +sleep 1s +./$caseDir + From 6989ed36963c039f5315ccd6b76173943be52734 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Wed, 23 Sep 2020 17:24:34 +0800 Subject: [PATCH 48/77] remove test case stability --- tests/pytest/fulltest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index e219d76b97..597102a0f0 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -197,5 +197,5 @@ python3 test.py -f tools/taosdemo.py # subscribe python3 test.py -f subscribe/singlemeter.py -python3 test.py -f subscribe/stability.py +#python3 test.py -f subscribe/stability.py python3 test.py -f subscribe/supertable.py \ No newline at end of file From 5337236c04f7d40fba79785dc269f8f3ea007726 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 23 Sep 2020 13:19:57 +0000 Subject: [PATCH 49/77] [TD-1595] --- src/client/src/tscSQLParser.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index b9d4cc13d1..f690d13164 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -820,20 +820,20 @@ int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pzTableNa if (hasSpecifyDB(pzTableName)) { // db has been specified in sql string so we ignore current db path code = setObjFullName(pTableMetaInfo->name, getAccountId(pSql), NULL, pzTableName, NULL); - if (code != 0) { + if (code != TSDB_CODE_SUCCESS) { invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } } else { // get current DB name first, then set it into path SStrToken t = {0}; getCurrentDBName(pSql, &t); if (t.n == 0) { - invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); - } - - code = setObjFullName(pTableMetaInfo->name, NULL, &t, pzTableName, NULL); - if (code != 0) { - invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); - } + code = invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); + } else { + code = setObjFullName(pTableMetaInfo->name, NULL, &t, pzTableName, NULL); + if (code != TSDB_CODE_SUCCESS) { + code = invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); + } + } } if (code != TSDB_CODE_SUCCESS) { From d627ab2a88e37c9e8f38e4163decb79fb7cc855d Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 23 Sep 2020 15:01:18 +0000 Subject: [PATCH 50/77] TD-1574 --- src/common/src/tglobal.c | 2 +- src/os/inc/osDir.h | 1 + src/os/src/detail/CMakeLists.txt | 1 + src/os/src/detail/osDir.c | 53 +++++++++++++++++++++++++++++--- src/util/CMakeLists.txt | 2 +- src/util/src/tlog.c | 12 ++++++-- 6 files changed, 63 insertions(+), 8 deletions(-) diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index a75e712f38..2630e3c468 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -1014,7 +1014,7 @@ static void doInitGlobalConfig(void) { cfg.ptr = &tsLogKeepDays; cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT; - cfg.minValue = 0; + cfg.minValue = -365000; cfg.maxValue = 365000; cfg.ptrLength = 0; cfg.unitType = TAOS_CFG_UTYPE_NONE; diff --git a/src/os/inc/osDir.h b/src/os/inc/osDir.h index 17683743e3..4a522dadb5 100644 --- a/src/os/inc/osDir.h +++ b/src/os/inc/osDir.h @@ -25,6 +25,7 @@ void taosRemoveDir(char *rootDir); int taosMkDir(const char *pathname, mode_t mode); void taosRename(char* oldName, char *newName); void taosRemoveOldLogFiles(char *rootDir, int32_t keepDays); +int32_t taosCompressFile(char *srcFileName, char *destFileName); #ifdef __cplusplus } diff --git a/src/os/src/detail/CMakeLists.txt b/src/os/src/detail/CMakeLists.txt index 9f710e3ddf..afb8935453 100644 --- a/src/os/src/detail/CMakeLists.txt +++ b/src/os/src/detail/CMakeLists.txt @@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) INCLUDE_DIRECTORIES(.) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/zlib-1.2.11/inc) AUX_SOURCE_DIRECTORY(. SRC) SET_SOURCE_FILES_PROPERTIES(osSysinfo.c PROPERTIES COMPILE_FLAGS -w) SET_SOURCE_FILES_PROPERTIES(osCoredump.c PROPERTIES COMPILE_FLAGS -w) diff --git a/src/os/src/detail/osDir.c b/src/os/src/detail/osDir.c index 93651c78ef..bdb840ce01 100644 --- a/src/os/src/detail/osDir.c +++ b/src/os/src/detail/osDir.c @@ -17,6 +17,9 @@ #include "os.h" #include "tglobal.h" #include "tulog.h" +#include "zlib.h" + +#define COMPRESS_STEP_SIZE 163840 void taosRemoveDir(char *rootDir) { DIR *dir = opendir(rootDir); @@ -73,11 +76,11 @@ void taosRemoveOldLogFiles(char *rootDir, int32_t keepDays) { if (de->d_type & DT_DIR) { continue; } else { - // struct stat fState; - // if (stat(fname, &fState) < 0) { - // continue; - // } int32_t len = (int32_t)strlen(filename); + if (len > 3 && strcmp(filename + len - 3, ".gz") == 0) { + len -= 3; + } + int64_t fileSec = 0; for (int i = len - 1; i >= 0; i--) { if (filename[i] == '.') { @@ -100,3 +103,45 @@ void taosRemoveOldLogFiles(char *rootDir, int32_t keepDays) { closedir(dir); rmdir(rootDir); } + +int32_t taosCompressFile(char *srcFileName, char *destFileName) { + int32_t ret = 0; + int32_t len = 0; + char * data = malloc(COMPRESS_STEP_SIZE); + FILE * srcFp = NULL; + gzFile dstFp = NULL; + + srcFp = fopen(srcFileName, "r"); + if (srcFp == NULL) { + ret = -1; + goto cmp_end; + } + + int32_t fd = open(destFileName, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO); + if (fd < 0) { + ret = -2; + goto cmp_end; + } + + dstFp = gzdopen(fd, "wb6f"); + if (dstFp == NULL) { + ret = -3; + goto cmp_end; + } + + while (!feof(srcFp)) { + len = (uLong)fread(data, 1, COMPRESS_STEP_SIZE, srcFp); + gzwrite(dstFp, data, len); + } + +cmp_end: + if (srcFp) { + fclose(srcFp); + } + if (dstFp) { + gzclose(dstFp); + } + free(data); + + return ret; +} diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index e63a085cc8..89c8e3dc39 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -3,7 +3,7 @@ PROJECT(TDengine) AUX_SOURCE_DIRECTORY(src SRC) ADD_LIBRARY(tutil ${SRC}) -TARGET_LINK_LIBRARIES(tutil pthread osdetail lz4) +TARGET_LINK_LIBRARIES(tutil pthread osdetail lz4 z) IF (TD_LINUX) TARGET_LINK_LIBRARIES(tutil m rt) diff --git a/src/util/src/tlog.c b/src/util/src/tlog.c index e5afe1b68e..09b0933fd6 100644 --- a/src/util/src/tlog.c +++ b/src/util/src/tlog.c @@ -139,14 +139,22 @@ static void taosUnLockFile(int32_t fd) { } static void taosKeepOldLog(char *oldName) { - if (tsLogKeepDays <= 0) return; + if (tsLogKeepDays == 0) return; int64_t fileSec = taosGetTimestampSec(); char fileName[LOG_FILE_NAME_LEN + 20]; snprintf(fileName, LOG_FILE_NAME_LEN + 20, "%s.%" PRId64, tsLogObj.logName, fileSec); taosRename(oldName, fileName); - taosRemoveOldLogFiles(tsLogDir, tsLogKeepDays); + if (tsLogKeepDays < 0) { + char compressFileName[LOG_FILE_NAME_LEN + 20]; + snprintf(compressFileName, LOG_FILE_NAME_LEN + 20, "%s.%" PRId64 ".gz", tsLogObj.logName, fileSec); + if (taosCompressFile(fileName, compressFileName) == 0) { + (void)remove(fileName); + } + } + + taosRemoveOldLogFiles(tsLogDir, ABS(tsLogKeepDays)); } static void *taosThreadToOpenNewFile(void *param) { From 1c3b799d0891305b56083dfae257ad8cc026c08c Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Wed, 23 Sep 2020 23:24:16 +0800 Subject: [PATCH 51/77] add restful multiple threads example --- tests/pytest/insert/restful.py | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tests/pytest/insert/restful.py diff --git a/tests/pytest/insert/restful.py b/tests/pytest/insert/restful.py new file mode 100644 index 0000000000..8922065602 --- /dev/null +++ b/tests/pytest/insert/restful.py @@ -0,0 +1,63 @@ +################################################################### +# 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 +import requests, json +import threading +import string +import random + +class RestfulInsert: + def init(self): + self.header = {'Authorization': 'Basic cm9vdDp0YW9zZGF0YQ=='} + self.url = "http://127.0.0.1:6041/rest/sql" + self.ts = 1104508800000 + self.numOfThreads = 50 + + def get_random_string(self, length): + letters = string.ascii_lowercase + result_str = ''.join(random.choice(letters) for i in range(length)) + return result_str + + def insertData(self, threadID): + print("thread %d started" % threadID) + data = "create table test.tb%d(ts timestamp, name nchar(20))" % threadID + requests.post(self.url, data, headers = self.header) + name = self.get_random_string(10) + start = self.ts + while True: + start += 1 + data = "insert into test.tb%d values(%d, '%s')" % (threadID, start, name) + requests.post(self.url, data, headers = self.header) + + def run(self): + data = "drop database if exist test" + requests.post(self.url, data, headers = self.header) + data = "create database test keep 7300" + requests.post(self.url, data, headers = self.header) + + threads = [] + for i in range(self.numOfThreads): + thread = threading.Thread(target=self.insertData, args=(i,)) + thread.start() + threads.append(thread) + + for i in range(self.numOfThreads): + threads[i].join() + +ri = RestfulInsert() +ri.init() +ri.run() + + + From b2eddc776506fcca95a85611ce403365aac144b0 Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Thu, 24 Sep 2020 09:28:29 +0800 Subject: [PATCH 52/77] fix td-1558: fd(eventpoll) leaks --- src/client/src/tscUtil.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 23f412ddd1..77088f5b7c 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1912,7 +1912,6 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void pNew->pTscObj = pSql->pTscObj; pNew->signature = pNew; - T_REF_INC(pNew->pTscObj); pNew->sqlstr = strdup(pSql->sqlstr); if (pNew->sqlstr == NULL) { From 02d1583725496bce0937ff305a5d21b431830155 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 24 Sep 2020 11:09:16 +0800 Subject: [PATCH 53/77] [td-1523] fix memory leaks and refactor some functions. --- src/client/inc/tscUtil.h | 2 ++ src/client/src/tscAsync.c | 5 +---- src/client/src/tscPrepare.c | 6 ++---- src/client/src/tscServer.c | 23 ++++++----------------- src/client/src/tscSql.c | 7 ++----- src/client/src/tscStream.c | 4 +--- src/client/src/tscSub.c | 4 +--- src/client/src/tscSystem.c | 12 +++--------- src/client/src/tscUtil.c | 24 ++++++++++++++---------- src/util/src/tcache.c | 2 +- 10 files changed, 33 insertions(+), 56 deletions(-) diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index 79a792ab65..0323434a99 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -258,6 +258,8 @@ void tscDoQuery(SSqlObj* pSql); */ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cmd); +void registerSqlObj(SSqlObj* pSql); + SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void* param, int32_t cmd, SSqlObj* pPrevSql); void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t subClauseIndex, int32_t tableIndex); diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 09610575f6..c5d622e245 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -51,10 +51,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, void (*fp)(), void* param, const pSql->fp = fp; pSql->fetchFp = fp; - uint64_t handle = (uint64_t) pSql; - pSql->self = taosCachePut(tscObjCache, &handle, sizeof(uint64_t), &pSql, sizeof(uint64_t), 2*3600*1000); - - T_REF_INC(pSql->pTscObj); + registerSqlObj(pSql); pSql->sqlstr = calloc(1, sqlLen + 1); if (pSql->sqlstr == NULL) { diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index c4ca6793ff..cdbd8685df 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -545,10 +545,8 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { pSql->cmd.numOfParams = 0; pSql->cmd.batchSize = 0; - - uint64_t handle = (uint64_t) pSql; - pSql->self = taosCachePut(tscObjCache, &handle, sizeof(uint64_t), &pSql, sizeof(uint64_t), 2*3600*1000); - T_REF_INC(pSql->pTscObj); + + registerSqlObj(pSql); int32_t code = tsParseSql(pSql, true); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 8eaa406bce..b26abf2145 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -1987,15 +1987,11 @@ static void createHBObj(STscObj* pObj) { pSql->param = pObj; pSql->pTscObj = pObj; pSql->signature = pSql; + + registerSqlObj(pSql); + tscDebug("%p HB is allocated, pObj:%p", pSql, pObj); + pObj->pHb = pSql; - - tscAddSubqueryInfo(&pObj->pHb->cmd); - - int64_t ad = (int64_t) pSql; - pSql->self = taosCachePut(tscObjCache, &ad, sizeof(int64_t), &pSql, sizeof(int64_t), 2 * 60 * 1000); - T_REF_INC(pObj); - - tscDebug("%p HB is allocated, pObj:%p", pObj->pHb, pObj); } int tscProcessConnectRsp(SSqlObj *pSql) { @@ -2170,11 +2166,7 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf pNew->signature = pNew; pNew->cmd.command = TSDB_SQL_META; - T_REF_INC(pNew->pTscObj); - - // TODO add test case on x86 platform - uint64_t adr = (uint64_t) pNew; - pNew->self = taosCachePut(tscObjCache, &adr, sizeof(uint64_t), &pNew, sizeof(uint64_t), 2*60*1000); + registerSqlObj(pNew); tscAddSubqueryInfo(&pNew->cmd); @@ -2301,10 +2293,7 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) { } pNewQueryInfo->numOfTables = pQueryInfo->numOfTables; - T_REF_INC(pNew->pTscObj); - - uint64_t p = (uint64_t) pNew; - pNew->self = taosCachePut(tscObjCache, &p, sizeof(uint64_t), &pNew, sizeof(uint64_t), 2 * 600 * 1000); + registerSqlObj(pNew); tscDebug("%p new sqlObj:%p to get vgroupInfo, numOfTables:%d", pSql, pNew, pNewQueryInfo->numOfTables); pNew->fp = tscTableMetaCallBack; diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index e1a07fdcfe..347e3cb508 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -156,10 +156,7 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con *taos = pObj; } - T_REF_INC(pSql->pTscObj); - - uint64_t key = (uint64_t) pSql; - pSql->self = taosCachePut(tscObjCache, &key, sizeof(uint64_t), &pSql, sizeof(uint64_t), 2*3600*1000); + registerSqlObj(pSql); tsInsertHeadSize = sizeof(SMsgDesc) + sizeof(SSubmitMsg); return pSql; @@ -270,7 +267,7 @@ void taos_close(TAOS *taos) { pHb->pRpcCtx = NULL; } - tscDebug("%p, HB is freed", pHb); + tscDebug("%p HB is freed", pHb); taos_free_result(pHb); } diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index 35cd09a033..81b8cf7359 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -510,9 +510,7 @@ static void tscCreateStream(void *param, TAOS_RES *res, int code) { return; } - uint64_t handle = (uint64_t) pSql; - pSql->self = taosCachePut(tscObjCache, &handle, sizeof(uint64_t), &pSql, sizeof(uint64_t), 2*3600*1000); - T_REF_INC(pSql->pTscObj); + registerSqlObj(pSql); SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); diff --git a/src/client/src/tscSub.c b/src/client/src/tscSub.c index 760c5f5a51..7913e0fa03 100644 --- a/src/client/src/tscSub.c +++ b/src/client/src/tscSub.c @@ -152,9 +152,7 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* goto fail; } - uint64_t handle = (uint64_t) pSql; - pSql->self = taosCachePut(tscObjCache, &handle, sizeof(uint64_t), &pSql, sizeof(uint64_t), 2*3600*1000); - T_REF_INC(pSql->pTscObj); + registerSqlObj(pSql); code = tsParseSql(pSql, false); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index 82ce1d3679..620fe13a9f 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -122,11 +122,8 @@ void taos_init_imp(void) { tscInitMsgsFp(); int queueSize = tsMaxConnections*2; - if (tscEmbedded == 0) { - tscNumOfThreads = (int)(tsNumOfCores * tsNumOfThreadsPerCore / 2.0); - } else { - tscNumOfThreads = (int)(tsNumOfCores * tsNumOfThreadsPerCore / 4.0); - } + double factor = (tscEmbedded == 0)? 2.0:4.0; + tscNumOfThreads = (int)(tsNumOfCores * tsNumOfThreadsPerCore / factor); if (tscNumOfThreads < 2) tscNumOfThreads = 2; @@ -140,11 +137,8 @@ void taos_init_imp(void) { if(0 == tscEmbedded){ taosTmrReset(tscCheckDiskUsage, 10, NULL, tscTmr, &tscCheckDiskUsageTmr); } - - int64_t refreshTime = tsTableMetaKeepTimer; - refreshTime = refreshTime > 10 ? 10 : refreshTime; - refreshTime = refreshTime < 10 ? 10 : refreshTime; + int64_t refreshTime = 10; // 10 seconds by default if (tscMetaCache == NULL) { tscMetaCache = taosCacheInit(TSDB_DATA_TYPE_BINARY, refreshTime, false, NULL, "tableMeta"); tscObjCache = taosCacheInit(TSDB_DATA_TYPE_BIGINT, refreshTime/2, false, tscFreeSqlObjInCache, "sqlObj"); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 7f445344b1..5d439927e2 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -424,12 +424,12 @@ void tscFreeSqlObj(SSqlObj* pSql) { free(pSql); - tscDebug("%p free sqlObj completed", p); - int32_t ref = T_REF_DEC(pTscObj); assert(ref >= 0); + tscDebug("%p free sqlObj completed, tscObj:%p ref:%d", p, pTscObj, ref); if (ref == 0) { + tscDebug("%p all sqlObj freed, free tscObj:%p", p, pTscObj); tscCloseTscObj(pTscObj); } } @@ -1783,6 +1783,16 @@ void tscResetForNextRetrieve(SSqlRes* pRes) { pRes->numOfRows = 0; } +void registerSqlObj(SSqlObj* pSql) { + int64_t DEFAULT_LIFE_TIME = 2 * 600 * 1000; // 1200 sec + + int32_t ref = T_REF_INC(pSql->pTscObj); + tscDebug("%p add to tscObj:%p, ref:%d", pSql, pSql->pTscObj, ref); + + uint64_t p = (uint64_t) pSql; + pSql->self = taosCachePut(tscObjCache, &p, sizeof(uint64_t), &p, sizeof(uint64_t), DEFAULT_LIFE_TIME); +} + SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cmd) { SSqlObj* pNew = (SSqlObj*)calloc(1, sizeof(SSqlObj)); if (pNew == NULL) { @@ -1822,10 +1832,7 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm STableMetaInfo* pMasterTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, pSql->cmd.clauseIndex, 0); tscAddTableMetaInfo(pQueryInfo, pMasterTableMetaInfo->name, NULL, NULL, NULL); - - T_REF_INC(pNew->pTscObj); - uint64_t p = (uint64_t) pNew; - pNew->self = taosCachePut(tscObjCache, &p, sizeof(uint64_t), &pNew, sizeof(uint64_t), 2 * 600 * 1000); + registerSqlObj(pNew); return pNew; } @@ -2063,10 +2070,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void tscDebug("%p new sub insertion: %p, vnodeIdx:%d", pSql, pNew, pTableMetaInfo->vgroupIndex); } - T_REF_INC(pNew->pTscObj); - - uint64_t p = (uint64_t) pNew; - pNew->self = taosCachePut(tscObjCache, &p, sizeof(uint64_t), &pNew, sizeof(uint64_t), 2 * 600 * 10); + registerSqlObj(pNew); return pNew; _error: diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index 49b9996cf4..2637699adb 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -97,7 +97,7 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo int32_t size = (int32_t)taosHashGetSize(pCacheObj->pHashTable); assert(size > 0); - uDebug("cache:%s, key:%p, %p is destroyed from cache, size:%dbytes, num:%d size:%" PRId64 "bytes", + uDebug("cache:%s, key:%p, %p is destroyed from cache, size:%dbytes, totalNum:%d size:%" PRId64 "bytes", pCacheObj->name, pNode->key, pNode->data, pNode->size, size - 1, pCacheObj->totalSize); if (pCacheObj->freeFp) { From 3a26dd3bfcd019f5ba45164a220c997c91c69139 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 24 Sep 2020 11:14:35 +0800 Subject: [PATCH 54/77] [td-225]fix compiler error. --- src/client/src/tscUtil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 5d439927e2..21524f8fd2 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1784,7 +1784,7 @@ void tscResetForNextRetrieve(SSqlRes* pRes) { } void registerSqlObj(SSqlObj* pSql) { - int64_t DEFAULT_LIFE_TIME = 2 * 600 * 1000; // 1200 sec + int32_t DEFAULT_LIFE_TIME = 2 * 600 * 1000; // 1200 sec int32_t ref = T_REF_INC(pSql->pTscObj); tscDebug("%p add to tscObj:%p, ref:%d", pSql, pSql->pTscObj, ref); From 0f5d866f9ba56d1c69f971f9e66e4f5de2b3b2a7 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Sep 2020 11:14:40 +0800 Subject: [PATCH 55/77] [TD-1587] add python restful example --- tests/pytest/insert/restful.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/pytest/insert/restful.py b/tests/pytest/insert/restful.py index 8922065602..bf9bde99f0 100644 --- a/tests/pytest/insert/restful.py +++ b/tests/pytest/insert/restful.py @@ -41,7 +41,7 @@ class RestfulInsert: requests.post(self.url, data, headers = self.header) def run(self): - data = "drop database if exist test" + data = "drop database if exists test" requests.post(self.url, data, headers = self.header) data = "create database test keep 7300" requests.post(self.url, data, headers = self.header) @@ -57,7 +57,4 @@ class RestfulInsert: ri = RestfulInsert() ri.init() -ri.run() - - - +ri.run() \ No newline at end of file From 4149545bc0ef7f077f4abfe760d188fd4a922026 Mon Sep 17 00:00:00 2001 From: zyyang Date: Thu, 24 Sep 2020 11:30:54 +0800 Subject: [PATCH 56/77] [TD-1572]: A JdbcTaosdemo is supported now. --- tests/examples/JDBC/JDBCDemo/.gitignore | 2 + tests/examples/JDBC/JDBCDemo/pom.xml | 7 +- .../com/taosdata/example/JdbcTaosdemo.java | 285 ++++++++++++++++++ .../example/domain/JdbcTaosdemoConfig.java | 183 +++++++++++ .../example/task/CreateTableTask.java | 44 +++ .../example/task/InsertTableDatetimeTask.java | 47 +++ .../example/task/InsertTableTask.java | 45 +++ .../taosdata/example/utils/TimeStampUtil.java | 35 +++ .../src/main/resources/log4j.properties | 21 ++ 9 files changed, 668 insertions(+), 1 deletion(-) create mode 100644 tests/examples/JDBC/JDBCDemo/.gitignore create mode 100644 tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcTaosdemo.java create mode 100644 tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/domain/JdbcTaosdemoConfig.java create mode 100644 tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/CreateTableTask.java create mode 100644 tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/InsertTableDatetimeTask.java create mode 100644 tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/InsertTableTask.java create mode 100644 tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/utils/TimeStampUtil.java create mode 100644 tests/examples/JDBC/JDBCDemo/src/main/resources/log4j.properties diff --git a/tests/examples/JDBC/JDBCDemo/.gitignore b/tests/examples/JDBC/JDBCDemo/.gitignore new file mode 100644 index 0000000000..d587e5fe38 --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/.gitignore @@ -0,0 +1,2 @@ +out/ +logs/ diff --git a/tests/examples/JDBC/JDBCDemo/pom.xml b/tests/examples/JDBC/JDBCDemo/pom.xml index 92d757edfd..f3a31d08a0 100644 --- a/tests/examples/JDBC/JDBCDemo/pom.xml +++ b/tests/examples/JDBC/JDBCDemo/pom.xml @@ -63,7 +63,12 @@ com.taosdata.jdbc taos-jdbcdriver - 2.0.4 + 2.0.6 + + + log4j + log4j + 1.2.17 diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcTaosdemo.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcTaosdemo.java new file mode 100644 index 0000000000..461a639682 --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcTaosdemo.java @@ -0,0 +1,285 @@ +package com.taosdata.example; + +import com.taosdata.example.domain.JdbcTaosdemoConfig; +import com.taosdata.example.task.CreateTableTask; +import com.taosdata.example.task.InsertTableDatetimeTask; +import com.taosdata.example.task.InsertTableTask; +import com.taosdata.example.utils.TimeStampUtil; +import com.taosdata.jdbc.TSDBDriver; +import org.apache.log4j.Logger; + +import java.sql.*; +import java.util.*; +import java.util.concurrent.atomic.AtomicLong; + +public class JdbcTaosdemo { + + private static Logger logger = Logger.getLogger(JdbcTaosdemo.class); + private static AtomicLong beginTimestamp = new AtomicLong(TimeStampUtil.datetimeToLong("2005-01-01 00:00:00.000")); + private final JdbcTaosdemoConfig config; + private Connection connection; + private static final String[] locations = {"Beijing", "Shanghai", "Guangzhou", "Shenzhen", "HangZhou", "Tianjin", "Wuhan", "Changsha", "Nanjing", "Xian"}; + private static Random random = new Random(System.currentTimeMillis()); + + public JdbcTaosdemo(JdbcTaosdemoConfig config) { + this.config = config; + } + + private static void printHelp() { + System.out.println("Usage: java -jar JDBCConnectorChecker.jar -h host [OPTION...]"); + System.out.println("-p port The TCP/IP port number to use for the connection. Default is 6030"); + System.out.println("-u user The TDengine user name to use when connecting to the server. Default is 'root'"); + System.out.println("-P password The password to use when connecting to the server.Default is 'taosdata'"); + System.out.println("-d database Destination database. Default is 'test'"); + System.out.println("-m tablePrefix Table prefix name. Default is 'd'"); + System.out.println("-T num_of_threads The number of threads. Default is 10"); + System.out.println("-t num_of_tables The number of tables. Default is 10000"); + System.out.println("-n num_of_records_per_table The number of records per table. Default is 100000"); + System.out.println("-D delete table Delete data methods. Default is false"); + System.out.println("--help Give this help list"); + } + + public static void main(String[] args) { + JdbcTaosdemoConfig config = JdbcTaosdemoConfig.build(args); + + boolean isHelp = Arrays.asList(args).contains("--help"); + if (isHelp) { + printHelp(); + return; + } + if (config.getHost() == null) { + printHelp(); + return; + } + + boolean infinite = Arrays.asList().contains("--infinite"); + JdbcTaosdemo taosdemo = new JdbcTaosdemo(config); + taosdemo.init(); + taosdemo.dropDatabase(); + taosdemo.createDatabase(); + taosdemo.useDatabase(); + taosdemo.createSuperTable(); + taosdemo.createTableMultiThreads(); + if (infinite) { + taosdemo.insertInfinite(); + } else { + taosdemo.insertMultiThreads(); + taosdemo.countFromSuperTable(); + if (config.isDeleteTable()) + taosdemo.dropSuperTable(); + taosdemo.close(); + } + } + + + /** + * establish the connection + */ + private void init() { + try { + Class.forName("com.taosdata.jdbc.TSDBDriver"); + connection = getConnection(config); + if (connection != null) + logger.info("[ OK ] Connection established."); + } catch (ClassNotFoundException | SQLException e) { + logger.error(e.getMessage()); + throw new RuntimeException("connection failed: " + config.getHost()); + } + } + + public static Connection getConnection(JdbcTaosdemoConfig config) throws SQLException { + Properties properties = new Properties(); + properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, config.getHost()); + properties.setProperty(TSDBDriver.PROPERTY_KEY_USER, config.getUser()); + properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD, config.getPassword()); + properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); + return DriverManager.getConnection("jdbc:TAOS://" + config.getHost() + ":" + config.getPort() + "/" + config.getDbName() + "", properties); + } + + /** + * create database + */ + private void createDatabase() { + String sql = "create database if not exists " + config.getDbName() + " keep " + config.getKeep() + " days " + config.getDays(); + execute(sql); + } + + private void dropDatabase() { + String sql = "drop database if exists " + config.getDbName(); + execute(sql); + } + + /** + * use database + */ + private void useDatabase() { + String sql = "use " + config.getDbName(); + execute(sql); + } + + private void createSuperTable() { + String sql = "create table if not exists " + config.getStbName() + "(ts timestamp, current float, voltage int, phase float) tags(location binary(64), groupId int)"; + execute(sql); + } + + /** + * create table use super table with multi threads + */ + private void createTableMultiThreads() { + try { + final int tableSize = config.getNumberOfTable() / config.getNumberOfThreads(); + List threads = new ArrayList<>(); + for (int i = 0; i < config.getNumberOfThreads(); i++) { + Thread thread = new Thread(new CreateTableTask(config, i * tableSize, tableSize), "Thread-" + i); + threads.add(thread); + thread.start(); + } + for (Thread thread : threads) { + thread.join(); + } + logger.info(">>> Multi Threads create table finished."); + } catch (InterruptedException e) { + logger.error(e.getMessage()); + e.printStackTrace(); + } + } + + private void insertInfinite() { + try { + final long startDatetime = TimeStampUtil.datetimeToLong("2005-01-01 00:00:00.000"); + final long finishDatetime = TimeStampUtil.datetimeToLong("2030-01-01 00:00:00.000"); + + final int tableSize = config.getNumberOfTable() / config.getNumberOfThreads(); + List threads = new ArrayList<>(); + for (int i = 0; i < config.getNumberOfThreads(); i++) { + Thread thread = new Thread(new InsertTableDatetimeTask(config, i * tableSize, tableSize, startDatetime, finishDatetime), "Thread-" + i); + threads.add(thread); + thread.start(); + } + for (Thread thread : threads) { + thread.join(); + } + logger.info(">>> Multi Threads insert table finished."); + } catch (InterruptedException e) { + logger.error(e.getMessage()); + e.printStackTrace(); + } + } + + private void insertMultiThreads() { + try { + final int tableSize = config.getNumberOfTable() / config.getNumberOfThreads(); + final int numberOfRecordsPerTable = config.getNumberOfRecordsPerTable(); + List threads = new ArrayList<>(); + for (int i = 0; i < config.getNumberOfThreads(); i++) { + Thread thread = new Thread(new InsertTableTask(config, i * tableSize, tableSize, numberOfRecordsPerTable), "Thread-" + i); + threads.add(thread); + thread.start(); + } + for (Thread thread : threads) { + thread.join(); + } + logger.info(">>> Multi Threads insert table finished."); + } catch (InterruptedException e) { + logger.error(e.getMessage()); + e.printStackTrace(); + } + } + + public static String insertSql(int tableIndex, JdbcTaosdemoConfig config) { + float current = 10 + random.nextFloat(); + int voltage = 200 + random.nextInt(20); + float phase = random.nextFloat(); + String sql = "insert into " + config.getDbName() + "." + config.getTbPrefix() + "" + tableIndex + " " + + "values(" + beginTimestamp.getAndIncrement() + ", " + current + ", " + voltage + ", " + phase + ") "; + return sql; + } + + public static String insertSql(int tableIndex, long ts, JdbcTaosdemoConfig config) { + float current = 10 + random.nextFloat(); + int voltage = 200 + random.nextInt(20); + float phase = random.nextFloat(); + String sql = "insert into " + config.getDbName() + "." + config.getTbPrefix() + "" + tableIndex + " " + + "values(" + ts + ", " + current + ", " + voltage + ", " + phase + ") "; + return sql; + } + + + public static String createTableSql(int tableIndex, JdbcTaosdemoConfig config) { + String location = locations[random.nextInt(locations.length)]; + return "create table d" + tableIndex + " using " + config.getDbName() + "." + config.getStbName() + " tags('" + location + "'," + tableIndex + ")"; + } + + private void countFromSuperTable() { + String sql = "select count(*) from " + config.getDbName() + "." + config.getStbName(); + executeQuery(sql); + } + + private void close() { + try { + if (connection != null) { + this.connection.close(); + logger.info("connection closed."); + } + } catch (SQLException e) { + logger.error(e.getMessage()); + e.printStackTrace(); + } + } + + /** + * drop super table + */ + private void dropSuperTable() { + String sql = "drop table if exists " + config.getDbName() + "." + config.getStbName(); + execute(sql); + } + + /** + * execute sql, use this method when sql is create, alter, drop.. + */ + private void execute(String sql) { + try (Statement statement = connection.createStatement()) { + long start = System.currentTimeMillis(); + boolean execute = statement.execute(sql); + long end = System.currentTimeMillis(); + printSql(sql, execute, (end - start)); + } catch (SQLException e) { + logger.error(e.getMessage()); + e.printStackTrace(); + } + } + + private void printSql(String sql, boolean succeed, long cost) { + logger.info("[ " + (succeed ? "OK" : "ERROR!") + " ] time cost: " + cost + " ms, execute statement ====> " + sql); + } + + private void executeQuery(String sql) { + try (Statement statement = connection.createStatement()) { + long start = System.currentTimeMillis(); + ResultSet resultSet = statement.executeQuery(sql); + long end = System.currentTimeMillis(); + printSql(sql, true, (end - start)); + printResult(resultSet); + } catch (SQLException e) { + logger.error(e.getMessage()); + e.printStackTrace(); + } + } + + private void printResult(ResultSet resultSet) throws SQLException { + ResultSetMetaData metaData = resultSet.getMetaData(); + while (resultSet.next()) { + StringBuilder sb = new StringBuilder(); + for (int i = 1; i <= metaData.getColumnCount(); i++) { + String columnLabel = metaData.getColumnLabel(i); + String value = resultSet.getString(i); + sb.append(columnLabel + ": " + value + "\t"); + } + logger.info(sb.toString()); + } + } + +} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/domain/JdbcTaosdemoConfig.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/domain/JdbcTaosdemoConfig.java new file mode 100644 index 0000000000..efaddbfa0d --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/domain/JdbcTaosdemoConfig.java @@ -0,0 +1,183 @@ +package com.taosdata.example.domain; + +public class JdbcTaosdemoConfig { + + //The host to connect to TDengine. Must insert one + private String host; + //The TCP/IP port number to use for the connection. Default is 6030. + private int port = 6030; + //The TDengine user name to use when connecting to the server. Default is 'root' + private String user = "root"; + //The password to use when connecting to the server. Default is 'taosdata' + private String password = "taosdata"; + //Destination database. Default is 'test' + private String dbName = "test"; + + // + private int keep = 365 * 20; + + private int days = 30; + + //Super table Name. Default is 'meters' + private String stbName = "meters"; + + + //Table name prefix. Default is 'd' + private String tbPrefix = "d"; + //The number of threads. Default is 10. + private int numberOfThreads = 10; + //The number of tables. Default is 10000. + private int numberOfTable = 10000; + //The number of records per table. Default is 100000 + private int numberOfRecordsPerTable = 100000; + //Delete data. Default is false + private boolean deleteTable = true; + + /** + * parse args from command line + * + * @param args command line args + * @return JdbcTaosdemoConfig + */ + public static JdbcTaosdemoConfig build(String[] args) { + JdbcTaosdemoConfig config = new JdbcTaosdemoConfig(); + for (int i = 0; i < args.length; i++) { + if ("-h".equals(args[i]) && i < args.length - 1) { + config.setHost(args[++i]); + } + if ("-p".equals(args[i]) && i < args.length - 1) { + config.setPort(Integer.parseInt(args[++i])); + } + if ("-u".equals(args[i]) && i < args.length - 1) { + config.setUser(args[++i]); + } + if ("-P".equals(args[i]) && i < args.length - 1) { + config.setPassword(args[++i]); + } + if ("-d".equals(args[i]) && i < args.length - 1) { + config.setDbName(args[++i]); + } + if ("-m".equals(args[i]) && i < args.length - 1) { + config.setTbPrefix(args[++i]); + } + if ("-T".equals(args[i]) && i < args.length - 1) { + config.setNumberOfThreads(Integer.parseInt(args[++i])); + } + if ("-t".equals(args[i]) && i < args.length - 1) { + config.setNumberOfTable(Integer.parseInt(args[++i])); + } + if ("-n".equals(args[i]) && i < args.length - 1) { + config.setNumberOfRecordsPerTable(Integer.parseInt(args[++i])); + } + if ("-D".equals(args[i]) && i < args.length - 1) { + config.setDeleteTable(Boolean.parseBoolean(args[++i])); + } + + } + return config; + } + + public void setHost(String host) { + this.host = host; + } + + public String getHost() { + return host; + } + + public String getDbName() { + return dbName; + } + + public void setDbName(String dbName) { + this.dbName = dbName; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getStbName() { + return stbName; + } + + public void setStbName(String stbName) { + this.stbName = stbName; + } + + public String getTbPrefix() { + return tbPrefix; + } + + public void setTbPrefix(String tbPrefix) { + this.tbPrefix = tbPrefix; + } + + public int getNumberOfThreads() { + return numberOfThreads; + } + + public void setNumberOfThreads(int numberOfThreads) { + this.numberOfThreads = numberOfThreads; + } + + public int getNumberOfTable() { + return numberOfTable; + } + + public void setNumberOfTable(int numberOfTable) { + this.numberOfTable = numberOfTable; + } + + public int getNumberOfRecordsPerTable() { + return numberOfRecordsPerTable; + } + + public void setNumberOfRecordsPerTable(int numberOfRecordsPerTable) { + this.numberOfRecordsPerTable = numberOfRecordsPerTable; + } + + public boolean isDeleteTable() { + return deleteTable; + } + + public void setDeleteTable(boolean deleteTable) { + this.deleteTable = deleteTable; + } + + public int getKeep() { + return keep; + } + + public void setKeep(int keep) { + this.keep = keep; + } + + public int getDays() { + return days; + } + + public void setDays(int days) { + this.days = days; + } +} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/CreateTableTask.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/CreateTableTask.java new file mode 100644 index 0000000000..167dbdb648 --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/CreateTableTask.java @@ -0,0 +1,44 @@ +package com.taosdata.example.task; + +import com.taosdata.example.JdbcTaosdemo; +import com.taosdata.example.domain.JdbcTaosdemoConfig; +import org.apache.log4j.Logger; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; + +public class CreateTableTask implements Runnable { + + private static Logger logger = Logger.getLogger(CreateTableTask.class); + private final JdbcTaosdemoConfig config; + private final int startIndex; + private final int tableNumber; + + public CreateTableTask(JdbcTaosdemoConfig config, int startIndex, int tableNumber) { + this.config = config; + this.startIndex = startIndex; + this.tableNumber = tableNumber; + } + + @Override + public void run() { + try { + Connection connection = JdbcTaosdemo.getConnection(config); + for (int i = startIndex; i < startIndex + tableNumber; i++) { + Statement statement = connection.createStatement(); + String sql = JdbcTaosdemo.createTableSql(i + 1, config); +// long start = System.currentTimeMillis(); + boolean execute = statement.execute(sql); +// long end = System.currentTimeMillis(); +// printSql(sql, execute, (end - start)); + statement.close(); + logger.info(">>> " + sql); + } + connection.close(); + } catch (SQLException e) { + logger.error(e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/InsertTableDatetimeTask.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/InsertTableDatetimeTask.java new file mode 100644 index 0000000000..a54f73a258 --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/InsertTableDatetimeTask.java @@ -0,0 +1,47 @@ +package com.taosdata.example.task; + +import com.taosdata.example.JdbcTaosdemo; +import com.taosdata.example.domain.JdbcTaosdemoConfig; +import org.apache.log4j.Logger; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; + +public class InsertTableDatetimeTask implements Runnable { + private static Logger logger = Logger.getLogger(InsertTableDatetimeTask.class); + + private final JdbcTaosdemoConfig config; + private final int startTableIndex; + private final int tableNumber; + private final long startDatetime; + private final long finishedDatetime; + + public InsertTableDatetimeTask(JdbcTaosdemoConfig config, int startTableIndex, int tableNumber, long startDatetime, long finishedDatetime) { + this.config = config; + this.startTableIndex = startTableIndex; + this.tableNumber = tableNumber; + this.startDatetime = startDatetime; + this.finishedDatetime = finishedDatetime; + } + + @Override + public void run() { + try { + Connection connection = JdbcTaosdemo.getConnection(config); + for (long ts = startDatetime; ts < finishedDatetime; ts++) { + for (int i = startTableIndex; i < startTableIndex + tableNumber; i++) { + String sql = JdbcTaosdemo.insertSql(i + 1, ts, config); + Statement statement = connection.createStatement(); + statement.execute(sql); + statement.close(); + logger.info(Thread.currentThread().getName() + ">>> " + sql); + } + } + connection.close(); + } catch (SQLException e) { + logger.error(e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/InsertTableTask.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/InsertTableTask.java new file mode 100644 index 0000000000..88f65f739d --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/InsertTableTask.java @@ -0,0 +1,45 @@ +package com.taosdata.example.task; + +import com.taosdata.example.JdbcTaosdemo; +import com.taosdata.example.domain.JdbcTaosdemoConfig; +import org.apache.log4j.Logger; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; + +public class InsertTableTask implements Runnable { + private static Logger logger = Logger.getLogger(InsertTableTask.class); + + private final JdbcTaosdemoConfig config; + private final int startIndex; + private final int tableNumber; + private final int recordsNumber; + + public InsertTableTask(JdbcTaosdemoConfig config, int startIndex, int tableNumber, int recordsNumber) { + this.config = config; + this.startIndex = startIndex; + this.tableNumber = tableNumber; + this.recordsNumber = recordsNumber; + } + + @Override + public void run() { + try { + Connection connection = JdbcTaosdemo.getConnection(config); + for (int i = startIndex; i < startIndex + tableNumber; i++) { + for (int j = 0; j < recordsNumber; j++) { + String sql = JdbcTaosdemo.insertSql(i + 1, config); + Statement statement = connection.createStatement(); + statement.execute(sql); + statement.close(); + logger.info(Thread.currentThread().getName() + ">>> " + sql); + } + } + connection.close(); + } catch (SQLException e) { + logger.error(e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/utils/TimeStampUtil.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/utils/TimeStampUtil.java new file mode 100644 index 0000000000..2ec91ef1cb --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/utils/TimeStampUtil.java @@ -0,0 +1,35 @@ +package com.taosdata.example.utils; + +import java.sql.Date; +import java.text.ParseException; +import java.text.SimpleDateFormat; + +public class TimeStampUtil { + private static final String datetimeFormat = "yyyy-MM-dd HH:mm:ss.SSS"; + + public static long datetimeToLong(String dateTime) { + SimpleDateFormat sdf = new SimpleDateFormat(datetimeFormat); + try { + return sdf.parse(dateTime).getTime(); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + + public static String longToDatetime(long time) { + SimpleDateFormat sdf = new SimpleDateFormat(datetimeFormat); + return sdf.format(new Date(time)); + } + + public static void main(String[] args) { + final String startTime = "2005-01-01 00:00:00.000"; + + long start = TimeStampUtil.datetimeToLong(startTime); + System.out.println(start); + + String datetime = TimeStampUtil.longToDatetime(1519833600000L); + System.out.println(datetime); + } + + +} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/resources/log4j.properties b/tests/examples/JDBC/JDBCDemo/src/main/resources/log4j.properties new file mode 100644 index 0000000000..b445e5f52e --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/resources/log4j.properties @@ -0,0 +1,21 @@ +### 设置### +log4j.rootLogger=debug,stdout,DebugLog,ErrorLog +### 输出信息到控制抬 ### +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n +### 输出DEBUG 级别以上的日志到=logs/error.log ### +log4j.appender.DebugLog=org.apache.log4j.DailyRollingFileAppender +log4j.appender.DebugLog.File=logs/debug.log +log4j.appender.DebugLog.Append=true +log4j.appender.DebugLog.Threshold=DEBUG +log4j.appender.DebugLog.layout=org.apache.log4j.PatternLayout +log4j.appender.DebugLog.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n +### 输出ERROR 级别以上的日志到=logs/error.log ### +log4j.appender.ErrorLog=org.apache.log4j.DailyRollingFileAppender +log4j.appender.ErrorLog.File=logs/error.log +log4j.appender.ErrorLog.Append=true +log4j.appender.ErrorLog.Threshold=ERROR +log4j.appender.ErrorLog.layout=org.apache.log4j.PatternLayout +log4j.appender.ErrorLog.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n \ No newline at end of file From 4aaf2bd99c7252f3a3b520a7de70e35888e3dd68 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 24 Sep 2020 13:52:30 +0800 Subject: [PATCH 57/77] [td-225] refactor codes. --- src/client/inc/tsclient.h | 4 ++-- src/client/src/tscServer.c | 3 ++- src/client/src/tscSql.c | 34 ++++++++++++++++++---------------- src/client/src/tscSub.c | 6 ++++++ src/client/src/tscUtil.c | 27 +++++++++++++-------------- 5 files changed, 41 insertions(+), 33 deletions(-) diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 55ca02dfb5..ea42b0f6a3 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -89,7 +89,7 @@ typedef struct STableComInfo { typedef struct SCMCorVgroupInfo { int32_t version; - int8_t inUse; + int8_t inUse; int8_t numOfEps; SEpAddr epAddr[TSDB_MAX_REPLICA]; } SCMCorVgroupInfo; @@ -107,7 +107,7 @@ typedef struct STableMeta { } STableMeta; typedef struct STableMetaInfo { - STableMeta * pTableMeta; // table meta, cached in client side and acquired by name + STableMeta *pTableMeta; // table meta, cached in client side and acquired by name SVgroupsInfo *vgroupList; SArray *pVgroupTables; // SArray diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index b26abf2145..3cbb0d936e 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -128,6 +128,7 @@ static void tscUpdateVgroupInfo(SSqlObj *pObj, SRpcEpSet *pEpSet) { tscDebug("after: EndPoint in use: %d", pVgroupInfo->inUse); taosCorEndWrite(&pVgroupInfo->version); } + void tscPrintMgmtEp() { SRpcEpSet dump; tscDumpMgmtEpSet(&dump); @@ -745,7 +746,6 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i); if (!tscValidateColumnId(pTableMetaInfo, pExpr->colInfo.colId, pExpr->numOfParams)) { - /* column id is not valid according to the cached table meta, the table meta is expired */ tscError("%p table schema is not matched with parsed sql", pSql); return TSDB_CODE_TSC_INVALID_SQL; } @@ -2294,6 +2294,7 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) { pNewQueryInfo->numOfTables = pQueryInfo->numOfTables; registerSqlObj(pNew); + tscDebug("%p new sqlObj:%p to get vgroupInfo, numOfTables:%d", pSql, pNew, pNewQueryInfo->numOfTables); pNew->fp = tscTableMetaCallBack; diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 347e3cb508..430a762321 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -786,14 +786,17 @@ int taos_validate_sql(TAOS *taos, const char *sql) { } SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); + pSql->pTscObj = taos; pSql->signature = pSql; + SSqlRes *pRes = &pSql->res; SSqlCmd *pCmd = &pSql->cmd; pRes->numOfTotal = 0; pRes->numOfClauseTotal = 0; + tscDebug("%p Valid SQL: %s pObj:%p", pSql, sql, pObj); int32_t sqlLen = (int32_t)strlen(sql); @@ -829,11 +832,12 @@ int taos_validate_sql(TAOS *taos, const char *sql) { tsem_wait(&pSql->rspSem); code = pSql->res.code; } + if (code != TSDB_CODE_SUCCESS) { tscDebug("%p Valid SQL result:%d, %s pObj:%p", pSql, code, taos_errstr(taos), pObj); } - taos_free_result(pSql); + taos_free_result(pSql); return code; } @@ -932,34 +936,32 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); pSql->pTscObj = taos; pSql->signature = pSql; + SSqlRes *pRes = &pSql->res; + pRes->code = 0; pRes->numOfTotal = 0; // the number of getting table meta from server pRes->numOfClauseTotal = 0; - pRes->code = 0; - assert(pSql->fp == NULL); tscDebug("%p tableNameList: %s pObj:%p", pSql, tableNameList, pObj); int32_t tblListLen = (int32_t)strlen(tableNameList); if (tblListLen > MAX_TABLE_NAME_LENGTH) { tscError("%p tableNameList too long, length:%d, maximum allowed:%d", pSql, tblListLen, MAX_TABLE_NAME_LENGTH); - pRes->code = TSDB_CODE_TSC_INVALID_SQL; - taosTFree(pSql); - return pRes->code; + tscFreeSqlObj(pSql); + return TSDB_CODE_TSC_INVALID_SQL; } char *str = calloc(1, tblListLen + 1); if (str == NULL) { - pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; tscError("%p failed to malloc sql string buffer", pSql); - taosTFree(pSql); - return pRes->code; + tscFreeSqlObj(pSql); + return TSDB_CODE_TSC_OUT_OF_MEMORY; } strtolower(str, tableNameList); - pRes->code = (uint8_t)tscParseTblNameList(pSql, str, tblListLen); + int32_t code = (uint8_t) tscParseTblNameList(pSql, str, tblListLen); /* * set the qhandle to 0 before return in order to erase the qhandle value assigned in the previous successful query. @@ -969,17 +971,17 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { pRes->qhandle = 0; free(str); - if (pRes->code != TSDB_CODE_SUCCESS) { + if (code != TSDB_CODE_SUCCESS) { tscFreeSqlObj(pSql); - return pRes->code; + return code; } tscDoQuery(pSql); - tscDebug("%p load multi metermeta result:%d %s pObj:%p", pSql, pRes->code, taos_errstr(taos), pObj); - if (pRes->code != TSDB_CODE_SUCCESS) { - tscPartiallyFreeSqlObj(pSql); + tscDebug("%p load multi table meta result:%d %s pObj:%p", pSql, pRes->code, taos_errstr(taos), pObj); + if ((code = pRes->code) != TSDB_CODE_SUCCESS) { + tscFreeSqlObj(pSql); } - return pRes->code; + return code; } diff --git a/src/client/src/tscSub.c b/src/client/src/tscSub.c index 7913e0fa03..2c81bd7c7c 100644 --- a/src/client/src/tscSub.c +++ b/src/client/src/tscSub.c @@ -105,6 +105,7 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* code = TAOS_SYSTEM_ERROR(errno); goto fail; } + tstrncpy(pSub->topic, topic, sizeof(pSub->topic)); pSub->progress = taosArrayInit(32, sizeof(SSubscriptionProgress)); if (pSub->progress == NULL) { @@ -119,6 +120,7 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* code = TSDB_CODE_TSC_OUT_OF_MEMORY; goto fail; } + pSql->signature = pSql; pSql->pTscObj = pObj; pSql->pSubscription = pSub; @@ -142,6 +144,7 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* code = TSDB_CODE_TSC_OUT_OF_MEMORY; goto fail; } + strtolower(pSql->sqlstr, pSql->sqlstr); pRes->qhandle = 0; pRes->numOfRows = 1; @@ -159,6 +162,7 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* tsem_wait(&pSub->sem); code = pSql->res.code; } + if (code != TSDB_CODE_SUCCESS) { line = __LINE__; goto fail; @@ -180,8 +184,10 @@ fail: } else { tscFreeSqlObj(pSql); } + pSql = NULL; } + if (pSub != NULL) { taosArrayDestroy(pSub->progress); tsem_destroy(&pSub->sem); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 21524f8fd2..33362409cf 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -391,10 +391,21 @@ static UNUSED_FUNC void tscFreeSubobj(SSqlObj* pSql) { */ void tscFreeSqlObjInCache(void *pSql) { assert(pSql != NULL); + SSqlObj** p = (SSqlObj**)pSql; + STscObj* pTscObj = (*p)->pTscObj; assert((*p)->self != 0 && (*p)->self == (p)); tscFreeSqlObj(*p); + + int32_t ref = T_REF_DEC(pTscObj); + assert(ref >= 0); + + tscDebug("%p free sqlObj completed, tscObj:%p ref:%d", *p, pTscObj, ref); + if (ref == 0) { + tscDebug("%p all sqlObj freed, free tscObj:%p", *p, pTscObj); + tscCloseTscObj(pTscObj); + } } void tscFreeSqlObj(SSqlObj* pSql) { @@ -402,10 +413,7 @@ void tscFreeSqlObj(SSqlObj* pSql) { return; } - void *p = pSql; - tscDebug("%p start to free sqlObj", pSql); - STscObj* pTscObj = pSql->pTscObj; tscFreeSubobj(pSql); tscPartiallyFreeSqlObj(pSql); @@ -423,15 +431,6 @@ void tscFreeSqlObj(SSqlObj* pSql) { tsem_destroy(&pSql->rspSem); free(pSql); - - int32_t ref = T_REF_DEC(pTscObj); - assert(ref >= 0); - - tscDebug("%p free sqlObj completed, tscObj:%p ref:%d", p, pTscObj, ref); - if (ref == 0) { - tscDebug("%p all sqlObj freed, free tscObj:%p", p, pTscObj); - tscCloseTscObj(pTscObj); - } } void tscDestroyDataBlock(STableDataBlocks* pDataBlock) { @@ -1821,8 +1820,7 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm pNew->sqlstr = strdup(pSql->sqlstr); if (pNew->sqlstr == NULL) { tscError("%p new subquery failed", pSql); - - free(pNew); + tscFreeSqlObj(pNew); return NULL; } @@ -1832,6 +1830,7 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm STableMetaInfo* pMasterTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, pSql->cmd.clauseIndex, 0); tscAddTableMetaInfo(pQueryInfo, pMasterTableMetaInfo->name, NULL, NULL, NULL); + registerSqlObj(pNew); return pNew; } From 7c361bffb535d9f4c4dce68292cba50d55571a84 Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Thu, 24 Sep 2020 14:25:07 +0800 Subject: [PATCH 58/77] [TD-1469] add test case for alter table and insert --- tests/pytest/fulltest.sh | 1 + tests/pytest/insert/alterTableAndInsert.py | 40 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tests/pytest/insert/alterTableAndInsert.py diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 597102a0f0..a73e7dd5a5 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -17,6 +17,7 @@ python3 ./test.py -f insert/nchar-unicode.py python3 ./test.py -f insert/multi.py python3 ./test.py -f insert/randomNullCommit.py python3 insert/retentionpolicy.py +python3 ./test.py -f insert/alterTableAndInsert.py python3 ./test.py -f table/column_name.py python3 ./test.py -f table/column_num.py diff --git a/tests/pytest/insert/alterTableAndInsert.py b/tests/pytest/insert/alterTableAndInsert.py new file mode 100644 index 0000000000..a0447704f3 --- /dev/null +++ b/tests/pytest/insert/alterTableAndInsert.py @@ -0,0 +1,40 @@ +################################################################### +# 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 * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.execute("create table cars(ts timestamp, speed int) tags(id int)") + tdSql.execute("create table car0 using cars tags(0)") + tdSql.execute("insert into car0 values(now, 1)") + tdSql.execute("alter table cars add column c2 int") + tdSql.execute("insert into car0(ts, 'speed') values(now, 2)") + tdSql.checkAffectedRows(1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) From 29b03317795cbb43f2d70c685b4364afbf7965a2 Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Thu, 24 Sep 2020 15:49:29 +0800 Subject: [PATCH 59/77] add client test cases and update TAOS SQL md file --- .../webdocs/markdowndocs/TAOS SQL-ch.md | 4 +- tests/pytest/client/alterDatabase.py | 55 +++++++++++++++++++ tests/pytest/fulltest.sh | 1 + 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 tests/pytest/client/alterDatabase.py diff --git a/documentation20/webdocs/markdowndocs/TAOS SQL-ch.md b/documentation20/webdocs/markdowndocs/TAOS SQL-ch.md index e0acaee137..66d17c6aa6 100644 --- a/documentation20/webdocs/markdowndocs/TAOS SQL-ch.md +++ b/documentation20/webdocs/markdowndocs/TAOS SQL-ch.md @@ -98,12 +98,12 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic KEEP参数是指修改数据文件保存的天数,缺省值为3650,取值范围[days, 365000],必须大于或等于days参数值。 ```mysql - ALTER DATABASE db_name QUORUM 365; + ALTER DATABASE db_name QUORUM 2; ``` QUORUM参数是指数据写入成功所需要的确认数。取值范围[1, 3]。对于异步复制,quorum设为1,具有master角色的虚拟节点自己确认即可。对于同步复制,需要至少大于等于2。原则上,Quorum >=1 并且 Quorum <= replica(副本数),这个参数在启动一个同步模块实例时需要提供。 ```mysql - ALTER DATABASE db_name BLOCKS 365; + ALTER DATABASE db_name BLOCKS 100; ``` BLOCKS参数是每个VNODE (TSDB) 中有多少cache大小的内存块,因此一个VNODE的用的内存大小粗略为(cache * blocks)。取值范围[3, 1000]。 diff --git a/tests/pytest/client/alterDatabase.py b/tests/pytest/client/alterDatabase.py new file mode 100644 index 0000000000..fa397d16c5 --- /dev/null +++ b/tests/pytest/client/alterDatabase.py @@ -0,0 +1,55 @@ +################################################################### +# 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 * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdSql.query('select database()') + tdSql.checkData(0, 0, "db") + + tdSql.execute("alter database db comp 2") + tdSql.query("show databases") + tdSql.checkData(0, 14, 2) + + tdSql.execute("alter database db keep 365") + tdSql.query("show databases") + tdSql.checkData(0, 7, "3650,3650,365") + + tdSql.execute("alter database db quorum 2") + tdSql.query("show databases") + tdSql.checkData(0, 5, 2) + + tdSql.execute("alter database db blocks 100") + tdSql.query("show databases") + tdSql.checkData(0, 9, 100) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +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 a73e7dd5a5..b679942054 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -164,6 +164,7 @@ python3 ./test.py -f alter/alter_table_crash.py # client python3 ./test.py -f client/client.py python3 ./test.py -f client/version.py +python3 ./test.py -f client/alterDatabase.py # Misc python3 testCompress.py From b694980d72a0098c55b0c565a06a5d5d0f3b99dd Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Thu, 24 Sep 2020 16:07:10 +0800 Subject: [PATCH 60/77] [TD-1583] add test case for this bug --- tests/pytest/query/queryNormal.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/pytest/query/queryNormal.py b/tests/pytest/query/queryNormal.py index 208ac54ecd..13393117d6 100644 --- a/tests/pytest/query/queryNormal.py +++ b/tests/pytest/query/queryNormal.py @@ -35,7 +35,8 @@ class TDTestCase: tdSql.execute( "insert into tb2 using stb1 tags(2,'tb2', '表2') values ('2020-04-18 15:00:02.000', 3, 2.1), ('2020-04-18 15:00:03.000', 4, 2.2)") - # inner join --- bug + tdSql.error("select * from tb 1") + tdSql.query("select * from tb1 a, tb2 b where a.ts = b.ts") tdSql.checkRows(0) From 4806e7bf3dd3b4e7d6ab92bdc111f8ce238c93c1 Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Thu, 24 Sep 2020 16:30:14 +0800 Subject: [PATCH 61/77] fix td-1488 --- src/client/inc/tsclient.h | 5 +++-- src/client/src/tscParseInsert.c | 3 +-- src/client/src/tscServer.c | 35 ++++++++++----------------------- src/client/src/tscUtil.c | 1 + 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 55ca02dfb5..500f784ec5 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -261,7 +261,7 @@ typedef struct { }; int32_t insertType; - int32_t clauseIndex; // index of multiple subclause query + int32_t clauseIndex; // index of multiple subclause query char * curSql; // current sql, resume position of sql after parsing paused int8_t parseFinished; @@ -276,7 +276,8 @@ typedef struct { int32_t numOfParams; int8_t dataSourceType; // load data from file or not - int8_t submitSchema; // submit block is built with table schema + int8_t submitSchema; // submit block is built with table schema + STagData tagData; SHashObj *pTableList; // referred table involved in sql SArray *pDataBlocks; // SArray submit data blocks after parsing sql } SSqlCmd; diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 6fd97c09e9..0480370dfa 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -791,7 +791,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) { sql += index; tscAllocPayload(pCmd, sizeof(STagData)); - STagData *pTag = (STagData *) pCmd->payload; + STagData *pTag = &pCmd->tagData; memset(pTag, 0, sizeof(STagData)); @@ -946,7 +946,6 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) { return tscSQLSyntaxErrMsg(pCmd->payload, ") expected", sToken.z); } - pCmd->payloadLen = sizeof(pTag->name) + sizeof(pTag->dataLen) + pTag->dataLen; pTag->dataLen = htonl(pTag->dataLen); if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) { diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 8eaa406bce..72fe64d4a4 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -1495,43 +1495,29 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) { - SCMTableInfoMsg *pInfoMsg; - char * pMsg; - int msgLen = 0; - - char *tmpData = NULL; - uint32_t len = pSql->cmd.payloadLen; - if (len > 0) { - if ((tmpData = calloc(1, len)) == NULL) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; - } - - // STagData is in binary format, strncpy is not available - memcpy(tmpData, pSql->cmd.payload, len); - } - SSqlCmd * pCmd = &pSql->cmd; SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - pInfoMsg = (SCMTableInfoMsg *)pCmd->payload; + SCMTableInfoMsg* pInfoMsg = (SCMTableInfoMsg *)pCmd->payload; strcpy(pInfoMsg->tableId, pTableMetaInfo->name); pInfoMsg->createFlag = htons(pSql->cmd.autoCreated ? 1 : 0); - pMsg = (char*)pInfoMsg + sizeof(SCMTableInfoMsg); + char* pMsg = (char*)pInfoMsg + sizeof(SCMTableInfoMsg); - if (pSql->cmd.autoCreated && len > 0) { - memcpy(pInfoMsg->tags, tmpData, len); - pMsg += len; + size_t len = htonl(pCmd->tagData.dataLen); + if (pSql->cmd.autoCreated) { + if (len > 0) { + len += sizeof(pCmd->tagData.name) + sizeof(pCmd->tagData.dataLen); + memcpy(pInfoMsg->tags, &pCmd->tagData, len); + pMsg += len; + } } pCmd->payloadLen = (int32_t)(pMsg - (char*)pInfoMsg); pCmd->msgType = TSDB_MSG_TYPE_CM_TABLE_META; - taosTFree(tmpData); - - assert(msgLen + minMsgSize() <= (int32_t)pCmd->allocSize); return TSDB_CODE_SUCCESS; } @@ -2192,8 +2178,7 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf assert(pNew->cmd.numOfClause == 1 && pNewQueryInfo->numOfTables == 1); tstrncpy(pNewMeterMetaInfo->name, pTableMetaInfo->name, sizeof(pNewMeterMetaInfo->name)); - memcpy(pNew->cmd.payload, pSql->cmd.payload, pSql->cmd.payloadLen); // tag information if table does not exists. - pNew->cmd.payloadLen = pSql->cmd.payloadLen; + memcpy(&pNew->cmd.tagData, &pSql->cmd.tagData, sizeof(pSql->cmd.tagData)); tscDebug("%p new pSqlObj:%p to get tableMeta, auto create:%d", pSql, pNew, pNew->cmd.autoCreated); pNew->fp = tscTableMetaCallBack; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 77088f5b7c..875411d9a3 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1794,6 +1794,7 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm pCmd->command = cmd; pCmd->parseFinished = 1; pCmd->autoCreated = pSql->cmd.autoCreated; + memcpy(&pCmd->tagData, &pSql->cmd.tagData, sizeof(pCmd->tagData)); if (tscAddSubqueryInfo(pCmd) != TSDB_CODE_SUCCESS) { tscFreeSqlObj(pNew); From afd549828ccb6a2fdc88276f9a01838c02187b8d Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Thu, 24 Sep 2020 17:51:44 +0800 Subject: [PATCH 62/77] fix some err --- tests/pytest/insert/retentionpolicy.py | 48 ++++++++++++++++---------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/tests/pytest/insert/retentionpolicy.py b/tests/pytest/insert/retentionpolicy.py index c50de31cc4..c69060b5ae 100644 --- a/tests/pytest/insert/retentionpolicy.py +++ b/tests/pytest/insert/retentionpolicy.py @@ -43,7 +43,8 @@ class TDTestRetetion: else: caller = inspect.getframeinfo(inspect.stack()[1][0]) args = (caller.filename, caller.lineno, sql, self.queryRows, expectRows) - os.system("timedatectl set-ntp true") + os.system("sudo timedatectl set-ntp true") + time.sleep(40) tdLog.exit("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) def run(self): @@ -53,7 +54,7 @@ class TDTestRetetion: tdSql.execute('use test;') tdSql.execute('create table test(ts timestamp,i int);') - cmd = 'insert into test values(now-2d,11)(now-1d,11)(now,11)(now+1d,11);' + cmd = 'insert into test values(now-2d,1)(now-1d,2)(now,3)(now+1d,4);' tdLog.info(cmd) tdSql.execute(cmd) tdSql.query('select * from test') @@ -61,46 +62,55 @@ class TDTestRetetion: tdLog.info("=============== step2") tdDnodes.stop(1) - os.system("timedatectl set-ntp false") - os.system("date -s $(date -d \"${DATE} 2 days\" \"+%Y%m%d\")") + os.system("sudo timedatectl set-ntp false") + os.system("sudo date -s $(date -d \"${DATE} 2 days\" \"+%Y%m%d\")") tdDnodes.start(1) - cmd = 'insert into test values(now,11);' + cmd = 'insert into test values(now,5);' + tdDnodes.stop(1) + tdDnodes.start(1) + tdLog.info(cmd) tdSql.execute(cmd) - queryRows=tdSql.query('select * from test') - if queryRows==4: - tdSql.checkRows(4) + self.queryRows=tdSql.query('select * from test') + if self.queryRows==4: + self.checkRows(4,cmd) return 0 else: - tdSql.checkRows(5) - + self.checkRows(5,cmd) tdLog.info("=============== step3") tdDnodes.stop(1) - os.system("date -s $(date -d \"${DATE} 2 days\" \"+%Y%m%d\")") + os.system("sudo date -s $(date -d \"${DATE} 2 days\" \"+%Y%m%d\")") tdDnodes.start(1) - cmd = 'insert into test values(now-1d,11);' tdLog.info(cmd) tdSql.execute(cmd) - queryRows=tdSql.query('select * from test') - tdSql.checkRows(6) + self.queryRows=tdSql.query('select * from test') + if self.queryRows==4: + self.checkRows(4,cmd) + return 0 + cmd = 'insert into test values(now-1d,6);' + tdLog.info(cmd) + tdSql.execute(cmd) + self.queryRows=tdSql.query('select * from test') + self.checkRows(6,cmd) tdLog.info("=============== step4") tdDnodes.stop(1) tdDnodes.start(1) - cmd = 'insert into test values(now,11);' + cmd = 'insert into test values(now,7);' tdLog.info(cmd) tdSql.execute(cmd) - tdSql.query('select * from test') - tdSql.checkRows(7) + self.queryRows=tdSql.query('select * from test') + self.checkRows(7,cmd) tdLog.info("=============== step5") tdDnodes.stop(1) tdDnodes.start(1) cmd='select * from test where ts > now-1d' - queryRows=tdSql.query('select * from test where ts > now-1d') + self.queryRows=tdSql.query('select * from test where ts > now-1d') self.checkRows(1,cmd) def stop(self): - os.system("timedatectl set-ntp true") + os.system("sudo timedatectl set-ntp true") + time.sleep(40) tdSql.close() tdLog.success("%s successfully executed" % __file__) From f39cd1bf1e4036714811205b47be29d5a1e3e7c0 Mon Sep 17 00:00:00 2001 From: elvizlai Date: Fri, 25 Sep 2020 10:09:50 +0800 Subject: [PATCH 63/77] typo: fix chinese semicolon --- .../webdocs/markdowndocs/advanced features-ch.md | 10 +++++----- .../webdocs/markdowndocs/architecture-ch.md | 4 ++-- documentation20/webdocs/markdowndocs/cluster-ch.md | 6 +++--- documentation20/webdocs/markdowndocs/cluster.md | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/documentation20/webdocs/markdowndocs/advanced features-ch.md b/documentation20/webdocs/markdowndocs/advanced features-ch.md index b1d050c8cc..ed02af25f2 100644 --- a/documentation20/webdocs/markdowndocs/advanced features-ch.md +++ b/documentation20/webdocs/markdowndocs/advanced features-ch.md @@ -39,7 +39,7 @@ create table D1002 using meters tags ("Beijing.Haidian", 2); 我们已经知道,可以通过下面这条SQL语句以一分钟为时间窗口、30秒为前向增量统计这些电表的平均电压。 ```sql -select avg(voltage) from meters interval(1m) sliding(30s); +select avg(voltage) from meters interval(1m) sliding(30s); ``` 每次执行这条语句,都会重新计算所有数据。 @@ -47,14 +47,14 @@ select avg(voltage) from meters interval(1m) sliding(30s); 可以把上面的语句改进成下面的样子,每次使用不同的 `startTime` 并定期执行: ```sql -select avg(voltage) from meters where ts > {startTime} interval(1m) sliding(30s); +select avg(voltage) from meters where ts > {startTime} interval(1m) sliding(30s); ``` 这样做没有问题,但TDengine提供了更简单的方法, 只要在最初的查询语句前面加上 `create table {tableName} as ` 就可以了, 例如: ```sql -create table avg_vol as select avg(voltage) from meters interval(1m) sliding(30s); +create table avg_vol as select avg(voltage) from meters interval(1m) sliding(30s); ``` 会自动创建一个名为 `avg_vol` 的新表,然后每隔30秒,TDengine会增量执行 `as` 后面的 SQL 语句, @@ -80,7 +80,7 @@ taos> select * from avg_vol; 比如使用下面的SQL创建的连续查询将运行一小时,之后会自动停止。 ```sql -create table avg_vol as select avg(voltage) from meters where ts > now and ts <= now + 1h interval(1m) sliding(30s); +create table avg_vol as select avg(voltage) from meters where ts > now and ts <= now + 1h interval(1m) sliding(30s); ``` 需要说明的是,上面例子中的 `now` 是指创建连续查询的时间,而不是查询执行的时间,否则,查询就无法自动停止了。 @@ -396,7 +396,7 @@ ts: 1597465200000 current: 11.2 voltage: 220 phase: 1 location: Beijing.Haidian ```sql # taos -taos> use power; +taos> use power; taos> insert into d1001 values("2020-08-15 12:40:00.000", 12.4, 220, 1); ``` diff --git a/documentation20/webdocs/markdowndocs/architecture-ch.md b/documentation20/webdocs/markdowndocs/architecture-ch.md index 460e655f5f..7dfff1f21f 100644 --- a/documentation20/webdocs/markdowndocs/architecture-ch.md +++ b/documentation20/webdocs/markdowndocs/architecture-ch.md @@ -276,14 +276,14 @@ SQL语句的解析和校验工作在客户端完成。解析SQL语句并生成 在TDengine中引入关键词interval来进行时间轴上固定长度时间窗口的切分,并按照时间窗口对数据进行聚合,对窗口范围内的数据按需进行聚合。例如: ```mysql -select count(*) from d1001 interval(1h); +select count(*) from d1001 interval(1h); ``` 针对d1001设备采集的数据,按照1小时的时间窗口返回每小时存储的记录数量。 在需要连续获得查询结果的应用场景下,如果给定的时间区间存在数据缺失,会导致该区间数据结果也丢失。TDengine提供策略针对时间轴聚合计算的结果进行插值,通过使用关键词Fill就能够对时间轴聚合结果进行插值。例如: ```mysql -select count(*) from d1001 interval(1h) fill(prev); +select count(*) from d1001 interval(1h) fill(prev); ``` 针对d1001设备采集数据统计每小时记录数,如果某一个小时不存在数据,这返回之前一个小时的统计数据。TDengine提供前向插值(prev)、线性插值(linear)、NULL值填充(NULL)、特定值填充(value)。 diff --git a/documentation20/webdocs/markdowndocs/cluster-ch.md b/documentation20/webdocs/markdowndocs/cluster-ch.md index c36819e5c7..13b773b3e3 100644 --- a/documentation20/webdocs/markdowndocs/cluster-ch.md +++ b/documentation20/webdocs/markdowndocs/cluster-ch.md @@ -89,7 +89,7 @@ taos> 2. 在第一个数据节点,使用CLI程序taos, 登录进TDengine系统, 执行命令: ``` - CREATE DNODE "h2.taos.com:6030"; + CREATE DNODE "h2.taos.com:6030"; ``` 将新数据节点的End Point (准备工作中第四步获知的) 添加进集群的EP列表。**"fqdn:port"需要用双引号引起来**,否则出错。请注意将示例的“h2.taos.com:6030" 替换为这个新数据节点的End Point。 @@ -97,7 +97,7 @@ taos> 3. 然后执行命令 ``` - SHOW DNODES; + SHOW DNODES; ``` 查看新节点是否被成功加入。如果该被加入的数据节点处于离线状态,请做两个检查 @@ -122,7 +122,7 @@ taos> 执行CLI程序taos, 使用root账号登录进系统, 执行: ``` -CREATE DNODE "fqdn:port"; +CREATE DNODE "fqdn:port"; ``` 将新数据节点的End Point添加进集群的EP列表。**"fqdn:port"需要用双引号引起来**,否则出错。一个数据节点对外服务的fqdn和port可以通过配置文件taos.cfg进行配置,缺省是自动获取。【强烈不建议用自动获取方式来配置FQDN,可能导致生成的数据节点的End Point不是所期望的】 diff --git a/documentation20/webdocs/markdowndocs/cluster.md b/documentation20/webdocs/markdowndocs/cluster.md index 43b35dbc66..f5fa6af48c 100644 --- a/documentation20/webdocs/markdowndocs/cluster.md +++ b/documentation20/webdocs/markdowndocs/cluster.md @@ -46,7 +46,7 @@ taos> 5. 在第一个节点,使用CLI程序taos, 登录进TDengine系统, 使用命令: ``` - CREATE DNODE "h2.taos.com:6030"; + CREATE DNODE "h2.taos.com:6030"; ``` 将新节点的End Point添加进集群的EP列表。**"fqdn:port"需要用双引号引起来**,否则出错。请注意将示例的“h2.taos.com:6030" 替换为你自己第一个节点的End Point @@ -54,7 +54,7 @@ taos> 6. 使用命令 ``` - SHOW DNODES; + SHOW DNODES; ``` 查看新节点是否被成功加入。 @@ -71,7 +71,7 @@ taos> ###添加节点 执行CLI程序taos, 使用root账号登录进系统, 执行: ``` -CREATE DNODE "fqdn:port"; +CREATE DNODE "fqdn:port"; ``` 将新节点的End Point添加进集群的EP列表。**"fqdn:port"需要用双引号引起来**,否则出错。一个节点对外服务的fqdn和port可以通过配置文件taos.cfg进行配置,缺省是自动获取。 From a5a4f7026f8f3bd81e76ac691a6a8ccb3e84eada Mon Sep 17 00:00:00 2001 From: zyyang Date: Fri, 25 Sep 2020 10:26:58 +0800 Subject: [PATCH 64/77] update jdbcTaosdemo --- tests/examples/JDBC/JDBCDemo/.gitignore | 21 +++++++- tests/examples/JDBC/JDBCDemo/pom.xml | 2 +- .../example/JDBCConnectorChecker.java | 1 - .../{ => jdbcTaosdemo}/JdbcTaosdemo.java | 48 +++++++++---------- .../domain/JdbcTaosdemoConfig.java | 27 +++++++---- .../task/CreateTableTask.java | 6 +-- .../task/InsertTableDatetimeTask.java | 13 +++-- .../task/InsertTableTask.java | 8 ++-- .../utils/TimeStampUtil.java | 2 +- .../src/main/resources/log4j.properties | 11 +++-- 10 files changed, 85 insertions(+), 54 deletions(-) rename tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/{ => jdbcTaosdemo}/JdbcTaosdemo.java (84%) rename tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/{ => jdbcTaosdemo}/domain/JdbcTaosdemoConfig.java (78%) rename tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/{ => jdbcTaosdemo}/task/CreateTableTask.java (89%) rename tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/{ => jdbcTaosdemo}/task/InsertTableDatetimeTask.java (79%) rename tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/{ => jdbcTaosdemo}/task/InsertTableTask.java (84%) rename tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/{ => jdbcTaosdemo}/utils/TimeStampUtil.java (95%) diff --git a/tests/examples/JDBC/JDBCDemo/.gitignore b/tests/examples/JDBC/JDBCDemo/.gitignore index d587e5fe38..b79f223d17 100644 --- a/tests/examples/JDBC/JDBCDemo/.gitignore +++ b/tests/examples/JDBC/JDBCDemo/.gitignore @@ -1,2 +1,19 @@ -out/ -logs/ +# custom +/out/ +/logs/ +*.jar + +# Created by .ignore support plugin (hsz.mobi) +.gitignore + +# Build Artifacts +.gradle/* +build/* +target/* +bin/* +dependency-reduced-pom.xml + +# Eclipse Project Files +.classpath +.project +.settings/* diff --git a/tests/examples/JDBC/JDBCDemo/pom.xml b/tests/examples/JDBC/JDBCDemo/pom.xml index f3a31d08a0..2113074674 100644 --- a/tests/examples/JDBC/JDBCDemo/pom.xml +++ b/tests/examples/JDBC/JDBCDemo/pom.xml @@ -63,7 +63,7 @@ com.taosdata.jdbc taos-jdbcdriver - 2.0.6 + 2.0.4 log4j diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCConnectorChecker.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCConnectorChecker.java index 1e801bc658..24a4b3a77e 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCConnectorChecker.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCConnectorChecker.java @@ -11,7 +11,6 @@ public class JDBCConnectorChecker { private static String tbName = "weather"; private Connection connection; - /** * get connection **/ diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcTaosdemo.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java similarity index 84% rename from tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcTaosdemo.java rename to tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java index 461a639682..874f950132 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcTaosdemo.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java @@ -1,10 +1,10 @@ -package com.taosdata.example; +package com.taosdata.example.jdbcTaosdemo; -import com.taosdata.example.domain.JdbcTaosdemoConfig; -import com.taosdata.example.task.CreateTableTask; -import com.taosdata.example.task.InsertTableDatetimeTask; -import com.taosdata.example.task.InsertTableTask; -import com.taosdata.example.utils.TimeStampUtil; +import com.taosdata.example.jdbcTaosdemo.domain.JdbcTaosdemoConfig; +import com.taosdata.example.jdbcTaosdemo.task.CreateTableTask; +import com.taosdata.example.jdbcTaosdemo.task.InsertTableDatetimeTask; +import com.taosdata.example.jdbcTaosdemo.task.InsertTableTask; +import com.taosdata.example.jdbcTaosdemo.utils.TimeStampUtil; import com.taosdata.jdbc.TSDBDriver; import org.apache.log4j.Logger; @@ -25,34 +25,20 @@ public class JdbcTaosdemo { this.config = config; } - private static void printHelp() { - System.out.println("Usage: java -jar JDBCConnectorChecker.jar -h host [OPTION...]"); - System.out.println("-p port The TCP/IP port number to use for the connection. Default is 6030"); - System.out.println("-u user The TDengine user name to use when connecting to the server. Default is 'root'"); - System.out.println("-P password The password to use when connecting to the server.Default is 'taosdata'"); - System.out.println("-d database Destination database. Default is 'test'"); - System.out.println("-m tablePrefix Table prefix name. Default is 'd'"); - System.out.println("-T num_of_threads The number of threads. Default is 10"); - System.out.println("-t num_of_tables The number of tables. Default is 10000"); - System.out.println("-n num_of_records_per_table The number of records per table. Default is 100000"); - System.out.println("-D delete table Delete data methods. Default is false"); - System.out.println("--help Give this help list"); - } public static void main(String[] args) { JdbcTaosdemoConfig config = JdbcTaosdemoConfig.build(args); boolean isHelp = Arrays.asList(args).contains("--help"); if (isHelp) { - printHelp(); + JdbcTaosdemoConfig.printHelp(); return; } if (config.getHost() == null) { - printHelp(); + JdbcTaosdemoConfig.printHelp(); return; } - boolean infinite = Arrays.asList().contains("--infinite"); JdbcTaosdemo taosdemo = new JdbcTaosdemo(config); taosdemo.init(); taosdemo.dropDatabase(); @@ -60,7 +46,10 @@ public class JdbcTaosdemo { taosdemo.useDatabase(); taosdemo.createSuperTable(); taosdemo.createTableMultiThreads(); + + boolean infinite = Arrays.asList(args).contains("--infinite"); if (infinite) { + logger.info("!!! Infinite Insert Mode Started. !!!!"); taosdemo.insertInfinite(); } else { taosdemo.insertMultiThreads(); @@ -206,6 +195,17 @@ public class JdbcTaosdemo { return sql; } + public static String batchInsertSql(int tableIndex, long ts, int valueCnt, JdbcTaosdemoConfig config) { + float current = 10 + random.nextFloat(); + int voltage = 200 + random.nextInt(20); + float phase = random.nextFloat(); + StringBuilder sb = new StringBuilder(); + sb.append("insert into " + config.getDbName() + "." + config.getTbPrefix() + "" + tableIndex + " " + "values"); + for (int i = 0; i < valueCnt; i++) { + sb.append("(" + (ts + i) + ", " + current + ", " + voltage + ", " + phase + ") "); + } + return sb.toString(); + } public static String createTableSql(int tableIndex, JdbcTaosdemoConfig config) { String location = locations[random.nextInt(locations.length)]; @@ -252,7 +252,7 @@ public class JdbcTaosdemo { } } - private void printSql(String sql, boolean succeed, long cost) { + private static void printSql(String sql, boolean succeed, long cost) { logger.info("[ " + (succeed ? "OK" : "ERROR!") + " ] time cost: " + cost + " ms, execute statement ====> " + sql); } @@ -269,7 +269,7 @@ public class JdbcTaosdemo { } } - private void printResult(ResultSet resultSet) throws SQLException { + private static void printResult(ResultSet resultSet) throws SQLException { ResultSetMetaData metaData = resultSet.getMetaData(); while (resultSet.next()) { StringBuilder sb = new StringBuilder(); diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/domain/JdbcTaosdemoConfig.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java similarity index 78% rename from tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/domain/JdbcTaosdemoConfig.java rename to tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java index efaddbfa0d..ef0f7bef12 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/domain/JdbcTaosdemoConfig.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java @@ -1,4 +1,4 @@ -package com.taosdata.example.domain; +package com.taosdata.example.jdbcTaosdemo.domain; public class JdbcTaosdemoConfig { @@ -12,16 +12,12 @@ public class JdbcTaosdemoConfig { private String password = "taosdata"; //Destination database. Default is 'test' private String dbName = "test"; - - // + //keep private int keep = 365 * 20; - + // private int days = 30; - //Super table Name. Default is 'meters' private String stbName = "meters"; - - //Table name prefix. Default is 'd' private String tbPrefix = "d"; //The number of threads. Default is 10. @@ -33,6 +29,20 @@ public class JdbcTaosdemoConfig { //Delete data. Default is false private boolean deleteTable = true; + public static void printHelp() { + System.out.println("Usage: java -jar JDBCConnectorChecker.jar -h host [OPTION...]"); + System.out.println("-p port The TCP/IP port number to use for the connection. Default is 6030"); + System.out.println("-u user The TDengine user name to use when connecting to the server. Default is 'root'"); + System.out.println("-P password The password to use when connecting to the server.Default is 'taosdata'"); + System.out.println("-d database Destination database. Default is 'test'"); + System.out.println("-m tablePrefix Table prefix name. Default is 'd'"); + System.out.println("-T num_of_threads The number of threads. Default is 10"); + System.out.println("-t num_of_tables The number of tables. Default is 10000"); + System.out.println("-n num_of_records_per_table The number of records per table. Default is 100000"); + System.out.println("-D delete table Delete data methods. Default is false"); + System.out.println("--help Give this help list"); + } + /** * parse args from command line * @@ -40,6 +50,7 @@ public class JdbcTaosdemoConfig { * @return JdbcTaosdemoConfig */ public static JdbcTaosdemoConfig build(String[] args) { + JdbcTaosdemoConfig config = new JdbcTaosdemoConfig(); for (int i = 0; i < args.length; i++) { if ("-h".equals(args[i]) && i < args.length - 1) { @@ -72,8 +83,8 @@ public class JdbcTaosdemoConfig { if ("-D".equals(args[i]) && i < args.length - 1) { config.setDeleteTable(Boolean.parseBoolean(args[++i])); } - } + return config; } diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/CreateTableTask.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/CreateTableTask.java similarity index 89% rename from tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/CreateTableTask.java rename to tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/CreateTableTask.java index 167dbdb648..2b1a08ab40 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/CreateTableTask.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/CreateTableTask.java @@ -1,7 +1,7 @@ -package com.taosdata.example.task; +package com.taosdata.example.jdbcTaosdemo.task; -import com.taosdata.example.JdbcTaosdemo; -import com.taosdata.example.domain.JdbcTaosdemoConfig; +import com.taosdata.example.jdbcTaosdemo.JdbcTaosdemo; +import com.taosdata.example.jdbcTaosdemo.domain.JdbcTaosdemoConfig; import org.apache.log4j.Logger; import java.sql.Connection; diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/InsertTableDatetimeTask.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableDatetimeTask.java similarity index 79% rename from tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/InsertTableDatetimeTask.java rename to tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableDatetimeTask.java index a54f73a258..d477ceeaed 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/InsertTableDatetimeTask.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableDatetimeTask.java @@ -1,7 +1,7 @@ -package com.taosdata.example.task; +package com.taosdata.example.jdbcTaosdemo.task; -import com.taosdata.example.JdbcTaosdemo; -import com.taosdata.example.domain.JdbcTaosdemoConfig; +import com.taosdata.example.jdbcTaosdemo.JdbcTaosdemo; +import com.taosdata.example.jdbcTaosdemo.domain.JdbcTaosdemoConfig; import org.apache.log4j.Logger; import java.sql.Connection; @@ -29,9 +29,12 @@ public class InsertTableDatetimeTask implements Runnable { public void run() { try { Connection connection = JdbcTaosdemo.getConnection(config); - for (long ts = startDatetime; ts < finishedDatetime; ts++) { + int valueCnt = 100; + for (long ts = startDatetime; ts < finishedDatetime; ts+= valueCnt) { for (int i = startTableIndex; i < startTableIndex + tableNumber; i++) { - String sql = JdbcTaosdemo.insertSql(i + 1, ts, config); +// String sql = JdbcTaosdemo.insertSql(i + 1, ts, config); + + String sql = JdbcTaosdemo.batchInsertSql(i + 1, ts, valueCnt, config); Statement statement = connection.createStatement(); statement.execute(sql); statement.close(); diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/InsertTableTask.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java similarity index 84% rename from tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/InsertTableTask.java rename to tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java index 88f65f739d..9ae50d830e 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/task/InsertTableTask.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java @@ -1,7 +1,7 @@ -package com.taosdata.example.task; +package com.taosdata.example.jdbcTaosdemo.task; -import com.taosdata.example.JdbcTaosdemo; -import com.taosdata.example.domain.JdbcTaosdemoConfig; +import com.taosdata.example.jdbcTaosdemo.JdbcTaosdemo; +import com.taosdata.example.jdbcTaosdemo.domain.JdbcTaosdemoConfig; import org.apache.log4j.Logger; import java.sql.Connection; @@ -9,7 +9,7 @@ import java.sql.SQLException; import java.sql.Statement; public class InsertTableTask implements Runnable { - private static Logger logger = Logger.getLogger(InsertTableTask.class); + private static final Logger logger = Logger.getLogger(InsertTableTask.class); private final JdbcTaosdemoConfig config; private final int startIndex; diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/utils/TimeStampUtil.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/TimeStampUtil.java similarity index 95% rename from tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/utils/TimeStampUtil.java rename to tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/TimeStampUtil.java index 2ec91ef1cb..d00471f581 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/utils/TimeStampUtil.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/TimeStampUtil.java @@ -1,4 +1,4 @@ -package com.taosdata.example.utils; +package com.taosdata.example.jdbcTaosdemo.utils; import java.sql.Date; import java.text.ParseException; diff --git a/tests/examples/JDBC/JDBCDemo/src/main/resources/log4j.properties b/tests/examples/JDBC/JDBCDemo/src/main/resources/log4j.properties index b445e5f52e..0ed95d04d3 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/resources/log4j.properties +++ b/tests/examples/JDBC/JDBCDemo/src/main/resources/log4j.properties @@ -1,10 +1,11 @@ ### 设置### -log4j.rootLogger=debug,stdout,DebugLog,ErrorLog +#log4j.rootLogger=debug,stdout,DebugLog,ErrorLog +log4j.rootLogger=debug,DebugLog,ErrorLog ### 输出信息到控制抬 ### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n +#log4j.appender.stdout=org.apache.log4j.ConsoleAppender +#log4j.appender.stdout.Target=System.out +#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +#log4j.appender.stdout.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n ### 输出DEBUG 级别以上的日志到=logs/error.log ### log4j.appender.DebugLog=org.apache.log4j.DailyRollingFileAppender log4j.appender.DebugLog.File=logs/debug.log From e74edd3d04462db4acc1ce907876b05d2699b8e6 Mon Sep 17 00:00:00 2001 From: Hui Li Date: Fri, 25 Sep 2020 10:34:49 +0800 Subject: [PATCH 65/77] [TD-1504] --- src/connector/go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connector/go b/src/connector/go index 06ec30a0f1..8d7bf74385 160000 --- a/src/connector/go +++ b/src/connector/go @@ -1 +1 @@ -Subproject commit 06ec30a0f1762e8169bf6b9045c82bcaa52bcdf0 +Subproject commit 8d7bf743852897110cbdcc7c4322cd7a74d4167b From c35887815bc01d3f59033067929363e444d3ee80 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Fri, 25 Sep 2020 11:47:26 +0800 Subject: [PATCH 66/77] Support custom IP --- tests/examples/python/read_example.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/examples/python/read_example.py b/tests/examples/python/read_example.py index dd1475ec14..73052ab2df 100644 --- a/tests/examples/python/read_example.py +++ b/tests/examples/python/read_example.py @@ -22,8 +22,12 @@ if __name__ == '__main__': # @password : Password # @database : Database to use when connecting to TDengine server # @config : Configuration directory - conn = taos.connect(host="127.0.0.1", user="root", password="taosdata", config="/etc/taos") - + if len(sys.argv)>1: + hostname=sys.argv[1] + conn = taos.connect(host=hostname, user="root", password="taosdata", config="/etc/taos") + else: + conn = taos.connect(host="127.0.0.1", user="root", password="taosdata", config="/etc/taos") + # Generate a cursor object to run SQL commands c1 = conn.cursor() # Create a database named db From d3d4691c946d0823cf36a11a7d95e86a7b650354 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 25 Sep 2020 14:36:20 +0800 Subject: [PATCH 67/77] TD-1550 --- src/tsdb/src/tsdbMemTable.c | 2 + tests/test/c/CMakeLists.txt | 12 +++--- tests/test/c/importPerTable.c | 73 +++++++++++++++++++++++------------ 3 files changed, 57 insertions(+), 30 deletions(-) diff --git a/src/tsdb/src/tsdbMemTable.c b/src/tsdb/src/tsdbMemTable.c index f6a7f1b35c..4cf8ddd4bd 100644 --- a/src/tsdb/src/tsdbMemTable.c +++ b/src/tsdb/src/tsdbMemTable.c @@ -262,7 +262,9 @@ int tsdbAsyncCommit(STsdbRepo *pRepo) { if (pIMem != NULL) { ASSERT(pRepo->commit); + tsdbDebug("vgId:%d waiting for the commit thread", REPO_ID(pRepo)); code = pthread_join(pRepo->commitThread, NULL); + tsdbDebug("vgId:%d commit thread is finished", REPO_ID(pRepo)); if (code != 0) { tsdbError("vgId:%d failed to thread join since %s", REPO_ID(pRepo), strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); diff --git a/tests/test/c/CMakeLists.txt b/tests/test/c/CMakeLists.txt index ffab39d41c..a4eb0b13a6 100644 --- a/tests/test/c/CMakeLists.txt +++ b/tests/test/c/CMakeLists.txt @@ -22,8 +22,8 @@ IF (TD_LINUX) #add_executable(importOneRow importOneRow.c) #target_link_libraries(importOneRow taos_static pthread) - #add_executable(importPerTable importPerTable.c) - #target_link_libraries(importPerTable taos_static pthread) + add_executable(importPerTable importPerTable.c) + target_link_libraries(importPerTable taos_static pthread) #add_executable(hashPerformance hashPerformance.c) #target_link_libraries(hashPerformance taos_static tutil common pthread) @@ -37,10 +37,10 @@ IF (TD_LINUX) #add_executable(queryPerformance queryPerformance.c) #target_link_libraries(queryPerformance taos_static tutil common pthread) - add_executable(httpTest httpTest.c) - target_link_libraries(httpTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) + #add_executable(httpTest httpTest.c) + #target_link_libraries(httpTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) - add_executable(cacheTest cacheTest.c) - target_link_libraries(cacheTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) + #add_executable(cacheTest cacheTest.c) + #target_link_libraries(cacheTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) ENDIF() diff --git a/tests/test/c/importPerTable.c b/tests/test/c/importPerTable.c index b4e8b68703..68f7898050 100644 --- a/tests/test/c/importPerTable.c +++ b/tests/test/c/importPerTable.c @@ -20,6 +20,7 @@ #include "ttimer.h" #include "tutil.h" #include "tglobal.h" +#include "osTime.h" #define MAX_RANDOM_POINTS 20000 #define GREEN "\033[1;32m" @@ -43,14 +44,16 @@ void createDbAndTable(); void insertData(); int32_t randomData[MAX_RANDOM_POINTS]; -int64_t rowsPerTable = 10000; +int64_t rowsPerTable = 1000000; int64_t pointsPerTable = 1; -int64_t numOfThreads = 1; -int64_t numOfTablesPerThread = 1; +int64_t numOfThreads = 10; +int64_t numOfTablesPerThread = 100; char dbName[32] = "db"; char stableName[64] = "st"; -int32_t cache = 16384; -int32_t tables = 1000; +int64_t totalUs = 0; +int64_t reqNum = 0; +int64_t maxUs = 0; +int64_t minUs = 100000000; int main(int argc, char *argv[]) { shellParseArgument(argc, argv); @@ -58,6 +61,38 @@ int main(int argc, char *argv[]) { taos_init(); createDbAndTable(); insertData(); + int64_t avgUs = totalUs / reqNum; + pError("%s totalUs:%ld, avgUs:%ld maxUs:%ld minUs:%ld reqNum:%ld %s\n", GREEN, totalUs, avgUs, maxUs, minUs, reqNum, NC); +} + +int32_t query(void *con, char *qstr) { + int64_t begin = taosGetTimestampUs(); + + TAOS_RES *pSql = taos_query(con, qstr); + int32_t code = taos_errno(pSql); + if (code != 0) { + pError("failed to exec sql:%s, code:%d reason:%s", qstr, taos_errno(con), taos_errstr(con)); + exit(0); + } + taos_free_result(pSql); + + int64_t us = taosGetTimestampUs() - begin; + maxUs = MAX(us, maxUs); + minUs = MIN(us, minUs); + atomic_add_fetch_64(&totalUs, us); + atomic_add_fetch_64(&reqNum, 1); + if (reqNum > 100000) { + int64_t avgUs = totalUs / reqNum; + if (us > avgUs * 100) { + pError("sql:%s", qstr); + pError("%s totalUs:%ld, avgUs:%ld maxUs:%ld minUs:%ld reqNum:%ld %s\n", GREEN, totalUs, avgUs, maxUs, minUs, + reqNum, NC); + taosMsleep(1000); + exit(0); + } + } + + return code; } void createDbAndTable() { @@ -79,14 +114,14 @@ void createDbAndTable() { exit(1); } - sprintf(qstr, "create database if not exists %s cache %d tables %d", dbName, cache, tables); - if (taos_query(con, qstr)) { + sprintf(qstr, "create database if not exists %s", dbName); + if (query(con, qstr)) { pError("failed to create database:%s, code:%d reason:%s", dbName, taos_errno(con), taos_errstr(con)); exit(0); } sprintf(qstr, "use %s", dbName); - if (taos_query(con, qstr)) { + if (query(con, qstr)) { pError("failed to use db, code:%d reason:%s", taos_errno(con), taos_errstr(con)); exit(0); } @@ -102,14 +137,14 @@ void createDbAndTable() { } sprintf(qstr + len, ") tags(t int)"); - if (taos_query(con, qstr)) { + if (query(con, qstr)) { pError("failed to create stable, code:%d reason:%s", taos_errno(con), taos_errstr(con)); exit(0); } for (int64_t t = 0; t < totalTables; ++t) { sprintf(qstr, "create table if not exists %s%ld using %s tags(%ld)", stableName, t, stableName, t); - if (taos_query(con, qstr)) { + if (query(con, qstr)) { pError("failed to create table %s%" PRId64 ", reason:%s", stableName, t, taos_errstr(con)); exit(0); } @@ -122,7 +157,7 @@ void createDbAndTable() { } sprintf(qstr + len, ")"); - if (taos_query(con, qstr)) { + if (query(con, qstr)) { pError("failed to create table %s%ld, reason:%s", stableName, t, taos_errstr(con)); exit(0); } @@ -207,7 +242,7 @@ void *syncTest(void *param) { } sprintf(qstr, "use %s", pInfo->dbName); - taos_query(con, qstr); + query(con, qstr); gettimeofday(&systemTime, NULL); st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; @@ -229,7 +264,7 @@ void *syncTest(void *param) { } len += sprintf(sql + len, ")"); if (len > maxBytes) { - if (taos_query(con, qstr)) { + if (query(con, qstr)) { pError("thread:%d, failed to import table:%s%ld row:%ld, reason:%s", pInfo->threadIndex, pInfo->stableName, table, row, taos_errstr(con)); } @@ -246,7 +281,7 @@ void *syncTest(void *param) { } if (len != strlen(inserStr)) { - taos_query(con, qstr); + query(con, qstr); } gettimeofday(&systemTime, NULL); @@ -284,10 +319,6 @@ void printHelp() { printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of threads to be used, default is ", numOfThreads); printf("%s%s\n", indent, "-n"); printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of tables per thread, default is ", numOfTablesPerThread); - printf("%s%s\n", indent, "-tables"); - printf("%s%s%s%d\n", indent, indent, "Database parameters tables, default is ", tables); - printf("%s%s\n", indent, "-cache"); - printf("%s%s%s%d\n", indent, indent, "Database parameters cache, default is ", cache); exit(EXIT_SUCCESS); } @@ -311,10 +342,6 @@ void shellParseArgument(int argc, char *argv[]) { numOfThreads = atoi(argv[++i]); } else if (strcmp(argv[i], "-n") == 0) { numOfTablesPerThread = atoi(argv[++i]); - } else if (strcmp(argv[i], "-tables") == 0) { - tables = atoi(argv[++i]); - } else if (strcmp(argv[i], "-cache") == 0) { - cache = atoi(argv[++i]); } else { } } @@ -323,8 +350,6 @@ void shellParseArgument(int argc, char *argv[]) { pPrint("%spointsPerTable:%" PRId64 "%s", GREEN, pointsPerTable, NC); pPrint("%snumOfThreads:%" PRId64 "%s", GREEN, numOfThreads, NC); pPrint("%snumOfTablesPerThread:%" PRId64 "%s", GREEN, numOfTablesPerThread, NC); - pPrint("%scache:%d%s", GREEN, cache, NC); - pPrint("%stables:%d%s", GREEN, tables, NC); pPrint("%sdbName:%s%s", GREEN, dbName, NC); pPrint("%stableName:%s%s", GREEN, stableName, NC); pPrint("%sstart to run%s", GREEN, NC); From 9431641ff1c9343aa543019d7bd6c8c486404210 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 25 Sep 2020 07:05:49 +0000 Subject: [PATCH 68/77] minor changes --- src/rpc/src/rpcMain.c | 6 +++--- src/rpc/src/rpcTcp.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index cb318d5c24..50b1507a56 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -323,14 +323,14 @@ void *rpcMallocCont(int contLen) { tError("failed to malloc msg, size:%d", size); return NULL; } else { - tDebug("malloc mem: %p", start); + tDebug("malloc msg: %p", start); } return start + sizeof(SRpcReqContext) + sizeof(SRpcHead); } void rpcFreeCont(void *cont) { - if ( cont ) { + if (cont) { char *temp = ((char *)cont) - sizeof(SRpcHead) - sizeof(SRpcReqContext); free(temp); tDebug("free mem: %p", temp); @@ -553,7 +553,7 @@ static void rpcFreeMsg(void *msg) { if ( msg ) { char *temp = (char *)msg - sizeof(SRpcReqContext); free(temp); - tDebug("free mem: %p", temp); + tDebug("free msg: %p", temp); } } diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index 56b3fa8616..2a3facdb36 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -421,7 +421,7 @@ static int taosReadTcpData(SFdObj *pFdObj, SRecvInfo *pInfo) { msgLen = (int32_t)htonl((uint32_t)rpcHead.msgLen); buffer = malloc(msgLen + tsRpcOverhead); - if ( NULL == buffer) { + if (NULL == buffer) { tError("%s %p TCP malloc(size:%d) fail", pThreadObj->label, pFdObj->thandle, msgLen); return -1; } else { From 5ec266098f6bb25720bd94a1bd1782c3ec97cae3 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 25 Sep 2020 07:10:07 +0000 Subject: [PATCH 69/77] minor changes --- tests/test/c/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test/c/CMakeLists.txt b/tests/test/c/CMakeLists.txt index 4ff1947aee..befaec60a6 100644 --- a/tests/test/c/CMakeLists.txt +++ b/tests/test/c/CMakeLists.txt @@ -22,8 +22,8 @@ IF (TD_LINUX) #add_executable(importOneRow importOneRow.c) #target_link_libraries(importOneRow taos_static pthread) - add_executable(importPerTable importPerTable.c) - target_link_libraries(importPerTable taos_static pthread) + #add_executable(importPerTable importPerTable.c) + #target_link_libraries(importPerTable taos_static pthread) #add_executable(hashPerformance hashPerformance.c) #target_link_libraries(hashPerformance taos_static tutil common pthread) @@ -31,8 +31,8 @@ IF (TD_LINUX) #add_executable(createTablePerformance createTablePerformance.c) #target_link_libraries(createTablePerformance taos_static tutil common pthread) - add_executable(createNormalTable createNormalTable.c) - target_link_libraries(createNormalTable taos_static tutil common pthread) + #add_executable(createNormalTable createNormalTable.c) + #target_link_libraries(createNormalTable taos_static tutil common pthread) #add_executable(queryPerformance queryPerformance.c) #target_link_libraries(queryPerformance taos_static tutil common pthread) From 56c8889ee4d6f1f4de2acac791cdce1f73a0d61a Mon Sep 17 00:00:00 2001 From: zyyang Date: Fri, 25 Sep 2020 15:39:21 +0800 Subject: [PATCH 70/77] update JdbcTaosdemo --- .../example/jdbcTaosdemo/JdbcTaosdemo.java | 88 +++------ .../domain/JdbcTaosdemoConfig.java | 171 +++++++----------- .../jdbcTaosdemo/task/CreateTableTask.java | 12 +- .../task/InsertTableDatetimeTask.java | 13 +- .../jdbcTaosdemo/task/InsertTableTask.java | 17 +- .../jdbcTaosdemo/utils/ConnectionFactory.java | 32 ++++ .../jdbcTaosdemo/utils/SqlSpeller.java | 58 ++++++ .../src/main/resources/log4j.properties | 11 +- 8 files changed, 208 insertions(+), 194 deletions(-) create mode 100644 tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/ConnectionFactory.java create mode 100644 tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/SqlSpeller.java diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java index 874f950132..5a6acb0291 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java @@ -4,30 +4,29 @@ import com.taosdata.example.jdbcTaosdemo.domain.JdbcTaosdemoConfig; import com.taosdata.example.jdbcTaosdemo.task.CreateTableTask; import com.taosdata.example.jdbcTaosdemo.task.InsertTableDatetimeTask; import com.taosdata.example.jdbcTaosdemo.task.InsertTableTask; +import com.taosdata.example.jdbcTaosdemo.utils.ConnectionFactory; +import com.taosdata.example.jdbcTaosdemo.utils.SqlSpeller; import com.taosdata.example.jdbcTaosdemo.utils.TimeStampUtil; -import com.taosdata.jdbc.TSDBDriver; import org.apache.log4j.Logger; import java.sql.*; -import java.util.*; -import java.util.concurrent.atomic.AtomicLong; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class JdbcTaosdemo { private static Logger logger = Logger.getLogger(JdbcTaosdemo.class); - private static AtomicLong beginTimestamp = new AtomicLong(TimeStampUtil.datetimeToLong("2005-01-01 00:00:00.000")); private final JdbcTaosdemoConfig config; private Connection connection; - private static final String[] locations = {"Beijing", "Shanghai", "Guangzhou", "Shenzhen", "HangZhou", "Tianjin", "Wuhan", "Changsha", "Nanjing", "Xian"}; - private static Random random = new Random(System.currentTimeMillis()); public JdbcTaosdemo(JdbcTaosdemoConfig config) { this.config = config; } - public static void main(String[] args) { - JdbcTaosdemoConfig config = JdbcTaosdemoConfig.build(args); + + JdbcTaosdemoConfig config = new JdbcTaosdemoConfig(args); boolean isHelp = Arrays.asList(args).contains("--help"); if (isHelp) { @@ -67,7 +66,7 @@ public class JdbcTaosdemo { private void init() { try { Class.forName("com.taosdata.jdbc.TSDBDriver"); - connection = getConnection(config); + connection = ConnectionFactory.build(config); if (connection != null) logger.info("[ OK ] Connection established."); } catch (ClassNotFoundException | SQLException e) { @@ -76,27 +75,19 @@ public class JdbcTaosdemo { } } - public static Connection getConnection(JdbcTaosdemoConfig config) throws SQLException { - Properties properties = new Properties(); - properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, config.getHost()); - properties.setProperty(TSDBDriver.PROPERTY_KEY_USER, config.getUser()); - properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD, config.getPassword()); - properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); - return DriverManager.getConnection("jdbc:TAOS://" + config.getHost() + ":" + config.getPort() + "/" + config.getDbName() + "", properties); - } - /** * create database */ private void createDatabase() { - String sql = "create database if not exists " + config.getDbName() + " keep " + config.getKeep() + " days " + config.getDays(); + String sql = SqlSpeller.createDatabaseSQL(config.getDbName(), config.getKeep(), config.getDays()); execute(sql); } + /** + * drop database + */ private void dropDatabase() { - String sql = "drop database if exists " + config.getDbName(); + String sql = SqlSpeller.dropDatabaseSQL(config.getDbName()); execute(sql); } @@ -104,12 +95,15 @@ public class JdbcTaosdemo { * use database */ private void useDatabase() { - String sql = "use " + config.getDbName(); + String sql = SqlSpeller.useDatabaseSQL(config.getDbName()); execute(sql); } + /** + * create super table + */ private void createSuperTable() { - String sql = "create table if not exists " + config.getStbName() + "(ts timestamp, current float, voltage int, phase float) tags(location binary(64), groupId int)"; + String sql = SqlSpeller.createSuperTableSQL(config.getStbName()); execute(sql); } @@ -128,13 +122,16 @@ public class JdbcTaosdemo { for (Thread thread : threads) { thread.join(); } - logger.info(">>> Multi Threads create table finished."); + logger.info("<<< Multi Threads create table finished."); } catch (InterruptedException e) { logger.error(e.getMessage()); e.printStackTrace(); } } + /** + * insert data infinitely + */ private void insertInfinite() { try { final long startDatetime = TimeStampUtil.datetimeToLong("2005-01-01 00:00:00.000"); @@ -150,7 +147,7 @@ public class JdbcTaosdemo { for (Thread thread : threads) { thread.join(); } - logger.info(">>> Multi Threads insert table finished."); + logger.info("<<< Multi Threads insert table finished."); } catch (InterruptedException e) { logger.error(e.getMessage()); e.printStackTrace(); @@ -170,48 +167,13 @@ public class JdbcTaosdemo { for (Thread thread : threads) { thread.join(); } - logger.info(">>> Multi Threads insert table finished."); + logger.info("<<< Multi Threads insert table finished."); } catch (InterruptedException e) { logger.error(e.getMessage()); e.printStackTrace(); } } - public static String insertSql(int tableIndex, JdbcTaosdemoConfig config) { - float current = 10 + random.nextFloat(); - int voltage = 200 + random.nextInt(20); - float phase = random.nextFloat(); - String sql = "insert into " + config.getDbName() + "." + config.getTbPrefix() + "" + tableIndex + " " + - "values(" + beginTimestamp.getAndIncrement() + ", " + current + ", " + voltage + ", " + phase + ") "; - return sql; - } - - public static String insertSql(int tableIndex, long ts, JdbcTaosdemoConfig config) { - float current = 10 + random.nextFloat(); - int voltage = 200 + random.nextInt(20); - float phase = random.nextFloat(); - String sql = "insert into " + config.getDbName() + "." + config.getTbPrefix() + "" + tableIndex + " " + - "values(" + ts + ", " + current + ", " + voltage + ", " + phase + ") "; - return sql; - } - - public static String batchInsertSql(int tableIndex, long ts, int valueCnt, JdbcTaosdemoConfig config) { - float current = 10 + random.nextFloat(); - int voltage = 200 + random.nextInt(20); - float phase = random.nextFloat(); - StringBuilder sb = new StringBuilder(); - sb.append("insert into " + config.getDbName() + "." + config.getTbPrefix() + "" + tableIndex + " " + "values"); - for (int i = 0; i < valueCnt; i++) { - sb.append("(" + (ts + i) + ", " + current + ", " + voltage + ", " + phase + ") "); - } - return sb.toString(); - } - - public static String createTableSql(int tableIndex, JdbcTaosdemoConfig config) { - String location = locations[random.nextInt(locations.length)]; - return "create table d" + tableIndex + " using " + config.getDbName() + "." + config.getStbName() + " tags('" + location + "'," + tableIndex + ")"; - } - private void countFromSuperTable() { String sql = "select count(*) from " + config.getDbName() + "." + config.getStbName(); executeQuery(sql); @@ -233,7 +195,7 @@ public class JdbcTaosdemo { * drop super table */ private void dropSuperTable() { - String sql = "drop table if exists " + config.getDbName() + "." + config.getStbName(); + String sql = SqlSpeller.dropSuperTableSQL(config.getDbName(), config.getStbName()); execute(sql); } diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java index ef0f7bef12..3cca9a3d7a 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/domain/JdbcTaosdemoConfig.java @@ -1,6 +1,6 @@ package com.taosdata.example.jdbcTaosdemo.domain; -public class JdbcTaosdemoConfig { +public final class JdbcTaosdemoConfig { //The host to connect to TDengine. Must insert one private String host; @@ -10,37 +10,45 @@ public class JdbcTaosdemoConfig { private String user = "root"; //The password to use when connecting to the server. Default is 'taosdata' private String password = "taosdata"; + //Destination database. Default is 'test' private String dbName = "test"; //keep private int keep = 365 * 20; - // + //days private int days = 30; + //Super table Name. Default is 'meters' private String stbName = "meters"; //Table name prefix. Default is 'd' private String tbPrefix = "d"; - //The number of threads. Default is 10. - private int numberOfThreads = 10; - //The number of tables. Default is 10000. - private int numberOfTable = 10000; - //The number of records per table. Default is 100000 - private int numberOfRecordsPerTable = 100000; + //The number of tables. Default is 10. + private int numberOfTable = 10; + //The number of records per table. Default is 2 + private int numberOfRecordsPerTable = 2; + //The number of records per request. Default is 100 + private int numberOfRecordsPerRequest = 100; + + //The number of threads. Default is 1. + private int numberOfThreads = 1; //Delete data. Default is false - private boolean deleteTable = true; + private boolean deleteTable = false; public static void printHelp() { - System.out.println("Usage: java -jar JDBCConnectorChecker.jar -h host [OPTION...]"); + System.out.println("Usage: java -jar JDBCConnectorChecker.jar [OPTION...]"); + System.out.println("-h host The host to connect to TDengine. you must input one"); System.out.println("-p port The TCP/IP port number to use for the connection. Default is 6030"); System.out.println("-u user The TDengine user name to use when connecting to the server. Default is 'root'"); System.out.println("-P password The password to use when connecting to the server.Default is 'taosdata'"); System.out.println("-d database Destination database. Default is 'test'"); System.out.println("-m tablePrefix Table prefix name. Default is 'd'"); - System.out.println("-T num_of_threads The number of threads. Default is 10"); - System.out.println("-t num_of_tables The number of tables. Default is 10000"); - System.out.println("-n num_of_records_per_table The number of records per table. Default is 100000"); + System.out.println("-t num_of_tables The number of tables. Default is 10"); + System.out.println("-n num_of_records_per_table The number of records per table. Default is 2"); + System.out.println("-r num_of_records_per_req The number of records per request. Default is 100"); + System.out.println("-T num_of_threads The number of threads. Default is 1"); System.out.println("-D delete table Delete data methods. Default is false"); System.out.println("--help Give this help list"); +// System.out.println("--infinite infinite insert mode"); } /** @@ -49,146 +57,97 @@ public class JdbcTaosdemoConfig { * @param args command line args * @return JdbcTaosdemoConfig */ - public static JdbcTaosdemoConfig build(String[] args) { - - JdbcTaosdemoConfig config = new JdbcTaosdemoConfig(); + public JdbcTaosdemoConfig(String[] args) { for (int i = 0; i < args.length; i++) { if ("-h".equals(args[i]) && i < args.length - 1) { - config.setHost(args[++i]); + host = args[++i]; } if ("-p".equals(args[i]) && i < args.length - 1) { - config.setPort(Integer.parseInt(args[++i])); + port = Integer.parseInt(args[++i]); } if ("-u".equals(args[i]) && i < args.length - 1) { - config.setUser(args[++i]); + user = args[++i]; } if ("-P".equals(args[i]) && i < args.length - 1) { - config.setPassword(args[++i]); + password = args[++i]; } if ("-d".equals(args[i]) && i < args.length - 1) { - config.setDbName(args[++i]); + dbName = args[++i]; } if ("-m".equals(args[i]) && i < args.length - 1) { - config.setTbPrefix(args[++i]); - } - if ("-T".equals(args[i]) && i < args.length - 1) { - config.setNumberOfThreads(Integer.parseInt(args[++i])); + tbPrefix = args[++i]; } if ("-t".equals(args[i]) && i < args.length - 1) { - config.setNumberOfTable(Integer.parseInt(args[++i])); + numberOfTable = Integer.parseInt(args[++i]); } if ("-n".equals(args[i]) && i < args.length - 1) { - config.setNumberOfRecordsPerTable(Integer.parseInt(args[++i])); + numberOfRecordsPerTable = Integer.parseInt(args[++i]); + } + if ("-r".equals(args[i]) && i < args.length - 1) { + numberOfRecordsPerRequest = Integer.parseInt(args[++i]); + } + if ("-T".equals(args[i]) && i < args.length - 1) { + numberOfThreads = Integer.parseInt(args[++i]); } if ("-D".equals(args[i]) && i < args.length - 1) { - config.setDeleteTable(Boolean.parseBoolean(args[++i])); + deleteTable = Boolean.parseBoolean(args[++i]); } } - - return config; - } - - public void setHost(String host) { - this.host = host; } public String getHost() { return host; } - public String getDbName() { - return dbName; - } - - public void setDbName(String dbName) { - this.dbName = dbName; - } - public int getPort() { return port; } - public void setPort(int port) { - this.port = port; - } - public String getUser() { return user; } - public void setUser(String user) { - this.user = user; - } - public String getPassword() { return password; } - public void setPassword(String password) { - this.password = password; - } - - public String getStbName() { - return stbName; - } - - public void setStbName(String stbName) { - this.stbName = stbName; - } - - public String getTbPrefix() { - return tbPrefix; - } - - public void setTbPrefix(String tbPrefix) { - this.tbPrefix = tbPrefix; - } - - public int getNumberOfThreads() { - return numberOfThreads; - } - - public void setNumberOfThreads(int numberOfThreads) { - this.numberOfThreads = numberOfThreads; - } - - public int getNumberOfTable() { - return numberOfTable; - } - - public void setNumberOfTable(int numberOfTable) { - this.numberOfTable = numberOfTable; - } - - public int getNumberOfRecordsPerTable() { - return numberOfRecordsPerTable; - } - - public void setNumberOfRecordsPerTable(int numberOfRecordsPerTable) { - this.numberOfRecordsPerTable = numberOfRecordsPerTable; - } - - public boolean isDeleteTable() { - return deleteTable; - } - - public void setDeleteTable(boolean deleteTable) { - this.deleteTable = deleteTable; + public String getDbName() { + return dbName; } public int getKeep() { return keep; } - public void setKeep(int keep) { - this.keep = keep; - } - public int getDays() { return days; } - public void setDays(int days) { - this.days = days; + public String getStbName() { + return stbName; + } + + public String getTbPrefix() { + return tbPrefix; + } + + public int getNumberOfTable() { + return numberOfTable; + } + + public int getNumberOfRecordsPerTable() { + return numberOfRecordsPerTable; + } + + public int getNumberOfThreads() { + return numberOfThreads; + } + + public boolean isDeleteTable() { + return deleteTable; + } + + public int getNumberOfRecordsPerRequest() { + return numberOfRecordsPerRequest; } } diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/CreateTableTask.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/CreateTableTask.java index 2b1a08ab40..1da2c8647e 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/CreateTableTask.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/CreateTableTask.java @@ -1,7 +1,8 @@ package com.taosdata.example.jdbcTaosdemo.task; -import com.taosdata.example.jdbcTaosdemo.JdbcTaosdemo; import com.taosdata.example.jdbcTaosdemo.domain.JdbcTaosdemoConfig; +import com.taosdata.example.jdbcTaosdemo.utils.ConnectionFactory; +import com.taosdata.example.jdbcTaosdemo.utils.SqlSpeller; import org.apache.log4j.Logger; import java.sql.Connection; @@ -24,14 +25,11 @@ public class CreateTableTask implements Runnable { @Override public void run() { try { - Connection connection = JdbcTaosdemo.getConnection(config); + Connection connection = ConnectionFactory.build(config); for (int i = startIndex; i < startIndex + tableNumber; i++) { Statement statement = connection.createStatement(); - String sql = JdbcTaosdemo.createTableSql(i + 1, config); -// long start = System.currentTimeMillis(); - boolean execute = statement.execute(sql); -// long end = System.currentTimeMillis(); -// printSql(sql, execute, (end - start)); + String sql = SqlSpeller.createTableSQL(i + 1, config.getDbName(), config.getStbName()); + statement.execute(sql); statement.close(); logger.info(">>> " + sql); } diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableDatetimeTask.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableDatetimeTask.java index d477ceeaed..4f60c25646 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableDatetimeTask.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableDatetimeTask.java @@ -1,7 +1,8 @@ package com.taosdata.example.jdbcTaosdemo.task; -import com.taosdata.example.jdbcTaosdemo.JdbcTaosdemo; import com.taosdata.example.jdbcTaosdemo.domain.JdbcTaosdemoConfig; +import com.taosdata.example.jdbcTaosdemo.utils.ConnectionFactory; +import com.taosdata.example.jdbcTaosdemo.utils.SqlSpeller; import org.apache.log4j.Logger; import java.sql.Connection; @@ -28,13 +29,11 @@ public class InsertTableDatetimeTask implements Runnable { @Override public void run() { try { - Connection connection = JdbcTaosdemo.getConnection(config); - int valueCnt = 100; - for (long ts = startDatetime; ts < finishedDatetime; ts+= valueCnt) { + Connection connection = ConnectionFactory.build(config); + int valuesCount = config.getNumberOfRecordsPerRequest(); + for (long ts = startDatetime; ts < finishedDatetime; ts += valuesCount) { for (int i = startTableIndex; i < startTableIndex + tableNumber; i++) { -// String sql = JdbcTaosdemo.insertSql(i + 1, ts, config); - - String sql = JdbcTaosdemo.batchInsertSql(i + 1, ts, valueCnt, config); + String sql = SqlSpeller.insertBatchSizeRowsSQL(config.getDbName(), config.getTbPrefix(), i + 1, ts, valuesCount); Statement statement = connection.createStatement(); statement.execute(sql); statement.close(); diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java index 9ae50d830e..d6d6ebbff1 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/task/InsertTableTask.java @@ -1,15 +1,19 @@ package com.taosdata.example.jdbcTaosdemo.task; -import com.taosdata.example.jdbcTaosdemo.JdbcTaosdemo; import com.taosdata.example.jdbcTaosdemo.domain.JdbcTaosdemoConfig; +import com.taosdata.example.jdbcTaosdemo.utils.ConnectionFactory; +import com.taosdata.example.jdbcTaosdemo.utils.SqlSpeller; +import com.taosdata.example.jdbcTaosdemo.utils.TimeStampUtil; import org.apache.log4j.Logger; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; +import java.util.concurrent.atomic.AtomicLong; public class InsertTableTask implements Runnable { private static final Logger logger = Logger.getLogger(InsertTableTask.class); + private static AtomicLong beginTimestamp = new AtomicLong(TimeStampUtil.datetimeToLong("2005-01-01 00:00:00.000")); private final JdbcTaosdemoConfig config; private final int startIndex; @@ -26,10 +30,13 @@ public class InsertTableTask implements Runnable { @Override public void run() { try { - Connection connection = JdbcTaosdemo.getConnection(config); - for (int i = startIndex; i < startIndex + tableNumber; i++) { - for (int j = 0; j < recordsNumber; j++) { - String sql = JdbcTaosdemo.insertSql(i + 1, config); + Connection connection = ConnectionFactory.build(config); + // iterate insert + for (int j = 0; j < recordsNumber; j++) { + long ts = beginTimestamp.getAndIncrement(); + // insert data into echo table + for (int i = startIndex; i < startIndex + tableNumber; i++) { + String sql = SqlSpeller.insertOneRowSQL(config.getDbName(), config.getTbPrefix(), i + 1, ts); Statement statement = connection.createStatement(); statement.execute(sql); statement.close(); diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/ConnectionFactory.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/ConnectionFactory.java new file mode 100644 index 0000000000..52691f4de7 --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/ConnectionFactory.java @@ -0,0 +1,32 @@ +package com.taosdata.example.jdbcTaosdemo.utils; + +import com.taosdata.example.jdbcTaosdemo.domain.JdbcTaosdemoConfig; +import com.taosdata.jdbc.TSDBDriver; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.Properties; + +public class ConnectionFactory { + + public static Connection build(JdbcTaosdemoConfig config) throws SQLException { + return build(config.getHost(), config.getPort(), config.getDbName(), config.getUser(), config.getPassword()); + } + + public static Connection build(String host, int port, String dbName) throws SQLException { + return build(host, port, dbName, "root", "taosdata"); + } + + private static Connection build(String host, int port, String dbName, String user, String password) throws SQLException { + Properties properties = new Properties(); + properties.setProperty(TSDBDriver.PROPERTY_KEY_USER, user); + properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD, password); + properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); + return DriverManager.getConnection("jdbc:TAOS://" + host + ":" + port + "/" + dbName + "", properties); + } + + +} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/SqlSpeller.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/SqlSpeller.java new file mode 100644 index 0000000000..ecab1a0359 --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/SqlSpeller.java @@ -0,0 +1,58 @@ +package com.taosdata.example.jdbcTaosdemo.utils; + +import java.util.Random; + +public class SqlSpeller { + private static final Random random = new Random(System.currentTimeMillis()); + private static final String[] locations = { + "Beijing", "Shanghai", "Guangzhou", "Shenzhen", + "HangZhou", "Tianjin", "Wuhan", "Changsha", "Nanjing", "Xian" + }; + + public static String createDatabaseSQL(String dbName, int keep, int days) { + return "create database if not exists " + dbName + " keep " + keep + " days " + days; + } + + public static String dropDatabaseSQL(String dbName) { + return "drop database if exists " + dbName; + } + + public static String useDatabaseSQL(String dbName) { + return "use " + dbName; + } + + public static String createSuperTableSQL(String superTableName) { + return "create table if not exists " + superTableName + "(ts timestamp, current float, voltage int, phase float) tags(location binary(64), groupId int)"; + } + + public static String dropSuperTableSQL(String dbName, String superTableName) { + return "drop table if exists " + dbName + "." + superTableName; + } + + public static String createTableSQL(int tableIndex, String dbName, String superTableName) { + String location = locations[random.nextInt(locations.length)]; + return "create table d" + tableIndex + " using " + dbName + "." + superTableName + " tags('" + location + "'," + tableIndex + ")"; + } + + public static String insertOneRowSQL(String dbName, String tbPrefix, int tableIndex, long ts) { + float current = 10 + random.nextFloat(); + int voltage = 200 + random.nextInt(20); + float phase = random.nextFloat(); + String sql = "insert into " + dbName + "." + tbPrefix + "" + tableIndex + " " + "values(" + ts + ", " + current + ", " + voltage + ", " + phase + ")"; + return sql; + } + + public static String insertBatchSizeRowsSQL(String dbName, String tbPrefix, int tbIndex, long ts, int valuesCount) { + float current = 10 + random.nextFloat(); + int voltage = 200 + random.nextInt(20); + float phase = random.nextFloat(); + StringBuilder sb = new StringBuilder(); + sb.append("insert into " + dbName + "." + tbPrefix + "" + tbIndex + " " + "values"); + for (int i = 0; i < valuesCount; i++) { + sb.append("(" + (ts + i) + ", " + current + ", " + voltage + ", " + phase + ") "); + } + return sb.toString(); + } + + +} \ No newline at end of file diff --git a/tests/examples/JDBC/JDBCDemo/src/main/resources/log4j.properties b/tests/examples/JDBC/JDBCDemo/src/main/resources/log4j.properties index 0ed95d04d3..b445e5f52e 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/resources/log4j.properties +++ b/tests/examples/JDBC/JDBCDemo/src/main/resources/log4j.properties @@ -1,11 +1,10 @@ ### 设置### -#log4j.rootLogger=debug,stdout,DebugLog,ErrorLog -log4j.rootLogger=debug,DebugLog,ErrorLog +log4j.rootLogger=debug,stdout,DebugLog,ErrorLog ### 输出信息到控制抬 ### -#log4j.appender.stdout=org.apache.log4j.ConsoleAppender -#log4j.appender.stdout.Target=System.out -#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -#log4j.appender.stdout.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n ### 输出DEBUG 级别以上的日志到=logs/error.log ### log4j.appender.DebugLog=org.apache.log4j.DailyRollingFileAppender log4j.appender.DebugLog.File=logs/debug.log From 2cd68ffe6946a757d56d52a709ae7689b1f93752 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 25 Sep 2020 15:40:17 +0800 Subject: [PATCH 71/77] TD-1574 compile in windows --- deps/zlib-1.2.11/CMakeLists.txt | 13 ++++++++----- src/os/src/detail/osDir.c | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/deps/zlib-1.2.11/CMakeLists.txt b/deps/zlib-1.2.11/CMakeLists.txt index 5502070819..f83aa70085 100644 --- a/deps/zlib-1.2.11/CMakeLists.txt +++ b/deps/zlib-1.2.11/CMakeLists.txt @@ -1,8 +1,11 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) -IF (TD_LINUX) - INCLUDE_DIRECTORIES(inc) - AUX_SOURCE_DIRECTORY(src SRC) - ADD_LIBRARY(z ${SRC}) -ENDIF () \ No newline at end of file +IF (TD_WINDOWS) + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /WX-") + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /WX-") +ENDIF() + +INCLUDE_DIRECTORIES(inc) +AUX_SOURCE_DIRECTORY(src SRC) +ADD_LIBRARY(z ${SRC}) diff --git a/src/os/src/detail/osDir.c b/src/os/src/detail/osDir.c index bdb840ce01..30fd05ffc7 100644 --- a/src/os/src/detail/osDir.c +++ b/src/os/src/detail/osDir.c @@ -130,7 +130,7 @@ int32_t taosCompressFile(char *srcFileName, char *destFileName) { } while (!feof(srcFp)) { - len = (uLong)fread(data, 1, COMPRESS_STEP_SIZE, srcFp); + len = (int32_t)fread(data, 1, COMPRESS_STEP_SIZE, srcFp); gzwrite(dstFp, data, len); } From 1a4746d4255e650a678fd4e2078c18f2571fcc60 Mon Sep 17 00:00:00 2001 From: zyyang Date: Fri, 25 Sep 2020 17:12:15 +0800 Subject: [PATCH 72/77] update jdbc taosdemo --- .../example/jdbcTaosdemo/JdbcTaosdemo.java | 44 ++++++++++++++++--- .../jdbcTaosdemo/utils/SqlSpeller.java | 24 ++++++++++ 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java index 5a6acb0291..c30d85a084 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/JdbcTaosdemo.java @@ -25,7 +25,6 @@ public class JdbcTaosdemo { } public static void main(String[] args) { - JdbcTaosdemoConfig config = new JdbcTaosdemoConfig(args); boolean isHelp = Arrays.asList(args).contains("--help"); @@ -52,7 +51,15 @@ public class JdbcTaosdemo { taosdemo.insertInfinite(); } else { taosdemo.insertMultiThreads(); - taosdemo.countFromSuperTable(); + // single table select + taosdemo.selectFromTableLimit(); + taosdemo.selectCountFromTable(); + taosdemo.selectAvgMinMaxFromTable(); + // super table select + taosdemo.selectFromSuperTableLimit(); + taosdemo.selectCountFromSuperTable(); + taosdemo.selectAvgMinMaxFromSuperTable(); + // drop super table if (config.isDeleteTable()) taosdemo.dropSuperTable(); taosdemo.close(); @@ -174,8 +181,33 @@ public class JdbcTaosdemo { } } - private void countFromSuperTable() { - String sql = "select count(*) from " + config.getDbName() + "." + config.getStbName(); + private void selectFromTableLimit() { + String sql = SqlSpeller.selectFromTableLimitSQL(config.getDbName(), config.getTbPrefix(), 1, 10, 0); + executeQuery(sql); + } + + private void selectCountFromTable() { + String sql = SqlSpeller.selectCountFromTableSQL(config.getDbName(), config.getTbPrefix(), 1); + executeQuery(sql); + } + + private void selectAvgMinMaxFromTable() { + String sql = SqlSpeller.selectAvgMinMaxFromTableSQL("current", config.getDbName(), config.getTbPrefix(), 1); + executeQuery(sql); + } + + private void selectFromSuperTableLimit() { + String sql = SqlSpeller.selectFromSuperTableLimitSQL(config.getDbName(), config.getStbName(), 10, 0); + executeQuery(sql); + } + + private void selectCountFromSuperTable() { + String sql = SqlSpeller.selectCountFromSuperTableSQL(config.getDbName(), config.getStbName()); + executeQuery(sql); + } + + private void selectAvgMinMaxFromSuperTable() { + String sql = SqlSpeller.selectAvgMinMaxFromSuperTableSQL("current", config.getDbName(), config.getStbName()); executeQuery(sql); } @@ -215,7 +247,7 @@ public class JdbcTaosdemo { } private static void printSql(String sql, boolean succeed, long cost) { - logger.info("[ " + (succeed ? "OK" : "ERROR!") + " ] time cost: " + cost + " ms, execute statement ====> " + sql); + System.out.println("[ " + (succeed ? "OK" : "ERROR!") + " ] time cost: " + cost + " ms, execute statement ====> " + sql); } private void executeQuery(String sql) { @@ -240,7 +272,7 @@ public class JdbcTaosdemo { String value = resultSet.getString(i); sb.append(columnLabel + ": " + value + "\t"); } - logger.info(sb.toString()); + System.out.println(sb.toString()); } } diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/SqlSpeller.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/SqlSpeller.java index ecab1a0359..7af97f3b1b 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/SqlSpeller.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/jdbcTaosdemo/utils/SqlSpeller.java @@ -54,5 +54,29 @@ public class SqlSpeller { return sb.toString(); } + public static String selectFromTableLimitSQL(String dbName, String tbPrefix, int tbIndex, int limit, int offset) { + return "select * from " + dbName + "." + tbPrefix + "" + tbIndex + " limit " + limit + " offset " + offset; + } + + public static String selectCountFromTableSQL(String dbName, String tbPrefix, int tbIndex) { + return "select count(*) from " + dbName + "." + tbPrefix + "" + tbIndex; + } + + public static String selectAvgMinMaxFromTableSQL(String field, String dbName, String tbPrefix, int tbIndex) { + return "select avg(" + field + "),min(" + field + "),max(" + field + ") from " + dbName + "." + tbPrefix + "" + tbIndex; + } + + public static String selectFromSuperTableLimitSQL(String dbName, String stbName, int limit, int offset) { + return "select * from " + dbName + "." + stbName + " limit " + limit + " offset " + offset; + } + + public static String selectCountFromSuperTableSQL(String dbName, String stableName) { + return "select count(*) from " + dbName + "." + stableName; + } + + public static String selectAvgMinMaxFromSuperTableSQL(String field, String dbName, String stbName) { + return "select avg(" + field + "),min(" + field + "),max(" + field + ") from " + dbName + "." + stbName + ""; + } + } \ No newline at end of file From 7a840d7f2ac73a253f49ae55057c0c1b61034118 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 25 Sep 2020 10:14:20 +0000 Subject: [PATCH 73/77] change maxVgroupsPerDb to 16 --- src/inc/taosdef.h | 2 ++ src/mnode/src/mnodeVgroup.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index f9d4b3d7bf..228aba2a5e 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -294,6 +294,8 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf #define TSDB_CQ_SQL_SIZE 1024 #define TSDB_MIN_VNODES 64 #define TSDB_MAX_VNODES 2048 +#define TSDB_MIN_VNODES_PER_DB 2 +#define TSDB_MAX_VNODES_PER_DB 16 #define TSDB_DNODE_ROLE_ANY 0 #define TSDB_DNODE_ROLE_MGMT 1 diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 9345bdae2c..7dbf605405 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -434,7 +434,8 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi int maxVgroupsPerDb = tsMaxVgroupsPerDb; if (maxVgroupsPerDb <= 0) { maxVgroupsPerDb = mnodeGetOnlinDnodesCpuCoreNum(); - maxVgroupsPerDb = MAX(maxVgroupsPerDb, 2); + maxVgroupsPerDb = MAX(maxVgroupsPerDb, TSDB_MIN_VNODES_PER_DB); + maxVgroupsPerDb = MIN(maxVgroupsPerDb, TSDB_MAX_VNODES_PER_DB); } int32_t code = TSDB_CODE_MND_NO_ENOUGH_DNODES; From f2dafd9c7232132848a1cddb6e260e63c35a6907 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 25 Sep 2020 14:42:56 +0000 Subject: [PATCH 74/77] TD-1473 --- src/balance/src/balance.c | 2 + src/mnode/inc/mnodeDef.h | 3 +- src/mnode/inc/mnodeDnode.h | 22 +++++ src/mnode/src/mnodeDnode.c | 134 +++++++++++++++++++-------- tests/script/jenkins/basic.txt | 1 + tests/script/unique/dnode/reason.sim | 132 ++++++++++++++++++++++++++ 6 files changed, 253 insertions(+), 41 deletions(-) create mode 100644 tests/script/unique/dnode/reason.sim diff --git a/src/balance/src/balance.c b/src/balance/src/balance.c index 2b1888042c..3b9af741c3 100644 --- a/src/balance/src/balance.c +++ b/src/balance/src/balance.c @@ -389,6 +389,7 @@ void balanceReset() { pDnode->lastAccess = 0; if (pDnode->status != TAOS_DN_STATUS_DROPPING) { pDnode->status = TAOS_DN_STATUS_OFFLINE; + pDnode->offlineReason = TAOS_DN_OFF_STATUS_NOT_RECEIVED; } mnodeDecDnodeRef(pDnode); @@ -551,6 +552,7 @@ static void balanceCheckDnodeAccess() { if (tsAccessSquence - pDnode->lastAccess > 3) { if (pDnode->status != TAOS_DN_STATUS_DROPPING && pDnode->status != TAOS_DN_STATUS_OFFLINE) { pDnode->status = TAOS_DN_STATUS_OFFLINE; + pDnode->offlineReason = TAOS_DN_OFF_STATUS_MSG_TIMEOUT; mInfo("dnode:%d, set to offline state", pDnode->dnodeId); balanceSetVgroupOffline(pDnode); } diff --git a/src/mnode/inc/mnodeDef.h b/src/mnode/inc/mnodeDef.h index 682986b29f..8a2947dd18 100644 --- a/src/mnode/inc/mnodeDef.h +++ b/src/mnode/inc/mnodeDef.h @@ -69,7 +69,8 @@ typedef struct SDnodeObj { int16_t cpuAvgUsage; // calc from sys.cpu int16_t memoryAvgUsage; // calc from sys.mem int16_t bandwidthUsage; // calc from sys.band - int8_t reserved2[2]; + int8_t offlineReason; + int8_t reserved2[1]; } SDnodeObj; typedef struct SMnodeObj { diff --git a/src/mnode/inc/mnodeDnode.h b/src/mnode/inc/mnodeDnode.h index 13b6ec4411..b6ddb7a9bf 100644 --- a/src/mnode/inc/mnodeDnode.h +++ b/src/mnode/inc/mnodeDnode.h @@ -33,6 +33,28 @@ typedef enum { TAOS_DN_ALTERNATIVE_ROLE_VNODE } EDnodeAlternativeRole; +typedef enum EDnodeOfflineReason { + TAOS_DN_OFF_ONLINE = 0, + TAOS_DN_OFF_STATUS_MSG_TIMEOUT, + TAOS_DN_OFF_STATUS_NOT_RECEIVED, + TAOS_DN_OFF_RESET_BY_MNODE, + TAOS_DN_OFF_VERSION_NOT_MATCH, + TAOS_DN_OFF_DNODE_ID_NOT_MATCH, + TAOS_DN_OFF_CLUSTER_ID_NOT_MATCH, + TAOS_DN_OFF_NUM_OF_MNODES_NOT_MATCH, + TAOS_DN_OFF_ENABLE_BALANCE_NOT_MATCH, + TAOS_DN_OFF_MN_EQUAL_VN_NOT_MATCH, + TAOS_DN_OFF_OFFLINE_THRESHOLD_NOT_MATCH, + TAOS_DN_OFF_STATUS_INTERVAL_NOT_MATCH, + TAOS_DN_OFF_MAX_TAB_PER_VN_NOT_MATCH, + TAOS_DN_OFF_MAX_VG_PER_DB_NOT_MATCH, + TAOS_DN_OFF_ARBITRATOR_NOT_MATCH, + TAOS_DN_OFF_TIME_ZONE_NOT_MATCH, + TAOS_DN_OFF_LOCALE_NOT_MATCH, + TAOS_DN_OFF_CHARSET_NOT_MATCH, + TAOS_DN_OFF_OTHERS +} EDnodeOfflineReason; + int32_t mnodeInitDnodes(); void mnodeCleanupDnodes(); diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index ac8730b0cc..61c1d4113f 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -60,6 +60,28 @@ static int32_t mnodeGetDnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC static int32_t mnodeRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn); static char* mnodeGetDnodeAlternativeRoleStr(int32_t alternativeRole); +static char* offlineReason[] = { + "", + "status msg timeout", + "status not received", + "status reset by mnode", + "version not match", + "dnodeId not match", + "clusterId not match", + "numOfMnodes not match", + "balance not match", + "mnEqualVn not match", + "offThreshold not match", + "interval not match", + "maxTabPerVn not match", + "maxVgPerDb not match", + "arbitrator not match", + "timezone not match", + "locale not match", + "charset not match", + "unknown", +}; + static int32_t mnodeDnodeActionDestroy(SSdbOper *pOper) { taosTFree(pOper->pObj); return TSDB_CODE_SUCCESS; @@ -70,6 +92,7 @@ static int32_t mnodeDnodeActionInsert(SSdbOper *pOper) { if (pDnode->status != TAOS_DN_STATUS_DROPPING) { pDnode->status = TAOS_DN_STATUS_OFFLINE; pDnode->lastAccess = tsAccessSquence; + pDnode->offlineReason = TAOS_DN_OFF_STATUS_NOT_RECEIVED; } mInfo("dnode:%d, fqdn:%s ep:%s port:%d, do insert action", pDnode->dnodeId, pDnode->dnodeFqdn, pDnode->dnodeEp, pDnode->dnodePort); @@ -334,74 +357,85 @@ static void mnodeProcessCfgDnodeMsgRsp(SRpcMsg *rpcMsg) { mInfo("cfg dnode rsp is received"); } -static bool mnodeCheckClusterCfgPara(const SClusterCfg *clusterCfg) { +static int32_t mnodeCheckClusterCfgPara(const SClusterCfg *clusterCfg) { if (clusterCfg->numOfMnodes != htonl(tsNumOfMnodes)) { mError("\"numOfMnodes\"[%d - %d] cfg parameters inconsistent", clusterCfg->numOfMnodes, htonl(tsNumOfMnodes)); - return false; - } - if (clusterCfg->enableBalance != htonl(tsEnableBalance)) { + return TAOS_DN_OFF_NUM_OF_MNODES_NOT_MATCH; + } + if (clusterCfg->enableBalance != htonl(tsEnableBalance)) { mError("\"balance\"[%d - %d] cfg parameters inconsistent", clusterCfg->enableBalance, htonl(tsEnableBalance)); - return false; + return TAOS_DN_OFF_ENABLE_BALANCE_NOT_MATCH; } if (clusterCfg->mnodeEqualVnodeNum != htonl(tsMnodeEqualVnodeNum)) { - mError("\"mnodeEqualVnodeNum\"[%d - %d] cfg parameters inconsistent", clusterCfg->mnodeEqualVnodeNum, htonl(tsMnodeEqualVnodeNum)); - return false; + mError("\"mnodeEqualVnodeNum\"[%d - %d] cfg parameters inconsistent", clusterCfg->mnodeEqualVnodeNum, + htonl(tsMnodeEqualVnodeNum)); + return TAOS_DN_OFF_MN_EQUAL_VN_NOT_MATCH; } - if (clusterCfg->offlineThreshold != htonl(tsOfflineThreshold)) { - mError("\"offlineThreshold\"[%d - %d] cfg parameters inconsistent", clusterCfg->offlineThreshold, htonl(tsOfflineThreshold)); - return false; + if (clusterCfg->offlineThreshold != htonl(tsOfflineThreshold)) { + mError("\"offlineThreshold\"[%d - %d] cfg parameters inconsistent", clusterCfg->offlineThreshold, + htonl(tsOfflineThreshold)); + return TAOS_DN_OFF_OFFLINE_THRESHOLD_NOT_MATCH; } - if (clusterCfg->statusInterval != htonl(tsStatusInterval)) { - mError("\"statusInterval\"[%d - %d] cfg parameters inconsistent", clusterCfg->statusInterval, htonl(tsStatusInterval)); - return false; + if (clusterCfg->statusInterval != htonl(tsStatusInterval)) { + mError("\"statusInterval\"[%d - %d] cfg parameters inconsistent", clusterCfg->statusInterval, + htonl(tsStatusInterval)); + return TAOS_DN_OFF_STATUS_INTERVAL_NOT_MATCH; } - if (clusterCfg->maxtablesPerVnode != htonl(tsMaxTablePerVnode)) { - mError("\"maxTablesPerVnode\"[%d - %d] cfg parameters inconsistent", clusterCfg->maxtablesPerVnode, htonl(tsMaxTablePerVnode)); - return false; + if (clusterCfg->maxtablesPerVnode != htonl(tsMaxTablePerVnode)) { + mError("\"maxTablesPerVnode\"[%d - %d] cfg parameters inconsistent", clusterCfg->maxtablesPerVnode, + htonl(tsMaxTablePerVnode)); + return TAOS_DN_OFF_MAX_TAB_PER_VN_NOT_MATCH; } - if (clusterCfg->maxVgroupsPerDb != htonl(tsMaxVgroupsPerDb)) { - mError("\"maxVgroupsPerDb\"[%d - %d] cfg parameters inconsistent", clusterCfg->maxVgroupsPerDb, htonl(tsMaxVgroupsPerDb)); - return false; + if (clusterCfg->maxVgroupsPerDb != htonl(tsMaxVgroupsPerDb)) { + mError("\"maxVgroupsPerDb\"[%d - %d] cfg parameters inconsistent", clusterCfg->maxVgroupsPerDb, + htonl(tsMaxVgroupsPerDb)); + return TAOS_DN_OFF_MAX_VG_PER_DB_NOT_MATCH; } if (0 != strncasecmp(clusterCfg->arbitrator, tsArbitrator, strlen(tsArbitrator))) { mError("\"arbitrator\"[%s - %s] cfg parameters inconsistent", clusterCfg->arbitrator, tsArbitrator); - return false; + return TAOS_DN_OFF_ARBITRATOR_NOT_MATCH; } int64_t checkTime = 0; - char timestr[32] = "1970-01-01 00:00:00.00"; + char timestr[32] = "1970-01-01 00:00:00.00"; (void)taosParseTime(timestr, &checkTime, strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0); - if ((0 != strncasecmp(clusterCfg->timezone, tsTimezone, strlen(tsTimezone))) && (checkTime != clusterCfg->checkTime)) { - mError("\"timezone\"[%s - %s] [%" PRId64 " - %" PRId64"] cfg parameters inconsistent", clusterCfg->timezone, tsTimezone, clusterCfg->checkTime, checkTime); - return false; + if ((0 != strncasecmp(clusterCfg->timezone, tsTimezone, strlen(tsTimezone))) && + (checkTime != clusterCfg->checkTime)) { + mError("\"timezone\"[%s - %s] [%" PRId64 " - %" PRId64 "] cfg parameters inconsistent", clusterCfg->timezone, + tsTimezone, clusterCfg->checkTime, checkTime); + return TAOS_DN_OFF_TIME_ZONE_NOT_MATCH; } if (0 != strncasecmp(clusterCfg->locale, tsLocale, strlen(tsLocale))) { mError("\"locale\"[%s - %s] cfg parameters inconsistent", clusterCfg->locale, tsLocale); - return false; + return TAOS_DN_OFF_LOCALE_NOT_MATCH; } if (0 != strncasecmp(clusterCfg->charset, tsCharset, strlen(tsCharset))) { mError("\"charset\"[%s - %s] cfg parameters inconsistent.", clusterCfg->charset, tsCharset); - return false; + return TAOS_DN_OFF_CHARSET_NOT_MATCH; } - - return true; + + return 0; } static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { + SDnodeObj *pDnode = NULL; SDMStatusMsg *pStatus = pMsg->rpcMsg.pCont; pStatus->dnodeId = htonl(pStatus->dnodeId); pStatus->moduleStatus = htonl(pStatus->moduleStatus); pStatus->lastReboot = htonl(pStatus->lastReboot); pStatus->numOfCores = htons(pStatus->numOfCores); - + uint32_t version = htonl(pStatus->version); if (version != tsVersion) { - mError("status msg version:%d not equal with mnode:%d", version, tsVersion); + pDnode = mnodeGetDnodeByEp(pStatus->dnodeEp); + if (pDnode != NULL && pDnode->status != TAOS_DN_STATUS_READY) { + pDnode->offlineReason = TAOS_DN_OFF_VERSION_NOT_MATCH; + } + mError("dnode:%d, status msg version:%d not equal with cluster:%d", pStatus->dnodeId, version, tsVersion); return TSDB_CODE_MND_INVALID_MSG_VERSION; } - SDnodeObj *pDnode = NULL; if (pStatus->dnodeId == 0) { pDnode = mnodeGetDnodeByEp(pStatus->dnodeEp); if (pDnode == NULL) { @@ -411,7 +445,11 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { } else { pDnode = mnodeGetDnode(pStatus->dnodeId); if (pDnode == NULL) { - mError("dnode id:%d, %s not exist", pStatus->dnodeId, pStatus->dnodeEp); + pDnode = mnodeGetDnodeByEp(pStatus->dnodeEp); + if (pDnode != NULL && pDnode->status != TAOS_DN_STATUS_READY) { + pDnode->offlineReason = TAOS_DN_OFF_DNODE_ID_NOT_MATCH; + } + mError("dnode:%d, %s not exist", pStatus->dnodeId, pStatus->dnodeEp); return TSDB_CODE_MND_DNODE_NOT_EXIST; } } @@ -426,6 +464,9 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { mDebug("dnode:%d %s, first access, set clusterId %s", pDnode->dnodeId, pDnode->dnodeEp, mnodeGetClusterId()); } else { if (strncmp(pStatus->clusterId, mnodeGetClusterId(), TSDB_CLUSTER_ID_LEN - 1) != 0) { + if (pDnode != NULL && pDnode->status != TAOS_DN_STATUS_READY) { + pDnode->offlineReason = TAOS_DN_OFF_CLUSTER_ID_NOT_MATCH; + } mError("dnode:%d, input clusterId %s not match with exist %s", pDnode->dnodeId, pStatus->clusterId, mnodeGetClusterId()); return TSDB_CODE_MND_INVALID_CLUSTER_ID; @@ -469,16 +510,19 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { if (pDnode->status == TAOS_DN_STATUS_OFFLINE) { // Verify whether the cluster parameters are consistent when status change from offline to ready - bool ret = mnodeCheckClusterCfgPara(&(pStatus->clusterCfg)); - if (false == ret) { + int32_t ret = mnodeCheckClusterCfgPara(&(pStatus->clusterCfg)); + if (0 != ret) { + pDnode->offlineReason = ret; mnodeDecDnodeRef(pDnode); rpcFreeCont(pRsp); - mError("dnode:%d, %s cluster cfg parameters inconsistent", pDnode->dnodeId, pStatus->dnodeEp); + mError("dnode:%d, %s cluster cfg parameters inconsistent, reason:%s", pDnode->dnodeId, pStatus->dnodeEp, + offlineReason[ret]); return TSDB_CODE_MND_CLUSTER_CFG_INCONSISTENT; } - + mDebug("dnode:%d, from offline to online", pDnode->dnodeId); pDnode->status = TAOS_DN_STATUS_READY; + pDnode->offlineReason = TAOS_DN_OFF_ONLINE; balanceSyncNotify(); balanceAsyncNotify(); } @@ -529,6 +573,7 @@ static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) { pDnode = (SDnodeObj *) calloc(1, sizeof(SDnodeObj)); pDnode->createdTime = taosGetTimestampMs(); pDnode->status = TAOS_DN_STATUS_OFFLINE; + pDnode->offlineReason = TAOS_DN_OFF_STATUS_NOT_RECEIVED; tstrncpy(pDnode->dnodeEp, ep, TSDB_EP_LEN); taosGetFqdnPortFromEp(ep, pDnode->dnodeFqdn, &pDnode->dnodePort); @@ -654,13 +699,13 @@ static int32_t mnodeGetDnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - pShow->bytes[cols] = 12 + VARSTR_HEADER_SIZE; + pShow->bytes[cols] = 10 + VARSTR_HEADER_SIZE; pSchema[cols].type = TSDB_DATA_TYPE_BINARY; strcpy(pSchema[cols].name, "status"); pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - pShow->bytes[cols] = 6 + VARSTR_HEADER_SIZE; + pShow->bytes[cols] = 5 + VARSTR_HEADER_SIZE; pSchema[cols].type = TSDB_DATA_TYPE_BINARY; strcpy(pSchema[cols].name, "role"); pSchema[cols].bytes = htons(pShow->bytes[cols]); @@ -672,6 +717,12 @@ static int32_t mnodeGetDnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; + pShow->bytes[cols] = 24 + VARSTR_HEADER_SIZE; + pSchema[cols].type = TSDB_DATA_TYPE_BINARY; + strcpy(pSchema[cols].name, "offline reason"); + pSchema[cols].bytes = htons(pShow->bytes[cols]); + cols++; + pMeta->numOfColumns = htons(cols); pShow->numOfColumns = cols; @@ -731,8 +782,11 @@ static int32_t mnodeRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, vo *(int64_t *)pWrite = pDnode->createdTime; cols++; - - numOfRows++; + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + STR_TO_VARSTR(pWrite, offlineReason[pDnode->offlineReason]); + cols++; + + numOfRows++; mnodeDecDnodeRef(pDnode); } diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 9e42adfea9..977ef452ab 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -278,6 +278,7 @@ cd ../../../debug; make ./test.sh -f unique/dnode/balancex.sim ./test.sh -f unique/dnode/offline1.sim ./test.sh -f unique/dnode/offline2.sim +./test.sh -f unique/dnode/reason.sim ./test.sh -f unique/dnode/remove1.sim ./test.sh -f unique/dnode/remove2.sim ./test.sh -f unique/dnode/vnode_clean.sim diff --git a/tests/script/unique/dnode/reason.sim b/tests/script/unique/dnode/reason.sim new file mode 100644 index 0000000000..ad61a81b97 --- /dev/null +++ b/tests/script/unique/dnode/reason.sim @@ -0,0 +1,132 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect +sql create dnode $hostname2 + +sql show dnodes +print dnode1 off: $data7_1 +print dnode2 off: $data7_2 +if $data7_2 != @status not received@ then + return -1 +endi + +print ========== step2 +system sh/exec.sh -n dnode2 -s start +sleep 3000 +sql show dnodes +print dnode1 off: $data7_1 +print dnode2 off: $data7_2 + +print ========== step3 +system sh/exec.sh -n dnode2 -s stop +sleep 3000 +sql show dnodes +print dnode1 off: $data7_1 +print dnode2 off: $data7_2 +if $data7_2 != @status msg timeout@ then + return -1 +endi + +print ========== step4 +sql drop dnode $hostname2 +sleep 5000 +sql show dnodes +if $rows != 1 then + return -1 +endi + +print ========== step5 +system sh/exec.sh -n dnode2 -s start +sql create dnode $hostname2 +sleep 3000 +sql show dnodes +print dnode1 off: $data7_1 +print dnode2 off: $data7_3 +if $data7_3 != @dnodeId not match@ then + return -1 +endi + +print ========== step6 +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 3 +system sh/exec.sh -n dnode4 -s start +sql create dnode $hostname4 + +sleep 3000 +sql show dnodes +print dnode1 off: $data7_1 +print dnode4 off: $data7_4 +if $data7_4 != @mnEqualVn not match@ then + return -1 +endi + +print ========== step7 +system sh/deploy.sh -n dnode5 -i 5 +system sh/cfg.sh -n dnode5 -c statusInterval -v 3 +system sh/exec.sh -n dnode5 -s start +sql create dnode $hostname5 + +sleep 3000 +sql show dnodes +print dnode1 off: $data7_1 +print dnode5 off: $data7_5 +if $data7_5 != @interval not match@ then + return -1 +endi + +print ========== step8 +system sh/deploy.sh -n dnode6 -i 6 +system sh/cfg.sh -n dnode6 -c balance -v 0 +system sh/exec.sh -n dnode6 -s start +sql create dnode $hostname6 + +sleep 3000 +sql show dnodes +print dnode1 off: $data7_1 +print dnode6 off: $data7_6 +if $data7_6 != @balance not match@ then + return -1 +endi + +print ========== step9 +system sh/deploy.sh -n dnode7 -i 7 +system sh/cfg.sh -n dnode7 -c maxTablesPerVnode -v 3000 +system sh/exec.sh -n dnode7 -s start +sql create dnode $hostname7 + +sleep 3000 +sql show dnodes +print dnode1 off: $data7_1 +print dnode7 off: $data7_7 +if $data7_7 != @maxTabPerVn not match@ then + return -1 +endi + +print ========== step10 +system sh/deploy.sh -n dnode8 -i 8 +system sh/cfg.sh -n dnode8 -c maxVgroupsPerDb -v 3 +system sh/exec.sh -n dnode8 -s start +sql create dnode $hostname8 + +sleep 3000 +sql show dnodes +print dnode1 off: $data7_1 +print dnode8 off: $data7_8 +if $data7_8 != @maxVgPerDb not match@ then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file From 786f3256f21819b8d40afc9ea2b715b02fe7d566 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 25 Sep 2020 14:45:21 +0000 Subject: [PATCH 75/77] minor changes --- tests/script/jenkins/basic.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 977ef452ab..000d36c178 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -303,8 +303,8 @@ cd ../../../debug; make ./test.sh -f unique/mnode/mgmt22.sim ./test.sh -f unique/mnode/mgmt23.sim ./test.sh -f unique/mnode/mgmt24.sim -./test.sh -f unique/mnode/mgmt25.sim -./test.sh -f unique/mnode/mgmt26.sim +#./test.sh -f unique/mnode/mgmt25.sim +#./test.sh -f unique/mnode/mgmt26.sim ./test.sh -f unique/mnode/mgmt33.sim ./test.sh -f unique/mnode/mgmt34.sim ./test.sh -f unique/mnode/mgmtr2.sim From 9dbc9b6fd8d313e8216bb14cb51aa850942b5cec Mon Sep 17 00:00:00 2001 From: zyyang Date: Sun, 27 Sep 2020 09:14:43 +0800 Subject: [PATCH 76/77] [TD-1608]: fix bugs in jdbc parse url --- .../jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java index 13be9d538d..97d93fb0a1 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java @@ -179,7 +179,7 @@ public class TSDBDriver implements java.sql.Driver { } //load taos.cfg start - if (info.getProperty(TSDBDriver.PROPERTY_KEY_HOST) == null && info.getProperty(TSDBDriver.PROPERTY_KEY_PORT) == null){ + if (info.getProperty(TSDBDriver.PROPERTY_KEY_HOST) == null && info.getProperty(TSDBDriver.PROPERTY_KEY_PORT) == null) { File cfgDir = loadConfigDir(info.getProperty(TSDBDriver.PROPERTY_KEY_CONFIG_DIR)); File cfgFile = cfgDir.listFiles((dir, name) -> "taos.cfg".equalsIgnoreCase(name))[0]; List endpoints = loadConfigEndpoints(cfgFile); @@ -244,7 +244,7 @@ public class TSDBDriver implements java.sql.Driver { } public boolean acceptsURL(String url) throws SQLException { - return (url != null && url.length() > 0 && url.trim().length() > 0) && url.toLowerCase().startsWith(URL_PREFIX); + return (url != null && url.length() > 0 && url.trim().length() > 0) && url.startsWith(URL_PREFIX); } public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { @@ -291,7 +291,6 @@ public class TSDBDriver implements java.sql.Driver { return null; } -// String lowerUrl = url.toLowerCase(); if (!url.startsWith(URL_PREFIX) && !url.startsWith(URL_PREFIX1)) { return null; } From 1f4d0b0c130c49511155636f32b0d70d23e6e55f Mon Sep 17 00:00:00 2001 From: Hui Li Date: Sun, 27 Sep 2020 13:28:37 +0800 Subject: [PATCH 77/77] [TD-1465] --- cmake/install.inc | 42 ++++++++++++++++------------------- packaging/deb/makedeb.sh | 1 + packaging/rpm/tdengine.spec | 1 + packaging/tools/makeclient.sh | 7 ++++-- packaging/tools/makepkg.sh | 9 +++++--- 5 files changed, 32 insertions(+), 28 deletions(-) diff --git a/cmake/install.inc b/cmake/install.inc index 0531d40048..f5e01e2f1d 100755 --- a/cmake/install.inc +++ b/cmake/install.inc @@ -10,31 +10,27 @@ ELSEIF (TD_WINDOWS) SET(CMAKE_INSTALL_PREFIX C:/TDengine) ENDIF () - IF (NOT TD_GODLL) - #INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/go DESTINATION connector) - #INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/grafana DESTINATION connector) - INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/python DESTINATION connector) - INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/tests/examples DESTINATION .) - INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/packaging/cfg DESTINATION .) - INSTALL(FILES ${TD_COMMUNITY_DIR}/src/inc/taos.h DESTINATION include) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.exp DESTINATION driver) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.dll DESTINATION driver) + INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/go DESTINATION connector) + INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/nodejs DESTINATION connector) + INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/python DESTINATION connector) + INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/tests/examples DESTINATION .) + INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/packaging/cfg DESTINATION .) + INSTALL(FILES ${TD_COMMUNITY_DIR}/src/inc/taos.h DESTINATION include) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.exp DESTINATION driver) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.dll DESTINATION driver) - IF (TD_POWER) - INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/power.exe DESTINATION .) - ELSE () - INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taos.exe DESTINATION .) - ENDIF () + IF (TD_POWER) + INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/power.exe DESTINATION .) + ELSE () + INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taos.exe DESTINATION .) + INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taosdemo.exe DESTINATION .) + ENDIF () - #INSTALL(TARGETS taos RUNTIME DESTINATION driver) - #INSTALL(TARGETS shell RUNTIME DESTINATION .) - IF (TD_MVN_INSTALLED) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.0-dist.jar DESTINATION connector/jdbc) - ENDIF () - ELSE () - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/libtaos.dll DESTINATION driver) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/libtaos.dll.a DESTINATION driver) + #INSTALL(TARGETS taos RUNTIME DESTINATION driver) + #INSTALL(TARGETS shell RUNTIME DESTINATION .) + IF (TD_MVN_INSTALLED) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.0-dist.jar DESTINATION connector/jdbc) ENDIF () ELSEIF (TD_DARWIN) SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh") diff --git a/packaging/deb/makedeb.sh b/packaging/deb/makedeb.sh index f05d7f3414..450c6a8f55 100755 --- a/packaging/deb/makedeb.sh +++ b/packaging/deb/makedeb.sh @@ -57,6 +57,7 @@ cp -r ${top_dir}/tests/examples/* ${pkg_dir}${install_home_pat cp -r ${top_dir}/src/connector/grafanaplugin ${pkg_dir}${install_home_path}/connector cp -r ${top_dir}/src/connector/python ${pkg_dir}${install_home_path}/connector cp -r ${top_dir}/src/connector/go ${pkg_dir}${install_home_path}/connector +cp -r ${top_dir}/src/connector/nodejs ${pkg_dir}${install_home_path}/connector cp ${compile_dir}/build/lib/taos-jdbcdriver*dist.* ${pkg_dir}${install_home_path}/connector cp -r ${compile_dir}/../packaging/deb/DEBIAN ${pkg_dir}/ diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec index a8303c594a..4e40263dc4 100644 --- a/packaging/rpm/tdengine.spec +++ b/packaging/rpm/tdengine.spec @@ -64,6 +64,7 @@ cp %{_compiledir}/../src/inc/taoserror.h %{buildroot}%{homepath}/incl cp -r %{_compiledir}/../src/connector/grafanaplugin %{buildroot}%{homepath}/connector cp -r %{_compiledir}/../src/connector/python %{buildroot}%{homepath}/connector cp -r %{_compiledir}/../src/connector/go %{buildroot}%{homepath}/connector +cp -r %{_compiledir}/../src/connector/nodejs %{buildroot}%{homepath}/connector cp %{_compiledir}/build/lib/taos-jdbcdriver*dist.* %{buildroot}%{homepath}/connector cp -r %{_compiledir}/../tests/examples/* %{buildroot}%{homepath}/examples diff --git a/packaging/tools/makeclient.sh b/packaging/tools/makeclient.sh index 665fb2845c..d69a8e6007 100755 --- a/packaging/tools/makeclient.sh +++ b/packaging/tools/makeclient.sh @@ -97,6 +97,8 @@ if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then cp -r ${examples_dir}/python ${install_dir}/examples cp -r ${examples_dir}/R ${install_dir}/examples cp -r ${examples_dir}/go ${install_dir}/examples + cp -r ${examples_dir}/nodejs ${install_dir}/examples + cp -r ${examples_dir}/C# ${install_dir}/examples fi # Copy driver mkdir -p ${install_dir}/driver @@ -111,8 +113,9 @@ if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then cp ${build_dir}/lib/*.jar ${install_dir}/connector fi cp -r ${connector_dir}/grafanaplugin ${install_dir}/connector/ - cp -r ${connector_dir}/python ${install_dir}/connector/ - cp -r ${connector_dir}/go ${install_dir}/connector + cp -r ${connector_dir}/python ${install_dir}/connector/ + cp -r ${connector_dir}/go ${install_dir}/connector + cp -r ${connector_dir}/nodejs ${install_dir}/connector fi # Copy release note # cp ${script_dir}/release_note ${install_dir} diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index 796f39ccc0..3958cff53b 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -113,6 +113,8 @@ if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then cp -r ${examples_dir}/python ${install_dir}/examples cp -r ${examples_dir}/R ${install_dir}/examples cp -r ${examples_dir}/go ${install_dir}/examples + cp -r ${examples_dir}/nodejs ${install_dir}/examples + cp -r ${examples_dir}/C# ${install_dir}/examples fi # Copy driver mkdir -p ${install_dir}/driver @@ -122,10 +124,11 @@ cp ${lib_files} ${install_dir}/driver connector_dir="${code_dir}/connector" mkdir -p ${install_dir}/connector if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then - cp ${build_dir}/lib/*.jar ${install_dir}/connector + cp ${build_dir}/lib/*.jar ${install_dir}/connector cp -r ${connector_dir}/grafanaplugin ${install_dir}/connector/ - cp -r ${connector_dir}/python ${install_dir}/connector/ - cp -r ${connector_dir}/go ${install_dir}/connector + cp -r ${connector_dir}/python ${install_dir}/connector/ + cp -r ${connector_dir}/go ${install_dir}/connector + cp -r ${connector_dir}/nodejs ${install_dir}/connector fi # Copy release note # cp ${script_dir}/release_note ${install_dir}