diff --git a/src/client/inc/tscSubquery.h b/src/client/inc/tscSubquery.h index 15ef54b7b13eb8463c54a7b979eb6d007560bb0e..f0349c2b3dc5b03b44afdca682f314709ecf6886 100644 --- a/src/client/inc/tscSubquery.h +++ b/src/client/inc/tscSubquery.h @@ -48,6 +48,8 @@ void tscLockByThread(int64_t *lockedBy); void tscUnlockByThread(int64_t *lockedBy); +int tsInsertInitialCheck(SSqlObj *pSql); + #ifdef __cplusplus } #endif diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 2dc99cc319f724e496b5402d1489e72eb474bf27..bf41449e13b08c53ffd8ebe26025229053980776 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -155,13 +155,12 @@ typedef struct STagCond { typedef struct SParamInfo { int32_t idx; - char type; + uint8_t type; uint8_t timePrec; int16_t bytes; uint32_t offset; } SParamInfo; - typedef struct SBoundColumn { bool hasVal; // denote if current column has bound or not int32_t offset; // all column offset value @@ -373,7 +372,8 @@ typedef struct SSqlObj { tsem_t rspSem; SSqlCmd cmd; SSqlRes res; - + bool isBind; + SSubqueryState subState; struct SSqlObj **pSubs; diff --git a/src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h b/src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h index b3060e2c820d7bbb405bf6e96a4bf8af8ed0ec55..04bccc1a4a9e81c8dd9d70521f9916c304df3a53 100644 --- a/src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h +++ b/src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h @@ -100,7 +100,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getResultSetImp /* * Class: com_taosdata_jdbc_TSDBJNIConnector * Method: isUpdateQueryImp - * Signature: (J)J + * Signature: (JJ)I */ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_isUpdateQueryImp (JNIEnv *env, jobject jobj, jlong con, jlong tres); @@ -185,6 +185,44 @@ JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_unsubscribeImp JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTableSqlImp (JNIEnv *, jobject, jlong, jbyteArray); +/* + * Class: com_taosdata_jdbc_TSDBJNIConnector + * Method: prepareStmtImp + * Signature: ([BJ)I + */ +JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_prepareStmtImp + (JNIEnv *, jobject, jbyteArray, jlong); + +/* + * Class: com_taosdata_jdbc_TSDBJNIConnector + * Method: setBindTableNameImp + * Signature: (JLjava/lang/String;J)I + */ +JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setBindTableNameImp + (JNIEnv *, jobject, jlong, jstring, jlong); + +/* + * Class: com_taosdata_jdbc_TSDBJNIConnector + * Method: bindColDataImp + * Signature: (J[B[B[BIIIIJ)J + */ +JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_bindColDataImp +(JNIEnv *, jobject, jlong, jbyteArray, jbyteArray, jbyteArray, jint, jint, jint, jint, jlong); + +/* + * Class: com_taosdata_jdbc_TSDBJNIConnector + * Method: executeBatchImp + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeBatchImp(JNIEnv *env, jobject jobj, jlong stmt, jlong con); + +/* + * Class: com_taosdata_jdbc_TSDBJNIConnector + * Method: executeBatchImp + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_closeStmt(JNIEnv *env, jobject jobj, jlong stmt, jlong con); + #ifdef __cplusplus } #endif diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index 7447e36ac9cf1074db0c62077be07b6a41a99256..da7da17aa3ee29b31acbe2470edf052f1d9cb15b 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -687,4 +687,194 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TDDBJNIConnector_getResultTimePrec } return taos_result_precision(result); -} \ No newline at end of file +} + +JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_prepareStmtImp(JNIEnv *env, jobject jobj, jbyteArray jsql, jlong con) { + TAOS *tscon = (TAOS *)con; + if (tscon == NULL) { + jniError("jobj:%p, connection already closed", jobj); + return JNI_CONNECTION_NULL; + } + + if (jsql == NULL) { + jniError("jobj:%p, conn:%p, empty sql string", jobj, tscon); + return JNI_SQL_NULL; + } + + jsize len = (*env)->GetArrayLength(env, jsql); + + char *str = (char *) calloc(1, sizeof(char) * (len + 1)); + if (str == NULL) { + jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon); + return JNI_OUT_OF_MEMORY; + } + + (*env)->GetByteArrayRegion(env, jsql, 0, len, (jbyte *)str); + if ((*env)->ExceptionCheck(env)) { + // todo handle error + } + + TAOS_STMT* pStmt = taos_stmt_init(tscon); + int32_t code = taos_stmt_prepare(pStmt, str, len); + if (code != TSDB_CODE_SUCCESS) { + jniError("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code)); + return JNI_TDENGINE_ERROR; + } + + free(str); + return (jlong) pStmt; +} + +JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setBindTableNameImp(JNIEnv *env, jobject jobj, jlong stmt, jstring jname, jlong conn) { + TAOS *tsconn = (TAOS *)conn; + if (tsconn == NULL) { + jniError("jobj:%p, connection already closed", jobj); + return JNI_CONNECTION_NULL; + } + + TAOS_STMT* pStmt = (TAOS_STMT*) stmt; + if (pStmt == NULL) { + jniError("jobj:%p, conn:%p, invalid stmt handle", jobj, tsconn); + return JNI_SQL_NULL; + } + + const char *name = (*env)->GetStringUTFChars(env, jname, NULL); + + int32_t code = taos_stmt_set_tbname((void*)stmt, name); + if (code != TSDB_CODE_SUCCESS) { + (*env)->ReleaseStringUTFChars(env, jname, name); + + jniError("jobj:%p, conn:%p, code:%s", jobj, tsconn, tstrerror(code)); + return JNI_TDENGINE_ERROR; + } + + jniDebug("jobj:%p, conn:%p, set stmt bind table name:%s", jobj, tsconn, name); + + (*env)->ReleaseStringUTFChars(env, jname, name); + return JNI_SUCCESS; +} + +JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_bindColDataImp(JNIEnv *env, jobject jobj, jlong stmt, + jbyteArray colDataList, jbyteArray lengthList, jbyteArray nullList, jint dataType, jint dataBytes, jint numOfRows, jint colIndex, jlong con) { + TAOS *tscon = (TAOS *)con; + if (tscon == NULL) { + jniError("jobj:%p, connection already closed", jobj); + return JNI_CONNECTION_NULL; + } + + TAOS_STMT* pStmt = (TAOS_STMT*) stmt; + if (pStmt == NULL) { + jniError("jobj:%p, conn:%p, invalid stmt", jobj, tscon); + return JNI_SQL_NULL; + } + + // todo refactor + jsize len = (*env)->GetArrayLength(env, colDataList); + char *colBuf = (char *)calloc(1, len); + (*env)->GetByteArrayRegion(env, colDataList, 0, len, (jbyte *)colBuf); + if ((*env)->ExceptionCheck(env)) { + // todo handle error + } + + len = (*env)->GetArrayLength(env, lengthList); + char *lengthArray = (char*) calloc(1, len); + (*env)->GetByteArrayRegion(env, lengthList, 0, len, (jbyte*) lengthArray); + if ((*env)->ExceptionCheck(env)) { + } + + len = (*env)->GetArrayLength(env, nullList); + char *nullArray = (char*) calloc(1, len); + (*env)->GetByteArrayRegion(env, nullList, 0, len, (jbyte*) nullArray); + if ((*env)->ExceptionCheck(env)) { + } + + // bind multi-rows with only one invoke. + TAOS_MULTI_BIND* b = calloc(1, sizeof(TAOS_MULTI_BIND)); + + b->num = numOfRows; + b->buffer_type = dataType; // todo check data type + b->buffer_length = IS_VAR_DATA_TYPE(dataType)? dataBytes:tDataTypes[dataType].bytes; + b->is_null = nullArray; + b->buffer = colBuf; + b->length = (int32_t*)lengthArray; + + // set the length and is_null array + switch(dataType) { + case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_BIGINT: { + int32_t bytes = tDataTypes[dataType].bytes; + for(int32_t i = 0; i < numOfRows; ++i) { + b->length[i] = bytes; + } + break; + } + + case TSDB_DATA_TYPE_NCHAR: + case TSDB_DATA_TYPE_BINARY: { + // do nothing + } + } + + int32_t code = taos_stmt_bind_single_param_batch(pStmt, b, colIndex); + tfree(b->length); + tfree(b->buffer); + tfree(b->is_null); + tfree(b); + + if (code != TSDB_CODE_SUCCESS) { + jniError("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code)); + return JNI_TDENGINE_ERROR; + } + + return JNI_SUCCESS; +} + +JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeBatchImp(JNIEnv *env, jobject jobj, jlong stmt, jlong con) { + TAOS *tscon = (TAOS *)con; + if (tscon == NULL) { + jniError("jobj:%p, connection already closed", jobj); + return JNI_CONNECTION_NULL; + } + + TAOS_STMT *pStmt = (TAOS_STMT*) stmt; + if (pStmt == NULL) { + jniError("jobj:%p, conn:%p, invalid stmt", jobj, tscon); + return JNI_SQL_NULL; + } + + taos_stmt_add_batch(pStmt); + int32_t code = taos_stmt_execute(pStmt); + if (code != TSDB_CODE_SUCCESS) { + jniError("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code)); + return JNI_TDENGINE_ERROR; + } + + jniDebug("jobj:%p, conn:%p, batch execute", jobj, tscon); + return JNI_SUCCESS; +} + +JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_closeStmt(JNIEnv *env, jobject jobj, jlong stmt, jlong con) { + TAOS *tscon = (TAOS *)con; + if (tscon == NULL) { + jniError("jobj:%p, connection already closed", jobj); + return JNI_CONNECTION_NULL; + } + + TAOS_STMT *pStmt = (TAOS_STMT*) stmt; + if (pStmt == NULL) { + jniError("jobj:%p, conn:%p, invalid stmt", jobj, tscon); + return JNI_SQL_NULL; + } + + int32_t code = taos_stmt_close(pStmt); + if (code != TSDB_CODE_SUCCESS) { + jniError("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code)); + return JNI_TDENGINE_ERROR; + } + + jniDebug("jobj:%p, conn:%p, stmt closed", jobj, tscon); + return JNI_SUCCESS; +} diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index a7882ffa6186224e30cbbdfb84ff5300131e479e..6b55780af93554446f7f0599fe267e42e258ae81 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -326,6 +326,7 @@ TAOS_ROW tscFetchRow(void *param) { pCmd->command == TSDB_SQL_FETCH || pCmd->command == TSDB_SQL_SHOW || pCmd->command == TSDB_SQL_SHOW_CREATE_TABLE || + pCmd->command == TSDB_SQL_SHOW_CREATE_STABLE || pCmd->command == TSDB_SQL_SHOW_CREATE_DATABASE || pCmd->command == TSDB_SQL_SELECT || pCmd->command == TSDB_SQL_DESCRIBE_TABLE || @@ -679,6 +680,9 @@ static int32_t tscProcessShowCreateTable(SSqlObj *pSql) { assert(pTableMetaInfo->pTableMeta != NULL); const char* tableName = tNameGetTableName(&pTableMetaInfo->name); + if (pSql->cmd.command == TSDB_SQL_SHOW_CREATE_STABLE && !UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { + return TSDB_CODE_TSC_INVALID_VALUE; + } char *result = (char *)calloc(1, TSDB_MAX_BINARY_LEN); int32_t code = TSDB_CODE_SUCCESS; @@ -907,7 +911,7 @@ int tscProcessLocalCmd(SSqlObj *pSql) { */ pRes->qId = 0x1; pRes->numOfRows = 0; - } else if (pCmd->command == TSDB_SQL_SHOW_CREATE_TABLE) { + } else if (pCmd->command == TSDB_SQL_SHOW_CREATE_TABLE || pCmd->command == TSDB_SQL_SHOW_CREATE_STABLE) { pRes->code = tscProcessShowCreateTable(pSql); } else if (pCmd->command == TSDB_SQL_SHOW_CREATE_DATABASE) { pRes->code = tscProcessShowCreateDatabase(pSql); diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 9fb19c6d4f7672302f1f6c90c99ce75bacf8fb57..0fad4f97f5056301893e35df91a32735c628c789 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -385,7 +385,7 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha * The server time/client time should not be mixed up in one sql string * Do not employ sort operation is not involved if server time is used. */ -static int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start) { +int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start) { // once the data block is disordered, we do NOT keep previous timestamp any more if (!pDataBlocks->ordered) { return TSDB_CODE_SUCCESS; @@ -410,6 +410,7 @@ static int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start if (k <= pDataBlocks->prevTS && (pDataBlocks->tsSource == TSDB_USE_CLI_TS)) { pDataBlocks->ordered = false; + tscWarn("NOT ordered input timestamp"); } pDataBlocks->prevTS = k; @@ -693,6 +694,8 @@ void tscSortRemoveDataBlockDupRows(STableDataBlocks *dataBuf) { pBlocks->numOfRows = i + 1; dataBuf->size = sizeof(SSubmitBlk) + dataBuf->rowSize * pBlocks->numOfRows; } + + dataBuf->prevTS = INT64_MIN; } static int32_t doParseInsertStatement(SSqlCmd* pCmd, char **str, STableDataBlocks* dataBuf, int32_t *totalNum) { @@ -1290,7 +1293,7 @@ int tsParseInsertSql(SSqlObj *pSql) { goto _clean; } - if (taosHashGetSize(pCmd->pTableBlockHashList) > 0) { // merge according to vgId + if ((pCmd->insertType != TSDB_QUERY_TYPE_STMT_INSERT) && taosHashGetSize(pCmd->pTableBlockHashList) > 0) { // merge according to vgId if ((code = tscMergeTableDataBlocks(pSql, true)) != TSDB_CODE_SUCCESS) { goto _clean; } diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index f66c8cf52c87135f22c67656e86f8ef1402a0cad..dc1bc35fc09a0852ca37493aeeef2e1692f55faf 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -24,6 +24,7 @@ #include "tscSubquery.h" int tsParseInsertSql(SSqlObj *pSql); +int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start); //////////////////////////////////////////////////////////////////////////////// // functions for normal statement preparation @@ -43,10 +44,32 @@ typedef struct SNormalStmt { tVariant* params; } SNormalStmt; +typedef struct SMultiTbStmt { + bool nameSet; + uint64_t currentUid; + uint32_t tbNum; + SStrToken tbname; + SHashObj *pTableHash; + SHashObj *pTableBlockHashList; // data block for each table +} SMultiTbStmt; + +typedef enum { + STMT_INIT = 1, + STMT_PREPARE, + STMT_SETTBNAME, + STMT_BIND, + STMT_BIND_COL, + STMT_ADD_BATCH, + STMT_EXECUTE +} STMT_ST; + typedef struct STscStmt { bool isInsert; + bool multiTbInsert; + int16_t last; STscObj* taos; SSqlObj* pSql; + SMultiTbStmt mtb; SNormalStmt normal; } STscStmt; @@ -135,7 +158,7 @@ static int normalStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) { break; default: - tscDebug("param %d: type mismatch or invalid", i); + tscDebug("0x%"PRIx64" bind column%d: type mismatch or invalid", stmt->pSql->self, i); return TSDB_CODE_TSC_INVALID_VALUE; } } @@ -255,12 +278,13 @@ static char* normalStmtBuildSql(STscStmt* stmt) { //////////////////////////////////////////////////////////////////////////////// // functions for insertion statement preparation -static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) { +static int doBindParam(STableDataBlocks* pBlock, char* data, SParamInfo* param, TAOS_BIND* bind, int32_t colNum) { if (bind->is_null != NULL && *(bind->is_null)) { setNull(data + param->offset, param->type, param->bytes); return TSDB_CODE_SUCCESS; } +#if 0 if (0) { // allow user bind param data with different type union { @@ -641,6 +665,7 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) { } } } +#endif if (bind->buffer_type != param->type) { return TSDB_CODE_TSC_INVALID_VALUE; @@ -690,29 +715,106 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) { } memcpy(data + param->offset, bind->buffer, size); + if (param->offset == 0) { + if (tsCheckTimestamp(pBlock, data + param->offset) != TSDB_CODE_SUCCESS) { + tscError("invalid timestamp"); + return TSDB_CODE_TSC_INVALID_VALUE; + } + } + return TSDB_CODE_SUCCESS; } -static int insertStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) { - SSqlCmd* pCmd = &stmt->pSql->cmd; - STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, 0, 0); +static int doBindBatchParam(STableDataBlocks* pBlock, SParamInfo* param, TAOS_MULTI_BIND* bind, int32_t rowNum) { + if (bind->buffer_type != param->type || !isValidDataType(param->type)) { + return TSDB_CODE_TSC_INVALID_VALUE; + } - STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; - if (pCmd->pTableBlockHashList == NULL) { - pCmd->pTableBlockHashList = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false); + if (IS_VAR_DATA_TYPE(param->type) && bind->length == NULL) { + tscError("BINARY/NCHAR no length"); + return TSDB_CODE_TSC_INVALID_VALUE; + } + + for (int i = 0; i < bind->num; ++i) { + char* data = pBlock->pData + sizeof(SSubmitBlk) + pBlock->rowSize * (rowNum + i); + + if (bind->is_null != NULL && bind->is_null[i]) { + setNull(data + param->offset, param->type, param->bytes); + continue; + } + + if (!IS_VAR_DATA_TYPE(param->type)) { + memcpy(data + param->offset, (char *)bind->buffer + bind->buffer_length * i, tDataTypes[param->type].bytes); + + if (param->offset == 0) { + if (tsCheckTimestamp(pBlock, data + param->offset) != TSDB_CODE_SUCCESS) { + tscError("invalid timestamp"); + return TSDB_CODE_TSC_INVALID_VALUE; + } + } + } else if (param->type == TSDB_DATA_TYPE_BINARY) { + if (bind->length[i] > (uintptr_t)param->bytes) { + tscError("binary length too long, ignore it, max:%d, actual:%d", param->bytes, (int32_t)bind->length[i]); + return TSDB_CODE_TSC_INVALID_VALUE; + } + int16_t bsize = (short)bind->length[i]; + STR_WITH_SIZE_TO_VARSTR(data + param->offset, (char *)bind->buffer + bind->buffer_length * i, bsize); + } else if (param->type == TSDB_DATA_TYPE_NCHAR) { + if (bind->length[i] > (uintptr_t)param->bytes) { + tscError("nchar string length too long, ignore it, max:%d, actual:%d", param->bytes, (int32_t)bind->length[i]); + return TSDB_CODE_TSC_INVALID_VALUE; + } + + int32_t output = 0; + if (!taosMbsToUcs4((char *)bind->buffer + bind->buffer_length * i, bind->length[i], varDataVal(data + param->offset), param->bytes - VARSTR_HEADER_SIZE, &output)) { + tscError("convert nchar string to UCS4_LE failed:%s", (char*)((char *)bind->buffer + bind->buffer_length * i)); + return TSDB_CODE_TSC_INVALID_VALUE; + } + + varDataSetLen(data + param->offset, output); + } } + + return TSDB_CODE_SUCCESS; +} +static int insertStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) { + SSqlCmd* pCmd = &stmt->pSql->cmd; + STscStmt* pStmt = (STscStmt*)stmt; + STableDataBlocks* pBlock = NULL; + + if (pStmt->multiTbInsert) { + if (pCmd->pTableBlockHashList == NULL) { + tscError("0x%"PRIx64" Table block hash list is empty", pStmt->pSql->self); + return TSDB_CODE_TSC_APP_ERROR; + } + + STableDataBlocks** t1 = (STableDataBlocks**)taosHashGet(pCmd->pTableBlockHashList, (const char*)&pStmt->mtb.currentUid, sizeof(pStmt->mtb.currentUid)); + if (t1 == NULL) { + tscError("0x%"PRIx64" no table data block in hash list, uid:%" PRId64 , pStmt->pSql->self, pStmt->mtb.currentUid); + return TSDB_CODE_TSC_APP_ERROR; + } - int32_t ret = - tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_PAYLOAD_SIZE, sizeof(SSubmitBlk), - pTableMeta->tableInfo.rowSize, &pTableMetaInfo->name, pTableMeta, &pBlock, NULL); - if (ret != 0) { - // todo handle error + pBlock = *t1; + } else { + STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, 0, 0); + + STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; + if (pCmd->pTableBlockHashList == NULL) { + pCmd->pTableBlockHashList = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false); + } + + int32_t ret = + tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_PAYLOAD_SIZE, sizeof(SSubmitBlk), + pTableMeta->tableInfo.rowSize, &pTableMetaInfo->name, pTableMeta, &pBlock, NULL); + if (ret != 0) { + return ret; + } } - uint32_t totalDataSize = sizeof(SSubmitBlk) + pCmd->batchSize * pBlock->rowSize; + uint32_t totalDataSize = sizeof(SSubmitBlk) + (pCmd->batchSize + 1) * pBlock->rowSize; if (totalDataSize > pBlock->nAllocSize) { const double factor = 1.5; @@ -729,9 +831,9 @@ static int insertStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) { for (uint32_t j = 0; j < pBlock->numOfParams; ++j) { SParamInfo* param = &pBlock->params[j]; - int code = doBindParam(data, param, &bind[param->idx]); + int code = doBindParam(pBlock, data, param, &bind[param->idx], 1); if (code != TSDB_CODE_SUCCESS) { - tscDebug("param %d: type mismatch or invalid", param->idx); + tscDebug("0x%"PRIx64" bind column %d: type mismatch or invalid", pStmt->pSql->self, param->idx); return code; } } @@ -739,9 +841,135 @@ static int insertStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) { return TSDB_CODE_SUCCESS; } + +static int insertStmtBindParamBatch(STscStmt* stmt, TAOS_MULTI_BIND* bind, int colIdx) { + SSqlCmd* pCmd = &stmt->pSql->cmd; + STscStmt* pStmt = (STscStmt*)stmt; + int rowNum = bind->num; + + STableDataBlocks* pBlock = NULL; + + if (pStmt->multiTbInsert) { + if (pCmd->pTableBlockHashList == NULL) { + tscError("0x%"PRIx64" Table block hash list is empty", pStmt->pSql->self); + return TSDB_CODE_TSC_APP_ERROR; + } + + STableDataBlocks** t1 = (STableDataBlocks**)taosHashGet(pCmd->pTableBlockHashList, (const char*)&pStmt->mtb.currentUid, sizeof(pStmt->mtb.currentUid)); + if (t1 == NULL) { + tscError("0x%"PRIx64" no table data block in hash list, uid:%" PRId64 , pStmt->pSql->self, pStmt->mtb.currentUid); + return TSDB_CODE_TSC_APP_ERROR; + } + + pBlock = *t1; + } else { + STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, 0, 0); + + STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; + if (pCmd->pTableBlockHashList == NULL) { + pCmd->pTableBlockHashList = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false); + } + + int32_t ret = + tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_PAYLOAD_SIZE, sizeof(SSubmitBlk), + pTableMeta->tableInfo.rowSize, &pTableMetaInfo->name, pTableMeta, &pBlock, NULL); + if (ret != 0) { + return ret; + } + } + + assert(colIdx == -1 || (colIdx >= 0 && colIdx < pBlock->numOfParams)); + + uint32_t totalDataSize = sizeof(SSubmitBlk) + (pCmd->batchSize + rowNum) * pBlock->rowSize; + if (totalDataSize > pBlock->nAllocSize) { + const double factor = 1.5; + + void* tmp = realloc(pBlock->pData, (uint32_t)(totalDataSize * factor)); + if (tmp == NULL) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + pBlock->pData = (char*)tmp; + pBlock->nAllocSize = (uint32_t)(totalDataSize * factor); + } + + if (colIdx == -1) { + for (uint32_t j = 0; j < pBlock->numOfParams; ++j) { + SParamInfo* param = &pBlock->params[j]; + if (bind[param->idx].num != rowNum) { + tscError("0x%"PRIx64" param %d: num[%d:%d] not match", pStmt->pSql->self, param->idx, rowNum, bind[param->idx].num); + return TSDB_CODE_TSC_INVALID_VALUE; + } + + int code = doBindBatchParam(pBlock, param, &bind[param->idx], pCmd->batchSize); + if (code != TSDB_CODE_SUCCESS) { + tscError("0x%"PRIx64" bind column %d: type mismatch or invalid", pStmt->pSql->self, param->idx); + return code; + } + } + + pCmd->batchSize += rowNum - 1; + } else { + SParamInfo* param = &pBlock->params[colIdx]; + + int code = doBindBatchParam(pBlock, param, bind, pCmd->batchSize); + if (code != TSDB_CODE_SUCCESS) { + tscError("0x%"PRIx64" bind column %d: type mismatch or invalid", pStmt->pSql->self, param->idx); + return code; + } + + if (colIdx == (pBlock->numOfParams - 1)) { + pCmd->batchSize += rowNum - 1; + } + } + + return TSDB_CODE_SUCCESS; +} + + +static int insertStmtUpdateBatch(STscStmt* stmt) { + SSqlObj* pSql = stmt->pSql; + SSqlCmd* pCmd = &pSql->cmd; + STableDataBlocks* pBlock = NULL; + + if (pCmd->batchSize > INT16_MAX) { + tscError("too many record:%d", pCmd->batchSize); + return TSDB_CODE_TSC_APP_ERROR; + } + + assert(pCmd->numOfClause == 1); + if (taosHashGetSize(pCmd->pTableBlockHashList) == 0) { + return TSDB_CODE_SUCCESS; + } + + STableDataBlocks** t1 = (STableDataBlocks**)taosHashGet(pCmd->pTableBlockHashList, (const char*)&stmt->mtb.currentUid, sizeof(stmt->mtb.currentUid)); + if (t1 == NULL) { + tscError("0x%"PRIx64" no table data block in hash list, uid:%" PRId64 , pSql->self, stmt->mtb.currentUid); + return TSDB_CODE_TSC_APP_ERROR; + } + + pBlock = *t1; + + STableMeta* pTableMeta = pBlock->pTableMeta; + + pBlock->size = sizeof(SSubmitBlk) + pCmd->batchSize * pBlock->rowSize; + SSubmitBlk* pBlk = (SSubmitBlk*) pBlock->pData; + pBlk->numOfRows = pCmd->batchSize; + pBlk->dataLen = 0; + pBlk->uid = pTableMeta->id.uid; + pBlk->tid = pTableMeta->id.tid; + + return TSDB_CODE_SUCCESS; +} + static int insertStmtAddBatch(STscStmt* stmt) { SSqlCmd* pCmd = &stmt->pSql->cmd; ++pCmd->batchSize; + + if (stmt->multiTbInsert) { + return insertStmtUpdateBatch(stmt); + } + return TSDB_CODE_SUCCESS; } @@ -835,6 +1063,83 @@ static int insertStmtExecute(STscStmt* stmt) { return pSql->res.code; } +static void insertBatchClean(STscStmt* pStmt) { + SSqlCmd *pCmd = &pStmt->pSql->cmd; + SSqlObj *pSql = pStmt->pSql; + int32_t size = taosHashGetSize(pCmd->pTableBlockHashList); + + // data block reset + pCmd->batchSize = 0; + + for(int32_t i = 0; i < size; ++i) { + if (pCmd->pTableNameList && pCmd->pTableNameList[i]) { + tfree(pCmd->pTableNameList[i]); + } + } + + tfree(pCmd->pTableNameList); + +/* + STableDataBlocks** p = taosHashIterate(pCmd->pTableBlockHashList, NULL); + + STableDataBlocks* pOneTableBlock = *p; + + while (1) { + SSubmitBlk* pBlocks = (SSubmitBlk*) pOneTableBlock->pData; + + pOneTableBlock->size = sizeof(SSubmitBlk); + + pBlocks->numOfRows = 0; + + p = taosHashIterate(pCmd->pTableBlockHashList, p); + if (p == NULL) { + break; + } + + pOneTableBlock = *p; + } +*/ + + pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks); + pCmd->numOfTables = 0; + + taosHashEmpty(pCmd->pTableBlockHashList); + tscFreeSqlResult(pSql); + tscFreeSubobj(pSql); + tfree(pSql->pSubs); + pSql->subState.numOfSub = 0; +} + +static int insertBatchStmtExecute(STscStmt* pStmt) { + int32_t code = 0; + + if(pStmt->mtb.nameSet == false) { + tscError("0x%"PRIx64" no table name set", pStmt->pSql->self); + return TSDB_CODE_TSC_APP_ERROR; + } + + pStmt->pSql->retry = pStmt->pSql->maxRetry + 1; //no retry + + if (taosHashGetSize(pStmt->pSql->cmd.pTableBlockHashList) > 0) { // merge according to vgId + if ((code = tscMergeTableDataBlocks(pStmt->pSql, false)) != TSDB_CODE_SUCCESS) { + return code; + } + } + + code = tscHandleMultivnodeInsert(pStmt->pSql); + + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + // wait for the callback function to post the semaphore + tsem_wait(&pStmt->pSql->rspSem); + + insertBatchClean(pStmt); + + return pStmt->pSql->res.code; +} + //////////////////////////////////////////////////////////////////////////////// // interface functions @@ -866,7 +1171,9 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) { pSql->signature = pSql; pSql->pTscObj = pObj; pSql->maxRetry = TSDB_MAX_REPLICA; + pSql->isBind = true; pStmt->pSql = pSql; + pStmt->last = STMT_INIT; return pStmt; } @@ -879,6 +1186,13 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { return TSDB_CODE_TSC_DISCONNECTED; } + if (pStmt->last != STMT_INIT) { + tscError("prepare status error, last:%d", pStmt->last); + return TSDB_CODE_TSC_APP_ERROR; + } + + pStmt->last = STMT_PREPARE; + SSqlObj* pSql = pStmt->pSql; size_t sqlLen = strlen(sql); @@ -917,6 +1231,36 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { registerSqlObj(pSql); + int32_t ret = TSDB_CODE_SUCCESS; + + if ((ret = tsInsertInitialCheck(pSql)) != TSDB_CODE_SUCCESS) { + return ret; + } + + int32_t index = 0; + SStrToken sToken = tStrGetToken(pCmd->curSql, &index, false); + + if (sToken.n == 0) { + return TSDB_CODE_TSC_INVALID_SQL; + } + + if (sToken.n == 1 && sToken.type == TK_QUESTION) { + pStmt->multiTbInsert = true; + pStmt->mtb.tbname = sToken; + pStmt->mtb.nameSet = false; + if (pStmt->mtb.pTableHash == NULL) { + pStmt->mtb.pTableHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + } + if (pStmt->mtb.pTableBlockHashList == NULL) { + pStmt->mtb.pTableBlockHashList = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false); + } + + return TSDB_CODE_SUCCESS; + } + + pStmt->multiTbInsert = false; + memset(&pStmt->mtb, 0, sizeof(pStmt->mtb)); + int32_t code = tsParseSql(pSql, true); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { // wait for the callback function to post the semaphore @@ -931,6 +1275,105 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { return normalStmtPrepare(pStmt); } + +int taos_stmt_set_tbname(TAOS_STMT* stmt, const char* name) { + STscStmt* pStmt = (STscStmt*)stmt; + SSqlObj* pSql = pStmt->pSql; + SSqlCmd* pCmd = &pSql->cmd; + + if (stmt == NULL || pStmt->pSql == NULL || pStmt->taos == NULL) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return TSDB_CODE_TSC_DISCONNECTED; + } + + if (name == NULL) { + terrno = TSDB_CODE_TSC_APP_ERROR; + tscError("0x%"PRIx64" name is NULL", pSql->self); + return TSDB_CODE_TSC_APP_ERROR; + } + + if (pStmt->multiTbInsert == false || !tscIsInsertData(pSql->sqlstr)) { + terrno = TSDB_CODE_TSC_APP_ERROR; + tscError("0x%"PRIx64" not multi table insert", pSql->self); + return TSDB_CODE_TSC_APP_ERROR; + } + + if (pStmt->last == STMT_INIT || pStmt->last == STMT_BIND || pStmt->last == STMT_BIND_COL) { + tscError("0x%"PRIx64" settbname status error, last:%d", pSql->self, pStmt->last); + return TSDB_CODE_TSC_APP_ERROR; + } + + pStmt->last = STMT_SETTBNAME; + + uint64_t* uid = (uint64_t*)taosHashGet(pStmt->mtb.pTableHash, name, strlen(name)); + if (uid != NULL) { + pStmt->mtb.currentUid = *uid; + + STableDataBlocks** t1 = (STableDataBlocks**)taosHashGet(pStmt->mtb.pTableBlockHashList, (const char*)&pStmt->mtb.currentUid, sizeof(pStmt->mtb.currentUid)); + if (t1 == NULL) { + tscError("0x%"PRIx64" no table data block in hash list, uid:%" PRId64 , pSql->self, pStmt->mtb.currentUid); + return TSDB_CODE_TSC_APP_ERROR; + } + + SSubmitBlk* pBlk = (SSubmitBlk*) (*t1)->pData; + pCmd->batchSize = pBlk->numOfRows; + + taosHashPut(pCmd->pTableBlockHashList, (void *)&pStmt->mtb.currentUid, sizeof(pStmt->mtb.currentUid), (void*)t1, POINTER_BYTES); + + tscDebug("0x%"PRIx64" table:%s is already prepared, uid:%" PRIu64, pSql->self, name, pStmt->mtb.currentUid); + return TSDB_CODE_SUCCESS; + } + + pStmt->mtb.tbname = tscReplaceStrToken(&pSql->sqlstr, &pStmt->mtb.tbname, name); + pStmt->mtb.nameSet = true; + + tscDebug("0x%"PRIx64" SQL: %s", pSql->self, pSql->sqlstr); + + pSql->cmd.parseFinished = 0; + pSql->cmd.numOfParams = 0; + pSql->cmd.batchSize = 0; + + if (taosHashGetSize(pCmd->pTableBlockHashList) > 0) { + SHashObj* hashList = pCmd->pTableBlockHashList; + pCmd->pTableBlockHashList = NULL; + tscResetSqlCmd(pCmd, true); + pCmd->pTableBlockHashList = hashList; + } + + int32_t code = tsParseSql(pStmt->pSql, true); + if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { + // wait for the callback function to post the semaphore + tsem_wait(&pStmt->pSql->rspSem); + + code = pStmt->pSql->res.code; + } + + if (code == TSDB_CODE_SUCCESS) { + STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, 0, 0); + STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; + STableDataBlocks* pBlock = NULL; + code = tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_PAYLOAD_SIZE, sizeof(SSubmitBlk), + pTableMeta->tableInfo.rowSize, &pTableMetaInfo->name, pTableMeta, &pBlock, NULL); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + SSubmitBlk* blk = (SSubmitBlk*)pBlock->pData; + blk->numOfRows = 0; + + pStmt->mtb.currentUid = pTableMeta->id.uid; + pStmt->mtb.tbNum++; + + taosHashPut(pStmt->mtb.pTableBlockHashList, (void *)&pStmt->mtb.currentUid, sizeof(pStmt->mtb.currentUid), (void*)&pBlock, POINTER_BYTES); + + taosHashPut(pStmt->mtb.pTableHash, name, strlen(name), (char*) &pTableMeta->id.uid, sizeof(pTableMeta->id.uid)); + + tscDebug("0x%"PRIx64" table:%s is prepared, uid:%" PRIx64, pSql->self, name, pStmt->mtb.currentUid); + } + + return code; +} + int taos_stmt_close(TAOS_STMT* stmt) { STscStmt* pStmt = (STscStmt*)stmt; if (!pStmt->isInsert) { @@ -943,6 +1386,13 @@ int taos_stmt_close(TAOS_STMT* stmt) { } free(normal->parts); free(normal->sql); + } else { + if (pStmt->multiTbInsert) { + taosHashCleanup(pStmt->mtb.pTableHash); + pStmt->mtb.pTableBlockHashList = tscDestroyBlockHashTable(pStmt->mtb.pTableBlockHashList, true); + taosHashCleanup(pStmt->pSql->cmd.pTableBlockHashList); + pStmt->pSql->cmd.pTableBlockHashList = NULL; + } } taos_free_result(pStmt->pSql); @@ -952,18 +1402,122 @@ int taos_stmt_close(TAOS_STMT* stmt) { int taos_stmt_bind_param(TAOS_STMT* stmt, TAOS_BIND* bind) { STscStmt* pStmt = (STscStmt*)stmt; + if (stmt == NULL || pStmt->pSql == NULL || pStmt->taos == NULL) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return TSDB_CODE_TSC_DISCONNECTED; + } + if (pStmt->isInsert) { + if (pStmt->multiTbInsert) { + if (pStmt->last != STMT_SETTBNAME && pStmt->last != STMT_ADD_BATCH) { + tscError("0x%"PRIx64" bind param status error, last:%d", pStmt->pSql->self, pStmt->last); + return TSDB_CODE_TSC_APP_ERROR; + } + } else { + if (pStmt->last != STMT_PREPARE && pStmt->last != STMT_ADD_BATCH && pStmt->last != STMT_EXECUTE) { + tscError("0x%"PRIx64" bind param status error, last:%d", pStmt->pSql->self, pStmt->last); + return TSDB_CODE_TSC_APP_ERROR; + } + } + + pStmt->last = STMT_BIND; + return insertStmtBindParam(pStmt, bind); } else { return normalStmtBindParam(pStmt, bind); } } + +int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind) { + STscStmt* pStmt = (STscStmt*)stmt; + + if (stmt == NULL || pStmt->pSql == NULL || pStmt->taos == NULL) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return TSDB_CODE_TSC_DISCONNECTED; + } + + if (bind == NULL || bind->num <= 0 || bind->num > INT16_MAX) { + tscError("0x%"PRIx64" invalid parameter", pStmt->pSql->self); + return TSDB_CODE_TSC_APP_ERROR; + } + + if (!pStmt->isInsert) { + tscError("0x%"PRIx64" not or invalid batch insert", pStmt->pSql->self); + return TSDB_CODE_TSC_APP_ERROR; + } + + if (pStmt->multiTbInsert) { + if (pStmt->last != STMT_SETTBNAME && pStmt->last != STMT_ADD_BATCH) { + tscError("0x%"PRIx64" bind param status error, last:%d", pStmt->pSql->self, pStmt->last); + return TSDB_CODE_TSC_APP_ERROR; + } + } else { + if (pStmt->last != STMT_PREPARE && pStmt->last != STMT_ADD_BATCH && pStmt->last != STMT_EXECUTE) { + tscError("0x%"PRIx64" bind param status error, last:%d", pStmt->pSql->self, pStmt->last); + return TSDB_CODE_TSC_APP_ERROR; + } + } + + pStmt->last = STMT_BIND; + + return insertStmtBindParamBatch(pStmt, bind, -1); +} + +int taos_stmt_bind_single_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int colIdx) { + STscStmt* pStmt = (STscStmt*)stmt; + if (stmt == NULL || pStmt->pSql == NULL || pStmt->taos == NULL) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return TSDB_CODE_TSC_DISCONNECTED; + } + + if (bind == NULL || bind->num <= 0 || bind->num > INT16_MAX) { + tscError("0x%"PRIx64" invalid parameter", pStmt->pSql->self); + return TSDB_CODE_TSC_APP_ERROR; + } + + if (!pStmt->isInsert) { + tscError("0x%"PRIx64" not or invalid batch insert", pStmt->pSql->self); + return TSDB_CODE_TSC_APP_ERROR; + } + + if (pStmt->multiTbInsert) { + if (pStmt->last != STMT_SETTBNAME && pStmt->last != STMT_ADD_BATCH && pStmt->last != STMT_BIND_COL) { + tscError("0x%"PRIx64" bind param status error, last:%d", pStmt->pSql->self, pStmt->last); + return TSDB_CODE_TSC_APP_ERROR; + } + } else { + if (pStmt->last != STMT_PREPARE && pStmt->last != STMT_ADD_BATCH && pStmt->last != STMT_BIND_COL && pStmt->last != STMT_EXECUTE) { + tscError("0x%"PRIx64" bind param status error, last:%d", pStmt->pSql->self, pStmt->last); + return TSDB_CODE_TSC_APP_ERROR; + } + } + + pStmt->last = STMT_BIND_COL; + + return insertStmtBindParamBatch(pStmt, bind, colIdx); +} + + + int taos_stmt_add_batch(TAOS_STMT* stmt) { STscStmt* pStmt = (STscStmt*)stmt; + if (stmt == NULL || pStmt->pSql == NULL || pStmt->taos == NULL) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return TSDB_CODE_TSC_DISCONNECTED; + } + if (pStmt->isInsert) { + if (pStmt->last != STMT_BIND && pStmt->last != STMT_BIND_COL) { + tscError("0x%"PRIx64" add batch status error, last:%d", pStmt->pSql->self, pStmt->last); + return TSDB_CODE_TSC_APP_ERROR; + } + + pStmt->last = STMT_ADD_BATCH; + return insertStmtAddBatch(pStmt); } + return TSDB_CODE_COM_OPS_NOT_SUPPORT; } @@ -978,8 +1532,24 @@ int taos_stmt_reset(TAOS_STMT* stmt) { int taos_stmt_execute(TAOS_STMT* stmt) { int ret = 0; STscStmt* pStmt = (STscStmt*)stmt; + if (stmt == NULL || pStmt->pSql == NULL || pStmt->taos == NULL) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return TSDB_CODE_TSC_DISCONNECTED; + } + if (pStmt->isInsert) { - ret = insertStmtExecute(pStmt); + if (pStmt->last != STMT_ADD_BATCH) { + tscError("0x%"PRIx64" exec status error, last:%d", pStmt->pSql->self, pStmt->last); + return TSDB_CODE_TSC_APP_ERROR; + } + + pStmt->last = STMT_EXECUTE; + + if (pStmt->multiTbInsert) { + ret = insertBatchStmtExecute(pStmt); + } else { + ret = insertStmtExecute(pStmt); + } } else { // normal stmt query char* sql = normalStmtBuildSql(pStmt); if (sql == NULL) { @@ -1074,7 +1644,7 @@ int taos_stmt_get_param(TAOS_STMT *stmt, int idx, int *type, int *bytes) { } if (idx<0 || idx>=pBlock->numOfParams) { - tscError("param %d: out of range", idx); + tscError("0x%"PRIx64" param %d: out of range", pStmt->pSql->self, idx); abort(); } diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index e760704bad97dbb722cfe35db0d536b69f7c47f8..e2ce0da739fcdb9089f1514025e01d49444e8ddf 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -440,6 +440,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { return tscGetTableMeta(pSql, pTableMetaInfo); } + case TSDB_SQL_SHOW_CREATE_STABLE: case TSDB_SQL_SHOW_CREATE_TABLE: { const char* msg1 = "invalid table name"; diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 2c75a40b06d2d458b5ef1f8b5d083df483e73477..6587a55152bceb468145fcb73cbcf8de29ed7530 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -2659,6 +2659,7 @@ void tscInitMsgsFp() { tscProcessMsgRsp[TSDB_SQL_ALTER_DB] = tscProcessAlterDbMsgRsp; tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_TABLE] = tscProcessShowCreateRsp; + tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_STABLE] = tscProcessShowCreateRsp; tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_DATABASE] = tscProcessShowCreateRsp; tscKeepConn[TSDB_SQL_SHOW] = 1; diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 67fb34734c536517abfd4f4dcd044071529055b3..e1a1ff7fd23a1da18cfb6982d602c49d9262a183 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -457,6 +457,7 @@ static bool needToFetchNewBlock(SSqlObj* pSql) { pCmd->command == TSDB_SQL_FETCH || pCmd->command == TSDB_SQL_SHOW || pCmd->command == TSDB_SQL_SHOW_CREATE_TABLE || + pCmd->command == TSDB_SQL_SHOW_CREATE_STABLE || pCmd->command == TSDB_SQL_SHOW_CREATE_DATABASE || pCmd->command == TSDB_SQL_SELECT || pCmd->command == TSDB_SQL_DESCRIBE_TABLE || diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 37956d42d8cf143415ac7945c94d3e2f66826e43..cb863e55b61f70c062274a78fe4cfc593a3b2760 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1256,67 +1256,73 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap) { STableDataBlocks* pOneTableBlock = *p; while(pOneTableBlock) { - // the maximum expanded size in byte when a row-wise data is converted to SDataRow format - int32_t expandSize = getRowExpandSize(pOneTableBlock->pTableMeta); - STableDataBlocks* dataBuf = NULL; - - int32_t ret = tscGetDataBlockFromList(pVnodeDataBlockHashList, pOneTableBlock->vgId, TSDB_PAYLOAD_SIZE, - INSERT_HEAD_SIZE, 0, &pOneTableBlock->tableName, pOneTableBlock->pTableMeta, &dataBuf, pVnodeDataBlockList); - if (ret != TSDB_CODE_SUCCESS) { - tscError("0x%"PRIx64" failed to prepare the data block buffer for merging table data, code:%d", pSql->self, ret); - taosHashCleanup(pVnodeDataBlockHashList); - tscDestroyBlockArrayList(pVnodeDataBlockList); - return ret; - } - SSubmitBlk* pBlocks = (SSubmitBlk*) pOneTableBlock->pData; - int64_t destSize = dataBuf->size + pOneTableBlock->size + pBlocks->numOfRows * expandSize + sizeof(STColumn) * tscGetNumOfColumns(pOneTableBlock->pTableMeta); - - if (dataBuf->nAllocSize < destSize) { - while (dataBuf->nAllocSize < destSize) { - dataBuf->nAllocSize = (uint32_t)(dataBuf->nAllocSize * 1.5); + if (pBlocks->numOfRows > 0) { + // the maximum expanded size in byte when a row-wise data is converted to SDataRow format + int32_t expandSize = getRowExpandSize(pOneTableBlock->pTableMeta); + STableDataBlocks* dataBuf = NULL; + + int32_t ret = tscGetDataBlockFromList(pVnodeDataBlockHashList, pOneTableBlock->vgId, TSDB_PAYLOAD_SIZE, + INSERT_HEAD_SIZE, 0, &pOneTableBlock->tableName, pOneTableBlock->pTableMeta, &dataBuf, pVnodeDataBlockList); + if (ret != TSDB_CODE_SUCCESS) { + tscError("0x%"PRIx64" failed to prepare the data block buffer for merging table data, code:%d", pSql->self, ret); + taosHashCleanup(pVnodeDataBlockHashList); + tscDestroyBlockArrayList(pVnodeDataBlockList); + return ret; } - char* tmp = realloc(dataBuf->pData, dataBuf->nAllocSize); - if (tmp != NULL) { - dataBuf->pData = tmp; - memset(dataBuf->pData + dataBuf->size, 0, dataBuf->nAllocSize - dataBuf->size); - } else { // failed to allocate memory, free already allocated memory and return error code - tscError("0x%"PRIx64" failed to allocate memory for merging submit block, size:%d", pSql->self, dataBuf->nAllocSize); + int64_t destSize = dataBuf->size + pOneTableBlock->size + pBlocks->numOfRows * expandSize + sizeof(STColumn) * tscGetNumOfColumns(pOneTableBlock->pTableMeta); - taosHashCleanup(pVnodeDataBlockHashList); - tscDestroyBlockArrayList(pVnodeDataBlockList); - tfree(dataBuf->pData); + if (dataBuf->nAllocSize < destSize) { + while (dataBuf->nAllocSize < destSize) { + dataBuf->nAllocSize = (uint32_t)(dataBuf->nAllocSize * 1.5); + } + + char* tmp = realloc(dataBuf->pData, dataBuf->nAllocSize); + if (tmp != NULL) { + dataBuf->pData = tmp; + memset(dataBuf->pData + dataBuf->size, 0, dataBuf->nAllocSize - dataBuf->size); + } else { // failed to allocate memory, free already allocated memory and return error code + tscError("0x%"PRIx64" failed to allocate memory for merging submit block, size:%d", pSql->self, dataBuf->nAllocSize); + + taosHashCleanup(pVnodeDataBlockHashList); + tscDestroyBlockArrayList(pVnodeDataBlockList); + tfree(dataBuf->pData); - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } } - } - tscSortRemoveDataBlockDupRows(pOneTableBlock); - char* ekey = (char*)pBlocks->data + pOneTableBlock->rowSize*(pBlocks->numOfRows-1); + tscSortRemoveDataBlockDupRows(pOneTableBlock); + char* ekey = (char*)pBlocks->data + pOneTableBlock->rowSize*(pBlocks->numOfRows-1); - tscDebug("0x%"PRIx64" name:%s, name:%d rows:%d sversion:%d skey:%" PRId64 ", ekey:%" PRId64, pSql->self, tNameGetTableName(&pOneTableBlock->tableName), - pBlocks->tid, pBlocks->numOfRows, pBlocks->sversion, GET_INT64_VAL(pBlocks->data), GET_INT64_VAL(ekey)); + tscDebug("0x%"PRIx64" name:%s, name:%d rows:%d sversion:%d skey:%" PRId64 ", ekey:%" PRId64, pSql->self, tNameGetTableName(&pOneTableBlock->tableName), + pBlocks->tid, pBlocks->numOfRows, pBlocks->sversion, GET_INT64_VAL(pBlocks->data), GET_INT64_VAL(ekey)); - int32_t len = pBlocks->numOfRows * (pOneTableBlock->rowSize + expandSize) + sizeof(STColumn) * tscGetNumOfColumns(pOneTableBlock->pTableMeta); + int32_t len = pBlocks->numOfRows * (pOneTableBlock->rowSize + expandSize) + sizeof(STColumn) * tscGetNumOfColumns(pOneTableBlock->pTableMeta); - pBlocks->tid = htonl(pBlocks->tid); - pBlocks->uid = htobe64(pBlocks->uid); - pBlocks->sversion = htonl(pBlocks->sversion); - pBlocks->numOfRows = htons(pBlocks->numOfRows); - pBlocks->schemaLen = 0; + pBlocks->tid = htonl(pBlocks->tid); + pBlocks->uid = htobe64(pBlocks->uid); + pBlocks->sversion = htonl(pBlocks->sversion); + pBlocks->numOfRows = htons(pBlocks->numOfRows); + pBlocks->schemaLen = 0; - // erase the empty space reserved for binary data - int32_t finalLen = trimDataBlock(dataBuf->pData + dataBuf->size, pOneTableBlock, pCmd->submitSchema); - assert(finalLen <= len); + // erase the empty space reserved for binary data + int32_t finalLen = trimDataBlock(dataBuf->pData + dataBuf->size, pOneTableBlock, pCmd->submitSchema); + assert(finalLen <= len); - dataBuf->size += (finalLen + sizeof(SSubmitBlk)); - assert(dataBuf->size <= dataBuf->nAllocSize); + dataBuf->size += (finalLen + sizeof(SSubmitBlk)); + assert(dataBuf->size <= dataBuf->nAllocSize); - // the length does not include the SSubmitBlk structure - pBlocks->dataLen = htonl(finalLen); - dataBuf->numOfTables += 1; + // the length does not include the SSubmitBlk structure + pBlocks->dataLen = htonl(finalLen); + dataBuf->numOfTables += 1; + pBlocks->numOfRows = 0; + }else { + tscDebug("0x%"PRIx64" table %s data block is empty", pSql->self, pOneTableBlock->tableName.tname); + } + p = taosHashIterate(pCmd->pTableBlockHashList, p); if (p == NULL) { break; diff --git a/src/common/inc/tcmdtype.h b/src/common/inc/tcmdtype.h index be16e80124358012a079ada5f7cd689afa0f7b75..adf210cfebb15ddc0adcfce2aa85e606f79c44a5 100644 --- a/src/common/inc/tcmdtype.h +++ b/src/common/inc/tcmdtype.h @@ -80,6 +80,7 @@ enum { 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_STABLE, "show-create-stable") TSDB_DEFINE_SQL_TYPE( TSDB_SQL_SHOW_CREATE_DATABASE, "show-create-database") /* diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java index 4b5b88d93bdf14b2387708a3e24229d0fd5d74d7..f8ea9af4230e9584197f1141dc5a4f7c1621b3ff 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java @@ -84,10 +84,12 @@ public abstract class AbstractResultSet extends WrapperImpl implements ResultSet } @Override + @Deprecated public InputStream getUnicodeStream(int columnIndex) throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED); - + } + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); } @@ -171,6 +173,7 @@ public abstract class AbstractResultSet extends WrapperImpl implements ResultSet } @Override + @Deprecated public InputStream getUnicodeStream(String columnLabel) throws SQLException { return getUnicodeStream(findColumn(columnLabel)); } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java index c8ab9fb15ae0ece504ff825dbbe16e12408aede0..02fee74eb5544f282559f88dab723ccfd8ca096f 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConnection.java @@ -49,7 +49,7 @@ public class TSDBConnection extends AbstractConnection { this.databaseMetaData.setConnection(this); } - public TSDBJNIConnector getConnection() { + public TSDBJNIConnector getConnector() { return this.connector; } @@ -58,7 +58,7 @@ public class TSDBConnection extends AbstractConnection { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED); } - return new TSDBStatement(this, this.connector); + return new TSDBStatement(this); } public TSDBSubscribe subscribe(String topic, String sql, boolean restart) throws SQLException { @@ -74,14 +74,18 @@ public class TSDBConnection extends AbstractConnection { } public PreparedStatement prepareStatement(String sql) throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED); - return new TSDBPreparedStatement(this, this.connector, sql); + } + + return new TSDBPreparedStatement(this, sql); } public void close() throws SQLException { - if (isClosed) + if (isClosed) { return; + } + this.connector.closeConnection(); this.isClosed = true; } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java index 5e3ffffa4fe7326b8c1e89ac91a37e95c346784f..2111ab2743d30511bf28619c87666144969e891a 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java @@ -18,6 +18,7 @@ package com.taosdata.jdbc; import com.taosdata.jdbc.utils.TaosInfo; +import java.nio.ByteBuffer; import java.sql.SQLException; import java.sql.SQLWarning; import java.util.List; @@ -29,10 +30,13 @@ public class TSDBJNIConnector { private static volatile Boolean isInitialized = false; private TaosInfo taosInfo = TaosInfo.getInstance(); + // Connection pointer used in C private long taos = TSDBConstants.JNI_NULL_POINTER; + // result set status in current connection private boolean isResultsetClosed = true; + private int affectedRows = -1; static { @@ -75,7 +79,6 @@ public class TSDBJNIConnector { public boolean connect(String host, int port, String dbName, String user, String password) throws SQLException { if (this.taos != TSDBConstants.JNI_NULL_POINTER) { -// this.closeConnectionImp(this.taos); closeConnection(); this.taos = TSDBConstants.JNI_NULL_POINTER; } @@ -97,12 +100,6 @@ public class TSDBJNIConnector { * @throws SQLException */ public long executeQuery(String sql) throws SQLException { - // close previous result set if the user forgets to invoke the - // free method to close previous result set. -// if (!this.isResultsetClosed) { -// freeResultSet(taosResultSetPointer); -// } - Long pSql = 0l; try { pSql = this.executeQueryImp(sql.getBytes(TaosGlobalConfig.getCharset()), this.taos); @@ -169,37 +166,14 @@ public class TSDBJNIConnector { private native long isUpdateQueryImp(long connection, long pSql); /** - * Free resultset operation from C to release resultset pointer by JNI + * Free result set operation from C to release result set pointer by JNI */ public int freeResultSet(long pSql) { - int res = TSDBConstants.JNI_SUCCESS; -// if (result != taosResultSetPointer && taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) { -// throw new RuntimeException("Invalid result set pointer"); -// } - -// if (taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) { - res = this.freeResultSetImp(this.taos, pSql); -// taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER; -// } - + int res = this.freeResultSetImp(this.taos, pSql); isResultsetClosed = true; return res; } - /** - * Close the open result set which is associated to the current connection. If the result set is already - * closed, return 0 for success. - */ -// public int freeResultSet() { -// int resCode = TSDBConstants.JNI_SUCCESS; -// if (!isResultsetClosed) { -// resCode = this.freeResultSetImp(this.taos, this.taosResultSetPointer); -// taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER; -// isResultsetClosed = true; -// } -// return resCode; -// } - private native int freeResultSetImp(long connection, long result); /** @@ -246,6 +220,7 @@ public class TSDBJNIConnector { */ public void closeConnection() throws SQLException { int code = this.closeConnectionImp(this.taos); + if (code < 0) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); } else if (code == 0) { @@ -253,6 +228,7 @@ public class TSDBJNIConnector { } else { throw new SQLException("Undefined error code returned by TDengine when closing a connection"); } + // invoke closeConnectionImpl only here taosInfo.connect_close_increment(); } @@ -289,7 +265,7 @@ public class TSDBJNIConnector { private native void unsubscribeImp(long subscription, boolean isKeep); /** - * Validate if a create table sql statement is correct without actually creating that table + * Validate if a create table SQL statement is correct without actually creating that table */ public boolean validateCreateTableSql(String sql) { int res = validateCreateTableSqlImp(taos, sql.getBytes()); @@ -297,4 +273,66 @@ public class TSDBJNIConnector { } private native int validateCreateTableSqlImp(long connection, byte[] sqlBytes); + + public long prepareStmt(String sql) throws SQLException { + Long stmt = 0L; + try { + stmt = prepareStmtImp(sql.getBytes(), this.taos); + } catch (Exception e) { + e.printStackTrace(); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_ENCODING); + } + + if (stmt == TSDBConstants.JNI_CONNECTION_NULL) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); + } + + if (stmt == TSDBConstants.JNI_SQL_NULL) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_SQL_NULL); + } + + if (stmt == TSDBConstants.JNI_OUT_OF_MEMORY) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_OUT_OF_MEMORY); + } + + return stmt; + } + + private native long prepareStmtImp(byte[] sql, long con); + + public void setBindTableName(long stmt, String tableName) throws SQLException { + int code = setBindTableNameImp(stmt, tableName, this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to set table name"); + } + } + + private native int setBindTableNameImp(long stmt, String name, long conn); + + public void bindColumnDataArray(long stmt, ByteBuffer colDataList, ByteBuffer lengthList, ByteBuffer isNullList, int type, int bytes, int numOfRows,int columnIndex) throws SQLException { + int code = bindColDataImp(stmt, colDataList.array(), lengthList.array(), isNullList.array(), type, bytes, numOfRows, columnIndex, this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to bind column data"); + } + } + + private native int bindColDataImp(long stmt, byte[] colDataList, byte[] lengthList, byte[] isNullList, int type, int bytes, int numOfRows, int columnIndex, long conn); + + public void executeBatch(long stmt) throws SQLException { + int code = executeBatchImp(stmt, this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to execute batch bind"); + } + } + + private native int executeBatchImp(long stmt, long con); + + public void closeBatch(long stmt) throws SQLException { + int code = closeStmt(stmt, this.taos); + if (code != TSDBConstants.JNI_SUCCESS) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to close batch bind"); + } + } + + private native int closeStmt(long stmt, long con); } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java index 56f971a35e72c60608fcc294298a2f3ca7fbc292..71e07252a34003c3fcc4dceae80e897030e55926 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java @@ -18,33 +18,40 @@ import com.taosdata.jdbc.utils.Utils; import java.io.InputStream; import java.io.Reader; +import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.net.URL; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.sql.*; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collections; import java.util.regex.Matcher; import java.util.regex.Pattern; /* - * TDengine only supports a subset of the standard SQL, thus this implemetation of the + * TDengine only supports a subset of the standard SQL, thus this implementation of the * standard JDBC API contains more or less some adjustments customized for certain * compatibility needs. */ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStatement { - private String rawSql; private Object[] parameters; private boolean isPrepared; - + + private ArrayList colData; + private String tableName; + private long nativeStmtHandle = 0; + private volatile TSDBParameterMetaData parameterMetaData; - TSDBPreparedStatement(TSDBConnection connection, TSDBJNIConnector connecter, String sql) { - super(connection, connecter); + TSDBPreparedStatement(TSDBConnection connection, String sql) { + super(connection); init(sql); + int parameterCnt = 0; if (sql.contains("?")) { - int parameterCnt = 0; for (int i = 0; i < sql.length(); i++) { if ('?' == sql.charAt(i)) { parameterCnt++; @@ -53,6 +60,12 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat parameters = new Object[parameterCnt]; this.isPrepared = true; } + + if (parameterCnt > 1) { + // the table name is also a parameter, so ignore it. + this.colData = new ArrayList(parameterCnt - 1); + this.colData.addAll(Collections.nCopies(parameterCnt - 1, null)); + } } private void init(String sql) { @@ -260,10 +273,14 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat @Override public void setObject(int parameterIndex, Object x) throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - if (parameterIndex < 1 && parameterIndex >= parameters.length) + } + + if (parameterIndex < 1 && parameterIndex >= parameters.length) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE); + } + parameters[parameterIndex - 1] = x; } @@ -300,9 +317,10 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat @Override public void setRef(int parameterIndex, Ref x) throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - + } + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); } @@ -515,4 +533,276 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); } + + /////////////////////////////////////////////////////////////////////// + // NOTE: the following APIs are not JDBC compatible + // set the bind table name + private static class ColumnInfo { + @SuppressWarnings("rawtypes") + private ArrayList data; + private int type; + private int bytes; + private boolean typeIsSet; + + public ColumnInfo() { + this.typeIsSet = false; + } + + public void setType(int type) throws SQLException { + if (this.isTypeSet()) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data type has been set"); + } + + this.typeIsSet = true; + this.type = type; + } + + public boolean isTypeSet() { + return this.typeIsSet; + } + }; + + public void setTableName(String name) { + this.tableName = name; + } + + public void setValueImpl(int columnIndex, ArrayList list, int type, int bytes) throws SQLException { + ColumnInfo col = (ColumnInfo) this.colData.get(columnIndex); + if (col == null) { + ColumnInfo p = new ColumnInfo(); + p.setType(type); + p.bytes = bytes; + p.data = (ArrayList) list.clone(); + this.colData.set(columnIndex, p); + } else { + if (col.type != type) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data type mismatch"); + } + col.data.addAll(list); + } + } + + public void setInt(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_INT, Integer.BYTES); + } + + public void setFloat(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_FLOAT, Float.BYTES); + } + + public void setTimestamp(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP, Long.BYTES); + } + + public void setLong(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_BIGINT, Long.BYTES); + } + + public void setDouble(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_DOUBLE, Double.BYTES); + } + + public void setBoolean(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_BOOL, Byte.BYTES); + } + + public void setByte(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_TINYINT, Byte.BYTES); + } + + public void setShort(int columnIndex, ArrayList list) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_SMALLINT, Short.BYTES); + } + + public void setString(int columnIndex, ArrayList list, int size) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_BINARY, size); + } + + // note: expand the required space for each NChar character + public void setNString(int columnIndex, ArrayList list, int size) throws SQLException { + setValueImpl(columnIndex, list, TSDBConstants.TSDB_DATA_TYPE_NCHAR, size * Integer.BYTES); + } + + public void columnDataAddBatch() throws SQLException { + // pass the data block to native code + if (rawSql == null) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "sql statement not set yet"); + } + + // table name is not set yet, abort + if (this.tableName == null) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "table name not set yet"); + } + + int numOfCols = this.colData.size(); + if (numOfCols == 0) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data not bind"); + } + + TSDBJNIConnector connector = ((TSDBConnection) this.getConnection()).getConnector(); + this.nativeStmtHandle = connector.prepareStmt(rawSql); + connector.setBindTableName(this.nativeStmtHandle, this.tableName); + + ColumnInfo colInfo = (ColumnInfo) this.colData.get(0); + if (colInfo == null) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data not bind"); + } + + int rows = colInfo.data.size(); + for (int i = 0; i < numOfCols; ++i) { + ColumnInfo col1 = this.colData.get(i); + if (col1 == null || !col1.isTypeSet()) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "column data not bind"); + } + + if (rows != col1.data.size()) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "the rows in column data not identical"); + } + + ByteBuffer colDataList = ByteBuffer.allocate(rows * col1.bytes); + colDataList.order(ByteOrder.LITTLE_ENDIAN); + + ByteBuffer lengthList = ByteBuffer.allocate(rows * Integer.BYTES); + lengthList.order(ByteOrder.LITTLE_ENDIAN); + + ByteBuffer isNullList = ByteBuffer.allocate(rows * Byte.BYTES); + isNullList.order(ByteOrder.LITTLE_ENDIAN); + + switch (col1.type) { + case TSDBConstants.TSDB_DATA_TYPE_INT: { + for (int j = 0; j < rows; ++j) { + Integer val = (Integer) col1.data.get(j); + colDataList.putInt(val == null? Integer.MIN_VALUE:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: { + for (int j = 0; j < rows; ++j) { + Byte val = (Byte) col1.data.get(j); + colDataList.put(val == null? 0:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_BOOL: { + for (int j = 0; j < rows; ++j) { + Boolean val = (Boolean) col1.data.get(j); + if (val == null) { + colDataList.put((byte) 0); + } else { + colDataList.put((byte) (val? 1:0)); + } + + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: { + for (int j = 0; j < rows; ++j) { + Short val = (Short) col1.data.get(j); + colDataList.putShort(val == null? 0:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: { + for (int j = 0; j < rows; ++j) { + Long val = (Long) col1.data.get(j); + colDataList.putLong(val == null? 0:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: { + for (int j = 0; j < rows; ++j) { + Float val = (Float) col1.data.get(j); + colDataList.putFloat(val == null? 0:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { + for (int j = 0; j < rows; ++j) { + Double val = (Double) col1.data.get(j); + colDataList.putDouble(val == null? 0:val); + isNullList.put((byte) (val == null? 1:0)); + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + case TSDBConstants.TSDB_DATA_TYPE_BINARY: { + String charset = TaosGlobalConfig.getCharset(); + for (int j = 0; j < rows; ++j) { + String val = (String) col1.data.get(j); + + colDataList.position(j * col1.bytes); // seek to the correct position + if (val != null) { + byte[] b = null; + try { + if (col1.type == TSDBConstants.TSDB_DATA_TYPE_BINARY) { + b = val.getBytes(); + } else { + b = val.getBytes(charset); + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + if (val.length() > col1.bytes) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "string data too long"); + } + + colDataList.put(b); + lengthList.putInt(b.length); + isNullList.put((byte) 0); + } else { + lengthList.putInt(0); + isNullList.put((byte) 1); + } + } + break; + } + + case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: + case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: + case TSDBConstants.TSDB_DATA_TYPE_UINT: + case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "not support data types"); + } + }; + + connector.bindColumnDataArray(this.nativeStmtHandle, colDataList, lengthList, isNullList, col1.type, col1.bytes, rows, i); + } + } + + public void columnDataExecuteBatch() throws SQLException { + TSDBJNIConnector connector = ((TSDBConnection) this.getConnection()).getConnector(); + connector.executeBatch(this.nativeStmtHandle); + this.columnDataClearBatch(); + } + + public void columnDataClearBatch() { + int size = this.colData.size(); + this.colData.clear(); + + this.colData.addAll(Collections.nCopies(size, null)); + this.tableName = null; // clear the table name + } + + public void columnDataCloseBatch() throws SQLException { + TSDBJNIConnector connector = ((TSDBConnection) this.getConnection()).getConnector(); + connector.closeBatch(this.nativeStmtHandle); + + this.nativeStmtHandle = 0L; + this.tableName = null; + } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java index ce5290de6616dfcc367434cc2e24899e992ddd63..7b3be5d26397eae704d98f1e1802af14abaad4fc 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java @@ -29,6 +29,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import com.taosdata.jdbc.utils.NullType; + public class TSDBResultSetBlockData { private int numOfRows = 0; private int rowIndex = 0; @@ -164,59 +166,7 @@ public class TSDBResultSetBlockData { } } - private static class NullType { - private static final byte NULL_BOOL_VAL = 0x2; - private static final String NULL_STR = "null"; - - public String toString() { - return NullType.NULL_STR; - } - - public static boolean isBooleanNull(byte val) { - return val == NullType.NULL_BOOL_VAL; - } - - private static boolean isTinyIntNull(byte val) { - return val == Byte.MIN_VALUE; - } - - private static boolean isSmallIntNull(short val) { - return val == Short.MIN_VALUE; - } - - private static boolean isIntNull(int val) { - return val == Integer.MIN_VALUE; - } - - private static boolean isBigIntNull(long val) { - return val == Long.MIN_VALUE; - } - - private static boolean isFloatNull(float val) { - return Float.isNaN(val); - } - - private static boolean isDoubleNull(double val) { - return Double.isNaN(val); - } - - private static boolean isBinaryNull(byte[] val, int length) { - if (length != Byte.BYTES) { - return false; - } - - return val[0] == 0xFF; - } - - private static boolean isNcharNull(byte[] val, int length) { - if (length != Integer.BYTES) { - return false; - } - - return (val[0] & val[1] & val[2] & val[3]) == 0xFF; - } - - } + /** * The original type may not be a string type, but will be converted to by @@ -488,8 +438,8 @@ public class TSDBResultSetBlockData { } try { - String ss = TaosGlobalConfig.getCharset(); - return new String(dest, ss); + String charset = TaosGlobalConfig.getCharset(); + return new String(dest, charset); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java index 34470fbc4e5c06caa117737923612478d7039a90..618e896a6ddfe43d63f631b663a356f485575b06 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java @@ -84,7 +84,8 @@ public class TSDBResultSetRowData { data.set(col, value); } - public int getInt(int col, int srcType) throws SQLException { + @SuppressWarnings("deprecation") + public int getInt(int col, int srcType) throws SQLException { Object obj = data.get(col); switch (srcType) { @@ -128,7 +129,7 @@ public class TSDBResultSetRowData { long value = (long) obj; if (value < 0) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); - return new Long(value).intValue(); + return Long.valueOf(value).intValue(); } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java index fb20a621b0f11413e13e4234be357f6456a2a4fa..d8ba67576d069a6aec0a5bb17e9549e41b8cf31e 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java @@ -19,8 +19,6 @@ import java.sql.ResultSet; import java.sql.SQLException; public class TSDBStatement extends AbstractStatement { - - private TSDBJNIConnector connector; /** * Status of current statement */ @@ -29,29 +27,26 @@ public class TSDBStatement extends AbstractStatement { private TSDBConnection connection; private TSDBResultSet resultSet; - public void setConnection(TSDBConnection connection) { - this.connection = connection; - } - - TSDBStatement(TSDBConnection connection, TSDBJNIConnector connector) { + TSDBStatement(TSDBConnection connection) { this.connection = connection; - this.connector = connector; } public ResultSet executeQuery(String sql) throws SQLException { // check if closed - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); + } + //TODO: 如果在executeQuery方法中执行insert语句,那么先执行了SQL,再通过pSql来检查是否为一个insert语句,但这个insert SQL已经执行成功了 // execute query - long pSql = this.connector.executeQuery(sql); + long pSql = this.connection.getConnector().executeQuery(sql); // if pSql is create/insert/update/delete/alter SQL - if (this.connector.isUpdateQuery(pSql)) { - this.connector.freeResultSet(pSql); + if (this.connection.getConnector().isUpdateQuery(pSql)) { + this.connection.getConnector().freeResultSet(pSql); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEQUERY); } - TSDBResultSet res = new TSDBResultSet(this, this.connector, pSql); + TSDBResultSet res = new TSDBResultSet(this, this.connection.getConnector(), pSql); res.setBatchFetch(this.connection.getBatchFetch()); return res; } @@ -60,14 +55,14 @@ public class TSDBStatement extends AbstractStatement { if (isClosed()) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - long pSql = this.connector.executeQuery(sql); + long pSql = this.connection.getConnector().executeQuery(sql); // if pSql is create/insert/update/delete/alter SQL - if (!this.connector.isUpdateQuery(pSql)) { - this.connector.freeResultSet(pSql); + if (!this.connection.getConnector().isUpdateQuery(pSql)) { + this.connection.getConnector().freeResultSet(pSql); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEUPDATE); } - int affectedRows = this.connector.getAffectedRows(pSql); - this.connector.freeResultSet(pSql); + int affectedRows = this.connection.getConnector().getAffectedRows(pSql); + this.connection.getConnector().freeResultSet(pSql); return affectedRows; } @@ -81,30 +76,29 @@ public class TSDBStatement extends AbstractStatement { public boolean execute(String sql) throws SQLException { // check if closed - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); + } + // execute query - long pSql = this.connector.executeQuery(sql); + long pSql = this.connection.getConnector().executeQuery(sql); // if pSql is create/insert/update/delete/alter SQL - if (this.connector.isUpdateQuery(pSql)) { - this.affectedRows = this.connector.getAffectedRows(pSql); - this.connector.freeResultSet(pSql); + if (this.connection.getConnector().isUpdateQuery(pSql)) { + this.affectedRows = this.connection.getConnector().getAffectedRows(pSql); + this.connection.getConnector().freeResultSet(pSql); return false; } - this.resultSet = new TSDBResultSet(this, this.connector, pSql); + this.resultSet = new TSDBResultSet(this, this.connection.getConnector(), pSql); this.resultSet.setBatchFetch(this.connection.getBatchFetch()); return true; } public ResultSet getResultSet() throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); -// long resultSetPointer = connector.getResultSet(); -// TSDBResultSet resSet = null; -// if (resultSetPointer != TSDBConstants.JNI_NULL_POINTER) { -// resSet = new TSDBResultSet(connector, resultSetPointer); -// } + } + return this.resultSet; } @@ -115,12 +109,20 @@ public class TSDBStatement extends AbstractStatement { } public Connection getConnection() throws SQLException { - if (isClosed()) + if (isClosed()) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - if (this.connector == null) + } + + if (this.connection.getConnector() == null) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); + } + return this.connection; } + + public void setConnection(TSDBConnection connection) { + this.connection = connection; + } public boolean isClosed() throws SQLException { return isClosed; diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulPreparedStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulPreparedStatement.java index 4e64b708c987e8c7f4e4a01c668b662802b80b79..f58e3f8cd2406e6372900c2f7b2547a450fb7fe9 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulPreparedStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulPreparedStatement.java @@ -1,8 +1,5 @@ package com.taosdata.jdbc.rs; -import com.google.common.collect.Range; -import com.google.common.collect.RangeSet; -import com.google.common.collect.TreeRangeSet; import com.taosdata.jdbc.TSDBError; import com.taosdata.jdbc.TSDBErrorNumbers; import com.taosdata.jdbc.utils.Utils; @@ -13,12 +10,6 @@ import java.math.BigDecimal; import java.net.URL; import java.sql.*; import java.util.Calendar; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.IntStream; public class RestfulPreparedStatement extends RestfulStatement implements PreparedStatement { diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/NullType.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/NullType.java new file mode 100755 index 0000000000000000000000000000000000000000..0e05aeeee7ae0eeb7728910cb5e77a5084d0aa2f --- /dev/null +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/NullType.java @@ -0,0 +1,91 @@ +package com.taosdata.jdbc.utils; + +public class NullType { + private static final byte NULL_BOOL_VAL = 0x2; + private static final String NULL_STR = "null"; + + public String toString() { + return NullType.NULL_STR; + } + + public static boolean isBooleanNull(byte val) { + return val == NullType.NULL_BOOL_VAL; + } + + public static boolean isTinyIntNull(byte val) { + return val == Byte.MIN_VALUE; + } + + public static boolean isSmallIntNull(short val) { + return val == Short.MIN_VALUE; + } + + public static boolean isIntNull(int val) { + return val == Integer.MIN_VALUE; + } + + public static boolean isBigIntNull(long val) { + return val == Long.MIN_VALUE; + } + + public static boolean isFloatNull(float val) { + return Float.isNaN(val); + } + + public static boolean isDoubleNull(double val) { + return Double.isNaN(val); + } + + public static boolean isBinaryNull(byte[] val, int length) { + if (length != Byte.BYTES) { + return false; + } + + return val[0] == 0xFF; + } + + public static boolean isNcharNull(byte[] val, int length) { + if (length != Integer.BYTES) { + return false; + } + + return (val[0] & val[1] & val[2] & val[3]) == 0xFF; + } + + public static byte getBooleanNull() { + return NullType.NULL_BOOL_VAL; + } + + public static byte getTinyintNull() { + return Byte.MIN_VALUE; + } + + public static int getIntNull() { + return Integer.MIN_VALUE; + } + + public static short getSmallIntNull() { + return Short.MIN_VALUE; + } + + public static long getBigIntNull() { + return Long.MIN_VALUE; + } + + public static int getFloatNull() { + return 0x7FF00000; + } + + public static long getDoubleNull() { + return 0x7FFFFF0000000000L; + } + + public static byte getBinaryNull() { + return (byte) 0xFF; + } + + public static byte[] getNcharNull() { + return new byte[] {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}; + } + +} diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java index c5c6f7bca5226ca87441e0d080b269231f0167c0..f304fd687406ccf919ea1b1e457cd218239e765f 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java @@ -3,7 +3,6 @@ package com.taosdata.jdbc; import com.google.common.primitives.Ints; import com.google.common.primitives.Longs; import com.google.common.primitives.Shorts; -import com.taosdata.jdbc.rs.RestfulResultSet; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -177,7 +176,8 @@ public class TSDBResultSetTest { rs.getAsciiStream("f1"); } - @Test(expected = SQLFeatureNotSupportedException.class) + @SuppressWarnings("deprecation") + @Test(expected = SQLFeatureNotSupportedException.class) public void getUnicodeStream() throws SQLException { rs.getUnicodeStream("f1"); } @@ -326,7 +326,7 @@ public class TSDBResultSetTest { @Test(expected = SQLFeatureNotSupportedException.class) public void getRow() throws SQLException { - int row = rs.getRow(); + rs.getRow(); } @Test(expected = SQLFeatureNotSupportedException.class) @@ -405,12 +405,12 @@ public class TSDBResultSetTest { @Test(expected = SQLFeatureNotSupportedException.class) public void updateByte() throws SQLException { - rs.updateByte(1, new Byte("0")); + rs.updateByte(1, (byte) 0); } @Test(expected = SQLFeatureNotSupportedException.class) public void updateShort() throws SQLException { - rs.updateShort(1, new Short("0")); + rs.updateShort(1, (short) 0); } @Test(expected = SQLFeatureNotSupportedException.class) diff --git a/src/inc/taos.h b/src/inc/taos.h index cd8e116053bd9adabda9a1eeeb20c6d92679d99d..6dd695b320f71ff65b97715aed108c7d1b4e2f7e 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -82,6 +82,7 @@ typedef struct TAOS_BIND { uintptr_t buffer_length; // unused uintptr_t *length; int * is_null; + int is_unsigned; // unused int * error; // unused union { @@ -99,12 +100,25 @@ typedef struct TAOS_BIND { unsigned int allocated; } TAOS_BIND; +typedef struct TAOS_MULTI_BIND { + int buffer_type; + void *buffer; + uintptr_t buffer_length; + int32_t *length; + char *is_null; + int num; +} TAOS_MULTI_BIND; + + TAOS_STMT *taos_stmt_init(TAOS *taos); int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length); +int taos_stmt_set_tbname(TAOS_STMT* stmt, const char* name); int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert); int taos_stmt_num_params(TAOS_STMT *stmt, int *nums); int taos_stmt_get_param(TAOS_STMT *stmt, int idx, int *type, int *bytes); int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind); +int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind); +int taos_stmt_bind_single_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int colIdx); int taos_stmt_add_batch(TAOS_STMT *stmt); int taos_stmt_execute(TAOS_STMT *stmt); TAOS_RES * taos_stmt_use_result(TAOS_STMT *stmt); diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h index e9f95660f7d6defb6a8dd63b7431bd0ab913b4ab..ef3f8ed1fbcc754ad54dd7e9c232f610b37b98e8 100644 --- a/src/inc/ttokendef.h +++ b/src/inc/ttokendef.h @@ -79,12 +79,12 @@ #define TK_DOT 60 #define TK_CREATE 61 #define TK_TABLE 62 -#define TK_DATABASE 63 -#define TK_TABLES 64 -#define TK_STABLES 65 -#define TK_VGROUPS 66 -#define TK_DROP 67 -#define TK_STABLE 68 +#define TK_STABLE 63 +#define TK_DATABASE 64 +#define TK_TABLES 65 +#define TK_STABLES 66 +#define TK_VGROUPS 67 +#define TK_DROP 68 #define TK_TOPIC 69 #define TK_DNODE 70 #define TK_USER 71 diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index a3a8968017d7b0fc06ccdc176a2b81b347aa2629..8866bf2607adecca7860388593ac84aac65e80a1 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -68,12 +68,6 @@ enum TEST_MODE { INVAID_TEST }; -enum QUERY_MODE { - SYNC_QUERY_MODE, // 0 - ASYNC_QUERY_MODE, // 1 - INVALID_MODE -}; - #define MAX_RECORDS_PER_REQ 32766 #define MAX_SQL_SIZE 65536 @@ -1107,6 +1101,7 @@ static void appendResultBufToFile(char *resultBuf, char *resultFile) } } + fprintf(fp, "%s", resultBuf); tmfclose(fp); } @@ -1142,6 +1137,7 @@ static void appendResultToFile(TAOS_RES *res, char* resultFile) { totalLen += len; } + verbosePrint("%s() LN%d, databuf=%s resultFile=%s\n", __func__, __LINE__, databuf, resultFile); appendResultBufToFile(databuf, resultFile); free(databuf); } @@ -6517,59 +6513,63 @@ static void *superSubscribe(void *sarg) { return NULL; } - //int64_t st = 0; - //int64_t et = 0; - do { - //if (g_queryInfo.specifiedQueryInfo.queryInterval && (et - st) < g_queryInfo.specifiedQueryInfo.queryInterval) { - // taosMsleep(g_queryInfo.specifiedQueryInfo.queryInterval- (et - st)); // ms - // //printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, pThreadInfo->start_table_from, pThreadInfo->end_table_to); - //} - - //st = taosGetTimestampMs(); - char topic[32] = {0}; - for (int i = 0; i < g_queryInfo.superQueryInfo.sqlCount; i++) { - sprintf(topic, "taosdemo-subscribe-%d", i); + char topic[32] = {0}; + for (uint64_t i = pThreadInfo->start_table_from; + i <= pThreadInfo->end_table_to; i++) { + for (int j = 0; j < g_queryInfo.superQueryInfo.sqlCount; j++) { + sprintf(topic, "taosdemo-subscribe-%"PRIu64"-%d", i, j); memset(subSqlstr,0,sizeof(subSqlstr)); - replaceChildTblName(g_queryInfo.superQueryInfo.sql[i], subSqlstr, i); + replaceChildTblName(g_queryInfo.superQueryInfo.sql[j], subSqlstr, i); char tmpFile[MAX_FILE_NAME_LEN*2] = {0}; - if (g_queryInfo.superQueryInfo.result[i][0] != 0) { + if (g_queryInfo.superQueryInfo.result[j][0] != 0) { sprintf(tmpFile, "%s-%d", - g_queryInfo.superQueryInfo.result[i], pThreadInfo->threadID); + g_queryInfo.superQueryInfo.result[j], pThreadInfo->threadID); } - tsub[i] = subscribeImpl(pThreadInfo->taos, subSqlstr, topic, tmpFile); - if (NULL == tsub[i]) { + + uint64_t subSeq = i * g_queryInfo.superQueryInfo.sqlCount + j; + debugPrint("%s() LN%d, subSeq=%"PRIu64" subSqlstr: %s\n", + __func__, __LINE__, subSeq, subSqlstr); + tsub[subSeq] = subscribeImpl(pThreadInfo->taos, subSqlstr, topic, tmpFile); + if (NULL == tsub[subSeq]) { taos_close(pThreadInfo->taos); return NULL; } } - //et = taosGetTimestampMs(); - //printf("========thread[%"PRIu64"] complete all sqls to super table once queries duration:%.4fs\n", taosGetSelfPthreadId(), (double)(et - st)/1000.0); - } while(0); + } // start loop to consume result TAOS_RES* res = NULL; while(1) { - for (int i = 0; i < g_queryInfo.superQueryInfo.sqlCount; i++) { - if (ASYNC_MODE == g_queryInfo.superQueryInfo.asyncMode) { - continue; - } + for (uint64_t i = pThreadInfo->start_table_from; i <= pThreadInfo->end_table_to; i++) { + for (int j = 0; j < g_queryInfo.superQueryInfo.sqlCount; j++) { + if (ASYNC_MODE == g_queryInfo.superQueryInfo.asyncMode) { + continue; + } - res = taos_consume(tsub[i]); - if (res) { - char tmpFile[MAX_FILE_NAME_LEN*2] = {0}; - if (g_queryInfo.superQueryInfo.result[i][0] != 0) { - sprintf(tmpFile, "%s-%d", - g_queryInfo.superQueryInfo.result[i], + uint64_t subSeq = i * g_queryInfo.superQueryInfo.sqlCount + j; + taosMsleep(100); // ms + res = taos_consume(tsub[subSeq]); + if (res) { + char tmpFile[MAX_FILE_NAME_LEN*2] = {0}; + if (g_queryInfo.superQueryInfo.result[j][0] != 0) { + sprintf(tmpFile, "%s-%d", + g_queryInfo.superQueryInfo.result[j], pThreadInfo->threadID); - appendResultToFile(res, tmpFile); + appendResultToFile(res, tmpFile); + } } } } } taos_free_result(res); - for (int i = 0; i < g_queryInfo.superQueryInfo.sqlCount; i++) { - taos_unsubscribe(tsub[i], g_queryInfo.superQueryInfo.subscribeKeepProgress); + for (uint64_t i = pThreadInfo->start_table_from; + i <= pThreadInfo->end_table_to; i++) { + for (int j = 0; j < g_queryInfo.superQueryInfo.sqlCount; j++) { + uint64_t subSeq = i * g_queryInfo.superQueryInfo.sqlCount + j; + taos_unsubscribe(tsub[subSeq], + g_queryInfo.superQueryInfo.subscribeKeepProgress); + } } taos_close(pThreadInfo->taos); @@ -6607,17 +6607,8 @@ static void *specifiedSubscribe(void *sarg) { return NULL; } - //int64_t st = 0; - //int64_t et = 0; - do { - //if (g_queryInfo.specifiedQueryInfo.queryInterval && (et - st) < g_queryInfo.specifiedQueryInfo.queryInterval) { - // taosMsleep(g_queryInfo.specifiedQueryInfo.queryInterval- (et - st)); // ms - // //printf("========sleep duration:%"PRIu64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, pThreadInfo->start_table_from, pThreadInfo->end_table_to); - //} - - //st = taosGetTimestampMs(); - char topic[32] = {0}; - for (int i = 0; i < g_queryInfo.specifiedQueryInfo.sqlCount; i++) { + char topic[32] = {0}; + for (int i = 0; i < g_queryInfo.specifiedQueryInfo.sqlCount; i++) { sprintf(topic, "taosdemo-subscribe-%d", i); char tmpFile[MAX_FILE_NAME_LEN*2] = {0}; if (g_queryInfo.specifiedQueryInfo.result[i][0] != 0) { @@ -6630,11 +6621,7 @@ static void *specifiedSubscribe(void *sarg) { taos_close(pThreadInfo->taos); return NULL; } - } - //et = taosGetTimestampMs(); - //printf("========thread[%"PRIu64"] complete all sqls to super table once queries duration:%.4fs\n", taosGetSelfPthreadId(), (double)(et - st)/1000.0); - } while(0); - + } // start loop to consume result TAOS_RES* res = NULL; while(1) { @@ -6643,6 +6630,7 @@ static void *specifiedSubscribe(void *sarg) { continue; } + taosMsleep(1000); // ms res = taos_consume(tsub[i]); if (res) { char tmpFile[MAX_FILE_NAME_LEN*2] = {0}; @@ -6699,31 +6687,35 @@ static int subscribeTestProcess() { pthread_t *pids = NULL; threadInfo *infos = NULL; - //==== create sub threads for query from super table - if ((g_queryInfo.specifiedQueryInfo.sqlCount <= 0) || - (g_queryInfo.specifiedQueryInfo.concurrent <= 0)) { - errorPrint("%s() LN%d, query sqlCount %"PRIu64" or concurrent %"PRIu64" is not correct.\n", + //==== create sub threads for query for specified table + if (g_queryInfo.specifiedQueryInfo.sqlCount <= 0) { + printf("%s() LN%d, sepcified query sqlCount %"PRIu64".\n", __func__, __LINE__, - g_queryInfo.specifiedQueryInfo.sqlCount, - g_queryInfo.specifiedQueryInfo.concurrent); - exit(-1); - } + g_queryInfo.specifiedQueryInfo.sqlCount); + } else { + if (g_queryInfo.specifiedQueryInfo.concurrent <= 0) { + errorPrint("%s() LN%d, sepcified query sqlCount %"PRIu64".\n", + __func__, __LINE__, + g_queryInfo.specifiedQueryInfo.sqlCount); + exit(-1); + } - pids = malloc(g_queryInfo.specifiedQueryInfo.concurrent * sizeof(pthread_t)); - infos = malloc(g_queryInfo.specifiedQueryInfo.concurrent * sizeof(threadInfo)); - if ((NULL == pids) || (NULL == infos)) { - errorPrint("%s() LN%d, malloc failed for create threads\n", __func__, __LINE__); - exit(-1); - } + pids = malloc(g_queryInfo.specifiedQueryInfo.concurrent * sizeof(pthread_t)); + infos = malloc(g_queryInfo.specifiedQueryInfo.concurrent * sizeof(threadInfo)); + if ((NULL == pids) || (NULL == infos)) { + errorPrint("%s() LN%d, malloc failed for create threads\n", __func__, __LINE__); + exit(-1); + } - for (int i = 0; i < g_queryInfo.specifiedQueryInfo.concurrent; i++) { + for (int i = 0; i < g_queryInfo.specifiedQueryInfo.concurrent; i++) { threadInfo *t_info = infos + i; t_info->threadID = i; t_info->taos = NULL; // TODO: workaround to use separate taos connection; pthread_create(pids + i, NULL, specifiedSubscribe, t_info); + } } - //==== create sub threads for query from sub table + //==== create sub threads for super table query pthread_t *pidsOfSub = NULL; threadInfo *infosOfSub = NULL; if ((g_queryInfo.superQueryInfo.sqlCount > 0) diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index fd922240c2d452f125ce07c77a7faef84f2a31be..8ef8ef0e2b3080ce334686f7fdbb7105596356e5 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -94,6 +94,10 @@ cmd ::= SHOW CREATE TABLE ids(X) cpxName(Y). { X.n += Y.n; setDCLSqlElems(pInfo, TSDB_SQL_SHOW_CREATE_TABLE, 1, &X); } +cmd ::= SHOW CREATE STABLE ids(X) cpxName(Y). { + X.n += Y.n; + setDCLSqlElems(pInfo, TSDB_SQL_SHOW_CREATE_STABLE, 1, &X); +} cmd ::= SHOW CREATE DATABASE ids(X). { setDCLSqlElems(pInfo, TSDB_SQL_SHOW_CREATE_DATABASE, 1, &X); diff --git a/src/query/src/sql.c b/src/query/src/sql.c index e78e177eed4ad85db45e27dfd73970050d5ec10b..5a5038be796dc6c244f08e7acfe7b5de30d71b28 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -127,17 +127,17 @@ typedef union { #define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo #define ParseARG_STORE yypParser->pInfo = pInfo #define YYFALLBACK 1 -#define YYNSTATE 315 -#define YYNRULE 269 +#define YYNSTATE 317 +#define YYNRULE 270 #define YYNTOKEN 187 -#define YY_MAX_SHIFT 314 -#define YY_MIN_SHIFTREDUCE 508 -#define YY_MAX_SHIFTREDUCE 776 -#define YY_ERROR_ACTION 777 -#define YY_ACCEPT_ACTION 778 -#define YY_NO_ACTION 779 -#define YY_MIN_REDUCE 780 -#define YY_MAX_REDUCE 1048 +#define YY_MAX_SHIFT 316 +#define YY_MIN_SHIFTREDUCE 511 +#define YY_MAX_SHIFTREDUCE 780 +#define YY_ERROR_ACTION 781 +#define YY_ACCEPT_ACTION 782 +#define YY_NO_ACTION 783 +#define YY_MIN_REDUCE 784 +#define YY_MAX_REDUCE 1053 /************* End control #defines *******************************************/ /* Define the yytestcase() macro to be a no-op if is not already defined @@ -203,148 +203,148 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (683) +#define YY_ACTTAB_COUNT (685) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 133, 555, 204, 312, 208, 140, 947, 226, 140, 556, - /* 10 */ 778, 314, 17, 47, 48, 140, 51, 52, 30, 181, - /* 20 */ 214, 41, 181, 50, 262, 55, 53, 57, 54, 1029, - /* 30 */ 926, 211, 1030, 46, 45, 179, 181, 44, 43, 42, - /* 40 */ 47, 48, 924, 51, 52, 210, 1030, 214, 41, 555, - /* 50 */ 50, 262, 55, 53, 57, 54, 938, 556, 185, 205, - /* 60 */ 46, 45, 923, 247, 44, 43, 42, 48, 944, 51, - /* 70 */ 52, 242, 978, 214, 41, 79, 50, 262, 55, 53, - /* 80 */ 57, 54, 979, 634, 257, 30, 46, 45, 278, 225, - /* 90 */ 44, 43, 42, 509, 510, 511, 512, 513, 514, 515, - /* 100 */ 516, 517, 518, 519, 520, 521, 313, 555, 85, 231, - /* 110 */ 70, 288, 287, 47, 48, 556, 51, 52, 298, 219, - /* 120 */ 214, 41, 555, 50, 262, 55, 53, 57, 54, 922, - /* 130 */ 556, 105, 720, 46, 45, 1026, 298, 44, 43, 42, - /* 140 */ 47, 49, 914, 51, 52, 926, 140, 214, 41, 234, - /* 150 */ 50, 262, 55, 53, 57, 54, 1025, 238, 237, 227, - /* 160 */ 46, 45, 285, 284, 44, 43, 42, 23, 276, 307, - /* 170 */ 306, 275, 274, 273, 305, 272, 304, 303, 302, 271, - /* 180 */ 301, 300, 886, 30, 874, 875, 876, 877, 878, 879, - /* 190 */ 880, 881, 882, 883, 884, 885, 887, 888, 51, 52, - /* 200 */ 825, 1024, 214, 41, 166, 50, 262, 55, 53, 57, - /* 210 */ 54, 259, 18, 78, 82, 46, 45, 61, 223, 44, - /* 220 */ 43, 42, 213, 735, 217, 25, 724, 923, 727, 190, - /* 230 */ 730, 221, 213, 735, 198, 191, 724, 912, 727, 62, - /* 240 */ 730, 118, 117, 189, 69, 909, 910, 29, 913, 44, - /* 250 */ 43, 42, 30, 74, 200, 201, 308, 926, 261, 30, - /* 260 */ 23, 36, 307, 306, 200, 201, 938, 305, 30, 304, - /* 270 */ 303, 302, 74, 301, 300, 894, 911, 199, 892, 893, - /* 280 */ 36, 206, 926, 895, 920, 897, 898, 896, 224, 899, - /* 290 */ 900, 280, 658, 218, 834, 655, 923, 656, 166, 657, - /* 300 */ 281, 673, 241, 923, 68, 55, 53, 57, 54, 282, - /* 310 */ 197, 263, 923, 46, 45, 30, 278, 44, 43, 42, - /* 320 */ 80, 103, 108, 228, 229, 56, 220, 97, 107, 113, - /* 330 */ 116, 106, 736, 71, 726, 56, 729, 110, 732, 30, - /* 340 */ 1, 154, 736, 5, 156, 725, 183, 728, 732, 33, - /* 350 */ 155, 92, 87, 91, 731, 680, 286, 184, 826, 923, - /* 360 */ 174, 170, 166, 245, 731, 212, 172, 169, 121, 120, - /* 370 */ 119, 46, 45, 3, 167, 44, 43, 42, 12, 677, - /* 380 */ 290, 722, 84, 923, 81, 670, 311, 310, 126, 701, - /* 390 */ 702, 243, 24, 686, 692, 31, 693, 135, 60, 756, - /* 400 */ 20, 659, 737, 19, 64, 186, 19, 739, 644, 6, - /* 410 */ 180, 265, 31, 187, 646, 31, 267, 723, 60, 645, - /* 420 */ 83, 188, 28, 60, 65, 268, 662, 67, 663, 633, - /* 430 */ 96, 95, 660, 194, 661, 115, 114, 14, 13, 102, - /* 440 */ 101, 195, 16, 15, 131, 129, 733, 193, 178, 192, - /* 450 */ 182, 1040, 925, 989, 988, 215, 985, 734, 239, 984, - /* 460 */ 216, 289, 132, 946, 39, 971, 954, 970, 956, 939, - /* 470 */ 246, 130, 248, 134, 138, 921, 150, 244, 151, 207, - /* 480 */ 250, 299, 685, 149, 919, 255, 142, 936, 143, 141, - /* 490 */ 144, 152, 256, 153, 260, 258, 66, 145, 837, 270, - /* 500 */ 63, 37, 58, 176, 34, 254, 279, 833, 1045, 252, - /* 510 */ 93, 1044, 1042, 249, 147, 157, 283, 1039, 99, 1038, - /* 520 */ 146, 1036, 158, 855, 35, 32, 38, 177, 822, 40, - /* 530 */ 109, 104, 820, 111, 112, 818, 817, 230, 168, 815, - /* 540 */ 814, 813, 812, 811, 810, 171, 173, 807, 805, 803, - /* 550 */ 291, 801, 799, 175, 292, 72, 75, 293, 251, 972, - /* 560 */ 294, 295, 296, 297, 309, 776, 202, 232, 222, 269, - /* 570 */ 233, 775, 236, 235, 774, 761, 203, 762, 88, 196, - /* 580 */ 89, 240, 245, 264, 8, 73, 76, 665, 687, 690, - /* 590 */ 816, 161, 136, 122, 856, 159, 164, 160, 162, 163, - /* 600 */ 165, 123, 809, 2, 890, 124, 808, 4, 125, 800, - /* 610 */ 137, 209, 77, 148, 253, 26, 694, 139, 9, 902, - /* 620 */ 10, 27, 738, 7, 11, 740, 21, 22, 266, 86, - /* 630 */ 597, 593, 84, 591, 590, 589, 586, 559, 277, 90, - /* 640 */ 31, 94, 98, 59, 100, 636, 635, 632, 581, 579, - /* 650 */ 571, 577, 573, 575, 569, 567, 600, 599, 598, 596, - /* 660 */ 595, 594, 592, 588, 587, 60, 557, 525, 523, 780, - /* 670 */ 779, 779, 779, 779, 779, 779, 779, 779, 779, 779, - /* 680 */ 779, 127, 128, + /* 0 */ 925, 559, 206, 314, 211, 141, 952, 3, 168, 560, + /* 10 */ 782, 316, 134, 47, 48, 141, 51, 52, 30, 183, + /* 20 */ 217, 41, 183, 50, 264, 55, 53, 57, 54, 1034, + /* 30 */ 931, 214, 1035, 46, 45, 17, 183, 44, 43, 42, + /* 40 */ 47, 48, 223, 51, 52, 213, 1035, 217, 41, 559, + /* 50 */ 50, 264, 55, 53, 57, 54, 943, 560, 181, 208, + /* 60 */ 46, 45, 928, 222, 44, 43, 42, 48, 949, 51, + /* 70 */ 52, 244, 983, 217, 41, 249, 50, 264, 55, 53, + /* 80 */ 57, 54, 984, 638, 259, 85, 46, 45, 280, 931, + /* 90 */ 44, 43, 42, 512, 513, 514, 515, 516, 517, 518, + /* 100 */ 519, 520, 521, 522, 523, 524, 315, 943, 187, 207, + /* 110 */ 70, 290, 289, 47, 48, 30, 51, 52, 300, 919, + /* 120 */ 217, 41, 209, 50, 264, 55, 53, 57, 54, 44, + /* 130 */ 43, 42, 724, 46, 45, 674, 224, 44, 43, 42, + /* 140 */ 47, 49, 24, 51, 52, 228, 141, 217, 41, 559, + /* 150 */ 50, 264, 55, 53, 57, 54, 220, 560, 105, 928, + /* 160 */ 46, 45, 931, 300, 44, 43, 42, 23, 278, 309, + /* 170 */ 308, 277, 276, 275, 307, 274, 306, 305, 304, 273, + /* 180 */ 303, 302, 891, 30, 879, 880, 881, 882, 883, 884, + /* 190 */ 885, 886, 887, 888, 889, 890, 892, 893, 51, 52, + /* 200 */ 830, 1031, 217, 41, 167, 50, 264, 55, 53, 57, + /* 210 */ 54, 261, 18, 78, 230, 46, 45, 287, 286, 44, + /* 220 */ 43, 42, 216, 739, 221, 30, 728, 928, 731, 192, + /* 230 */ 734, 216, 739, 310, 1030, 728, 193, 731, 236, 734, + /* 240 */ 30, 118, 117, 191, 677, 559, 240, 239, 55, 53, + /* 250 */ 57, 54, 25, 560, 202, 203, 46, 45, 263, 931, + /* 260 */ 44, 43, 42, 202, 203, 74, 283, 61, 23, 928, + /* 270 */ 309, 308, 74, 36, 730, 307, 733, 306, 305, 304, + /* 280 */ 36, 303, 302, 899, 927, 662, 897, 898, 659, 62, + /* 290 */ 660, 900, 661, 902, 903, 901, 82, 904, 905, 103, + /* 300 */ 97, 108, 243, 917, 68, 30, 107, 113, 116, 106, + /* 310 */ 199, 5, 33, 157, 141, 110, 231, 232, 156, 92, + /* 320 */ 87, 91, 681, 226, 30, 56, 30, 914, 915, 29, + /* 330 */ 918, 729, 740, 732, 56, 175, 173, 171, 736, 1, + /* 340 */ 155, 740, 170, 121, 120, 119, 284, 736, 229, 928, + /* 350 */ 265, 46, 45, 69, 735, 44, 43, 42, 839, 666, + /* 360 */ 12, 667, 167, 735, 84, 288, 81, 292, 928, 215, + /* 370 */ 928, 313, 312, 126, 132, 130, 129, 80, 705, 706, + /* 380 */ 831, 79, 280, 929, 167, 916, 737, 245, 726, 684, + /* 390 */ 71, 31, 227, 994, 663, 282, 690, 247, 696, 697, + /* 400 */ 136, 760, 60, 20, 741, 19, 64, 648, 19, 241, + /* 410 */ 267, 31, 650, 6, 31, 269, 60, 1029, 649, 83, + /* 420 */ 28, 200, 60, 270, 727, 201, 65, 96, 95, 185, + /* 430 */ 14, 13, 993, 102, 101, 67, 218, 637, 16, 15, + /* 440 */ 664, 186, 665, 738, 115, 114, 743, 188, 182, 189, + /* 450 */ 190, 196, 197, 195, 180, 194, 184, 133, 1045, 990, + /* 460 */ 930, 989, 219, 291, 39, 951, 959, 944, 961, 135, + /* 470 */ 139, 976, 248, 975, 926, 131, 152, 151, 924, 153, + /* 480 */ 250, 154, 689, 210, 252, 150, 257, 145, 142, 842, + /* 490 */ 941, 143, 272, 144, 262, 37, 146, 66, 58, 178, + /* 500 */ 63, 260, 34, 258, 256, 281, 838, 147, 1050, 254, + /* 510 */ 93, 1049, 1047, 158, 285, 1044, 99, 148, 1043, 1041, + /* 520 */ 159, 860, 251, 35, 32, 38, 149, 179, 827, 109, + /* 530 */ 825, 111, 112, 823, 822, 233, 169, 820, 819, 818, + /* 540 */ 817, 816, 815, 172, 174, 40, 812, 810, 808, 806, + /* 550 */ 176, 803, 177, 301, 246, 72, 75, 104, 253, 977, + /* 560 */ 293, 294, 295, 296, 297, 204, 225, 298, 271, 299, + /* 570 */ 311, 780, 205, 198, 234, 88, 89, 235, 779, 237, + /* 580 */ 238, 778, 766, 765, 242, 247, 821, 814, 162, 266, + /* 590 */ 122, 861, 160, 165, 161, 164, 163, 166, 123, 124, + /* 600 */ 813, 805, 895, 125, 804, 2, 8, 73, 4, 669, + /* 610 */ 76, 691, 137, 212, 694, 86, 138, 77, 907, 255, + /* 620 */ 9, 698, 140, 26, 742, 7, 27, 11, 10, 21, + /* 630 */ 84, 744, 22, 268, 601, 597, 595, 594, 593, 590, + /* 640 */ 563, 279, 94, 90, 31, 59, 640, 639, 636, 585, + /* 650 */ 583, 98, 575, 581, 577, 579, 573, 571, 604, 603, + /* 660 */ 602, 600, 599, 100, 598, 596, 592, 591, 60, 561, + /* 670 */ 528, 784, 526, 783, 783, 783, 783, 783, 783, 127, + /* 680 */ 783, 783, 783, 783, 128, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 191, 1, 190, 191, 210, 191, 191, 191, 191, 9, - /* 10 */ 188, 189, 252, 13, 14, 191, 16, 17, 191, 252, + /* 0 */ 191, 1, 190, 191, 210, 191, 191, 194, 195, 9, + /* 10 */ 188, 189, 191, 13, 14, 191, 16, 17, 191, 252, /* 20 */ 20, 21, 252, 23, 24, 25, 26, 27, 28, 262, /* 30 */ 236, 261, 262, 33, 34, 252, 252, 37, 38, 39, - /* 40 */ 13, 14, 226, 16, 17, 261, 262, 20, 21, 1, + /* 40 */ 13, 14, 233, 16, 17, 261, 262, 20, 21, 1, /* 50 */ 23, 24, 25, 26, 27, 28, 234, 9, 252, 232, - /* 60 */ 33, 34, 235, 254, 37, 38, 39, 14, 253, 16, - /* 70 */ 17, 249, 258, 20, 21, 258, 23, 24, 25, 26, - /* 80 */ 27, 28, 258, 5, 260, 191, 33, 34, 79, 67, + /* 60 */ 33, 34, 235, 210, 37, 38, 39, 14, 253, 16, + /* 70 */ 17, 249, 258, 20, 21, 254, 23, 24, 25, 26, + /* 80 */ 27, 28, 258, 5, 260, 197, 33, 34, 79, 236, /* 90 */ 37, 38, 39, 45, 46, 47, 48, 49, 50, 51, - /* 100 */ 52, 53, 54, 55, 56, 57, 58, 1, 197, 61, - /* 110 */ 110, 33, 34, 13, 14, 9, 16, 17, 81, 210, - /* 120 */ 20, 21, 1, 23, 24, 25, 26, 27, 28, 235, - /* 130 */ 9, 76, 105, 33, 34, 252, 81, 37, 38, 39, - /* 140 */ 13, 14, 231, 16, 17, 236, 191, 20, 21, 135, - /* 150 */ 23, 24, 25, 26, 27, 28, 252, 143, 144, 137, - /* 160 */ 33, 34, 140, 141, 37, 38, 39, 88, 89, 90, + /* 100 */ 52, 53, 54, 55, 56, 57, 58, 234, 252, 61, + /* 110 */ 110, 33, 34, 13, 14, 191, 16, 17, 81, 231, + /* 120 */ 20, 21, 249, 23, 24, 25, 26, 27, 28, 37, + /* 130 */ 38, 39, 105, 33, 34, 109, 210, 37, 38, 39, + /* 140 */ 13, 14, 116, 16, 17, 68, 191, 20, 21, 1, + /* 150 */ 23, 24, 25, 26, 27, 28, 232, 9, 76, 235, + /* 160 */ 33, 34, 236, 81, 37, 38, 39, 88, 89, 90, /* 170 */ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, /* 180 */ 101, 102, 209, 191, 211, 212, 213, 214, 215, 216, /* 190 */ 217, 218, 219, 220, 221, 222, 223, 224, 16, 17, /* 200 */ 196, 252, 20, 21, 200, 23, 24, 25, 26, 27, - /* 210 */ 28, 256, 44, 258, 197, 33, 34, 109, 67, 37, - /* 220 */ 38, 39, 1, 2, 232, 104, 5, 235, 7, 61, - /* 230 */ 9, 210, 1, 2, 252, 67, 5, 0, 7, 131, - /* 240 */ 9, 73, 74, 75, 197, 228, 229, 230, 231, 37, - /* 250 */ 38, 39, 191, 104, 33, 34, 210, 236, 37, 191, - /* 260 */ 88, 112, 90, 91, 33, 34, 234, 95, 191, 97, - /* 270 */ 98, 99, 104, 101, 102, 209, 229, 252, 212, 213, - /* 280 */ 112, 249, 236, 217, 191, 219, 220, 221, 137, 223, - /* 290 */ 224, 140, 2, 232, 196, 5, 235, 7, 200, 9, - /* 300 */ 232, 37, 134, 235, 136, 25, 26, 27, 28, 232, - /* 310 */ 142, 15, 235, 33, 34, 191, 79, 37, 38, 39, - /* 320 */ 237, 62, 63, 33, 34, 104, 233, 68, 69, 70, - /* 330 */ 71, 72, 111, 250, 5, 104, 7, 78, 117, 191, - /* 340 */ 198, 199, 111, 62, 63, 5, 252, 7, 117, 68, - /* 350 */ 69, 70, 71, 72, 133, 105, 232, 252, 196, 235, - /* 360 */ 62, 63, 200, 113, 133, 60, 68, 69, 70, 71, - /* 370 */ 72, 33, 34, 194, 195, 37, 38, 39, 104, 115, - /* 380 */ 232, 1, 108, 235, 110, 109, 64, 65, 66, 124, - /* 390 */ 125, 105, 116, 105, 105, 109, 105, 109, 109, 105, - /* 400 */ 109, 111, 105, 109, 109, 252, 109, 111, 105, 104, - /* 410 */ 252, 105, 109, 252, 105, 109, 105, 37, 109, 105, - /* 420 */ 109, 252, 104, 109, 129, 107, 5, 104, 7, 106, - /* 430 */ 138, 139, 5, 252, 7, 76, 77, 138, 139, 138, - /* 440 */ 139, 252, 138, 139, 62, 63, 117, 252, 252, 252, - /* 450 */ 252, 236, 236, 227, 227, 227, 227, 117, 191, 227, - /* 460 */ 227, 227, 191, 191, 251, 259, 191, 259, 191, 234, - /* 470 */ 234, 60, 255, 191, 191, 234, 238, 192, 191, 255, - /* 480 */ 255, 103, 117, 239, 191, 255, 246, 248, 245, 247, - /* 490 */ 244, 191, 121, 191, 122, 126, 128, 243, 191, 191, - /* 500 */ 130, 191, 127, 191, 191, 120, 191, 191, 191, 119, - /* 510 */ 191, 191, 191, 118, 241, 191, 191, 191, 191, 191, - /* 520 */ 242, 191, 191, 191, 191, 191, 191, 191, 191, 132, - /* 530 */ 191, 87, 191, 191, 191, 191, 191, 191, 191, 191, - /* 540 */ 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, - /* 550 */ 86, 191, 191, 191, 50, 192, 192, 83, 192, 192, - /* 560 */ 85, 54, 84, 82, 79, 5, 192, 145, 192, 192, - /* 570 */ 5, 5, 5, 145, 5, 89, 192, 90, 197, 192, - /* 580 */ 197, 135, 113, 107, 104, 114, 109, 105, 105, 105, - /* 590 */ 192, 202, 104, 193, 208, 207, 204, 206, 205, 203, - /* 600 */ 201, 193, 192, 198, 225, 193, 192, 194, 193, 192, - /* 610 */ 109, 1, 104, 240, 104, 109, 105, 104, 123, 225, - /* 620 */ 123, 109, 105, 104, 104, 111, 104, 104, 107, 76, - /* 630 */ 9, 5, 108, 5, 5, 5, 5, 80, 15, 76, - /* 640 */ 109, 139, 139, 16, 139, 5, 5, 105, 5, 5, - /* 650 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - /* 660 */ 5, 5, 5, 5, 5, 109, 80, 60, 59, 0, - /* 670 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, - /* 680 */ 263, 21, 21, 263, 263, 263, 263, 263, 263, 263, + /* 210 */ 28, 256, 44, 258, 137, 33, 34, 140, 141, 37, + /* 220 */ 38, 39, 1, 2, 232, 191, 5, 235, 7, 61, + /* 230 */ 9, 1, 2, 210, 252, 5, 68, 7, 135, 9, + /* 240 */ 191, 73, 74, 75, 37, 1, 143, 144, 25, 26, + /* 250 */ 27, 28, 104, 9, 33, 34, 33, 34, 37, 236, + /* 260 */ 37, 38, 39, 33, 34, 104, 232, 109, 88, 235, + /* 270 */ 90, 91, 104, 112, 5, 95, 7, 97, 98, 99, + /* 280 */ 112, 101, 102, 209, 235, 2, 212, 213, 5, 131, + /* 290 */ 7, 217, 9, 219, 220, 221, 197, 223, 224, 62, + /* 300 */ 63, 64, 134, 0, 136, 191, 69, 70, 71, 72, + /* 310 */ 142, 62, 63, 64, 191, 78, 33, 34, 69, 70, + /* 320 */ 71, 72, 115, 68, 191, 104, 191, 228, 229, 230, + /* 330 */ 231, 5, 111, 7, 104, 62, 63, 64, 117, 198, + /* 340 */ 199, 111, 69, 70, 71, 72, 232, 117, 191, 235, + /* 350 */ 15, 33, 34, 197, 133, 37, 38, 39, 196, 5, + /* 360 */ 104, 7, 200, 133, 108, 232, 110, 232, 235, 60, + /* 370 */ 235, 65, 66, 67, 62, 63, 64, 237, 124, 125, + /* 380 */ 196, 258, 79, 226, 200, 229, 117, 105, 1, 105, + /* 390 */ 250, 109, 137, 227, 111, 140, 105, 113, 105, 105, + /* 400 */ 109, 105, 109, 109, 105, 109, 109, 105, 109, 191, + /* 410 */ 105, 109, 105, 104, 109, 105, 109, 252, 105, 109, + /* 420 */ 104, 252, 109, 107, 37, 252, 129, 138, 139, 252, + /* 430 */ 138, 139, 227, 138, 139, 104, 227, 106, 138, 139, + /* 440 */ 5, 252, 7, 117, 76, 77, 111, 252, 252, 252, + /* 450 */ 252, 252, 252, 252, 252, 252, 252, 191, 236, 227, + /* 460 */ 236, 227, 227, 227, 251, 191, 191, 234, 191, 191, + /* 470 */ 191, 259, 234, 259, 234, 60, 191, 238, 191, 191, + /* 480 */ 255, 191, 117, 255, 255, 239, 255, 244, 247, 191, + /* 490 */ 248, 246, 191, 245, 122, 191, 243, 128, 127, 191, + /* 500 */ 130, 126, 191, 121, 120, 191, 191, 242, 191, 119, + /* 510 */ 191, 191, 191, 191, 191, 191, 191, 241, 191, 191, + /* 520 */ 191, 191, 118, 191, 191, 191, 240, 191, 191, 191, + /* 530 */ 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, + /* 540 */ 191, 191, 191, 191, 191, 132, 191, 191, 191, 191, + /* 550 */ 191, 191, 191, 103, 192, 192, 192, 87, 192, 192, + /* 560 */ 86, 50, 83, 85, 54, 192, 192, 84, 192, 82, + /* 570 */ 79, 5, 192, 192, 145, 197, 197, 5, 5, 145, + /* 580 */ 5, 5, 90, 89, 135, 113, 192, 192, 202, 107, + /* 590 */ 193, 208, 207, 204, 206, 203, 205, 201, 193, 193, + /* 600 */ 192, 192, 225, 193, 192, 198, 104, 114, 194, 105, + /* 610 */ 109, 105, 104, 1, 105, 76, 109, 104, 225, 104, + /* 620 */ 123, 105, 104, 109, 105, 104, 109, 104, 123, 104, + /* 630 */ 108, 111, 104, 107, 9, 5, 5, 5, 5, 5, + /* 640 */ 80, 15, 139, 76, 109, 16, 5, 5, 105, 5, + /* 650 */ 5, 139, 5, 5, 5, 5, 5, 5, 5, 5, + /* 660 */ 5, 5, 5, 139, 5, 5, 5, 5, 109, 80, + /* 670 */ 60, 0, 59, 263, 263, 263, 263, 263, 263, 21, + /* 680 */ 263, 263, 263, 263, 21, 263, 263, 263, 263, 263, /* 690 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, /* 700 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, /* 710 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, @@ -363,100 +363,101 @@ static const YYCODETYPE yy_lookahead[] = { /* 840 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, /* 850 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, /* 860 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, + /* 870 */ 263, 263, }; -#define YY_SHIFT_COUNT (314) +#define YY_SHIFT_COUNT (316) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (669) +#define YY_SHIFT_MAX (671) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 168, 79, 79, 172, 172, 9, 221, 231, 106, 106, - /* 10 */ 106, 106, 106, 106, 106, 106, 106, 0, 48, 231, - /* 20 */ 290, 290, 290, 290, 121, 149, 106, 106, 106, 237, - /* 30 */ 106, 106, 55, 9, 37, 37, 683, 683, 683, 231, - /* 40 */ 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, - /* 50 */ 231, 231, 231, 231, 231, 231, 231, 231, 231, 290, - /* 60 */ 290, 78, 78, 78, 78, 78, 78, 78, 106, 106, - /* 70 */ 106, 264, 106, 149, 149, 106, 106, 106, 265, 265, - /* 80 */ 276, 149, 106, 106, 106, 106, 106, 106, 106, 106, - /* 90 */ 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, - /* 100 */ 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, - /* 110 */ 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, - /* 120 */ 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, - /* 130 */ 106, 106, 411, 411, 411, 365, 365, 365, 411, 365, - /* 140 */ 411, 368, 370, 375, 372, 369, 371, 385, 390, 395, - /* 150 */ 397, 411, 411, 411, 378, 9, 9, 411, 411, 444, - /* 160 */ 464, 504, 474, 475, 507, 478, 481, 378, 411, 485, - /* 170 */ 485, 411, 485, 411, 485, 411, 683, 683, 27, 100, - /* 180 */ 127, 100, 100, 53, 182, 280, 280, 280, 280, 259, - /* 190 */ 281, 298, 338, 338, 338, 338, 22, 14, 212, 212, - /* 200 */ 329, 340, 274, 151, 322, 286, 250, 288, 289, 291, - /* 210 */ 294, 297, 380, 305, 296, 108, 295, 303, 306, 309, - /* 220 */ 311, 314, 318, 292, 299, 301, 323, 304, 421, 427, - /* 230 */ 359, 382, 560, 422, 565, 566, 428, 567, 569, 487, - /* 240 */ 486, 446, 469, 476, 480, 471, 482, 477, 483, 488, - /* 250 */ 484, 501, 508, 610, 510, 511, 513, 506, 495, 512, - /* 260 */ 497, 517, 519, 514, 520, 476, 522, 521, 523, 524, - /* 270 */ 553, 621, 626, 628, 629, 630, 631, 557, 623, 563, - /* 280 */ 502, 531, 531, 627, 503, 505, 531, 640, 641, 542, - /* 290 */ 531, 643, 644, 645, 646, 647, 648, 649, 650, 651, - /* 300 */ 652, 653, 654, 655, 656, 657, 658, 659, 556, 586, - /* 310 */ 660, 661, 607, 609, 669, + /* 0 */ 168, 79, 79, 180, 180, 9, 221, 230, 244, 244, + /* 10 */ 244, 244, 244, 244, 244, 244, 244, 0, 48, 230, + /* 20 */ 283, 283, 283, 283, 148, 161, 244, 244, 244, 303, + /* 30 */ 244, 244, 82, 9, 37, 37, 685, 685, 685, 230, + /* 40 */ 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, + /* 50 */ 230, 230, 230, 230, 230, 230, 230, 230, 230, 283, + /* 60 */ 283, 78, 78, 78, 78, 78, 78, 78, 244, 244, + /* 70 */ 244, 207, 244, 161, 161, 244, 244, 244, 254, 254, + /* 80 */ 26, 161, 244, 244, 244, 244, 244, 244, 244, 244, + /* 90 */ 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + /* 100 */ 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + /* 110 */ 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + /* 120 */ 244, 244, 244, 244, 244, 244, 244, 244, 244, 244, + /* 130 */ 244, 244, 244, 415, 415, 415, 365, 365, 365, 415, + /* 140 */ 365, 415, 369, 370, 371, 372, 375, 382, 384, 390, + /* 150 */ 404, 413, 415, 415, 415, 450, 9, 9, 415, 415, + /* 160 */ 470, 474, 511, 479, 478, 510, 483, 487, 450, 415, + /* 170 */ 491, 491, 415, 491, 415, 491, 415, 415, 685, 685, + /* 180 */ 27, 100, 127, 100, 100, 53, 182, 223, 223, 223, + /* 190 */ 223, 237, 249, 273, 318, 318, 318, 318, 77, 103, + /* 200 */ 92, 92, 269, 326, 256, 255, 306, 312, 282, 284, + /* 210 */ 291, 293, 294, 296, 299, 387, 309, 335, 158, 297, + /* 220 */ 302, 305, 307, 310, 313, 316, 289, 292, 295, 331, + /* 230 */ 300, 354, 435, 368, 566, 429, 572, 573, 434, 575, + /* 240 */ 576, 492, 494, 449, 472, 482, 502, 493, 504, 501, + /* 250 */ 506, 508, 509, 507, 513, 612, 515, 516, 518, 514, + /* 260 */ 497, 517, 505, 519, 521, 520, 523, 482, 525, 526, + /* 270 */ 528, 522, 539, 625, 630, 631, 632, 633, 634, 560, + /* 280 */ 626, 567, 503, 535, 535, 629, 512, 524, 535, 641, + /* 290 */ 642, 543, 535, 644, 645, 647, 648, 649, 650, 651, + /* 300 */ 652, 653, 654, 655, 656, 657, 659, 660, 661, 662, + /* 310 */ 559, 589, 658, 663, 610, 613, 671, }; -#define YY_REDUCE_COUNT (177) -#define YY_REDUCE_MIN (-240) -#define YY_REDUCE_MAX (417) +#define YY_REDUCE_COUNT (179) +#define YY_REDUCE_MIN (-233) +#define YY_REDUCE_MAX (414) static const short yy_reduce_ofst[] = { - /* 0 */ -178, -27, -27, 66, 66, 17, -230, -216, -173, -176, - /* 10 */ -45, -8, 61, 68, 77, 124, 148, -185, -188, -233, - /* 20 */ -206, -91, 21, 46, -191, 32, -186, -183, 93, -89, - /* 30 */ -184, -106, 4, 47, 98, 162, 83, 142, 179, -240, - /* 40 */ -217, -194, -117, -96, -51, -18, 25, 94, 105, 153, - /* 50 */ 158, 161, 169, 181, 189, 195, 196, 197, 198, 215, - /* 60 */ 216, 226, 227, 228, 229, 232, 233, 234, 267, 271, - /* 70 */ 272, 213, 275, 235, 236, 277, 282, 283, 206, 208, - /* 80 */ 238, 241, 287, 293, 300, 302, 307, 308, 310, 312, - /* 90 */ 313, 315, 316, 317, 319, 320, 321, 324, 325, 326, - /* 100 */ 327, 328, 330, 331, 332, 333, 334, 335, 336, 337, - /* 110 */ 339, 341, 342, 343, 344, 345, 346, 347, 348, 349, - /* 120 */ 350, 351, 352, 353, 354, 355, 356, 357, 358, 360, - /* 130 */ 361, 362, 285, 363, 364, 217, 224, 225, 366, 230, - /* 140 */ 367, 239, 242, 240, 243, 246, 254, 278, 273, 373, - /* 150 */ 244, 374, 376, 377, 379, 381, 383, 384, 387, 386, - /* 160 */ 388, 391, 389, 393, 396, 392, 399, 394, 398, 400, - /* 170 */ 408, 410, 412, 414, 415, 417, 405, 413, + /* 0 */ -178, -27, -27, 74, 74, 99, -230, -216, -173, -176, + /* 10 */ -45, -76, -8, 34, 114, 133, 135, -185, -188, -233, + /* 20 */ -206, -147, -74, 23, -179, -127, -186, 123, -191, -112, + /* 30 */ 157, 49, 4, 156, 162, 184, 140, 141, -187, -217, + /* 40 */ -194, -144, -51, -18, 165, 169, 173, 177, 189, 195, + /* 50 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 222, + /* 60 */ 224, 166, 205, 209, 232, 234, 235, 236, 218, 266, + /* 70 */ 274, 213, 275, 233, 238, 277, 278, 279, 212, 214, + /* 80 */ 239, 240, 285, 287, 288, 290, 298, 301, 304, 308, + /* 90 */ 311, 314, 315, 317, 319, 320, 321, 322, 323, 324, + /* 100 */ 325, 327, 328, 329, 330, 332, 333, 334, 336, 337, + /* 110 */ 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, + /* 120 */ 348, 349, 350, 351, 352, 353, 355, 356, 357, 358, + /* 130 */ 359, 360, 361, 362, 363, 364, 225, 228, 229, 366, + /* 140 */ 231, 367, 242, 241, 245, 248, 243, 253, 265, 276, + /* 150 */ 286, 246, 373, 374, 376, 377, 378, 379, 380, 381, + /* 160 */ 383, 385, 388, 386, 391, 392, 389, 396, 393, 394, + /* 170 */ 397, 405, 395, 406, 408, 410, 409, 412, 407, 414, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 777, 889, 835, 901, 823, 832, 1032, 1032, 777, 777, - /* 10 */ 777, 777, 777, 777, 777, 777, 777, 948, 796, 1032, - /* 20 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 832, - /* 30 */ 777, 777, 838, 832, 838, 838, 943, 873, 891, 777, - /* 40 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 50 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 60 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 70 */ 777, 950, 953, 777, 777, 955, 777, 777, 975, 975, - /* 80 */ 941, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 90 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 100 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 821, - /* 110 */ 777, 819, 777, 777, 777, 777, 777, 777, 777, 777, - /* 120 */ 777, 777, 777, 777, 777, 777, 806, 777, 777, 777, - /* 130 */ 777, 777, 798, 798, 798, 777, 777, 777, 798, 777, - /* 140 */ 798, 982, 986, 980, 968, 976, 967, 963, 961, 960, - /* 150 */ 990, 798, 798, 798, 836, 832, 832, 798, 798, 854, - /* 160 */ 852, 850, 842, 848, 844, 846, 840, 824, 798, 830, - /* 170 */ 830, 798, 830, 798, 830, 798, 873, 891, 777, 991, - /* 180 */ 777, 1031, 981, 1021, 1020, 1027, 1019, 1018, 1017, 777, - /* 190 */ 777, 777, 1013, 1014, 1016, 1015, 777, 777, 1023, 1022, - /* 200 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 210 */ 777, 777, 777, 993, 777, 987, 983, 777, 777, 777, - /* 220 */ 777, 777, 777, 777, 777, 777, 903, 777, 777, 777, - /* 230 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 240 */ 777, 777, 940, 777, 777, 777, 777, 951, 777, 777, - /* 250 */ 777, 777, 777, 777, 777, 777, 777, 977, 777, 969, - /* 260 */ 777, 777, 777, 777, 777, 915, 777, 777, 777, 777, - /* 270 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 280 */ 777, 1043, 1041, 777, 777, 777, 1037, 777, 777, 777, - /* 290 */ 1035, 777, 777, 777, 777, 777, 777, 777, 777, 777, - /* 300 */ 777, 777, 777, 777, 777, 777, 777, 777, 857, 777, - /* 310 */ 804, 802, 777, 794, 777, + /* 0 */ 781, 894, 840, 906, 828, 837, 1037, 1037, 781, 781, + /* 10 */ 781, 781, 781, 781, 781, 781, 781, 953, 800, 1037, + /* 20 */ 781, 781, 781, 781, 781, 781, 781, 781, 781, 837, + /* 30 */ 781, 781, 843, 837, 843, 843, 948, 878, 896, 781, + /* 40 */ 781, 781, 781, 781, 781, 781, 781, 781, 781, 781, + /* 50 */ 781, 781, 781, 781, 781, 781, 781, 781, 781, 781, + /* 60 */ 781, 781, 781, 781, 781, 781, 781, 781, 781, 781, + /* 70 */ 781, 955, 958, 781, 781, 960, 781, 781, 980, 980, + /* 80 */ 946, 781, 781, 781, 781, 781, 781, 781, 781, 781, + /* 90 */ 781, 781, 781, 781, 781, 781, 781, 781, 781, 781, + /* 100 */ 781, 781, 781, 781, 781, 781, 781, 781, 781, 826, + /* 110 */ 781, 824, 781, 781, 781, 781, 781, 781, 781, 781, + /* 120 */ 781, 781, 781, 781, 781, 781, 811, 781, 781, 781, + /* 130 */ 781, 781, 781, 802, 802, 802, 781, 781, 781, 802, + /* 140 */ 781, 802, 987, 991, 985, 973, 981, 972, 968, 966, + /* 150 */ 965, 995, 802, 802, 802, 841, 837, 837, 802, 802, + /* 160 */ 859, 857, 855, 847, 853, 849, 851, 845, 829, 802, + /* 170 */ 835, 835, 802, 835, 802, 835, 802, 802, 878, 896, + /* 180 */ 781, 996, 781, 1036, 986, 1026, 1025, 1032, 1024, 1023, + /* 190 */ 1022, 781, 781, 781, 1018, 1019, 1021, 1020, 781, 781, + /* 200 */ 1028, 1027, 781, 781, 781, 781, 781, 781, 781, 781, + /* 210 */ 781, 781, 781, 781, 781, 781, 998, 781, 992, 988, + /* 220 */ 781, 781, 781, 781, 781, 781, 781, 781, 781, 908, + /* 230 */ 781, 781, 781, 781, 781, 781, 781, 781, 781, 781, + /* 240 */ 781, 781, 781, 781, 945, 781, 781, 781, 781, 956, + /* 250 */ 781, 781, 781, 781, 781, 781, 781, 781, 781, 982, + /* 260 */ 781, 974, 781, 781, 781, 781, 781, 920, 781, 781, + /* 270 */ 781, 781, 781, 781, 781, 781, 781, 781, 781, 781, + /* 280 */ 781, 781, 781, 1048, 1046, 781, 781, 781, 1042, 781, + /* 290 */ 781, 781, 1040, 781, 781, 781, 781, 781, 781, 781, + /* 300 */ 781, 781, 781, 781, 781, 781, 781, 781, 781, 781, + /* 310 */ 862, 781, 809, 807, 781, 798, 781, }; /********** End of lemon-generated parsing tables *****************************/ @@ -539,12 +540,12 @@ static const YYCODETYPE yyFallback[] = { 0, /* DOT => nothing */ 0, /* CREATE => nothing */ 0, /* TABLE => nothing */ + 1, /* STABLE => ID */ 1, /* DATABASE => ID */ 0, /* TABLES => nothing */ 0, /* STABLES => nothing */ 0, /* VGROUPS => nothing */ 0, /* DROP => nothing */ - 1, /* STABLE => ID */ 0, /* TOPIC => nothing */ 0, /* DNODE => nothing */ 0, /* USER => nothing */ @@ -812,12 +813,12 @@ static const char *const yyTokenName[] = { /* 60 */ "DOT", /* 61 */ "CREATE", /* 62 */ "TABLE", - /* 63 */ "DATABASE", - /* 64 */ "TABLES", - /* 65 */ "STABLES", - /* 66 */ "VGROUPS", - /* 67 */ "DROP", - /* 68 */ "STABLE", + /* 63 */ "STABLE", + /* 64 */ "DATABASE", + /* 65 */ "TABLES", + /* 66 */ "STABLES", + /* 67 */ "VGROUPS", + /* 68 */ "DROP", /* 69 */ "TOPIC", /* 70 */ "DNODE", /* 71 */ "USER", @@ -1040,254 +1041,255 @@ static const char *const yyRuleName[] = { /* 18 */ "cpxName ::=", /* 19 */ "cpxName ::= DOT ids", /* 20 */ "cmd ::= SHOW CREATE TABLE ids cpxName", - /* 21 */ "cmd ::= SHOW CREATE DATABASE ids", - /* 22 */ "cmd ::= SHOW dbPrefix TABLES", - /* 23 */ "cmd ::= SHOW dbPrefix TABLES LIKE ids", - /* 24 */ "cmd ::= SHOW dbPrefix STABLES", - /* 25 */ "cmd ::= SHOW dbPrefix STABLES LIKE ids", - /* 26 */ "cmd ::= SHOW dbPrefix VGROUPS", - /* 27 */ "cmd ::= SHOW dbPrefix VGROUPS ids", - /* 28 */ "cmd ::= DROP TABLE ifexists ids cpxName", - /* 29 */ "cmd ::= DROP STABLE ifexists ids cpxName", - /* 30 */ "cmd ::= DROP DATABASE ifexists ids", - /* 31 */ "cmd ::= DROP TOPIC ifexists ids", - /* 32 */ "cmd ::= DROP DNODE ids", - /* 33 */ "cmd ::= DROP USER ids", - /* 34 */ "cmd ::= DROP ACCOUNT ids", - /* 35 */ "cmd ::= USE ids", - /* 36 */ "cmd ::= DESCRIBE ids cpxName", - /* 37 */ "cmd ::= ALTER USER ids PASS ids", - /* 38 */ "cmd ::= ALTER USER ids PRIVILEGE ids", - /* 39 */ "cmd ::= ALTER DNODE ids ids", - /* 40 */ "cmd ::= ALTER DNODE ids ids ids", - /* 41 */ "cmd ::= ALTER LOCAL ids", - /* 42 */ "cmd ::= ALTER LOCAL ids ids", - /* 43 */ "cmd ::= ALTER DATABASE ids alter_db_optr", - /* 44 */ "cmd ::= ALTER TOPIC ids alter_topic_optr", - /* 45 */ "cmd ::= ALTER ACCOUNT ids acct_optr", - /* 46 */ "cmd ::= ALTER ACCOUNT ids PASS ids acct_optr", - /* 47 */ "ids ::= ID", - /* 48 */ "ids ::= STRING", - /* 49 */ "ifexists ::= IF EXISTS", - /* 50 */ "ifexists ::=", - /* 51 */ "ifnotexists ::= IF NOT EXISTS", - /* 52 */ "ifnotexists ::=", - /* 53 */ "cmd ::= CREATE DNODE ids", - /* 54 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr", - /* 55 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr", - /* 56 */ "cmd ::= CREATE TOPIC ifnotexists ids topic_optr", - /* 57 */ "cmd ::= CREATE USER ids PASS ids", - /* 58 */ "pps ::=", - /* 59 */ "pps ::= PPS INTEGER", - /* 60 */ "tseries ::=", - /* 61 */ "tseries ::= TSERIES INTEGER", - /* 62 */ "dbs ::=", - /* 63 */ "dbs ::= DBS INTEGER", - /* 64 */ "streams ::=", - /* 65 */ "streams ::= STREAMS INTEGER", - /* 66 */ "storage ::=", - /* 67 */ "storage ::= STORAGE INTEGER", - /* 68 */ "qtime ::=", - /* 69 */ "qtime ::= QTIME INTEGER", - /* 70 */ "users ::=", - /* 71 */ "users ::= USERS INTEGER", - /* 72 */ "conns ::=", - /* 73 */ "conns ::= CONNS INTEGER", - /* 74 */ "state ::=", - /* 75 */ "state ::= STATE ids", - /* 76 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state", - /* 77 */ "keep ::= KEEP tagitemlist", - /* 78 */ "cache ::= CACHE INTEGER", - /* 79 */ "replica ::= REPLICA INTEGER", - /* 80 */ "quorum ::= QUORUM INTEGER", - /* 81 */ "days ::= DAYS INTEGER", - /* 82 */ "minrows ::= MINROWS INTEGER", - /* 83 */ "maxrows ::= MAXROWS INTEGER", - /* 84 */ "blocks ::= BLOCKS INTEGER", - /* 85 */ "ctime ::= CTIME INTEGER", - /* 86 */ "wal ::= WAL INTEGER", - /* 87 */ "fsync ::= FSYNC INTEGER", - /* 88 */ "comp ::= COMP INTEGER", - /* 89 */ "prec ::= PRECISION STRING", - /* 90 */ "update ::= UPDATE INTEGER", - /* 91 */ "cachelast ::= CACHELAST INTEGER", - /* 92 */ "partitions ::= PARTITIONS INTEGER", - /* 93 */ "db_optr ::=", - /* 94 */ "db_optr ::= db_optr cache", - /* 95 */ "db_optr ::= db_optr replica", - /* 96 */ "db_optr ::= db_optr quorum", - /* 97 */ "db_optr ::= db_optr days", - /* 98 */ "db_optr ::= db_optr minrows", - /* 99 */ "db_optr ::= db_optr maxrows", - /* 100 */ "db_optr ::= db_optr blocks", - /* 101 */ "db_optr ::= db_optr ctime", - /* 102 */ "db_optr ::= db_optr wal", - /* 103 */ "db_optr ::= db_optr fsync", - /* 104 */ "db_optr ::= db_optr comp", - /* 105 */ "db_optr ::= db_optr prec", - /* 106 */ "db_optr ::= db_optr keep", - /* 107 */ "db_optr ::= db_optr update", - /* 108 */ "db_optr ::= db_optr cachelast", - /* 109 */ "topic_optr ::= db_optr", - /* 110 */ "topic_optr ::= topic_optr partitions", - /* 111 */ "alter_db_optr ::=", - /* 112 */ "alter_db_optr ::= alter_db_optr replica", - /* 113 */ "alter_db_optr ::= alter_db_optr quorum", - /* 114 */ "alter_db_optr ::= alter_db_optr keep", - /* 115 */ "alter_db_optr ::= alter_db_optr blocks", - /* 116 */ "alter_db_optr ::= alter_db_optr comp", - /* 117 */ "alter_db_optr ::= alter_db_optr wal", - /* 118 */ "alter_db_optr ::= alter_db_optr fsync", - /* 119 */ "alter_db_optr ::= alter_db_optr update", - /* 120 */ "alter_db_optr ::= alter_db_optr cachelast", - /* 121 */ "alter_topic_optr ::= alter_db_optr", - /* 122 */ "alter_topic_optr ::= alter_topic_optr partitions", - /* 123 */ "typename ::= ids", - /* 124 */ "typename ::= ids LP signed RP", - /* 125 */ "typename ::= ids UNSIGNED", - /* 126 */ "signed ::= INTEGER", - /* 127 */ "signed ::= PLUS INTEGER", - /* 128 */ "signed ::= MINUS INTEGER", - /* 129 */ "cmd ::= CREATE TABLE create_table_args", - /* 130 */ "cmd ::= CREATE TABLE create_stable_args", - /* 131 */ "cmd ::= CREATE STABLE create_stable_args", - /* 132 */ "cmd ::= CREATE TABLE create_table_list", - /* 133 */ "create_table_list ::= create_from_stable", - /* 134 */ "create_table_list ::= create_table_list create_from_stable", - /* 135 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", - /* 136 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", - /* 137 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP", - /* 138 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP", - /* 139 */ "tagNamelist ::= tagNamelist COMMA ids", - /* 140 */ "tagNamelist ::= ids", - /* 141 */ "create_table_args ::= ifnotexists ids cpxName AS select", - /* 142 */ "columnlist ::= columnlist COMMA column", - /* 143 */ "columnlist ::= column", - /* 144 */ "column ::= ids typename", - /* 145 */ "tagitemlist ::= tagitemlist COMMA tagitem", - /* 146 */ "tagitemlist ::= tagitem", - /* 147 */ "tagitem ::= INTEGER", - /* 148 */ "tagitem ::= FLOAT", - /* 149 */ "tagitem ::= STRING", - /* 150 */ "tagitem ::= BOOL", - /* 151 */ "tagitem ::= NULL", - /* 152 */ "tagitem ::= MINUS INTEGER", - /* 153 */ "tagitem ::= MINUS FLOAT", - /* 154 */ "tagitem ::= PLUS INTEGER", - /* 155 */ "tagitem ::= PLUS FLOAT", - /* 156 */ "select ::= SELECT selcollist from where_opt interval_opt session_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt", - /* 157 */ "select ::= LP select RP", - /* 158 */ "union ::= select", - /* 159 */ "union ::= union UNION ALL select", - /* 160 */ "cmd ::= union", - /* 161 */ "select ::= SELECT selcollist", - /* 162 */ "sclp ::= selcollist COMMA", - /* 163 */ "sclp ::=", - /* 164 */ "selcollist ::= sclp distinct expr as", - /* 165 */ "selcollist ::= sclp STAR", - /* 166 */ "as ::= AS ids", - /* 167 */ "as ::= ids", - /* 168 */ "as ::=", - /* 169 */ "distinct ::= DISTINCT", - /* 170 */ "distinct ::=", - /* 171 */ "from ::= FROM tablelist", - /* 172 */ "from ::= FROM LP union RP", - /* 173 */ "tablelist ::= ids cpxName", - /* 174 */ "tablelist ::= ids cpxName ids", - /* 175 */ "tablelist ::= tablelist COMMA ids cpxName", - /* 176 */ "tablelist ::= tablelist COMMA ids cpxName ids", - /* 177 */ "tmvar ::= VARIABLE", - /* 178 */ "interval_opt ::= INTERVAL LP tmvar RP", - /* 179 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", - /* 180 */ "interval_opt ::=", - /* 181 */ "session_option ::=", - /* 182 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", - /* 183 */ "fill_opt ::=", - /* 184 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", - /* 185 */ "fill_opt ::= FILL LP ID RP", - /* 186 */ "sliding_opt ::= SLIDING LP tmvar RP", - /* 187 */ "sliding_opt ::=", - /* 188 */ "orderby_opt ::=", - /* 189 */ "orderby_opt ::= ORDER BY sortlist", - /* 190 */ "sortlist ::= sortlist COMMA item sortorder", - /* 191 */ "sortlist ::= item sortorder", - /* 192 */ "item ::= ids cpxName", - /* 193 */ "sortorder ::= ASC", - /* 194 */ "sortorder ::= DESC", - /* 195 */ "sortorder ::=", - /* 196 */ "groupby_opt ::=", - /* 197 */ "groupby_opt ::= GROUP BY grouplist", - /* 198 */ "grouplist ::= grouplist COMMA item", - /* 199 */ "grouplist ::= item", - /* 200 */ "having_opt ::=", - /* 201 */ "having_opt ::= HAVING expr", - /* 202 */ "limit_opt ::=", - /* 203 */ "limit_opt ::= LIMIT signed", - /* 204 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 205 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 206 */ "slimit_opt ::=", - /* 207 */ "slimit_opt ::= SLIMIT signed", - /* 208 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", - /* 209 */ "slimit_opt ::= SLIMIT signed COMMA signed", - /* 210 */ "where_opt ::=", - /* 211 */ "where_opt ::= WHERE expr", - /* 212 */ "expr ::= LP expr RP", - /* 213 */ "expr ::= ID", - /* 214 */ "expr ::= ID DOT ID", - /* 215 */ "expr ::= ID DOT STAR", - /* 216 */ "expr ::= INTEGER", - /* 217 */ "expr ::= MINUS INTEGER", - /* 218 */ "expr ::= PLUS INTEGER", - /* 219 */ "expr ::= FLOAT", - /* 220 */ "expr ::= MINUS FLOAT", - /* 221 */ "expr ::= PLUS FLOAT", - /* 222 */ "expr ::= STRING", - /* 223 */ "expr ::= NOW", - /* 224 */ "expr ::= VARIABLE", - /* 225 */ "expr ::= PLUS VARIABLE", - /* 226 */ "expr ::= MINUS VARIABLE", - /* 227 */ "expr ::= BOOL", - /* 228 */ "expr ::= NULL", - /* 229 */ "expr ::= ID LP exprlist RP", - /* 230 */ "expr ::= ID LP STAR RP", - /* 231 */ "expr ::= expr IS NULL", - /* 232 */ "expr ::= expr IS NOT NULL", - /* 233 */ "expr ::= expr LT expr", - /* 234 */ "expr ::= expr GT expr", - /* 235 */ "expr ::= expr LE expr", - /* 236 */ "expr ::= expr GE expr", - /* 237 */ "expr ::= expr NE expr", - /* 238 */ "expr ::= expr EQ expr", - /* 239 */ "expr ::= expr BETWEEN expr AND expr", - /* 240 */ "expr ::= expr AND expr", - /* 241 */ "expr ::= expr OR expr", - /* 242 */ "expr ::= expr PLUS expr", - /* 243 */ "expr ::= expr MINUS expr", - /* 244 */ "expr ::= expr STAR expr", - /* 245 */ "expr ::= expr SLASH expr", - /* 246 */ "expr ::= expr REM expr", - /* 247 */ "expr ::= expr LIKE expr", - /* 248 */ "expr ::= expr IN LP exprlist RP", - /* 249 */ "exprlist ::= exprlist COMMA expritem", - /* 250 */ "exprlist ::= expritem", - /* 251 */ "expritem ::= expr", - /* 252 */ "expritem ::=", - /* 253 */ "cmd ::= RESET QUERY CACHE", - /* 254 */ "cmd ::= SYNCDB ids REPLICA", - /* 255 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 256 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 257 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 258 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 259 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 260 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 261 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", - /* 262 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", - /* 263 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", - /* 264 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", - /* 265 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", - /* 266 */ "cmd ::= KILL CONNECTION INTEGER", - /* 267 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 268 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 21 */ "cmd ::= SHOW CREATE STABLE ids cpxName", + /* 22 */ "cmd ::= SHOW CREATE DATABASE ids", + /* 23 */ "cmd ::= SHOW dbPrefix TABLES", + /* 24 */ "cmd ::= SHOW dbPrefix TABLES LIKE ids", + /* 25 */ "cmd ::= SHOW dbPrefix STABLES", + /* 26 */ "cmd ::= SHOW dbPrefix STABLES LIKE ids", + /* 27 */ "cmd ::= SHOW dbPrefix VGROUPS", + /* 28 */ "cmd ::= SHOW dbPrefix VGROUPS ids", + /* 29 */ "cmd ::= DROP TABLE ifexists ids cpxName", + /* 30 */ "cmd ::= DROP STABLE ifexists ids cpxName", + /* 31 */ "cmd ::= DROP DATABASE ifexists ids", + /* 32 */ "cmd ::= DROP TOPIC ifexists ids", + /* 33 */ "cmd ::= DROP DNODE ids", + /* 34 */ "cmd ::= DROP USER ids", + /* 35 */ "cmd ::= DROP ACCOUNT ids", + /* 36 */ "cmd ::= USE ids", + /* 37 */ "cmd ::= DESCRIBE ids cpxName", + /* 38 */ "cmd ::= ALTER USER ids PASS ids", + /* 39 */ "cmd ::= ALTER USER ids PRIVILEGE ids", + /* 40 */ "cmd ::= ALTER DNODE ids ids", + /* 41 */ "cmd ::= ALTER DNODE ids ids ids", + /* 42 */ "cmd ::= ALTER LOCAL ids", + /* 43 */ "cmd ::= ALTER LOCAL ids ids", + /* 44 */ "cmd ::= ALTER DATABASE ids alter_db_optr", + /* 45 */ "cmd ::= ALTER TOPIC ids alter_topic_optr", + /* 46 */ "cmd ::= ALTER ACCOUNT ids acct_optr", + /* 47 */ "cmd ::= ALTER ACCOUNT ids PASS ids acct_optr", + /* 48 */ "ids ::= ID", + /* 49 */ "ids ::= STRING", + /* 50 */ "ifexists ::= IF EXISTS", + /* 51 */ "ifexists ::=", + /* 52 */ "ifnotexists ::= IF NOT EXISTS", + /* 53 */ "ifnotexists ::=", + /* 54 */ "cmd ::= CREATE DNODE ids", + /* 55 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr", + /* 56 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr", + /* 57 */ "cmd ::= CREATE TOPIC ifnotexists ids topic_optr", + /* 58 */ "cmd ::= CREATE USER ids PASS ids", + /* 59 */ "pps ::=", + /* 60 */ "pps ::= PPS INTEGER", + /* 61 */ "tseries ::=", + /* 62 */ "tseries ::= TSERIES INTEGER", + /* 63 */ "dbs ::=", + /* 64 */ "dbs ::= DBS INTEGER", + /* 65 */ "streams ::=", + /* 66 */ "streams ::= STREAMS INTEGER", + /* 67 */ "storage ::=", + /* 68 */ "storage ::= STORAGE INTEGER", + /* 69 */ "qtime ::=", + /* 70 */ "qtime ::= QTIME INTEGER", + /* 71 */ "users ::=", + /* 72 */ "users ::= USERS INTEGER", + /* 73 */ "conns ::=", + /* 74 */ "conns ::= CONNS INTEGER", + /* 75 */ "state ::=", + /* 76 */ "state ::= STATE ids", + /* 77 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state", + /* 78 */ "keep ::= KEEP tagitemlist", + /* 79 */ "cache ::= CACHE INTEGER", + /* 80 */ "replica ::= REPLICA INTEGER", + /* 81 */ "quorum ::= QUORUM INTEGER", + /* 82 */ "days ::= DAYS INTEGER", + /* 83 */ "minrows ::= MINROWS INTEGER", + /* 84 */ "maxrows ::= MAXROWS INTEGER", + /* 85 */ "blocks ::= BLOCKS INTEGER", + /* 86 */ "ctime ::= CTIME INTEGER", + /* 87 */ "wal ::= WAL INTEGER", + /* 88 */ "fsync ::= FSYNC INTEGER", + /* 89 */ "comp ::= COMP INTEGER", + /* 90 */ "prec ::= PRECISION STRING", + /* 91 */ "update ::= UPDATE INTEGER", + /* 92 */ "cachelast ::= CACHELAST INTEGER", + /* 93 */ "partitions ::= PARTITIONS INTEGER", + /* 94 */ "db_optr ::=", + /* 95 */ "db_optr ::= db_optr cache", + /* 96 */ "db_optr ::= db_optr replica", + /* 97 */ "db_optr ::= db_optr quorum", + /* 98 */ "db_optr ::= db_optr days", + /* 99 */ "db_optr ::= db_optr minrows", + /* 100 */ "db_optr ::= db_optr maxrows", + /* 101 */ "db_optr ::= db_optr blocks", + /* 102 */ "db_optr ::= db_optr ctime", + /* 103 */ "db_optr ::= db_optr wal", + /* 104 */ "db_optr ::= db_optr fsync", + /* 105 */ "db_optr ::= db_optr comp", + /* 106 */ "db_optr ::= db_optr prec", + /* 107 */ "db_optr ::= db_optr keep", + /* 108 */ "db_optr ::= db_optr update", + /* 109 */ "db_optr ::= db_optr cachelast", + /* 110 */ "topic_optr ::= db_optr", + /* 111 */ "topic_optr ::= topic_optr partitions", + /* 112 */ "alter_db_optr ::=", + /* 113 */ "alter_db_optr ::= alter_db_optr replica", + /* 114 */ "alter_db_optr ::= alter_db_optr quorum", + /* 115 */ "alter_db_optr ::= alter_db_optr keep", + /* 116 */ "alter_db_optr ::= alter_db_optr blocks", + /* 117 */ "alter_db_optr ::= alter_db_optr comp", + /* 118 */ "alter_db_optr ::= alter_db_optr wal", + /* 119 */ "alter_db_optr ::= alter_db_optr fsync", + /* 120 */ "alter_db_optr ::= alter_db_optr update", + /* 121 */ "alter_db_optr ::= alter_db_optr cachelast", + /* 122 */ "alter_topic_optr ::= alter_db_optr", + /* 123 */ "alter_topic_optr ::= alter_topic_optr partitions", + /* 124 */ "typename ::= ids", + /* 125 */ "typename ::= ids LP signed RP", + /* 126 */ "typename ::= ids UNSIGNED", + /* 127 */ "signed ::= INTEGER", + /* 128 */ "signed ::= PLUS INTEGER", + /* 129 */ "signed ::= MINUS INTEGER", + /* 130 */ "cmd ::= CREATE TABLE create_table_args", + /* 131 */ "cmd ::= CREATE TABLE create_stable_args", + /* 132 */ "cmd ::= CREATE STABLE create_stable_args", + /* 133 */ "cmd ::= CREATE TABLE create_table_list", + /* 134 */ "create_table_list ::= create_from_stable", + /* 135 */ "create_table_list ::= create_table_list create_from_stable", + /* 136 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", + /* 137 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", + /* 138 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP", + /* 139 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP", + /* 140 */ "tagNamelist ::= tagNamelist COMMA ids", + /* 141 */ "tagNamelist ::= ids", + /* 142 */ "create_table_args ::= ifnotexists ids cpxName AS select", + /* 143 */ "columnlist ::= columnlist COMMA column", + /* 144 */ "columnlist ::= column", + /* 145 */ "column ::= ids typename", + /* 146 */ "tagitemlist ::= tagitemlist COMMA tagitem", + /* 147 */ "tagitemlist ::= tagitem", + /* 148 */ "tagitem ::= INTEGER", + /* 149 */ "tagitem ::= FLOAT", + /* 150 */ "tagitem ::= STRING", + /* 151 */ "tagitem ::= BOOL", + /* 152 */ "tagitem ::= NULL", + /* 153 */ "tagitem ::= MINUS INTEGER", + /* 154 */ "tagitem ::= MINUS FLOAT", + /* 155 */ "tagitem ::= PLUS INTEGER", + /* 156 */ "tagitem ::= PLUS FLOAT", + /* 157 */ "select ::= SELECT selcollist from where_opt interval_opt session_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt", + /* 158 */ "select ::= LP select RP", + /* 159 */ "union ::= select", + /* 160 */ "union ::= union UNION ALL select", + /* 161 */ "cmd ::= union", + /* 162 */ "select ::= SELECT selcollist", + /* 163 */ "sclp ::= selcollist COMMA", + /* 164 */ "sclp ::=", + /* 165 */ "selcollist ::= sclp distinct expr as", + /* 166 */ "selcollist ::= sclp STAR", + /* 167 */ "as ::= AS ids", + /* 168 */ "as ::= ids", + /* 169 */ "as ::=", + /* 170 */ "distinct ::= DISTINCT", + /* 171 */ "distinct ::=", + /* 172 */ "from ::= FROM tablelist", + /* 173 */ "from ::= FROM LP union RP", + /* 174 */ "tablelist ::= ids cpxName", + /* 175 */ "tablelist ::= ids cpxName ids", + /* 176 */ "tablelist ::= tablelist COMMA ids cpxName", + /* 177 */ "tablelist ::= tablelist COMMA ids cpxName ids", + /* 178 */ "tmvar ::= VARIABLE", + /* 179 */ "interval_opt ::= INTERVAL LP tmvar RP", + /* 180 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", + /* 181 */ "interval_opt ::=", + /* 182 */ "session_option ::=", + /* 183 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", + /* 184 */ "fill_opt ::=", + /* 185 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", + /* 186 */ "fill_opt ::= FILL LP ID RP", + /* 187 */ "sliding_opt ::= SLIDING LP tmvar RP", + /* 188 */ "sliding_opt ::=", + /* 189 */ "orderby_opt ::=", + /* 190 */ "orderby_opt ::= ORDER BY sortlist", + /* 191 */ "sortlist ::= sortlist COMMA item sortorder", + /* 192 */ "sortlist ::= item sortorder", + /* 193 */ "item ::= ids cpxName", + /* 194 */ "sortorder ::= ASC", + /* 195 */ "sortorder ::= DESC", + /* 196 */ "sortorder ::=", + /* 197 */ "groupby_opt ::=", + /* 198 */ "groupby_opt ::= GROUP BY grouplist", + /* 199 */ "grouplist ::= grouplist COMMA item", + /* 200 */ "grouplist ::= item", + /* 201 */ "having_opt ::=", + /* 202 */ "having_opt ::= HAVING expr", + /* 203 */ "limit_opt ::=", + /* 204 */ "limit_opt ::= LIMIT signed", + /* 205 */ "limit_opt ::= LIMIT signed OFFSET signed", + /* 206 */ "limit_opt ::= LIMIT signed COMMA signed", + /* 207 */ "slimit_opt ::=", + /* 208 */ "slimit_opt ::= SLIMIT signed", + /* 209 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", + /* 210 */ "slimit_opt ::= SLIMIT signed COMMA signed", + /* 211 */ "where_opt ::=", + /* 212 */ "where_opt ::= WHERE expr", + /* 213 */ "expr ::= LP expr RP", + /* 214 */ "expr ::= ID", + /* 215 */ "expr ::= ID DOT ID", + /* 216 */ "expr ::= ID DOT STAR", + /* 217 */ "expr ::= INTEGER", + /* 218 */ "expr ::= MINUS INTEGER", + /* 219 */ "expr ::= PLUS INTEGER", + /* 220 */ "expr ::= FLOAT", + /* 221 */ "expr ::= MINUS FLOAT", + /* 222 */ "expr ::= PLUS FLOAT", + /* 223 */ "expr ::= STRING", + /* 224 */ "expr ::= NOW", + /* 225 */ "expr ::= VARIABLE", + /* 226 */ "expr ::= PLUS VARIABLE", + /* 227 */ "expr ::= MINUS VARIABLE", + /* 228 */ "expr ::= BOOL", + /* 229 */ "expr ::= NULL", + /* 230 */ "expr ::= ID LP exprlist RP", + /* 231 */ "expr ::= ID LP STAR RP", + /* 232 */ "expr ::= expr IS NULL", + /* 233 */ "expr ::= expr IS NOT NULL", + /* 234 */ "expr ::= expr LT expr", + /* 235 */ "expr ::= expr GT expr", + /* 236 */ "expr ::= expr LE expr", + /* 237 */ "expr ::= expr GE expr", + /* 238 */ "expr ::= expr NE expr", + /* 239 */ "expr ::= expr EQ expr", + /* 240 */ "expr ::= expr BETWEEN expr AND expr", + /* 241 */ "expr ::= expr AND expr", + /* 242 */ "expr ::= expr OR expr", + /* 243 */ "expr ::= expr PLUS expr", + /* 244 */ "expr ::= expr MINUS expr", + /* 245 */ "expr ::= expr STAR expr", + /* 246 */ "expr ::= expr SLASH expr", + /* 247 */ "expr ::= expr REM expr", + /* 248 */ "expr ::= expr LIKE expr", + /* 249 */ "expr ::= expr IN LP exprlist RP", + /* 250 */ "exprlist ::= exprlist COMMA expritem", + /* 251 */ "exprlist ::= expritem", + /* 252 */ "expritem ::= expr", + /* 253 */ "expritem ::=", + /* 254 */ "cmd ::= RESET QUERY CACHE", + /* 255 */ "cmd ::= SYNCDB ids REPLICA", + /* 256 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 257 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 258 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 259 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 260 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 261 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 262 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", + /* 263 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", + /* 264 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", + /* 265 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", + /* 266 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", + /* 267 */ "cmd ::= KILL CONNECTION INTEGER", + /* 268 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 269 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1774,254 +1776,255 @@ static const struct { { 192, 0 }, /* (18) cpxName ::= */ { 192, -2 }, /* (19) cpxName ::= DOT ids */ { 189, -5 }, /* (20) cmd ::= SHOW CREATE TABLE ids cpxName */ - { 189, -4 }, /* (21) cmd ::= SHOW CREATE DATABASE ids */ - { 189, -3 }, /* (22) cmd ::= SHOW dbPrefix TABLES */ - { 189, -5 }, /* (23) cmd ::= SHOW dbPrefix TABLES LIKE ids */ - { 189, -3 }, /* (24) cmd ::= SHOW dbPrefix STABLES */ - { 189, -5 }, /* (25) cmd ::= SHOW dbPrefix STABLES LIKE ids */ - { 189, -3 }, /* (26) cmd ::= SHOW dbPrefix VGROUPS */ - { 189, -4 }, /* (27) cmd ::= SHOW dbPrefix VGROUPS ids */ - { 189, -5 }, /* (28) cmd ::= DROP TABLE ifexists ids cpxName */ - { 189, -5 }, /* (29) cmd ::= DROP STABLE ifexists ids cpxName */ - { 189, -4 }, /* (30) cmd ::= DROP DATABASE ifexists ids */ - { 189, -4 }, /* (31) cmd ::= DROP TOPIC ifexists ids */ - { 189, -3 }, /* (32) cmd ::= DROP DNODE ids */ - { 189, -3 }, /* (33) cmd ::= DROP USER ids */ - { 189, -3 }, /* (34) cmd ::= DROP ACCOUNT ids */ - { 189, -2 }, /* (35) cmd ::= USE ids */ - { 189, -3 }, /* (36) cmd ::= DESCRIBE ids cpxName */ - { 189, -5 }, /* (37) cmd ::= ALTER USER ids PASS ids */ - { 189, -5 }, /* (38) cmd ::= ALTER USER ids PRIVILEGE ids */ - { 189, -4 }, /* (39) cmd ::= ALTER DNODE ids ids */ - { 189, -5 }, /* (40) cmd ::= ALTER DNODE ids ids ids */ - { 189, -3 }, /* (41) cmd ::= ALTER LOCAL ids */ - { 189, -4 }, /* (42) cmd ::= ALTER LOCAL ids ids */ - { 189, -4 }, /* (43) cmd ::= ALTER DATABASE ids alter_db_optr */ - { 189, -4 }, /* (44) cmd ::= ALTER TOPIC ids alter_topic_optr */ - { 189, -4 }, /* (45) cmd ::= ALTER ACCOUNT ids acct_optr */ - { 189, -6 }, /* (46) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - { 191, -1 }, /* (47) ids ::= ID */ - { 191, -1 }, /* (48) ids ::= STRING */ - { 193, -2 }, /* (49) ifexists ::= IF EXISTS */ - { 193, 0 }, /* (50) ifexists ::= */ - { 197, -3 }, /* (51) ifnotexists ::= IF NOT EXISTS */ - { 197, 0 }, /* (52) ifnotexists ::= */ - { 189, -3 }, /* (53) cmd ::= CREATE DNODE ids */ - { 189, -6 }, /* (54) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - { 189, -5 }, /* (55) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - { 189, -5 }, /* (56) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ - { 189, -5 }, /* (57) cmd ::= CREATE USER ids PASS ids */ - { 200, 0 }, /* (58) pps ::= */ - { 200, -2 }, /* (59) pps ::= PPS INTEGER */ - { 201, 0 }, /* (60) tseries ::= */ - { 201, -2 }, /* (61) tseries ::= TSERIES INTEGER */ - { 202, 0 }, /* (62) dbs ::= */ - { 202, -2 }, /* (63) dbs ::= DBS INTEGER */ - { 203, 0 }, /* (64) streams ::= */ - { 203, -2 }, /* (65) streams ::= STREAMS INTEGER */ - { 204, 0 }, /* (66) storage ::= */ - { 204, -2 }, /* (67) storage ::= STORAGE INTEGER */ - { 205, 0 }, /* (68) qtime ::= */ - { 205, -2 }, /* (69) qtime ::= QTIME INTEGER */ - { 206, 0 }, /* (70) users ::= */ - { 206, -2 }, /* (71) users ::= USERS INTEGER */ - { 207, 0 }, /* (72) conns ::= */ - { 207, -2 }, /* (73) conns ::= CONNS INTEGER */ - { 208, 0 }, /* (74) state ::= */ - { 208, -2 }, /* (75) state ::= STATE ids */ - { 196, -9 }, /* (76) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - { 209, -2 }, /* (77) keep ::= KEEP tagitemlist */ - { 211, -2 }, /* (78) cache ::= CACHE INTEGER */ - { 212, -2 }, /* (79) replica ::= REPLICA INTEGER */ - { 213, -2 }, /* (80) quorum ::= QUORUM INTEGER */ - { 214, -2 }, /* (81) days ::= DAYS INTEGER */ - { 215, -2 }, /* (82) minrows ::= MINROWS INTEGER */ - { 216, -2 }, /* (83) maxrows ::= MAXROWS INTEGER */ - { 217, -2 }, /* (84) blocks ::= BLOCKS INTEGER */ - { 218, -2 }, /* (85) ctime ::= CTIME INTEGER */ - { 219, -2 }, /* (86) wal ::= WAL INTEGER */ - { 220, -2 }, /* (87) fsync ::= FSYNC INTEGER */ - { 221, -2 }, /* (88) comp ::= COMP INTEGER */ - { 222, -2 }, /* (89) prec ::= PRECISION STRING */ - { 223, -2 }, /* (90) update ::= UPDATE INTEGER */ - { 224, -2 }, /* (91) cachelast ::= CACHELAST INTEGER */ - { 225, -2 }, /* (92) partitions ::= PARTITIONS INTEGER */ - { 198, 0 }, /* (93) db_optr ::= */ - { 198, -2 }, /* (94) db_optr ::= db_optr cache */ - { 198, -2 }, /* (95) db_optr ::= db_optr replica */ - { 198, -2 }, /* (96) db_optr ::= db_optr quorum */ - { 198, -2 }, /* (97) db_optr ::= db_optr days */ - { 198, -2 }, /* (98) db_optr ::= db_optr minrows */ - { 198, -2 }, /* (99) db_optr ::= db_optr maxrows */ - { 198, -2 }, /* (100) db_optr ::= db_optr blocks */ - { 198, -2 }, /* (101) db_optr ::= db_optr ctime */ - { 198, -2 }, /* (102) db_optr ::= db_optr wal */ - { 198, -2 }, /* (103) db_optr ::= db_optr fsync */ - { 198, -2 }, /* (104) db_optr ::= db_optr comp */ - { 198, -2 }, /* (105) db_optr ::= db_optr prec */ - { 198, -2 }, /* (106) db_optr ::= db_optr keep */ - { 198, -2 }, /* (107) db_optr ::= db_optr update */ - { 198, -2 }, /* (108) db_optr ::= db_optr cachelast */ - { 199, -1 }, /* (109) topic_optr ::= db_optr */ - { 199, -2 }, /* (110) topic_optr ::= topic_optr partitions */ - { 194, 0 }, /* (111) alter_db_optr ::= */ - { 194, -2 }, /* (112) alter_db_optr ::= alter_db_optr replica */ - { 194, -2 }, /* (113) alter_db_optr ::= alter_db_optr quorum */ - { 194, -2 }, /* (114) alter_db_optr ::= alter_db_optr keep */ - { 194, -2 }, /* (115) alter_db_optr ::= alter_db_optr blocks */ - { 194, -2 }, /* (116) alter_db_optr ::= alter_db_optr comp */ - { 194, -2 }, /* (117) alter_db_optr ::= alter_db_optr wal */ - { 194, -2 }, /* (118) alter_db_optr ::= alter_db_optr fsync */ - { 194, -2 }, /* (119) alter_db_optr ::= alter_db_optr update */ - { 194, -2 }, /* (120) alter_db_optr ::= alter_db_optr cachelast */ - { 195, -1 }, /* (121) alter_topic_optr ::= alter_db_optr */ - { 195, -2 }, /* (122) alter_topic_optr ::= alter_topic_optr partitions */ - { 226, -1 }, /* (123) typename ::= ids */ - { 226, -4 }, /* (124) typename ::= ids LP signed RP */ - { 226, -2 }, /* (125) typename ::= ids UNSIGNED */ - { 227, -1 }, /* (126) signed ::= INTEGER */ - { 227, -2 }, /* (127) signed ::= PLUS INTEGER */ - { 227, -2 }, /* (128) signed ::= MINUS INTEGER */ - { 189, -3 }, /* (129) cmd ::= CREATE TABLE create_table_args */ - { 189, -3 }, /* (130) cmd ::= CREATE TABLE create_stable_args */ - { 189, -3 }, /* (131) cmd ::= CREATE STABLE create_stable_args */ - { 189, -3 }, /* (132) cmd ::= CREATE TABLE create_table_list */ - { 230, -1 }, /* (133) create_table_list ::= create_from_stable */ - { 230, -2 }, /* (134) create_table_list ::= create_table_list create_from_stable */ - { 228, -6 }, /* (135) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - { 229, -10 }, /* (136) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - { 231, -10 }, /* (137) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - { 231, -13 }, /* (138) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ - { 233, -3 }, /* (139) tagNamelist ::= tagNamelist COMMA ids */ - { 233, -1 }, /* (140) tagNamelist ::= ids */ - { 228, -5 }, /* (141) create_table_args ::= ifnotexists ids cpxName AS select */ - { 232, -3 }, /* (142) columnlist ::= columnlist COMMA column */ - { 232, -1 }, /* (143) columnlist ::= column */ - { 235, -2 }, /* (144) column ::= ids typename */ - { 210, -3 }, /* (145) tagitemlist ::= tagitemlist COMMA tagitem */ - { 210, -1 }, /* (146) tagitemlist ::= tagitem */ - { 236, -1 }, /* (147) tagitem ::= INTEGER */ - { 236, -1 }, /* (148) tagitem ::= FLOAT */ - { 236, -1 }, /* (149) tagitem ::= STRING */ - { 236, -1 }, /* (150) tagitem ::= BOOL */ - { 236, -1 }, /* (151) tagitem ::= NULL */ - { 236, -2 }, /* (152) tagitem ::= MINUS INTEGER */ - { 236, -2 }, /* (153) tagitem ::= MINUS FLOAT */ - { 236, -2 }, /* (154) tagitem ::= PLUS INTEGER */ - { 236, -2 }, /* (155) tagitem ::= PLUS FLOAT */ - { 234, -13 }, /* (156) select ::= SELECT selcollist from where_opt interval_opt session_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ - { 234, -3 }, /* (157) select ::= LP select RP */ - { 249, -1 }, /* (158) union ::= select */ - { 249, -4 }, /* (159) union ::= union UNION ALL select */ - { 189, -1 }, /* (160) cmd ::= union */ - { 234, -2 }, /* (161) select ::= SELECT selcollist */ - { 250, -2 }, /* (162) sclp ::= selcollist COMMA */ - { 250, 0 }, /* (163) sclp ::= */ - { 237, -4 }, /* (164) selcollist ::= sclp distinct expr as */ - { 237, -2 }, /* (165) selcollist ::= sclp STAR */ - { 253, -2 }, /* (166) as ::= AS ids */ - { 253, -1 }, /* (167) as ::= ids */ - { 253, 0 }, /* (168) as ::= */ - { 251, -1 }, /* (169) distinct ::= DISTINCT */ - { 251, 0 }, /* (170) distinct ::= */ - { 238, -2 }, /* (171) from ::= FROM tablelist */ - { 238, -4 }, /* (172) from ::= FROM LP union RP */ - { 254, -2 }, /* (173) tablelist ::= ids cpxName */ - { 254, -3 }, /* (174) tablelist ::= ids cpxName ids */ - { 254, -4 }, /* (175) tablelist ::= tablelist COMMA ids cpxName */ - { 254, -5 }, /* (176) tablelist ::= tablelist COMMA ids cpxName ids */ - { 255, -1 }, /* (177) tmvar ::= VARIABLE */ - { 240, -4 }, /* (178) interval_opt ::= INTERVAL LP tmvar RP */ - { 240, -6 }, /* (179) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ - { 240, 0 }, /* (180) interval_opt ::= */ - { 241, 0 }, /* (181) session_option ::= */ - { 241, -7 }, /* (182) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - { 242, 0 }, /* (183) fill_opt ::= */ - { 242, -6 }, /* (184) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - { 242, -4 }, /* (185) fill_opt ::= FILL LP ID RP */ - { 243, -4 }, /* (186) sliding_opt ::= SLIDING LP tmvar RP */ - { 243, 0 }, /* (187) sliding_opt ::= */ - { 245, 0 }, /* (188) orderby_opt ::= */ - { 245, -3 }, /* (189) orderby_opt ::= ORDER BY sortlist */ - { 256, -4 }, /* (190) sortlist ::= sortlist COMMA item sortorder */ - { 256, -2 }, /* (191) sortlist ::= item sortorder */ - { 258, -2 }, /* (192) item ::= ids cpxName */ - { 259, -1 }, /* (193) sortorder ::= ASC */ - { 259, -1 }, /* (194) sortorder ::= DESC */ - { 259, 0 }, /* (195) sortorder ::= */ - { 244, 0 }, /* (196) groupby_opt ::= */ - { 244, -3 }, /* (197) groupby_opt ::= GROUP BY grouplist */ - { 260, -3 }, /* (198) grouplist ::= grouplist COMMA item */ - { 260, -1 }, /* (199) grouplist ::= item */ - { 246, 0 }, /* (200) having_opt ::= */ - { 246, -2 }, /* (201) having_opt ::= HAVING expr */ - { 248, 0 }, /* (202) limit_opt ::= */ - { 248, -2 }, /* (203) limit_opt ::= LIMIT signed */ - { 248, -4 }, /* (204) limit_opt ::= LIMIT signed OFFSET signed */ - { 248, -4 }, /* (205) limit_opt ::= LIMIT signed COMMA signed */ - { 247, 0 }, /* (206) slimit_opt ::= */ - { 247, -2 }, /* (207) slimit_opt ::= SLIMIT signed */ - { 247, -4 }, /* (208) slimit_opt ::= SLIMIT signed SOFFSET signed */ - { 247, -4 }, /* (209) slimit_opt ::= SLIMIT signed COMMA signed */ - { 239, 0 }, /* (210) where_opt ::= */ - { 239, -2 }, /* (211) where_opt ::= WHERE expr */ - { 252, -3 }, /* (212) expr ::= LP expr RP */ - { 252, -1 }, /* (213) expr ::= ID */ - { 252, -3 }, /* (214) expr ::= ID DOT ID */ - { 252, -3 }, /* (215) expr ::= ID DOT STAR */ - { 252, -1 }, /* (216) expr ::= INTEGER */ - { 252, -2 }, /* (217) expr ::= MINUS INTEGER */ - { 252, -2 }, /* (218) expr ::= PLUS INTEGER */ - { 252, -1 }, /* (219) expr ::= FLOAT */ - { 252, -2 }, /* (220) expr ::= MINUS FLOAT */ - { 252, -2 }, /* (221) expr ::= PLUS FLOAT */ - { 252, -1 }, /* (222) expr ::= STRING */ - { 252, -1 }, /* (223) expr ::= NOW */ - { 252, -1 }, /* (224) expr ::= VARIABLE */ - { 252, -2 }, /* (225) expr ::= PLUS VARIABLE */ - { 252, -2 }, /* (226) expr ::= MINUS VARIABLE */ - { 252, -1 }, /* (227) expr ::= BOOL */ - { 252, -1 }, /* (228) expr ::= NULL */ - { 252, -4 }, /* (229) expr ::= ID LP exprlist RP */ - { 252, -4 }, /* (230) expr ::= ID LP STAR RP */ - { 252, -3 }, /* (231) expr ::= expr IS NULL */ - { 252, -4 }, /* (232) expr ::= expr IS NOT NULL */ - { 252, -3 }, /* (233) expr ::= expr LT expr */ - { 252, -3 }, /* (234) expr ::= expr GT expr */ - { 252, -3 }, /* (235) expr ::= expr LE expr */ - { 252, -3 }, /* (236) expr ::= expr GE expr */ - { 252, -3 }, /* (237) expr ::= expr NE expr */ - { 252, -3 }, /* (238) expr ::= expr EQ expr */ - { 252, -5 }, /* (239) expr ::= expr BETWEEN expr AND expr */ - { 252, -3 }, /* (240) expr ::= expr AND expr */ - { 252, -3 }, /* (241) expr ::= expr OR expr */ - { 252, -3 }, /* (242) expr ::= expr PLUS expr */ - { 252, -3 }, /* (243) expr ::= expr MINUS expr */ - { 252, -3 }, /* (244) expr ::= expr STAR expr */ - { 252, -3 }, /* (245) expr ::= expr SLASH expr */ - { 252, -3 }, /* (246) expr ::= expr REM expr */ - { 252, -3 }, /* (247) expr ::= expr LIKE expr */ - { 252, -5 }, /* (248) expr ::= expr IN LP exprlist RP */ - { 261, -3 }, /* (249) exprlist ::= exprlist COMMA expritem */ - { 261, -1 }, /* (250) exprlist ::= expritem */ - { 262, -1 }, /* (251) expritem ::= expr */ - { 262, 0 }, /* (252) expritem ::= */ - { 189, -3 }, /* (253) cmd ::= RESET QUERY CACHE */ - { 189, -3 }, /* (254) cmd ::= SYNCDB ids REPLICA */ - { 189, -7 }, /* (255) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - { 189, -7 }, /* (256) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - { 189, -7 }, /* (257) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - { 189, -7 }, /* (258) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - { 189, -8 }, /* (259) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - { 189, -9 }, /* (260) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - { 189, -7 }, /* (261) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - { 189, -7 }, /* (262) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - { 189, -7 }, /* (263) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - { 189, -7 }, /* (264) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - { 189, -8 }, /* (265) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - { 189, -3 }, /* (266) cmd ::= KILL CONNECTION INTEGER */ - { 189, -5 }, /* (267) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - { 189, -5 }, /* (268) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + { 189, -5 }, /* (21) cmd ::= SHOW CREATE STABLE ids cpxName */ + { 189, -4 }, /* (22) cmd ::= SHOW CREATE DATABASE ids */ + { 189, -3 }, /* (23) cmd ::= SHOW dbPrefix TABLES */ + { 189, -5 }, /* (24) cmd ::= SHOW dbPrefix TABLES LIKE ids */ + { 189, -3 }, /* (25) cmd ::= SHOW dbPrefix STABLES */ + { 189, -5 }, /* (26) cmd ::= SHOW dbPrefix STABLES LIKE ids */ + { 189, -3 }, /* (27) cmd ::= SHOW dbPrefix VGROUPS */ + { 189, -4 }, /* (28) cmd ::= SHOW dbPrefix VGROUPS ids */ + { 189, -5 }, /* (29) cmd ::= DROP TABLE ifexists ids cpxName */ + { 189, -5 }, /* (30) cmd ::= DROP STABLE ifexists ids cpxName */ + { 189, -4 }, /* (31) cmd ::= DROP DATABASE ifexists ids */ + { 189, -4 }, /* (32) cmd ::= DROP TOPIC ifexists ids */ + { 189, -3 }, /* (33) cmd ::= DROP DNODE ids */ + { 189, -3 }, /* (34) cmd ::= DROP USER ids */ + { 189, -3 }, /* (35) cmd ::= DROP ACCOUNT ids */ + { 189, -2 }, /* (36) cmd ::= USE ids */ + { 189, -3 }, /* (37) cmd ::= DESCRIBE ids cpxName */ + { 189, -5 }, /* (38) cmd ::= ALTER USER ids PASS ids */ + { 189, -5 }, /* (39) cmd ::= ALTER USER ids PRIVILEGE ids */ + { 189, -4 }, /* (40) cmd ::= ALTER DNODE ids ids */ + { 189, -5 }, /* (41) cmd ::= ALTER DNODE ids ids ids */ + { 189, -3 }, /* (42) cmd ::= ALTER LOCAL ids */ + { 189, -4 }, /* (43) cmd ::= ALTER LOCAL ids ids */ + { 189, -4 }, /* (44) cmd ::= ALTER DATABASE ids alter_db_optr */ + { 189, -4 }, /* (45) cmd ::= ALTER TOPIC ids alter_topic_optr */ + { 189, -4 }, /* (46) cmd ::= ALTER ACCOUNT ids acct_optr */ + { 189, -6 }, /* (47) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ + { 191, -1 }, /* (48) ids ::= ID */ + { 191, -1 }, /* (49) ids ::= STRING */ + { 193, -2 }, /* (50) ifexists ::= IF EXISTS */ + { 193, 0 }, /* (51) ifexists ::= */ + { 197, -3 }, /* (52) ifnotexists ::= IF NOT EXISTS */ + { 197, 0 }, /* (53) ifnotexists ::= */ + { 189, -3 }, /* (54) cmd ::= CREATE DNODE ids */ + { 189, -6 }, /* (55) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + { 189, -5 }, /* (56) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + { 189, -5 }, /* (57) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ + { 189, -5 }, /* (58) cmd ::= CREATE USER ids PASS ids */ + { 200, 0 }, /* (59) pps ::= */ + { 200, -2 }, /* (60) pps ::= PPS INTEGER */ + { 201, 0 }, /* (61) tseries ::= */ + { 201, -2 }, /* (62) tseries ::= TSERIES INTEGER */ + { 202, 0 }, /* (63) dbs ::= */ + { 202, -2 }, /* (64) dbs ::= DBS INTEGER */ + { 203, 0 }, /* (65) streams ::= */ + { 203, -2 }, /* (66) streams ::= STREAMS INTEGER */ + { 204, 0 }, /* (67) storage ::= */ + { 204, -2 }, /* (68) storage ::= STORAGE INTEGER */ + { 205, 0 }, /* (69) qtime ::= */ + { 205, -2 }, /* (70) qtime ::= QTIME INTEGER */ + { 206, 0 }, /* (71) users ::= */ + { 206, -2 }, /* (72) users ::= USERS INTEGER */ + { 207, 0 }, /* (73) conns ::= */ + { 207, -2 }, /* (74) conns ::= CONNS INTEGER */ + { 208, 0 }, /* (75) state ::= */ + { 208, -2 }, /* (76) state ::= STATE ids */ + { 196, -9 }, /* (77) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + { 209, -2 }, /* (78) keep ::= KEEP tagitemlist */ + { 211, -2 }, /* (79) cache ::= CACHE INTEGER */ + { 212, -2 }, /* (80) replica ::= REPLICA INTEGER */ + { 213, -2 }, /* (81) quorum ::= QUORUM INTEGER */ + { 214, -2 }, /* (82) days ::= DAYS INTEGER */ + { 215, -2 }, /* (83) minrows ::= MINROWS INTEGER */ + { 216, -2 }, /* (84) maxrows ::= MAXROWS INTEGER */ + { 217, -2 }, /* (85) blocks ::= BLOCKS INTEGER */ + { 218, -2 }, /* (86) ctime ::= CTIME INTEGER */ + { 219, -2 }, /* (87) wal ::= WAL INTEGER */ + { 220, -2 }, /* (88) fsync ::= FSYNC INTEGER */ + { 221, -2 }, /* (89) comp ::= COMP INTEGER */ + { 222, -2 }, /* (90) prec ::= PRECISION STRING */ + { 223, -2 }, /* (91) update ::= UPDATE INTEGER */ + { 224, -2 }, /* (92) cachelast ::= CACHELAST INTEGER */ + { 225, -2 }, /* (93) partitions ::= PARTITIONS INTEGER */ + { 198, 0 }, /* (94) db_optr ::= */ + { 198, -2 }, /* (95) db_optr ::= db_optr cache */ + { 198, -2 }, /* (96) db_optr ::= db_optr replica */ + { 198, -2 }, /* (97) db_optr ::= db_optr quorum */ + { 198, -2 }, /* (98) db_optr ::= db_optr days */ + { 198, -2 }, /* (99) db_optr ::= db_optr minrows */ + { 198, -2 }, /* (100) db_optr ::= db_optr maxrows */ + { 198, -2 }, /* (101) db_optr ::= db_optr blocks */ + { 198, -2 }, /* (102) db_optr ::= db_optr ctime */ + { 198, -2 }, /* (103) db_optr ::= db_optr wal */ + { 198, -2 }, /* (104) db_optr ::= db_optr fsync */ + { 198, -2 }, /* (105) db_optr ::= db_optr comp */ + { 198, -2 }, /* (106) db_optr ::= db_optr prec */ + { 198, -2 }, /* (107) db_optr ::= db_optr keep */ + { 198, -2 }, /* (108) db_optr ::= db_optr update */ + { 198, -2 }, /* (109) db_optr ::= db_optr cachelast */ + { 199, -1 }, /* (110) topic_optr ::= db_optr */ + { 199, -2 }, /* (111) topic_optr ::= topic_optr partitions */ + { 194, 0 }, /* (112) alter_db_optr ::= */ + { 194, -2 }, /* (113) alter_db_optr ::= alter_db_optr replica */ + { 194, -2 }, /* (114) alter_db_optr ::= alter_db_optr quorum */ + { 194, -2 }, /* (115) alter_db_optr ::= alter_db_optr keep */ + { 194, -2 }, /* (116) alter_db_optr ::= alter_db_optr blocks */ + { 194, -2 }, /* (117) alter_db_optr ::= alter_db_optr comp */ + { 194, -2 }, /* (118) alter_db_optr ::= alter_db_optr wal */ + { 194, -2 }, /* (119) alter_db_optr ::= alter_db_optr fsync */ + { 194, -2 }, /* (120) alter_db_optr ::= alter_db_optr update */ + { 194, -2 }, /* (121) alter_db_optr ::= alter_db_optr cachelast */ + { 195, -1 }, /* (122) alter_topic_optr ::= alter_db_optr */ + { 195, -2 }, /* (123) alter_topic_optr ::= alter_topic_optr partitions */ + { 226, -1 }, /* (124) typename ::= ids */ + { 226, -4 }, /* (125) typename ::= ids LP signed RP */ + { 226, -2 }, /* (126) typename ::= ids UNSIGNED */ + { 227, -1 }, /* (127) signed ::= INTEGER */ + { 227, -2 }, /* (128) signed ::= PLUS INTEGER */ + { 227, -2 }, /* (129) signed ::= MINUS INTEGER */ + { 189, -3 }, /* (130) cmd ::= CREATE TABLE create_table_args */ + { 189, -3 }, /* (131) cmd ::= CREATE TABLE create_stable_args */ + { 189, -3 }, /* (132) cmd ::= CREATE STABLE create_stable_args */ + { 189, -3 }, /* (133) cmd ::= CREATE TABLE create_table_list */ + { 230, -1 }, /* (134) create_table_list ::= create_from_stable */ + { 230, -2 }, /* (135) create_table_list ::= create_table_list create_from_stable */ + { 228, -6 }, /* (136) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + { 229, -10 }, /* (137) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + { 231, -10 }, /* (138) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + { 231, -13 }, /* (139) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + { 233, -3 }, /* (140) tagNamelist ::= tagNamelist COMMA ids */ + { 233, -1 }, /* (141) tagNamelist ::= ids */ + { 228, -5 }, /* (142) create_table_args ::= ifnotexists ids cpxName AS select */ + { 232, -3 }, /* (143) columnlist ::= columnlist COMMA column */ + { 232, -1 }, /* (144) columnlist ::= column */ + { 235, -2 }, /* (145) column ::= ids typename */ + { 210, -3 }, /* (146) tagitemlist ::= tagitemlist COMMA tagitem */ + { 210, -1 }, /* (147) tagitemlist ::= tagitem */ + { 236, -1 }, /* (148) tagitem ::= INTEGER */ + { 236, -1 }, /* (149) tagitem ::= FLOAT */ + { 236, -1 }, /* (150) tagitem ::= STRING */ + { 236, -1 }, /* (151) tagitem ::= BOOL */ + { 236, -1 }, /* (152) tagitem ::= NULL */ + { 236, -2 }, /* (153) tagitem ::= MINUS INTEGER */ + { 236, -2 }, /* (154) tagitem ::= MINUS FLOAT */ + { 236, -2 }, /* (155) tagitem ::= PLUS INTEGER */ + { 236, -2 }, /* (156) tagitem ::= PLUS FLOAT */ + { 234, -13 }, /* (157) select ::= SELECT selcollist from where_opt interval_opt session_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ + { 234, -3 }, /* (158) select ::= LP select RP */ + { 249, -1 }, /* (159) union ::= select */ + { 249, -4 }, /* (160) union ::= union UNION ALL select */ + { 189, -1 }, /* (161) cmd ::= union */ + { 234, -2 }, /* (162) select ::= SELECT selcollist */ + { 250, -2 }, /* (163) sclp ::= selcollist COMMA */ + { 250, 0 }, /* (164) sclp ::= */ + { 237, -4 }, /* (165) selcollist ::= sclp distinct expr as */ + { 237, -2 }, /* (166) selcollist ::= sclp STAR */ + { 253, -2 }, /* (167) as ::= AS ids */ + { 253, -1 }, /* (168) as ::= ids */ + { 253, 0 }, /* (169) as ::= */ + { 251, -1 }, /* (170) distinct ::= DISTINCT */ + { 251, 0 }, /* (171) distinct ::= */ + { 238, -2 }, /* (172) from ::= FROM tablelist */ + { 238, -4 }, /* (173) from ::= FROM LP union RP */ + { 254, -2 }, /* (174) tablelist ::= ids cpxName */ + { 254, -3 }, /* (175) tablelist ::= ids cpxName ids */ + { 254, -4 }, /* (176) tablelist ::= tablelist COMMA ids cpxName */ + { 254, -5 }, /* (177) tablelist ::= tablelist COMMA ids cpxName ids */ + { 255, -1 }, /* (178) tmvar ::= VARIABLE */ + { 240, -4 }, /* (179) interval_opt ::= INTERVAL LP tmvar RP */ + { 240, -6 }, /* (180) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + { 240, 0 }, /* (181) interval_opt ::= */ + { 241, 0 }, /* (182) session_option ::= */ + { 241, -7 }, /* (183) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + { 242, 0 }, /* (184) fill_opt ::= */ + { 242, -6 }, /* (185) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + { 242, -4 }, /* (186) fill_opt ::= FILL LP ID RP */ + { 243, -4 }, /* (187) sliding_opt ::= SLIDING LP tmvar RP */ + { 243, 0 }, /* (188) sliding_opt ::= */ + { 245, 0 }, /* (189) orderby_opt ::= */ + { 245, -3 }, /* (190) orderby_opt ::= ORDER BY sortlist */ + { 256, -4 }, /* (191) sortlist ::= sortlist COMMA item sortorder */ + { 256, -2 }, /* (192) sortlist ::= item sortorder */ + { 258, -2 }, /* (193) item ::= ids cpxName */ + { 259, -1 }, /* (194) sortorder ::= ASC */ + { 259, -1 }, /* (195) sortorder ::= DESC */ + { 259, 0 }, /* (196) sortorder ::= */ + { 244, 0 }, /* (197) groupby_opt ::= */ + { 244, -3 }, /* (198) groupby_opt ::= GROUP BY grouplist */ + { 260, -3 }, /* (199) grouplist ::= grouplist COMMA item */ + { 260, -1 }, /* (200) grouplist ::= item */ + { 246, 0 }, /* (201) having_opt ::= */ + { 246, -2 }, /* (202) having_opt ::= HAVING expr */ + { 248, 0 }, /* (203) limit_opt ::= */ + { 248, -2 }, /* (204) limit_opt ::= LIMIT signed */ + { 248, -4 }, /* (205) limit_opt ::= LIMIT signed OFFSET signed */ + { 248, -4 }, /* (206) limit_opt ::= LIMIT signed COMMA signed */ + { 247, 0 }, /* (207) slimit_opt ::= */ + { 247, -2 }, /* (208) slimit_opt ::= SLIMIT signed */ + { 247, -4 }, /* (209) slimit_opt ::= SLIMIT signed SOFFSET signed */ + { 247, -4 }, /* (210) slimit_opt ::= SLIMIT signed COMMA signed */ + { 239, 0 }, /* (211) where_opt ::= */ + { 239, -2 }, /* (212) where_opt ::= WHERE expr */ + { 252, -3 }, /* (213) expr ::= LP expr RP */ + { 252, -1 }, /* (214) expr ::= ID */ + { 252, -3 }, /* (215) expr ::= ID DOT ID */ + { 252, -3 }, /* (216) expr ::= ID DOT STAR */ + { 252, -1 }, /* (217) expr ::= INTEGER */ + { 252, -2 }, /* (218) expr ::= MINUS INTEGER */ + { 252, -2 }, /* (219) expr ::= PLUS INTEGER */ + { 252, -1 }, /* (220) expr ::= FLOAT */ + { 252, -2 }, /* (221) expr ::= MINUS FLOAT */ + { 252, -2 }, /* (222) expr ::= PLUS FLOAT */ + { 252, -1 }, /* (223) expr ::= STRING */ + { 252, -1 }, /* (224) expr ::= NOW */ + { 252, -1 }, /* (225) expr ::= VARIABLE */ + { 252, -2 }, /* (226) expr ::= PLUS VARIABLE */ + { 252, -2 }, /* (227) expr ::= MINUS VARIABLE */ + { 252, -1 }, /* (228) expr ::= BOOL */ + { 252, -1 }, /* (229) expr ::= NULL */ + { 252, -4 }, /* (230) expr ::= ID LP exprlist RP */ + { 252, -4 }, /* (231) expr ::= ID LP STAR RP */ + { 252, -3 }, /* (232) expr ::= expr IS NULL */ + { 252, -4 }, /* (233) expr ::= expr IS NOT NULL */ + { 252, -3 }, /* (234) expr ::= expr LT expr */ + { 252, -3 }, /* (235) expr ::= expr GT expr */ + { 252, -3 }, /* (236) expr ::= expr LE expr */ + { 252, -3 }, /* (237) expr ::= expr GE expr */ + { 252, -3 }, /* (238) expr ::= expr NE expr */ + { 252, -3 }, /* (239) expr ::= expr EQ expr */ + { 252, -5 }, /* (240) expr ::= expr BETWEEN expr AND expr */ + { 252, -3 }, /* (241) expr ::= expr AND expr */ + { 252, -3 }, /* (242) expr ::= expr OR expr */ + { 252, -3 }, /* (243) expr ::= expr PLUS expr */ + { 252, -3 }, /* (244) expr ::= expr MINUS expr */ + { 252, -3 }, /* (245) expr ::= expr STAR expr */ + { 252, -3 }, /* (246) expr ::= expr SLASH expr */ + { 252, -3 }, /* (247) expr ::= expr REM expr */ + { 252, -3 }, /* (248) expr ::= expr LIKE expr */ + { 252, -5 }, /* (249) expr ::= expr IN LP exprlist RP */ + { 261, -3 }, /* (250) exprlist ::= exprlist COMMA expritem */ + { 261, -1 }, /* (251) exprlist ::= expritem */ + { 262, -1 }, /* (252) expritem ::= expr */ + { 262, 0 }, /* (253) expritem ::= */ + { 189, -3 }, /* (254) cmd ::= RESET QUERY CACHE */ + { 189, -3 }, /* (255) cmd ::= SYNCDB ids REPLICA */ + { 189, -7 }, /* (256) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + { 189, -7 }, /* (257) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + { 189, -7 }, /* (258) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + { 189, -7 }, /* (259) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + { 189, -8 }, /* (260) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + { 189, -9 }, /* (261) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + { 189, -7 }, /* (262) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + { 189, -7 }, /* (263) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + { 189, -7 }, /* (264) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + { 189, -7 }, /* (265) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + { 189, -8 }, /* (266) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + { 189, -3 }, /* (267) cmd ::= KILL CONNECTION INTEGER */ + { 189, -5 }, /* (268) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + { 189, -5 }, /* (269) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2102,9 +2105,9 @@ static void yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* program ::= cmd */ - case 129: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==129); - case 130: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==130); - case 131: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==131); + case 130: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==130); + case 131: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==131); + case 132: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==132); {} break; case 1: /* cmd ::= SHOW DATABASES */ @@ -2171,163 +2174,169 @@ static void yy_reduce( setDCLSqlElems(pInfo, TSDB_SQL_SHOW_CREATE_TABLE, 1, &yymsp[-1].minor.yy0); } break; - case 21: /* cmd ::= SHOW CREATE DATABASE ids */ + case 21: /* cmd ::= SHOW CREATE STABLE ids cpxName */ +{ + yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; + setDCLSqlElems(pInfo, TSDB_SQL_SHOW_CREATE_STABLE, 1, &yymsp[-1].minor.yy0); +} + break; + case 22: /* cmd ::= SHOW CREATE DATABASE ids */ { setDCLSqlElems(pInfo, TSDB_SQL_SHOW_CREATE_DATABASE, 1, &yymsp[0].minor.yy0); } break; - case 22: /* cmd ::= SHOW dbPrefix TABLES */ + case 23: /* cmd ::= SHOW dbPrefix TABLES */ { setShowOptions(pInfo, TSDB_MGMT_TABLE_TABLE, &yymsp[-1].minor.yy0, 0); } break; - case 23: /* cmd ::= SHOW dbPrefix TABLES LIKE ids */ + case 24: /* cmd ::= SHOW dbPrefix TABLES LIKE ids */ { setShowOptions(pInfo, TSDB_MGMT_TABLE_TABLE, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0); } break; - case 24: /* cmd ::= SHOW dbPrefix STABLES */ + case 25: /* cmd ::= SHOW dbPrefix STABLES */ { setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &yymsp[-1].minor.yy0, 0); } break; - case 25: /* cmd ::= SHOW dbPrefix STABLES LIKE ids */ + case 26: /* cmd ::= SHOW dbPrefix STABLES LIKE ids */ { SStrToken token; tSetDbName(&token, &yymsp[-3].minor.yy0); setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &token, &yymsp[0].minor.yy0); } break; - case 26: /* cmd ::= SHOW dbPrefix VGROUPS */ + case 27: /* cmd ::= SHOW dbPrefix VGROUPS */ { SStrToken token; tSetDbName(&token, &yymsp[-1].minor.yy0); setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, 0); } break; - case 27: /* cmd ::= SHOW dbPrefix VGROUPS ids */ + case 28: /* cmd ::= SHOW dbPrefix VGROUPS ids */ { SStrToken token; tSetDbName(&token, &yymsp[-2].minor.yy0); setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, &yymsp[0].minor.yy0); } break; - case 28: /* cmd ::= DROP TABLE ifexists ids cpxName */ + case 29: /* 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, -1, -1); } break; - case 29: /* cmd ::= DROP STABLE ifexists ids cpxName */ + case 30: /* cmd ::= DROP STABLE 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, -1, TSDB_SUPER_TABLE); } break; - case 30: /* cmd ::= DROP DATABASE ifexists ids */ + case 31: /* cmd ::= DROP DATABASE ifexists ids */ { setDropDbTableInfo(pInfo, TSDB_SQL_DROP_DB, &yymsp[0].minor.yy0, &yymsp[-1].minor.yy0, TSDB_DB_TYPE_DEFAULT, -1); } break; - case 31: /* cmd ::= DROP TOPIC ifexists ids */ + case 32: /* cmd ::= DROP TOPIC ifexists ids */ { setDropDbTableInfo(pInfo, TSDB_SQL_DROP_DB, &yymsp[0].minor.yy0, &yymsp[-1].minor.yy0, TSDB_DB_TYPE_TOPIC, -1); } break; - case 32: /* cmd ::= DROP DNODE ids */ + case 33: /* cmd ::= DROP DNODE ids */ { setDCLSqlElems(pInfo, TSDB_SQL_DROP_DNODE, 1, &yymsp[0].minor.yy0); } break; - case 33: /* cmd ::= DROP USER ids */ + case 34: /* cmd ::= DROP USER ids */ { setDCLSqlElems(pInfo, TSDB_SQL_DROP_USER, 1, &yymsp[0].minor.yy0); } break; - case 34: /* cmd ::= DROP ACCOUNT ids */ + case 35: /* cmd ::= DROP ACCOUNT ids */ { setDCLSqlElems(pInfo, TSDB_SQL_DROP_ACCT, 1, &yymsp[0].minor.yy0); } break; - case 35: /* cmd ::= USE ids */ + case 36: /* cmd ::= USE ids */ { setDCLSqlElems(pInfo, TSDB_SQL_USE_DB, 1, &yymsp[0].minor.yy0);} break; - case 36: /* cmd ::= DESCRIBE ids cpxName */ + case 37: /* 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 37: /* cmd ::= ALTER USER ids PASS ids */ + case 38: /* cmd ::= ALTER USER ids PASS ids */ { setAlterUserSql(pInfo, TSDB_ALTER_USER_PASSWD, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, NULL); } break; - case 38: /* cmd ::= ALTER USER ids PRIVILEGE ids */ + case 39: /* cmd ::= ALTER USER ids PRIVILEGE ids */ { setAlterUserSql(pInfo, TSDB_ALTER_USER_PRIVILEGES, &yymsp[-2].minor.yy0, NULL, &yymsp[0].minor.yy0);} break; - case 39: /* cmd ::= ALTER DNODE ids ids */ + case 40: /* cmd ::= ALTER DNODE ids ids */ { setDCLSqlElems(pInfo, TSDB_SQL_CFG_DNODE, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 40: /* cmd ::= ALTER DNODE ids ids ids */ + case 41: /* 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 41: /* cmd ::= ALTER LOCAL ids */ + case 42: /* cmd ::= ALTER LOCAL ids */ { setDCLSqlElems(pInfo, TSDB_SQL_CFG_LOCAL, 1, &yymsp[0].minor.yy0); } break; - case 42: /* cmd ::= ALTER LOCAL ids ids */ + case 43: /* cmd ::= ALTER LOCAL ids ids */ { setDCLSqlElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 43: /* cmd ::= ALTER DATABASE ids alter_db_optr */ - case 44: /* cmd ::= ALTER TOPIC ids alter_topic_optr */ yytestcase(yyruleno==44); + case 44: /* cmd ::= ALTER DATABASE ids alter_db_optr */ + case 45: /* cmd ::= ALTER TOPIC ids alter_topic_optr */ yytestcase(yyruleno==45); { SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy322, &t);} break; - case 45: /* cmd ::= ALTER ACCOUNT ids acct_optr */ + case 46: /* cmd ::= ALTER ACCOUNT ids acct_optr */ { setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy351);} break; - case 46: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ + case 47: /* 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.yy351);} break; - case 47: /* ids ::= ID */ - case 48: /* ids ::= STRING */ yytestcase(yyruleno==48); + case 48: /* ids ::= ID */ + case 49: /* ids ::= STRING */ yytestcase(yyruleno==49); {yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 49: /* ifexists ::= IF EXISTS */ + case 50: /* ifexists ::= IF EXISTS */ { yymsp[-1].minor.yy0.n = 1;} break; - case 50: /* ifexists ::= */ - case 52: /* ifnotexists ::= */ yytestcase(yyruleno==52); - case 170: /* distinct ::= */ yytestcase(yyruleno==170); + case 51: /* ifexists ::= */ + case 53: /* ifnotexists ::= */ yytestcase(yyruleno==53); + case 171: /* distinct ::= */ yytestcase(yyruleno==171); { yymsp[1].minor.yy0.n = 0;} break; - case 51: /* ifnotexists ::= IF NOT EXISTS */ + case 52: /* ifnotexists ::= IF NOT EXISTS */ { yymsp[-2].minor.yy0.n = 1;} break; - case 53: /* cmd ::= CREATE DNODE ids */ + case 54: /* cmd ::= CREATE DNODE ids */ { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);} break; - case 54: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + case 55: /* 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.yy351);} break; - case 55: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - case 56: /* cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ yytestcase(yyruleno==56); + case 56: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + case 57: /* cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ yytestcase(yyruleno==57); { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy322, &yymsp[-2].minor.yy0);} break; - case 57: /* cmd ::= CREATE USER ids PASS ids */ + case 58: /* cmd ::= CREATE USER ids PASS ids */ { setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} break; - case 58: /* pps ::= */ - case 60: /* tseries ::= */ yytestcase(yyruleno==60); - case 62: /* dbs ::= */ yytestcase(yyruleno==62); - case 64: /* streams ::= */ yytestcase(yyruleno==64); - case 66: /* storage ::= */ yytestcase(yyruleno==66); - case 68: /* qtime ::= */ yytestcase(yyruleno==68); - case 70: /* users ::= */ yytestcase(yyruleno==70); - case 72: /* conns ::= */ yytestcase(yyruleno==72); - case 74: /* state ::= */ yytestcase(yyruleno==74); + case 59: /* pps ::= */ + case 61: /* tseries ::= */ yytestcase(yyruleno==61); + case 63: /* dbs ::= */ yytestcase(yyruleno==63); + case 65: /* streams ::= */ yytestcase(yyruleno==65); + case 67: /* storage ::= */ yytestcase(yyruleno==67); + case 69: /* qtime ::= */ yytestcase(yyruleno==69); + case 71: /* users ::= */ yytestcase(yyruleno==71); + case 73: /* conns ::= */ yytestcase(yyruleno==73); + case 75: /* state ::= */ yytestcase(yyruleno==75); { yymsp[1].minor.yy0.n = 0; } break; - case 59: /* pps ::= PPS INTEGER */ - case 61: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==61); - case 63: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==63); - case 65: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==65); - case 67: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==67); - case 69: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==69); - case 71: /* users ::= USERS INTEGER */ yytestcase(yyruleno==71); - case 73: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==73); - case 75: /* state ::= STATE ids */ yytestcase(yyruleno==75); + case 60: /* pps ::= PPS INTEGER */ + case 62: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==62); + case 64: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==64); + case 66: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==66); + case 68: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==68); + case 70: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==70); + case 72: /* users ::= USERS INTEGER */ yytestcase(yyruleno==72); + case 74: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==74); + case 76: /* state ::= STATE ids */ yytestcase(yyruleno==76); { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 76: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + case 77: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { yylhsminor.yy351.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; yylhsminor.yy351.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; @@ -2341,119 +2350,119 @@ static void yy_reduce( } yymsp[-8].minor.yy351 = yylhsminor.yy351; break; - case 77: /* keep ::= KEEP tagitemlist */ + case 78: /* keep ::= KEEP tagitemlist */ { yymsp[-1].minor.yy159 = yymsp[0].minor.yy159; } break; - case 78: /* cache ::= CACHE INTEGER */ - case 79: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==79); - case 80: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==80); - case 81: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==81); - case 82: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==82); - case 83: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==83); - case 84: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==84); - case 85: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==85); - case 86: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==86); - case 87: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==87); - case 88: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==88); - case 89: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==89); - case 90: /* update ::= UPDATE INTEGER */ yytestcase(yyruleno==90); - case 91: /* cachelast ::= CACHELAST INTEGER */ yytestcase(yyruleno==91); - case 92: /* partitions ::= PARTITIONS INTEGER */ yytestcase(yyruleno==92); + case 79: /* cache ::= CACHE INTEGER */ + case 80: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==80); + case 81: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==81); + case 82: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==82); + case 83: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==83); + case 84: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==84); + case 85: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==85); + case 86: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==86); + case 87: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==87); + case 88: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==88); + case 89: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==89); + case 90: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==90); + case 91: /* update ::= UPDATE INTEGER */ yytestcase(yyruleno==91); + case 92: /* cachelast ::= CACHELAST INTEGER */ yytestcase(yyruleno==92); + case 93: /* partitions ::= PARTITIONS INTEGER */ yytestcase(yyruleno==93); { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 93: /* db_optr ::= */ + case 94: /* db_optr ::= */ {setDefaultCreateDbOption(&yymsp[1].minor.yy322); yymsp[1].minor.yy322.dbType = TSDB_DB_TYPE_DEFAULT;} break; - case 94: /* db_optr ::= db_optr cache */ + case 95: /* db_optr ::= db_optr cache */ { yylhsminor.yy322 = yymsp[-1].minor.yy322; yylhsminor.yy322.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy322 = yylhsminor.yy322; break; - case 95: /* db_optr ::= db_optr replica */ - case 112: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==112); + case 96: /* db_optr ::= db_optr replica */ + case 113: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==113); { yylhsminor.yy322 = yymsp[-1].minor.yy322; yylhsminor.yy322.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy322 = yylhsminor.yy322; break; - case 96: /* db_optr ::= db_optr quorum */ - case 113: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==113); + case 97: /* db_optr ::= db_optr quorum */ + case 114: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==114); { yylhsminor.yy322 = yymsp[-1].minor.yy322; yylhsminor.yy322.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy322 = yylhsminor.yy322; break; - case 97: /* db_optr ::= db_optr days */ + case 98: /* db_optr ::= db_optr days */ { yylhsminor.yy322 = yymsp[-1].minor.yy322; yylhsminor.yy322.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy322 = yylhsminor.yy322; break; - case 98: /* db_optr ::= db_optr minrows */ + case 99: /* db_optr ::= db_optr minrows */ { yylhsminor.yy322 = yymsp[-1].minor.yy322; yylhsminor.yy322.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } yymsp[-1].minor.yy322 = yylhsminor.yy322; break; - case 99: /* db_optr ::= db_optr maxrows */ + case 100: /* db_optr ::= db_optr maxrows */ { yylhsminor.yy322 = yymsp[-1].minor.yy322; yylhsminor.yy322.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } yymsp[-1].minor.yy322 = yylhsminor.yy322; break; - case 100: /* db_optr ::= db_optr blocks */ - case 115: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==115); + case 101: /* db_optr ::= db_optr blocks */ + case 116: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==116); { yylhsminor.yy322 = yymsp[-1].minor.yy322; yylhsminor.yy322.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy322 = yylhsminor.yy322; break; - case 101: /* db_optr ::= db_optr ctime */ + case 102: /* db_optr ::= db_optr ctime */ { yylhsminor.yy322 = yymsp[-1].minor.yy322; yylhsminor.yy322.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy322 = yylhsminor.yy322; break; - case 102: /* db_optr ::= db_optr wal */ - case 117: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==117); + case 103: /* db_optr ::= db_optr wal */ + case 118: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==118); { yylhsminor.yy322 = yymsp[-1].minor.yy322; yylhsminor.yy322.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy322 = yylhsminor.yy322; break; - case 103: /* db_optr ::= db_optr fsync */ - case 118: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==118); + case 104: /* db_optr ::= db_optr fsync */ + case 119: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==119); { yylhsminor.yy322 = yymsp[-1].minor.yy322; yylhsminor.yy322.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy322 = yylhsminor.yy322; break; - case 104: /* db_optr ::= db_optr comp */ - case 116: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==116); + case 105: /* db_optr ::= db_optr comp */ + case 117: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==117); { yylhsminor.yy322 = yymsp[-1].minor.yy322; yylhsminor.yy322.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy322 = yylhsminor.yy322; break; - case 105: /* db_optr ::= db_optr prec */ + case 106: /* db_optr ::= db_optr prec */ { yylhsminor.yy322 = yymsp[-1].minor.yy322; yylhsminor.yy322.precision = yymsp[0].minor.yy0; } yymsp[-1].minor.yy322 = yylhsminor.yy322; break; - case 106: /* db_optr ::= db_optr keep */ - case 114: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==114); + case 107: /* db_optr ::= db_optr keep */ + case 115: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==115); { yylhsminor.yy322 = yymsp[-1].minor.yy322; yylhsminor.yy322.keep = yymsp[0].minor.yy159; } yymsp[-1].minor.yy322 = yylhsminor.yy322; break; - case 107: /* db_optr ::= db_optr update */ - case 119: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==119); + case 108: /* db_optr ::= db_optr update */ + case 120: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==120); { yylhsminor.yy322 = yymsp[-1].minor.yy322; yylhsminor.yy322.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy322 = yylhsminor.yy322; break; - case 108: /* db_optr ::= db_optr cachelast */ - case 120: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==120); + case 109: /* db_optr ::= db_optr cachelast */ + case 121: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==121); { yylhsminor.yy322 = yymsp[-1].minor.yy322; yylhsminor.yy322.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy322 = yylhsminor.yy322; break; - case 109: /* topic_optr ::= db_optr */ - case 121: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==121); + case 110: /* topic_optr ::= db_optr */ + case 122: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==122); { yylhsminor.yy322 = yymsp[0].minor.yy322; yylhsminor.yy322.dbType = TSDB_DB_TYPE_TOPIC; } yymsp[0].minor.yy322 = yylhsminor.yy322; break; - case 110: /* topic_optr ::= topic_optr partitions */ - case 122: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==122); + case 111: /* topic_optr ::= topic_optr partitions */ + case 123: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==123); { yylhsminor.yy322 = yymsp[-1].minor.yy322; yylhsminor.yy322.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy322 = yylhsminor.yy322; break; - case 111: /* alter_db_optr ::= */ + case 112: /* alter_db_optr ::= */ { setDefaultCreateDbOption(&yymsp[1].minor.yy322); yymsp[1].minor.yy322.dbType = TSDB_DB_TYPE_DEFAULT;} break; - case 123: /* typename ::= ids */ + case 124: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; tSetColumnType (&yylhsminor.yy407, &yymsp[0].minor.yy0); } yymsp[0].minor.yy407 = yylhsminor.yy407; break; - case 124: /* typename ::= ids LP signed RP */ + case 125: /* typename ::= ids LP signed RP */ { if (yymsp[-1].minor.yy317 <= 0) { yymsp[-3].minor.yy0.type = 0; @@ -2465,7 +2474,7 @@ static void yy_reduce( } yymsp[-3].minor.yy407 = yylhsminor.yy407; break; - case 125: /* typename ::= ids UNSIGNED */ + case 126: /* typename ::= ids UNSIGNED */ { yymsp[-1].minor.yy0.type = 0; yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z); @@ -2473,20 +2482,20 @@ static void yy_reduce( } yymsp[-1].minor.yy407 = yylhsminor.yy407; break; - case 126: /* signed ::= INTEGER */ + case 127: /* signed ::= INTEGER */ { yylhsminor.yy317 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[0].minor.yy317 = yylhsminor.yy317; break; - case 127: /* signed ::= PLUS INTEGER */ + case 128: /* signed ::= PLUS INTEGER */ { yymsp[-1].minor.yy317 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 128: /* signed ::= MINUS INTEGER */ + case 129: /* signed ::= MINUS INTEGER */ { yymsp[-1].minor.yy317 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; - case 132: /* cmd ::= CREATE TABLE create_table_list */ + case 133: /* cmd ::= CREATE TABLE create_table_list */ { pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy14;} break; - case 133: /* create_table_list ::= create_from_stable */ + case 134: /* create_table_list ::= create_from_stable */ { SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); @@ -2497,14 +2506,14 @@ static void yy_reduce( } yymsp[0].minor.yy14 = yylhsminor.yy14; break; - case 134: /* create_table_list ::= create_table_list create_from_stable */ + case 135: /* create_table_list ::= create_table_list create_from_stable */ { taosArrayPush(yymsp[-1].minor.yy14->childTableInfo, &yymsp[0].minor.yy206); yylhsminor.yy14 = yymsp[-1].minor.yy14; } yymsp[-1].minor.yy14 = yylhsminor.yy14; break; - case 135: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + case 136: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { yylhsminor.yy14 = tSetCreateTableInfo(yymsp[-1].minor.yy159, NULL, NULL, TSQL_CREATE_TABLE); setSqlInfo(pInfo, yylhsminor.yy14, NULL, TSDB_SQL_CREATE_TABLE); @@ -2514,7 +2523,7 @@ static void yy_reduce( } yymsp[-5].minor.yy14 = yylhsminor.yy14; break; - case 136: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + case 137: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { yylhsminor.yy14 = tSetCreateTableInfo(yymsp[-5].minor.yy159, yymsp[-1].minor.yy159, NULL, TSQL_CREATE_STABLE); setSqlInfo(pInfo, yylhsminor.yy14, NULL, TSDB_SQL_CREATE_TABLE); @@ -2524,7 +2533,7 @@ static void yy_reduce( } yymsp[-9].minor.yy14 = yylhsminor.yy14; break; - case 137: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + case 138: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; @@ -2532,7 +2541,7 @@ static void yy_reduce( } yymsp[-9].minor.yy206 = yylhsminor.yy206; break; - case 138: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + case 139: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ { yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n; @@ -2540,15 +2549,15 @@ static void yy_reduce( } yymsp[-12].minor.yy206 = yylhsminor.yy206; break; - case 139: /* tagNamelist ::= tagNamelist COMMA ids */ + case 140: /* tagNamelist ::= tagNamelist COMMA ids */ {taosArrayPush(yymsp[-2].minor.yy159, &yymsp[0].minor.yy0); yylhsminor.yy159 = yymsp[-2].minor.yy159; } yymsp[-2].minor.yy159 = yylhsminor.yy159; break; - case 140: /* tagNamelist ::= ids */ + case 141: /* tagNamelist ::= ids */ {yylhsminor.yy159 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy159, &yymsp[0].minor.yy0);} yymsp[0].minor.yy159 = yylhsminor.yy159; break; - case 141: /* create_table_args ::= ifnotexists ids cpxName AS select */ + case 142: /* create_table_args ::= ifnotexists ids cpxName AS select */ { yylhsminor.yy14 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy116, TSQL_CREATE_STREAM); setSqlInfo(pInfo, yylhsminor.yy14, NULL, TSDB_SQL_CREATE_TABLE); @@ -2558,43 +2567,43 @@ static void yy_reduce( } yymsp[-4].minor.yy14 = yylhsminor.yy14; break; - case 142: /* columnlist ::= columnlist COMMA column */ + case 143: /* columnlist ::= columnlist COMMA column */ {taosArrayPush(yymsp[-2].minor.yy159, &yymsp[0].minor.yy407); yylhsminor.yy159 = yymsp[-2].minor.yy159; } yymsp[-2].minor.yy159 = yylhsminor.yy159; break; - case 143: /* columnlist ::= column */ + case 144: /* columnlist ::= column */ {yylhsminor.yy159 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy159, &yymsp[0].minor.yy407);} yymsp[0].minor.yy159 = yylhsminor.yy159; break; - case 144: /* column ::= ids typename */ + case 145: /* column ::= ids typename */ { tSetColumnInfo(&yylhsminor.yy407, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy407); } yymsp[-1].minor.yy407 = yylhsminor.yy407; break; - case 145: /* tagitemlist ::= tagitemlist COMMA tagitem */ + case 146: /* tagitemlist ::= tagitemlist COMMA tagitem */ { yylhsminor.yy159 = tVariantListAppend(yymsp[-2].minor.yy159, &yymsp[0].minor.yy488, -1); } yymsp[-2].minor.yy159 = yylhsminor.yy159; break; - case 146: /* tagitemlist ::= tagitem */ + case 147: /* tagitemlist ::= tagitem */ { yylhsminor.yy159 = tVariantListAppend(NULL, &yymsp[0].minor.yy488, -1); } yymsp[0].minor.yy159 = yylhsminor.yy159; break; - case 147: /* tagitem ::= INTEGER */ - case 148: /* tagitem ::= FLOAT */ yytestcase(yyruleno==148); - case 149: /* tagitem ::= STRING */ yytestcase(yyruleno==149); - case 150: /* tagitem ::= BOOL */ yytestcase(yyruleno==150); + case 148: /* tagitem ::= INTEGER */ + case 149: /* tagitem ::= FLOAT */ yytestcase(yyruleno==149); + case 150: /* tagitem ::= STRING */ yytestcase(yyruleno==150); + case 151: /* tagitem ::= BOOL */ yytestcase(yyruleno==151); { toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy488, &yymsp[0].minor.yy0); } yymsp[0].minor.yy488 = yylhsminor.yy488; break; - case 151: /* tagitem ::= NULL */ + case 152: /* tagitem ::= NULL */ { yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy488, &yymsp[0].minor.yy0); } yymsp[0].minor.yy488 = yylhsminor.yy488; break; - case 152: /* tagitem ::= MINUS INTEGER */ - case 153: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==153); - case 154: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==154); - case 155: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==155); + case 153: /* tagitem ::= MINUS INTEGER */ + case 154: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==154); + case 155: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==155); + case 156: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==156); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; @@ -2603,128 +2612,128 @@ static void yy_reduce( } yymsp[-1].minor.yy488 = yylhsminor.yy488; break; - case 156: /* select ::= SELECT selcollist from where_opt interval_opt session_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ + case 157: /* select ::= SELECT selcollist from where_opt interval_opt session_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ { yylhsminor.yy116 = tSetQuerySqlNode(&yymsp[-12].minor.yy0, yymsp[-11].minor.yy159, yymsp[-10].minor.yy236, yymsp[-9].minor.yy118, yymsp[-4].minor.yy159, yymsp[-3].minor.yy159, &yymsp[-8].minor.yy184, &yymsp[-7].minor.yy249, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy159, &yymsp[0].minor.yy440, &yymsp[-1].minor.yy440, yymsp[-2].minor.yy118); } yymsp[-12].minor.yy116 = yylhsminor.yy116; break; - case 157: /* select ::= LP select RP */ + case 158: /* select ::= LP select RP */ {yymsp[-2].minor.yy116 = yymsp[-1].minor.yy116;} break; - case 158: /* union ::= select */ + case 159: /* union ::= select */ { yylhsminor.yy159 = setSubclause(NULL, yymsp[0].minor.yy116); } yymsp[0].minor.yy159 = yylhsminor.yy159; break; - case 159: /* union ::= union UNION ALL select */ + case 160: /* union ::= union UNION ALL select */ { yylhsminor.yy159 = appendSelectClause(yymsp[-3].minor.yy159, yymsp[0].minor.yy116); } yymsp[-3].minor.yy159 = yylhsminor.yy159; break; - case 160: /* cmd ::= union */ + case 161: /* cmd ::= union */ { setSqlInfo(pInfo, yymsp[0].minor.yy159, NULL, TSDB_SQL_SELECT); } break; - case 161: /* select ::= SELECT selcollist */ + case 162: /* select ::= SELECT selcollist */ { yylhsminor.yy116 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy159, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } yymsp[-1].minor.yy116 = yylhsminor.yy116; break; - case 162: /* sclp ::= selcollist COMMA */ + case 163: /* sclp ::= selcollist COMMA */ {yylhsminor.yy159 = yymsp[-1].minor.yy159;} yymsp[-1].minor.yy159 = yylhsminor.yy159; break; - case 163: /* sclp ::= */ - case 188: /* orderby_opt ::= */ yytestcase(yyruleno==188); + case 164: /* sclp ::= */ + case 189: /* orderby_opt ::= */ yytestcase(yyruleno==189); {yymsp[1].minor.yy159 = 0;} break; - case 164: /* selcollist ::= sclp distinct expr as */ + case 165: /* selcollist ::= sclp distinct expr as */ { yylhsminor.yy159 = tSqlExprListAppend(yymsp[-3].minor.yy159, yymsp[-1].minor.yy118, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } yymsp[-3].minor.yy159 = yylhsminor.yy159; break; - case 165: /* selcollist ::= sclp STAR */ + case 166: /* selcollist ::= sclp STAR */ { tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL); yylhsminor.yy159 = tSqlExprListAppend(yymsp[-1].minor.yy159, pNode, 0, 0); } yymsp[-1].minor.yy159 = yylhsminor.yy159; break; - case 166: /* as ::= AS ids */ + case 167: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 167: /* as ::= ids */ + case 168: /* as ::= ids */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 168: /* as ::= */ + case 169: /* as ::= */ { yymsp[1].minor.yy0.n = 0; } break; - case 169: /* distinct ::= DISTINCT */ + case 170: /* distinct ::= DISTINCT */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 171: /* from ::= FROM tablelist */ + case 172: /* from ::= FROM tablelist */ {yymsp[-1].minor.yy236 = yymsp[0].minor.yy236;} break; - case 172: /* from ::= FROM LP union RP */ + case 173: /* from ::= FROM LP union RP */ {yymsp[-3].minor.yy236 = setSubquery(NULL, yymsp[-1].minor.yy159);} break; - case 173: /* tablelist ::= ids cpxName */ + case 174: /* tablelist ::= ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yylhsminor.yy236 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); } yymsp[-1].minor.yy236 = yylhsminor.yy236; break; - case 174: /* tablelist ::= ids cpxName ids */ + case 175: /* tablelist ::= ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; yylhsminor.yy236 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy236 = yylhsminor.yy236; break; - case 175: /* tablelist ::= tablelist COMMA ids cpxName */ + case 176: /* tablelist ::= tablelist COMMA ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yylhsminor.yy236 = setTableNameList(yymsp[-3].minor.yy236, &yymsp[-1].minor.yy0, NULL); } yymsp[-3].minor.yy236 = yylhsminor.yy236; break; - case 176: /* tablelist ::= tablelist COMMA ids cpxName ids */ + case 177: /* tablelist ::= tablelist COMMA ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; yylhsminor.yy236 = setTableNameList(yymsp[-4].minor.yy236, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } yymsp[-4].minor.yy236 = yylhsminor.yy236; break; - case 177: /* tmvar ::= VARIABLE */ + case 178: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 178: /* interval_opt ::= INTERVAL LP tmvar RP */ + case 179: /* interval_opt ::= INTERVAL LP tmvar RP */ {yymsp[-3].minor.yy184.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy184.offset.n = 0;} break; - case 179: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + case 180: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ {yymsp[-5].minor.yy184.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy184.offset = yymsp[-1].minor.yy0;} break; - case 180: /* interval_opt ::= */ + case 181: /* interval_opt ::= */ {memset(&yymsp[1].minor.yy184, 0, sizeof(yymsp[1].minor.yy184));} break; - case 181: /* session_option ::= */ + case 182: /* session_option ::= */ {yymsp[1].minor.yy249.col.n = 0; yymsp[1].minor.yy249.gap.n = 0;} break; - case 182: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + case 183: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-6].minor.yy249.col = yymsp[-4].minor.yy0; yymsp[-6].minor.yy249.gap = yymsp[-1].minor.yy0; } break; - case 183: /* fill_opt ::= */ + case 184: /* fill_opt ::= */ { yymsp[1].minor.yy159 = 0; } break; - case 184: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + case 185: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { tVariant A = {0}; toTSDBType(yymsp[-3].minor.yy0.type); @@ -2734,34 +2743,34 @@ static void yy_reduce( yymsp[-5].minor.yy159 = yymsp[-1].minor.yy159; } break; - case 185: /* fill_opt ::= FILL LP ID RP */ + case 186: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-3].minor.yy159 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } break; - case 186: /* sliding_opt ::= SLIDING LP tmvar RP */ + case 187: /* sliding_opt ::= SLIDING LP tmvar RP */ {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } break; - case 187: /* sliding_opt ::= */ + case 188: /* sliding_opt ::= */ {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; - case 189: /* orderby_opt ::= ORDER BY sortlist */ + case 190: /* orderby_opt ::= ORDER BY sortlist */ {yymsp[-2].minor.yy159 = yymsp[0].minor.yy159;} break; - case 190: /* sortlist ::= sortlist COMMA item sortorder */ + case 191: /* sortlist ::= sortlist COMMA item sortorder */ { yylhsminor.yy159 = tVariantListAppend(yymsp[-3].minor.yy159, &yymsp[-1].minor.yy488, yymsp[0].minor.yy20); } yymsp[-3].minor.yy159 = yylhsminor.yy159; break; - case 191: /* sortlist ::= item sortorder */ + case 192: /* sortlist ::= item sortorder */ { yylhsminor.yy159 = tVariantListAppend(NULL, &yymsp[-1].minor.yy488, yymsp[0].minor.yy20); } yymsp[-1].minor.yy159 = yylhsminor.yy159; break; - case 192: /* item ::= ids cpxName */ + case 193: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; @@ -2770,227 +2779,227 @@ static void yy_reduce( } yymsp[-1].minor.yy488 = yylhsminor.yy488; break; - case 193: /* sortorder ::= ASC */ + case 194: /* sortorder ::= ASC */ { yymsp[0].minor.yy20 = TSDB_ORDER_ASC; } break; - case 194: /* sortorder ::= DESC */ + case 195: /* sortorder ::= DESC */ { yymsp[0].minor.yy20 = TSDB_ORDER_DESC;} break; - case 195: /* sortorder ::= */ + case 196: /* sortorder ::= */ { yymsp[1].minor.yy20 = TSDB_ORDER_ASC; } break; - case 196: /* groupby_opt ::= */ + case 197: /* groupby_opt ::= */ { yymsp[1].minor.yy159 = 0;} break; - case 197: /* groupby_opt ::= GROUP BY grouplist */ + case 198: /* groupby_opt ::= GROUP BY grouplist */ { yymsp[-2].minor.yy159 = yymsp[0].minor.yy159;} break; - case 198: /* grouplist ::= grouplist COMMA item */ + case 199: /* grouplist ::= grouplist COMMA item */ { yylhsminor.yy159 = tVariantListAppend(yymsp[-2].minor.yy159, &yymsp[0].minor.yy488, -1); } yymsp[-2].minor.yy159 = yylhsminor.yy159; break; - case 199: /* grouplist ::= item */ + case 200: /* grouplist ::= item */ { yylhsminor.yy159 = tVariantListAppend(NULL, &yymsp[0].minor.yy488, -1); } yymsp[0].minor.yy159 = yylhsminor.yy159; break; - case 200: /* having_opt ::= */ - case 210: /* where_opt ::= */ yytestcase(yyruleno==210); - case 252: /* expritem ::= */ yytestcase(yyruleno==252); + case 201: /* having_opt ::= */ + case 211: /* where_opt ::= */ yytestcase(yyruleno==211); + case 253: /* expritem ::= */ yytestcase(yyruleno==253); {yymsp[1].minor.yy118 = 0;} break; - case 201: /* having_opt ::= HAVING expr */ - case 211: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==211); + case 202: /* having_opt ::= HAVING expr */ + case 212: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==212); {yymsp[-1].minor.yy118 = yymsp[0].minor.yy118;} break; - case 202: /* limit_opt ::= */ - case 206: /* slimit_opt ::= */ yytestcase(yyruleno==206); + case 203: /* limit_opt ::= */ + case 207: /* slimit_opt ::= */ yytestcase(yyruleno==207); {yymsp[1].minor.yy440.limit = -1; yymsp[1].minor.yy440.offset = 0;} break; - case 203: /* limit_opt ::= LIMIT signed */ - case 207: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==207); + case 204: /* limit_opt ::= LIMIT signed */ + case 208: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==208); {yymsp[-1].minor.yy440.limit = yymsp[0].minor.yy317; yymsp[-1].minor.yy440.offset = 0;} break; - case 204: /* limit_opt ::= LIMIT signed OFFSET signed */ + case 205: /* limit_opt ::= LIMIT signed OFFSET signed */ { yymsp[-3].minor.yy440.limit = yymsp[-2].minor.yy317; yymsp[-3].minor.yy440.offset = yymsp[0].minor.yy317;} break; - case 205: /* limit_opt ::= LIMIT signed COMMA signed */ + case 206: /* limit_opt ::= LIMIT signed COMMA signed */ { yymsp[-3].minor.yy440.limit = yymsp[0].minor.yy317; yymsp[-3].minor.yy440.offset = yymsp[-2].minor.yy317;} break; - case 208: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ + case 209: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ {yymsp[-3].minor.yy440.limit = yymsp[-2].minor.yy317; yymsp[-3].minor.yy440.offset = yymsp[0].minor.yy317;} break; - case 209: /* slimit_opt ::= SLIMIT signed COMMA signed */ + case 210: /* slimit_opt ::= SLIMIT signed COMMA signed */ {yymsp[-3].minor.yy440.limit = yymsp[0].minor.yy317; yymsp[-3].minor.yy440.offset = yymsp[-2].minor.yy317;} break; - case 212: /* expr ::= LP expr RP */ + case 213: /* expr ::= LP expr RP */ {yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118->token.z = yymsp[-2].minor.yy0.z; yylhsminor.yy118->token.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 213: /* expr ::= ID */ + case 214: /* expr ::= ID */ { yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} yymsp[0].minor.yy118 = yylhsminor.yy118; break; - case 214: /* expr ::= ID DOT ID */ + case 215: /* expr ::= ID DOT ID */ { yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 215: /* expr ::= ID DOT STAR */ + case 216: /* expr ::= ID DOT STAR */ { yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 216: /* expr ::= INTEGER */ + case 217: /* expr ::= INTEGER */ { yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} yymsp[0].minor.yy118 = yylhsminor.yy118; break; - case 217: /* expr ::= MINUS INTEGER */ - case 218: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==218); + case 218: /* expr ::= MINUS INTEGER */ + case 219: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==219); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} yymsp[-1].minor.yy118 = yylhsminor.yy118; break; - case 219: /* expr ::= FLOAT */ + case 220: /* expr ::= FLOAT */ { yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} yymsp[0].minor.yy118 = yylhsminor.yy118; break; - case 220: /* expr ::= MINUS FLOAT */ - case 221: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==221); + case 221: /* expr ::= MINUS FLOAT */ + case 222: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==222); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} yymsp[-1].minor.yy118 = yylhsminor.yy118; break; - case 222: /* expr ::= STRING */ + case 223: /* expr ::= STRING */ { yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} yymsp[0].minor.yy118 = yylhsminor.yy118; break; - case 223: /* expr ::= NOW */ + case 224: /* expr ::= NOW */ { yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } yymsp[0].minor.yy118 = yylhsminor.yy118; break; - case 224: /* expr ::= VARIABLE */ + case 225: /* expr ::= VARIABLE */ { yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} yymsp[0].minor.yy118 = yylhsminor.yy118; break; - case 225: /* expr ::= PLUS VARIABLE */ - case 226: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==226); + case 226: /* expr ::= PLUS VARIABLE */ + case 227: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==227); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} yymsp[-1].minor.yy118 = yylhsminor.yy118; break; - case 227: /* expr ::= BOOL */ + case 228: /* expr ::= BOOL */ { yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} yymsp[0].minor.yy118 = yylhsminor.yy118; break; - case 228: /* expr ::= NULL */ + case 229: /* expr ::= NULL */ { yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} yymsp[0].minor.yy118 = yylhsminor.yy118; break; - case 229: /* expr ::= ID LP exprlist RP */ + case 230: /* expr ::= ID LP exprlist RP */ { yylhsminor.yy118 = tSqlExprCreateFunction(yymsp[-1].minor.yy159, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy118 = yylhsminor.yy118; break; - case 230: /* expr ::= ID LP STAR RP */ + case 231: /* expr ::= ID LP STAR RP */ { yylhsminor.yy118 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy118 = yylhsminor.yy118; break; - case 231: /* expr ::= expr IS NULL */ + case 232: /* expr ::= expr IS NULL */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, NULL, TK_ISNULL);} yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 232: /* expr ::= expr IS NOT NULL */ + case 233: /* expr ::= expr IS NOT NULL */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-3].minor.yy118, NULL, TK_NOTNULL);} yymsp[-3].minor.yy118 = yylhsminor.yy118; break; - case 233: /* expr ::= expr LT expr */ + case 234: /* expr ::= expr LT expr */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_LT);} yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 234: /* expr ::= expr GT expr */ + case 235: /* expr ::= expr GT expr */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_GT);} yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 235: /* expr ::= expr LE expr */ + case 236: /* expr ::= expr LE expr */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_LE);} yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 236: /* expr ::= expr GE expr */ + case 237: /* expr ::= expr GE expr */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_GE);} yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 237: /* expr ::= expr NE expr */ + case 238: /* expr ::= expr NE expr */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_NE);} yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 238: /* expr ::= expr EQ expr */ + case 239: /* expr ::= expr EQ expr */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_EQ);} yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 239: /* expr ::= expr BETWEEN expr AND expr */ + case 240: /* expr ::= expr BETWEEN expr AND expr */ { tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy118); yylhsminor.yy118 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy118, yymsp[-2].minor.yy118, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy118, TK_LE), TK_AND);} yymsp[-4].minor.yy118 = yylhsminor.yy118; break; - case 240: /* expr ::= expr AND expr */ + case 241: /* expr ::= expr AND expr */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_AND);} yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 241: /* expr ::= expr OR expr */ + case 242: /* expr ::= expr OR expr */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_OR); } yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 242: /* expr ::= expr PLUS expr */ + case 243: /* expr ::= expr PLUS expr */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_PLUS); } yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 243: /* expr ::= expr MINUS expr */ + case 244: /* expr ::= expr MINUS expr */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_MINUS); } yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 244: /* expr ::= expr STAR expr */ + case 245: /* expr ::= expr STAR expr */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_STAR); } yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 245: /* expr ::= expr SLASH expr */ + case 246: /* expr ::= expr SLASH expr */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_DIVIDE);} yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 246: /* expr ::= expr REM expr */ + case 247: /* expr ::= expr REM expr */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_REM); } yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 247: /* expr ::= expr LIKE expr */ + case 248: /* expr ::= expr LIKE expr */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_LIKE); } yymsp[-2].minor.yy118 = yylhsminor.yy118; break; - case 248: /* expr ::= expr IN LP exprlist RP */ + case 249: /* expr ::= expr IN LP exprlist RP */ {yylhsminor.yy118 = tSqlExprCreate(yymsp[-4].minor.yy118, (tSqlExpr*)yymsp[-1].minor.yy159, TK_IN); } yymsp[-4].minor.yy118 = yylhsminor.yy118; break; - case 249: /* exprlist ::= exprlist COMMA expritem */ + case 250: /* exprlist ::= exprlist COMMA expritem */ {yylhsminor.yy159 = tSqlExprListAppend(yymsp[-2].minor.yy159,yymsp[0].minor.yy118,0, 0);} yymsp[-2].minor.yy159 = yylhsminor.yy159; break; - case 250: /* exprlist ::= expritem */ + case 251: /* exprlist ::= expritem */ {yylhsminor.yy159 = tSqlExprListAppend(0,yymsp[0].minor.yy118,0, 0);} yymsp[0].minor.yy159 = yylhsminor.yy159; break; - case 251: /* expritem ::= expr */ + case 252: /* expritem ::= expr */ {yylhsminor.yy118 = yymsp[0].minor.yy118;} yymsp[0].minor.yy118 = yylhsminor.yy118; break; - case 253: /* cmd ::= RESET QUERY CACHE */ + case 254: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 254: /* cmd ::= SYNCDB ids REPLICA */ + case 255: /* cmd ::= SYNCDB ids REPLICA */ { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} break; - case 255: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 256: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy159, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 256: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 257: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3001,14 +3010,14 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 257: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 258: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy159, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 258: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 259: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3019,7 +3028,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 259: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 260: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3033,7 +3042,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 260: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 261: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; @@ -3045,14 +3054,14 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 261: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + case 262: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy159, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 262: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + case 263: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3063,14 +3072,14 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 263: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + case 264: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy159, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 264: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + case 265: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3081,7 +3090,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 265: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + case 266: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3095,13 +3104,13 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 266: /* cmd ::= KILL CONNECTION INTEGER */ + case 267: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 267: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 268: /* 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 268: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 269: /* 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: diff --git a/src/util/inc/ttoken.h b/src/util/inc/ttoken.h index c1e2170ac30358f24b05aa00c9422dd34bb4401d..d5e45e60a148726d0e71c38fcd8262d1d67a380a 100644 --- a/src/util/inc/ttoken.h +++ b/src/util/inc/ttoken.h @@ -185,6 +185,9 @@ static FORCE_INLINE int32_t tGetNumericStringType(const SStrToken* pToken) { void taosCleanupKeywordsTable(); +SStrToken tscReplaceStrToken(char **str, SStrToken *token, const char* newToken); + + #ifdef __cplusplus } #endif diff --git a/src/util/src/ttokenizer.c b/src/util/src/ttokenizer.c index 54da75cae007a909a4f28a5f97b7d66bdcb114be..93d4570ea8de5c41edcedce7fab3183d5f54f7e8 100644 --- a/src/util/src/ttokenizer.c +++ b/src/util/src/ttokenizer.c @@ -572,6 +572,28 @@ uint32_t tGetToken(char* z, uint32_t* tokenId) { return 0; } +SStrToken tscReplaceStrToken(char **str, SStrToken *token, const char* newToken) { + char *src = *str; + size_t nsize = strlen(newToken); + int32_t size = (int32_t)strlen(*str) - token->n + (int32_t)nsize + 1; + int32_t bsize = (int32_t)((uint64_t)token->z - (uint64_t)src); + SStrToken ntoken; + + *str = calloc(1, size); + + strncpy(*str, src, bsize); + strcat(*str, newToken); + strcat(*str, token->z + token->n); + + ntoken.n = (uint32_t)nsize; + ntoken.z = *str + bsize; + + tfree(src); + + return ntoken; +} + + SStrToken tStrGetToken(char* str, int32_t* i, bool isPrevOptr) { SStrToken t0 = {0}; diff --git a/tests/examples/c/makefile b/tests/examples/c/makefile index b06fe551dbde4b16e3ea197ca4c2bc1711ef63bb..304623c27af27cd23a301af134647fb3b9746d64 100644 --- a/tests/examples/c/makefile +++ b/tests/examples/c/makefile @@ -22,6 +22,7 @@ clean: rm $(ROOT)asyncdemo rm $(ROOT)demo rm $(ROOT)prepare + rm $(ROOT)batchprepare rm $(ROOT)stream rm $(ROOT)subscribe rm $(ROOT)apitest diff --git a/tests/script/api/batchprepare.c b/tests/script/api/batchprepare.c new file mode 100644 index 0000000000000000000000000000000000000000..8f1337486e736cbb7f322609b8bf7ab71d1eb693 --- /dev/null +++ b/tests/script/api/batchprepare.c @@ -0,0 +1,2567 @@ +// TAOS standard API example. The same syntax as MySQL, but only a subet +// to compile: gcc -o prepare prepare.c -ltaos + +#include +#include +#include +#include "taos.h" +#include +#include +#include + +typedef struct { + TAOS *taos; + int idx; +}T_par; + +void taosMsleep(int mseconds); + +unsigned long long getCurrentTime(){ + struct timeval tv; + if (gettimeofday(&tv, NULL) != 0) { + perror("Failed to get current time in ms"); + exit(EXIT_FAILURE); + } + + return (uint64_t)tv.tv_sec * 1000000ULL + (uint64_t)tv.tv_usec; +} + + + +int stmt_func1(TAOS_STMT *stmt) { + struct { + int64_t ts; + int8_t b; + int8_t v1; + int16_t v2; + int32_t v4; + int64_t v8; + float f4; + double f8; + char bin[40]; + char blob[80]; + } v = {0}; + + TAOS_BIND params[10]; + params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[0].buffer_length = sizeof(v.ts); + params[0].buffer = &v.ts; + params[0].length = ¶ms[0].buffer_length; + params[0].is_null = NULL; + + params[1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[1].buffer_length = sizeof(v.b); + params[1].buffer = &v.b; + params[1].length = ¶ms[1].buffer_length; + params[1].is_null = NULL; + + params[2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[2].buffer_length = sizeof(v.v1); + params[2].buffer = &v.v1; + params[2].length = ¶ms[2].buffer_length; + params[2].is_null = NULL; + + params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[3].buffer_length = sizeof(v.v2); + params[3].buffer = &v.v2; + params[3].length = ¶ms[3].buffer_length; + params[3].is_null = NULL; + + params[4].buffer_type = TSDB_DATA_TYPE_INT; + params[4].buffer_length = sizeof(v.v4); + params[4].buffer = &v.v4; + params[4].length = ¶ms[4].buffer_length; + params[4].is_null = NULL; + + params[5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[5].buffer_length = sizeof(v.v8); + params[5].buffer = &v.v8; + params[5].length = ¶ms[5].buffer_length; + params[5].is_null = NULL; + + params[6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[6].buffer_length = sizeof(v.f4); + params[6].buffer = &v.f4; + params[6].length = ¶ms[6].buffer_length; + params[6].is_null = NULL; + + params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[7].buffer_length = sizeof(v.f8); + params[7].buffer = &v.f8; + params[7].length = ¶ms[7].buffer_length; + params[7].is_null = NULL; + + params[8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[8].buffer_length = sizeof(v.bin); + params[8].buffer = v.bin; + params[8].length = ¶ms[8].buffer_length; + params[8].is_null = NULL; + + params[9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[9].buffer_length = sizeof(v.bin); + params[9].buffer = v.bin; + params[9].length = ¶ms[9].buffer_length; + params[9].is_null = NULL; + + int is_null = 1; + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + for (int zz = 0; zz < 10; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + v.ts = 1591060628000 + zz * 10; + for (int i = 0; i < 10; ++i) { + v.ts += 1; + for (int j = 1; j < 10; ++j) { + params[j].is_null = ((i == j) ? &is_null : 0); + } + v.b = (int8_t)(i+zz*10) % 2; + v.v1 = (int8_t)(i+zz*10); + v.v2 = (int16_t)((i+zz*10) * 2); + v.v4 = (int32_t)((i+zz*10) * 4); + v.v8 = (int64_t)((i+zz*10) * 8); + v.f4 = (float)((i+zz*10) * 40); + v.f8 = (double)((i+zz*10) * 80); + for (int j = 0; j < sizeof(v.bin) - 1; ++j) { + v.bin[j] = (char)((i+zz)%10 + '0'); + } + + taos_stmt_bind_param(stmt, params); + taos_stmt_add_batch(stmt); + } + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + return 0; +} + + +int stmt_func2(TAOS_STMT *stmt) { + struct { + int64_t ts; + int8_t b; + int8_t v1; + int16_t v2; + int32_t v4; + int64_t v8; + float f4; + double f8; + char bin[40]; + char blob[80]; + } v = {0}; + + TAOS_BIND params[10]; + params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[0].buffer_length = sizeof(v.ts); + params[0].buffer = &v.ts; + params[0].length = ¶ms[0].buffer_length; + params[0].is_null = NULL; + + params[1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[1].buffer_length = sizeof(v.b); + params[1].buffer = &v.b; + params[1].length = ¶ms[1].buffer_length; + params[1].is_null = NULL; + + params[2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[2].buffer_length = sizeof(v.v1); + params[2].buffer = &v.v1; + params[2].length = ¶ms[2].buffer_length; + params[2].is_null = NULL; + + params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[3].buffer_length = sizeof(v.v2); + params[3].buffer = &v.v2; + params[3].length = ¶ms[3].buffer_length; + params[3].is_null = NULL; + + params[4].buffer_type = TSDB_DATA_TYPE_INT; + params[4].buffer_length = sizeof(v.v4); + params[4].buffer = &v.v4; + params[4].length = ¶ms[4].buffer_length; + params[4].is_null = NULL; + + params[5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[5].buffer_length = sizeof(v.v8); + params[5].buffer = &v.v8; + params[5].length = ¶ms[5].buffer_length; + params[5].is_null = NULL; + + params[6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[6].buffer_length = sizeof(v.f4); + params[6].buffer = &v.f4; + params[6].length = ¶ms[6].buffer_length; + params[6].is_null = NULL; + + params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[7].buffer_length = sizeof(v.f8); + params[7].buffer = &v.f8; + params[7].length = ¶ms[7].buffer_length; + params[7].is_null = NULL; + + params[8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[8].buffer_length = sizeof(v.bin); + params[8].buffer = v.bin; + params[8].length = ¶ms[8].buffer_length; + params[8].is_null = NULL; + + params[9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[9].buffer_length = sizeof(v.bin); + params[9].buffer = v.bin; + params[9].length = ¶ms[9].buffer_length; + params[9].is_null = NULL; + + int is_null = 1; + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + for (int l = 0; l < 100; l++) { + for (int zz = 0; zz < 10; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + v.ts = 1591060628000 + zz * 100 * l; + for (int i = 0; i < zz; ++i) { + v.ts += 1; + for (int j = 1; j < 10; ++j) { + params[j].is_null = ((i == j) ? &is_null : 0); + } + v.b = (int8_t)(i+zz*10) % 2; + v.v1 = (int8_t)(i+zz*10); + v.v2 = (int16_t)((i+zz*10) * 2); + v.v4 = (int32_t)((i+zz*10) * 4); + v.v8 = (int64_t)((i+zz*10) * 8); + v.f4 = (float)((i+zz*10) * 40); + v.f8 = (double)((i+zz*10) * 80); + for (int j = 0; j < sizeof(v.bin) - 1; ++j) { + v.bin[j] = (char)((i+zz)%10 + '0'); + } + + taos_stmt_bind_param(stmt, params); + taos_stmt_add_batch(stmt); + } + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + } + + + return 0; +} + + + + +int stmt_func3(TAOS_STMT *stmt) { + struct { + int64_t ts; + int8_t b; + int8_t v1; + int16_t v2; + int32_t v4; + int64_t v8; + float f4; + double f8; + char bin[40]; + char blob[80]; + } v = {0}; + + TAOS_BIND params[10]; + params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[0].buffer_length = sizeof(v.ts); + params[0].buffer = &v.ts; + params[0].length = ¶ms[0].buffer_length; + params[0].is_null = NULL; + + params[1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[1].buffer_length = sizeof(v.b); + params[1].buffer = &v.b; + params[1].length = ¶ms[1].buffer_length; + params[1].is_null = NULL; + + params[2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[2].buffer_length = sizeof(v.v1); + params[2].buffer = &v.v1; + params[2].length = ¶ms[2].buffer_length; + params[2].is_null = NULL; + + params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[3].buffer_length = sizeof(v.v2); + params[3].buffer = &v.v2; + params[3].length = ¶ms[3].buffer_length; + params[3].is_null = NULL; + + params[4].buffer_type = TSDB_DATA_TYPE_INT; + params[4].buffer_length = sizeof(v.v4); + params[4].buffer = &v.v4; + params[4].length = ¶ms[4].buffer_length; + params[4].is_null = NULL; + + params[5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[5].buffer_length = sizeof(v.v8); + params[5].buffer = &v.v8; + params[5].length = ¶ms[5].buffer_length; + params[5].is_null = NULL; + + params[6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[6].buffer_length = sizeof(v.f4); + params[6].buffer = &v.f4; + params[6].length = ¶ms[6].buffer_length; + params[6].is_null = NULL; + + params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[7].buffer_length = sizeof(v.f8); + params[7].buffer = &v.f8; + params[7].length = ¶ms[7].buffer_length; + params[7].is_null = NULL; + + params[8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[8].buffer_length = sizeof(v.bin); + params[8].buffer = v.bin; + params[8].length = ¶ms[8].buffer_length; + params[8].is_null = NULL; + + params[9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[9].buffer_length = sizeof(v.bin); + params[9].buffer = v.bin; + params[9].length = ¶ms[9].buffer_length; + params[9].is_null = NULL; + + int is_null = 1; + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + for (int l = 0; l < 100; l++) { + for (int zz = 0; zz < 10; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + v.ts = 1591060628000 + zz * 100 * l; + for (int i = 0; i < zz; ++i) { + v.ts += 1; + for (int j = 1; j < 10; ++j) { + params[j].is_null = ((i == j) ? &is_null : 0); + } + v.b = (int8_t)(i+zz*10) % 2; + v.v1 = (int8_t)(i+zz*10); + v.v2 = (int16_t)((i+zz*10) * 2); + v.v4 = (int32_t)((i+zz*10) * 4); + v.v8 = (int64_t)((i+zz*10) * 8); + v.f4 = (float)((i+zz*10) * 40); + v.f8 = (double)((i+zz*10) * 80); + for (int j = 0; j < sizeof(v.bin) - 1; ++j) { + v.bin[j] = (char)((i+zz)%10 + '0'); + } + + taos_stmt_bind_param(stmt, params); + taos_stmt_add_batch(stmt); + } + } + } + + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + + return 0; +} + + +//300 tables 60 records +int stmt_funcb1(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[60]; + int8_t v1[60]; + int16_t v2[60]; + int32_t v4[60]; + int64_t v8[60]; + float f4[60]; + double f8[60]; + char bin[60][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(60 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10); + char* is_null = malloc(sizeof(char) * 60); + char* no_null = malloc(sizeof(char) * 60); + + for (int i = 0; i < 60; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 9000000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[60*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 60; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 60; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 60; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 60; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 60; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 60; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 60; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 60; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 60; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 60; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 3000; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + +//1table 18000 reocrds +int stmt_funcb2(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[18000]; + int8_t v1[18000]; + int16_t v2[18000]; + int32_t v4[18000]; + int64_t v8[18000]; + float f4[18000]; + double f8[18000]; + char bin[18000][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(18000 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 3000*10); + char* is_null = malloc(sizeof(char) * 18000); + char* no_null = malloc(sizeof(char) * 18000); + + for (int i = 0; i < 18000; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 30000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[18000*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 18000; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 18000; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 18000; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 18000; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 18000; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 18000; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 18000; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 18000; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 18000; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 18000; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 10; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + ++id; + + } + + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + +//disorder +int stmt_funcb3(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[60]; + int8_t v1[60]; + int16_t v2[60]; + int32_t v4[60]; + int64_t v8[60]; + float f4[60]; + double f8[60]; + char bin[60][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(60 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10); + char* is_null = malloc(sizeof(char) * 60); + char* no_null = malloc(sizeof(char) * 60); + + for (int i = 0; i < 60; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 9000000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[60*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 60; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 60; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 60; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 60; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 60; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 60; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 60; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 60; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 60; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 60; + + } + + int64_t tts = 1591060628000; + int64_t ttt = 0; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts + i; + if (i > 0 && i%60 == 0) { + ttt = v.ts[i-1]; + v.ts[i-1] = v.ts[i-60]; + v.ts[i-60] = ttt; + } + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 3000; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + + + +//samets +int stmt_funcb4(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[60]; + int8_t v1[60]; + int16_t v2[60]; + int32_t v4[60]; + int64_t v8[60]; + float f4[60]; + double f8[60]; + char bin[60][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(60 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10); + char* is_null = malloc(sizeof(char) * 60); + char* no_null = malloc(sizeof(char) * 60); + + for (int i = 0; i < 60; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 9000000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[60*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 60; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 60; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 60; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 60; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 60; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 60; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 60; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 60; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 60; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 60; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 3000; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + + + +//1table 18000 reocrds +int stmt_funcb5(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[18000]; + int8_t v1[18000]; + int16_t v2[18000]; + int32_t v4[18000]; + int64_t v8[18000]; + float f4[18000]; + double f8[18000]; + char bin[18000][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(18000 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 3000*10); + char* is_null = malloc(sizeof(char) * 18000); + char* no_null = malloc(sizeof(char) * 18000); + + for (int i = 0; i < 18000; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 30000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[18000*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 18000; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 18000; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 18000; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 18000; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 18000; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 18000; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 18000; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 18000; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 18000; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 18000; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into m0 values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 10; l++) { + for (int zz = 0; zz < 1; zz++) { + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + ++id; + + } + + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + +//1table 200000 reocrds +int stmt_funcb_ssz1(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int b[30000]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 30000 * 3000); + + int *lb = malloc(30000 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 3000*10); + char* no_null = malloc(sizeof(int) * 200000); + + for (int i = 0; i < 30000; ++i) { + lb[i] = 40; + no_null[i] = 0; + v.b[i] = (int8_t)(i % 2); + } + + for (int i = 0; i < 30000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[30000*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 30000; + + params[i+1].buffer_type = TSDB_DATA_TYPE_INT; + params[i+1].buffer_length = sizeof(int); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = no_null; + params[i+1].num = 30000; + } + + int64_t tts = 0; + for (int64_t i = 0; i < 90000000LL; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 10; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + ++id; + + } + + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(no_null); + + return 0; +} + + +//one table 60 records one time +int stmt_funcb_s1(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[60]; + int8_t v1[60]; + int16_t v2[60]; + int32_t v4[60]; + int64_t v8[60]; + float f4[60]; + double f8[60]; + char bin[60][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(60 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10); + char* is_null = malloc(sizeof(char) * 60); + char* no_null = malloc(sizeof(char) * 60); + + for (int i = 0; i < 60; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 9000000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[60*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 60; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 60; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 60; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 60; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 60; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 60; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 60; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 60; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 60; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 60; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 3000; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + taos_stmt_bind_param_batch(stmt, params + id * 10); + taos_stmt_add_batch(stmt); + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + ++id; + } + + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + + + + + +//300 tables 60 records single column bind +int stmt_funcb_sc1(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[60]; + int8_t v1[60]; + int16_t v2[60]; + int32_t v4[60]; + int64_t v8[60]; + float f4[60]; + double f8[60]; + char bin[60][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(60 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10); + char* is_null = malloc(sizeof(char) * 60); + char* no_null = malloc(sizeof(char) * 60); + + for (int i = 0; i < 60; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 9000000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[60*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 60; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 60; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 60; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 60; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 60; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 60; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 60; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 60; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 60; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 60; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 3000; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + for (int col=0; col < 10; ++col) { + taos_stmt_bind_single_param_batch(stmt, params + id++, col); + } + + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + +//1 tables 60 records single column bind +int stmt_funcb_sc2(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[60]; + int8_t v1[60]; + int16_t v2[60]; + int32_t v4[60]; + int64_t v8[60]; + float f4[60]; + double f8[60]; + char bin[60][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 900000 * 60); + + int *lb = malloc(60 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10); + char* is_null = malloc(sizeof(char) * 60); + char* no_null = malloc(sizeof(char) * 60); + + for (int i = 0; i < 60; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + for (int i = 0; i < 9000000; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[60*i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = 60; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = 60; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = 60; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = 60; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = 60; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = 60; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = 60; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = 60; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = 60; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = 60; + + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 54000000; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int l = 0; l < 3000; l++) { + for (int zz = 0; zz < 300; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + for (int col=0; col < 10; ++col) { + taos_stmt_bind_single_param_batch(stmt, params + id++, col); + } + + taos_stmt_add_batch(stmt); + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + } + + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + +//10 tables [1...10] records single column bind +int stmt_funcb_sc3(TAOS_STMT *stmt) { + struct { + int64_t *ts; + int8_t b[60]; + int8_t v1[60]; + int16_t v2[60]; + int32_t v4[60]; + int64_t v8[60]; + float f4[60]; + double f8[60]; + char bin[60][40]; + } v = {0}; + + v.ts = malloc(sizeof(int64_t) * 60); + + int *lb = malloc(60 * sizeof(int)); + + TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * 60*10); + char* is_null = malloc(sizeof(char) * 60); + char* no_null = malloc(sizeof(char) * 60); + + for (int i = 0; i < 60; ++i) { + lb[i] = 40; + no_null[i] = 0; + is_null[i] = (i % 10 == 2) ? 1 : 0; + v.b[i] = (int8_t)(i % 2); + v.v1[i] = (int8_t)((i+1) % 2); + v.v2[i] = (int16_t)i; + v.v4[i] = (int32_t)(i+1); + v.v8[i] = (int64_t)(i+2); + v.f4[i] = (float)(i+3); + v.f8[i] = (double)(i+4); + memset(v.bin[i], '0'+i%10, 40); + } + + int g = 0; + for (int i = 0; i < 600; i+=10) { + params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[i+0].buffer_length = sizeof(int64_t); + params[i+0].buffer = &v.ts[i/10]; + params[i+0].length = NULL; + params[i+0].is_null = no_null; + params[i+0].num = g%10+1; + + params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL; + params[i+1].buffer_length = sizeof(int8_t); + params[i+1].buffer = v.b; + params[i+1].length = NULL; + params[i+1].is_null = is_null; + params[i+1].num = g%10+1; + + params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT; + params[i+2].buffer_length = sizeof(int8_t); + params[i+2].buffer = v.v1; + params[i+2].length = NULL; + params[i+2].is_null = is_null; + params[i+2].num = g%10+1; + + params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT; + params[i+3].buffer_length = sizeof(int16_t); + params[i+3].buffer = v.v2; + params[i+3].length = NULL; + params[i+3].is_null = is_null; + params[i+3].num = g%10+1; + + params[i+4].buffer_type = TSDB_DATA_TYPE_INT; + params[i+4].buffer_length = sizeof(int32_t); + params[i+4].buffer = v.v4; + params[i+4].length = NULL; + params[i+4].is_null = is_null; + params[i+4].num = g%10+1; + + params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT; + params[i+5].buffer_length = sizeof(int64_t); + params[i+5].buffer = v.v8; + params[i+5].length = NULL; + params[i+5].is_null = is_null; + params[i+5].num = g%10+1; + + params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[i+6].buffer_length = sizeof(float); + params[i+6].buffer = v.f4; + params[i+6].length = NULL; + params[i+6].is_null = is_null; + params[i+6].num = g%10+1; + + params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE; + params[i+7].buffer_length = sizeof(double); + params[i+7].buffer = v.f8; + params[i+7].length = NULL; + params[i+7].is_null = is_null; + params[i+7].num = g%10+1; + + params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+8].buffer_length = 40; + params[i+8].buffer = v.bin; + params[i+8].length = lb; + params[i+8].is_null = is_null; + params[i+8].num = g%10+1; + + params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY; + params[i+9].buffer_length = 40; + params[i+9].buffer = v.bin; + params[i+9].length = lb; + params[i+9].is_null = is_null; + params[i+9].num = g%10+1; + ++g; + } + + int64_t tts = 1591060628000; + for (int i = 0; i < 60; ++i) { + v.ts[i] = tts + i; + } + + unsigned long long starttime = getCurrentTime(); + + char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + if (code != 0){ + printf("failed to execute taos_stmt_prepare. code:0x%x\n", code); + } + + int id = 0; + for (int zz = 0; zz < 10; zz++) { + char buf[32]; + sprintf(buf, "m%d", zz); + code = taos_stmt_set_tbname(stmt, buf); + if (code != 0){ + printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code); + } + + for (int col=0; col < 10; ++col) { + taos_stmt_bind_single_param_batch(stmt, params + id++, col); + } + + taos_stmt_add_batch(stmt); + } + + if (taos_stmt_execute(stmt) != 0) { + printf("failed to execute insert statement.\n"); + exit(1); + } + + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60)); + + free(v.ts); + free(lb); + free(params); + free(is_null); + free(no_null); + + return 0; +} + + +void check_result(TAOS *taos, char *tname, int printr, int expected) { + char sql[255] = "SELECT * FROM "; + TAOS_RES *result; + + strcat(sql, tname); + + result = taos_query(taos, sql); + int code = taos_errno(result); + if (code != 0) { + printf("failed to query table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + + + TAOS_ROW row; + int rows = 0; + int num_fields = taos_num_fields(result); + TAOS_FIELD *fields = taos_fetch_fields(result); + char temp[256]; + + // fetch the records row by row + while ((row = taos_fetch_row(result))) { + rows++; + if (printr) { + memset(temp, 0, sizeof(temp)); + taos_print_row(temp, row, fields, num_fields); + printf("[%s]\n", temp); + } + } + + if (rows == expected) { + printf("%d rows are fetched as expectation\n", rows); + } else { + printf("!!!expect %d rows, but %d rows are fetched\n", expected, rows); + exit(1); + } + + taos_free_result(result); + +} + + + +//120table 60 record each table +int sql_perf1(TAOS *taos) { + char *sql[3000] = {0}; + TAOS_RES *result; + + for (int i = 0; i < 3000; i++) { + sql[i] = calloc(1, 1048576); + } + + int len = 0; + int tss = 0; + for (int l = 0; l < 3000; ++l) { + len = sprintf(sql[l], "insert into "); + for (int t = 0; t < 120; ++t) { + len += sprintf(sql[l] + len, "m%d values ", t); + for (int m = 0; m < 60; ++m) { + len += sprintf(sql[l] + len, "(%d, %d, %d, %d, %d, %d, %f, %f, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") ", tss++, m, m, m, m, m, m+1.0, m+1.0); + } + } + } + + + unsigned long long starttime = getCurrentTime(); + for (int i = 0; i < 3000; ++i) { + result = taos_query(taos, sql[i]); + int code = taos_errno(result); + if (code != 0) { + printf("failed to query table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + + taos_free_result(result); + } + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%.1f useconds\n", 3000*120*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*120*60)); + + for (int i = 0; i < 3000; i++) { + free(sql[i]); + } + + return 0; +} + + + + + +//one table 60 records one time +int sql_perf_s1(TAOS *taos) { + char **sql = calloc(1, sizeof(char*) * 360000); + TAOS_RES *result; + + for (int i = 0; i < 360000; i++) { + sql[i] = calloc(1, 9000); + } + + int len = 0; + int tss = 0; + int id = 0; + for (int t = 0; t < 120; ++t) { + for (int l = 0; l < 3000; ++l) { + len = sprintf(sql[id], "insert into m%d values ", t); + for (int m = 0; m < 60; ++m) { + len += sprintf(sql[id] + len, "(%d, %d, %d, %d, %d, %d, %f, %f, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") ", tss++, m, m, m, m, m, m+1.0, m+1.0); + } + if (len >= 9000) { + printf("sql:%s,len:%d\n", sql[id], len); + exit(1); + } + ++id; + } + } + + + unsigned long long starttime = getCurrentTime(); + for (int i = 0; i < 360000; ++i) { + result = taos_query(taos, sql[i]); + int code = taos_errno(result); + if (code != 0) { + printf("failed to query table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + + taos_free_result(result); + } + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%.1f useconds\n", 3000*120*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*120*60)); + + for (int i = 0; i < 360000; i++) { + free(sql[i]); + } + + free(sql); + + return 0; +} + + +//small record size +int sql_s_perf1(TAOS *taos) { + char *sql[3000] = {0}; + TAOS_RES *result; + + for (int i = 0; i < 3000; i++) { + sql[i] = calloc(1, 1048576); + } + + int len = 0; + int tss = 0; + for (int l = 0; l < 3000; ++l) { + len = sprintf(sql[l], "insert into "); + for (int t = 0; t < 120; ++t) { + len += sprintf(sql[l] + len, "m%d values ", t); + for (int m = 0; m < 60; ++m) { + len += sprintf(sql[l] + len, "(%d, %d) ", tss++, m%2); + } + } + } + + + unsigned long long starttime = getCurrentTime(); + for (int i = 0; i < 3000; ++i) { + result = taos_query(taos, sql[i]); + int code = taos_errno(result); + if (code != 0) { + printf("failed to query table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + + taos_free_result(result); + } + unsigned long long endtime = getCurrentTime(); + printf("insert total %d records, used %u seconds, avg:%.1f useconds\n", 3000*120*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*120*60)); + + for (int i = 0; i < 3000; i++) { + free(sql[i]); + } + + return 0; +} + + +void prepare(TAOS *taos, int bigsize) { + TAOS_RES *result; + int code; + + result = taos_query(taos, "drop database demo"); + taos_free_result(result); + + result = taos_query(taos, "create database demo"); + code = taos_errno(result); + if (code != 0) { + printf("failed to create database, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + taos_free_result(result); + + result = taos_query(taos, "use demo"); + taos_free_result(result); + + // create table + for (int i = 0 ; i < 300; i++) { + char buf[1024]; + if (bigsize) { + sprintf(buf, "create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), bin2 binary(40))", i) ; + } else { + sprintf(buf, "create table m%d (ts timestamp, b int)", i) ; + } + result = taos_query(taos, buf); + code = taos_errno(result); + if (code != 0) { + printf("failed to create table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + taos_free_result(result); + } + +} + + + +void preparem(TAOS *taos, int bigsize, int idx) { + TAOS_RES *result; + int code; + char dbname[32],sql[255]; + + sprintf(dbname, "demo%d", idx); + sprintf(sql, "drop database %s", dbname); + + + result = taos_query(taos, sql); + taos_free_result(result); + + sprintf(sql, "create database %s", dbname); + result = taos_query(taos, sql); + code = taos_errno(result); + if (code != 0) { + printf("failed to create database, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + taos_free_result(result); + + sprintf(sql, "use %s", dbname); + result = taos_query(taos, sql); + taos_free_result(result); + + // create table + for (int i = 0 ; i < 300; i++) { + char buf[1024]; + if (bigsize) { + sprintf(buf, "create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), bin2 binary(40))", i) ; + } else { + sprintf(buf, "create table m%d (ts timestamp, b int)", i) ; + } + result = taos_query(taos, buf); + code = taos_errno(result); + if (code != 0) { + printf("failed to create table, reason:%s\n", taos_errstr(result)); + taos_free_result(result); + exit(1); + } + taos_free_result(result); + } + +} + + + +//void runcase(TAOS *taos, int idx) { +void* runcase(void *par) { + T_par* tpar = (T_par *)par; + TAOS *taos = tpar->taos; + int idx = tpar->idx; + + TAOS_STMT *stmt; + + (void)idx; + + +#if 1 + prepare(taos, 1); + + stmt = taos_stmt_init(taos); + + printf("10t+10records start\n"); + stmt_func1(stmt); + printf("10t+10records end\n"); + printf("check result start\n"); + check_result(taos, "m0", 1, 10); + check_result(taos, "m1", 1, 10); + check_result(taos, "m2", 1, 10); + check_result(taos, "m3", 1, 10); + check_result(taos, "m4", 1, 10); + check_result(taos, "m5", 1, 10); + check_result(taos, "m6", 1, 10); + check_result(taos, "m7", 1, 10); + check_result(taos, "m8", 1, 10); + check_result(taos, "m9", 1, 10); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1); + + stmt = taos_stmt_init(taos); + + printf("10t+[0,1,2...9]records start\n"); + stmt_func2(stmt); + printf("10t+[0,1,2...9]records end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 0); + check_result(taos, "m1", 0, 100); + check_result(taos, "m2", 0, 200); + check_result(taos, "m3", 0, 300); + check_result(taos, "m4", 0, 400); + check_result(taos, "m5", 0, 500); + check_result(taos, "m6", 0, 600); + check_result(taos, "m7", 0, 700); + check_result(taos, "m8", 0, 800); + check_result(taos, "m9", 0, 900); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1); + + stmt = taos_stmt_init(taos); + + printf("10t+[0,100,200...900]records start\n"); + stmt_func3(stmt); + printf("10t+[0,100,200...900]records end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 0); + check_result(taos, "m1", 0, 100); + check_result(taos, "m2", 0, 200); + check_result(taos, "m3", 0, 300); + check_result(taos, "m4", 0, 400); + check_result(taos, "m5", 0, 500); + check_result(taos, "m6", 0, 600); + check_result(taos, "m7", 0, 700); + check_result(taos, "m8", 0, 800); + check_result(taos, "m9", 0, 900); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + +#if 1 + prepare(taos, 1); + + stmt = taos_stmt_init(taos); + + printf("300t+60r+bm start\n"); + stmt_funcb1(stmt); + printf("300t+60r+bm end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + check_result(taos, "m1", 0, 180000); + check_result(taos, "m111", 0, 180000); + check_result(taos, "m223", 0, 180000); + check_result(taos, "m299", 0, 180000); + printf("check result end\n"); + taos_stmt_close(stmt); +#endif + + +#if 1 + prepare(taos, 1); + + stmt = taos_stmt_init(taos); + + printf("1t+18000r+bm start\n"); + stmt_funcb2(stmt); + printf("1t+18000r+bm end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + check_result(taos, "m1", 0, 180000); + check_result(taos, "m111", 0, 180000); + check_result(taos, "m223", 0, 180000); + check_result(taos, "m299", 0, 180000); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1); + + stmt = taos_stmt_init(taos); + + printf("300t+60r+disorder+bm start\n"); + stmt_funcb3(stmt); + printf("300t+60r+disorder+bm end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + check_result(taos, "m1", 0, 180000); + check_result(taos, "m111", 0, 180000); + check_result(taos, "m223", 0, 180000); + check_result(taos, "m299", 0, 180000); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + +#if 1 + prepare(taos, 1); + + stmt = taos_stmt_init(taos); + + printf("300t+60r+samets+bm start\n"); + stmt_funcb4(stmt); + printf("300t+60r+samets+bm end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 1); + check_result(taos, "m1", 0, 1); + check_result(taos, "m111", 0, 1); + check_result(taos, "m223", 0, 1); + check_result(taos, "m299", 0, 1); + printf("check result end\n"); + taos_stmt_close(stmt); +#endif + +#if 1 + prepare(taos, 1); + + stmt = taos_stmt_init(taos); + + printf("1t+18000r+nodyntable+bm start\n"); + stmt_funcb5(stmt); + printf("1t+18000r+nodyntable+bm end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + +#if 1 + prepare(taos, 1); + + stmt = taos_stmt_init(taos); + + printf("300t+60r+bm+sc start\n"); + stmt_funcb_sc1(stmt); + printf("300t+60r+bm+sc end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + check_result(taos, "m1", 0, 180000); + check_result(taos, "m111", 0, 180000); + check_result(taos, "m223", 0, 180000); + check_result(taos, "m299", 0, 180000); + printf("check result end\n"); + taos_stmt_close(stmt); +#endif + +#if 1 + prepare(taos, 1); + + stmt = taos_stmt_init(taos); + + printf("1t+60r+bm+sc start\n"); + stmt_funcb_sc2(stmt); + printf("1t+60r+bm+sc end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + check_result(taos, "m1", 0, 180000); + check_result(taos, "m111", 0, 180000); + check_result(taos, "m223", 0, 180000); + check_result(taos, "m299", 0, 180000); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + +#if 1 + prepare(taos, 1); + + stmt = taos_stmt_init(taos); + + printf("10t+[1...10]r+bm+sc start\n"); + stmt_funcb_sc3(stmt); + printf("10t+[1...10]r+bm+sc end\n"); + printf("check result start\n"); + check_result(taos, "m0", 1, 1); + check_result(taos, "m1", 1, 2); + check_result(taos, "m2", 1, 3); + check_result(taos, "m3", 1, 4); + check_result(taos, "m4", 1, 5); + check_result(taos, "m5", 1, 6); + check_result(taos, "m6", 1, 7); + check_result(taos, "m7", 1, 8); + check_result(taos, "m8", 1, 9); + check_result(taos, "m9", 1, 10); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + +#if 1 + prepare(taos, 1); + + stmt = taos_stmt_init(taos); + + printf("1t+60r+bm start\n"); + stmt_funcb_s1(stmt); + printf("1t+60r+bm end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + check_result(taos, "m1", 0, 180000); + check_result(taos, "m111", 0, 180000); + check_result(taos, "m223", 0, 180000); + check_result(taos, "m299", 0, 180000); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + +#if 1 + prepare(taos, 1); + + (void)stmt; + printf("120t+60r+sql start\n"); + sql_perf1(taos); + printf("120t+60r+sql end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + check_result(taos, "m1", 0, 180000); + check_result(taos, "m34", 0, 180000); + check_result(taos, "m67", 0, 180000); + check_result(taos, "m99", 0, 180000); + printf("check result end\n"); +#endif + +#if 1 + prepare(taos, 1); + + (void)stmt; + printf("1t+60r+sql start\n"); + sql_perf_s1(taos); + printf("1t+60r+sql end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 180000); + check_result(taos, "m1", 0, 180000); + check_result(taos, "m34", 0, 180000); + check_result(taos, "m67", 0, 180000); + check_result(taos, "m99", 0, 180000); + printf("check result end\n"); +#endif + + +#if 1 + preparem(taos, 0, idx); + + stmt = taos_stmt_init(taos); + + printf("1t+30000r+bm start\n"); + stmt_funcb_ssz1(stmt); + printf("1t+30000r+bm end\n"); + printf("check result start\n"); + check_result(taos, "m0", 0, 300000); + check_result(taos, "m1", 0, 300000); + check_result(taos, "m111", 0, 300000); + check_result(taos, "m223", 0, 300000); + check_result(taos, "m299", 0, 300000); + printf("check result end\n"); + taos_stmt_close(stmt); + +#endif + + return NULL; + +} + +int main(int argc, char *argv[]) +{ + TAOS *taos[4]; + + // connect to server + if (argc < 2) { + printf("please input server ip \n"); + return 0; + } + + taos[0] = taos_connect(argv[1], "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("failed to connect to db, reason:%s\n", taos_errstr(taos)); + exit(1); + } + + taos[1] = taos_connect(argv[1], "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("failed to connect to db, reason:%s\n", taos_errstr(taos)); + exit(1); + } + + taos[2] = taos_connect(argv[1], "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("failed to connect to db, reason:%s\n", taos_errstr(taos)); + exit(1); + } + + taos[3] = taos_connect(argv[1], "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("failed to connect to db, reason:%s\n", taos_errstr(taos)); + exit(1); + } + + pthread_t *pThreadList = (pthread_t *) calloc(sizeof(pthread_t), 4); + + pthread_attr_t thattr; + pthread_attr_init(&thattr); + pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); + T_par par[4]; + + par[0].taos = taos[0]; + par[0].idx = 0; + par[1].taos = taos[1]; + par[1].idx = 1; + par[2].taos = taos[2]; + par[2].idx = 2; + par[3].taos = taos[3]; + par[3].idx = 3; + + pthread_create(&(pThreadList[0]), &thattr, runcase, (void *)&par[0]); + //pthread_create(&(pThreadList[1]), &thattr, runcase, (void *)&par[1]); + //pthread_create(&(pThreadList[2]), &thattr, runcase, (void *)&par[2]); + //pthread_create(&(pThreadList[3]), &thattr, runcase, (void *)&par[3]); + + while(1) { + sleep(1); + } + return 0; +} + diff --git a/tests/script/api/makefile b/tests/script/api/makefile new file mode 100644 index 0000000000000000000000000000000000000000..c5bbde0f0be02a4c423eccee3fb3476981e9ac59 --- /dev/null +++ b/tests/script/api/makefile @@ -0,0 +1,17 @@ +# Copyright (c) 2017 by TAOS Technologies, Inc. +# todo: library dependency, header file dependency + +ROOT=./ +TARGET=exe +LFLAGS = '-Wl,-rpath,/usr/local/taos/driver/' -ltaos -lpthread -lm -lrt +CFLAGS = -O0 -g -Wall -Wno-deprecated -fPIC -Wno-unused-result -Wconversion \ + -Wno-char-subscripts -D_REENTRANT -Wno-format -D_REENTRANT -DLINUX \ + -Wno-unused-function -D_M_X64 -I/usr/local/taos/include -std=gnu99 + +all: $(TARGET) + +exe: + gcc $(CFLAGS) ./batchprepare.c -o $(ROOT)batchprepare $(LFLAGS) + +clean: + rm $(ROOT)batchprepare