diff --git a/Jenkinsfile b/Jenkinsfile
index eb4b56ad21..dc7836c3da 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -27,6 +27,7 @@ pipeline {
cd debug
cmake .. > /dev/null
make > /dev/null
+ make install > /dev/null
cd ${WKC}/tests
#./test-all.sh smoke
./test-all.sh pytest
diff --git a/packaging/deb/makedeb.sh b/packaging/deb/makedeb.sh
index a7bb22f345..edc7de9692 100755
--- a/packaging/deb/makedeb.sh
+++ b/packaging/deb/makedeb.sh
@@ -48,6 +48,7 @@ cp ${compile_dir}/../packaging/deb/taosd ${pkg_dir}${install_home_pat
cp ${compile_dir}/../packaging/tools/post.sh ${pkg_dir}${install_home_path}/script
cp ${compile_dir}/../packaging/tools/preun.sh ${pkg_dir}${install_home_path}/script
cp ${compile_dir}/build/bin/taosdemo ${pkg_dir}${install_home_path}/bin
+cp ${compile_dir}/build/bin/taosdump ${pkg_dir}${install_home_path}/bin
cp ${compile_dir}/build/bin/taosd ${pkg_dir}${install_home_path}/bin
cp ${compile_dir}/build/bin/taos ${pkg_dir}${install_home_path}/bin
cp ${compile_dir}/build/lib/${libfile} ${pkg_dir}${install_home_path}/driver
diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec
index 54c3c9b279..afec1eaf9a 100644
--- a/packaging/rpm/tdengine.spec
+++ b/packaging/rpm/tdengine.spec
@@ -58,6 +58,7 @@ cp %{_compiledir}/../packaging/tools/preun.sh %{buildroot}%{homepath}/scri
cp %{_compiledir}/build/bin/taos %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/bin/taosd %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/bin/taosdemo %{buildroot}%{homepath}/bin
+cp %{_compiledir}/build/bin/taosdump %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver
cp %{_compiledir}/../src/inc/taos.h %{buildroot}%{homepath}/include
cp %{_compiledir}/../src/inc/taoserror.h %{buildroot}%{homepath}/include
@@ -134,6 +135,7 @@ if [ $1 -eq 0 ];then
${csudo} rm -f ${bin_link_dir}/taos || :
${csudo} rm -f ${bin_link_dir}/taosd || :
${csudo} rm -f ${bin_link_dir}/taosdemo || :
+ ${csudo} rm -f ${bin_link_dir}/taosdump || :
${csudo} rm -f ${cfg_link_dir}/* || :
${csudo} rm -f ${inc_link_dir}/taos.h || :
${csudo} rm -f ${inc_link_dir}/taoserror.h || :
diff --git a/packaging/tools/makeclient.sh b/packaging/tools/makeclient.sh
index 69fa53c087..83a9cb1ced 100755
--- a/packaging/tools/makeclient.sh
+++ b/packaging/tools/makeclient.sh
@@ -45,7 +45,7 @@ if [ "$osType" != "Darwin" ]; then
strip ${build_dir}/bin/taos
bin_files="${build_dir}/bin/taos ${script_dir}/remove_client.sh"
else
- bin_files="${build_dir}/bin/taos ${build_dir}/bin/taosdemo ${script_dir}/remove_client.sh ${script_dir}/set_core.sh"
+ bin_files="${build_dir}/bin/taos ${build_dir}/bin/taosdump ${build_dir}/bin/taosdemo ${script_dir}/remove_client.sh ${script_dir}/set_core.sh"
fi
lib_files="${build_dir}/lib/libtaos.so.${version}"
else
diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh
index a6d868ed1d..00a92cb063 100755
--- a/packaging/tools/makepkg.sh
+++ b/packaging/tools/makepkg.sh
@@ -36,7 +36,7 @@ if [ "$pagMode" == "lite" ]; then
strip ${build_dir}/bin/taos
bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${script_dir}/remove.sh"
else
- bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdemo ${build_dir}/bin/tarbitrator ${script_dir}/remove.sh ${script_dir}/set_core.sh"
+ bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdump ${build_dir}/bin/taosdemo ${build_dir}/bin/tarbitrator ${script_dir}/remove.sh ${script_dir}/set_core.sh"
fi
lib_files="${build_dir}/lib/libtaos.so.${version}"
diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c
index e70cd11fbe..99c03c6580 100644
--- a/src/client/src/tscAsync.c
+++ b/src/client/src/tscAsync.c
@@ -428,6 +428,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
} else {
assert(code == TSDB_CODE_SUCCESS);
}
+
// param already freed by other routine and pSql in tscCache when ctrl + c
if (atomic_load_ptr(&pSql->param) == NULL) {
return;
@@ -441,6 +442,20 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
assert(pParObj->signature == pParObj && trs->subqueryIndex == pTableMetaInfo->vgroupIndex &&
pTableMetaInfo->vgroupIndex >= 0 && pTableMetaInfo->vgroupList != NULL);
+ // tscProcessSql can add error into async res
+ tscProcessSql(pSql);
+ return;
+ } else if (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY)) {
+ tscDebug("%p update table meta in local cache, continue to process sql and send corresponding tid_tag query", pSql);
+ STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
+ code = tscGetTableMeta(pSql, pTableMetaInfo);
+ if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
+ return;
+ } else {
+ assert(code == TSDB_CODE_SUCCESS);
+ }
+
+ assert((tscGetNumOfTags(pTableMetaInfo->pTableMeta) != 0));
// tscProcessSql can add error into async res
tscProcessSql(pSql);
return;
@@ -465,7 +480,6 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
tscResetSqlCmdObj(pCmd, false);
code = tsParseSql(pSql, true);
-
if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
return;
} else if (code != TSDB_CODE_SUCCESS) {
diff --git a/src/client/src/tscLocalMerge.c b/src/client/src/tscLocalMerge.c
index c67edf5b5a..f49c4da0cb 100644
--- a/src/client/src/tscLocalMerge.c
+++ b/src/client/src/tscLocalMerge.c
@@ -97,6 +97,9 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalReducer *pReducer, tOrderDesc
pCtx->param[2].i64Key = pQueryInfo->order.order;
pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT;
pCtx->param[1].i64Key = pQueryInfo->order.orderColId;
+ } else if (functionId == TSDB_FUNC_APERCT) {
+ pCtx->param[0].i64Key = pExpr->param[0].i64Key;
+ pCtx->param[0].nType = pExpr->param[0].nType;
}
pCtx->interBufBytes = pExpr->interBytes;
diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c
index 5e65126ef6..f960beb5d9 100644
--- a/src/client/src/tscParseInsert.c
+++ b/src/client/src/tscParseInsert.c
@@ -1309,7 +1309,7 @@ int tsParseSql(SSqlObj *pSql, bool initial) {
if ((!pCmd->parseFinished) && (!initial)) {
tscDebug("%p resume to parse sql: %s", pSql, pCmd->curSql);
}
-
+
ret = tscAllocPayload(&pSql->cmd, TSDB_DEFAULT_PAYLOAD_SIZE);
if (TSDB_CODE_SUCCESS != ret) {
return ret;
diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c
index f497263f2a..029e1fdb5a 100644
--- a/src/client/src/tscSQLParser.c
+++ b/src/client/src/tscSQLParser.c
@@ -5311,6 +5311,7 @@ static void setCreateDBOption(SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) {
pMsg->replications = pCreateDb->replica;
pMsg->quorum = pCreateDb->quorum;
pMsg->ignoreExist = pCreateDb->ignoreExists;
+ pMsg->update = pCreateDb->update;
}
int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDBInfo* pCreateDbSql) {
diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c
index 9905de279e..b3d151ba27 100644
--- a/src/client/src/tscSubquery.c
+++ b/src/client/src/tscSubquery.c
@@ -523,7 +523,7 @@ static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSupporter* pSupporter) {
assert(pSqlObj->subState.numOfRemain > 0);
if (atomic_sub_fetch_32(&pSqlObj->subState.numOfRemain, 1) <= 0) {
- tscError("%p all subquery return and query failed, global code:%d", pSqlObj, pSqlObj->res.code);
+ tscError("%p all subquery return and query failed, global code:%s", pSqlObj, tstrerror(pSqlObj->res.code));
freeJoinSubqueryObj(pSqlObj);
}
}
@@ -565,7 +565,7 @@ int32_t tagValCompar(const void* p1, const void* p2) {
return (tag1->len > tag2->len)? 1: -1;
}
- return strncmp(tag1->data, tag2->data, tag1->len);
+ return memcmp(tag1->data, tag2->data, tag1->len);
}
void tscBuildVgroupTableInfo(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo, SArray* tables) {
@@ -853,11 +853,15 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
}
if (taosArrayGetSize(s1) == 0 || taosArrayGetSize(s2) == 0) { // no results,return.
+ assert(pParentSql->fp != tscJoinQueryCallback);
+
tscDebug("%p tag intersect does not generated qualified tables for join, free all sub SqlObj and quit", pParentSql);
freeJoinSubqueryObj(pParentSql);
// set no result command
pParentSql->cmd.command = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
+ assert(pParentSql->fp != tscJoinQueryCallback);
+
(*pParentSql->fp)(pParentSql->param, pParentSql, 0);
} else {
// proceed to for ts_comp query
diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h
index cc4afeb3f8..43968a6108 100644
--- a/src/common/inc/tdataformat.h
+++ b/src/common/inc/tdataformat.h
@@ -119,6 +119,33 @@ void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version);
int tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int16_t colId, int16_t bytes);
STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder);
+// ----------------- Semantic timestamp key definition
+typedef uint64_t TKEY;
+
+#define TKEY_INVALID UINT64_MAX
+#define TKEY_NULL TKEY_INVALID
+#define TKEY_NEGATIVE_FLAG (((TKEY)1) << 63)
+#define TKEY_DELETE_FLAG (((TKEY)1) << 62)
+#define TKEY_VALUE_FILTER (~(TKEY_NEGATIVE_FLAG | TKEY_DELETE_FLAG))
+
+#define TKEY_IS_NEGATIVE(tkey) (((tkey)&TKEY_NEGATIVE_FLAG) != 0)
+#define TKEY_IS_DELETED(tkey) (((tkey)&TKEY_DELETE_FLAG) != 0)
+#define tdSetTKEYDeleted(tkey) ((tkey) | TKEY_DELETE_FLAG)
+#define tdGetTKEY(key) (((TKEY)ABS(key)) | (TKEY_NEGATIVE_FLAG & (TKEY)(key)))
+#define tdGetKey(tkey) (((TSKEY)((tkey)&TKEY_VALUE_FILTER)) * (TKEY_IS_NEGATIVE(tkey) ? -1 : 1))
+
+static FORCE_INLINE int tkeyComparFn(const void *tkey1, const void *tkey2) {
+ TSKEY key1 = tdGetKey(*(TKEY *)tkey1);
+ TSKEY key2 = tdGetKey(*(TKEY *)tkey2);
+
+ if (key1 < key2) {
+ return -1;
+ } else if (key1 > key2) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
// ----------------- Data row structure
/* A data row, the format is like below:
@@ -129,6 +156,8 @@ STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder);
* +----------+----------+---------------------------------+---------------------------------+
* | len | sversion | First part | Second part |
* +----------+----------+---------------------------------+---------------------------------+
+ *
+ * NOTE: timestamp in this row structure is TKEY instead of TSKEY
*/
typedef void *SDataRow;
@@ -137,11 +166,13 @@ typedef void *SDataRow;
#define dataRowLen(r) (*(uint16_t *)(r))
#define dataRowVersion(r) *(int16_t *)POINTER_SHIFT(r, sizeof(int16_t))
#define dataRowTuple(r) POINTER_SHIFT(r, TD_DATA_ROW_HEAD_SIZE)
-#define dataRowKey(r) (*(TSKEY *)(dataRowTuple(r)))
+#define dataRowTKey(r) (*(TKEY *)(dataRowTuple(r)))
+#define dataRowKey(r) tdGetKey(dataRowTKey(r))
#define dataRowSetLen(r, l) (dataRowLen(r) = (l))
#define dataRowSetVersion(r, v) (dataRowVersion(r) = (v))
#define dataRowCpy(dst, r) memcpy((dst), (r), dataRowLen(r))
#define dataRowMaxBytesFromSchema(s) (schemaTLen(s) + TD_DATA_ROW_HEAD_SIZE)
+#define dataRowDeleted(r) TKEY_IS_DELETED(dataRowTKey(r))
SDataRow tdNewDataRowFromSchema(STSchema *pSchema);
void tdFreeDataRow(SDataRow row);
@@ -154,16 +185,18 @@ static FORCE_INLINE int tdAppendColVal(SDataRow row, void *value, int8_t type, i
int32_t toffset = offset + TD_DATA_ROW_HEAD_SIZE;
char * ptr = (char *)POINTER_SHIFT(row, dataRowLen(row));
- switch (type) {
- case TSDB_DATA_TYPE_BINARY:
- case TSDB_DATA_TYPE_NCHAR:
- *(VarDataOffsetT *)POINTER_SHIFT(row, toffset) = dataRowLen(row);
- memcpy(ptr, value, varDataTLen(value));
- dataRowLen(row) += varDataTLen(value);
- break;
- default:
+ if (IS_VAR_DATA_TYPE(type)) {
+ *(VarDataOffsetT *)POINTER_SHIFT(row, toffset) = dataRowLen(row);
+ memcpy(ptr, value, varDataTLen(value));
+ dataRowLen(row) += varDataTLen(value);
+ } else {
+ if (offset == 0) {
+ ASSERT(type == TSDB_DATA_TYPE_TIMESTAMP);
+ TKEY tvalue = tdGetTKEY(*(TSKEY *)value);
+ memcpy(POINTER_SHIFT(row, toffset), (void *)(&tvalue), TYPE_BYTES[type]);
+ } else {
memcpy(POINTER_SHIFT(row, toffset), value, TYPE_BYTES[type]);
- break;
+ }
}
return 0;
@@ -171,12 +204,10 @@ static FORCE_INLINE int tdAppendColVal(SDataRow row, void *value, int8_t type, i
// NOTE: offset here including the header size
static FORCE_INLINE void *tdGetRowDataOfCol(SDataRow row, int8_t type, int32_t offset) {
- switch (type) {
- case TSDB_DATA_TYPE_BINARY:
- case TSDB_DATA_TYPE_NCHAR:
- return POINTER_SHIFT(row, *(VarDataOffsetT *)POINTER_SHIFT(row, offset));
- default:
- return POINTER_SHIFT(row, offset);
+ if (IS_VAR_DATA_TYPE(type)) {
+ return POINTER_SHIFT(row, *(VarDataOffsetT *)POINTER_SHIFT(row, offset));
+ } else {
+ return POINTER_SHIFT(row, offset);
}
}
@@ -196,7 +227,6 @@ static FORCE_INLINE void dataColReset(SDataCol *pDataCol) { pDataCol->len = 0; }
void dataColInit(SDataCol *pDataCol, STColumn *pCol, void **pBuf, int maxPoints);
void dataColAppendVal(SDataCol *pCol, void *value, int numOfRows, int maxPoints);
-void dataColPopPoints(SDataCol *pCol, int pointsToPop, int numOfRows);
void dataColSetOffset(SDataCol *pCol, int nEle);
bool isNEleNull(SDataCol *pCol, int nEle);
@@ -204,28 +234,20 @@ void dataColSetNEleNull(SDataCol *pCol, int nEle, int maxPoints);
// Get the data pointer from a column-wised data
static FORCE_INLINE void *tdGetColDataOfRow(SDataCol *pCol, int row) {
- switch (pCol->type) {
- case TSDB_DATA_TYPE_BINARY:
- case TSDB_DATA_TYPE_NCHAR:
- return POINTER_SHIFT(pCol->pData, pCol->dataOff[row]);
- break;
-
- default:
- return POINTER_SHIFT(pCol->pData, TYPE_BYTES[pCol->type] * row);
- break;
+ if (IS_VAR_DATA_TYPE(pCol->type)) {
+ return POINTER_SHIFT(pCol->pData, pCol->dataOff[row]);
+ } else {
+ return POINTER_SHIFT(pCol->pData, TYPE_BYTES[pCol->type] * row);
}
}
static FORCE_INLINE int32_t dataColGetNEleLen(SDataCol *pDataCol, int rows) {
ASSERT(rows > 0);
- switch (pDataCol->type) {
- case TSDB_DATA_TYPE_BINARY:
- case TSDB_DATA_TYPE_NCHAR:
- return pDataCol->dataOff[rows - 1] + varDataTLen(tdGetColDataOfRow(pDataCol, rows - 1));
- break;
- default:
- return TYPE_BYTES[pDataCol->type] * rows;
+ if (IS_VAR_DATA_TYPE(pDataCol->type)) {
+ return pDataCol->dataOff[rows - 1] + varDataTLen(tdGetColDataOfRow(pDataCol, rows - 1));
+ } else {
+ return TYPE_BYTES[pDataCol->type] * rows;
}
}
@@ -243,9 +265,14 @@ typedef struct {
} SDataCols;
#define keyCol(pCols) (&((pCols)->cols[0])) // Key column
-#define dataColsKeyAt(pCols, idx) ((TSKEY *)(keyCol(pCols)->pData))[(idx)]
-#define dataColsKeyFirst(pCols) dataColsKeyAt(pCols, 0)
-#define dataColsKeyLast(pCols) ((pCols->numOfRows == 0) ? 0 : dataColsKeyAt(pCols, (pCols)->numOfRows - 1))
+#define dataColsTKeyAt(pCols, idx) ((TKEY *)(keyCol(pCols)->pData))[(idx)]
+#define dataColsKeyAt(pCols, idx) tdGetKey(dataColsTKeyAt(pCols, idx))
+#define dataColsTKeyFirst(pCols) (((pCols)->numOfRows == 0) ? TKEY_INVALID : dataColsTKeyAt(pCols, 0))
+#define dataColsKeyFirst(pCols) (((pCols)->numOfRows == 0) ? TSDB_DATA_TIMESTAMP_NULL : dataColsKeyAt(pCols, 0))
+#define dataColsTKeyLast(pCols) \
+ (((pCols)->numOfRows == 0) ? TKEY_INVALID : dataColsTKeyAt(pCols, (pCols)->numOfRows - 1))
+#define dataColsKeyLast(pCols) \
+ (((pCols)->numOfRows == 0) ? TSDB_DATA_TIMESTAMP_NULL : dataColsKeyAt(pCols, (pCols)->numOfRows - 1))
SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows);
void tdResetDataCols(SDataCols *pCols);
@@ -253,10 +280,7 @@ int tdInitDataCols(SDataCols *pCols, STSchema *pSchema);
SDataCols *tdDupDataCols(SDataCols *pCols, bool keepData);
void tdFreeDataCols(SDataCols *pCols);
void tdAppendDataRowToDataCol(SDataRow row, STSchema *pSchema, SDataCols *pCols);
-void tdPopDataColsPoints(SDataCols *pCols, int pointsToPop); //!!!!
int tdMergeDataCols(SDataCols *target, SDataCols *src, int rowsToMerge);
-void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, int limit1, SDataCols *src2, int *iter2,
- int limit2, int tRows);
// ----------------- K-V data row structure
/*
diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h
index f059ec1566..dbcf50ba77 100644
--- a/src/common/inc/tglobal.h
+++ b/src/common/inc/tglobal.h
@@ -88,6 +88,7 @@ extern int16_t tsWAL;
extern int32_t tsFsyncPeriod;
extern int32_t tsReplications;
extern int32_t tsQuorum;
+extern int32_t tsUpdate;
// balance
extern int32_t tsEnableBalance;
diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c
index 28289b051e..40b524488a 100644
--- a/src/common/src/tdataformat.c
+++ b/src/common/src/tdataformat.c
@@ -18,6 +18,9 @@
#include "tcoding.h"
#include "wchar.h"
+static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, int limit1, SDataCols *src2, int *iter2,
+ int limit2, int tRows);
+
/**
* Duplicate the schema and return a new object
*/
@@ -202,7 +205,7 @@ void dataColInit(SDataCol *pDataCol, STColumn *pCol, void **pBuf, int maxPoints)
pDataCol->offset = colOffset(pCol) + TD_DATA_ROW_HEAD_SIZE;
pDataCol->len = 0;
- if (pDataCol->type == TSDB_DATA_TYPE_BINARY || pDataCol->type == TSDB_DATA_TYPE_NCHAR) {
+ if (IS_VAR_DATA_TYPE(pDataCol->type)) {
pDataCol->dataOff = (VarDataOffsetT *)(*pBuf);
pDataCol->pData = POINTER_SHIFT(*pBuf, sizeof(VarDataOffsetT) * maxPoints);
pDataCol->spaceSize = pDataCol->bytes * maxPoints;
@@ -215,60 +218,29 @@ void dataColInit(SDataCol *pDataCol, STColumn *pCol, void **pBuf, int maxPoints)
}
}
+// value from timestamp should be TKEY here instead of TSKEY
void dataColAppendVal(SDataCol *pCol, void *value, int numOfRows, int maxPoints) {
ASSERT(pCol != NULL && value != NULL);
- switch (pCol->type) {
- case TSDB_DATA_TYPE_BINARY:
- case TSDB_DATA_TYPE_NCHAR:
- // set offset
- pCol->dataOff[numOfRows] = pCol->len;
- // Copy data
- memcpy(POINTER_SHIFT(pCol->pData, pCol->len), value, varDataTLen(value));
- // Update the length
- pCol->len += varDataTLen(value);
- break;
- default:
- ASSERT(pCol->len == TYPE_BYTES[pCol->type] * numOfRows);
- memcpy(POINTER_SHIFT(pCol->pData, pCol->len), value, pCol->bytes);
- pCol->len += pCol->bytes;
- break;
- }
-}
-
-void dataColPopPoints(SDataCol *pCol, int pointsToPop, int numOfRows) {
- int pointsLeft = numOfRows - pointsToPop;
-
- ASSERT(pointsLeft > 0);
-
- if (pCol->type == TSDB_DATA_TYPE_BINARY || pCol->type == TSDB_DATA_TYPE_NCHAR) {
- ASSERT(pCol->len > 0);
- VarDataOffsetT toffset = pCol->dataOff[pointsToPop];
- pCol->len = pCol->len - toffset;
- ASSERT(pCol->len > 0);
- memmove(pCol->pData, POINTER_SHIFT(pCol->pData, toffset), pCol->len);
- dataColSetOffset(pCol, pointsLeft);
+ if (IS_VAR_DATA_TYPE(pCol->type)) {
+ // set offset
+ pCol->dataOff[numOfRows] = pCol->len;
+ // Copy data
+ memcpy(POINTER_SHIFT(pCol->pData, pCol->len), value, varDataTLen(value));
+ // Update the length
+ pCol->len += varDataTLen(value);
} else {
ASSERT(pCol->len == TYPE_BYTES[pCol->type] * numOfRows);
- pCol->len = TYPE_BYTES[pCol->type] * pointsLeft;
- memmove(pCol->pData, POINTER_SHIFT(pCol->pData, TYPE_BYTES[pCol->type] * pointsToPop), pCol->len);
+ memcpy(POINTER_SHIFT(pCol->pData, pCol->len), value, pCol->bytes);
+ pCol->len += pCol->bytes;
}
}
bool isNEleNull(SDataCol *pCol, int nEle) {
- switch (pCol->type) {
- case TSDB_DATA_TYPE_BINARY:
- case TSDB_DATA_TYPE_NCHAR:
- for (int i = 0; i < nEle; i++) {
- if (!isNull(tdGetColDataOfRow(pCol, i), pCol->type)) return false;
- }
- return true;
- default:
- for (int i = 0; i < nEle; i++) {
- if (!isNull(tdGetColDataOfRow(pCol, i), pCol->type)) return false;
- }
- return true;
+ for (int i = 0; i < nEle; i++) {
+ if (!isNull(tdGetColDataOfRow(pCol, i), pCol->type)) return false;
}
+ return true;
}
void dataColSetNullAt(SDataCol *pCol, int index) {
@@ -390,7 +362,7 @@ SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) {
pRet->cols[i].spaceSize = pDataCols->cols[i].spaceSize;
pRet->cols[i].pData = (void *)((char *)pRet->buf + ((char *)(pDataCols->cols[i].pData) - (char *)(pDataCols->buf)));
- if (pRet->cols[i].type == TSDB_DATA_TYPE_BINARY || pRet->cols[i].type == TSDB_DATA_TYPE_NCHAR) {
+ if (IS_VAR_DATA_TYPE(pRet->cols[i].type)) {
ASSERT(pDataCols->cols[i].dataOff != NULL);
pRet->cols[i].dataOff =
(int32_t *)((char *)pRet->buf + ((char *)(pDataCols->cols[i].dataOff) - (char *)(pDataCols->buf)));
@@ -400,7 +372,7 @@ SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) {
pRet->cols[i].len = pDataCols->cols[i].len;
if (pDataCols->cols[i].len > 0) {
memcpy(pRet->cols[i].pData, pDataCols->cols[i].pData, pDataCols->cols[i].len);
- if (pRet->cols[i].type == TSDB_DATA_TYPE_BINARY || pRet->cols[i].type == TSDB_DATA_TYPE_NCHAR) {
+ if (IS_VAR_DATA_TYPE(pRet->cols[i].type)) {
memcpy(pRet->cols[i].dataOff, pDataCols->cols[i].dataOff, sizeof(VarDataOffsetT) * pDataCols->maxPoints);
}
}
@@ -420,58 +392,54 @@ void tdResetDataCols(SDataCols *pCols) {
}
void tdAppendDataRowToDataCol(SDataRow row, STSchema *pSchema, SDataCols *pCols) {
- ASSERT(dataColsKeyLast(pCols) < dataRowKey(row));
+ ASSERT(pCols->numOfRows == 0 || dataColsKeyLast(pCols) < dataRowKey(row));
int rcol = 0;
int dcol = 0;
- while (dcol < pCols->numOfCols) {
- SDataCol *pDataCol = &(pCols->cols[dcol]);
- if (rcol >= schemaNCols(pSchema)) {
- dataColSetNullAt(pDataCol, pCols->numOfRows);
- dcol++;
- continue;
+ if (dataRowDeleted(row)) {
+ for (; dcol < pCols->numOfCols; dcol++) {
+ SDataCol *pDataCol = &(pCols->cols[dcol]);
+ if (dcol == 0) {
+ dataColAppendVal(pDataCol, dataRowTuple(row), pCols->numOfRows, pCols->maxPoints);
+ } else {
+ dataColSetNullAt(pDataCol, pCols->numOfRows);
+ }
}
+ } else {
+ while (dcol < pCols->numOfCols) {
+ SDataCol *pDataCol = &(pCols->cols[dcol]);
+ if (rcol >= schemaNCols(pSchema)) {
+ dataColSetNullAt(pDataCol, pCols->numOfRows);
+ dcol++;
+ continue;
+ }
- STColumn *pRowCol = schemaColAt(pSchema, rcol);
- if (pRowCol->colId == pDataCol->colId) {
- void *value = tdGetRowDataOfCol(row, pRowCol->type, pRowCol->offset+TD_DATA_ROW_HEAD_SIZE);
- dataColAppendVal(pDataCol, value, pCols->numOfRows, pCols->maxPoints);
- dcol++;
- rcol++;
- } else if (pRowCol->colId < pDataCol->colId) {
- rcol++;
- } else {
- dataColSetNullAt(pDataCol, pCols->numOfRows);
- dcol++;
+ STColumn *pRowCol = schemaColAt(pSchema, rcol);
+ if (pRowCol->colId == pDataCol->colId) {
+ void *value = tdGetRowDataOfCol(row, pRowCol->type, pRowCol->offset + TD_DATA_ROW_HEAD_SIZE);
+ dataColAppendVal(pDataCol, value, pCols->numOfRows, pCols->maxPoints);
+ dcol++;
+ rcol++;
+ } else if (pRowCol->colId < pDataCol->colId) {
+ rcol++;
+ } else {
+ dataColSetNullAt(pDataCol, pCols->numOfRows);
+ dcol++;
+ }
}
}
pCols->numOfRows++;
}
-// Pop pointsToPop points from the SDataCols
-void tdPopDataColsPoints(SDataCols *pCols, int pointsToPop) {
- int pointsLeft = pCols->numOfRows - pointsToPop;
- if (pointsLeft <= 0) {
- tdResetDataCols(pCols);
- return;
- }
-
- for (int iCol = 0; iCol < pCols->numOfCols; iCol++) {
- SDataCol *pCol = pCols->cols + iCol;
- dataColPopPoints(pCol, pointsToPop, pCols->numOfRows);
- }
- pCols->numOfRows = pointsLeft;
-}
-
int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge) {
ASSERT(rowsToMerge > 0 && rowsToMerge <= source->numOfRows);
- ASSERT(target->numOfRows + rowsToMerge <= target->maxPoints);
ASSERT(target->numOfCols == source->numOfCols);
SDataCols *pTarget = NULL;
if (dataColsKeyLast(target) < dataColsKeyFirst(source)) { // No overlap
+ ASSERT(target->numOfRows + rowsToMerge <= target->maxPoints);
for (int i = 0; i < rowsToMerge; i++) {
for (int j = 0; j < source->numOfCols; j++) {
if (source->cols[j].len > 0) {
@@ -499,17 +467,23 @@ _err:
return -1;
}
-void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, int limit1, SDataCols *src2, int *iter2, int limit2, int tRows) {
+// src2 data has more priority than src1
+static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, int limit1, SDataCols *src2, int *iter2,
+ int limit2, int tRows) {
tdResetDataCols(target);
ASSERT(limit1 <= src1->numOfRows && limit2 <= src2->numOfRows);
while (target->numOfRows < tRows) {
if (*iter1 >= limit1 && *iter2 >= limit2) break;
- TSKEY key1 = (*iter1 >= limit1) ? INT64_MAX : ((TSKEY *)(src1->cols[0].pData))[*iter1];
- TSKEY key2 = (*iter2 >= limit2) ? INT64_MAX : ((TSKEY *)(src2->cols[0].pData))[*iter2];
+ TSKEY key1 = (*iter1 >= limit1) ? INT64_MAX : dataColsKeyAt(src1, *iter1);
+ TKEY tkey1 = (*iter1 >= limit1) ? TKEY_NULL : dataColsTKeyAt(src1, *iter1);
+ TSKEY key2 = (*iter2 >= limit2) ? INT64_MAX : dataColsKeyAt(src2, *iter2);
+ TKEY tkey2 = (*iter2 >= limit2) ? TKEY_NULL : dataColsTKeyAt(src2, *iter2);
- if (key1 <= key2) {
+ ASSERT(tkey1 == TKEY_NULL || (!TKEY_IS_DELETED(tkey1)));
+
+ if (key1 < key2) {
for (int i = 0; i < src1->numOfCols; i++) {
ASSERT(target->cols[i].type == src1->cols[i].type);
if (src1->cols[i].len > 0) {
@@ -520,19 +494,23 @@ void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, int limi
target->numOfRows++;
(*iter1)++;
- if (key1 == key2) (*iter2)++;
- } else {
- for (int i = 0; i < src2->numOfCols; i++) {
- ASSERT(target->cols[i].type == src2->cols[i].type);
- if (src2->cols[i].len > 0) {
- dataColAppendVal(&(target->cols[i]), tdGetColDataOfRow(src2->cols + i, *iter2), target->numOfRows,
- target->maxPoints);
+ } else if (key1 >= key2) {
+ if ((key1 > key2) || (key1 == key2 && !TKEY_IS_DELETED(tkey2))) {
+ for (int i = 0; i < src2->numOfCols; i++) {
+ ASSERT(target->cols[i].type == src2->cols[i].type);
+ if (src2->cols[i].len > 0) {
+ dataColAppendVal(&(target->cols[i]), tdGetColDataOfRow(src2->cols + i, *iter2), target->numOfRows,
+ target->maxPoints);
+ }
}
+ target->numOfRows++;
}
- target->numOfRows++;
(*iter2)++;
+ if (key1 == key2) (*iter1)++;
}
+
+ ASSERT(target->numOfRows <= target->maxPoints);
}
}
diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c
index cbeac421c9..75c8f93a82 100644
--- a/src/common/src/tglobal.c
+++ b/src/common/src/tglobal.c
@@ -120,6 +120,7 @@ int16_t tsWAL = TSDB_DEFAULT_WAL_LEVEL;
int32_t tsFsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD;
int32_t tsReplications = TSDB_DEFAULT_DB_REPLICA_OPTION;
int32_t tsQuorum = TSDB_DEFAULT_DB_QUORUM_OPTION;
+int32_t tsUpdate = TSDB_DEFAULT_DB_UPDATE_OPTION;
int32_t tsMaxVgroupsPerDb = 0;
int32_t tsMinTablePerVnode = TSDB_TABLES_STEP;
int32_t tsMaxTablePerVnode = TSDB_DEFAULT_TABLES;
@@ -786,6 +787,16 @@ static void doInitGlobalConfig(void) {
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
+ cfg.option = "update";
+ cfg.ptr = &tsUpdate;
+ cfg.valType = TAOS_CFG_VTYPE_INT32;
+ cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
+ cfg.minValue = TSDB_MIN_DB_UPDATE;
+ cfg.maxValue = TSDB_MAX_DB_UPDATE;
+ cfg.ptrLength = 0;
+ cfg.unitType = TAOS_CFG_UTYPE_NONE;
+ taosInitConfigOption(cfg);
+
cfg.option = "mqttHostName";
cfg.ptr = tsMqttHostName;
cfg.valType = TAOS_CFG_VTYPE_STRING;
diff --git a/src/dnode/src/dnodeVRead.c b/src/dnode/src/dnodeVRead.c
index f571cfda9f..34df11adcc 100644
--- a/src/dnode/src/dnodeVRead.c
+++ b/src/dnode/src/dnodeVRead.c
@@ -92,33 +92,23 @@ void dnodeDispatchToVReadQueue(SRpcMsg *pMsg) {
pHead->vgId = htonl(pHead->vgId);
pHead->contLen = htonl(pHead->contLen);
- taos_queue queue = vnodeAcquireRqueue(pHead->vgId);
-
- if (queue == NULL) {
- leftLen -= pHead->contLen;
- pCont -= pHead->contLen;
- continue;
+ void *pVnode = vnodeAcquire(pHead->vgId);
+ if (pVnode != NULL) {
+ int32_t code = vnodeWriteToRQueue(pVnode, pCont, pHead->contLen, TAOS_QTYPE_RPC, pMsg);
+ if (code == TSDB_CODE_SUCCESS) queuedMsgNum++;
+ vnodeRelease(pVnode);
}
- // put message into queue
- SVReadMsg *pRead = taosAllocateQitem(sizeof(SVReadMsg));
- pRead->rpcMsg = *pMsg;
- pRead->pCont = pCont;
- pRead->contLen = pHead->contLen;
-
- // next vnode
leftLen -= pHead->contLen;
pCont -= pHead->contLen;
- queuedMsgNum++;
-
- taosWriteQitem(queue, TAOS_QTYPE_RPC, pRead);
}
if (queuedMsgNum == 0) {
SRpcMsg rpcRsp = {.handle = pMsg->handle, .code = TSDB_CODE_VND_INVALID_VGROUP_ID};
rpcSendResponse(&rpcRsp);
- rpcFreeCont(pMsg->pCont);
}
+
+ rpcFreeCont(pMsg->pCont);
}
void *dnodeAllocVReadQueue(void *pVnode) {
@@ -162,50 +152,48 @@ void dnodeFreeVReadQueue(void *rqueue) {
void dnodeSendRpcVReadRsp(void *pVnode, SVReadMsg *pRead, int32_t code) {
SRpcMsg rpcRsp = {
- .handle = pRead->rpcMsg.handle,
+ .handle = pRead->rpcHandle,
.pCont = pRead->rspRet.rsp,
.contLen = pRead->rspRet.len,
.code = code,
};
rpcSendResponse(&rpcRsp);
- rpcFreeCont(pRead->rpcMsg.pCont);
vnodeRelease(pVnode);
}
void dnodeDispatchNonRspMsg(void *pVnode, SVReadMsg *pRead, int32_t code) {
- rpcFreeCont(pRead->rpcMsg.pCont);
vnodeRelease(pVnode);
}
static void *dnodeProcessReadQueue(void *param) {
- SVReadMsg *pReadMsg;
+ SVReadMsg *pRead;
int32_t qtype;
void * pVnode;
while (1) {
- if (taosReadQitemFromQset(tsVReadQset, &qtype, (void **)&pReadMsg, &pVnode) == 0) {
+ if (taosReadQitemFromQset(tsVReadQset, &qtype, (void **)&pRead, &pVnode) == 0) {
dDebug("qset:%p dnode vread got no message from qset, exiting", tsVReadQset);
break;
}
- dDebug("%p, msg:%s will be processed in vread queue, qtype:%d, msg:%p", pReadMsg->rpcMsg.ahandle,
- taosMsg[pReadMsg->rpcMsg.msgType], qtype, pReadMsg);
+ dDebug("%p, msg:%p:%s will be processed in vread queue, qtype:%d", pRead->rpcAhandle, pRead,
+ taosMsg[pRead->msgType], qtype);
- int32_t code = vnodeProcessRead(pVnode, pReadMsg);
+ int32_t code = vnodeProcessRead(pVnode, pRead);
if (qtype == TAOS_QTYPE_RPC && code != TSDB_CODE_QRY_NOT_READY) {
- dnodeSendRpcVReadRsp(pVnode, pReadMsg, code);
+ dnodeSendRpcVReadRsp(pVnode, pRead, code);
} else {
if (code == TSDB_CODE_QRY_HAS_RSP) {
- dnodeSendRpcVReadRsp(pVnode, pReadMsg, pReadMsg->rpcMsg.code);
+ dnodeSendRpcVReadRsp(pVnode, pRead, pRead->code);
} else { // code == TSDB_CODE_QRY_NOT_READY, do not return msg to client
- assert(pReadMsg->rpcMsg.handle == NULL || (pReadMsg->rpcMsg.handle != NULL && pReadMsg->rpcMsg.msgType == 5));
- dnodeDispatchNonRspMsg(pVnode, pReadMsg, code);
+ assert(pRead->rpcHandle == NULL || (pRead->rpcHandle != NULL && pRead->msgType == 5));
+ dnodeDispatchNonRspMsg(pVnode, pRead, code);
}
}
- taosFreeQitem(pReadMsg);
+ taosFreeQitem(pRead);
}
return NULL;
diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h
index aee60da201..6c7229f12d 100644
--- a/src/inc/taosdef.h
+++ b/src/inc/taosdef.h
@@ -75,6 +75,7 @@ extern const int32_t TYPE_BYTES[11];
#define TSDB_DATA_SMALLINT_NULL 0x8000
#define TSDB_DATA_INT_NULL 0x80000000L
#define TSDB_DATA_BIGINT_NULL 0x8000000000000000L
+#define TSDB_DATA_TIMESTAMP_NULL TSDB_DATA_BIGINT_NULL
#define TSDB_DATA_FLOAT_NULL 0x7FF00000 // it is an NAN
#define TSDB_DATA_DOUBLE_NULL 0x7FFFFF0000000000L // an NAN
@@ -363,6 +364,10 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf
#define TSDB_MAX_WAL_LEVEL 2
#define TSDB_DEFAULT_WAL_LEVEL 1
+#define TSDB_MIN_DB_UPDATE 0
+#define TSDB_MAX_DB_UPDATE 1
+#define TSDB_DEFAULT_DB_UPDATE_OPTION 0
+
#define TSDB_MIN_FSYNC_PERIOD 0
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second
diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h
index 8139c9ab17..743616e08e 100644
--- a/src/inc/taosmsg.h
+++ b/src/inc/taosmsg.h
@@ -544,6 +544,8 @@ typedef struct {
int8_t replications;
int8_t quorum;
int8_t ignoreExist;
+ int8_t update;
+ int8_t reserve[9];
} SCreateDbMsg, SAlterDbMsg;
typedef struct {
@@ -654,7 +656,8 @@ typedef struct {
int8_t replications;
int8_t wals;
int8_t quorum;
- int8_t reserved[16];
+ int8_t update;
+ int8_t reserved[15];
} SVnodeCfg;
typedef struct {
diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h
index 85f9b3bdc7..fe03277763 100644
--- a/src/inc/tsdb.h
+++ b/src/inc/tsdb.h
@@ -65,6 +65,7 @@ typedef struct {
int32_t maxRowsPerFileBlock; // maximum rows per file block
int8_t precision;
int8_t compression;
+ int8_t update;
} STsdbCfg;
// --------- TSDB REPOSITORY USAGE STATISTICS
diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h
index a94cdaad15..32f2a2d32e 100644
--- a/src/inc/ttokendef.h
+++ b/src/inc/ttokendef.h
@@ -114,114 +114,115 @@
#define TK_FSYNC 95
#define TK_COMP 96
#define TK_PRECISION 97
-#define TK_LP 98
-#define TK_RP 99
-#define TK_TAGS 100
-#define TK_USING 101
-#define TK_AS 102
-#define TK_COMMA 103
-#define TK_NULL 104
-#define TK_SELECT 105
-#define TK_UNION 106
-#define TK_ALL 107
-#define TK_FROM 108
-#define TK_VARIABLE 109
-#define TK_INTERVAL 110
-#define TK_FILL 111
-#define TK_SLIDING 112
-#define TK_ORDER 113
-#define TK_BY 114
-#define TK_ASC 115
-#define TK_DESC 116
-#define TK_GROUP 117
-#define TK_HAVING 118
-#define TK_LIMIT 119
-#define TK_OFFSET 120
-#define TK_SLIMIT 121
-#define TK_SOFFSET 122
-#define TK_WHERE 123
-#define TK_NOW 124
-#define TK_RESET 125
-#define TK_QUERY 126
-#define TK_ADD 127
-#define TK_COLUMN 128
-#define TK_TAG 129
-#define TK_CHANGE 130
-#define TK_SET 131
-#define TK_KILL 132
-#define TK_CONNECTION 133
-#define TK_STREAM 134
-#define TK_COLON 135
-#define TK_ABORT 136
-#define TK_AFTER 137
-#define TK_ATTACH 138
-#define TK_BEFORE 139
-#define TK_BEGIN 140
-#define TK_CASCADE 141
-#define TK_CLUSTER 142
-#define TK_CONFLICT 143
-#define TK_COPY 144
-#define TK_DEFERRED 145
-#define TK_DELIMITERS 146
-#define TK_DETACH 147
-#define TK_EACH 148
-#define TK_END 149
-#define TK_EXPLAIN 150
-#define TK_FAIL 151
-#define TK_FOR 152
-#define TK_IGNORE 153
-#define TK_IMMEDIATE 154
-#define TK_INITIALLY 155
-#define TK_INSTEAD 156
-#define TK_MATCH 157
-#define TK_KEY 158
-#define TK_OF 159
-#define TK_RAISE 160
-#define TK_REPLACE 161
-#define TK_RESTRICT 162
-#define TK_ROW 163
-#define TK_STATEMENT 164
-#define TK_TRIGGER 165
-#define TK_VIEW 166
-#define TK_COUNT 167
-#define TK_SUM 168
-#define TK_AVG 169
-#define TK_MIN 170
-#define TK_MAX 171
-#define TK_FIRST 172
-#define TK_LAST 173
-#define TK_TOP 174
-#define TK_BOTTOM 175
-#define TK_STDDEV 176
-#define TK_PERCENTILE 177
-#define TK_APERCENTILE 178
-#define TK_LEASTSQUARES 179
-#define TK_HISTOGRAM 180
-#define TK_DIFF 181
-#define TK_SPREAD 182
-#define TK_TWA 183
-#define TK_INTERP 184
-#define TK_LAST_ROW 185
-#define TK_RATE 186
-#define TK_IRATE 187
-#define TK_SUM_RATE 188
-#define TK_SUM_IRATE 189
-#define TK_AVG_RATE 190
-#define TK_AVG_IRATE 191
-#define TK_TBID 192
-#define TK_SEMI 193
-#define TK_NONE 194
-#define TK_PREV 195
-#define TK_LINEAR 196
-#define TK_IMPORT 197
-#define TK_METRIC 198
-#define TK_TBNAME 199
-#define TK_JOIN 200
-#define TK_METRICS 201
-#define TK_STABLE 202
-#define TK_INSERT 203
-#define TK_INTO 204
-#define TK_VALUES 205
+#define TK_UPDATE 98
+#define TK_LP 99
+#define TK_RP 100
+#define TK_TAGS 101
+#define TK_USING 102
+#define TK_AS 103
+#define TK_COMMA 104
+#define TK_NULL 105
+#define TK_SELECT 106
+#define TK_UNION 107
+#define TK_ALL 108
+#define TK_FROM 109
+#define TK_VARIABLE 110
+#define TK_INTERVAL 111
+#define TK_FILL 112
+#define TK_SLIDING 113
+#define TK_ORDER 114
+#define TK_BY 115
+#define TK_ASC 116
+#define TK_DESC 117
+#define TK_GROUP 118
+#define TK_HAVING 119
+#define TK_LIMIT 120
+#define TK_OFFSET 121
+#define TK_SLIMIT 122
+#define TK_SOFFSET 123
+#define TK_WHERE 124
+#define TK_NOW 125
+#define TK_RESET 126
+#define TK_QUERY 127
+#define TK_ADD 128
+#define TK_COLUMN 129
+#define TK_TAG 130
+#define TK_CHANGE 131
+#define TK_SET 132
+#define TK_KILL 133
+#define TK_CONNECTION 134
+#define TK_STREAM 135
+#define TK_COLON 136
+#define TK_ABORT 137
+#define TK_AFTER 138
+#define TK_ATTACH 139
+#define TK_BEFORE 140
+#define TK_BEGIN 141
+#define TK_CASCADE 142
+#define TK_CLUSTER 143
+#define TK_CONFLICT 144
+#define TK_COPY 145
+#define TK_DEFERRED 146
+#define TK_DELIMITERS 147
+#define TK_DETACH 148
+#define TK_EACH 149
+#define TK_END 150
+#define TK_EXPLAIN 151
+#define TK_FAIL 152
+#define TK_FOR 153
+#define TK_IGNORE 154
+#define TK_IMMEDIATE 155
+#define TK_INITIALLY 156
+#define TK_INSTEAD 157
+#define TK_MATCH 158
+#define TK_KEY 159
+#define TK_OF 160
+#define TK_RAISE 161
+#define TK_REPLACE 162
+#define TK_RESTRICT 163
+#define TK_ROW 164
+#define TK_STATEMENT 165
+#define TK_TRIGGER 166
+#define TK_VIEW 167
+#define TK_COUNT 168
+#define TK_SUM 169
+#define TK_AVG 170
+#define TK_MIN 171
+#define TK_MAX 172
+#define TK_FIRST 173
+#define TK_LAST 174
+#define TK_TOP 175
+#define TK_BOTTOM 176
+#define TK_STDDEV 177
+#define TK_PERCENTILE 178
+#define TK_APERCENTILE 179
+#define TK_LEASTSQUARES 180
+#define TK_HISTOGRAM 181
+#define TK_DIFF 182
+#define TK_SPREAD 183
+#define TK_TWA 184
+#define TK_INTERP 185
+#define TK_LAST_ROW 186
+#define TK_RATE 187
+#define TK_IRATE 188
+#define TK_SUM_RATE 189
+#define TK_SUM_IRATE 190
+#define TK_AVG_RATE 191
+#define TK_AVG_IRATE 192
+#define TK_TBID 193
+#define TK_SEMI 194
+#define TK_NONE 195
+#define TK_PREV 196
+#define TK_LINEAR 197
+#define TK_IMPORT 198
+#define TK_METRIC 199
+#define TK_TBNAME 200
+#define TK_JOIN 201
+#define TK_METRICS 202
+#define TK_STABLE 203
+#define TK_INSERT 204
+#define TK_INTO 205
+#define TK_VALUES 206
#define TK_SPACE 300
#define TK_COMMENT 301
diff --git a/src/inc/vnode.h b/src/inc/vnode.h
index e77bec926a..018e96e193 100644
--- a/src/inc/vnode.h
+++ b/src/inc/vnode.h
@@ -37,10 +37,15 @@ typedef struct {
} SRspRet;
typedef struct {
- SRspRet rspRet;
- void * pCont;
+ int32_t code;
int32_t contLen;
- SRpcMsg rpcMsg;
+ void * rpcHandle;
+ void * rpcAhandle;
+ void * qhandle;
+ int8_t qtype;
+ int8_t msgType;
+ SRspRet rspRet;
+ char pCont[];
} SVReadMsg;
typedef struct {
@@ -62,13 +67,11 @@ int32_t vnodeAlter(void *pVnode, SCreateVnodeMsg *pVnodeCfg);
int32_t vnodeClose(int32_t vgId);
void* vnodeAcquire(int32_t vgId); // add refcount
-void* vnodeAcquireRqueue(int32_t vgId); // add refCount, get read queue
void vnodeRelease(void *pVnode); // dec refCount
void* vnodeGetWal(void *pVnode);
int32_t vnodeWriteToWQueue(void *vparam, void *wparam, int32_t qtype, void *rparam);
int32_t vnodeProcessWrite(void *vparam, void *wparam, int32_t qtype, void *rparam);
-int32_t vnodeCheckWrite(void *pVnode);
int32_t vnodeGetVnodeList(int32_t vnodeList[], int32_t *numOfVnodes);
void vnodeBuildStatusMsg(void *param);
void vnodeConfirmForward(void *param, uint64_t version, int32_t code);
@@ -77,8 +80,8 @@ void vnodeSetAccess(SVgroupAccess *pAccess, int32_t numOfVnodes);
int32_t vnodeInitResources();
void vnodeCleanupResources();
-int32_t vnodeProcessRead(void *pVnode, SVReadMsg *pReadMsg);
-int32_t vnodeCheckRead(void *pVnode);
+int32_t vnodeWriteToRQueue(void *vparam, void *pCont, int32_t contLen, int8_t qtype, void *rparam);
+int32_t vnodeProcessRead(void *pVnode, SVReadMsg *pRead);
#ifdef __cplusplus
}
diff --git a/src/mnode/inc/mnodeDef.h b/src/mnode/inc/mnodeDef.h
index 4bc840f026..d25652100b 100644
--- a/src/mnode/inc/mnodeDef.h
+++ b/src/mnode/inc/mnodeDef.h
@@ -172,7 +172,8 @@ typedef struct {
int8_t walLevel;
int8_t replications;
int8_t quorum;
- int8_t reserved[12];
+ int8_t update;
+ int8_t reserved[11];
} SDbCfg;
typedef struct SDbObj {
diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c
index 748b856ba4..fb4793c056 100644
--- a/src/mnode/src/mnodeDb.c
+++ b/src/mnode/src/mnodeDb.c
@@ -319,6 +319,11 @@ static int32_t mnodeCheckDbCfg(SDbCfg *pCfg) {
}
#endif
+ if (pCfg->update < TSDB_MIN_DB_UPDATE || pCfg->update > TSDB_MAX_DB_UPDATE) {
+ mError("invalid db option update:%d valid range: [%d, %d]", pCfg->update, TSDB_MIN_DB_UPDATE, TSDB_MAX_DB_UPDATE);
+ return TSDB_CODE_MND_INVALID_DB_OPTION;
+ }
+
return TSDB_CODE_SUCCESS;
}
@@ -339,6 +344,7 @@ static void mnodeSetDefaultDbCfg(SDbCfg *pCfg) {
if (pCfg->walLevel < 0) pCfg->walLevel = tsWAL;
if (pCfg->replications < 0) pCfg->replications = tsReplications;
if (pCfg->quorum < 0) pCfg->quorum = tsQuorum;
+ if (pCfg->update < 0) pCfg->update = tsUpdate;
}
static int32_t mnodeCreateDbCb(SMnodeMsg *pMsg, int32_t code) {
@@ -391,7 +397,8 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
.compression = pCreate->compression,
.walLevel = pCreate->walLevel,
.replications = pCreate->replications,
- .quorum = pCreate->quorum
+ .quorum = pCreate->quorum,
+ .update = pCreate->update
};
mnodeSetDefaultDbCfg(&pDb->cfg);
@@ -610,6 +617,12 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn
pSchema[cols].bytes = htons(pShow->bytes[cols]);
cols++;
+ pShow->bytes[cols] = 1;
+ pSchema[cols].type = TSDB_DATA_TYPE_TINYINT;
+ strcpy(pSchema[cols].name, "update");
+ pSchema[cols].bytes = htons(pShow->bytes[cols]);
+ cols++;
+
pShow->bytes[cols] = 10 + VARSTR_HEADER_SIZE;
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
strcpy(pSchema[cols].name, "status");
@@ -749,6 +762,10 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void
STR_WITH_SIZE_TO_VARSTR(pWrite, prec, 2);
cols++;
+ pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
+ *(int8_t *)pWrite = pDb->cfg.update;
+ cols++;
+
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
if (pDb->status == TSDB_DB_STATUS_READY) {
const char *src = "ready";
@@ -848,6 +865,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
int8_t replications = pAlter->replications;
int8_t quorum = pAlter->quorum;
int8_t precision = pAlter->precision;
+ int8_t update = pAlter->update;
terrno = TSDB_CODE_SUCCESS;
@@ -950,6 +968,16 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
newCfg.quorum = quorum;
}
+ if (update >= 0 && update != pDb->cfg.update) {
+#if 0
+ mDebug("db:%s, update:%d change to %d", pDb->name, pDb->cfg.update, update);
+ newCfg.update = update;
+#else
+ mError("db:%s, can't alter update option", pDb->name);
+ terrno = TSDB_CODE_MND_INVALID_DB_OPTION;
+#endif
+ }
+
return newCfg;
}
diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c
index 1d1f21c3d7..d3fa9a43ab 100644
--- a/src/mnode/src/mnodeVgroup.c
+++ b/src/mnode/src/mnodeVgroup.c
@@ -850,6 +850,7 @@ static SCreateVnodeMsg *mnodeBuildVnodeMsg(SVgObj *pVgroup) {
pCfg->replications = (int8_t) pVgroup->numOfVnodes;
pCfg->wals = 3;
pCfg->quorum = pDb->cfg.quorum;
+ pCfg->update = pDb->cfg.update;
SVnodeDesc *pNodes = pVnode->nodes;
for (int32_t j = 0; j < pVgroup->numOfVnodes; ++j) {
diff --git a/src/query/inc/qSqlparser.h b/src/query/inc/qSqlparser.h
index 25da04710d..f08e13db64 100644
--- a/src/query/inc/qSqlparser.h
+++ b/src/query/inc/qSqlparser.h
@@ -129,6 +129,7 @@ typedef struct SCreateDBInfo {
int32_t compressionLevel;
SStrToken precision;
bool ignoreExists;
+ int8_t update;
tVariantList *keep;
} SCreateDBInfo;
diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y
index e5d1185330..83386e79bb 100644
--- a/src/query/inc/sql.y
+++ b/src/query/inc/sql.y
@@ -239,6 +239,7 @@ wal(Y) ::= WAL INTEGER(X). { Y = X; }
fsync(Y) ::= FSYNC INTEGER(X). { Y = X; }
comp(Y) ::= COMP INTEGER(X). { Y = X; }
prec(Y) ::= PRECISION STRING(X). { Y = X; }
+update(Y) ::= UPDATE INTEGER(X). { Y = X; }
%type db_optr {SCreateDBInfo}
db_optr(Y) ::= . {setDefaultCreateDbOption(&Y);}
@@ -256,6 +257,7 @@ db_optr(Y) ::= db_optr(Z) fsync(X). { Y = Z; Y.fsyncPeriod = strtol(X.z
db_optr(Y) ::= db_optr(Z) comp(X). { Y = Z; Y.compressionLevel = strtol(X.z, NULL, 10); }
db_optr(Y) ::= db_optr(Z) prec(X). { Y = Z; Y.precision = X; }
db_optr(Y) ::= db_optr(Z) keep(X). { Y = Z; Y.keep = X; }
+db_optr(Y) ::= db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); }
%type alter_db_optr {SCreateDBInfo}
alter_db_optr(Y) ::= . { setDefaultCreateDbOption(&Y);}
@@ -267,6 +269,7 @@ alter_db_optr(Y) ::= alter_db_optr(Z) blocks(X). { Y = Z; Y.numOfBlocks = s
alter_db_optr(Y) ::= alter_db_optr(Z) comp(X). { Y = Z; Y.compressionLevel = strtol(X.z, NULL, 10); }
alter_db_optr(Y) ::= alter_db_optr(Z) wal(X). { Y = Z; Y.walLevel = strtol(X.z, NULL, 10); }
alter_db_optr(Y) ::= alter_db_optr(Z) fsync(X). { Y = Z; Y.fsyncPeriod = strtol(X.z, NULL, 10); }
+alter_db_optr(Y) ::= alter_db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); }
%type typename {TAOS_FIELD}
typename(A) ::= ids(X). {
diff --git a/src/query/inc/tsqlfunction.h b/src/query/inc/tsqlfunction.h
index 3bd4aad276..84ca78d822 100644
--- a/src/query/inc/tsqlfunction.h
+++ b/src/query/inc/tsqlfunction.h
@@ -149,7 +149,7 @@ typedef struct SResultRowCellInfo {
int8_t hasResult; // result generated, not NULL value
bool initialized; // output buffer has been initialized
bool complete; // query has completed
- uint16_t numOfRes; // num of output result in current buffer
+ uint32_t numOfRes; // num of output result in current buffer
} SResultRowCellInfo;
#define GET_ROWCELL_INTERBUF(_c) ((void*) ((char*)(_c) + sizeof(SResultRowCellInfo)))
diff --git a/src/query/src/qAst.c b/src/query/src/qAst.c
index 847a8b8eb6..f32ed7c39c 100644
--- a/src/query/src/qAst.c
+++ b/src/query/src/qAst.c
@@ -32,7 +32,6 @@
#include "tstoken.h"
#include "ttokendef.h"
#include "tulog.h"
-#include "tutil.h"
/*
*
@@ -415,9 +414,9 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
}
if (cond.start != NULL) {
- iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->keyInfo.type, TSDB_ORDER_ASC);
+ iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->type, TSDB_ORDER_ASC);
} else {
- iter = tSkipListCreateIterFromVal(pSkipList, (char*)(cond.end ? cond.end->v: NULL), pSkipList->keyInfo.type, TSDB_ORDER_DESC);
+ iter = tSkipListCreateIterFromVal(pSkipList, (char*)(cond.end ? cond.end->v: NULL), pSkipList->type, TSDB_ORDER_DESC);
}
if (cond.start != NULL) {
@@ -432,7 +431,7 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
break;
}
- STableKeyInfo info = {.pTable = *(void**)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
+ STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
taosArrayPush(result, &info);
}
} else if (optr == TSDB_RELATION_GREATER || optr == TSDB_RELATION_GREATER_EQUAL) { // greater equal
@@ -450,7 +449,7 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
if (ret == 0 && optr == TSDB_RELATION_GREATER) {
continue;
} else {
- STableKeyInfo info = {.pTable = *(void**)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
+ STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
taosArrayPush(result, &info);
comp = false;
}
@@ -465,22 +464,22 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
continue;
}
- STableKeyInfo info = {.pTable = *(void**)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
+ STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
taosArrayPush(result, &info);
}
tSkipListDestroyIter(iter);
comp = true;
- iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->keyInfo.type, TSDB_ORDER_DESC);
+ iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->type, TSDB_ORDER_DESC);
while(tSkipListIterNext(iter)) {
SSkipListNode* pNode = tSkipListIterGet(iter);
comp = comp && (pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v) == 0);
- if (comp) {
+ if (comp) {
continue;
}
- STableKeyInfo info = {.pTable = *(void**)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
+ STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
taosArrayPush(result, &info);
}
@@ -504,7 +503,7 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
if (ret == 0 && optr == TSDB_RELATION_LESS) {
continue;
} else {
- STableKeyInfo info = {.pTable = *(void **)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
+ STableKeyInfo info = {.pTable = (void *)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
taosArrayPush(result, &info);
comp = false; // no need to compare anymore
}
@@ -518,7 +517,7 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
bool isnull = isNull(SL_GET_NODE_KEY(pSkipList, pNode), pQueryInfo->sch.type);
if ((pQueryInfo->optr == TSDB_RELATION_ISNULL && isnull) ||
(pQueryInfo->optr == TSDB_RELATION_NOTNULL && (!isnull))) {
- STableKeyInfo info = {.pTable = *(void **)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
+ STableKeyInfo info = {.pTable = (void *)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
taosArrayPush(result, &info);
}
}
@@ -682,7 +681,7 @@ static void tSQLBinaryTraverseOnSkipList(tExprNode *pExpr, SArray *pResult, SSki
while (tSkipListIterNext(iter)) {
SSkipListNode *pNode = tSkipListIterGet(iter);
if (filterItem(pExpr, pNode, param)) {
- taosArrayPush(pResult, SL_GET_NODE_DATA(pNode));
+ taosArrayPush(pResult, &(SL_GET_NODE_DATA(pNode)));
}
}
tSkipListDestroyIter(iter);
@@ -697,7 +696,7 @@ static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo,
SSkipListNode *pNode = tSkipListIterGet(iter);
char * pData = SL_GET_NODE_DATA(pNode);
- tstr *name = (tstr*) tsdbGetTableName(*(void**) pData);
+ tstr *name = (tstr*) tsdbGetTableName((void*) pData);
// todo speed up by using hash
if (pQueryInfo->sch.colId == TSDB_TBNAME_COLUMN_INDEX) {
@@ -711,7 +710,7 @@ static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo,
}
if (addToResult) {
- STableKeyInfo info = {.pTable = *(void**)pData, .lastKey = TSKEY_INITIAL_VAL};
+ STableKeyInfo info = {.pTable = (void*)pData, .lastKey = TSKEY_INITIAL_VAL};
taosArrayPush(res, &info);
}
}
diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c
index b365dc4283..b992a037ed 100644
--- a/src/query/src/qExecutor.c
+++ b/src/query/src/qExecutor.c
@@ -1609,7 +1609,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order
pRuntimeEnv->pCtx = (SQLFunctionCtx *)calloc(pQuery->numOfOutput, sizeof(SQLFunctionCtx));
pRuntimeEnv->rowCellInfoOffset = calloc(pQuery->numOfOutput, sizeof(int32_t));
- pRuntimeEnv->pResultRow = getNewResultRow(pRuntimeEnv->pool);//calloc(1, sizeof(SResultRow));
+ pRuntimeEnv->pResultRow = getNewResultRow(pRuntimeEnv->pool);
if (pRuntimeEnv->pResultRow == NULL || pRuntimeEnv->pCtx == NULL || pRuntimeEnv->rowCellInfoOffset == NULL) {
goto _clean;
@@ -1745,6 +1745,7 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
pRuntimeEnv->pTSBuf = tsBufDestroy(pRuntimeEnv->pTSBuf);
taosTFree(pRuntimeEnv->keyBuf);
+ taosTFree(pRuntimeEnv->rowCellInfoOffset);
taosHashCleanup(pRuntimeEnv->pResultRowHashTable);
pRuntimeEnv->pResultRowHashTable = NULL;
diff --git a/src/query/src/qFill.c b/src/query/src/qFill.c
index a219bd6abd..788779b2bb 100644
--- a/src/query/src/qFill.c
+++ b/src/query/src/qFill.c
@@ -170,7 +170,7 @@ int64_t getFilledNumOfRes(SFillInfo* pFillInfo, TSKEY ekey, int32_t maxNumOfRows
int32_t numOfRows = taosNumOfRemainRows(pFillInfo);
TSKEY ekey1 = ekey;
- if (pFillInfo->order != TSDB_ORDER_ASC) {
+ if (!FILL_IS_ASC_FILL(pFillInfo)) {
pFillInfo->endKey = taosTimeTruncate(ekey, &pFillInfo->interval, pFillInfo->precision);
}
diff --git a/src/query/src/qHistogram.c b/src/query/src/qHistogram.c
index 703ee2c521..35e5906d1f 100644
--- a/src/query/src/qHistogram.c
+++ b/src/query/src/qHistogram.c
@@ -168,7 +168,7 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
(*pHisto)->numOfEntries += 1;
}
} else { /* insert a new slot */
- if ((*pHisto)->numOfElems > 1 && idx < (*pHisto)->numOfEntries) {
+ if ((*pHisto)->numOfElems >= 1 && idx < (*pHisto)->numOfEntries) {
if (idx > 0) {
assert((*pHisto)->elems[idx - 1].val <= val);
}
@@ -661,4 +661,4 @@ SHistogramInfo* tHistogramMerge(SHistogramInfo* pHisto1, SHistogramInfo* pHisto2
free(pHistoBins);
return pResHistogram;
-}
\ No newline at end of file
+}
diff --git a/src/query/src/qParserImpl.c b/src/query/src/qParserImpl.c
index 7e8128f200..6e4b08316d 100644
--- a/src/query/src/qParserImpl.c
+++ b/src/query/src/qParserImpl.c
@@ -872,5 +872,6 @@ void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo) {
pDBInfo->quorum = -1;
pDBInfo->keep = NULL;
+ pDBInfo->update = -1;
memset(&pDBInfo->precision, 0, sizeof(SStrToken));
}
diff --git a/src/query/src/qTokenizer.c b/src/query/src/qTokenizer.c
index d8159a27a5..98545c8ef3 100644
--- a/src/query/src/qTokenizer.c
+++ b/src/query/src/qTokenizer.c
@@ -155,6 +155,7 @@ static SKeyword keywordTable[] = {
{"INSERT", TK_INSERT},
{"INTO", TK_INTO},
{"VALUES", TK_VALUES},
+ {"UPDATE", TK_UPDATE},
{"RESET", TK_RESET},
{"QUERY", TK_QUERY},
{"ADD", TK_ADD},
@@ -664,4 +665,4 @@ void taosCleanupKeywordsTable() {
if (m != NULL && atomic_val_compare_exchange_ptr(&keywordHashTable, m, 0) == m) {
taosHashCleanup(m);
}
-}
\ No newline at end of file
+}
diff --git a/src/query/src/sql.c b/src/query/src/sql.c
index a18efdeb74..93bb9b2ee7 100644
--- a/src/query/src/sql.c
+++ b/src/query/src/sql.c
@@ -97,27 +97,27 @@
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned short int
-#define YYNOCODE 272
+#define YYNOCODE 274
#define YYACTIONTYPE unsigned short int
#define ParseTOKENTYPE SStrToken
typedef union {
int yyinit;
ParseTOKENTYPE yy0;
- SSubclauseInfo* yy25;
- tSQLExpr* yy66;
- SCreateAcctSQL yy73;
- int yy82;
- SQuerySQL* yy150;
- SCreateDBInfo yy158;
- TAOS_FIELD yy181;
- SLimitVal yy188;
- tSQLExprList* yy224;
- int64_t yy271;
- tVariant yy312;
- SIntervalVal yy314;
- SCreateTableSQL* yy374;
- tFieldList* yy449;
- tVariantList* yy494;
+ int yy46;
+ tSQLExpr* yy64;
+ tVariant yy134;
+ SCreateAcctSQL yy149;
+ int64_t yy207;
+ SLimitVal yy216;
+ TAOS_FIELD yy223;
+ SSubclauseInfo* yy231;
+ SCreateDBInfo yy268;
+ tSQLExprList* yy290;
+ SQuerySQL* yy414;
+ SCreateTableSQL* yy470;
+ tVariantList* yy498;
+ tFieldList* yy523;
+ SIntervalVal yy532;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
@@ -127,17 +127,17 @@ typedef union {
#define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo
#define ParseARG_STORE yypParser->pInfo = pInfo
#define YYFALLBACK 1
-#define YYNSTATE 252
-#define YYNRULE 230
-#define YYNTOKEN 206
-#define YY_MAX_SHIFT 251
-#define YY_MIN_SHIFTREDUCE 416
-#define YY_MAX_SHIFTREDUCE 645
-#define YY_ERROR_ACTION 646
-#define YY_ACCEPT_ACTION 647
-#define YY_NO_ACTION 648
-#define YY_MIN_REDUCE 649
-#define YY_MAX_REDUCE 878
+#define YYNSTATE 253
+#define YYNRULE 233
+#define YYNTOKEN 207
+#define YY_MAX_SHIFT 252
+#define YY_MIN_SHIFTREDUCE 420
+#define YY_MAX_SHIFTREDUCE 652
+#define YY_ERROR_ACTION 653
+#define YY_ACCEPT_ACTION 654
+#define YY_NO_ACTION 655
+#define YY_MIN_REDUCE 656
+#define YY_MAX_REDUCE 888
/************* End control #defines *******************************************/
/* Define the yytestcase() macro to be a no-op if is not already defined
@@ -203,223 +203,224 @@ typedef union {
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
-#define YY_ACTTAB_COUNT (566)
+#define YY_ACTTAB_COUNT (571)
static const YYACTIONTYPE yy_action[] = {
- /* 0 */ 751, 459, 11, 749, 750, 647, 251, 459, 752, 460,
- /* 10 */ 754, 755, 753, 35, 36, 460, 37, 38, 159, 249,
- /* 20 */ 170, 29, 141, 459, 206, 41, 39, 43, 40, 140,
- /* 30 */ 145, 460, 865, 34, 33, 862, 141, 32, 31, 30,
- /* 40 */ 35, 36, 781, 37, 38, 165, 866, 170, 29, 141,
- /* 50 */ 62, 206, 41, 39, 43, 40, 191, 525, 164, 866,
- /* 60 */ 34, 33, 27, 21, 32, 31, 30, 417, 418, 419,
- /* 70 */ 420, 421, 422, 423, 424, 425, 426, 427, 428, 250,
- /* 80 */ 35, 36, 181, 37, 38, 227, 226, 170, 29, 781,
- /* 90 */ 176, 206, 41, 39, 43, 40, 174, 162, 767, 792,
- /* 100 */ 34, 33, 56, 160, 32, 31, 30, 21, 36, 8,
- /* 110 */ 37, 38, 63, 118, 170, 29, 770, 108, 206, 41,
- /* 120 */ 39, 43, 40, 32, 31, 30, 599, 34, 33, 78,
- /* 130 */ 875, 32, 31, 30, 238, 37, 38, 108, 238, 170,
- /* 140 */ 29, 184, 766, 206, 41, 39, 43, 40, 188, 187,
- /* 150 */ 789, 177, 34, 33, 224, 223, 32, 31, 30, 16,
- /* 160 */ 218, 244, 243, 217, 216, 215, 242, 214, 241, 240,
- /* 170 */ 239, 213, 747, 818, 735, 736, 737, 738, 739, 740,
- /* 180 */ 741, 742, 743, 744, 745, 746, 169, 612, 103, 12,
- /* 190 */ 603, 17, 606, 819, 609, 201, 169, 612, 26, 108,
- /* 200 */ 603, 108, 606, 861, 609, 153, 169, 612, 173, 567,
- /* 210 */ 603, 154, 606, 105, 609, 90, 89, 148, 166, 167,
- /* 220 */ 34, 33, 205, 102, 32, 31, 30, 770, 166, 167,
- /* 230 */ 26, 21, 557, 41, 39, 43, 40, 549, 166, 167,
- /* 240 */ 194, 34, 33, 17, 193, 32, 31, 30, 860, 16,
- /* 250 */ 26, 244, 243, 203, 21, 60, 242, 61, 241, 240,
- /* 260 */ 239, 248, 247, 96, 175, 229, 767, 76, 80, 245,
- /* 270 */ 190, 554, 21, 85, 88, 79, 18, 156, 121, 122,
- /* 280 */ 605, 82, 608, 42, 70, 66, 69, 225, 770, 767,
- /* 290 */ 135, 133, 601, 42, 611, 768, 93, 92, 91, 690,
- /* 300 */ 168, 207, 131, 42, 611, 230, 545, 767, 546, 610,
- /* 310 */ 699, 157, 691, 131, 611, 131, 604, 541, 607, 610,
- /* 320 */ 538, 571, 539, 47, 540, 46, 580, 581, 602, 610,
- /* 330 */ 572, 631, 613, 50, 14, 13, 13, 531, 543, 3,
- /* 340 */ 544, 46, 48, 530, 75, 74, 811, 22, 178, 179,
- /* 350 */ 51, 211, 10, 9, 829, 22, 87, 86, 101, 99,
- /* 360 */ 158, 143, 144, 146, 147, 151, 152, 150, 139, 149,
- /* 370 */ 769, 142, 828, 171, 825, 824, 172, 791, 761, 796,
- /* 380 */ 228, 783, 798, 104, 810, 119, 120, 701, 117, 212,
- /* 390 */ 615, 137, 24, 221, 698, 26, 222, 192, 874, 72,
- /* 400 */ 873, 871, 123, 719, 25, 100, 23, 138, 566, 688,
- /* 410 */ 81, 686, 83, 84, 684, 195, 780, 683, 161, 542,
- /* 420 */ 180, 199, 132, 681, 680, 679, 52, 49, 678, 677,
- /* 430 */ 109, 134, 44, 675, 204, 673, 671, 669, 667, 202,
- /* 440 */ 200, 198, 196, 28, 136, 220, 57, 58, 812, 77,
- /* 450 */ 231, 232, 233, 234, 235, 236, 237, 246, 209, 645,
- /* 460 */ 53, 182, 183, 644, 110, 64, 67, 155, 186, 185,
- /* 470 */ 682, 643, 94, 636, 676, 189, 126, 125, 720, 124,
- /* 480 */ 127, 128, 130, 129, 95, 668, 1, 551, 193, 765,
- /* 490 */ 2, 55, 113, 111, 114, 112, 115, 116, 59, 568,
- /* 500 */ 163, 106, 197, 5, 573, 107, 6, 65, 614, 19,
- /* 510 */ 4, 20, 15, 208, 616, 7, 210, 500, 496, 494,
- /* 520 */ 493, 492, 489, 463, 219, 68, 45, 71, 73, 22,
- /* 530 */ 527, 526, 524, 54, 484, 482, 474, 480, 476, 478,
- /* 540 */ 472, 470, 499, 498, 497, 495, 491, 490, 46, 461,
- /* 550 */ 432, 430, 649, 648, 648, 648, 648, 648, 648, 648,
- /* 560 */ 648, 648, 648, 648, 97, 98,
+ /* 0 */ 108, 463, 141, 11, 654, 252, 802, 463, 140, 464,
+ /* 10 */ 162, 165, 876, 35, 36, 464, 37, 38, 159, 250,
+ /* 20 */ 170, 29, 141, 463, 206, 41, 39, 43, 40, 173,
+ /* 30 */ 780, 464, 875, 34, 33, 145, 141, 32, 31, 30,
+ /* 40 */ 35, 36, 791, 37, 38, 164, 876, 170, 29, 780,
+ /* 50 */ 21, 206, 41, 39, 43, 40, 191, 829, 799, 201,
+ /* 60 */ 34, 33, 21, 21, 32, 31, 30, 421, 422, 423,
+ /* 70 */ 424, 425, 426, 427, 428, 429, 430, 431, 432, 251,
+ /* 80 */ 35, 36, 181, 37, 38, 532, 776, 170, 29, 238,
+ /* 90 */ 246, 206, 41, 39, 43, 40, 174, 175, 777, 777,
+ /* 100 */ 34, 33, 872, 56, 32, 31, 30, 176, 871, 36,
+ /* 110 */ 780, 37, 38, 227, 226, 170, 29, 791, 17, 206,
+ /* 120 */ 41, 39, 43, 40, 108, 26, 870, 606, 34, 33,
+ /* 130 */ 78, 160, 32, 31, 30, 238, 157, 16, 218, 245,
+ /* 140 */ 244, 217, 216, 215, 243, 214, 242, 241, 240, 213,
+ /* 150 */ 239, 755, 103, 743, 744, 745, 746, 747, 748, 749,
+ /* 160 */ 750, 751, 752, 753, 754, 756, 37, 38, 229, 177,
+ /* 170 */ 170, 29, 224, 223, 206, 41, 39, 43, 40, 203,
+ /* 180 */ 62, 60, 8, 34, 33, 63, 118, 32, 31, 30,
+ /* 190 */ 169, 619, 27, 12, 610, 184, 613, 158, 616, 778,
+ /* 200 */ 169, 619, 188, 187, 610, 194, 613, 108, 616, 153,
+ /* 210 */ 169, 619, 561, 108, 610, 154, 613, 18, 616, 90,
+ /* 220 */ 89, 148, 166, 167, 34, 33, 205, 143, 32, 31,
+ /* 230 */ 30, 697, 166, 167, 131, 144, 564, 41, 39, 43,
+ /* 240 */ 40, 706, 166, 167, 131, 34, 33, 146, 17, 32,
+ /* 250 */ 31, 30, 32, 31, 30, 26, 16, 207, 245, 244,
+ /* 260 */ 21, 587, 588, 243, 828, 242, 241, 240, 698, 239,
+ /* 270 */ 61, 131, 76, 80, 147, 190, 102, 151, 85, 88,
+ /* 280 */ 79, 760, 156, 26, 758, 759, 82, 21, 42, 761,
+ /* 290 */ 556, 763, 764, 762, 225, 765, 777, 193, 42, 618,
+ /* 300 */ 249, 248, 96, 574, 121, 122, 608, 105, 42, 618,
+ /* 310 */ 70, 66, 69, 578, 617, 168, 579, 46, 152, 618,
+ /* 320 */ 14, 230, 548, 777, 617, 545, 638, 546, 150, 547,
+ /* 330 */ 13, 135, 133, 612, 617, 615, 139, 93, 92, 91,
+ /* 340 */ 620, 611, 609, 614, 13, 47, 538, 622, 50, 552,
+ /* 350 */ 46, 553, 537, 178, 179, 3, 22, 211, 75, 74,
+ /* 360 */ 149, 22, 10, 9, 48, 51, 142, 550, 885, 551,
+ /* 370 */ 87, 86, 101, 99, 779, 839, 838, 171, 835, 834,
+ /* 380 */ 172, 801, 771, 228, 806, 793, 808, 104, 821, 119,
+ /* 390 */ 820, 117, 120, 708, 212, 137, 24, 221, 705, 222,
+ /* 400 */ 26, 192, 100, 884, 72, 883, 881, 123, 726, 25,
+ /* 410 */ 573, 23, 138, 695, 49, 81, 693, 83, 84, 691,
+ /* 420 */ 790, 690, 195, 161, 199, 549, 57, 52, 180, 132,
+ /* 430 */ 688, 687, 686, 685, 684, 134, 682, 109, 680, 678,
+ /* 440 */ 44, 676, 674, 136, 204, 202, 58, 822, 200, 198,
+ /* 450 */ 196, 220, 77, 28, 231, 232, 233, 235, 652, 234,
+ /* 460 */ 236, 237, 247, 209, 183, 53, 651, 182, 185, 186,
+ /* 470 */ 64, 67, 155, 650, 643, 189, 193, 689, 558, 94,
+ /* 480 */ 683, 675, 126, 125, 727, 129, 124, 127, 128, 95,
+ /* 490 */ 130, 1, 114, 110, 111, 775, 2, 55, 59, 116,
+ /* 500 */ 112, 113, 115, 575, 106, 163, 197, 5, 580, 107,
+ /* 510 */ 6, 65, 621, 19, 4, 20, 15, 208, 623, 7,
+ /* 520 */ 210, 504, 500, 498, 497, 496, 493, 467, 219, 68,
+ /* 530 */ 45, 71, 73, 22, 534, 533, 531, 488, 54, 486,
+ /* 540 */ 478, 484, 480, 482, 476, 474, 505, 503, 502, 501,
+ /* 550 */ 499, 495, 494, 46, 465, 436, 434, 656, 655, 655,
+ /* 560 */ 655, 655, 655, 655, 655, 655, 655, 655, 655, 97,
+ /* 570 */ 98,
};
static const YYCODETYPE yy_lookahead[] = {
- /* 0 */ 226, 1, 260, 229, 230, 207, 208, 1, 234, 9,
- /* 10 */ 236, 237, 238, 13, 14, 9, 16, 17, 209, 210,
- /* 20 */ 20, 21, 260, 1, 24, 25, 26, 27, 28, 260,
- /* 30 */ 260, 9, 270, 33, 34, 260, 260, 37, 38, 39,
- /* 40 */ 13, 14, 244, 16, 17, 269, 270, 20, 21, 260,
- /* 50 */ 247, 24, 25, 26, 27, 28, 258, 5, 269, 270,
- /* 60 */ 33, 34, 259, 210, 37, 38, 39, 45, 46, 47,
+ /* 0 */ 211, 1, 262, 262, 208, 209, 211, 1, 262, 9,
+ /* 10 */ 228, 271, 272, 13, 14, 9, 16, 17, 210, 211,
+ /* 20 */ 20, 21, 262, 1, 24, 25, 26, 27, 28, 228,
+ /* 30 */ 248, 9, 272, 33, 34, 262, 262, 37, 38, 39,
+ /* 40 */ 13, 14, 246, 16, 17, 271, 272, 20, 21, 248,
+ /* 50 */ 211, 24, 25, 26, 27, 28, 260, 268, 263, 270,
+ /* 60 */ 33, 34, 211, 211, 37, 38, 39, 45, 46, 47,
/* 70 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- /* 80 */ 13, 14, 60, 16, 17, 33, 34, 20, 21, 244,
- /* 90 */ 66, 24, 25, 26, 27, 28, 243, 227, 245, 210,
- /* 100 */ 33, 34, 102, 258, 37, 38, 39, 210, 14, 98,
- /* 110 */ 16, 17, 101, 102, 20, 21, 246, 210, 24, 25,
- /* 120 */ 26, 27, 28, 37, 38, 39, 99, 33, 34, 73,
- /* 130 */ 246, 37, 38, 39, 78, 16, 17, 210, 78, 20,
- /* 140 */ 21, 126, 245, 24, 25, 26, 27, 28, 133, 134,
- /* 150 */ 261, 127, 33, 34, 130, 131, 37, 38, 39, 85,
- /* 160 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
- /* 170 */ 96, 97, 226, 266, 228, 229, 230, 231, 232, 233,
- /* 180 */ 234, 235, 236, 237, 238, 239, 1, 2, 210, 44,
- /* 190 */ 5, 98, 7, 266, 9, 268, 1, 2, 105, 210,
- /* 200 */ 5, 210, 7, 260, 9, 60, 1, 2, 227, 99,
- /* 210 */ 5, 66, 7, 103, 9, 70, 71, 72, 33, 34,
- /* 220 */ 33, 34, 37, 98, 37, 38, 39, 246, 33, 34,
- /* 230 */ 105, 210, 37, 25, 26, 27, 28, 99, 33, 34,
- /* 240 */ 262, 33, 34, 98, 106, 37, 38, 39, 260, 85,
- /* 250 */ 105, 87, 88, 264, 210, 266, 92, 266, 94, 95,
- /* 260 */ 96, 63, 64, 65, 243, 210, 245, 61, 62, 227,
- /* 270 */ 125, 103, 210, 67, 68, 69, 108, 132, 61, 62,
- /* 280 */ 5, 75, 7, 98, 67, 68, 69, 243, 246, 245,
- /* 290 */ 61, 62, 1, 98, 109, 240, 67, 68, 69, 214,
- /* 300 */ 59, 15, 217, 98, 109, 243, 5, 245, 7, 124,
- /* 310 */ 214, 260, 214, 217, 109, 217, 5, 2, 7, 124,
- /* 320 */ 5, 99, 7, 103, 9, 103, 115, 116, 37, 124,
- /* 330 */ 99, 99, 99, 103, 103, 103, 103, 99, 5, 98,
- /* 340 */ 7, 103, 122, 99, 128, 129, 267, 103, 33, 34,
- /* 350 */ 120, 99, 128, 129, 241, 103, 73, 74, 61, 62,
- /* 360 */ 260, 260, 260, 260, 260, 260, 260, 260, 260, 260,
- /* 370 */ 246, 260, 241, 241, 241, 241, 241, 210, 242, 210,
- /* 380 */ 241, 244, 210, 210, 267, 210, 210, 210, 248, 210,
- /* 390 */ 104, 210, 210, 210, 210, 105, 210, 244, 210, 210,
- /* 400 */ 210, 210, 210, 210, 210, 59, 210, 210, 109, 210,
- /* 410 */ 210, 210, 210, 210, 210, 263, 257, 210, 263, 104,
- /* 420 */ 210, 263, 210, 210, 210, 210, 119, 121, 210, 210,
- /* 430 */ 256, 210, 118, 210, 113, 210, 210, 210, 210, 117,
- /* 440 */ 112, 111, 110, 123, 210, 76, 211, 211, 211, 84,
- /* 450 */ 83, 49, 80, 82, 53, 81, 79, 76, 211, 5,
- /* 460 */ 211, 135, 5, 5, 255, 215, 215, 211, 5, 135,
- /* 470 */ 211, 5, 212, 86, 211, 126, 219, 223, 225, 224,
- /* 480 */ 222, 220, 218, 221, 212, 211, 216, 99, 106, 244,
- /* 490 */ 213, 107, 252, 254, 251, 253, 250, 249, 103, 99,
- /* 500 */ 1, 98, 98, 114, 99, 98, 114, 73, 99, 103,
- /* 510 */ 98, 103, 98, 100, 104, 98, 100, 9, 5, 5,
- /* 520 */ 5, 5, 5, 77, 15, 73, 16, 129, 129, 103,
- /* 530 */ 5, 5, 99, 98, 5, 5, 5, 5, 5, 5,
- /* 540 */ 5, 5, 5, 5, 5, 5, 5, 5, 103, 77,
- /* 550 */ 59, 58, 0, 271, 271, 271, 271, 271, 271, 271,
- /* 560 */ 271, 271, 271, 271, 21, 21, 271, 271, 271, 271,
- /* 570 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 580 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 590 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 600 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 610 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 620 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 630 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 640 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 650 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 660 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 670 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 680 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 690 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 700 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 710 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 720 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 730 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 740 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 750 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 760 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
- /* 770 */ 271, 271,
+ /* 80 */ 13, 14, 60, 16, 17, 5, 247, 20, 21, 78,
+ /* 90 */ 228, 24, 25, 26, 27, 28, 245, 245, 247, 247,
+ /* 100 */ 33, 34, 262, 103, 37, 38, 39, 66, 262, 14,
+ /* 110 */ 248, 16, 17, 33, 34, 20, 21, 246, 99, 24,
+ /* 120 */ 25, 26, 27, 28, 211, 106, 262, 100, 33, 34,
+ /* 130 */ 73, 260, 37, 38, 39, 78, 262, 85, 86, 87,
+ /* 140 */ 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
+ /* 150 */ 98, 227, 211, 229, 230, 231, 232, 233, 234, 235,
+ /* 160 */ 236, 237, 238, 239, 240, 241, 16, 17, 211, 128,
+ /* 170 */ 20, 21, 131, 132, 24, 25, 26, 27, 28, 266,
+ /* 180 */ 249, 268, 99, 33, 34, 102, 103, 37, 38, 39,
+ /* 190 */ 1, 2, 261, 44, 5, 127, 7, 262, 9, 242,
+ /* 200 */ 1, 2, 134, 135, 5, 264, 7, 211, 9, 60,
+ /* 210 */ 1, 2, 104, 211, 5, 66, 7, 109, 9, 70,
+ /* 220 */ 71, 72, 33, 34, 33, 34, 37, 262, 37, 38,
+ /* 230 */ 39, 215, 33, 34, 218, 262, 37, 25, 26, 27,
+ /* 240 */ 28, 215, 33, 34, 218, 33, 34, 262, 99, 37,
+ /* 250 */ 38, 39, 37, 38, 39, 106, 85, 15, 87, 88,
+ /* 260 */ 211, 116, 117, 92, 268, 94, 95, 96, 215, 98,
+ /* 270 */ 268, 218, 61, 62, 262, 126, 99, 262, 67, 68,
+ /* 280 */ 69, 227, 133, 106, 230, 231, 75, 211, 99, 235,
+ /* 290 */ 100, 237, 238, 239, 245, 241, 247, 107, 99, 110,
+ /* 300 */ 63, 64, 65, 100, 61, 62, 1, 104, 99, 110,
+ /* 310 */ 67, 68, 69, 100, 125, 59, 100, 104, 262, 110,
+ /* 320 */ 104, 245, 2, 247, 125, 5, 100, 7, 262, 9,
+ /* 330 */ 104, 61, 62, 5, 125, 7, 262, 67, 68, 69,
+ /* 340 */ 100, 5, 37, 7, 104, 104, 100, 105, 104, 5,
+ /* 350 */ 104, 7, 100, 33, 34, 99, 104, 100, 129, 130,
+ /* 360 */ 262, 104, 129, 130, 123, 121, 262, 5, 248, 7,
+ /* 370 */ 73, 74, 61, 62, 248, 243, 243, 243, 243, 243,
+ /* 380 */ 243, 211, 244, 243, 211, 246, 211, 211, 269, 211,
+ /* 390 */ 269, 250, 211, 211, 211, 211, 211, 211, 211, 211,
+ /* 400 */ 106, 246, 59, 211, 211, 211, 211, 211, 211, 211,
+ /* 410 */ 110, 211, 211, 211, 122, 211, 211, 211, 211, 211,
+ /* 420 */ 259, 211, 265, 265, 265, 105, 212, 120, 211, 211,
+ /* 430 */ 211, 211, 211, 211, 211, 211, 211, 258, 211, 211,
+ /* 440 */ 119, 211, 211, 211, 114, 118, 212, 212, 113, 112,
+ /* 450 */ 111, 76, 84, 124, 83, 49, 80, 53, 5, 82,
+ /* 460 */ 81, 79, 76, 212, 5, 212, 5, 136, 136, 5,
+ /* 470 */ 216, 216, 212, 5, 86, 127, 107, 212, 100, 213,
+ /* 480 */ 212, 212, 220, 224, 226, 222, 225, 223, 221, 213,
+ /* 490 */ 219, 217, 253, 257, 256, 246, 214, 108, 104, 251,
+ /* 500 */ 255, 254, 252, 100, 99, 1, 99, 115, 100, 99,
+ /* 510 */ 115, 73, 100, 104, 99, 104, 99, 101, 105, 99,
+ /* 520 */ 101, 9, 5, 5, 5, 5, 5, 77, 15, 73,
+ /* 530 */ 16, 130, 130, 104, 5, 5, 100, 5, 99, 5,
+ /* 540 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ /* 550 */ 5, 5, 5, 104, 77, 59, 58, 0, 273, 273,
+ /* 560 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 21,
+ /* 570 */ 21, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 580 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 590 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 600 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 610 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 620 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 630 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 640 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 650 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 660 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 670 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 680 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 690 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 700 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 710 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 720 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 730 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 740 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 750 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 760 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273,
+ /* 770 */ 273, 273, 273, 273, 273, 273, 273, 273,
};
-#define YY_SHIFT_COUNT (251)
+#define YY_SHIFT_COUNT (252)
#define YY_SHIFT_MIN (0)
-#define YY_SHIFT_MAX (552)
+#define YY_SHIFT_MAX (557)
static const unsigned short int yy_shift_ofst[] = {
- /* 0 */ 145, 74, 164, 185, 205, 6, 6, 6, 6, 6,
- /* 10 */ 6, 0, 22, 205, 315, 315, 315, 93, 6, 6,
- /* 20 */ 6, 6, 6, 56, 60, 60, 566, 195, 205, 205,
- /* 30 */ 205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
- /* 40 */ 205, 205, 205, 205, 205, 315, 315, 52, 52, 52,
- /* 50 */ 52, 52, 52, 11, 52, 125, 6, 6, 6, 6,
- /* 60 */ 211, 211, 168, 6, 6, 6, 6, 6, 6, 6,
+ /* 0 */ 149, 52, 171, 189, 209, 6, 6, 6, 6, 6,
+ /* 10 */ 6, 0, 22, 209, 320, 320, 320, 19, 6, 6,
+ /* 20 */ 6, 6, 6, 57, 11, 11, 571, 199, 209, 209,
+ /* 30 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
+ /* 40 */ 209, 209, 209, 209, 209, 320, 320, 80, 80, 80,
+ /* 50 */ 80, 80, 80, 83, 80, 177, 6, 6, 6, 6,
+ /* 60 */ 145, 145, 108, 6, 6, 6, 6, 6, 6, 6,
/* 70 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
/* 80 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
/* 90 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- /* 100 */ 6, 6, 290, 346, 346, 299, 299, 299, 346, 307,
- /* 110 */ 306, 314, 321, 322, 328, 330, 332, 320, 290, 346,
- /* 120 */ 346, 369, 369, 346, 365, 367, 402, 372, 371, 401,
- /* 130 */ 374, 377, 346, 381, 346, 381, 346, 566, 566, 27,
- /* 140 */ 67, 67, 67, 94, 119, 208, 208, 208, 206, 187,
- /* 150 */ 187, 187, 187, 217, 229, 24, 15, 86, 86, 198,
- /* 160 */ 138, 110, 222, 231, 232, 233, 275, 311, 291, 241,
- /* 170 */ 286, 220, 230, 238, 244, 252, 216, 224, 301, 333,
- /* 180 */ 283, 297, 454, 326, 457, 458, 334, 463, 466, 387,
- /* 190 */ 349, 382, 388, 384, 395, 400, 403, 499, 404, 405,
- /* 200 */ 407, 406, 389, 408, 392, 409, 412, 410, 414, 413,
- /* 210 */ 417, 416, 434, 508, 513, 514, 515, 516, 517, 446,
- /* 220 */ 509, 452, 510, 398, 399, 426, 525, 526, 433, 435,
- /* 230 */ 426, 529, 530, 531, 532, 533, 534, 535, 536, 537,
- /* 240 */ 538, 539, 540, 541, 542, 445, 472, 543, 544, 491,
- /* 250 */ 493, 552,
+ /* 100 */ 6, 6, 294, 343, 343, 300, 300, 300, 343, 307,
+ /* 110 */ 292, 321, 330, 327, 335, 337, 339, 329, 294, 343,
+ /* 120 */ 343, 375, 375, 343, 368, 371, 406, 376, 377, 404,
+ /* 130 */ 379, 382, 343, 386, 343, 386, 343, 571, 571, 27,
+ /* 140 */ 67, 67, 67, 95, 150, 212, 212, 212, 211, 191,
+ /* 150 */ 191, 191, 191, 243, 270, 41, 68, 215, 215, 237,
+ /* 160 */ 190, 203, 213, 216, 226, 240, 328, 336, 305, 256,
+ /* 170 */ 242, 241, 244, 246, 252, 257, 229, 233, 344, 362,
+ /* 180 */ 297, 311, 453, 331, 459, 461, 332, 464, 468, 388,
+ /* 190 */ 348, 369, 378, 389, 394, 403, 405, 504, 407, 408,
+ /* 200 */ 410, 409, 392, 411, 395, 412, 415, 413, 417, 416,
+ /* 210 */ 420, 419, 438, 512, 517, 518, 519, 520, 521, 450,
+ /* 220 */ 513, 456, 514, 401, 402, 429, 529, 530, 436, 439,
+ /* 230 */ 429, 532, 534, 535, 536, 537, 538, 539, 540, 541,
+ /* 240 */ 542, 543, 544, 545, 546, 547, 449, 477, 548, 549,
+ /* 250 */ 496, 498, 557,
};
#define YY_REDUCE_COUNT (138)
-#define YY_REDUCE_MIN (-258)
-#define YY_REDUCE_MAX (277)
+#define YY_REDUCE_MIN (-260)
+#define YY_REDUCE_MAX (282)
static const short yy_reduce_ofst[] = {
- /* 0 */ -202, -54, -226, -224, -211, -73, -11, -147, 21, 44,
- /* 10 */ 62, -111, -191, -238, -130, -19, 42, -155, -22, -93,
- /* 20 */ -9, 55, -103, 85, 96, 98, -197, -258, -231, -230,
- /* 30 */ -225, -57, -12, 51, 100, 101, 102, 103, 104, 105,
- /* 40 */ 106, 107, 108, 109, 111, -116, 124, 113, 131, 132,
- /* 50 */ 133, 134, 135, 136, 139, 137, 167, 169, 172, 173,
- /* 60 */ 79, 117, 140, 175, 176, 177, 179, 181, 182, 183,
- /* 70 */ 184, 186, 188, 189, 190, 191, 192, 193, 194, 196,
- /* 80 */ 197, 199, 200, 201, 202, 203, 204, 207, 210, 212,
- /* 90 */ 213, 214, 215, 218, 219, 221, 223, 225, 226, 227,
- /* 100 */ 228, 234, 153, 235, 236, 152, 155, 158, 237, 159,
- /* 110 */ 174, 209, 239, 242, 240, 243, 246, 248, 245, 247,
- /* 120 */ 249, 250, 251, 256, 253, 255, 254, 257, 258, 261,
- /* 130 */ 262, 264, 259, 260, 263, 272, 274, 270, 277,
+ /* 0 */ -204, -76, 54, -260, -226, -211, -87, -149, -148, 49,
+ /* 10 */ 76, -205, -192, -240, -218, -199, -138, -129, -59, -4,
+ /* 20 */ 2, -43, -161, 16, 26, 53, -69, -259, -254, -227,
+ /* 30 */ -160, -154, -136, -126, -65, -35, -27, -15, 12, 15,
+ /* 40 */ 56, 66, 74, 98, 104, 120, 126, 132, 133, 134,
+ /* 50 */ 135, 136, 137, 138, 140, 139, 170, 173, 175, 176,
+ /* 60 */ 119, 121, 141, 178, 181, 182, 183, 184, 185, 186,
+ /* 70 */ 187, 188, 192, 193, 194, 195, 196, 197, 198, 200,
+ /* 80 */ 201, 202, 204, 205, 206, 207, 208, 210, 217, 218,
+ /* 90 */ 219, 220, 221, 222, 223, 224, 225, 227, 228, 230,
+ /* 100 */ 231, 232, 155, 214, 234, 157, 158, 159, 235, 161,
+ /* 110 */ 179, 236, 238, 245, 247, 239, 250, 248, 249, 251,
+ /* 120 */ 253, 254, 255, 260, 258, 261, 259, 262, 264, 267,
+ /* 130 */ 263, 271, 265, 266, 268, 276, 269, 274, 282,
};
static const YYACTIONTYPE yy_default[] = {
- /* 0 */ 646, 700, 689, 868, 868, 646, 646, 646, 646, 646,
- /* 10 */ 646, 793, 664, 868, 646, 646, 646, 646, 646, 646,
- /* 20 */ 646, 646, 646, 702, 702, 702, 788, 646, 646, 646,
- /* 30 */ 646, 646, 646, 646, 646, 646, 646, 646, 646, 646,
- /* 40 */ 646, 646, 646, 646, 646, 646, 646, 646, 646, 646,
- /* 50 */ 646, 646, 646, 646, 646, 646, 646, 795, 797, 646,
- /* 60 */ 815, 815, 786, 646, 646, 646, 646, 646, 646, 646,
- /* 70 */ 646, 646, 646, 646, 646, 646, 646, 646, 646, 646,
- /* 80 */ 646, 687, 646, 685, 646, 646, 646, 646, 646, 646,
- /* 90 */ 646, 646, 646, 646, 646, 646, 674, 646, 646, 646,
- /* 100 */ 646, 646, 646, 666, 666, 646, 646, 646, 666, 822,
- /* 110 */ 826, 820, 808, 816, 807, 803, 802, 830, 646, 666,
- /* 120 */ 666, 697, 697, 666, 718, 716, 714, 706, 712, 708,
- /* 130 */ 710, 704, 666, 695, 666, 695, 666, 734, 748, 646,
- /* 140 */ 831, 867, 821, 857, 856, 863, 855, 854, 646, 850,
- /* 150 */ 851, 853, 852, 646, 646, 646, 646, 859, 858, 646,
- /* 160 */ 646, 646, 646, 646, 646, 646, 646, 646, 646, 833,
- /* 170 */ 646, 827, 823, 646, 646, 646, 646, 646, 646, 646,
- /* 180 */ 646, 646, 646, 646, 646, 646, 646, 646, 646, 646,
- /* 190 */ 646, 785, 646, 646, 794, 646, 646, 646, 646, 646,
- /* 200 */ 646, 817, 646, 809, 646, 646, 646, 646, 646, 646,
- /* 210 */ 646, 762, 646, 646, 646, 646, 646, 646, 646, 646,
- /* 220 */ 646, 646, 646, 646, 646, 872, 646, 646, 646, 756,
- /* 230 */ 870, 646, 646, 646, 646, 646, 646, 646, 646, 646,
- /* 240 */ 646, 646, 646, 646, 646, 721, 646, 672, 670, 646,
- /* 250 */ 662, 646,
+ /* 0 */ 653, 707, 696, 878, 878, 653, 653, 653, 653, 653,
+ /* 10 */ 653, 803, 671, 878, 653, 653, 653, 653, 653, 653,
+ /* 20 */ 653, 653, 653, 709, 709, 709, 798, 653, 653, 653,
+ /* 30 */ 653, 653, 653, 653, 653, 653, 653, 653, 653, 653,
+ /* 40 */ 653, 653, 653, 653, 653, 653, 653, 653, 653, 653,
+ /* 50 */ 653, 653, 653, 653, 653, 653, 653, 805, 807, 653,
+ /* 60 */ 825, 825, 796, 653, 653, 653, 653, 653, 653, 653,
+ /* 70 */ 653, 653, 653, 653, 653, 653, 653, 653, 653, 653,
+ /* 80 */ 653, 694, 653, 692, 653, 653, 653, 653, 653, 653,
+ /* 90 */ 653, 653, 653, 653, 653, 653, 681, 653, 653, 653,
+ /* 100 */ 653, 653, 653, 673, 673, 653, 653, 653, 673, 832,
+ /* 110 */ 836, 830, 818, 826, 817, 813, 812, 840, 653, 673,
+ /* 120 */ 673, 704, 704, 673, 725, 723, 721, 713, 719, 715,
+ /* 130 */ 717, 711, 673, 702, 673, 702, 673, 742, 757, 653,
+ /* 140 */ 841, 877, 831, 867, 866, 873, 865, 864, 653, 860,
+ /* 150 */ 861, 863, 862, 653, 653, 653, 653, 869, 868, 653,
+ /* 160 */ 653, 653, 653, 653, 653, 653, 653, 653, 653, 843,
+ /* 170 */ 653, 837, 833, 653, 653, 653, 653, 653, 653, 653,
+ /* 180 */ 653, 653, 653, 653, 653, 653, 653, 653, 653, 653,
+ /* 190 */ 653, 795, 653, 653, 804, 653, 653, 653, 653, 653,
+ /* 200 */ 653, 827, 653, 819, 653, 653, 653, 653, 653, 653,
+ /* 210 */ 653, 772, 653, 653, 653, 653, 653, 653, 653, 653,
+ /* 220 */ 653, 653, 653, 653, 653, 882, 653, 653, 653, 766,
+ /* 230 */ 880, 653, 653, 653, 653, 653, 653, 653, 653, 653,
+ /* 240 */ 653, 653, 653, 653, 653, 653, 728, 653, 679, 677,
+ /* 250 */ 653, 669, 653,
};
/********** End of lemon-generated parsing tables *****************************/
@@ -537,6 +538,7 @@ static const YYCODETYPE yyFallback[] = {
0, /* FSYNC => nothing */
0, /* COMP => nothing */
0, /* PRECISION => nothing */
+ 0, /* UPDATE => nothing */
0, /* LP => nothing */
0, /* RP => nothing */
0, /* TAGS => nothing */
@@ -829,179 +831,181 @@ static const char *const yyTokenName[] = {
/* 95 */ "FSYNC",
/* 96 */ "COMP",
/* 97 */ "PRECISION",
- /* 98 */ "LP",
- /* 99 */ "RP",
- /* 100 */ "TAGS",
- /* 101 */ "USING",
- /* 102 */ "AS",
- /* 103 */ "COMMA",
- /* 104 */ "NULL",
- /* 105 */ "SELECT",
- /* 106 */ "UNION",
- /* 107 */ "ALL",
- /* 108 */ "FROM",
- /* 109 */ "VARIABLE",
- /* 110 */ "INTERVAL",
- /* 111 */ "FILL",
- /* 112 */ "SLIDING",
- /* 113 */ "ORDER",
- /* 114 */ "BY",
- /* 115 */ "ASC",
- /* 116 */ "DESC",
- /* 117 */ "GROUP",
- /* 118 */ "HAVING",
- /* 119 */ "LIMIT",
- /* 120 */ "OFFSET",
- /* 121 */ "SLIMIT",
- /* 122 */ "SOFFSET",
- /* 123 */ "WHERE",
- /* 124 */ "NOW",
- /* 125 */ "RESET",
- /* 126 */ "QUERY",
- /* 127 */ "ADD",
- /* 128 */ "COLUMN",
- /* 129 */ "TAG",
- /* 130 */ "CHANGE",
- /* 131 */ "SET",
- /* 132 */ "KILL",
- /* 133 */ "CONNECTION",
- /* 134 */ "STREAM",
- /* 135 */ "COLON",
- /* 136 */ "ABORT",
- /* 137 */ "AFTER",
- /* 138 */ "ATTACH",
- /* 139 */ "BEFORE",
- /* 140 */ "BEGIN",
- /* 141 */ "CASCADE",
- /* 142 */ "CLUSTER",
- /* 143 */ "CONFLICT",
- /* 144 */ "COPY",
- /* 145 */ "DEFERRED",
- /* 146 */ "DELIMITERS",
- /* 147 */ "DETACH",
- /* 148 */ "EACH",
- /* 149 */ "END",
- /* 150 */ "EXPLAIN",
- /* 151 */ "FAIL",
- /* 152 */ "FOR",
- /* 153 */ "IGNORE",
- /* 154 */ "IMMEDIATE",
- /* 155 */ "INITIALLY",
- /* 156 */ "INSTEAD",
- /* 157 */ "MATCH",
- /* 158 */ "KEY",
- /* 159 */ "OF",
- /* 160 */ "RAISE",
- /* 161 */ "REPLACE",
- /* 162 */ "RESTRICT",
- /* 163 */ "ROW",
- /* 164 */ "STATEMENT",
- /* 165 */ "TRIGGER",
- /* 166 */ "VIEW",
- /* 167 */ "COUNT",
- /* 168 */ "SUM",
- /* 169 */ "AVG",
- /* 170 */ "MIN",
- /* 171 */ "MAX",
- /* 172 */ "FIRST",
- /* 173 */ "LAST",
- /* 174 */ "TOP",
- /* 175 */ "BOTTOM",
- /* 176 */ "STDDEV",
- /* 177 */ "PERCENTILE",
- /* 178 */ "APERCENTILE",
- /* 179 */ "LEASTSQUARES",
- /* 180 */ "HISTOGRAM",
- /* 181 */ "DIFF",
- /* 182 */ "SPREAD",
- /* 183 */ "TWA",
- /* 184 */ "INTERP",
- /* 185 */ "LAST_ROW",
- /* 186 */ "RATE",
- /* 187 */ "IRATE",
- /* 188 */ "SUM_RATE",
- /* 189 */ "SUM_IRATE",
- /* 190 */ "AVG_RATE",
- /* 191 */ "AVG_IRATE",
- /* 192 */ "TBID",
- /* 193 */ "SEMI",
- /* 194 */ "NONE",
- /* 195 */ "PREV",
- /* 196 */ "LINEAR",
- /* 197 */ "IMPORT",
- /* 198 */ "METRIC",
- /* 199 */ "TBNAME",
- /* 200 */ "JOIN",
- /* 201 */ "METRICS",
- /* 202 */ "STABLE",
- /* 203 */ "INSERT",
- /* 204 */ "INTO",
- /* 205 */ "VALUES",
- /* 206 */ "error",
- /* 207 */ "program",
- /* 208 */ "cmd",
- /* 209 */ "dbPrefix",
- /* 210 */ "ids",
- /* 211 */ "cpxName",
- /* 212 */ "ifexists",
- /* 213 */ "alter_db_optr",
- /* 214 */ "acct_optr",
- /* 215 */ "ifnotexists",
- /* 216 */ "db_optr",
- /* 217 */ "pps",
- /* 218 */ "tseries",
- /* 219 */ "dbs",
- /* 220 */ "streams",
- /* 221 */ "storage",
- /* 222 */ "qtime",
- /* 223 */ "users",
- /* 224 */ "conns",
- /* 225 */ "state",
- /* 226 */ "keep",
- /* 227 */ "tagitemlist",
- /* 228 */ "cache",
- /* 229 */ "replica",
- /* 230 */ "quorum",
- /* 231 */ "days",
- /* 232 */ "minrows",
- /* 233 */ "maxrows",
- /* 234 */ "blocks",
- /* 235 */ "ctime",
- /* 236 */ "wal",
- /* 237 */ "fsync",
- /* 238 */ "comp",
- /* 239 */ "prec",
- /* 240 */ "typename",
- /* 241 */ "signed",
- /* 242 */ "create_table_args",
- /* 243 */ "columnlist",
- /* 244 */ "select",
- /* 245 */ "column",
- /* 246 */ "tagitem",
- /* 247 */ "selcollist",
- /* 248 */ "from",
- /* 249 */ "where_opt",
- /* 250 */ "interval_opt",
- /* 251 */ "fill_opt",
- /* 252 */ "sliding_opt",
- /* 253 */ "groupby_opt",
- /* 254 */ "orderby_opt",
- /* 255 */ "having_opt",
- /* 256 */ "slimit_opt",
- /* 257 */ "limit_opt",
- /* 258 */ "union",
- /* 259 */ "sclp",
- /* 260 */ "expr",
- /* 261 */ "as",
- /* 262 */ "tablelist",
- /* 263 */ "tmvar",
- /* 264 */ "sortlist",
- /* 265 */ "sortitem",
- /* 266 */ "item",
- /* 267 */ "sortorder",
- /* 268 */ "grouplist",
- /* 269 */ "exprlist",
- /* 270 */ "expritem",
+ /* 98 */ "UPDATE",
+ /* 99 */ "LP",
+ /* 100 */ "RP",
+ /* 101 */ "TAGS",
+ /* 102 */ "USING",
+ /* 103 */ "AS",
+ /* 104 */ "COMMA",
+ /* 105 */ "NULL",
+ /* 106 */ "SELECT",
+ /* 107 */ "UNION",
+ /* 108 */ "ALL",
+ /* 109 */ "FROM",
+ /* 110 */ "VARIABLE",
+ /* 111 */ "INTERVAL",
+ /* 112 */ "FILL",
+ /* 113 */ "SLIDING",
+ /* 114 */ "ORDER",
+ /* 115 */ "BY",
+ /* 116 */ "ASC",
+ /* 117 */ "DESC",
+ /* 118 */ "GROUP",
+ /* 119 */ "HAVING",
+ /* 120 */ "LIMIT",
+ /* 121 */ "OFFSET",
+ /* 122 */ "SLIMIT",
+ /* 123 */ "SOFFSET",
+ /* 124 */ "WHERE",
+ /* 125 */ "NOW",
+ /* 126 */ "RESET",
+ /* 127 */ "QUERY",
+ /* 128 */ "ADD",
+ /* 129 */ "COLUMN",
+ /* 130 */ "TAG",
+ /* 131 */ "CHANGE",
+ /* 132 */ "SET",
+ /* 133 */ "KILL",
+ /* 134 */ "CONNECTION",
+ /* 135 */ "STREAM",
+ /* 136 */ "COLON",
+ /* 137 */ "ABORT",
+ /* 138 */ "AFTER",
+ /* 139 */ "ATTACH",
+ /* 140 */ "BEFORE",
+ /* 141 */ "BEGIN",
+ /* 142 */ "CASCADE",
+ /* 143 */ "CLUSTER",
+ /* 144 */ "CONFLICT",
+ /* 145 */ "COPY",
+ /* 146 */ "DEFERRED",
+ /* 147 */ "DELIMITERS",
+ /* 148 */ "DETACH",
+ /* 149 */ "EACH",
+ /* 150 */ "END",
+ /* 151 */ "EXPLAIN",
+ /* 152 */ "FAIL",
+ /* 153 */ "FOR",
+ /* 154 */ "IGNORE",
+ /* 155 */ "IMMEDIATE",
+ /* 156 */ "INITIALLY",
+ /* 157 */ "INSTEAD",
+ /* 158 */ "MATCH",
+ /* 159 */ "KEY",
+ /* 160 */ "OF",
+ /* 161 */ "RAISE",
+ /* 162 */ "REPLACE",
+ /* 163 */ "RESTRICT",
+ /* 164 */ "ROW",
+ /* 165 */ "STATEMENT",
+ /* 166 */ "TRIGGER",
+ /* 167 */ "VIEW",
+ /* 168 */ "COUNT",
+ /* 169 */ "SUM",
+ /* 170 */ "AVG",
+ /* 171 */ "MIN",
+ /* 172 */ "MAX",
+ /* 173 */ "FIRST",
+ /* 174 */ "LAST",
+ /* 175 */ "TOP",
+ /* 176 */ "BOTTOM",
+ /* 177 */ "STDDEV",
+ /* 178 */ "PERCENTILE",
+ /* 179 */ "APERCENTILE",
+ /* 180 */ "LEASTSQUARES",
+ /* 181 */ "HISTOGRAM",
+ /* 182 */ "DIFF",
+ /* 183 */ "SPREAD",
+ /* 184 */ "TWA",
+ /* 185 */ "INTERP",
+ /* 186 */ "LAST_ROW",
+ /* 187 */ "RATE",
+ /* 188 */ "IRATE",
+ /* 189 */ "SUM_RATE",
+ /* 190 */ "SUM_IRATE",
+ /* 191 */ "AVG_RATE",
+ /* 192 */ "AVG_IRATE",
+ /* 193 */ "TBID",
+ /* 194 */ "SEMI",
+ /* 195 */ "NONE",
+ /* 196 */ "PREV",
+ /* 197 */ "LINEAR",
+ /* 198 */ "IMPORT",
+ /* 199 */ "METRIC",
+ /* 200 */ "TBNAME",
+ /* 201 */ "JOIN",
+ /* 202 */ "METRICS",
+ /* 203 */ "STABLE",
+ /* 204 */ "INSERT",
+ /* 205 */ "INTO",
+ /* 206 */ "VALUES",
+ /* 207 */ "error",
+ /* 208 */ "program",
+ /* 209 */ "cmd",
+ /* 210 */ "dbPrefix",
+ /* 211 */ "ids",
+ /* 212 */ "cpxName",
+ /* 213 */ "ifexists",
+ /* 214 */ "alter_db_optr",
+ /* 215 */ "acct_optr",
+ /* 216 */ "ifnotexists",
+ /* 217 */ "db_optr",
+ /* 218 */ "pps",
+ /* 219 */ "tseries",
+ /* 220 */ "dbs",
+ /* 221 */ "streams",
+ /* 222 */ "storage",
+ /* 223 */ "qtime",
+ /* 224 */ "users",
+ /* 225 */ "conns",
+ /* 226 */ "state",
+ /* 227 */ "keep",
+ /* 228 */ "tagitemlist",
+ /* 229 */ "cache",
+ /* 230 */ "replica",
+ /* 231 */ "quorum",
+ /* 232 */ "days",
+ /* 233 */ "minrows",
+ /* 234 */ "maxrows",
+ /* 235 */ "blocks",
+ /* 236 */ "ctime",
+ /* 237 */ "wal",
+ /* 238 */ "fsync",
+ /* 239 */ "comp",
+ /* 240 */ "prec",
+ /* 241 */ "update",
+ /* 242 */ "typename",
+ /* 243 */ "signed",
+ /* 244 */ "create_table_args",
+ /* 245 */ "columnlist",
+ /* 246 */ "select",
+ /* 247 */ "column",
+ /* 248 */ "tagitem",
+ /* 249 */ "selcollist",
+ /* 250 */ "from",
+ /* 251 */ "where_opt",
+ /* 252 */ "interval_opt",
+ /* 253 */ "fill_opt",
+ /* 254 */ "sliding_opt",
+ /* 255 */ "groupby_opt",
+ /* 256 */ "orderby_opt",
+ /* 257 */ "having_opt",
+ /* 258 */ "slimit_opt",
+ /* 259 */ "limit_opt",
+ /* 260 */ "union",
+ /* 261 */ "sclp",
+ /* 262 */ "expr",
+ /* 263 */ "as",
+ /* 264 */ "tablelist",
+ /* 265 */ "tmvar",
+ /* 266 */ "sortlist",
+ /* 267 */ "sortitem",
+ /* 268 */ "item",
+ /* 269 */ "sortorder",
+ /* 270 */ "grouplist",
+ /* 271 */ "exprlist",
+ /* 272 */ "expritem",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
@@ -1094,151 +1098,154 @@ static const char *const yyRuleName[] = {
/* 82 */ "fsync ::= FSYNC INTEGER",
/* 83 */ "comp ::= COMP INTEGER",
/* 84 */ "prec ::= PRECISION STRING",
- /* 85 */ "db_optr ::=",
- /* 86 */ "db_optr ::= db_optr cache",
- /* 87 */ "db_optr ::= db_optr replica",
- /* 88 */ "db_optr ::= db_optr quorum",
- /* 89 */ "db_optr ::= db_optr days",
- /* 90 */ "db_optr ::= db_optr minrows",
- /* 91 */ "db_optr ::= db_optr maxrows",
- /* 92 */ "db_optr ::= db_optr blocks",
- /* 93 */ "db_optr ::= db_optr ctime",
- /* 94 */ "db_optr ::= db_optr wal",
- /* 95 */ "db_optr ::= db_optr fsync",
- /* 96 */ "db_optr ::= db_optr comp",
- /* 97 */ "db_optr ::= db_optr prec",
- /* 98 */ "db_optr ::= db_optr keep",
- /* 99 */ "alter_db_optr ::=",
- /* 100 */ "alter_db_optr ::= alter_db_optr replica",
- /* 101 */ "alter_db_optr ::= alter_db_optr quorum",
- /* 102 */ "alter_db_optr ::= alter_db_optr keep",
- /* 103 */ "alter_db_optr ::= alter_db_optr blocks",
- /* 104 */ "alter_db_optr ::= alter_db_optr comp",
- /* 105 */ "alter_db_optr ::= alter_db_optr wal",
- /* 106 */ "alter_db_optr ::= alter_db_optr fsync",
- /* 107 */ "typename ::= ids",
- /* 108 */ "typename ::= ids LP signed RP",
- /* 109 */ "signed ::= INTEGER",
- /* 110 */ "signed ::= PLUS INTEGER",
- /* 111 */ "signed ::= MINUS INTEGER",
- /* 112 */ "cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args",
- /* 113 */ "create_table_args ::= LP columnlist RP",
- /* 114 */ "create_table_args ::= LP columnlist RP TAGS LP columnlist RP",
- /* 115 */ "create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP",
- /* 116 */ "create_table_args ::= AS select",
- /* 117 */ "columnlist ::= columnlist COMMA column",
- /* 118 */ "columnlist ::= column",
- /* 119 */ "column ::= ids typename",
- /* 120 */ "tagitemlist ::= tagitemlist COMMA tagitem",
- /* 121 */ "tagitemlist ::= tagitem",
- /* 122 */ "tagitem ::= INTEGER",
- /* 123 */ "tagitem ::= FLOAT",
- /* 124 */ "tagitem ::= STRING",
- /* 125 */ "tagitem ::= BOOL",
- /* 126 */ "tagitem ::= NULL",
- /* 127 */ "tagitem ::= MINUS INTEGER",
- /* 128 */ "tagitem ::= MINUS FLOAT",
- /* 129 */ "tagitem ::= PLUS INTEGER",
- /* 130 */ "tagitem ::= PLUS FLOAT",
- /* 131 */ "select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt",
- /* 132 */ "union ::= select",
- /* 133 */ "union ::= LP union RP",
- /* 134 */ "union ::= union UNION ALL select",
- /* 135 */ "union ::= union UNION ALL LP select RP",
- /* 136 */ "cmd ::= union",
- /* 137 */ "select ::= SELECT selcollist",
- /* 138 */ "sclp ::= selcollist COMMA",
- /* 139 */ "sclp ::=",
- /* 140 */ "selcollist ::= sclp expr as",
- /* 141 */ "selcollist ::= sclp STAR",
- /* 142 */ "as ::= AS ids",
- /* 143 */ "as ::= ids",
- /* 144 */ "as ::=",
- /* 145 */ "from ::= FROM tablelist",
- /* 146 */ "tablelist ::= ids cpxName",
- /* 147 */ "tablelist ::= ids cpxName ids",
- /* 148 */ "tablelist ::= tablelist COMMA ids cpxName",
- /* 149 */ "tablelist ::= tablelist COMMA ids cpxName ids",
- /* 150 */ "tmvar ::= VARIABLE",
- /* 151 */ "interval_opt ::= INTERVAL LP tmvar RP",
- /* 152 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP",
- /* 153 */ "interval_opt ::=",
- /* 154 */ "fill_opt ::=",
- /* 155 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP",
- /* 156 */ "fill_opt ::= FILL LP ID RP",
- /* 157 */ "sliding_opt ::= SLIDING LP tmvar RP",
- /* 158 */ "sliding_opt ::=",
- /* 159 */ "orderby_opt ::=",
- /* 160 */ "orderby_opt ::= ORDER BY sortlist",
- /* 161 */ "sortlist ::= sortlist COMMA item sortorder",
- /* 162 */ "sortlist ::= item sortorder",
- /* 163 */ "item ::= ids cpxName",
- /* 164 */ "sortorder ::= ASC",
- /* 165 */ "sortorder ::= DESC",
- /* 166 */ "sortorder ::=",
- /* 167 */ "groupby_opt ::=",
- /* 168 */ "groupby_opt ::= GROUP BY grouplist",
- /* 169 */ "grouplist ::= grouplist COMMA item",
- /* 170 */ "grouplist ::= item",
- /* 171 */ "having_opt ::=",
- /* 172 */ "having_opt ::= HAVING expr",
- /* 173 */ "limit_opt ::=",
- /* 174 */ "limit_opt ::= LIMIT signed",
- /* 175 */ "limit_opt ::= LIMIT signed OFFSET signed",
- /* 176 */ "limit_opt ::= LIMIT signed COMMA signed",
- /* 177 */ "slimit_opt ::=",
- /* 178 */ "slimit_opt ::= SLIMIT signed",
- /* 179 */ "slimit_opt ::= SLIMIT signed SOFFSET signed",
- /* 180 */ "slimit_opt ::= SLIMIT signed COMMA signed",
- /* 181 */ "where_opt ::=",
- /* 182 */ "where_opt ::= WHERE expr",
- /* 183 */ "expr ::= LP expr RP",
- /* 184 */ "expr ::= ID",
- /* 185 */ "expr ::= ID DOT ID",
- /* 186 */ "expr ::= ID DOT STAR",
- /* 187 */ "expr ::= INTEGER",
- /* 188 */ "expr ::= MINUS INTEGER",
- /* 189 */ "expr ::= PLUS INTEGER",
- /* 190 */ "expr ::= FLOAT",
- /* 191 */ "expr ::= MINUS FLOAT",
- /* 192 */ "expr ::= PLUS FLOAT",
- /* 193 */ "expr ::= STRING",
- /* 194 */ "expr ::= NOW",
- /* 195 */ "expr ::= VARIABLE",
- /* 196 */ "expr ::= BOOL",
- /* 197 */ "expr ::= ID LP exprlist RP",
- /* 198 */ "expr ::= ID LP STAR RP",
- /* 199 */ "expr ::= expr IS NULL",
- /* 200 */ "expr ::= expr IS NOT NULL",
- /* 201 */ "expr ::= expr LT expr",
- /* 202 */ "expr ::= expr GT expr",
- /* 203 */ "expr ::= expr LE expr",
- /* 204 */ "expr ::= expr GE expr",
- /* 205 */ "expr ::= expr NE expr",
- /* 206 */ "expr ::= expr EQ expr",
- /* 207 */ "expr ::= expr AND expr",
- /* 208 */ "expr ::= expr OR expr",
- /* 209 */ "expr ::= expr PLUS expr",
- /* 210 */ "expr ::= expr MINUS expr",
- /* 211 */ "expr ::= expr STAR expr",
- /* 212 */ "expr ::= expr SLASH expr",
- /* 213 */ "expr ::= expr REM expr",
- /* 214 */ "expr ::= expr LIKE expr",
- /* 215 */ "expr ::= expr IN LP exprlist RP",
- /* 216 */ "exprlist ::= exprlist COMMA expritem",
- /* 217 */ "exprlist ::= expritem",
- /* 218 */ "expritem ::= expr",
- /* 219 */ "expritem ::=",
- /* 220 */ "cmd ::= RESET QUERY CACHE",
- /* 221 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist",
- /* 222 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids",
- /* 223 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist",
- /* 224 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids",
- /* 225 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids",
- /* 226 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem",
- /* 227 */ "cmd ::= KILL CONNECTION INTEGER",
- /* 228 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER",
- /* 229 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER",
+ /* 85 */ "update ::= UPDATE INTEGER",
+ /* 86 */ "db_optr ::=",
+ /* 87 */ "db_optr ::= db_optr cache",
+ /* 88 */ "db_optr ::= db_optr replica",
+ /* 89 */ "db_optr ::= db_optr quorum",
+ /* 90 */ "db_optr ::= db_optr days",
+ /* 91 */ "db_optr ::= db_optr minrows",
+ /* 92 */ "db_optr ::= db_optr maxrows",
+ /* 93 */ "db_optr ::= db_optr blocks",
+ /* 94 */ "db_optr ::= db_optr ctime",
+ /* 95 */ "db_optr ::= db_optr wal",
+ /* 96 */ "db_optr ::= db_optr fsync",
+ /* 97 */ "db_optr ::= db_optr comp",
+ /* 98 */ "db_optr ::= db_optr prec",
+ /* 99 */ "db_optr ::= db_optr keep",
+ /* 100 */ "db_optr ::= db_optr update",
+ /* 101 */ "alter_db_optr ::=",
+ /* 102 */ "alter_db_optr ::= alter_db_optr replica",
+ /* 103 */ "alter_db_optr ::= alter_db_optr quorum",
+ /* 104 */ "alter_db_optr ::= alter_db_optr keep",
+ /* 105 */ "alter_db_optr ::= alter_db_optr blocks",
+ /* 106 */ "alter_db_optr ::= alter_db_optr comp",
+ /* 107 */ "alter_db_optr ::= alter_db_optr wal",
+ /* 108 */ "alter_db_optr ::= alter_db_optr fsync",
+ /* 109 */ "alter_db_optr ::= alter_db_optr update",
+ /* 110 */ "typename ::= ids",
+ /* 111 */ "typename ::= ids LP signed RP",
+ /* 112 */ "signed ::= INTEGER",
+ /* 113 */ "signed ::= PLUS INTEGER",
+ /* 114 */ "signed ::= MINUS INTEGER",
+ /* 115 */ "cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args",
+ /* 116 */ "create_table_args ::= LP columnlist RP",
+ /* 117 */ "create_table_args ::= LP columnlist RP TAGS LP columnlist RP",
+ /* 118 */ "create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP",
+ /* 119 */ "create_table_args ::= AS select",
+ /* 120 */ "columnlist ::= columnlist COMMA column",
+ /* 121 */ "columnlist ::= column",
+ /* 122 */ "column ::= ids typename",
+ /* 123 */ "tagitemlist ::= tagitemlist COMMA tagitem",
+ /* 124 */ "tagitemlist ::= tagitem",
+ /* 125 */ "tagitem ::= INTEGER",
+ /* 126 */ "tagitem ::= FLOAT",
+ /* 127 */ "tagitem ::= STRING",
+ /* 128 */ "tagitem ::= BOOL",
+ /* 129 */ "tagitem ::= NULL",
+ /* 130 */ "tagitem ::= MINUS INTEGER",
+ /* 131 */ "tagitem ::= MINUS FLOAT",
+ /* 132 */ "tagitem ::= PLUS INTEGER",
+ /* 133 */ "tagitem ::= PLUS FLOAT",
+ /* 134 */ "select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt",
+ /* 135 */ "union ::= select",
+ /* 136 */ "union ::= LP union RP",
+ /* 137 */ "union ::= union UNION ALL select",
+ /* 138 */ "union ::= union UNION ALL LP select RP",
+ /* 139 */ "cmd ::= union",
+ /* 140 */ "select ::= SELECT selcollist",
+ /* 141 */ "sclp ::= selcollist COMMA",
+ /* 142 */ "sclp ::=",
+ /* 143 */ "selcollist ::= sclp expr as",
+ /* 144 */ "selcollist ::= sclp STAR",
+ /* 145 */ "as ::= AS ids",
+ /* 146 */ "as ::= ids",
+ /* 147 */ "as ::=",
+ /* 148 */ "from ::= FROM tablelist",
+ /* 149 */ "tablelist ::= ids cpxName",
+ /* 150 */ "tablelist ::= ids cpxName ids",
+ /* 151 */ "tablelist ::= tablelist COMMA ids cpxName",
+ /* 152 */ "tablelist ::= tablelist COMMA ids cpxName ids",
+ /* 153 */ "tmvar ::= VARIABLE",
+ /* 154 */ "interval_opt ::= INTERVAL LP tmvar RP",
+ /* 155 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP",
+ /* 156 */ "interval_opt ::=",
+ /* 157 */ "fill_opt ::=",
+ /* 158 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP",
+ /* 159 */ "fill_opt ::= FILL LP ID RP",
+ /* 160 */ "sliding_opt ::= SLIDING LP tmvar RP",
+ /* 161 */ "sliding_opt ::=",
+ /* 162 */ "orderby_opt ::=",
+ /* 163 */ "orderby_opt ::= ORDER BY sortlist",
+ /* 164 */ "sortlist ::= sortlist COMMA item sortorder",
+ /* 165 */ "sortlist ::= item sortorder",
+ /* 166 */ "item ::= ids cpxName",
+ /* 167 */ "sortorder ::= ASC",
+ /* 168 */ "sortorder ::= DESC",
+ /* 169 */ "sortorder ::=",
+ /* 170 */ "groupby_opt ::=",
+ /* 171 */ "groupby_opt ::= GROUP BY grouplist",
+ /* 172 */ "grouplist ::= grouplist COMMA item",
+ /* 173 */ "grouplist ::= item",
+ /* 174 */ "having_opt ::=",
+ /* 175 */ "having_opt ::= HAVING expr",
+ /* 176 */ "limit_opt ::=",
+ /* 177 */ "limit_opt ::= LIMIT signed",
+ /* 178 */ "limit_opt ::= LIMIT signed OFFSET signed",
+ /* 179 */ "limit_opt ::= LIMIT signed COMMA signed",
+ /* 180 */ "slimit_opt ::=",
+ /* 181 */ "slimit_opt ::= SLIMIT signed",
+ /* 182 */ "slimit_opt ::= SLIMIT signed SOFFSET signed",
+ /* 183 */ "slimit_opt ::= SLIMIT signed COMMA signed",
+ /* 184 */ "where_opt ::=",
+ /* 185 */ "where_opt ::= WHERE expr",
+ /* 186 */ "expr ::= LP expr RP",
+ /* 187 */ "expr ::= ID",
+ /* 188 */ "expr ::= ID DOT ID",
+ /* 189 */ "expr ::= ID DOT STAR",
+ /* 190 */ "expr ::= INTEGER",
+ /* 191 */ "expr ::= MINUS INTEGER",
+ /* 192 */ "expr ::= PLUS INTEGER",
+ /* 193 */ "expr ::= FLOAT",
+ /* 194 */ "expr ::= MINUS FLOAT",
+ /* 195 */ "expr ::= PLUS FLOAT",
+ /* 196 */ "expr ::= STRING",
+ /* 197 */ "expr ::= NOW",
+ /* 198 */ "expr ::= VARIABLE",
+ /* 199 */ "expr ::= BOOL",
+ /* 200 */ "expr ::= ID LP exprlist RP",
+ /* 201 */ "expr ::= ID LP STAR RP",
+ /* 202 */ "expr ::= expr IS NULL",
+ /* 203 */ "expr ::= expr IS NOT NULL",
+ /* 204 */ "expr ::= expr LT expr",
+ /* 205 */ "expr ::= expr GT expr",
+ /* 206 */ "expr ::= expr LE expr",
+ /* 207 */ "expr ::= expr GE expr",
+ /* 208 */ "expr ::= expr NE expr",
+ /* 209 */ "expr ::= expr EQ expr",
+ /* 210 */ "expr ::= expr AND expr",
+ /* 211 */ "expr ::= expr OR expr",
+ /* 212 */ "expr ::= expr PLUS expr",
+ /* 213 */ "expr ::= expr MINUS expr",
+ /* 214 */ "expr ::= expr STAR expr",
+ /* 215 */ "expr ::= expr SLASH expr",
+ /* 216 */ "expr ::= expr REM expr",
+ /* 217 */ "expr ::= expr LIKE expr",
+ /* 218 */ "expr ::= expr IN LP exprlist RP",
+ /* 219 */ "exprlist ::= exprlist COMMA expritem",
+ /* 220 */ "exprlist ::= expritem",
+ /* 221 */ "expritem ::= expr",
+ /* 222 */ "expritem ::=",
+ /* 223 */ "cmd ::= RESET QUERY CACHE",
+ /* 224 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist",
+ /* 225 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids",
+ /* 226 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist",
+ /* 227 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids",
+ /* 228 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids",
+ /* 229 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem",
+ /* 230 */ "cmd ::= KILL CONNECTION INTEGER",
+ /* 231 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER",
+ /* 232 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER",
};
#endif /* NDEBUG */
@@ -1359,50 +1366,50 @@ static void yy_destructor(
** inside the C code.
*/
/********* Begin destructor definitions ***************************************/
- case 226: /* keep */
- case 227: /* tagitemlist */
- case 251: /* fill_opt */
- case 253: /* groupby_opt */
- case 254: /* orderby_opt */
- case 264: /* sortlist */
- case 268: /* grouplist */
+ case 227: /* keep */
+ case 228: /* tagitemlist */
+ case 253: /* fill_opt */
+ case 255: /* groupby_opt */
+ case 256: /* orderby_opt */
+ case 266: /* sortlist */
+ case 270: /* grouplist */
{
-tVariantListDestroy((yypminor->yy494));
+tVariantListDestroy((yypminor->yy498));
}
break;
- case 243: /* columnlist */
+ case 245: /* columnlist */
{
-tFieldListDestroy((yypminor->yy449));
+tFieldListDestroy((yypminor->yy523));
}
break;
- case 244: /* select */
+ case 246: /* select */
{
-doDestroyQuerySql((yypminor->yy150));
+doDestroyQuerySql((yypminor->yy414));
}
break;
- case 247: /* selcollist */
- case 259: /* sclp */
- case 269: /* exprlist */
+ case 249: /* selcollist */
+ case 261: /* sclp */
+ case 271: /* exprlist */
{
-tSQLExprListDestroy((yypminor->yy224));
+tSQLExprListDestroy((yypminor->yy290));
}
break;
- case 249: /* where_opt */
- case 255: /* having_opt */
- case 260: /* expr */
- case 270: /* expritem */
+ case 251: /* where_opt */
+ case 257: /* having_opt */
+ case 262: /* expr */
+ case 272: /* expritem */
{
-tSQLExprDestroy((yypminor->yy66));
+tSQLExprDestroy((yypminor->yy64));
}
break;
- case 258: /* union */
+ case 260: /* union */
{
-destroyAllSelectClause((yypminor->yy25));
+destroyAllSelectClause((yypminor->yy231));
}
break;
- case 265: /* sortitem */
+ case 267: /* sortitem */
{
-tVariantDestroy(&(yypminor->yy312));
+tVariantDestroy(&(yypminor->yy134));
}
break;
/********* End destructor definitions *****************************************/
@@ -1696,236 +1703,239 @@ static const struct {
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
signed char nrhs; /* Negative of the number of RHS symbols in the rule */
} yyRuleInfo[] = {
- { 207, -1 }, /* (0) program ::= cmd */
- { 208, -2 }, /* (1) cmd ::= SHOW DATABASES */
- { 208, -2 }, /* (2) cmd ::= SHOW MNODES */
- { 208, -2 }, /* (3) cmd ::= SHOW DNODES */
- { 208, -2 }, /* (4) cmd ::= SHOW ACCOUNTS */
- { 208, -2 }, /* (5) cmd ::= SHOW USERS */
- { 208, -2 }, /* (6) cmd ::= SHOW MODULES */
- { 208, -2 }, /* (7) cmd ::= SHOW QUERIES */
- { 208, -2 }, /* (8) cmd ::= SHOW CONNECTIONS */
- { 208, -2 }, /* (9) cmd ::= SHOW STREAMS */
- { 208, -2 }, /* (10) cmd ::= SHOW VARIABLES */
- { 208, -2 }, /* (11) cmd ::= SHOW SCORES */
- { 208, -2 }, /* (12) cmd ::= SHOW GRANTS */
- { 208, -2 }, /* (13) cmd ::= SHOW VNODES */
- { 208, -3 }, /* (14) cmd ::= SHOW VNODES IPTOKEN */
- { 209, 0 }, /* (15) dbPrefix ::= */
- { 209, -2 }, /* (16) dbPrefix ::= ids DOT */
- { 211, 0 }, /* (17) cpxName ::= */
- { 211, -2 }, /* (18) cpxName ::= DOT ids */
- { 208, -5 }, /* (19) cmd ::= SHOW CREATE TABLE ids cpxName */
- { 208, -4 }, /* (20) cmd ::= SHOW CREATE DATABASE ids */
- { 208, -3 }, /* (21) cmd ::= SHOW dbPrefix TABLES */
- { 208, -5 }, /* (22) cmd ::= SHOW dbPrefix TABLES LIKE ids */
- { 208, -3 }, /* (23) cmd ::= SHOW dbPrefix STABLES */
- { 208, -5 }, /* (24) cmd ::= SHOW dbPrefix STABLES LIKE ids */
- { 208, -3 }, /* (25) cmd ::= SHOW dbPrefix VGROUPS */
- { 208, -4 }, /* (26) cmd ::= SHOW dbPrefix VGROUPS ids */
- { 208, -5 }, /* (27) cmd ::= DROP TABLE ifexists ids cpxName */
- { 208, -4 }, /* (28) cmd ::= DROP DATABASE ifexists ids */
- { 208, -3 }, /* (29) cmd ::= DROP DNODE ids */
- { 208, -3 }, /* (30) cmd ::= DROP USER ids */
- { 208, -3 }, /* (31) cmd ::= DROP ACCOUNT ids */
- { 208, -2 }, /* (32) cmd ::= USE ids */
- { 208, -3 }, /* (33) cmd ::= DESCRIBE ids cpxName */
- { 208, -5 }, /* (34) cmd ::= ALTER USER ids PASS ids */
- { 208, -5 }, /* (35) cmd ::= ALTER USER ids PRIVILEGE ids */
- { 208, -4 }, /* (36) cmd ::= ALTER DNODE ids ids */
- { 208, -5 }, /* (37) cmd ::= ALTER DNODE ids ids ids */
- { 208, -3 }, /* (38) cmd ::= ALTER LOCAL ids */
- { 208, -4 }, /* (39) cmd ::= ALTER LOCAL ids ids */
- { 208, -4 }, /* (40) cmd ::= ALTER DATABASE ids alter_db_optr */
- { 208, -4 }, /* (41) cmd ::= ALTER ACCOUNT ids acct_optr */
- { 208, -6 }, /* (42) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */
- { 210, -1 }, /* (43) ids ::= ID */
- { 210, -1 }, /* (44) ids ::= STRING */
- { 212, -2 }, /* (45) ifexists ::= IF EXISTS */
- { 212, 0 }, /* (46) ifexists ::= */
- { 215, -3 }, /* (47) ifnotexists ::= IF NOT EXISTS */
- { 215, 0 }, /* (48) ifnotexists ::= */
- { 208, -3 }, /* (49) cmd ::= CREATE DNODE ids */
- { 208, -6 }, /* (50) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
- { 208, -5 }, /* (51) cmd ::= CREATE DATABASE ifnotexists ids db_optr */
- { 208, -5 }, /* (52) cmd ::= CREATE USER ids PASS ids */
- { 217, 0 }, /* (53) pps ::= */
- { 217, -2 }, /* (54) pps ::= PPS INTEGER */
- { 218, 0 }, /* (55) tseries ::= */
- { 218, -2 }, /* (56) tseries ::= TSERIES INTEGER */
- { 219, 0 }, /* (57) dbs ::= */
- { 219, -2 }, /* (58) dbs ::= DBS INTEGER */
- { 220, 0 }, /* (59) streams ::= */
- { 220, -2 }, /* (60) streams ::= STREAMS INTEGER */
- { 221, 0 }, /* (61) storage ::= */
- { 221, -2 }, /* (62) storage ::= STORAGE INTEGER */
- { 222, 0 }, /* (63) qtime ::= */
- { 222, -2 }, /* (64) qtime ::= QTIME INTEGER */
- { 223, 0 }, /* (65) users ::= */
- { 223, -2 }, /* (66) users ::= USERS INTEGER */
- { 224, 0 }, /* (67) conns ::= */
- { 224, -2 }, /* (68) conns ::= CONNS INTEGER */
- { 225, 0 }, /* (69) state ::= */
- { 225, -2 }, /* (70) state ::= STATE ids */
- { 214, -9 }, /* (71) acct_optr ::= pps tseries storage streams qtime dbs users conns state */
- { 226, -2 }, /* (72) keep ::= KEEP tagitemlist */
- { 228, -2 }, /* (73) cache ::= CACHE INTEGER */
- { 229, -2 }, /* (74) replica ::= REPLICA INTEGER */
- { 230, -2 }, /* (75) quorum ::= QUORUM INTEGER */
- { 231, -2 }, /* (76) days ::= DAYS INTEGER */
- { 232, -2 }, /* (77) minrows ::= MINROWS INTEGER */
- { 233, -2 }, /* (78) maxrows ::= MAXROWS INTEGER */
- { 234, -2 }, /* (79) blocks ::= BLOCKS INTEGER */
- { 235, -2 }, /* (80) ctime ::= CTIME INTEGER */
- { 236, -2 }, /* (81) wal ::= WAL INTEGER */
- { 237, -2 }, /* (82) fsync ::= FSYNC INTEGER */
- { 238, -2 }, /* (83) comp ::= COMP INTEGER */
- { 239, -2 }, /* (84) prec ::= PRECISION STRING */
- { 216, 0 }, /* (85) db_optr ::= */
- { 216, -2 }, /* (86) db_optr ::= db_optr cache */
- { 216, -2 }, /* (87) db_optr ::= db_optr replica */
- { 216, -2 }, /* (88) db_optr ::= db_optr quorum */
- { 216, -2 }, /* (89) db_optr ::= db_optr days */
- { 216, -2 }, /* (90) db_optr ::= db_optr minrows */
- { 216, -2 }, /* (91) db_optr ::= db_optr maxrows */
- { 216, -2 }, /* (92) db_optr ::= db_optr blocks */
- { 216, -2 }, /* (93) db_optr ::= db_optr ctime */
- { 216, -2 }, /* (94) db_optr ::= db_optr wal */
- { 216, -2 }, /* (95) db_optr ::= db_optr fsync */
- { 216, -2 }, /* (96) db_optr ::= db_optr comp */
- { 216, -2 }, /* (97) db_optr ::= db_optr prec */
- { 216, -2 }, /* (98) db_optr ::= db_optr keep */
- { 213, 0 }, /* (99) alter_db_optr ::= */
- { 213, -2 }, /* (100) alter_db_optr ::= alter_db_optr replica */
- { 213, -2 }, /* (101) alter_db_optr ::= alter_db_optr quorum */
- { 213, -2 }, /* (102) alter_db_optr ::= alter_db_optr keep */
- { 213, -2 }, /* (103) alter_db_optr ::= alter_db_optr blocks */
- { 213, -2 }, /* (104) alter_db_optr ::= alter_db_optr comp */
- { 213, -2 }, /* (105) alter_db_optr ::= alter_db_optr wal */
- { 213, -2 }, /* (106) alter_db_optr ::= alter_db_optr fsync */
- { 240, -1 }, /* (107) typename ::= ids */
- { 240, -4 }, /* (108) typename ::= ids LP signed RP */
- { 241, -1 }, /* (109) signed ::= INTEGER */
- { 241, -2 }, /* (110) signed ::= PLUS INTEGER */
- { 241, -2 }, /* (111) signed ::= MINUS INTEGER */
- { 208, -6 }, /* (112) cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */
- { 242, -3 }, /* (113) create_table_args ::= LP columnlist RP */
- { 242, -7 }, /* (114) create_table_args ::= LP columnlist RP TAGS LP columnlist RP */
- { 242, -7 }, /* (115) create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */
- { 242, -2 }, /* (116) create_table_args ::= AS select */
- { 243, -3 }, /* (117) columnlist ::= columnlist COMMA column */
- { 243, -1 }, /* (118) columnlist ::= column */
- { 245, -2 }, /* (119) column ::= ids typename */
- { 227, -3 }, /* (120) tagitemlist ::= tagitemlist COMMA tagitem */
- { 227, -1 }, /* (121) tagitemlist ::= tagitem */
- { 246, -1 }, /* (122) tagitem ::= INTEGER */
- { 246, -1 }, /* (123) tagitem ::= FLOAT */
- { 246, -1 }, /* (124) tagitem ::= STRING */
- { 246, -1 }, /* (125) tagitem ::= BOOL */
- { 246, -1 }, /* (126) tagitem ::= NULL */
- { 246, -2 }, /* (127) tagitem ::= MINUS INTEGER */
- { 246, -2 }, /* (128) tagitem ::= MINUS FLOAT */
- { 246, -2 }, /* (129) tagitem ::= PLUS INTEGER */
- { 246, -2 }, /* (130) tagitem ::= PLUS FLOAT */
- { 244, -12 }, /* (131) select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
- { 258, -1 }, /* (132) union ::= select */
- { 258, -3 }, /* (133) union ::= LP union RP */
- { 258, -4 }, /* (134) union ::= union UNION ALL select */
- { 258, -6 }, /* (135) union ::= union UNION ALL LP select RP */
- { 208, -1 }, /* (136) cmd ::= union */
- { 244, -2 }, /* (137) select ::= SELECT selcollist */
- { 259, -2 }, /* (138) sclp ::= selcollist COMMA */
- { 259, 0 }, /* (139) sclp ::= */
- { 247, -3 }, /* (140) selcollist ::= sclp expr as */
- { 247, -2 }, /* (141) selcollist ::= sclp STAR */
- { 261, -2 }, /* (142) as ::= AS ids */
- { 261, -1 }, /* (143) as ::= ids */
- { 261, 0 }, /* (144) as ::= */
- { 248, -2 }, /* (145) from ::= FROM tablelist */
- { 262, -2 }, /* (146) tablelist ::= ids cpxName */
- { 262, -3 }, /* (147) tablelist ::= ids cpxName ids */
- { 262, -4 }, /* (148) tablelist ::= tablelist COMMA ids cpxName */
- { 262, -5 }, /* (149) tablelist ::= tablelist COMMA ids cpxName ids */
- { 263, -1 }, /* (150) tmvar ::= VARIABLE */
- { 250, -4 }, /* (151) interval_opt ::= INTERVAL LP tmvar RP */
- { 250, -6 }, /* (152) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */
- { 250, 0 }, /* (153) interval_opt ::= */
- { 251, 0 }, /* (154) fill_opt ::= */
- { 251, -6 }, /* (155) fill_opt ::= FILL LP ID COMMA tagitemlist RP */
- { 251, -4 }, /* (156) fill_opt ::= FILL LP ID RP */
- { 252, -4 }, /* (157) sliding_opt ::= SLIDING LP tmvar RP */
- { 252, 0 }, /* (158) sliding_opt ::= */
- { 254, 0 }, /* (159) orderby_opt ::= */
- { 254, -3 }, /* (160) orderby_opt ::= ORDER BY sortlist */
- { 264, -4 }, /* (161) sortlist ::= sortlist COMMA item sortorder */
- { 264, -2 }, /* (162) sortlist ::= item sortorder */
- { 266, -2 }, /* (163) item ::= ids cpxName */
- { 267, -1 }, /* (164) sortorder ::= ASC */
- { 267, -1 }, /* (165) sortorder ::= DESC */
- { 267, 0 }, /* (166) sortorder ::= */
- { 253, 0 }, /* (167) groupby_opt ::= */
- { 253, -3 }, /* (168) groupby_opt ::= GROUP BY grouplist */
- { 268, -3 }, /* (169) grouplist ::= grouplist COMMA item */
- { 268, -1 }, /* (170) grouplist ::= item */
- { 255, 0 }, /* (171) having_opt ::= */
- { 255, -2 }, /* (172) having_opt ::= HAVING expr */
- { 257, 0 }, /* (173) limit_opt ::= */
- { 257, -2 }, /* (174) limit_opt ::= LIMIT signed */
- { 257, -4 }, /* (175) limit_opt ::= LIMIT signed OFFSET signed */
- { 257, -4 }, /* (176) limit_opt ::= LIMIT signed COMMA signed */
- { 256, 0 }, /* (177) slimit_opt ::= */
- { 256, -2 }, /* (178) slimit_opt ::= SLIMIT signed */
- { 256, -4 }, /* (179) slimit_opt ::= SLIMIT signed SOFFSET signed */
- { 256, -4 }, /* (180) slimit_opt ::= SLIMIT signed COMMA signed */
- { 249, 0 }, /* (181) where_opt ::= */
- { 249, -2 }, /* (182) where_opt ::= WHERE expr */
- { 260, -3 }, /* (183) expr ::= LP expr RP */
- { 260, -1 }, /* (184) expr ::= ID */
- { 260, -3 }, /* (185) expr ::= ID DOT ID */
- { 260, -3 }, /* (186) expr ::= ID DOT STAR */
- { 260, -1 }, /* (187) expr ::= INTEGER */
- { 260, -2 }, /* (188) expr ::= MINUS INTEGER */
- { 260, -2 }, /* (189) expr ::= PLUS INTEGER */
- { 260, -1 }, /* (190) expr ::= FLOAT */
- { 260, -2 }, /* (191) expr ::= MINUS FLOAT */
- { 260, -2 }, /* (192) expr ::= PLUS FLOAT */
- { 260, -1 }, /* (193) expr ::= STRING */
- { 260, -1 }, /* (194) expr ::= NOW */
- { 260, -1 }, /* (195) expr ::= VARIABLE */
- { 260, -1 }, /* (196) expr ::= BOOL */
- { 260, -4 }, /* (197) expr ::= ID LP exprlist RP */
- { 260, -4 }, /* (198) expr ::= ID LP STAR RP */
- { 260, -3 }, /* (199) expr ::= expr IS NULL */
- { 260, -4 }, /* (200) expr ::= expr IS NOT NULL */
- { 260, -3 }, /* (201) expr ::= expr LT expr */
- { 260, -3 }, /* (202) expr ::= expr GT expr */
- { 260, -3 }, /* (203) expr ::= expr LE expr */
- { 260, -3 }, /* (204) expr ::= expr GE expr */
- { 260, -3 }, /* (205) expr ::= expr NE expr */
- { 260, -3 }, /* (206) expr ::= expr EQ expr */
- { 260, -3 }, /* (207) expr ::= expr AND expr */
- { 260, -3 }, /* (208) expr ::= expr OR expr */
- { 260, -3 }, /* (209) expr ::= expr PLUS expr */
- { 260, -3 }, /* (210) expr ::= expr MINUS expr */
- { 260, -3 }, /* (211) expr ::= expr STAR expr */
- { 260, -3 }, /* (212) expr ::= expr SLASH expr */
- { 260, -3 }, /* (213) expr ::= expr REM expr */
- { 260, -3 }, /* (214) expr ::= expr LIKE expr */
- { 260, -5 }, /* (215) expr ::= expr IN LP exprlist RP */
- { 269, -3 }, /* (216) exprlist ::= exprlist COMMA expritem */
- { 269, -1 }, /* (217) exprlist ::= expritem */
- { 270, -1 }, /* (218) expritem ::= expr */
- { 270, 0 }, /* (219) expritem ::= */
- { 208, -3 }, /* (220) cmd ::= RESET QUERY CACHE */
- { 208, -7 }, /* (221) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
- { 208, -7 }, /* (222) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
- { 208, -7 }, /* (223) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
- { 208, -7 }, /* (224) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
- { 208, -8 }, /* (225) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
- { 208, -9 }, /* (226) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
- { 208, -3 }, /* (227) cmd ::= KILL CONNECTION INTEGER */
- { 208, -5 }, /* (228) cmd ::= KILL STREAM INTEGER COLON INTEGER */
- { 208, -5 }, /* (229) cmd ::= KILL QUERY INTEGER COLON INTEGER */
+ { 208, -1 }, /* (0) program ::= cmd */
+ { 209, -2 }, /* (1) cmd ::= SHOW DATABASES */
+ { 209, -2 }, /* (2) cmd ::= SHOW MNODES */
+ { 209, -2 }, /* (3) cmd ::= SHOW DNODES */
+ { 209, -2 }, /* (4) cmd ::= SHOW ACCOUNTS */
+ { 209, -2 }, /* (5) cmd ::= SHOW USERS */
+ { 209, -2 }, /* (6) cmd ::= SHOW MODULES */
+ { 209, -2 }, /* (7) cmd ::= SHOW QUERIES */
+ { 209, -2 }, /* (8) cmd ::= SHOW CONNECTIONS */
+ { 209, -2 }, /* (9) cmd ::= SHOW STREAMS */
+ { 209, -2 }, /* (10) cmd ::= SHOW VARIABLES */
+ { 209, -2 }, /* (11) cmd ::= SHOW SCORES */
+ { 209, -2 }, /* (12) cmd ::= SHOW GRANTS */
+ { 209, -2 }, /* (13) cmd ::= SHOW VNODES */
+ { 209, -3 }, /* (14) cmd ::= SHOW VNODES IPTOKEN */
+ { 210, 0 }, /* (15) dbPrefix ::= */
+ { 210, -2 }, /* (16) dbPrefix ::= ids DOT */
+ { 212, 0 }, /* (17) cpxName ::= */
+ { 212, -2 }, /* (18) cpxName ::= DOT ids */
+ { 209, -5 }, /* (19) cmd ::= SHOW CREATE TABLE ids cpxName */
+ { 209, -4 }, /* (20) cmd ::= SHOW CREATE DATABASE ids */
+ { 209, -3 }, /* (21) cmd ::= SHOW dbPrefix TABLES */
+ { 209, -5 }, /* (22) cmd ::= SHOW dbPrefix TABLES LIKE ids */
+ { 209, -3 }, /* (23) cmd ::= SHOW dbPrefix STABLES */
+ { 209, -5 }, /* (24) cmd ::= SHOW dbPrefix STABLES LIKE ids */
+ { 209, -3 }, /* (25) cmd ::= SHOW dbPrefix VGROUPS */
+ { 209, -4 }, /* (26) cmd ::= SHOW dbPrefix VGROUPS ids */
+ { 209, -5 }, /* (27) cmd ::= DROP TABLE ifexists ids cpxName */
+ { 209, -4 }, /* (28) cmd ::= DROP DATABASE ifexists ids */
+ { 209, -3 }, /* (29) cmd ::= DROP DNODE ids */
+ { 209, -3 }, /* (30) cmd ::= DROP USER ids */
+ { 209, -3 }, /* (31) cmd ::= DROP ACCOUNT ids */
+ { 209, -2 }, /* (32) cmd ::= USE ids */
+ { 209, -3 }, /* (33) cmd ::= DESCRIBE ids cpxName */
+ { 209, -5 }, /* (34) cmd ::= ALTER USER ids PASS ids */
+ { 209, -5 }, /* (35) cmd ::= ALTER USER ids PRIVILEGE ids */
+ { 209, -4 }, /* (36) cmd ::= ALTER DNODE ids ids */
+ { 209, -5 }, /* (37) cmd ::= ALTER DNODE ids ids ids */
+ { 209, -3 }, /* (38) cmd ::= ALTER LOCAL ids */
+ { 209, -4 }, /* (39) cmd ::= ALTER LOCAL ids ids */
+ { 209, -4 }, /* (40) cmd ::= ALTER DATABASE ids alter_db_optr */
+ { 209, -4 }, /* (41) cmd ::= ALTER ACCOUNT ids acct_optr */
+ { 209, -6 }, /* (42) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */
+ { 211, -1 }, /* (43) ids ::= ID */
+ { 211, -1 }, /* (44) ids ::= STRING */
+ { 213, -2 }, /* (45) ifexists ::= IF EXISTS */
+ { 213, 0 }, /* (46) ifexists ::= */
+ { 216, -3 }, /* (47) ifnotexists ::= IF NOT EXISTS */
+ { 216, 0 }, /* (48) ifnotexists ::= */
+ { 209, -3 }, /* (49) cmd ::= CREATE DNODE ids */
+ { 209, -6 }, /* (50) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
+ { 209, -5 }, /* (51) cmd ::= CREATE DATABASE ifnotexists ids db_optr */
+ { 209, -5 }, /* (52) cmd ::= CREATE USER ids PASS ids */
+ { 218, 0 }, /* (53) pps ::= */
+ { 218, -2 }, /* (54) pps ::= PPS INTEGER */
+ { 219, 0 }, /* (55) tseries ::= */
+ { 219, -2 }, /* (56) tseries ::= TSERIES INTEGER */
+ { 220, 0 }, /* (57) dbs ::= */
+ { 220, -2 }, /* (58) dbs ::= DBS INTEGER */
+ { 221, 0 }, /* (59) streams ::= */
+ { 221, -2 }, /* (60) streams ::= STREAMS INTEGER */
+ { 222, 0 }, /* (61) storage ::= */
+ { 222, -2 }, /* (62) storage ::= STORAGE INTEGER */
+ { 223, 0 }, /* (63) qtime ::= */
+ { 223, -2 }, /* (64) qtime ::= QTIME INTEGER */
+ { 224, 0 }, /* (65) users ::= */
+ { 224, -2 }, /* (66) users ::= USERS INTEGER */
+ { 225, 0 }, /* (67) conns ::= */
+ { 225, -2 }, /* (68) conns ::= CONNS INTEGER */
+ { 226, 0 }, /* (69) state ::= */
+ { 226, -2 }, /* (70) state ::= STATE ids */
+ { 215, -9 }, /* (71) acct_optr ::= pps tseries storage streams qtime dbs users conns state */
+ { 227, -2 }, /* (72) keep ::= KEEP tagitemlist */
+ { 229, -2 }, /* (73) cache ::= CACHE INTEGER */
+ { 230, -2 }, /* (74) replica ::= REPLICA INTEGER */
+ { 231, -2 }, /* (75) quorum ::= QUORUM INTEGER */
+ { 232, -2 }, /* (76) days ::= DAYS INTEGER */
+ { 233, -2 }, /* (77) minrows ::= MINROWS INTEGER */
+ { 234, -2 }, /* (78) maxrows ::= MAXROWS INTEGER */
+ { 235, -2 }, /* (79) blocks ::= BLOCKS INTEGER */
+ { 236, -2 }, /* (80) ctime ::= CTIME INTEGER */
+ { 237, -2 }, /* (81) wal ::= WAL INTEGER */
+ { 238, -2 }, /* (82) fsync ::= FSYNC INTEGER */
+ { 239, -2 }, /* (83) comp ::= COMP INTEGER */
+ { 240, -2 }, /* (84) prec ::= PRECISION STRING */
+ { 241, -2 }, /* (85) update ::= UPDATE INTEGER */
+ { 217, 0 }, /* (86) db_optr ::= */
+ { 217, -2 }, /* (87) db_optr ::= db_optr cache */
+ { 217, -2 }, /* (88) db_optr ::= db_optr replica */
+ { 217, -2 }, /* (89) db_optr ::= db_optr quorum */
+ { 217, -2 }, /* (90) db_optr ::= db_optr days */
+ { 217, -2 }, /* (91) db_optr ::= db_optr minrows */
+ { 217, -2 }, /* (92) db_optr ::= db_optr maxrows */
+ { 217, -2 }, /* (93) db_optr ::= db_optr blocks */
+ { 217, -2 }, /* (94) db_optr ::= db_optr ctime */
+ { 217, -2 }, /* (95) db_optr ::= db_optr wal */
+ { 217, -2 }, /* (96) db_optr ::= db_optr fsync */
+ { 217, -2 }, /* (97) db_optr ::= db_optr comp */
+ { 217, -2 }, /* (98) db_optr ::= db_optr prec */
+ { 217, -2 }, /* (99) db_optr ::= db_optr keep */
+ { 217, -2 }, /* (100) db_optr ::= db_optr update */
+ { 214, 0 }, /* (101) alter_db_optr ::= */
+ { 214, -2 }, /* (102) alter_db_optr ::= alter_db_optr replica */
+ { 214, -2 }, /* (103) alter_db_optr ::= alter_db_optr quorum */
+ { 214, -2 }, /* (104) alter_db_optr ::= alter_db_optr keep */
+ { 214, -2 }, /* (105) alter_db_optr ::= alter_db_optr blocks */
+ { 214, -2 }, /* (106) alter_db_optr ::= alter_db_optr comp */
+ { 214, -2 }, /* (107) alter_db_optr ::= alter_db_optr wal */
+ { 214, -2 }, /* (108) alter_db_optr ::= alter_db_optr fsync */
+ { 214, -2 }, /* (109) alter_db_optr ::= alter_db_optr update */
+ { 242, -1 }, /* (110) typename ::= ids */
+ { 242, -4 }, /* (111) typename ::= ids LP signed RP */
+ { 243, -1 }, /* (112) signed ::= INTEGER */
+ { 243, -2 }, /* (113) signed ::= PLUS INTEGER */
+ { 243, -2 }, /* (114) signed ::= MINUS INTEGER */
+ { 209, -6 }, /* (115) cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */
+ { 244, -3 }, /* (116) create_table_args ::= LP columnlist RP */
+ { 244, -7 }, /* (117) create_table_args ::= LP columnlist RP TAGS LP columnlist RP */
+ { 244, -7 }, /* (118) create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */
+ { 244, -2 }, /* (119) create_table_args ::= AS select */
+ { 245, -3 }, /* (120) columnlist ::= columnlist COMMA column */
+ { 245, -1 }, /* (121) columnlist ::= column */
+ { 247, -2 }, /* (122) column ::= ids typename */
+ { 228, -3 }, /* (123) tagitemlist ::= tagitemlist COMMA tagitem */
+ { 228, -1 }, /* (124) tagitemlist ::= tagitem */
+ { 248, -1 }, /* (125) tagitem ::= INTEGER */
+ { 248, -1 }, /* (126) tagitem ::= FLOAT */
+ { 248, -1 }, /* (127) tagitem ::= STRING */
+ { 248, -1 }, /* (128) tagitem ::= BOOL */
+ { 248, -1 }, /* (129) tagitem ::= NULL */
+ { 248, -2 }, /* (130) tagitem ::= MINUS INTEGER */
+ { 248, -2 }, /* (131) tagitem ::= MINUS FLOAT */
+ { 248, -2 }, /* (132) tagitem ::= PLUS INTEGER */
+ { 248, -2 }, /* (133) tagitem ::= PLUS FLOAT */
+ { 246, -12 }, /* (134) select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
+ { 260, -1 }, /* (135) union ::= select */
+ { 260, -3 }, /* (136) union ::= LP union RP */
+ { 260, -4 }, /* (137) union ::= union UNION ALL select */
+ { 260, -6 }, /* (138) union ::= union UNION ALL LP select RP */
+ { 209, -1 }, /* (139) cmd ::= union */
+ { 246, -2 }, /* (140) select ::= SELECT selcollist */
+ { 261, -2 }, /* (141) sclp ::= selcollist COMMA */
+ { 261, 0 }, /* (142) sclp ::= */
+ { 249, -3 }, /* (143) selcollist ::= sclp expr as */
+ { 249, -2 }, /* (144) selcollist ::= sclp STAR */
+ { 263, -2 }, /* (145) as ::= AS ids */
+ { 263, -1 }, /* (146) as ::= ids */
+ { 263, 0 }, /* (147) as ::= */
+ { 250, -2 }, /* (148) from ::= FROM tablelist */
+ { 264, -2 }, /* (149) tablelist ::= ids cpxName */
+ { 264, -3 }, /* (150) tablelist ::= ids cpxName ids */
+ { 264, -4 }, /* (151) tablelist ::= tablelist COMMA ids cpxName */
+ { 264, -5 }, /* (152) tablelist ::= tablelist COMMA ids cpxName ids */
+ { 265, -1 }, /* (153) tmvar ::= VARIABLE */
+ { 252, -4 }, /* (154) interval_opt ::= INTERVAL LP tmvar RP */
+ { 252, -6 }, /* (155) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */
+ { 252, 0 }, /* (156) interval_opt ::= */
+ { 253, 0 }, /* (157) fill_opt ::= */
+ { 253, -6 }, /* (158) fill_opt ::= FILL LP ID COMMA tagitemlist RP */
+ { 253, -4 }, /* (159) fill_opt ::= FILL LP ID RP */
+ { 254, -4 }, /* (160) sliding_opt ::= SLIDING LP tmvar RP */
+ { 254, 0 }, /* (161) sliding_opt ::= */
+ { 256, 0 }, /* (162) orderby_opt ::= */
+ { 256, -3 }, /* (163) orderby_opt ::= ORDER BY sortlist */
+ { 266, -4 }, /* (164) sortlist ::= sortlist COMMA item sortorder */
+ { 266, -2 }, /* (165) sortlist ::= item sortorder */
+ { 268, -2 }, /* (166) item ::= ids cpxName */
+ { 269, -1 }, /* (167) sortorder ::= ASC */
+ { 269, -1 }, /* (168) sortorder ::= DESC */
+ { 269, 0 }, /* (169) sortorder ::= */
+ { 255, 0 }, /* (170) groupby_opt ::= */
+ { 255, -3 }, /* (171) groupby_opt ::= GROUP BY grouplist */
+ { 270, -3 }, /* (172) grouplist ::= grouplist COMMA item */
+ { 270, -1 }, /* (173) grouplist ::= item */
+ { 257, 0 }, /* (174) having_opt ::= */
+ { 257, -2 }, /* (175) having_opt ::= HAVING expr */
+ { 259, 0 }, /* (176) limit_opt ::= */
+ { 259, -2 }, /* (177) limit_opt ::= LIMIT signed */
+ { 259, -4 }, /* (178) limit_opt ::= LIMIT signed OFFSET signed */
+ { 259, -4 }, /* (179) limit_opt ::= LIMIT signed COMMA signed */
+ { 258, 0 }, /* (180) slimit_opt ::= */
+ { 258, -2 }, /* (181) slimit_opt ::= SLIMIT signed */
+ { 258, -4 }, /* (182) slimit_opt ::= SLIMIT signed SOFFSET signed */
+ { 258, -4 }, /* (183) slimit_opt ::= SLIMIT signed COMMA signed */
+ { 251, 0 }, /* (184) where_opt ::= */
+ { 251, -2 }, /* (185) where_opt ::= WHERE expr */
+ { 262, -3 }, /* (186) expr ::= LP expr RP */
+ { 262, -1 }, /* (187) expr ::= ID */
+ { 262, -3 }, /* (188) expr ::= ID DOT ID */
+ { 262, -3 }, /* (189) expr ::= ID DOT STAR */
+ { 262, -1 }, /* (190) expr ::= INTEGER */
+ { 262, -2 }, /* (191) expr ::= MINUS INTEGER */
+ { 262, -2 }, /* (192) expr ::= PLUS INTEGER */
+ { 262, -1 }, /* (193) expr ::= FLOAT */
+ { 262, -2 }, /* (194) expr ::= MINUS FLOAT */
+ { 262, -2 }, /* (195) expr ::= PLUS FLOAT */
+ { 262, -1 }, /* (196) expr ::= STRING */
+ { 262, -1 }, /* (197) expr ::= NOW */
+ { 262, -1 }, /* (198) expr ::= VARIABLE */
+ { 262, -1 }, /* (199) expr ::= BOOL */
+ { 262, -4 }, /* (200) expr ::= ID LP exprlist RP */
+ { 262, -4 }, /* (201) expr ::= ID LP STAR RP */
+ { 262, -3 }, /* (202) expr ::= expr IS NULL */
+ { 262, -4 }, /* (203) expr ::= expr IS NOT NULL */
+ { 262, -3 }, /* (204) expr ::= expr LT expr */
+ { 262, -3 }, /* (205) expr ::= expr GT expr */
+ { 262, -3 }, /* (206) expr ::= expr LE expr */
+ { 262, -3 }, /* (207) expr ::= expr GE expr */
+ { 262, -3 }, /* (208) expr ::= expr NE expr */
+ { 262, -3 }, /* (209) expr ::= expr EQ expr */
+ { 262, -3 }, /* (210) expr ::= expr AND expr */
+ { 262, -3 }, /* (211) expr ::= expr OR expr */
+ { 262, -3 }, /* (212) expr ::= expr PLUS expr */
+ { 262, -3 }, /* (213) expr ::= expr MINUS expr */
+ { 262, -3 }, /* (214) expr ::= expr STAR expr */
+ { 262, -3 }, /* (215) expr ::= expr SLASH expr */
+ { 262, -3 }, /* (216) expr ::= expr REM expr */
+ { 262, -3 }, /* (217) expr ::= expr LIKE expr */
+ { 262, -5 }, /* (218) expr ::= expr IN LP exprlist RP */
+ { 271, -3 }, /* (219) exprlist ::= exprlist COMMA expritem */
+ { 271, -1 }, /* (220) exprlist ::= expritem */
+ { 272, -1 }, /* (221) expritem ::= expr */
+ { 272, 0 }, /* (222) expritem ::= */
+ { 209, -3 }, /* (223) cmd ::= RESET QUERY CACHE */
+ { 209, -7 }, /* (224) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
+ { 209, -7 }, /* (225) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
+ { 209, -7 }, /* (226) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
+ { 209, -7 }, /* (227) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
+ { 209, -8 }, /* (228) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
+ { 209, -9 }, /* (229) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
+ { 209, -3 }, /* (230) cmd ::= KILL CONNECTION INTEGER */
+ { 209, -5 }, /* (231) cmd ::= KILL STREAM INTEGER COLON INTEGER */
+ { 209, -5 }, /* (232) cmd ::= KILL QUERY INTEGER COLON INTEGER */
};
static void yy_accept(yyParser*); /* Forward Declaration */
@@ -2156,13 +2166,13 @@ static void yy_reduce(
{ setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); }
break;
case 40: /* cmd ::= ALTER DATABASE ids alter_db_optr */
-{ SStrToken t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy158, &t);}
+{ SStrToken t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy268, &t);}
break;
case 41: /* cmd ::= ALTER ACCOUNT ids acct_optr */
-{ setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy73);}
+{ setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy149);}
break;
case 42: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */
-{ setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy73);}
+{ setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy149);}
break;
case 43: /* ids ::= ID */
case 44: /* ids ::= STRING */ yytestcase(yyruleno==44);
@@ -2183,10 +2193,10 @@ static void yy_reduce(
{ setDCLSQLElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);}
break;
case 50: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
-{ setCreateAcctSQL(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy73);}
+{ setCreateAcctSQL(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy149);}
break;
case 51: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */
-{ setCreateDBSQL(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy158, &yymsp[-2].minor.yy0);}
+{ setCreateDBSQL(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy268, &yymsp[-2].minor.yy0);}
break;
case 52: /* cmd ::= CREATE USER ids PASS ids */
{ setCreateUserSQL(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);}
@@ -2215,20 +2225,20 @@ static void yy_reduce(
break;
case 71: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */
{
- yylhsminor.yy73.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1;
- yylhsminor.yy73.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1;
- yylhsminor.yy73.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1;
- yylhsminor.yy73.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1;
- yylhsminor.yy73.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1;
- yylhsminor.yy73.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1;
- yylhsminor.yy73.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1;
- yylhsminor.yy73.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1;
- yylhsminor.yy73.stat = yymsp[0].minor.yy0;
+ yylhsminor.yy149.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1;
+ yylhsminor.yy149.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1;
+ yylhsminor.yy149.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1;
+ yylhsminor.yy149.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1;
+ yylhsminor.yy149.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1;
+ yylhsminor.yy149.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1;
+ yylhsminor.yy149.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1;
+ yylhsminor.yy149.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1;
+ yylhsminor.yy149.stat = yymsp[0].minor.yy0;
}
- yymsp[-8].minor.yy73 = yylhsminor.yy73;
+ yymsp[-8].minor.yy149 = yylhsminor.yy149;
break;
case 72: /* keep ::= KEEP tagitemlist */
-{ yymsp[-1].minor.yy494 = yymsp[0].minor.yy494; }
+{ yymsp[-1].minor.yy498 = yymsp[0].minor.yy498; }
break;
case 73: /* cache ::= CACHE INTEGER */
case 74: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==74);
@@ -2242,540 +2252,546 @@ static void yy_reduce(
case 82: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==82);
case 83: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==83);
case 84: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==84);
+ case 85: /* update ::= UPDATE INTEGER */ yytestcase(yyruleno==85);
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
break;
- case 85: /* db_optr ::= */
-{setDefaultCreateDbOption(&yymsp[1].minor.yy158);}
+ case 86: /* db_optr ::= */
+{setDefaultCreateDbOption(&yymsp[1].minor.yy268);}
break;
- case 86: /* db_optr ::= db_optr cache */
-{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy158 = yylhsminor.yy158;
+ case 87: /* db_optr ::= db_optr cache */
+{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy268 = yylhsminor.yy268;
break;
- case 87: /* db_optr ::= db_optr replica */
- case 100: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==100);
-{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy158 = yylhsminor.yy158;
+ case 88: /* db_optr ::= db_optr replica */
+ case 102: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==102);
+{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy268 = yylhsminor.yy268;
break;
- case 88: /* db_optr ::= db_optr quorum */
- case 101: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==101);
-{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy158 = yylhsminor.yy158;
+ case 89: /* db_optr ::= db_optr quorum */
+ case 103: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==103);
+{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy268 = yylhsminor.yy268;
break;
- case 89: /* db_optr ::= db_optr days */
-{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy158 = yylhsminor.yy158;
+ case 90: /* db_optr ::= db_optr days */
+{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy268 = yylhsminor.yy268;
break;
- case 90: /* db_optr ::= db_optr minrows */
-{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); }
- yymsp[-1].minor.yy158 = yylhsminor.yy158;
+ case 91: /* db_optr ::= db_optr minrows */
+{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); }
+ yymsp[-1].minor.yy268 = yylhsminor.yy268;
break;
- case 91: /* db_optr ::= db_optr maxrows */
-{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); }
- yymsp[-1].minor.yy158 = yylhsminor.yy158;
+ case 92: /* db_optr ::= db_optr maxrows */
+{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); }
+ yymsp[-1].minor.yy268 = yylhsminor.yy268;
break;
- case 92: /* db_optr ::= db_optr blocks */
- case 103: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==103);
-{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy158 = yylhsminor.yy158;
+ case 93: /* db_optr ::= db_optr blocks */
+ case 105: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==105);
+{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy268 = yylhsminor.yy268;
break;
- case 93: /* db_optr ::= db_optr ctime */
-{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy158 = yylhsminor.yy158;
+ case 94: /* db_optr ::= db_optr ctime */
+{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy268 = yylhsminor.yy268;
break;
- case 94: /* db_optr ::= db_optr wal */
- case 105: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==105);
-{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy158 = yylhsminor.yy158;
+ case 95: /* db_optr ::= db_optr wal */
+ case 107: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==107);
+{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy268 = yylhsminor.yy268;
break;
- case 95: /* db_optr ::= db_optr fsync */
- case 106: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==106);
-{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy158 = yylhsminor.yy158;
+ case 96: /* db_optr ::= db_optr fsync */
+ case 108: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==108);
+{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy268 = yylhsminor.yy268;
break;
- case 96: /* db_optr ::= db_optr comp */
- case 104: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==104);
-{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy158 = yylhsminor.yy158;
+ case 97: /* db_optr ::= db_optr comp */
+ case 106: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==106);
+{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy268 = yylhsminor.yy268;
break;
- case 97: /* db_optr ::= db_optr prec */
-{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.precision = yymsp[0].minor.yy0; }
- yymsp[-1].minor.yy158 = yylhsminor.yy158;
+ case 98: /* db_optr ::= db_optr prec */
+{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.precision = yymsp[0].minor.yy0; }
+ yymsp[-1].minor.yy268 = yylhsminor.yy268;
break;
- case 98: /* db_optr ::= db_optr keep */
- case 102: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==102);
-{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.keep = yymsp[0].minor.yy494; }
- yymsp[-1].minor.yy158 = yylhsminor.yy158;
+ case 99: /* db_optr ::= db_optr keep */
+ case 104: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==104);
+{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.keep = yymsp[0].minor.yy498; }
+ yymsp[-1].minor.yy268 = yylhsminor.yy268;
break;
- case 99: /* alter_db_optr ::= */
-{ setDefaultCreateDbOption(&yymsp[1].minor.yy158);}
+ case 100: /* db_optr ::= db_optr update */
+ case 109: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==109);
+{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy268 = yylhsminor.yy268;
break;
- case 107: /* typename ::= ids */
+ case 101: /* alter_db_optr ::= */
+{ setDefaultCreateDbOption(&yymsp[1].minor.yy268);}
+ break;
+ case 110: /* typename ::= ids */
{
yymsp[0].minor.yy0.type = 0;
- tSQLSetColumnType (&yylhsminor.yy181, &yymsp[0].minor.yy0);
+ tSQLSetColumnType (&yylhsminor.yy223, &yymsp[0].minor.yy0);
}
- yymsp[0].minor.yy181 = yylhsminor.yy181;
+ yymsp[0].minor.yy223 = yylhsminor.yy223;
break;
- case 108: /* typename ::= ids LP signed RP */
+ case 111: /* typename ::= ids LP signed RP */
{
- if (yymsp[-1].minor.yy271 <= 0) {
+ if (yymsp[-1].minor.yy207 <= 0) {
yymsp[-3].minor.yy0.type = 0;
- tSQLSetColumnType(&yylhsminor.yy181, &yymsp[-3].minor.yy0);
+ tSQLSetColumnType(&yylhsminor.yy223, &yymsp[-3].minor.yy0);
} else {
- yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy271; // negative value of name length
- tSQLSetColumnType(&yylhsminor.yy181, &yymsp[-3].minor.yy0);
+ yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy207; // negative value of name length
+ tSQLSetColumnType(&yylhsminor.yy223, &yymsp[-3].minor.yy0);
}
}
- yymsp[-3].minor.yy181 = yylhsminor.yy181;
+ yymsp[-3].minor.yy223 = yylhsminor.yy223;
break;
- case 109: /* signed ::= INTEGER */
-{ yylhsminor.yy271 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[0].minor.yy271 = yylhsminor.yy271;
+ case 112: /* signed ::= INTEGER */
+{ yylhsminor.yy207 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[0].minor.yy207 = yylhsminor.yy207;
break;
- case 110: /* signed ::= PLUS INTEGER */
-{ yymsp[-1].minor.yy271 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ case 113: /* signed ::= PLUS INTEGER */
+{ yymsp[-1].minor.yy207 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break;
- case 111: /* signed ::= MINUS INTEGER */
-{ yymsp[-1].minor.yy271 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);}
+ case 114: /* signed ::= MINUS INTEGER */
+{ yymsp[-1].minor.yy207 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);}
break;
- case 112: /* cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */
+ case 115: /* cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */
{
yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n;
setCreatedTableName(pInfo, &yymsp[-2].minor.yy0, &yymsp[-3].minor.yy0);
}
break;
- case 113: /* create_table_args ::= LP columnlist RP */
+ case 116: /* create_table_args ::= LP columnlist RP */
{
- yymsp[-2].minor.yy374 = tSetCreateSQLElems(yymsp[-1].minor.yy449, NULL, NULL, NULL, NULL, TSQL_CREATE_TABLE);
- setSQLInfo(pInfo, yymsp[-2].minor.yy374, NULL, TSDB_SQL_CREATE_TABLE);
+ yymsp[-2].minor.yy470 = tSetCreateSQLElems(yymsp[-1].minor.yy523, NULL, NULL, NULL, NULL, TSQL_CREATE_TABLE);
+ setSQLInfo(pInfo, yymsp[-2].minor.yy470, NULL, TSDB_SQL_CREATE_TABLE);
}
break;
- case 114: /* create_table_args ::= LP columnlist RP TAGS LP columnlist RP */
+ case 117: /* create_table_args ::= LP columnlist RP TAGS LP columnlist RP */
{
- yymsp[-6].minor.yy374 = tSetCreateSQLElems(yymsp[-5].minor.yy449, yymsp[-1].minor.yy449, NULL, NULL, NULL, TSQL_CREATE_STABLE);
- setSQLInfo(pInfo, yymsp[-6].minor.yy374, NULL, TSDB_SQL_CREATE_TABLE);
+ yymsp[-6].minor.yy470 = tSetCreateSQLElems(yymsp[-5].minor.yy523, yymsp[-1].minor.yy523, NULL, NULL, NULL, TSQL_CREATE_STABLE);
+ setSQLInfo(pInfo, yymsp[-6].minor.yy470, NULL, TSDB_SQL_CREATE_TABLE);
}
break;
- case 115: /* create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */
+ case 118: /* create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */
{
yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
- yymsp[-6].minor.yy374 = tSetCreateSQLElems(NULL, NULL, &yymsp[-5].minor.yy0, yymsp[-1].minor.yy494, NULL, TSQL_CREATE_TABLE_FROM_STABLE);
- setSQLInfo(pInfo, yymsp[-6].minor.yy374, NULL, TSDB_SQL_CREATE_TABLE);
+ yymsp[-6].minor.yy470 = tSetCreateSQLElems(NULL, NULL, &yymsp[-5].minor.yy0, yymsp[-1].minor.yy498, NULL, TSQL_CREATE_TABLE_FROM_STABLE);
+ setSQLInfo(pInfo, yymsp[-6].minor.yy470, NULL, TSDB_SQL_CREATE_TABLE);
}
break;
- case 116: /* create_table_args ::= AS select */
+ case 119: /* create_table_args ::= AS select */
{
- yymsp[-1].minor.yy374 = tSetCreateSQLElems(NULL, NULL, NULL, NULL, yymsp[0].minor.yy150, TSQL_CREATE_STREAM);
- setSQLInfo(pInfo, yymsp[-1].minor.yy374, NULL, TSDB_SQL_CREATE_TABLE);
+ yymsp[-1].minor.yy470 = tSetCreateSQLElems(NULL, NULL, NULL, NULL, yymsp[0].minor.yy414, TSQL_CREATE_STREAM);
+ setSQLInfo(pInfo, yymsp[-1].minor.yy470, NULL, TSDB_SQL_CREATE_TABLE);
}
break;
- case 117: /* columnlist ::= columnlist COMMA column */
-{yylhsminor.yy449 = tFieldListAppend(yymsp[-2].minor.yy449, &yymsp[0].minor.yy181); }
- yymsp[-2].minor.yy449 = yylhsminor.yy449;
+ case 120: /* columnlist ::= columnlist COMMA column */
+{yylhsminor.yy523 = tFieldListAppend(yymsp[-2].minor.yy523, &yymsp[0].minor.yy223); }
+ yymsp[-2].minor.yy523 = yylhsminor.yy523;
break;
- case 118: /* columnlist ::= column */
-{yylhsminor.yy449 = tFieldListAppend(NULL, &yymsp[0].minor.yy181);}
- yymsp[0].minor.yy449 = yylhsminor.yy449;
+ case 121: /* columnlist ::= column */
+{yylhsminor.yy523 = tFieldListAppend(NULL, &yymsp[0].minor.yy223);}
+ yymsp[0].minor.yy523 = yylhsminor.yy523;
break;
- case 119: /* column ::= ids typename */
+ case 122: /* column ::= ids typename */
{
- tSQLSetColumnInfo(&yylhsminor.yy181, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy181);
+ tSQLSetColumnInfo(&yylhsminor.yy223, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy223);
}
- yymsp[-1].minor.yy181 = yylhsminor.yy181;
+ yymsp[-1].minor.yy223 = yylhsminor.yy223;
break;
- case 120: /* tagitemlist ::= tagitemlist COMMA tagitem */
-{ yylhsminor.yy494 = tVariantListAppend(yymsp[-2].minor.yy494, &yymsp[0].minor.yy312, -1); }
- yymsp[-2].minor.yy494 = yylhsminor.yy494;
+ case 123: /* tagitemlist ::= tagitemlist COMMA tagitem */
+{ yylhsminor.yy498 = tVariantListAppend(yymsp[-2].minor.yy498, &yymsp[0].minor.yy134, -1); }
+ yymsp[-2].minor.yy498 = yylhsminor.yy498;
break;
- case 121: /* tagitemlist ::= tagitem */
-{ yylhsminor.yy494 = tVariantListAppend(NULL, &yymsp[0].minor.yy312, -1); }
- yymsp[0].minor.yy494 = yylhsminor.yy494;
+ case 124: /* tagitemlist ::= tagitem */
+{ yylhsminor.yy498 = tVariantListAppend(NULL, &yymsp[0].minor.yy134, -1); }
+ yymsp[0].minor.yy498 = yylhsminor.yy498;
break;
- case 122: /* tagitem ::= INTEGER */
- case 123: /* tagitem ::= FLOAT */ yytestcase(yyruleno==123);
- case 124: /* tagitem ::= STRING */ yytestcase(yyruleno==124);
- case 125: /* tagitem ::= BOOL */ yytestcase(yyruleno==125);
-{toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy312, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy312 = yylhsminor.yy312;
+ case 125: /* tagitem ::= INTEGER */
+ case 126: /* tagitem ::= FLOAT */ yytestcase(yyruleno==126);
+ case 127: /* tagitem ::= STRING */ yytestcase(yyruleno==127);
+ case 128: /* tagitem ::= BOOL */ yytestcase(yyruleno==128);
+{toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy134, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy134 = yylhsminor.yy134;
break;
- case 126: /* tagitem ::= NULL */
-{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy312, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy312 = yylhsminor.yy312;
+ case 129: /* tagitem ::= NULL */
+{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy134, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy134 = yylhsminor.yy134;
break;
- case 127: /* tagitem ::= MINUS INTEGER */
- case 128: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==128);
- case 129: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==129);
- case 130: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==130);
+ case 130: /* tagitem ::= MINUS INTEGER */
+ case 131: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==131);
+ case 132: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==132);
+ case 133: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==133);
{
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type;
toTSDBType(yymsp[-1].minor.yy0.type);
- tVariantCreate(&yylhsminor.yy312, &yymsp[-1].minor.yy0);
+ tVariantCreate(&yylhsminor.yy134, &yymsp[-1].minor.yy0);
}
- yymsp[-1].minor.yy312 = yylhsminor.yy312;
+ yymsp[-1].minor.yy134 = yylhsminor.yy134;
break;
- case 131: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
+ case 134: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
{
- yylhsminor.yy150 = tSetQuerySQLElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy224, yymsp[-9].minor.yy494, yymsp[-8].minor.yy66, yymsp[-4].minor.yy494, yymsp[-3].minor.yy494, &yymsp[-7].minor.yy314, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy494, &yymsp[0].minor.yy188, &yymsp[-1].minor.yy188);
+ yylhsminor.yy414 = tSetQuerySQLElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy290, yymsp[-9].minor.yy498, yymsp[-8].minor.yy64, yymsp[-4].minor.yy498, yymsp[-3].minor.yy498, &yymsp[-7].minor.yy532, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy498, &yymsp[0].minor.yy216, &yymsp[-1].minor.yy216);
}
- yymsp[-11].minor.yy150 = yylhsminor.yy150;
+ yymsp[-11].minor.yy414 = yylhsminor.yy414;
break;
- case 132: /* union ::= select */
-{ yylhsminor.yy25 = setSubclause(NULL, yymsp[0].minor.yy150); }
- yymsp[0].minor.yy25 = yylhsminor.yy25;
+ case 135: /* union ::= select */
+{ yylhsminor.yy231 = setSubclause(NULL, yymsp[0].minor.yy414); }
+ yymsp[0].minor.yy231 = yylhsminor.yy231;
break;
- case 133: /* union ::= LP union RP */
-{ yymsp[-2].minor.yy25 = yymsp[-1].minor.yy25; }
+ case 136: /* union ::= LP union RP */
+{ yymsp[-2].minor.yy231 = yymsp[-1].minor.yy231; }
break;
- case 134: /* union ::= union UNION ALL select */
-{ yylhsminor.yy25 = appendSelectClause(yymsp[-3].minor.yy25, yymsp[0].minor.yy150); }
- yymsp[-3].minor.yy25 = yylhsminor.yy25;
+ case 137: /* union ::= union UNION ALL select */
+{ yylhsminor.yy231 = appendSelectClause(yymsp[-3].minor.yy231, yymsp[0].minor.yy414); }
+ yymsp[-3].minor.yy231 = yylhsminor.yy231;
break;
- case 135: /* union ::= union UNION ALL LP select RP */
-{ yylhsminor.yy25 = appendSelectClause(yymsp[-5].minor.yy25, yymsp[-1].minor.yy150); }
- yymsp[-5].minor.yy25 = yylhsminor.yy25;
+ case 138: /* union ::= union UNION ALL LP select RP */
+{ yylhsminor.yy231 = appendSelectClause(yymsp[-5].minor.yy231, yymsp[-1].minor.yy414); }
+ yymsp[-5].minor.yy231 = yylhsminor.yy231;
break;
- case 136: /* cmd ::= union */
-{ setSQLInfo(pInfo, yymsp[0].minor.yy25, NULL, TSDB_SQL_SELECT); }
+ case 139: /* cmd ::= union */
+{ setSQLInfo(pInfo, yymsp[0].minor.yy231, NULL, TSDB_SQL_SELECT); }
break;
- case 137: /* select ::= SELECT selcollist */
+ case 140: /* select ::= SELECT selcollist */
{
- yylhsminor.yy150 = tSetQuerySQLElems(&yymsp[-1].minor.yy0, yymsp[0].minor.yy224, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ yylhsminor.yy414 = tSetQuerySQLElems(&yymsp[-1].minor.yy0, yymsp[0].minor.yy290, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
- yymsp[-1].minor.yy150 = yylhsminor.yy150;
+ yymsp[-1].minor.yy414 = yylhsminor.yy414;
break;
- case 138: /* sclp ::= selcollist COMMA */
-{yylhsminor.yy224 = yymsp[-1].minor.yy224;}
- yymsp[-1].minor.yy224 = yylhsminor.yy224;
+ case 141: /* sclp ::= selcollist COMMA */
+{yylhsminor.yy290 = yymsp[-1].minor.yy290;}
+ yymsp[-1].minor.yy290 = yylhsminor.yy290;
break;
- case 139: /* sclp ::= */
-{yymsp[1].minor.yy224 = 0;}
+ case 142: /* sclp ::= */
+{yymsp[1].minor.yy290 = 0;}
break;
- case 140: /* selcollist ::= sclp expr as */
+ case 143: /* selcollist ::= sclp expr as */
{
- yylhsminor.yy224 = tSQLExprListAppend(yymsp[-2].minor.yy224, yymsp[-1].minor.yy66, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0);
+ yylhsminor.yy290 = tSQLExprListAppend(yymsp[-2].minor.yy290, yymsp[-1].minor.yy64, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0);
}
- yymsp[-2].minor.yy224 = yylhsminor.yy224;
+ yymsp[-2].minor.yy290 = yylhsminor.yy290;
break;
- case 141: /* selcollist ::= sclp STAR */
+ case 144: /* selcollist ::= sclp STAR */
{
tSQLExpr *pNode = tSQLExprIdValueCreate(NULL, TK_ALL);
- yylhsminor.yy224 = tSQLExprListAppend(yymsp[-1].minor.yy224, pNode, 0);
+ yylhsminor.yy290 = tSQLExprListAppend(yymsp[-1].minor.yy290, pNode, 0);
}
- yymsp[-1].minor.yy224 = yylhsminor.yy224;
+ yymsp[-1].minor.yy290 = yylhsminor.yy290;
break;
- case 142: /* as ::= AS ids */
+ case 145: /* as ::= AS ids */
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
break;
- case 143: /* as ::= ids */
+ case 146: /* as ::= ids */
{ yylhsminor.yy0 = yymsp[0].minor.yy0; }
yymsp[0].minor.yy0 = yylhsminor.yy0;
break;
- case 144: /* as ::= */
+ case 147: /* as ::= */
{ yymsp[1].minor.yy0.n = 0; }
break;
- case 145: /* from ::= FROM tablelist */
-{yymsp[-1].minor.yy494 = yymsp[0].minor.yy494;}
+ case 148: /* from ::= FROM tablelist */
+{yymsp[-1].minor.yy498 = yymsp[0].minor.yy498;}
break;
- case 146: /* tablelist ::= ids cpxName */
+ case 149: /* tablelist ::= ids cpxName */
{
toTSDBType(yymsp[-1].minor.yy0.type);
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
- yylhsminor.yy494 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);
- yylhsminor.yy494 = tVariantListAppendToken(yylhsminor.yy494, &yymsp[-1].minor.yy0, -1); // table alias name
+ yylhsminor.yy498 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);
+ yylhsminor.yy498 = tVariantListAppendToken(yylhsminor.yy498, &yymsp[-1].minor.yy0, -1); // table alias name
}
- yymsp[-1].minor.yy494 = yylhsminor.yy494;
+ yymsp[-1].minor.yy498 = yylhsminor.yy498;
break;
- case 147: /* tablelist ::= ids cpxName ids */
+ case 150: /* tablelist ::= ids cpxName ids */
{
toTSDBType(yymsp[-2].minor.yy0.type);
toTSDBType(yymsp[0].minor.yy0.type);
yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n;
- yylhsminor.yy494 = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1);
- yylhsminor.yy494 = tVariantListAppendToken(yylhsminor.yy494, &yymsp[0].minor.yy0, -1);
+ yylhsminor.yy498 = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1);
+ yylhsminor.yy498 = tVariantListAppendToken(yylhsminor.yy498, &yymsp[0].minor.yy0, -1);
}
- yymsp[-2].minor.yy494 = yylhsminor.yy494;
+ yymsp[-2].minor.yy498 = yylhsminor.yy498;
break;
- case 148: /* tablelist ::= tablelist COMMA ids cpxName */
+ case 151: /* tablelist ::= tablelist COMMA ids cpxName */
{
toTSDBType(yymsp[-1].minor.yy0.type);
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
- yylhsminor.yy494 = tVariantListAppendToken(yymsp[-3].minor.yy494, &yymsp[-1].minor.yy0, -1);
- yylhsminor.yy494 = tVariantListAppendToken(yylhsminor.yy494, &yymsp[-1].minor.yy0, -1);
+ yylhsminor.yy498 = tVariantListAppendToken(yymsp[-3].minor.yy498, &yymsp[-1].minor.yy0, -1);
+ yylhsminor.yy498 = tVariantListAppendToken(yylhsminor.yy498, &yymsp[-1].minor.yy0, -1);
}
- yymsp[-3].minor.yy494 = yylhsminor.yy494;
+ yymsp[-3].minor.yy498 = yylhsminor.yy498;
break;
- case 149: /* tablelist ::= tablelist COMMA ids cpxName ids */
+ case 152: /* tablelist ::= tablelist COMMA ids cpxName ids */
{
toTSDBType(yymsp[-2].minor.yy0.type);
toTSDBType(yymsp[0].minor.yy0.type);
yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n;
- yylhsminor.yy494 = tVariantListAppendToken(yymsp[-4].minor.yy494, &yymsp[-2].minor.yy0, -1);
- yylhsminor.yy494 = tVariantListAppendToken(yylhsminor.yy494, &yymsp[0].minor.yy0, -1);
+ yylhsminor.yy498 = tVariantListAppendToken(yymsp[-4].minor.yy498, &yymsp[-2].minor.yy0, -1);
+ yylhsminor.yy498 = tVariantListAppendToken(yylhsminor.yy498, &yymsp[0].minor.yy0, -1);
}
- yymsp[-4].minor.yy494 = yylhsminor.yy494;
+ yymsp[-4].minor.yy498 = yylhsminor.yy498;
break;
- case 150: /* tmvar ::= VARIABLE */
+ case 153: /* tmvar ::= VARIABLE */
{yylhsminor.yy0 = yymsp[0].minor.yy0;}
yymsp[0].minor.yy0 = yylhsminor.yy0;
break;
- case 151: /* interval_opt ::= INTERVAL LP tmvar RP */
-{yymsp[-3].minor.yy314.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy314.offset.n = 0; yymsp[-3].minor.yy314.offset.z = NULL; yymsp[-3].minor.yy314.offset.type = 0;}
+ case 154: /* interval_opt ::= INTERVAL LP tmvar RP */
+{yymsp[-3].minor.yy532.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy532.offset.n = 0; yymsp[-3].minor.yy532.offset.z = NULL; yymsp[-3].minor.yy532.offset.type = 0;}
break;
- case 152: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */
-{yymsp[-5].minor.yy314.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy314.offset = yymsp[-1].minor.yy0;}
+ case 155: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */
+{yymsp[-5].minor.yy532.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy532.offset = yymsp[-1].minor.yy0;}
break;
- case 153: /* interval_opt ::= */
-{memset(&yymsp[1].minor.yy314, 0, sizeof(yymsp[1].minor.yy314));}
+ case 156: /* interval_opt ::= */
+{memset(&yymsp[1].minor.yy532, 0, sizeof(yymsp[1].minor.yy532));}
break;
- case 154: /* fill_opt ::= */
-{yymsp[1].minor.yy494 = 0; }
+ case 157: /* fill_opt ::= */
+{yymsp[1].minor.yy498 = 0; }
break;
- case 155: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */
+ case 158: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */
{
tVariant A = {0};
toTSDBType(yymsp[-3].minor.yy0.type);
tVariantCreate(&A, &yymsp[-3].minor.yy0);
- tVariantListInsert(yymsp[-1].minor.yy494, &A, -1, 0);
- yymsp[-5].minor.yy494 = yymsp[-1].minor.yy494;
+ tVariantListInsert(yymsp[-1].minor.yy498, &A, -1, 0);
+ yymsp[-5].minor.yy498 = yymsp[-1].minor.yy498;
}
break;
- case 156: /* fill_opt ::= FILL LP ID RP */
+ case 159: /* fill_opt ::= FILL LP ID RP */
{
toTSDBType(yymsp[-1].minor.yy0.type);
- yymsp[-3].minor.yy494 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);
+ yymsp[-3].minor.yy498 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);
}
break;
- case 157: /* sliding_opt ::= SLIDING LP tmvar RP */
+ case 160: /* sliding_opt ::= SLIDING LP tmvar RP */
{yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; }
break;
- case 158: /* sliding_opt ::= */
+ case 161: /* sliding_opt ::= */
{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; }
break;
- case 159: /* orderby_opt ::= */
- case 167: /* groupby_opt ::= */ yytestcase(yyruleno==167);
-{yymsp[1].minor.yy494 = 0;}
+ case 162: /* orderby_opt ::= */
+ case 170: /* groupby_opt ::= */ yytestcase(yyruleno==170);
+{yymsp[1].minor.yy498 = 0;}
break;
- case 160: /* orderby_opt ::= ORDER BY sortlist */
- case 168: /* groupby_opt ::= GROUP BY grouplist */ yytestcase(yyruleno==168);
-{yymsp[-2].minor.yy494 = yymsp[0].minor.yy494;}
+ case 163: /* orderby_opt ::= ORDER BY sortlist */
+ case 171: /* groupby_opt ::= GROUP BY grouplist */ yytestcase(yyruleno==171);
+{yymsp[-2].minor.yy498 = yymsp[0].minor.yy498;}
break;
- case 161: /* sortlist ::= sortlist COMMA item sortorder */
+ case 164: /* sortlist ::= sortlist COMMA item sortorder */
{
- yylhsminor.yy494 = tVariantListAppend(yymsp[-3].minor.yy494, &yymsp[-1].minor.yy312, yymsp[0].minor.yy82);
+ yylhsminor.yy498 = tVariantListAppend(yymsp[-3].minor.yy498, &yymsp[-1].minor.yy134, yymsp[0].minor.yy46);
}
- yymsp[-3].minor.yy494 = yylhsminor.yy494;
+ yymsp[-3].minor.yy498 = yylhsminor.yy498;
break;
- case 162: /* sortlist ::= item sortorder */
+ case 165: /* sortlist ::= item sortorder */
{
- yylhsminor.yy494 = tVariantListAppend(NULL, &yymsp[-1].minor.yy312, yymsp[0].minor.yy82);
+ yylhsminor.yy498 = tVariantListAppend(NULL, &yymsp[-1].minor.yy134, yymsp[0].minor.yy46);
}
- yymsp[-1].minor.yy494 = yylhsminor.yy494;
+ yymsp[-1].minor.yy498 = yylhsminor.yy498;
break;
- case 163: /* item ::= ids cpxName */
+ case 166: /* item ::= ids cpxName */
{
toTSDBType(yymsp[-1].minor.yy0.type);
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
- tVariantCreate(&yylhsminor.yy312, &yymsp[-1].minor.yy0);
+ tVariantCreate(&yylhsminor.yy134, &yymsp[-1].minor.yy0);
}
- yymsp[-1].minor.yy312 = yylhsminor.yy312;
+ yymsp[-1].minor.yy134 = yylhsminor.yy134;
break;
- case 164: /* sortorder ::= ASC */
-{yymsp[0].minor.yy82 = TSDB_ORDER_ASC; }
+ case 167: /* sortorder ::= ASC */
+{yymsp[0].minor.yy46 = TSDB_ORDER_ASC; }
break;
- case 165: /* sortorder ::= DESC */
-{yymsp[0].minor.yy82 = TSDB_ORDER_DESC;}
+ case 168: /* sortorder ::= DESC */
+{yymsp[0].minor.yy46 = TSDB_ORDER_DESC;}
break;
- case 166: /* sortorder ::= */
-{yymsp[1].minor.yy82 = TSDB_ORDER_ASC;}
+ case 169: /* sortorder ::= */
+{yymsp[1].minor.yy46 = TSDB_ORDER_ASC;}
break;
- case 169: /* grouplist ::= grouplist COMMA item */
+ case 172: /* grouplist ::= grouplist COMMA item */
{
- yylhsminor.yy494 = tVariantListAppend(yymsp[-2].minor.yy494, &yymsp[0].minor.yy312, -1);
+ yylhsminor.yy498 = tVariantListAppend(yymsp[-2].minor.yy498, &yymsp[0].minor.yy134, -1);
}
- yymsp[-2].minor.yy494 = yylhsminor.yy494;
+ yymsp[-2].minor.yy498 = yylhsminor.yy498;
break;
- case 170: /* grouplist ::= item */
+ case 173: /* grouplist ::= item */
{
- yylhsminor.yy494 = tVariantListAppend(NULL, &yymsp[0].minor.yy312, -1);
+ yylhsminor.yy498 = tVariantListAppend(NULL, &yymsp[0].minor.yy134, -1);
}
- yymsp[0].minor.yy494 = yylhsminor.yy494;
+ yymsp[0].minor.yy498 = yylhsminor.yy498;
break;
- case 171: /* having_opt ::= */
- case 181: /* where_opt ::= */ yytestcase(yyruleno==181);
- case 219: /* expritem ::= */ yytestcase(yyruleno==219);
-{yymsp[1].minor.yy66 = 0;}
+ case 174: /* having_opt ::= */
+ case 184: /* where_opt ::= */ yytestcase(yyruleno==184);
+ case 222: /* expritem ::= */ yytestcase(yyruleno==222);
+{yymsp[1].minor.yy64 = 0;}
break;
- case 172: /* having_opt ::= HAVING expr */
- case 182: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==182);
-{yymsp[-1].minor.yy66 = yymsp[0].minor.yy66;}
+ case 175: /* having_opt ::= HAVING expr */
+ case 185: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==185);
+{yymsp[-1].minor.yy64 = yymsp[0].minor.yy64;}
break;
- case 173: /* limit_opt ::= */
- case 177: /* slimit_opt ::= */ yytestcase(yyruleno==177);
-{yymsp[1].minor.yy188.limit = -1; yymsp[1].minor.yy188.offset = 0;}
+ case 176: /* limit_opt ::= */
+ case 180: /* slimit_opt ::= */ yytestcase(yyruleno==180);
+{yymsp[1].minor.yy216.limit = -1; yymsp[1].minor.yy216.offset = 0;}
break;
- case 174: /* limit_opt ::= LIMIT signed */
- case 178: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==178);
-{yymsp[-1].minor.yy188.limit = yymsp[0].minor.yy271; yymsp[-1].minor.yy188.offset = 0;}
+ case 177: /* limit_opt ::= LIMIT signed */
+ case 181: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==181);
+{yymsp[-1].minor.yy216.limit = yymsp[0].minor.yy207; yymsp[-1].minor.yy216.offset = 0;}
break;
- case 175: /* limit_opt ::= LIMIT signed OFFSET signed */
- case 179: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ yytestcase(yyruleno==179);
-{yymsp[-3].minor.yy188.limit = yymsp[-2].minor.yy271; yymsp[-3].minor.yy188.offset = yymsp[0].minor.yy271;}
+ case 178: /* limit_opt ::= LIMIT signed OFFSET signed */
+ case 182: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ yytestcase(yyruleno==182);
+{yymsp[-3].minor.yy216.limit = yymsp[-2].minor.yy207; yymsp[-3].minor.yy216.offset = yymsp[0].minor.yy207;}
break;
- case 176: /* limit_opt ::= LIMIT signed COMMA signed */
- case 180: /* slimit_opt ::= SLIMIT signed COMMA signed */ yytestcase(yyruleno==180);
-{yymsp[-3].minor.yy188.limit = yymsp[0].minor.yy271; yymsp[-3].minor.yy188.offset = yymsp[-2].minor.yy271;}
+ case 179: /* limit_opt ::= LIMIT signed COMMA signed */
+ case 183: /* slimit_opt ::= SLIMIT signed COMMA signed */ yytestcase(yyruleno==183);
+{yymsp[-3].minor.yy216.limit = yymsp[0].minor.yy207; yymsp[-3].minor.yy216.offset = yymsp[-2].minor.yy207;}
break;
- case 183: /* expr ::= LP expr RP */
-{yymsp[-2].minor.yy66 = yymsp[-1].minor.yy66; }
+ case 186: /* expr ::= LP expr RP */
+{yymsp[-2].minor.yy64 = yymsp[-1].minor.yy64; }
break;
- case 184: /* expr ::= ID */
-{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);}
- yymsp[0].minor.yy66 = yylhsminor.yy66;
+ case 187: /* expr ::= ID */
+{yylhsminor.yy64 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);}
+ yymsp[0].minor.yy64 = yylhsminor.yy64;
break;
- case 185: /* expr ::= ID DOT ID */
-{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);}
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 188: /* expr ::= ID DOT ID */
+{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy64 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);}
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 186: /* expr ::= ID DOT STAR */
-{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);}
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 189: /* expr ::= ID DOT STAR */
+{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy64 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);}
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 187: /* expr ::= INTEGER */
-{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);}
- yymsp[0].minor.yy66 = yylhsminor.yy66;
+ case 190: /* expr ::= INTEGER */
+{yylhsminor.yy64 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);}
+ yymsp[0].minor.yy64 = yylhsminor.yy64;
break;
- case 188: /* expr ::= MINUS INTEGER */
- case 189: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==189);
-{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);}
- yymsp[-1].minor.yy66 = yylhsminor.yy66;
+ case 191: /* expr ::= MINUS INTEGER */
+ case 192: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==192);
+{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy64 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);}
+ yymsp[-1].minor.yy64 = yylhsminor.yy64;
break;
- case 190: /* expr ::= FLOAT */
-{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);}
- yymsp[0].minor.yy66 = yylhsminor.yy66;
+ case 193: /* expr ::= FLOAT */
+{yylhsminor.yy64 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);}
+ yymsp[0].minor.yy64 = yylhsminor.yy64;
break;
- case 191: /* expr ::= MINUS FLOAT */
- case 192: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==192);
-{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);}
- yymsp[-1].minor.yy66 = yylhsminor.yy66;
+ case 194: /* expr ::= MINUS FLOAT */
+ case 195: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==195);
+{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy64 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);}
+ yymsp[-1].minor.yy64 = yylhsminor.yy64;
break;
- case 193: /* expr ::= STRING */
-{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);}
- yymsp[0].minor.yy66 = yylhsminor.yy66;
+ case 196: /* expr ::= STRING */
+{yylhsminor.yy64 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);}
+ yymsp[0].minor.yy64 = yylhsminor.yy64;
break;
- case 194: /* expr ::= NOW */
-{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); }
- yymsp[0].minor.yy66 = yylhsminor.yy66;
+ case 197: /* expr ::= NOW */
+{yylhsminor.yy64 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); }
+ yymsp[0].minor.yy64 = yylhsminor.yy64;
break;
- case 195: /* expr ::= VARIABLE */
-{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);}
- yymsp[0].minor.yy66 = yylhsminor.yy66;
+ case 198: /* expr ::= VARIABLE */
+{yylhsminor.yy64 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);}
+ yymsp[0].minor.yy64 = yylhsminor.yy64;
break;
- case 196: /* expr ::= BOOL */
-{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);}
- yymsp[0].minor.yy66 = yylhsminor.yy66;
+ case 199: /* expr ::= BOOL */
+{yylhsminor.yy64 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);}
+ yymsp[0].minor.yy64 = yylhsminor.yy64;
break;
- case 197: /* expr ::= ID LP exprlist RP */
-{ yylhsminor.yy66 = tSQLExprCreateFunction(yymsp[-1].minor.yy224, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
- yymsp[-3].minor.yy66 = yylhsminor.yy66;
+ case 200: /* expr ::= ID LP exprlist RP */
+{ yylhsminor.yy64 = tSQLExprCreateFunction(yymsp[-1].minor.yy290, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
+ yymsp[-3].minor.yy64 = yylhsminor.yy64;
break;
- case 198: /* expr ::= ID LP STAR RP */
-{ yylhsminor.yy66 = tSQLExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
- yymsp[-3].minor.yy66 = yylhsminor.yy66;
+ case 201: /* expr ::= ID LP STAR RP */
+{ yylhsminor.yy64 = tSQLExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
+ yymsp[-3].minor.yy64 = yylhsminor.yy64;
break;
- case 199: /* expr ::= expr IS NULL */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, NULL, TK_ISNULL);}
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 202: /* expr ::= expr IS NULL */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-2].minor.yy64, NULL, TK_ISNULL);}
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 200: /* expr ::= expr IS NOT NULL */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-3].minor.yy66, NULL, TK_NOTNULL);}
- yymsp[-3].minor.yy66 = yylhsminor.yy66;
+ case 203: /* expr ::= expr IS NOT NULL */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-3].minor.yy64, NULL, TK_NOTNULL);}
+ yymsp[-3].minor.yy64 = yylhsminor.yy64;
break;
- case 201: /* expr ::= expr LT expr */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_LT);}
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 204: /* expr ::= expr LT expr */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-2].minor.yy64, yymsp[0].minor.yy64, TK_LT);}
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 202: /* expr ::= expr GT expr */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_GT);}
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 205: /* expr ::= expr GT expr */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-2].minor.yy64, yymsp[0].minor.yy64, TK_GT);}
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 203: /* expr ::= expr LE expr */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_LE);}
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 206: /* expr ::= expr LE expr */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-2].minor.yy64, yymsp[0].minor.yy64, TK_LE);}
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 204: /* expr ::= expr GE expr */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_GE);}
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 207: /* expr ::= expr GE expr */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-2].minor.yy64, yymsp[0].minor.yy64, TK_GE);}
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 205: /* expr ::= expr NE expr */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_NE);}
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 208: /* expr ::= expr NE expr */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-2].minor.yy64, yymsp[0].minor.yy64, TK_NE);}
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 206: /* expr ::= expr EQ expr */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_EQ);}
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 209: /* expr ::= expr EQ expr */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-2].minor.yy64, yymsp[0].minor.yy64, TK_EQ);}
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 207: /* expr ::= expr AND expr */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_AND);}
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 210: /* expr ::= expr AND expr */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-2].minor.yy64, yymsp[0].minor.yy64, TK_AND);}
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 208: /* expr ::= expr OR expr */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_OR); }
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 211: /* expr ::= expr OR expr */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-2].minor.yy64, yymsp[0].minor.yy64, TK_OR); }
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 209: /* expr ::= expr PLUS expr */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_PLUS); }
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 212: /* expr ::= expr PLUS expr */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-2].minor.yy64, yymsp[0].minor.yy64, TK_PLUS); }
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 210: /* expr ::= expr MINUS expr */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_MINUS); }
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 213: /* expr ::= expr MINUS expr */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-2].minor.yy64, yymsp[0].minor.yy64, TK_MINUS); }
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 211: /* expr ::= expr STAR expr */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_STAR); }
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 214: /* expr ::= expr STAR expr */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-2].minor.yy64, yymsp[0].minor.yy64, TK_STAR); }
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 212: /* expr ::= expr SLASH expr */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_DIVIDE);}
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 215: /* expr ::= expr SLASH expr */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-2].minor.yy64, yymsp[0].minor.yy64, TK_DIVIDE);}
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 213: /* expr ::= expr REM expr */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_REM); }
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 216: /* expr ::= expr REM expr */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-2].minor.yy64, yymsp[0].minor.yy64, TK_REM); }
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 214: /* expr ::= expr LIKE expr */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_LIKE); }
- yymsp[-2].minor.yy66 = yylhsminor.yy66;
+ case 217: /* expr ::= expr LIKE expr */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-2].minor.yy64, yymsp[0].minor.yy64, TK_LIKE); }
+ yymsp[-2].minor.yy64 = yylhsminor.yy64;
break;
- case 215: /* expr ::= expr IN LP exprlist RP */
-{yylhsminor.yy66 = tSQLExprCreate(yymsp[-4].minor.yy66, (tSQLExpr*)yymsp[-1].minor.yy224, TK_IN); }
- yymsp[-4].minor.yy66 = yylhsminor.yy66;
+ case 218: /* expr ::= expr IN LP exprlist RP */
+{yylhsminor.yy64 = tSQLExprCreate(yymsp[-4].minor.yy64, (tSQLExpr*)yymsp[-1].minor.yy290, TK_IN); }
+ yymsp[-4].minor.yy64 = yylhsminor.yy64;
break;
- case 216: /* exprlist ::= exprlist COMMA expritem */
-{yylhsminor.yy224 = tSQLExprListAppend(yymsp[-2].minor.yy224,yymsp[0].minor.yy66,0);}
- yymsp[-2].minor.yy224 = yylhsminor.yy224;
+ case 219: /* exprlist ::= exprlist COMMA expritem */
+{yylhsminor.yy290 = tSQLExprListAppend(yymsp[-2].minor.yy290,yymsp[0].minor.yy64,0);}
+ yymsp[-2].minor.yy290 = yylhsminor.yy290;
break;
- case 217: /* exprlist ::= expritem */
-{yylhsminor.yy224 = tSQLExprListAppend(0,yymsp[0].minor.yy66,0);}
- yymsp[0].minor.yy224 = yylhsminor.yy224;
+ case 220: /* exprlist ::= expritem */
+{yylhsminor.yy290 = tSQLExprListAppend(0,yymsp[0].minor.yy64,0);}
+ yymsp[0].minor.yy290 = yylhsminor.yy290;
break;
- case 218: /* expritem ::= expr */
-{yylhsminor.yy66 = yymsp[0].minor.yy66;}
- yymsp[0].minor.yy66 = yylhsminor.yy66;
+ case 221: /* expritem ::= expr */
+{yylhsminor.yy64 = yymsp[0].minor.yy64;}
+ yymsp[0].minor.yy64 = yylhsminor.yy64;
break;
- case 220: /* cmd ::= RESET QUERY CACHE */
+ case 223: /* cmd ::= RESET QUERY CACHE */
{ setDCLSQLElems(pInfo, TSDB_SQL_RESET_CACHE, 0);}
break;
- case 221: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
+ case 224: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
- SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy449, NULL, TSDB_ALTER_TABLE_ADD_COLUMN);
+ SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy523, NULL, TSDB_ALTER_TABLE_ADD_COLUMN);
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 222: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
+ case 225: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
@@ -2786,14 +2802,14 @@ static void yy_reduce(
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 223: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
+ case 226: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
- SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy449, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN);
+ SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy523, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN);
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 224: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
+ case 227: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
@@ -2804,7 +2820,7 @@ static void yy_reduce(
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 225: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
+ case 228: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
{
yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
@@ -2818,25 +2834,25 @@ static void yy_reduce(
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 226: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
+ case 229: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
{
yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n;
toTSDBType(yymsp[-2].minor.yy0.type);
tVariantList* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1);
- A = tVariantListAppend(A, &yymsp[0].minor.yy312, -1);
+ A = tVariantListAppend(A, &yymsp[0].minor.yy134, -1);
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL);
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 227: /* cmd ::= KILL CONNECTION INTEGER */
+ case 230: /* cmd ::= KILL CONNECTION INTEGER */
{setKillSQL(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);}
break;
- case 228: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */
+ case 231: /* 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 229: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */
+ case 232: /* 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:
@@ -3130,4 +3146,4 @@ void Parse(
}
#endif
return;
-}
+}
\ No newline at end of file
diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c
index d01c34c810..d89d3e275d 100644
--- a/src/rpc/src/rpcMain.c
+++ b/src/rpc/src/rpcMain.c
@@ -1622,7 +1622,7 @@ static void rpcDecRef(SRpcInfo *pRpc)
int count = atomic_sub_fetch_32(&tsRpcNum, 1);
if (count == 0) {
- taosCloseRef(tsRpcRefId);
+ // taosCloseRef(tsRpcRefId);
// tsRpcInit = PTHREAD_ONCE_INIT; // windows compliling error
}
}
diff --git a/src/tsdb/inc/tsdbMain.h b/src/tsdb/inc/tsdbMain.h
index 256b8189f8..7d40d7f00a 100644
--- a/src/tsdb/inc/tsdbMain.h
+++ b/src/tsdb/inc/tsdbMain.h
@@ -320,6 +320,15 @@ typedef struct {
void* compBuffer; // Buffer for temperary compress/decompress purpose
} SRWHelper;
+typedef struct {
+ int rowsInserted;
+ int rowsUpdated;
+ int rowsDeleteSucceed;
+ int rowsDeleteFailed;
+ int nOperations;
+ TSKEY keyFirst;
+ TSKEY keyLast;
+} SMergeInfo;
// ------------------ tsdbScan.c
typedef struct {
SFileGroup fGroup;
@@ -422,7 +431,7 @@ void tsdbCloseBufPool(STsdbRepo* pRepo);
SListNode* tsdbAllocBufBlockFromPool(STsdbRepo* pRepo);
// ------------------ tsdbMemTable.c
-int tsdbInsertRowToMem(STsdbRepo* pRepo, SDataRow row, STable* pTable);
+int tsdbUpdateRowInMem(STsdbRepo* pRepo, SDataRow row, STable* pTable);
int tsdbRefMemTable(STsdbRepo* pRepo, SMemTable* pMemTable);
int tsdbUnRefMemTable(STsdbRepo* pRepo, SMemTable* pMemTable);
int tsdbTakeMemSnapshot(STsdbRepo* pRepo, SMemTable** pMem, SMemTable** pIMem);
@@ -430,7 +439,7 @@ void tsdbUnTakeMemSnapShot(STsdbRepo* pRepo, SMemTable* pMem, SMemTable* pIMem)
void* tsdbAllocBytes(STsdbRepo* pRepo, int bytes);
int tsdbAsyncCommit(STsdbRepo* pRepo);
int tsdbLoadDataFromCache(STable* pTable, SSkipListIterator* pIter, TSKEY maxKey, int maxRowsToRead, SDataCols* pCols,
- TSKEY* filterKeys, int nFilterKeys);
+ TKEY* filterKeys, int nFilterKeys, bool keepDup, SMergeInfo* pMergeInfo);
static FORCE_INLINE SDataRow tsdbNextIterRow(SSkipListIterator* pIter) {
if (pIter == NULL) return NULL;
@@ -438,16 +447,23 @@ static FORCE_INLINE SDataRow tsdbNextIterRow(SSkipListIterator* pIter) {
SSkipListNode* node = tSkipListIterGet(pIter);
if (node == NULL) return NULL;
- return *(SDataRow *)SL_GET_NODE_DATA(node);
+ return (SDataRow)SL_GET_NODE_DATA(node);
}
static FORCE_INLINE TSKEY tsdbNextIterKey(SSkipListIterator* pIter) {
SDataRow row = tsdbNextIterRow(pIter);
- if (row == NULL) return -1;
+ if (row == NULL) return TSDB_DATA_TIMESTAMP_NULL;
return dataRowKey(row);
}
+static FORCE_INLINE TKEY tsdbNextIterTKey(SSkipListIterator* pIter) {
+ SDataRow row = tsdbNextIterRow(pIter);
+ if (row == NULL) return TKEY_NULL;
+
+ return dataRowTKey(row);
+}
+
static FORCE_INLINE STsdbBufBlock* tsdbGetCurrBufBlock(STsdbRepo* pRepo) {
ASSERT(pRepo != NULL);
if (pRepo->mem == NULL) return NULL;
diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c
index f714aadc36..9a7c2db3d3 100644
--- a/src/tsdb/src/tsdbMain.c
+++ b/src/tsdb/src/tsdbMain.c
@@ -512,6 +512,9 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) {
}
}
+ // update check
+ if (pCfg->update != 0) pCfg->update = 1;
+
return 0;
_err:
@@ -762,7 +765,7 @@ static int32_t tsdbInsertDataToTable(STsdbRepo *pRepo, SSubmitBlk *pBlock, TSKEY
return -1;
}
- if (tsdbInsertRowToMem(pRepo, row, pTable) < 0) return -1;
+ if (tsdbUpdateRowInMem(pRepo, row, pTable) < 0) return -1;
(*affectedrows)++;
points++;
@@ -923,6 +926,7 @@ static int tsdbEncodeCfg(void **buf, STsdbCfg *pCfg) {
tlen += taosEncodeVariantI32(buf, pCfg->maxRowsPerFileBlock);
tlen += taosEncodeFixedI8(buf, pCfg->precision);
tlen += taosEncodeFixedI8(buf, pCfg->compression);
+ tlen += taosEncodeFixedI8(buf, pCfg->update);
return tlen;
}
@@ -939,6 +943,7 @@ static void *tsdbDecodeCfg(void *buf, STsdbCfg *pCfg) {
buf = taosDecodeVariantI32(buf, &(pCfg->maxRowsPerFileBlock));
buf = taosDecodeFixedI8(buf, &(pCfg->precision));
buf = taosDecodeFixedI8(buf, &(pCfg->compression));
+ buf = taosDecodeFixedI8(buf, &(pCfg->update));
return buf;
}
diff --git a/src/tsdb/src/tsdbMemTable.c b/src/tsdb/src/tsdbMemTable.c
index 4cf8ddd4bd..d68a97eb13 100644
--- a/src/tsdb/src/tsdbMemTable.c
+++ b/src/tsdb/src/tsdbMemTable.c
@@ -32,43 +32,40 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitIter *iters, SRWHe
static SCommitIter *tsdbCreateCommitIters(STsdbRepo *pRepo);
static void tsdbDestroyCommitIters(SCommitIter *iters, int maxTables);
static int tsdbAdjustMemMaxTables(SMemTable *pMemTable, int maxTables);
+static int tsdbAppendTableRowToCols(STable *pTable, SDataCols *pCols, STSchema **ppSchema, SDataRow row);
// ---------------- INTERNAL FUNCTIONS ----------------
-int tsdbInsertRowToMem(STsdbRepo *pRepo, SDataRow row, STable *pTable) {
+int tsdbUpdateRowInMem(STsdbRepo *pRepo, SDataRow row, STable *pTable) {
STsdbCfg * pCfg = &pRepo->config;
STsdbMeta * pMeta = pRepo->tsdbMeta;
- int32_t level = 0;
- int32_t headSize = 0;
+ TKEY tkey = dataRowTKey(row);
TSKEY key = dataRowKey(row);
SMemTable * pMemTable = pRepo->mem;
STableData *pTableData = NULL;
- SSkipList * pSList = NULL;
+ bool isRowDelete = TKEY_IS_DELETED(tkey);
- if (pMemTable != NULL && TABLE_TID(pTable) < pMemTable->maxTables && pMemTable->tData[TABLE_TID(pTable)] != NULL &&
- pMemTable->tData[TABLE_TID(pTable)]->uid == TABLE_UID(pTable)) {
- pTableData = pMemTable->tData[TABLE_TID(pTable)];
- pSList = pTableData->pData;
- }
+ if (isRowDelete) {
+ if (!pCfg->update) {
+ tsdbWarn("vgId:%d vnode is not allowed to update but try to delete a data row", REPO_ID(pRepo));
+ terrno = TSDB_CODE_TDB_INVALID_ACTION;
+ return -1;
+ }
- tSkipListNewNodeInfo(pSList, &level, &headSize);
-
- SSkipListNode *pNode = (SSkipListNode *)malloc(headSize + sizeof(SDataRow *));
- if (pNode == NULL) {
- terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
- return -1;
+ if (key > TABLE_LASTKEY(pTable)) {
+ tsdbTrace("vgId:%d skip to delete row key %" PRId64 " which is larger than table lastKey %" PRId64,
+ REPO_ID(pRepo), key, TABLE_LASTKEY(pTable));
+ return 0;
+ }
}
void *pRow = tsdbAllocBytes(pRepo, dataRowLen(row));
if (pRow == NULL) {
tsdbError("vgId:%d failed to insert row with key %" PRId64 " to table %s while allocate %d bytes since %s",
REPO_ID(pRepo), key, TABLE_CHAR_NAME(pTable), dataRowLen(row), tstrerror(terrno));
- free(pNode);
return -1;
}
- pNode->level = level;
dataRowCpy(pRow, row);
- *(SDataRow *)SL_GET_NODE_DATA(pNode) = pRow;
// Operations above may change pRepo->mem, retake those values
ASSERT(pRepo->mem != NULL);
@@ -77,7 +74,6 @@ int tsdbInsertRowToMem(STsdbRepo *pRepo, SDataRow row, STable *pTable) {
if (TABLE_TID(pTable) >= pMemTable->maxTables) {
if (tsdbAdjustMemMaxTables(pMemTable, pMeta->maxTables) < 0) {
tsdbFreeBytes(pRepo, pRow, dataRowLen(row));
- free(pNode);
return -1;
}
}
@@ -97,7 +93,6 @@ int tsdbInsertRowToMem(STsdbRepo *pRepo, SDataRow row, STable *pTable) {
" to table %s while create new table data object since %s",
REPO_ID(pRepo), key, TABLE_CHAR_NAME(pTable), tstrerror(terrno));
tsdbFreeBytes(pRepo, (void *)pRow, dataRowLen(row));
- free(pNode);
return -1;
}
@@ -106,24 +101,31 @@ int tsdbInsertRowToMem(STsdbRepo *pRepo, SDataRow row, STable *pTable) {
ASSERT((pTableData != NULL) && pTableData->uid == TABLE_UID(pTable));
- if (tSkipListPut(pTableData->pData, pNode) == NULL) {
+ int64_t oldSize = SL_SIZE(pTableData->pData);
+ if (tSkipListPut(pTableData->pData, pRow) == NULL) {
tsdbFreeBytes(pRepo, (void *)pRow, dataRowLen(row));
- free(pNode);
} else {
- if (TABLE_LASTKEY(pTable) < key) TABLE_LASTKEY(pTable) = key;
+ int64_t deltaSize = SL_SIZE(pTableData->pData) - oldSize;
+ if (isRowDelete) {
+ if (TABLE_LASTKEY(pTable) == key) {
+ // TODO: need to update table last key here (may from file)
+ }
+ } else {
+ if (TABLE_LASTKEY(pTable) < key) TABLE_LASTKEY(pTable) = key;
+ }
+
if (pMemTable->keyFirst > key) pMemTable->keyFirst = key;
if (pMemTable->keyLast < key) pMemTable->keyLast = key;
- pMemTable->numOfRows++;
+ pMemTable->numOfRows += deltaSize;
if (pTableData->keyFirst > key) pTableData->keyFirst = key;
if (pTableData->keyLast < key) pTableData->keyLast = key;
- pTableData->numOfRows++;
-
- ASSERT(pTableData->numOfRows == tSkipListGetSize(pTableData->pData));
+ pTableData->numOfRows += deltaSize;
}
- tsdbTrace("vgId:%d a row is inserted to table %s tid %d uid %" PRIu64 " key %" PRIu64, REPO_ID(pRepo),
- TABLE_CHAR_NAME(pTable), TABLE_TID(pTable), TABLE_UID(pTable), key);
+ tsdbTrace("vgId:%d a row is %s table %s tid %d uid %" PRIu64 " key %" PRIu64, REPO_ID(pRepo),
+ isRowDelete ? "deleted from" : "updated in", TABLE_CHAR_NAME(pTable), TABLE_TID(pTable), TABLE_UID(pTable),
+ key);
return 0;
}
@@ -295,63 +297,124 @@ int tsdbAsyncCommit(STsdbRepo *pRepo) {
return 0;
}
+/**
+ * This is an important function to load data or try to load data from memory skiplist iterator.
+ *
+ * This function load memory data until:
+ * 1. iterator ends
+ * 2. data key exceeds maxKey
+ * 3. rowsIncreased = rowsInserted - rowsDeleteSucceed >= maxRowsToRead
+ * 4. operations in pCols not exceeds its max capacity if pCols is given
+ *
+ * The function tries to procceed AS MUSH AS POSSIBLE.
+ */
int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey, int maxRowsToRead, SDataCols *pCols,
- TSKEY *filterKeys, int nFilterKeys) {
- ASSERT(maxRowsToRead > 0 && nFilterKeys >= 0);
+ TKEY *filterKeys, int nFilterKeys, bool keepDup, SMergeInfo *pMergeInfo) {
+ ASSERT(maxRowsToRead > 0 && nFilterKeys >= 0 && pMergeInfo != NULL);
if (pIter == NULL) return 0;
STSchema *pSchema = NULL;
- int numOfRows = 0;
- TSKEY keyNext = 0;
+ TSKEY rowKey = 0;
+ TSKEY fKey = 0;
+ bool isRowDel = false;
int filterIter = 0;
+ SDataRow row = NULL;
- if (nFilterKeys != 0) { // for filter purpose
- ASSERT(filterKeys != NULL);
- keyNext = tsdbNextIterKey(pIter);
- if (keyNext < 0 || keyNext > maxKey) return numOfRows;
- void *ptr = taosbsearch((void *)(&keyNext), (void *)filterKeys, nFilterKeys, sizeof(TSKEY), compTSKEY, TD_GE);
- filterIter = (ptr == NULL) ? nFilterKeys : (int)((POINTER_DISTANCE(ptr, filterKeys) / sizeof(TSKEY)));
+ memset(pMergeInfo, 0, sizeof(*pMergeInfo));
+ pMergeInfo->keyFirst = INT64_MAX;
+ pMergeInfo->keyLast = INT64_MIN;
+ if (pCols) tdResetDataCols(pCols);
+
+ row = tsdbNextIterRow(pIter);
+ if (row == NULL || dataRowKey(row) > maxKey) {
+ rowKey = INT64_MAX;
+ isRowDel = false;
+ } else {
+ rowKey = dataRowKey(row);
+ isRowDel = dataRowDeleted(row);
}
- do {
- SDataRow row = tsdbNextIterRow(pIter);
- if (row == NULL) break;
+ if (filterIter >= nFilterKeys) {
+ fKey = INT64_MAX;
+ } else {
+ fKey = tdGetKey(filterKeys[filterIter]);
+ }
- keyNext = dataRowKey(row);
- if (keyNext > maxKey) break;
+ while (true) {
+ if (fKey == INT64_MAX && rowKey == INT64_MAX) break;
- bool keyFiltered = false;
- if (nFilterKeys != 0) {
- while (true) {
- if (filterIter >= nFilterKeys) break;
- if (keyNext == filterKeys[filterIter]) {
- keyFiltered = true;
- filterIter++;
- break;
- } else if (keyNext < filterKeys[filterIter]) {
- break;
+ if (fKey < rowKey) {
+ pMergeInfo->keyFirst = MIN(pMergeInfo->keyFirst, fKey);
+ pMergeInfo->keyLast = MAX(pMergeInfo->keyLast, fKey);
+
+ filterIter++;
+ if (filterIter >= nFilterKeys) {
+ fKey = INT64_MAX;
+ } else {
+ fKey = tdGetKey(filterKeys[filterIter]);
+ }
+ } else if (fKey > rowKey) {
+ if (isRowDel) {
+ pMergeInfo->rowsDeleteFailed++;
+ } else {
+ if (pMergeInfo->rowsInserted - pMergeInfo->rowsDeleteSucceed >= maxRowsToRead) break;
+ if (pCols && pMergeInfo->nOperations >= pCols->maxPoints) break;
+ pMergeInfo->rowsInserted++;
+ pMergeInfo->nOperations++;
+ pMergeInfo->keyFirst = MIN(pMergeInfo->keyFirst, rowKey);
+ pMergeInfo->keyLast = MAX(pMergeInfo->keyLast, rowKey);
+ tsdbAppendTableRowToCols(pTable, pCols, &pSchema, row);
+ }
+
+ tSkipListIterNext(pIter);
+ row = tsdbNextIterRow(pIter);
+ if (row == NULL || dataRowKey(row) > maxKey) {
+ rowKey = INT64_MAX;
+ isRowDel = false;
+ } else {
+ rowKey = dataRowKey(row);
+ isRowDel = dataRowDeleted(row);
+ }
+ } else {
+ if (isRowDel) {
+ ASSERT(!keepDup);
+ if (pCols && pMergeInfo->nOperations >= pCols->maxPoints) break;
+ pMergeInfo->rowsDeleteSucceed++;
+ pMergeInfo->nOperations++;
+ tsdbAppendTableRowToCols(pTable, pCols, &pSchema, row);
+ } else {
+ if (keepDup) {
+ if (pCols && pMergeInfo->nOperations >= pCols->maxPoints) break;
+ pMergeInfo->rowsUpdated++;
+ pMergeInfo->nOperations++;
+ pMergeInfo->keyFirst = MIN(pMergeInfo->keyFirst, rowKey);
+ pMergeInfo->keyLast = MAX(pMergeInfo->keyLast, rowKey);
+ tsdbAppendTableRowToCols(pTable, pCols, &pSchema, row);
} else {
- filterIter++;
+ pMergeInfo->keyFirst = MIN(pMergeInfo->keyFirst, fKey);
+ pMergeInfo->keyLast = MAX(pMergeInfo->keyLast, fKey);
}
}
- }
- if (!keyFiltered) {
- if (numOfRows >= maxRowsToRead) break;
- if (pCols) {
- if (pSchema == NULL || schemaVersion(pSchema) != dataRowVersion(row)) {
- pSchema = tsdbGetTableSchemaImpl(pTable, false, false, dataRowVersion(row));
- if (pSchema == NULL) {
- ASSERT(0);
- }
- }
-
- tdAppendDataRowToDataCol(row, pSchema, pCols);
+ tSkipListIterNext(pIter);
+ row = tsdbNextIterRow(pIter);
+ if (row == NULL || dataRowKey(row) > maxKey) {
+ rowKey = INT64_MAX;
+ isRowDel = false;
+ } else {
+ rowKey = dataRowKey(row);
+ isRowDel = dataRowDeleted(row);
}
- numOfRows++;
- }
- } while (tSkipListIterNext(pIter));
- return numOfRows;
+ filterIter++;
+ if (filterIter >= nFilterKeys) {
+ fKey = INT64_MAX;
+ } else {
+ fKey = tdGetKey(filterKeys[filterIter]);
+ }
+ }
+ }
+
+ return 0;
}
// ---------------- LOCAL FUNCTIONS ----------------
@@ -440,8 +503,9 @@ static STableData *tsdbNewTableData(STsdbCfg *pCfg, STable *pTable) {
pTableData->keyLast = 0;
pTableData->numOfRows = 0;
- pTableData->pData = tSkipListCreate(TSDB_DATA_SKIPLIST_LEVEL, TSDB_DATA_TYPE_TIMESTAMP,
- TYPE_BYTES[TSDB_DATA_TYPE_TIMESTAMP], 0, 0, 1, tsdbGetTsTupleKey);
+ pTableData->pData =
+ tSkipListCreate(TSDB_DATA_SKIPLIST_LEVEL, TSDB_DATA_TYPE_TIMESTAMP, TYPE_BYTES[TSDB_DATA_TYPE_TIMESTAMP],
+ tkeyComparFn, pCfg->update ? SL_UPDATE_DUP_KEY : SL_DISCARD_DUP_KEY, tsdbGetTsTupleKey);
if (pTableData->pData == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
goto _err;
@@ -461,7 +525,7 @@ static void tsdbFreeTableData(STableData *pTableData) {
}
}
-static char *tsdbGetTsTupleKey(const void *data) { return dataRowTuple(*(SDataRow *)data); }
+static char *tsdbGetTsTupleKey(const void *data) { return dataRowTuple((SDataRow)data); }
static void *tsdbCommitData(void *arg) {
STsdbRepo * pRepo = (STsdbRepo *)arg;
@@ -583,7 +647,7 @@ static void tsdbEndCommit(STsdbRepo *pRepo) {
static int tsdbHasDataToCommit(SCommitIter *iters, int nIters, TSKEY minKey, TSKEY maxKey) {
for (int i = 0; i < nIters; i++) {
TSKEY nextKey = tsdbNextIterKey((iters + i)->pIter);
- if (nextKey > 0 && (nextKey >= minKey && nextKey <= maxKey)) return 1;
+ if (nextKey != TSDB_DATA_TIMESTAMP_NULL && (nextKey >= minKey && nextKey <= maxKey)) return 1;
}
return 0;
}
@@ -779,5 +843,21 @@ static int tsdbAdjustMemMaxTables(SMemTable *pMemTable, int maxTables) {
taosTFree(tData);
+ return 0;
+}
+
+static int tsdbAppendTableRowToCols(STable *pTable, SDataCols *pCols, STSchema **ppSchema, SDataRow row) {
+ if (pCols) {
+ if (*ppSchema == NULL || schemaVersion(*ppSchema) != dataRowVersion(row)) {
+ *ppSchema = tsdbGetTableSchemaImpl(pTable, false, false, dataRowVersion(row));
+ if (*ppSchema == NULL) {
+ ASSERT(false);
+ return -1;
+ }
+ }
+
+ tdAppendDataRowToDataCol(row, *ppSchema, pCols);
+ }
+
return 0;
}
\ No newline at end of file
diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c
index a2affb8c4f..6811c976ca 100644
--- a/src/tsdb/src/tsdbMeta.c
+++ b/src/tsdb/src/tsdbMeta.c
@@ -86,7 +86,8 @@ int tsdbCreateTable(TSDB_REPO_T *repo, STableCfg *pCfg) {
if (pTable != NULL) {
tsdbError("vgId:%d table %s already exists, tid %d uid %" PRId64, REPO_ID(pRepo), TABLE_CHAR_NAME(pTable),
TABLE_TID(pTable), TABLE_UID(pTable));
- return TSDB_CODE_TDB_TABLE_ALREADY_EXIST;
+ terrno = TSDB_CODE_TDB_TABLE_ALREADY_EXIST;
+ goto _err;
}
if (pCfg->type == TSDB_CHILD_TABLE) {
@@ -643,7 +644,7 @@ static void tsdbOrgMeta(void *pHandle) {
}
static char *getTagIndexKey(const void *pData) {
- STable *pTable = *(STable **)pData;
+ STable *pTable = (STable *)pData;
STSchema *pSchema = tsdbGetTableTagSchema(pTable);
STColumn *pCol = schemaColAt(pSchema, DEFAULT_TAG_INDEX_COLUMN);
@@ -700,7 +701,7 @@ static STable *tsdbCreateTableFromCfg(STableCfg *pCfg, bool isSuper) {
}
pTable->tagVal = NULL;
STColumn *pCol = schemaColAt(pTable->tagSchema, DEFAULT_TAG_INDEX_COLUMN);
- pTable->pIndex = tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, colType(pCol), (uint8_t)(colBytes(pCol)), 1, 0, 1, getTagIndexKey);
+ pTable->pIndex = tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, colType(pCol), (uint8_t)(colBytes(pCol)), NULL, SL_ALLOW_DUP_KEY, getTagIndexKey);
if (pTable->pIndex == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
goto _err;
@@ -900,23 +901,8 @@ static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable, bool refSuper
pTable->pSuper = pSTable;
- int32_t level = 0;
- int32_t headSize = 0;
+ tSkipListPut(pSTable->pIndex, (void *)pTable);
- tSkipListNewNodeInfo(pSTable->pIndex, &level, &headSize);
-
- // NOTE: do not allocate the space for key, since in each skip list node, only keep the pointer to pTable, not the
- // actual key value, and the key value will be retrieved during query through the pTable and getTagIndexKey function
- SSkipListNode *pNode = calloc(1, headSize + sizeof(STable *));
- if (pNode == NULL) {
- terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
- return -1;
- }
- pNode->level = level;
-
- memcpy(SL_GET_NODE_DATA(pNode), &pTable, sizeof(STable *));
-
- tSkipListPut(pSTable->pIndex, pNode);
if (refSuper) T_REF_INC(pSTable);
return 0;
}
@@ -940,7 +926,7 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) {
SSkipListNode *pNode = taosArrayGetP(res, i);
// STableIndexElem* pElem = (STableIndexElem*) SL_GET_NODE_DATA(pNode);
- if (*(STable **)SL_GET_NODE_DATA(pNode) == pTable) { // this is the exact what we need
+ if ((STable *)SL_GET_NODE_DATA(pNode) == pTable) { // this is the exact what we need
tSkipListRemoveNode(pSTable->pIndex, pNode);
}
}
@@ -1170,8 +1156,8 @@ static void *tsdbDecodeTable(void *buf, STable **pRTable) {
if (TABLE_TYPE(pTable) == TSDB_SUPER_TABLE) {
buf = tdDecodeSchema(buf, &(pTable->tagSchema));
STColumn *pCol = schemaColAt(pTable->tagSchema, DEFAULT_TAG_INDEX_COLUMN);
- pTable->pIndex =
- tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, colType(pCol), (uint8_t)(colBytes(pCol)), 1, 0, 1, getTagIndexKey);
+ pTable->pIndex = tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, colType(pCol), (uint8_t)(colBytes(pCol)), NULL,
+ SL_ALLOW_DUP_KEY, getTagIndexKey);
if (pTable->pIndex == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
tsdbFreeTable(pTable);
@@ -1197,7 +1183,7 @@ static int tsdbGetTableEncodeSize(int8_t act, STable *pTable) {
tlen = sizeof(SListNode) + sizeof(SActObj) + sizeof(SActCont) + tsdbEncodeTable(NULL, pTable) + sizeof(TSCKSUM);
} else {
if (TABLE_TYPE(pTable) == TSDB_SUPER_TABLE) {
- tlen = (int)((sizeof(SListNode) + sizeof(SActObj)) * (tSkipListGetSize(pTable->pIndex) + 1));
+ tlen = (int)((sizeof(SListNode) + sizeof(SActObj)) * (SL_SIZE(pTable->pIndex) + 1));
} else {
tlen = sizeof(SListNode) + sizeof(SActObj);
}
@@ -1244,7 +1230,7 @@ static int tsdbRemoveTableFromStore(STsdbRepo *pRepo, STable *pTable) {
}
while (tSkipListIterNext(pIter)) {
- STable *tTable = *(STable **)SL_GET_NODE_DATA(tSkipListIterGet(pIter));
+ STable *tTable = (STable *)SL_GET_NODE_DATA(tSkipListIterGet(pIter));
ASSERT(TABLE_TYPE(tTable) == TSDB_CHILD_TABLE);
pBuf = tsdbInsertTableAct(pRepo, TSDB_DROP_META, pBuf, tTable);
}
@@ -1269,7 +1255,7 @@ static int tsdbRmTableFromMeta(STsdbRepo *pRepo, STable *pTable) {
tsdbWLockRepoMeta(pRepo);
while (tSkipListIterNext(pIter)) {
- STable *tTable = *(STable **)SL_GET_NODE_DATA(tSkipListIterGet(pIter));
+ STable *tTable = (STable *)SL_GET_NODE_DATA(tSkipListIterGet(pIter));
tsdbRemoveTableFromMeta(pRepo, tTable, false, false);
}
diff --git a/src/tsdb/src/tsdbRWHelper.c b/src/tsdb/src/tsdbRWHelper.c
index 9940ec40ef..98f815f78a 100644
--- a/src/tsdb/src/tsdbRWHelper.c
+++ b/src/tsdb/src/tsdbRWHelper.c
@@ -25,6 +25,7 @@
#define TSDB_GET_COMPCOL_LEN(nCols) (sizeof(SCompData) + sizeof(SCompCol) * (nCols) + sizeof(TSCKSUM))
#define TSDB_KEY_COL_OFFSET 0
#define TSDB_GET_COMPBLOCK_IDX(h, b) (POINTER_DISTANCE(b, (h)->pCompInfo->blocks)/sizeof(SCompBlock))
+#define TSDB_IS_LAST_BLOCK(pb) ((pb)->last)
static bool tsdbShouldCreateNewLast(SRWHelper *pHelper);
static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDataCols, SCompBlock *pCompBlock,
@@ -32,7 +33,7 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pD
static int compareKeyBlock(const void *arg1, const void *arg2);
static int tsdbAdjustInfoSizeIfNeeded(SRWHelper *pHelper, size_t esize);
static int tsdbInsertSuperBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkIdx);
-static int tsdbAddSubBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkIdx, int rowsAdded);
+static int tsdbAddSubBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkIdx, SMergeInfo *pMergeInfo);
static int tsdbUpdateSuperBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkIdx);
static void tsdbResetHelperFileImpl(SRWHelper *pHelper);
static int tsdbInitHelperFile(SRWHelper *pHelper);
@@ -59,8 +60,10 @@ static int tsdbLoadColData(SRWHelper *pHelper, SFile *pFile, SCompBlock *pComp
static int tsdbWriteBlockToProperFile(SRWHelper *pHelper, SDataCols *pDataCols, SCompBlock *pCompBlock);
static int tsdbProcessMergeCommit(SRWHelper *pHelper, SCommitIter *pCommitIter, SDataCols *pDataCols, TSKEY maxKey,
int *blkIdx);
-static int tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIter *pCommitIter, SDataCols *pTarget,
- TSKEY maxKey, int maxRows);
+static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIter *pCommitIter, SDataCols *pTarget,
+ TSKEY maxKey, int maxRows, int8_t update);
+static bool tsdbCheckAddSubBlockCond(SRWHelper *pHelper, SCompBlock *pCompBlock, SMergeInfo *pMergeInfo, int maxOps);
+static int tsdbDeleteSuperBlock(SRWHelper *pHelper, int blkIdx);
// ---------------------- INTERNAL FUNCTIONS ----------------------
int tsdbInitReadHelper(SRWHelper *pHelper, STsdbRepo *pRepo) {
@@ -277,7 +280,7 @@ int tsdbCommitTableData(SRWHelper *pHelper, SCommitIter *pCommitIter, SDataCols
while (true) {
ASSERT(blkIdx <= (int)pIdx->numOfBlocks);
TSKEY keyFirst = tsdbNextIterKey(pCommitIter->pIter);
- if (keyFirst < 0 || keyFirst > maxKey) break; // iter over
+ if (keyFirst == TSDB_DATA_TIMESTAMP_NULL || keyFirst > maxKey) break; // iter over
if (pIdx->len <= 0 || keyFirst > pIdx->maxKey) {
if (tsdbProcessAppendCommit(pHelper, pCommitIter, pDataCols, maxKey) < 0) return -1;
@@ -923,7 +926,7 @@ _err:
return -1;
}
-static int tsdbAddSubBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkIdx, int rowsAdded) {
+static int tsdbAddSubBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkIdx, SMergeInfo *pMergeInfo) {
ASSERT(pCompBlock->numOfSubBlocks == 0);
SCompIdx *pIdx = &(pHelper->curCompIdx);
@@ -956,9 +959,9 @@ static int tsdbAddSubBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkId
pSCompBlock->numOfSubBlocks++;
ASSERT(pSCompBlock->numOfSubBlocks <= TSDB_MAX_SUBBLOCKS);
pSCompBlock->len += sizeof(SCompBlock);
- pSCompBlock->numOfRows += rowsAdded;
- pSCompBlock->keyFirst = MIN(pSCompBlock->keyFirst, pCompBlock->keyFirst);
- pSCompBlock->keyLast = MAX(pSCompBlock->keyLast, pCompBlock->keyLast);
+ pSCompBlock->numOfRows = pSCompBlock->numOfRows + pMergeInfo->rowsInserted - pMergeInfo->rowsDeleteSucceed;
+ pSCompBlock->keyFirst = pMergeInfo->keyFirst;
+ pSCompBlock->keyLast = pMergeInfo->keyLast;
pIdx->len += sizeof(SCompBlock);
} else { // Need to create two sub-blocks
void *ptr = NULL;
@@ -987,11 +990,11 @@ static int tsdbAddSubBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkId
((SCompBlock *)ptr)[1] = *pCompBlock;
pSCompBlock->numOfSubBlocks = 2;
- pSCompBlock->numOfRows += rowsAdded;
+ pSCompBlock->numOfRows = pSCompBlock->numOfRows + pMergeInfo->rowsInserted - pMergeInfo->rowsDeleteSucceed;
pSCompBlock->offset = ((char *)ptr) - ((char *)pHelper->pCompInfo);
pSCompBlock->len = sizeof(SCompBlock) * 2;
- pSCompBlock->keyFirst = MIN(((SCompBlock *)ptr)[0].keyFirst, ((SCompBlock *)ptr)[1].keyFirst);
- pSCompBlock->keyLast = MAX(((SCompBlock *)ptr)[0].keyLast, ((SCompBlock *)ptr)[1].keyLast);
+ pSCompBlock->keyFirst = pMergeInfo->keyFirst;
+ pSCompBlock->keyLast = pMergeInfo->keyLast;
pIdx->len += (sizeof(SCompBlock) * 2);
}
@@ -1045,6 +1048,45 @@ static int tsdbUpdateSuperBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int
return 0;
}
+static int tsdbDeleteSuperBlock(SRWHelper *pHelper, int blkIdx) {
+ SCompIdx *pCompIdx = &(pHelper->curCompIdx);
+
+ ASSERT(pCompIdx->numOfBlocks > 0 && blkIdx < pCompIdx->numOfBlocks);
+
+ SCompBlock *pCompBlock= blockAtIdx(pHelper, blkIdx);
+ SCompBlock compBlock = *pCompBlock;
+ ASSERT(pCompBlock->numOfSubBlocks > 0 && pCompBlock->numOfSubBlocks <= TSDB_MAX_SUBBLOCKS);
+
+ if (pCompIdx->numOfBlocks == 1) {
+ memset(pCompIdx, 0, sizeof(*pCompIdx));
+ } else {
+ int tsize = 0;
+
+ if (compBlock.numOfSubBlocks > 1) {
+ tsize = (int)(pCompIdx->len - (compBlock.offset + sizeof(SCompBlock) * compBlock.numOfSubBlocks));
+
+ ASSERT(tsize > 0);
+ memmove(POINTER_SHIFT(pHelper->pCompInfo, compBlock.offset),
+ POINTER_SHIFT(pHelper->pCompInfo, compBlock.offset + sizeof(SCompBlock) * compBlock.numOfSubBlocks),
+ tsize);
+
+ pCompIdx->len = pCompIdx->len - sizeof(SCompBlock) * compBlock.numOfSubBlocks;
+ }
+
+ tsize = (int)(pCompIdx->len - POINTER_DISTANCE(blockAtIdx(pHelper, blkIdx + 1), pHelper->pCompInfo));
+ ASSERT(tsize > 0);
+ memmove((void *)blockAtIdx(pHelper, blkIdx), (void *)blockAtIdx(pHelper, blkIdx + 1), tsize);
+
+ pCompIdx->len -= sizeof(SCompBlock);
+
+ pCompIdx->numOfBlocks--;
+ pCompIdx->hasLast = (uint32_t)(blockAtIdx(pHelper, pCompIdx->numOfBlocks - 1)->last);
+ pCompIdx->maxKey = blockAtIdx(pHelper, pCompIdx->numOfBlocks - 1)->keyLast;
+ }
+
+ return 0;
+}
+
static void tsdbResetHelperFileImpl(SRWHelper *pHelper) {
pHelper->idxH.numOfIdx = 0;
pHelper->idxH.curIdx = 0;
@@ -1437,51 +1479,62 @@ static void *tsdbDecodeSCompIdx(void *buf, SCompIdx *pIdx) {
}
static int tsdbProcessAppendCommit(SRWHelper *pHelper, SCommitIter *pCommitIter, SDataCols *pDataCols, TSKEY maxKey) {
- STsdbCfg * pCfg = &(pHelper->pRepo->config);
- STable * pTable = pCommitIter->pTable;
- SCompIdx * pIdx = &(pHelper->curCompIdx);
- TSKEY keyFirst = tsdbNextIterKey(pCommitIter->pIter);
- int defaultRowsInBlock = pCfg->maxRowsPerFileBlock * 4 / 5;
- SCompBlock compBlock = {0};
+ STsdbCfg * pCfg = &(pHelper->pRepo->config);
+ STable * pTable = pCommitIter->pTable;
+ SCompIdx * pIdx = &(pHelper->curCompIdx);
+ TSKEY keyFirst = tsdbNextIterKey(pCommitIter->pIter);
+ int defaultRowsInBlock = pCfg->maxRowsPerFileBlock * 4 / 5;
+ SCompBlock compBlock = {0};
+ SMergeInfo mergeInfo = {0};
+ SMergeInfo *pMergeInfo = &mergeInfo;
ASSERT(pIdx->len <= 0 || keyFirst > pIdx->maxKey);
if (pIdx->hasLast) { // append to with last block
ASSERT(pIdx->len > 0);
SCompBlock *pCompBlock = blockAtIdx(pHelper, pIdx->numOfBlocks - 1);
ASSERT(pCompBlock->last && pCompBlock->numOfRows < pCfg->minRowsPerFileBlock);
- tdResetDataCols(pDataCols);
- int rowsRead = tsdbLoadDataFromCache(pTable, pCommitIter->pIter, maxKey, defaultRowsInBlock - pCompBlock->numOfRows,
- pDataCols, NULL, 0);
- ASSERT(rowsRead > 0 && rowsRead == pDataCols->numOfRows);
- if (rowsRead + pCompBlock->numOfRows < pCfg->minRowsPerFileBlock &&
- pCompBlock->numOfSubBlocks < TSDB_MAX_SUBBLOCKS && !TSDB_NLAST_FILE_OPENED(pHelper)) {
- if (tsdbWriteBlockToFile(pHelper, helperLastF(pHelper), pDataCols, &compBlock, true, false) < 0) return -1;
- if (tsdbAddSubBlock(pHelper, &compBlock, pIdx->numOfBlocks - 1, rowsRead) < 0) return -1;
- } else {
- if (tsdbLoadBlockData(pHelper, pCompBlock, NULL) < 0) return -1;
- ASSERT(pHelper->pDataCols[0]->numOfRows == pCompBlock->numOfRows);
+ tsdbLoadDataFromCache(pTable, pCommitIter->pIter, maxKey, defaultRowsInBlock - pCompBlock->numOfRows, pDataCols,
+ NULL, 0, pCfg->update, pMergeInfo);
- if (tdMergeDataCols(pHelper->pDataCols[0], pDataCols, pDataCols->numOfRows) < 0) return -1;
- ASSERT(pHelper->pDataCols[0]->numOfRows == pCompBlock->numOfRows + pDataCols->numOfRows);
+ ASSERT(pMergeInfo->rowsInserted == pMergeInfo->nOperations && pMergeInfo->nOperations == pDataCols->numOfRows);
- if (tsdbWriteBlockToProperFile(pHelper, pHelper->pDataCols[0], &compBlock) < 0) return -1;
- if (tsdbUpdateSuperBlock(pHelper, &compBlock, pIdx->numOfBlocks - 1) < 0) return -1;
+ if (pDataCols->numOfRows > 0) {
+ ASSERT((pMergeInfo->keyFirst == dataColsKeyFirst(pDataCols)) && (pMergeInfo->keyLast == dataColsKeyLast(pDataCols)));
+
+ if (pDataCols->numOfRows + pCompBlock->numOfRows < pCfg->minRowsPerFileBlock &&
+ pCompBlock->numOfSubBlocks < TSDB_MAX_SUBBLOCKS && !TSDB_NLAST_FILE_OPENED(pHelper)) {
+ if (tsdbWriteBlockToFile(pHelper, helperLastF(pHelper), pDataCols, &compBlock, true, false) < 0) return -1;
+ pMergeInfo->keyFirst = MIN(pMergeInfo->keyFirst, pCompBlock->keyFirst);
+ pMergeInfo->keyLast = MAX(pMergeInfo->keyLast, pCompBlock->keyLast);
+ if (tsdbAddSubBlock(pHelper, &compBlock, pIdx->numOfBlocks - 1, pMergeInfo) < 0) return -1;
+ } else {
+ if (tsdbLoadBlockData(pHelper, pCompBlock, NULL) < 0) return -1;
+ ASSERT(pHelper->pDataCols[0]->numOfRows == pCompBlock->numOfRows);
+
+ if (tdMergeDataCols(pHelper->pDataCols[0], pDataCols, pDataCols->numOfRows) < 0) return -1;
+ ASSERT(pHelper->pDataCols[0]->numOfRows == pCompBlock->numOfRows + pDataCols->numOfRows);
+
+ if (tsdbWriteBlockToProperFile(pHelper, pHelper->pDataCols[0], &compBlock) < 0) return -1;
+ if (tsdbUpdateSuperBlock(pHelper, &compBlock, pIdx->numOfBlocks - 1) < 0) return -1;
+ }
+
+ if (pHelper->hasOldLastBlock) pHelper->hasOldLastBlock = false;
}
-
- if (pHelper->hasOldLastBlock) pHelper->hasOldLastBlock = false;
} else {
ASSERT(!pHelper->hasOldLastBlock);
- tdResetDataCols(pDataCols);
- int rowsRead = tsdbLoadDataFromCache(pTable, pCommitIter->pIter, maxKey, defaultRowsInBlock, pDataCols, NULL, 0);
- ASSERT(rowsRead > 0 && rowsRead == pDataCols->numOfRows);
+ tsdbLoadDataFromCache(pTable, pCommitIter->pIter, maxKey, defaultRowsInBlock, pDataCols, NULL, 0, pCfg->update, pMergeInfo);
+ ASSERT(pMergeInfo->rowsInserted == pMergeInfo->nOperations && pMergeInfo->nOperations == pDataCols->numOfRows);
- if (tsdbWriteBlockToProperFile(pHelper, pDataCols, &compBlock) < 0) return -1;
- if (tsdbInsertSuperBlock(pHelper, &compBlock, pIdx->numOfBlocks) < 0) return -1;
+ if (pDataCols->numOfRows > 0) {
+ ASSERT((pMergeInfo->keyFirst == dataColsKeyFirst(pDataCols)) && (pMergeInfo->keyLast == dataColsKeyLast(pDataCols)));
+ if (tsdbWriteBlockToProperFile(pHelper, pDataCols, &compBlock) < 0) return -1;
+ if (tsdbInsertSuperBlock(pHelper, &compBlock, pIdx->numOfBlocks) < 0) return -1;
+ }
}
#ifndef NDEBUG
TSKEY keyNext = tsdbNextIterKey(pCommitIter->pIter);
- ASSERT(keyNext < 0 || keyNext > pIdx->maxKey);
+ ASSERT(keyNext == TSDB_DATA_TIMESTAMP_NULL || keyNext > pIdx->maxKey);
#endif
return 0;
@@ -1489,13 +1542,16 @@ static int tsdbProcessAppendCommit(SRWHelper *pHelper, SCommitIter *pCommitIter,
static int tsdbProcessMergeCommit(SRWHelper *pHelper, SCommitIter *pCommitIter, SDataCols *pDataCols, TSKEY maxKey,
int *blkIdx) {
- STsdbCfg * pCfg = &(pHelper->pRepo->config);
- STable * pTable = pCommitIter->pTable;
- SCompIdx * pIdx = &(pHelper->curCompIdx);
- SCompBlock compBlock = {0};
- TSKEY keyFirst = tsdbNextIterKey(pCommitIter->pIter);
- int defaultRowsInBlock = pCfg->maxRowsPerFileBlock * 4 / 5;
- SDataCols *pDataCols0 = pHelper->pDataCols[0];
+ STsdbCfg * pCfg = &(pHelper->pRepo->config);
+ STable * pTable = pCommitIter->pTable;
+ SCompIdx * pIdx = &(pHelper->curCompIdx);
+ SCompBlock compBlock = {0};
+ TSKEY keyFirst = tsdbNextIterKey(pCommitIter->pIter);
+ int defaultRowsInBlock = pCfg->maxRowsPerFileBlock * 4 / 5;
+ SDataCols * pDataCols0 = pHelper->pDataCols[0];
+ SMergeInfo mergeInfo = {0};
+ SMergeInfo *pMergeInfo = &mergeInfo;
+ SCompBlock oBlock = {0};
SSkipListIterator slIter = {0};
@@ -1505,123 +1561,82 @@ static int tsdbProcessMergeCommit(SRWHelper *pHelper, SCommitIter *pCommitIter,
pIdx->numOfBlocks - *blkIdx, sizeof(SCompBlock), compareKeyBlock, TD_GE);
ASSERT(pCompBlock != NULL);
int tblkIdx = (int32_t)(TSDB_GET_COMPBLOCK_IDX(pHelper, pCompBlock));
+ oBlock = *pCompBlock;
- if (pCompBlock->last) {
- ASSERT(pCompBlock->numOfRows < pCfg->minRowsPerFileBlock && tblkIdx == pIdx->numOfBlocks - 1);
- int16_t colId = 0;
- slIter = *(pCommitIter->pIter);
- if (tsdbLoadBlockDataCols(pHelper, pCompBlock, NULL, &colId, 1) < 0) return -1;
- ASSERT(pDataCols0->numOfRows == pCompBlock->numOfRows);
+ ASSERT((!TSDB_IS_LAST_BLOCK(&oBlock)) || (tblkIdx == pIdx->numOfBlocks - 1));
- int rows1 = defaultRowsInBlock - pCompBlock->numOfRows;
- int rows2 =
- tsdbLoadDataFromCache(pTable, &slIter, maxKey, rows1, NULL, pDataCols0->cols[0].pData, pDataCols0->numOfRows);
- if (rows2 == 0) { // all data filtered out
- *(pCommitIter->pIter) = slIter;
- } else {
- if (pCompBlock->numOfRows + rows2 < pCfg->minRowsPerFileBlock &&
- pCompBlock->numOfSubBlocks < TSDB_MAX_SUBBLOCKS && !TSDB_NLAST_FILE_OPENED(pHelper)) {
- tdResetDataCols(pDataCols);
- int rowsRead = tsdbLoadDataFromCache(pTable, pCommitIter->pIter, maxKey, rows1, pDataCols,
- pDataCols0->cols[0].pData, pDataCols0->numOfRows);
- ASSERT(rowsRead == rows2 && rowsRead == pDataCols->numOfRows);
- if (tsdbWriteBlockToFile(pHelper, helperLastF(pHelper), pDataCols, &compBlock, true, false) < 0) return -1;
- if (tsdbAddSubBlock(pHelper, &compBlock, tblkIdx, rowsRead) < 0) return -1;
- tblkIdx++;
- } else {
- if (tsdbLoadBlockData(pHelper, pCompBlock, NULL) < 0) return -1;
- int round = 0;
- int dIter = 0;
- while (true) {
- tdResetDataCols(pDataCols);
- int rowsRead =
- tsdbLoadAndMergeFromCache(pDataCols0, &dIter, pCommitIter, pDataCols, maxKey, defaultRowsInBlock);
- if (rowsRead == 0) break;
+ if ((!TSDB_IS_LAST_BLOCK(&oBlock)) && keyFirst < pCompBlock->keyFirst) {
+ while (true) {
+ tsdbLoadDataFromCache(pTable, pCommitIter->pIter, oBlock.keyFirst-1, defaultRowsInBlock, pDataCols, NULL, 0,
+ pCfg->update, pMergeInfo);
+ ASSERT(pMergeInfo->rowsInserted == pMergeInfo->nOperations && pMergeInfo->nOperations == pDataCols->numOfRows);
+ if (pDataCols->numOfRows == 0) break;
- if (tsdbWriteBlockToProperFile(pHelper, pDataCols, &compBlock) < 0) return -1;
- if (round == 0) {
- if (tsdbUpdateSuperBlock(pHelper, &compBlock, tblkIdx) < 0) return -1;
- } else {
- if (tsdbInsertSuperBlock(pHelper, &compBlock, tblkIdx) < 0) return -1;
- }
-
- tblkIdx++;
- round++;
- }
- }
- if (pHelper->hasOldLastBlock) pHelper->hasOldLastBlock = false;
+ if (tsdbWriteBlockToFile(pHelper, helperDataF(pHelper), pDataCols, &compBlock, false, true) < 0) return -1;
+ if (tsdbInsertSuperBlock(pHelper, &compBlock, tblkIdx) < 0) return -1;
+ tblkIdx++;
}
+ ASSERT(tblkIdx == 0 || (tsdbNextIterKey(pCommitIter->pIter) == TSDB_DATA_TIMESTAMP_NULL ||
+ tsdbNextIterKey(pCommitIter->pIter) > blockAtIdx(pHelper, tblkIdx - 1)->keyLast));
} else {
- TSKEY keyLimit = (tblkIdx == pIdx->numOfBlocks - 1) ? maxKey : (pCompBlock[1].keyFirst - 1);
- TSKEY blkKeyFirst = pCompBlock->keyFirst;
- TSKEY blkKeyLast = pCompBlock->keyLast;
+ int16_t colId = 0;
+ if (tsdbLoadBlockDataCols(pHelper, &oBlock, NULL, &colId, 1) < 0) return -1;
- if (keyFirst < blkKeyFirst) {
- while (true) {
- tdResetDataCols(pDataCols);
- int rowsRead =
- tsdbLoadDataFromCache(pTable, pCommitIter->pIter, blkKeyFirst - 1, defaultRowsInBlock, pDataCols, NULL, 0);
- if (rowsRead == 0) break;
+ TSKEY keyLimit = (tblkIdx == pIdx->numOfBlocks - 1) ? maxKey : (blockAtIdx(pHelper, tblkIdx + 1)->keyFirst - 1);
- ASSERT(rowsRead == pDataCols->numOfRows);
- if (tsdbWriteBlockToFile(pHelper, helperDataF(pHelper), pDataCols, &compBlock, false, true) < 0) return -1;
- if (tsdbInsertSuperBlock(pHelper, &compBlock, tblkIdx) < 0) return -1;
- tblkIdx++;
+ slIter = *(pCommitIter->pIter);
+ tsdbLoadDataFromCache(pTable, &slIter, keyLimit, INT_MAX, NULL, pDataCols0->cols[0].pData, pDataCols0->numOfRows,
+ pCfg->update, pMergeInfo);
+
+ if (pMergeInfo->nOperations == 0) {
+ // Do nothing
+ ASSERT(pMergeInfo->rowsDeleteFailed >= 0);
+ *(pCommitIter->pIter) = slIter;
+ tblkIdx++;
+ } else if (oBlock.numOfRows + pMergeInfo->rowsInserted - pMergeInfo->rowsDeleteSucceed == 0) {
+ // Delete the block and do some stuff
+ ASSERT(pMergeInfo->keyFirst == INT64_MAX && pMergeInfo->keyFirst == INT64_MIN);
+ if (tsdbDeleteSuperBlock(pHelper, tblkIdx) < 0) return -1;
+ *pCommitIter->pIter = slIter;
+ if (oBlock.last && pHelper->hasOldLastBlock) pHelper->hasOldLastBlock = false;
+ } else if (tsdbCheckAddSubBlockCond(pHelper, &oBlock, pMergeInfo, pDataCols->maxPoints)) {
+ // Append as a sub-block of the searched block
+ tsdbLoadDataFromCache(pTable, pCommitIter->pIter, keyLimit, INT_MAX, pDataCols, pDataCols0->cols[0].pData,
+ pDataCols0->numOfRows, pCfg->update, pMergeInfo);
+ ASSERT(memcmp(pCommitIter->pIter, &slIter, sizeof(slIter)) == 0);
+ if (tsdbWriteBlockToFile(pHelper, oBlock.last ? helperLastF(pHelper) : helperDataF(pHelper), pDataCols,
+ &compBlock, oBlock.last, false) < 0) {
+ return -1;
}
- ASSERT(tblkIdx == 0 || (tsdbNextIterKey(pCommitIter->pIter) < 0 ||
- tsdbNextIterKey(pCommitIter->pIter) > blockAtIdx(pHelper, tblkIdx - 1)->keyLast));
+ if (tsdbAddSubBlock(pHelper, &compBlock, tblkIdx, pMergeInfo) < 0) {
+ return -1;
+ }
+ tblkIdx++;
} else {
- ASSERT(keyFirst <= blkKeyLast);
- int16_t colId = 0;
- if (tsdbLoadBlockDataCols(pHelper, pCompBlock, NULL, &colId, 1) < 0) return -1;
+ // load the block data, merge with the memory data
+ if (tsdbLoadBlockData(pHelper, &oBlock, NULL) < 0) return -1;
+ int round = 0;
+ int dIter = 0;
+ while (true) {
+ tsdbLoadAndMergeFromCache(pDataCols0, &dIter, pCommitIter, pDataCols, keyLimit, defaultRowsInBlock,
+ pCfg->update);
- slIter = *(pCommitIter->pIter);
- int rows1 = (pCfg->maxRowsPerFileBlock - pCompBlock->numOfRows);
- int rows2 = tsdbLoadDataFromCache(pTable, &slIter, blkKeyLast, INT_MAX, NULL, pDataCols0->cols[0].pData,
- pDataCols0->numOfRows);
-
- if (rows2 == 0) { // all filtered out
- *(pCommitIter->pIter) = slIter;
- ASSERT(tblkIdx == 0 || (tsdbNextIterKey(pCommitIter->pIter) < 0 ||
- tsdbNextIterKey(pCommitIter->pIter) > blockAtIdx(pHelper, tblkIdx - 1)->keyLast));
- } else {
- int rows3 = tsdbLoadDataFromCache(pTable, &slIter, keyLimit, INT_MAX, NULL, NULL, 0) + rows2;
-
- if (pCompBlock->numOfSubBlocks < TSDB_MAX_SUBBLOCKS && rows1 >= rows2) {
- int rows = (rows1 >= rows3) ? rows3 : rows2;
- tdResetDataCols(pDataCols);
- int rowsRead = tsdbLoadDataFromCache(pTable, pCommitIter->pIter, keyLimit, rows, pDataCols,
- pDataCols0->cols[0].pData, pDataCols0->numOfRows);
- ASSERT(rowsRead == rows && rowsRead == pDataCols->numOfRows);
- if (tsdbWriteBlockToFile(pHelper, helperDataF(pHelper), pDataCols, &compBlock, false, false) < 0)
- return -1;
- if (tsdbAddSubBlock(pHelper, &compBlock, tblkIdx, rowsRead) < 0) return -1;
- tblkIdx++;
- ASSERT(tblkIdx == 0 || (tsdbNextIterKey(pCommitIter->pIter) < 0 ||
- tsdbNextIterKey(pCommitIter->pIter) > blockAtIdx(pHelper, tblkIdx - 1)->keyLast));
+ if (pDataCols->numOfRows == 0) break;
+ if (tblkIdx == pIdx->numOfBlocks - 1) {
+ if (tsdbWriteBlockToProperFile(pHelper, pDataCols, &compBlock) < 0) return -1;
} else {
- if (tsdbLoadBlockData(pHelper, pCompBlock, NULL) < 0) return -1;
- int round = 0;
- int dIter = 0;
- while (true) {
- int rowsRead =
- tsdbLoadAndMergeFromCache(pDataCols0, &dIter, pCommitIter, pDataCols, keyLimit, defaultRowsInBlock);
- if (rowsRead == 0) break;
-
- if (tsdbWriteBlockToFile(pHelper, helperDataF(pHelper), pDataCols, &compBlock, false, true) < 0)
- return -1;
- if (round == 0) {
- if (tsdbUpdateSuperBlock(pHelper, &compBlock, tblkIdx) < 0) return -1;
- } else {
- if (tsdbInsertSuperBlock(pHelper, &compBlock, tblkIdx) < 0) return -1;
- }
-
- round++;
- tblkIdx++;
- }
- ASSERT(tblkIdx == 0 || (tsdbNextIterKey(pCommitIter->pIter) < 0 ||
- tsdbNextIterKey(pCommitIter->pIter) > blockAtIdx(pHelper, tblkIdx - 1)->keyLast));
+ if (tsdbWriteBlockToFile(pHelper, helperDataF(pHelper), pDataCols, &compBlock, false, true) < 0) return -1;
}
+
+ if (round == 0) {
+ if (oBlock.last && pHelper->hasOldLastBlock) pHelper->hasOldLastBlock = false;
+ if (tsdbUpdateSuperBlock(pHelper, &compBlock, tblkIdx) < 0) return -1;
+ } else {
+ if (tsdbInsertSuperBlock(pHelper, &compBlock, tblkIdx) < 0) return -1;
+ }
+
+ round++;
+ tblkIdx++;
}
}
}
@@ -1630,9 +1645,8 @@ static int tsdbProcessMergeCommit(SRWHelper *pHelper, SCommitIter *pCommitIter,
return 0;
}
-static int tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIter *pCommitIter, SDataCols *pTarget,
- TSKEY maxKey, int maxRows) {
- int numOfRows = 0;
+static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIter *pCommitIter, SDataCols *pTarget,
+ TSKEY maxKey, int maxRows, int8_t update) {
TSKEY key1 = INT64_MAX;
TSKEY key2 = INT64_MAX;
STSchema *pSchema = NULL;
@@ -1642,35 +1656,62 @@ static int tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIte
while (true) {
key1 = (*iter >= pDataCols->numOfRows) ? INT64_MAX : dataColsKeyAt(pDataCols, *iter);
+ bool isRowDel = false;
SDataRow row = tsdbNextIterRow(pCommitIter->pIter);
- key2 = (row == NULL || dataRowKey(row) > maxKey) ? INT64_MAX : dataRowKey(row);
+ if (row == NULL || dataRowKey(row) > maxKey) {
+ key2 = INT64_MAX;
+ } else {
+ key2 = dataRowKey(row);
+ isRowDel = dataRowDeleted(row);
+ }
if (key1 == INT64_MAX && key2 == INT64_MAX) break;
- if (key1 <= key2) {
+ if (key1 < key2) {
for (int i = 0; i < pDataCols->numOfCols; i++) {
dataColAppendVal(pTarget->cols + i, tdGetColDataOfRow(pDataCols->cols + i, *iter), pTarget->numOfRows,
pTarget->maxPoints);
}
+
pTarget->numOfRows++;
(*iter)++;
- if (key1 == key2) tSkipListIterNext(pCommitIter->pIter);
- } else {
- if (pSchema == NULL || schemaVersion(pSchema) != dataRowVersion(row)) {
- pSchema = tsdbGetTableSchemaImpl(pCommitIter->pTable, false, false, dataRowVersion(row));
- ASSERT(pSchema != NULL);
+ } else if (key1 > key2) {
+ if (!isRowDel) {
+ if (pSchema == NULL || schemaVersion(pSchema) != dataRowVersion(row)) {
+ pSchema = tsdbGetTableSchemaImpl(pCommitIter->pTable, false, false, dataRowVersion(row));
+ ASSERT(pSchema != NULL);
+ }
+
+ tdAppendDataRowToDataCol(row, pSchema, pTarget);
}
- tdAppendDataRowToDataCol(row, pSchema, pTarget);
+ tSkipListIterNext(pCommitIter->pIter);
+ } else {
+ if (update) {
+ if (!isRowDel) {
+ if (pSchema == NULL || schemaVersion(pSchema) != dataRowVersion(row)) {
+ pSchema = tsdbGetTableSchemaImpl(pCommitIter->pTable, false, false, dataRowVersion(row));
+ ASSERT(pSchema != NULL);
+ }
+
+ tdAppendDataRowToDataCol(row, pSchema, pTarget);
+ }
+ } else {
+ ASSERT(!isRowDel);
+
+ for (int i = 0; i < pDataCols->numOfCols; i++) {
+ dataColAppendVal(pTarget->cols + i, tdGetColDataOfRow(pDataCols->cols + i, *iter), pTarget->numOfRows,
+ pTarget->maxPoints);
+ }
+
+ pTarget->numOfRows++;
+ }
+ (*iter)++;
tSkipListIterNext(pCommitIter->pIter);
}
- numOfRows++;
- if (numOfRows >= maxRows) break;
- ASSERT(numOfRows == pTarget->numOfRows && numOfRows <= pTarget->maxPoints);
+ if (pTarget->numOfRows >= maxRows) break;
}
-
- return numOfRows;
}
static int tsdbWriteBlockToProperFile(SRWHelper *pHelper, SDataCols *pDataCols, SCompBlock *pCompBlock) {
@@ -1693,3 +1734,20 @@ static int tsdbWriteBlockToProperFile(SRWHelper *pHelper, SDataCols *pDataCols,
return 0;
}
+
+static bool tsdbCheckAddSubBlockCond(SRWHelper *pHelper, SCompBlock *pCompBlock, SMergeInfo *pMergeInfo, int maxOps) {
+ STsdbCfg *pCfg = &(pHelper->pRepo->config);
+ int mergeRows = pCompBlock->numOfRows + pMergeInfo->rowsInserted - pMergeInfo->rowsDeleteSucceed;
+
+ ASSERT(mergeRows > 0);
+
+ if (pCompBlock->numOfSubBlocks < TSDB_MAX_SUBBLOCKS && pMergeInfo->nOperations <= maxOps) {
+ if (pCompBlock->last) {
+ if (!TSDB_NLAST_FILE_OPENED(pHelper) && mergeRows < pCfg->minRowsPerFileBlock) return true;
+ } else {
+ if (mergeRows < pCfg->maxRowsPerFileBlock) return true;
+ }
+ }
+
+ return false;
+}
\ No newline at end of file
diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c
index f88cd7190d..25fff48c49 100644
--- a/src/tsdb/src/tsdbRead.c
+++ b/src/tsdb/src/tsdbRead.c
@@ -457,7 +457,7 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
SSkipListNode* node = tSkipListIterGet(pCheckInfo->iter);
assert(node != NULL);
- SDataRow row = *(SDataRow *)SL_GET_NODE_DATA(node);
+ SDataRow row = (SDataRow)SL_GET_NODE_DATA(node);
TSKEY key = dataRowKey(row); // first timestamp in buffer
tsdbDebug("%p uid:%" PRId64 ", tid:%d check data in mem from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64
"-%" PRId64 ", lastKey:%" PRId64 ", numOfRows:%"PRId64", %p",
@@ -479,7 +479,7 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
SSkipListNode* node = tSkipListIterGet(pCheckInfo->iiter);
assert(node != NULL);
- SDataRow row = *(SDataRow *)SL_GET_NODE_DATA(node);
+ SDataRow row = (SDataRow)SL_GET_NODE_DATA(node);
TSKEY key = dataRowKey(row); // first timestamp in buffer
tsdbDebug("%p uid:%" PRId64 ", tid:%d check data in imem from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64
"-%" PRId64 ", lastKey:%" PRId64 ", numOfRows:%"PRId64", %p",
@@ -504,19 +504,19 @@ static void destroyTableMemIterator(STableCheckInfo* pCheckInfo) {
tSkipListDestroyIter(pCheckInfo->iiter);
}
-static SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo, int32_t order) {
+static SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo, int32_t order, int32_t update) {
SDataRow rmem = NULL, rimem = NULL;
if (pCheckInfo->iter) {
SSkipListNode* node = tSkipListIterGet(pCheckInfo->iter);
if (node != NULL) {
- rmem = *(SDataRow *)SL_GET_NODE_DATA(node);
+ rmem = (SDataRow)SL_GET_NODE_DATA(node);
}
}
if (pCheckInfo->iiter) {
SSkipListNode* node = tSkipListIterGet(pCheckInfo->iiter);
if (node != NULL) {
- rimem = *(SDataRow *)SL_GET_NODE_DATA(node);
+ rimem = (SDataRow)SL_GET_NODE_DATA(node);
}
}
@@ -538,9 +538,15 @@ static SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo, int32_t order
TSKEY r2 = dataRowKey(rimem);
if (r1 == r2) { // data ts are duplicated, ignore the data in mem
- tSkipListIterNext(pCheckInfo->iter);
- pCheckInfo->chosen = 1;
- return rimem;
+ if (!update) {
+ tSkipListIterNext(pCheckInfo->iter);
+ pCheckInfo->chosen = 1;
+ return rimem;
+ } else {
+ tSkipListIterNext(pCheckInfo->iiter);
+ pCheckInfo->chosen = 0;
+ return rmem;
+ }
} else {
if (ASCENDING_TRAVERSE(order)) {
if (r1 < r2) {
@@ -594,6 +600,7 @@ static bool moveToNextRowInMem(STableCheckInfo* pCheckInfo) {
}
static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) {
+ STsdbCfg *pCfg = &pHandle->pTsdb->config;
size_t size = taosArrayGetSize(pHandle->pTableCheckInfo);
assert(pHandle->activeIndex < size && pHandle->activeIndex >= 0 && size >= 1);
pHandle->cur.fid = -1;
@@ -607,7 +614,7 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) {
initTableMemIterator(pHandle, pCheckInfo);
}
- SDataRow row = getSDataRowInTableMem(pCheckInfo, pHandle->order);
+ SDataRow row = getSDataRowInTableMem(pCheckInfo, pHandle->order, pCfg->update);
if (row == NULL) {
return false;
}
@@ -827,11 +834,12 @@ static void copyAllRemainRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, STabl
static int32_t handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock, STableCheckInfo* pCheckInfo){
SQueryFilePos* cur = &pQueryHandle->cur;
+ STsdbCfg* pCfg = &pQueryHandle->pTsdb->config;
SDataBlockInfo binfo = GET_FILE_DATA_BLOCK_INFO(pCheckInfo, pBlock);
int32_t code = TSDB_CODE_SUCCESS;
/*bool hasData = */ initTableMemIterator(pQueryHandle, pCheckInfo);
- SDataRow row = getSDataRowInTableMem(pCheckInfo, pQueryHandle->order);
+ SDataRow row = getSDataRowInTableMem(pCheckInfo, pQueryHandle->order, pCfg->update);
assert(cur->pos >= 0 && cur->pos <= binfo.rows);
@@ -1316,6 +1324,7 @@ int32_t getEndPosInDataBlock(STsdbQueryHandle* pQueryHandle, SDataBlockInfo* pBl
static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, SCompBlock* pBlock) {
SQueryFilePos* cur = &pQueryHandle->cur;
SDataBlockInfo blockInfo = GET_FILE_DATA_BLOCK_INFO(pCheckInfo, pBlock);
+ STsdbCfg* pCfg = &pQueryHandle->pTsdb->config;
initTableMemIterator(pQueryHandle, pCheckInfo);
@@ -1353,7 +1362,7 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
} else if (pCheckInfo->iter != NULL || pCheckInfo->iiter != NULL) {
SSkipListNode* node = NULL;
do {
- SDataRow row = getSDataRowInTableMem(pCheckInfo, pQueryHandle->order);
+ SDataRow row = getSDataRowInTableMem(pCheckInfo, pQueryHandle->order, pCfg->update);
if (row == NULL) {
break;
}
@@ -1383,7 +1392,22 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
moveToNextRowInMem(pCheckInfo);
} else if (key == tsArray[pos]) { // data in buffer has the same timestamp of data in file block, ignore it
- moveToNextRowInMem(pCheckInfo);
+ if (pCfg->update) {
+ copyOneRowFromMem(pQueryHandle, pQueryHandle->outputCapacity, numOfRows, row, numOfCols, pTable);
+ numOfRows += 1;
+ if (cur->win.skey == TSKEY_INITIAL_VAL) {
+ cur->win.skey = key;
+ }
+
+ cur->win.ekey = key;
+ cur->lastKey = key + step;
+ cur->mixBlock = true;
+
+ moveToNextRowInMem(pCheckInfo);
+ pos += step;
+ } else {
+ moveToNextRowInMem(pCheckInfo);
+ }
} else if ((key > tsArray[pos] && ASCENDING_TRAVERSE(pQueryHandle->order)) ||
(key < tsArray[pos] && !ASCENDING_TRAVERSE(pQueryHandle->order))) {
if (cur->win.skey == TSKEY_INITIAL_VAL) {
@@ -1394,7 +1418,11 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
assert(end != -1);
if (tsArray[end] == key) { // the value of key in cache equals to the end timestamp value, ignore it
- moveToNextRowInMem(pCheckInfo);
+ if (!pCfg->update) {
+ moveToNextRowInMem(pCheckInfo);
+ } else {
+ end -= step;
+ }
}
int32_t qstart = 0, qend = 0;
@@ -1414,8 +1442,8 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
* copy them all to result buffer, since it may be overlapped with file data block.
*/
if (node == NULL ||
- ((dataRowKey(*(SDataRow *)SL_GET_NODE_DATA(node)) > pQueryHandle->window.ekey) && ASCENDING_TRAVERSE(pQueryHandle->order)) ||
- ((dataRowKey(*(SDataRow *)SL_GET_NODE_DATA(node)) < pQueryHandle->window.ekey) && !ASCENDING_TRAVERSE(pQueryHandle->order))) {
+ ((dataRowKey((SDataRow)SL_GET_NODE_DATA(node)) > pQueryHandle->window.ekey) && ASCENDING_TRAVERSE(pQueryHandle->order)) ||
+ ((dataRowKey((SDataRow)SL_GET_NODE_DATA(node)) < pQueryHandle->window.ekey) && !ASCENDING_TRAVERSE(pQueryHandle->order))) {
// no data in cache or data in cache is greater than the ekey of time window, load data from file block
if (cur->win.skey == TSKEY_INITIAL_VAL) {
cur->win.skey = tsArray[pos];
@@ -1862,13 +1890,14 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
STsdbQueryHandle* pQueryHandle) {
int numOfRows = 0;
int32_t numOfCols = (int32_t)taosArrayGetSize(pQueryHandle->pColumns);
+ STsdbCfg* pCfg = &pQueryHandle->pTsdb->config;
win->skey = TSKEY_INITIAL_VAL;
int64_t st = taosGetTimestampUs();
STable* pTable = pCheckInfo->pTableObj;
do {
- SDataRow row = getSDataRowInTableMem(pCheckInfo, pQueryHandle->order);
+ SDataRow row = getSDataRowInTableMem(pCheckInfo, pQueryHandle->order, pCfg->update);
if (row == NULL) {
break;
}
@@ -1919,9 +1948,9 @@ static int32_t getAllTableList(STable* pSuperTable, SArray* list) {
while (tSkipListIterNext(iter)) {
SSkipListNode* pNode = tSkipListIterGet(iter);
- STable** pTable = (STable**) SL_GET_NODE_DATA((SSkipListNode*) pNode);
+ STable* pTable = (STable*) SL_GET_NODE_DATA((SSkipListNode*) pNode);
- STableKeyInfo info = {.pTable = *pTable, .lastKey = TSKEY_INITIAL_VAL};
+ STableKeyInfo info = {.pTable = pTable, .lastKey = TSKEY_INITIAL_VAL};
taosArrayPush(list, &info);
}
@@ -2464,7 +2493,7 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
static bool indexedNodeFilterFp(const void* pNode, void* param) {
tQueryInfo* pInfo = (tQueryInfo*) param;
- STable* pTable = *(STable**)(SL_GET_NODE_DATA((SSkipListNode*)pNode));
+ STable* pTable = (STable*)(SL_GET_NODE_DATA((SSkipListNode*)pNode));
char* val = NULL;
diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt
index b8f568f82c..78b9c90979 100644
--- a/src/util/CMakeLists.txt
+++ b/src/util/CMakeLists.txt
@@ -8,7 +8,7 @@ TARGET_LINK_LIBRARIES(tutil pthread osdetail lz4 z)
IF (TD_LINUX)
TARGET_LINK_LIBRARIES(tutil m rt)
- ADD_SUBDIRECTORY(tests)
+ # ADD_SUBDIRECTORY(tests)
FIND_PATH(ICONV_INCLUDE_EXIST iconv.h /usr/include/ /usr/local/include/)
IF (ICONV_INCLUDE_EXIST)
diff --git a/src/util/inc/tskiplist.h b/src/util/inc/tskiplist.h
index a14a856561..65b6482520 100644
--- a/src/util/inc/tskiplist.h
+++ b/src/util/inc/tskiplist.h
@@ -27,33 +27,25 @@ extern "C" {
#define MAX_SKIP_LIST_LEVEL 15
#define SKIP_LIST_RECORD_PERFORMANCE 0
+// For key property setting
+#define SL_ALLOW_DUP_KEY (uint8_t)0x0 // Allow duplicate key exists (for tag index usage)
+#define SL_DISCARD_DUP_KEY (uint8_t)0x1 // Discard duplicate key (for data update=0 case)
+#define SL_UPDATE_DUP_KEY (uint8_t)0x2 // Update duplicate key by remove/insert (for data update=1 case)
+// For thread safety setting
+#define SL_THREAD_SAFE (uint8_t)0x4
+
typedef char *SSkipListKey;
typedef char *(*__sl_key_fn_t)(const void *);
-/**
- * the skip list node is located in a consecutive memory area,
- * the format of skip list node is as follows:
- * +------------+-----------------------+------------------------+-----+------+
- * | node level | forward pointer array | backward pointer array | key | data |
- * +------------+-----------------------+------------------------+-----+------+
- */
typedef struct SSkipListNode {
- uint8_t level;
+ uint8_t level;
+ void * pData;
+ struct SSkipListNode *forwards[];
} SSkipListNode;
-#define SL_NODE_HEADER_SIZE(_l) (sizeof(SSkipListNode) + ((_l) << 1u) * POINTER_BYTES)
-
-#define SL_GET_FORWARD_POINTER(n, _l) ((SSkipListNode **)((char *)(n) + sizeof(SSkipListNode)))[(_l)]
-#define SL_GET_BACKWARD_POINTER(n, _l) \
- ((SSkipListNode **)((char *)(n) + sizeof(SSkipListNode) + ((n)->level) * POINTER_BYTES))[(_l)]
-
-#define SL_GET_NODE_DATA(n) ((char *)(n) + SL_NODE_HEADER_SIZE((n)->level))
-#define SL_GET_NODE_KEY(s, n) ((s)->keyFn(SL_GET_NODE_DATA(n)))
-
-#define SL_GET_SL_MIN_KEY(s) (SL_GET_NODE_KEY((s), SL_GET_FORWARD_POINTER((s)->pHead, 0)))
-#define SL_GET_SL_MAX_KEY(s) (SL_GET_NODE_KEY((s), SL_GET_BACKWARD_POINTER((s)->pTail, 0)))
-
-#define SL_GET_NODE_LEVEL(n) *(uint8_t *)((n))
+#define SL_GET_NODE_DATA(n) (n)->pData
+#define SL_NODE_GET_FORWARD_POINTER(n, l) (n)->forwards[(l)]
+#define SL_NODE_GET_BACKWARD_POINTER(n, l) (n)->forwards[(n)->level + (l)]
/*
* @version 0.3
@@ -103,34 +95,23 @@ typedef struct tSkipListState {
uint64_t nTotalElapsedTimeForInsert;
} tSkipListState;
-typedef struct SSkipListKeyInfo {
- uint8_t dupKey : 2; // if allow duplicated key in the skip list
- uint8_t type : 4; // key type
- uint8_t freeNode:2; // free node when destroy the skiplist
- uint8_t len; // maximum key length, used in case of string key
-} SSkipListKeyInfo;
-
typedef struct SSkipList {
__compar_fn_t comparFn;
__sl_key_fn_t keyFn;
- uint32_t size;
- uint8_t maxLevel;
- uint8_t level;
- SSkipListKeyInfo keyInfo;
pthread_rwlock_t *lock;
- SSkipListNode * pHead; // point to the first element
- SSkipListNode * pTail; // point to the last element
+ uint16_t len;
+ uint8_t maxLevel;
+ uint8_t flags;
+ uint8_t type; // static info above
+ uint8_t level;
+ uint32_t size;
+ SSkipListNode * pHead; // point to the first element
+ SSkipListNode * pTail; // point to the last element
#if SKIP_LIST_RECORD_PERFORMANCE
tSkipListState state; // skiplist state
#endif
} SSkipList;
-/*
- * iterate the skiplist
- * this will cause the multi-thread problem, when the skiplist is destroyed, the iterate may
- * continue iterating the skiplist, so add the reference count for skiplist
- * TODO add the ref for skip list when one iterator is created
- */
typedef struct SSkipListIterator {
SSkipList * pSkipList;
SSkipListNode *cur;
@@ -139,114 +120,26 @@ typedef struct SSkipListIterator {
SSkipListNode *next; // next points to the true qualified node in skip list
} SSkipListIterator;
-/**
- *
- * @param nMaxLevel maximum skip list level
- * @param keyType type of key
- * @param dupKey allow the duplicated key in the skip list
- * @return
- */
-SSkipList *tSkipListCreate(uint8_t nMaxLevel, uint8_t keyType, uint8_t keyLen, uint8_t dupKey, uint8_t threadsafe,
- uint8_t freeNode, __sl_key_fn_t fn);
+#define SL_IS_THREAD_SAFE(s) (((s)->flags) & SL_THREAD_SAFE)
+#define SL_DUP_MODE(s) (((s)->flags) & ((((uint8_t)1) << 2) - 1))
+#define SL_GET_NODE_KEY(s, n) ((s)->keyFn((n)->pData))
+#define SL_GET_MIN_KEY(s) SL_GET_NODE_KEY(s, SL_NODE_GET_FORWARD_POINTER((s)->pHead, 0))
+#define SL_GET_MAX_KEY(s) SL_GET_NODE_KEY((s), SL_NODE_GET_BACKWARD_POINTER((s)->pTail, 0))
+#define SL_SIZE(s) (s)->size
-/**
- *
- * @param pSkipList
- * @return NULL will always be returned
- */
-void *tSkipListDestroy(SSkipList *pSkipList);
-
-/**
- *
- * @param pSkipList
- * @param level
- * @param headSize
- */
-void tSkipListNewNodeInfo(SSkipList *pSkipList, int32_t *level, int32_t *headSize);
-
-/**
- * put the skip list node into the skip list.
- * If failed, NULL will be returned, otherwise, the pNode will be returned.
- *
- * @param pSkipList
- * @param pNode
- * @return
- */
-SSkipListNode *tSkipListPut(SSkipList *pSkipList, SSkipListNode *pNode);
-
-/**
- * get *all* nodes which key are equivalent to pKey
- *
- * @param pSkipList
- * @param pKey
- * @return
- */
-SArray *tSkipListGet(SSkipList *pSkipList, SSkipListKey pKey);
-
-/**
- * get the size of skip list
- * @param pSkipList
- * @return
- */
-size_t tSkipListGetSize(const SSkipList *pSkipList);
-
-/**
- * display skip list of the given level, for debug purpose only
- * @param pSkipList
- * @param nlevel
- */
-void tSkipListPrint(SSkipList *pSkipList, int16_t nlevel);
-
-/**
- * create skiplist iterator
- * @param pSkipList
- * @return
- */
+SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint16_t keyLen, __compar_fn_t comparFn, uint8_t flags,
+ __sl_key_fn_t fn);
+void tSkipListDestroy(SSkipList *pSkipList);
+SSkipListNode * tSkipListPut(SSkipList *pSkipList, void *pData);
+SArray * tSkipListGet(SSkipList *pSkipList, SSkipListKey pKey);
+void tSkipListPrint(SSkipList *pSkipList, int16_t nlevel);
SSkipListIterator *tSkipListCreateIter(SSkipList *pSkipList);
-
-/**
- * create skip list iterator from the given node and specified the order
- * @param pSkipList
- * @param pNode start position, instead of the first node in skip list
- * @param order traverse order of the iterator
- * @return
- */
-SSkipListIterator *tSkipListCreateIterFromVal(SSkipList* pSkipList, const char* val, int32_t type, int32_t order);
-
-/**
- * forward the skip list iterator
- * @param iter
- * @return
- */
-bool tSkipListIterNext(SSkipListIterator *iter);
-
-/**
- * get the element of skip list node
- * @param iter
- * @return
- */
-SSkipListNode *tSkipListIterGet(SSkipListIterator *iter);
-
-/**
- * destroy the skip list node
- * @param iter
- * @return
- */
-void *tSkipListDestroyIter(SSkipListIterator *iter);
-
-/*
- * remove nodes of the pKey value.
- * If more than one node has the same value, all will be removed
- *
- * @Return
- * the count of removed nodes
- */
-uint32_t tSkipListRemove(SSkipList *pSkipList, SSkipListKey key);
-
-/*
- * remove the specified node in parameters
- */
-void tSkipListRemoveNode(SSkipList *pSkipList, SSkipListNode *pNode);
+SSkipListIterator *tSkipListCreateIterFromVal(SSkipList *pSkipList, const char *val, int32_t type, int32_t order);
+bool tSkipListIterNext(SSkipListIterator *iter);
+SSkipListNode * tSkipListIterGet(SSkipListIterator *iter);
+void * tSkipListDestroyIter(SSkipListIterator *iter);
+uint32_t tSkipListRemove(SSkipList *pSkipList, SSkipListKey key);
+void tSkipListRemoveNode(SSkipList *pSkipList, SSkipListNode *pNode);
#ifdef __cplusplus
}
diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c
index ba711ced8f..1090ab8101 100644
--- a/src/util/src/tcompare.c
+++ b/src/util/src/tcompare.c
@@ -367,7 +367,14 @@ int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) {
case TSDB_DATA_TYPE_TINYINT:
case TSDB_DATA_TYPE_BOOL: DEFAULT_COMP(GET_INT8_VAL(f1), GET_INT8_VAL(f2));
case TSDB_DATA_TYPE_NCHAR: {
- int32_t ret = wcsncmp((wchar_t*) f1, (wchar_t*) f2, size/TSDB_NCHAR_SIZE);
+ tstr* t1 = (tstr*) f1;
+ tstr* t2 = (tstr*) f2;
+
+ if (t1->len != t2->len) {
+ return t1->len > t2->len? 1:-1;
+ }
+
+ int32_t ret = wcsncmp((wchar_t*) t1->data, (wchar_t*) t2->data, t2->len/TSDB_NCHAR_SIZE);
if (ret == 0) {
return ret;
}
diff --git a/src/util/src/tskiplist.c b/src/util/src/tskiplist.c
index bacdaef6c8..c8e0febd7a 100644
--- a/src/util/src/tskiplist.c
+++ b/src/util/src/tskiplist.c
@@ -13,13 +13,447 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-#include "os.h"
-#include "tulog.h"
#include "tskiplist.h"
-#include "tutil.h"
+#include "os.h"
#include "tcompare.h"
+#include "tulog.h"
+#include "tutil.h"
-UNUSED_FUNC static FORCE_INLINE void recordNodeEachLevel(SSkipList *pSkipList, int32_t level) { // record link count in each level
+static int initForwardBackwardPtr(SSkipList *pSkipList);
+static SSkipListNode * getPriorNode(SSkipList *pSkipList, const char *val, int32_t order, SSkipListNode **pCur);
+static void tSkipListRemoveNodeImpl(SSkipList *pSkipList, SSkipListNode *pNode);
+static void tSkipListCorrectLevel(SSkipList *pSkipList);
+static SSkipListIterator *doCreateSkipListIterator(SSkipList *pSkipList, int32_t order);
+static void tSkipListDoInsert(SSkipList *pSkipList, SSkipListNode **forward, SSkipListNode *pNode);
+static bool tSkipListGetPosToPut(SSkipList *pSkipList, SSkipListNode **forward, void *pData);
+static SSkipListNode * tSkipListNewNode(uint8_t level);
+#define tSkipListFreeNode(n) taosTFree((n))
+
+static FORCE_INLINE int tSkipListWLock(SSkipList *pSkipList);
+static FORCE_INLINE int tSkipListRLock(SSkipList *pSkipList);
+static FORCE_INLINE int tSkipListUnlock(SSkipList *pSkipList);
+static FORCE_INLINE int32_t getSkipListRandLevel(SSkipList *pSkipList);
+
+SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint16_t keyLen, __compar_fn_t comparFn, uint8_t flags,
+ __sl_key_fn_t fn) {
+ SSkipList *pSkipList = (SSkipList *)calloc(1, sizeof(SSkipList));
+ if (pSkipList == NULL) return NULL;
+
+ if (maxLevel > MAX_SKIP_LIST_LEVEL) {
+ maxLevel = MAX_SKIP_LIST_LEVEL;
+ }
+
+ pSkipList->maxLevel = maxLevel;
+ pSkipList->type = keyType;
+ pSkipList->len = keyLen;
+ pSkipList->flags = flags;
+ pSkipList->keyFn = fn;
+ if (comparFn == NULL) {
+ pSkipList->comparFn = getKeyComparFunc(keyType);
+ } else {
+ pSkipList->comparFn = comparFn;
+ }
+
+ if (initForwardBackwardPtr(pSkipList) < 0) {
+ tSkipListDestroy(pSkipList);
+ return NULL;
+ }
+
+ if (SL_IS_THREAD_SAFE(pSkipList)) {
+ pSkipList->lock = (pthread_rwlock_t *)calloc(1, sizeof(pthread_rwlock_t));
+ if (pSkipList->lock == NULL) {
+ tSkipListDestroy(pSkipList);
+ return NULL;
+ }
+
+ if (pthread_rwlock_init(pSkipList->lock, NULL) != 0) {
+ tSkipListDestroy(pSkipList);
+ return NULL;
+ }
+ }
+
+ srand((uint32_t)time(NULL));
+
+#if SKIP_LIST_RECORD_PERFORMANCE
+ pSkipList->state.nTotalMemSize += sizeof(SSkipList);
+#endif
+
+ return pSkipList;
+}
+
+void tSkipListDestroy(SSkipList *pSkipList) {
+ if (pSkipList == NULL) return;
+
+ tSkipListWLock(pSkipList);
+
+ SSkipListNode *pNode = SL_NODE_GET_FORWARD_POINTER(pSkipList->pHead, 0);
+
+ while (pNode != pSkipList->pTail) {
+ SSkipListNode *pTemp = pNode;
+ pNode = SL_NODE_GET_FORWARD_POINTER(pNode, 0);
+ tSkipListFreeNode(pTemp);
+ }
+
+ tSkipListUnlock(pSkipList);
+ if (pSkipList->lock != NULL) {
+ pthread_rwlock_destroy(pSkipList->lock);
+ taosTFree(pSkipList->lock);
+ }
+
+ tSkipListFreeNode(pSkipList->pHead);
+ tSkipListFreeNode(pSkipList->pTail);
+ taosTFree(pSkipList);
+}
+
+SSkipListNode *tSkipListPut(SSkipList *pSkipList, void *pData) {
+ if (pSkipList == NULL || pData == NULL) return NULL;
+
+ SSkipListNode *forward[MAX_SKIP_LIST_LEVEL] = {0};
+ uint8_t dupMode = SL_DUP_MODE(pSkipList);
+ SSkipListNode *pNode = NULL;
+
+ tSkipListWLock(pSkipList);
+
+ bool hasDup = tSkipListGetPosToPut(pSkipList, forward, pData);
+
+ if (hasDup && (dupMode == SL_DISCARD_DUP_KEY || dupMode == SL_UPDATE_DUP_KEY)) {
+ if (dupMode == SL_UPDATE_DUP_KEY) {
+ pNode = SL_NODE_GET_FORWARD_POINTER(forward[0], 0);
+ atomic_store_ptr(&(pNode->pData), pData);
+ }
+ } else {
+ pNode = tSkipListNewNode(getSkipListRandLevel(pSkipList));
+ if (pNode != NULL) {
+ pNode->pData = pData;
+
+ tSkipListDoInsert(pSkipList, forward, pNode);
+ }
+ }
+
+ tSkipListUnlock(pSkipList);
+
+ return pNode;
+}
+
+uint32_t tSkipListRemove(SSkipList *pSkipList, SSkipListKey key) {
+ uint32_t count = 0;
+
+ tSkipListWLock(pSkipList);
+
+ SSkipListNode *pNode = getPriorNode(pSkipList, key, TSDB_ORDER_ASC, NULL);
+ while (1) {
+ SSkipListNode *p = SL_NODE_GET_FORWARD_POINTER(pNode, 0);
+ if (p == pSkipList->pTail) {
+ break;
+ }
+ if (pSkipList->comparFn(key, SL_GET_NODE_KEY(pSkipList, p)) != 0) {
+ break;
+ }
+
+ tSkipListRemoveNodeImpl(pSkipList, p);
+
+ ++count;
+ }
+
+ tSkipListCorrectLevel(pSkipList);
+
+ tSkipListUnlock(pSkipList);
+
+ return count;
+}
+
+SArray *tSkipListGet(SSkipList *pSkipList, SSkipListKey key) {
+ SArray *sa = taosArrayInit(1, POINTER_BYTES);
+
+ tSkipListRLock(pSkipList);
+
+ SSkipListNode *pNode = getPriorNode(pSkipList, key, TSDB_ORDER_ASC, NULL);
+ while (1) {
+ SSkipListNode *p = SL_NODE_GET_FORWARD_POINTER(pNode, 0);
+ if (p == pSkipList->pTail) {
+ break;
+ }
+ if (pSkipList->comparFn(key, SL_GET_NODE_KEY(pSkipList, p)) != 0) {
+ break;
+ }
+ taosArrayPush(sa, &p);
+ pNode = p;
+ }
+
+ tSkipListUnlock(pSkipList);
+
+ return sa;
+}
+
+void tSkipListRemoveNode(SSkipList *pSkipList, SSkipListNode *pNode) {
+ tSkipListWLock(pSkipList);
+ tSkipListRemoveNodeImpl(pSkipList, pNode);
+ tSkipListCorrectLevel(pSkipList);
+ tSkipListUnlock(pSkipList);
+}
+
+SSkipListIterator *tSkipListCreateIter(SSkipList *pSkipList) {
+ if (pSkipList == NULL) return NULL;
+
+ return doCreateSkipListIterator(pSkipList, TSDB_ORDER_ASC);
+}
+
+SSkipListIterator *tSkipListCreateIterFromVal(SSkipList *pSkipList, const char *val, int32_t type, int32_t order) {
+ ASSERT(order == TSDB_ORDER_ASC || order == TSDB_ORDER_DESC);
+ ASSERT(pSkipList != NULL);
+
+ SSkipListIterator *iter = doCreateSkipListIterator(pSkipList, order);
+ if (val == NULL) {
+ return iter;
+ }
+
+ tSkipListRLock(pSkipList);
+
+ iter->cur = getPriorNode(pSkipList, val, order, &(iter->next));
+
+ tSkipListUnlock(pSkipList);
+
+ return iter;
+}
+
+bool tSkipListIterNext(SSkipListIterator *iter) {
+ if (iter->pSkipList == NULL) return false;
+
+ SSkipList *pSkipList = iter->pSkipList;
+
+ tSkipListRLock(pSkipList);
+
+ if (iter->order == TSDB_ORDER_ASC) {
+ if (iter->cur == pSkipList->pTail) return false;
+ iter->cur = SL_NODE_GET_FORWARD_POINTER(iter->cur, 0);
+
+ // a new node is inserted into between iter->cur and iter->next, ignore it
+ if (iter->cur != iter->next && (iter->next != NULL)) {
+ iter->cur = iter->next;
+ }
+
+ iter->next = SL_NODE_GET_FORWARD_POINTER(iter->cur, 0);
+ iter->step++;
+ } else {
+ if (iter->cur == pSkipList->pHead) return false;
+ iter->cur = SL_NODE_GET_BACKWARD_POINTER(iter->cur, 0);
+
+ // a new node is inserted into between iter->cur and iter->next, ignore it
+ if (iter->cur != iter->next && (iter->next != NULL)) {
+ iter->cur = iter->next;
+ }
+
+ iter->next = SL_NODE_GET_BACKWARD_POINTER(iter->cur, 0);
+ iter->step++;
+ }
+
+ tSkipListUnlock(pSkipList);
+
+ return (iter->order == TSDB_ORDER_ASC) ? (iter->cur != pSkipList->pTail) : (iter->cur != pSkipList->pHead);
+}
+
+SSkipListNode *tSkipListIterGet(SSkipListIterator *iter) {
+ if (iter == NULL || iter->cur == iter->pSkipList->pTail || iter->cur == iter->pSkipList->pHead) {
+ return NULL;
+ } else {
+ return iter->cur;
+ }
+}
+
+void *tSkipListDestroyIter(SSkipListIterator *iter) {
+ if (iter == NULL) {
+ return NULL;
+ }
+
+ taosTFree(iter);
+ return NULL;
+}
+
+void tSkipListPrint(SSkipList *pSkipList, int16_t nlevel) {
+ if (pSkipList == NULL || pSkipList->level < nlevel || nlevel <= 0) {
+ return;
+ }
+
+ SSkipListNode *p = SL_NODE_GET_FORWARD_POINTER(pSkipList->pHead, nlevel - 1);
+
+ int32_t id = 1;
+ char * prev = NULL;
+
+ while (p != pSkipList->pTail) {
+ char *key = SL_GET_NODE_KEY(pSkipList, p);
+ if (prev != NULL) {
+ ASSERT(pSkipList->comparFn(prev, key) < 0);
+ }
+
+ switch (pSkipList->type) {
+ case TSDB_DATA_TYPE_INT:
+ fprintf(stdout, "%d: %d\n", id++, *(int32_t *)key);
+ break;
+ case TSDB_DATA_TYPE_SMALLINT:
+ case TSDB_DATA_TYPE_TINYINT:
+ case TSDB_DATA_TYPE_BIGINT:
+ fprintf(stdout, "%d: %" PRId64 " \n", id++, *(int64_t *)key);
+ break;
+ case TSDB_DATA_TYPE_BINARY:
+ fprintf(stdout, "%d: %s \n", id++, key);
+ break;
+ case TSDB_DATA_TYPE_DOUBLE:
+ fprintf(stdout, "%d: %lf \n", id++, *(double *)key);
+ break;
+ default:
+ fprintf(stdout, "\n");
+ }
+
+ prev = SL_GET_NODE_KEY(pSkipList, p);
+
+ p = SL_NODE_GET_FORWARD_POINTER(p, nlevel - 1);
+ }
+}
+
+static void tSkipListDoInsert(SSkipList *pSkipList, SSkipListNode **forward, SSkipListNode *pNode) {
+ for (int32_t i = 0; i < pNode->level; ++i) {
+ if (i >= pSkipList->level) {
+ SL_NODE_GET_FORWARD_POINTER(pNode, i) = pSkipList->pTail;
+ SL_NODE_GET_BACKWARD_POINTER(pNode, i) = pSkipList->pHead;
+ SL_NODE_GET_FORWARD_POINTER(pSkipList->pHead, i) = pNode;
+ SL_NODE_GET_BACKWARD_POINTER(pSkipList->pTail, i) = pNode;
+ } else {
+ SSkipListNode *x = forward[i];
+ SL_NODE_GET_BACKWARD_POINTER(pNode, i) = x;
+
+ SSkipListNode *next = SL_NODE_GET_FORWARD_POINTER(x, i);
+ SL_NODE_GET_BACKWARD_POINTER(next, i) = pNode;
+
+ SL_NODE_GET_FORWARD_POINTER(pNode, i) = next;
+ SL_NODE_GET_FORWARD_POINTER(x, i) = pNode;
+ }
+ }
+
+ if (pSkipList->level < pNode->level) pSkipList->level = pNode->level;
+
+ pSkipList->size += 1;
+}
+
+static SSkipListIterator *doCreateSkipListIterator(SSkipList *pSkipList, int32_t order) {
+ SSkipListIterator *iter = calloc(1, sizeof(SSkipListIterator));
+
+ iter->pSkipList = pSkipList;
+ iter->order = order;
+ if (order == TSDB_ORDER_ASC) {
+ iter->cur = pSkipList->pHead;
+ iter->next = SL_NODE_GET_FORWARD_POINTER(iter->cur, 0);
+ } else {
+ iter->cur = pSkipList->pTail;
+ iter->next = SL_NODE_GET_BACKWARD_POINTER(iter->cur, 0);
+ }
+
+ return iter;
+}
+
+static FORCE_INLINE int tSkipListWLock(SSkipList *pSkipList) {
+ if (pSkipList->lock) {
+ return pthread_rwlock_wrlock(pSkipList->lock);
+ }
+ return 0;
+}
+
+static FORCE_INLINE int tSkipListRLock(SSkipList *pSkipList) {
+ if (pSkipList->lock) {
+ return pthread_rwlock_rdlock(pSkipList->lock);
+ }
+ return 0;
+}
+
+static FORCE_INLINE int tSkipListUnlock(SSkipList *pSkipList) {
+ if (pSkipList->lock) {
+ return pthread_rwlock_unlock(pSkipList->lock);
+ }
+ return 0;
+}
+
+static bool tSkipListGetPosToPut(SSkipList *pSkipList, SSkipListNode **forward, void *pData) {
+ int compare = 0;
+ bool hasDupKey = false;
+ char * pDataKey = pSkipList->keyFn(pData);
+
+ if (pSkipList->size == 0) {
+ for (int i = 0; i < pSkipList->level; i++) {
+ forward[i] = pSkipList->pHead;
+ }
+ } else {
+ char *pKey = NULL;
+
+ // Compare min key
+ pKey = SL_GET_MIN_KEY(pSkipList);
+ compare = pSkipList->comparFn(pDataKey, pKey);
+ if (compare <= 0) {
+ for (int i = 0; i < pSkipList->level; i++) {
+ forward[i] = pSkipList->pHead;
+ }
+
+ return (compare == 0);
+ }
+
+ // Compare max key
+ pKey = SL_GET_MAX_KEY(pSkipList);
+ compare = pSkipList->comparFn(pDataKey, pKey);
+ if (compare > 0) {
+ for (int i = 0; i < pSkipList->level; i++) {
+ forward[i] = SL_NODE_GET_BACKWARD_POINTER(pSkipList->pTail, i);
+ }
+
+ return (compare == 0);
+ }
+
+ SSkipListNode *px = pSkipList->pHead;
+ for (int i = pSkipList->level - 1; i >= 0; --i) {
+ SSkipListNode *p = SL_NODE_GET_FORWARD_POINTER(px, i);
+ while (p != pSkipList->pTail) {
+ pKey = SL_GET_NODE_KEY(pSkipList, p);
+
+ compare = pSkipList->comparFn(pKey, pDataKey);
+ if (compare >= 0) {
+ if (compare == 0 && !hasDupKey) hasDupKey = true;
+ break;
+ } else {
+ px = p;
+ p = SL_NODE_GET_FORWARD_POINTER(px, i);
+ }
+ }
+
+ forward[i] = px;
+ }
+ }
+
+ return hasDupKey;
+}
+
+static void tSkipListRemoveNodeImpl(SSkipList *pSkipList, SSkipListNode *pNode) {
+ int32_t level = pNode->level;
+ uint8_t dupMode = SL_DUP_MODE(pSkipList);
+ ASSERT(dupMode != SL_DISCARD_DUP_KEY && dupMode != SL_UPDATE_DUP_KEY);
+
+ for (int32_t j = level - 1; j >= 0; --j) {
+ SSkipListNode *prev = SL_NODE_GET_BACKWARD_POINTER(pNode, j);
+ SSkipListNode *next = SL_NODE_GET_FORWARD_POINTER(pNode, j);
+
+ SL_NODE_GET_FORWARD_POINTER(prev, j) = next;
+ SL_NODE_GET_BACKWARD_POINTER(next, j) = prev;
+ }
+
+ tSkipListFreeNode(pNode);
+ pSkipList->size--;
+}
+
+// Function must be called after calling tSkipListRemoveNodeImpl() function
+static void tSkipListCorrectLevel(SSkipList *pSkipList) {
+ while (pSkipList->level > 0 && SL_NODE_GET_FORWARD_POINTER(pSkipList->pHead, pSkipList->level - 1) == pSkipList->pTail) {
+ pSkipList->level -= 1;
+ }
+}
+
+UNUSED_FUNC static FORCE_INLINE void recordNodeEachLevel(SSkipList *pSkipList,
+ int32_t level) { // record link count in each level
#if SKIP_LIST_RECORD_PERFORMANCE
for (int32_t i = 0; i < level; ++i) {
pSkipList->state.nLevelNodeCnt[i]++;
@@ -47,40 +481,28 @@ static FORCE_INLINE int32_t getSkipListNodeRandomHeight(SSkipList *pSkipList) {
}
static FORCE_INLINE int32_t getSkipListRandLevel(SSkipList *pSkipList) {
- int32_t level = getSkipListNodeRandomHeight(pSkipList);
+ int32_t level = 0;
if (pSkipList->size == 0) {
level = 1;
- pSkipList->level = 1;
} else {
+ level = getSkipListNodeRandomHeight(pSkipList);
if (level > pSkipList->level) {
if (pSkipList->level < pSkipList->maxLevel) {
- level = (++pSkipList->level);
+ level = pSkipList->level + 1;
} else {
level = pSkipList->level;
}
}
}
-
- assert(level <= pSkipList->maxLevel);
+
+ ASSERT(level <= pSkipList->maxLevel);
return level;
}
-#define DO_MEMSET_PTR_AREA(n) do {\
-int32_t _l = (n)->level;\
-memset(pNode, 0, SL_NODE_HEADER_SIZE(_l));\
-(n)->level = _l;\
-} while(0)
-
-static void tSkipListDoInsert(SSkipList *pSkipList, SSkipListNode **forward, SSkipListNode *pNode);
-static SSkipListNode* tSkipListPushBack(SSkipList *pSkipList, SSkipListNode *pNode);
-static SSkipListNode* tSkipListPushFront(SSkipList* pSkipList, SSkipListNode *pNode);
-static SSkipListIterator* doCreateSkipListIterator(SSkipList *pSkipList, int32_t order);
-
-
// when order is TSDB_ORDER_ASC, return the last node with key less than val
// when order is TSDB_ORDER_DESC, return the first node with key large than val
-static SSkipListNode* getPriorNode(SSkipList* pSkipList, const char* val, int32_t order, SSkipListNode** pCur) {
- __compar_fn_t comparFn = pSkipList->comparFn;
+static SSkipListNode *getPriorNode(SSkipList *pSkipList, const char *val, int32_t order, SSkipListNode **pCur) {
+ __compar_fn_t comparFn = pSkipList->comparFn;
SSkipListNode *pNode = NULL;
if (pCur != NULL) {
*pCur = NULL;
@@ -89,12 +511,12 @@ static SSkipListNode* getPriorNode(SSkipList* pSkipList, const char* val, int32_
if (order == TSDB_ORDER_ASC) {
pNode = pSkipList->pHead;
for (int32_t i = pSkipList->level - 1; i >= 0; --i) {
- SSkipListNode *p = SL_GET_FORWARD_POINTER(pNode, i);
+ SSkipListNode *p = SL_NODE_GET_FORWARD_POINTER(pNode, i);
while (p != pSkipList->pTail) {
char *key = SL_GET_NODE_KEY(pSkipList, p);
if (comparFn(key, val) < 0) {
pNode = p;
- p = SL_GET_FORWARD_POINTER(p, i);
+ p = SL_NODE_GET_FORWARD_POINTER(p, i);
} else {
if (pCur != NULL) {
*pCur = p;
@@ -106,12 +528,12 @@ static SSkipListNode* getPriorNode(SSkipList* pSkipList, const char* val, int32_
} else {
pNode = pSkipList->pTail;
for (int32_t i = pSkipList->level - 1; i >= 0; --i) {
- SSkipListNode *p = SL_GET_BACKWARD_POINTER(pNode, i);
+ SSkipListNode *p = SL_NODE_GET_BACKWARD_POINTER(pNode, i);
while (p != pSkipList->pHead) {
char *key = SL_GET_NODE_KEY(pSkipList, p);
if (comparFn(key, val) > 0) {
pNode = p;
- p = SL_GET_BACKWARD_POINTER(p, i);
+ p = SL_NODE_GET_BACKWARD_POINTER(p, i);
} else {
if (pCur != NULL) {
*pCur = p;
@@ -125,215 +547,38 @@ static SSkipListNode* getPriorNode(SSkipList* pSkipList, const char* val, int32_
return pNode;
}
-
-static bool initForwardBackwardPtr(SSkipList* pSkipList) {
+static int initForwardBackwardPtr(SSkipList *pSkipList) {
uint32_t maxLevel = pSkipList->maxLevel;
-
+
// head info
- pSkipList->pHead = (SSkipListNode *)calloc(1, SL_NODE_HEADER_SIZE(maxLevel) * 2);
- if (pSkipList->pHead == NULL) {
- return false;
- }
-
- pSkipList->pHead->level = pSkipList->maxLevel;
-
+ pSkipList->pHead = tSkipListNewNode(maxLevel);
+ if (pSkipList->pHead == NULL) return -1;
+
// tail info
- pSkipList->pTail = (SSkipListNode*) ((char*) pSkipList->pHead + SL_NODE_HEADER_SIZE(maxLevel));
- pSkipList->pTail->level = pSkipList->maxLevel;
-
+ pSkipList->pTail = tSkipListNewNode(maxLevel);
+ if (pSkipList->pTail == NULL) {
+ tSkipListFreeNode(pSkipList->pHead);
+ return -1;
+ }
+
for (uint32_t i = 0; i < maxLevel; ++i) {
- SL_GET_FORWARD_POINTER(pSkipList->pHead, i) = pSkipList->pTail;
- SL_GET_BACKWARD_POINTER(pSkipList->pTail, i) = pSkipList->pHead;
+ SL_NODE_GET_FORWARD_POINTER(pSkipList->pHead, i) = pSkipList->pTail;
+ SL_NODE_GET_BACKWARD_POINTER(pSkipList->pTail, i) = pSkipList->pHead;
}
-
- return true;
+
+ return 0;
}
-SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint8_t keyLen, uint8_t dupKey, uint8_t lock,
- uint8_t freeNode, __sl_key_fn_t fn) {
- SSkipList *pSkipList = (SSkipList *)calloc(1, sizeof(SSkipList));
- if (pSkipList == NULL) {
- return NULL;
- }
+static SSkipListNode *tSkipListNewNode(uint8_t level) {
+ int32_t tsize = sizeof(SSkipListNode) + sizeof(SSkipListNode *) * level * 2;
- if (maxLevel > MAX_SKIP_LIST_LEVEL) {
- maxLevel = MAX_SKIP_LIST_LEVEL;
- }
+ SSkipListNode *pNode = (SSkipListNode *)calloc(1, tsize);
+ if (pNode == NULL) return NULL;
- pSkipList->keyInfo.type = keyType;
- pSkipList->keyInfo.len = keyLen;
- pSkipList->keyInfo.dupKey = dupKey;
- pSkipList->keyInfo.freeNode = freeNode;
-
- pSkipList->keyFn = fn;
- pSkipList->comparFn = getKeyComparFunc(keyType);
- pSkipList->maxLevel = maxLevel;
- pSkipList->level = 1;
-
- if (!initForwardBackwardPtr(pSkipList)) {
- taosTFree(pSkipList);
- return NULL;
- }
-
- if (lock) {
- pSkipList->lock = calloc(1, sizeof(pthread_rwlock_t));
-
- if (pthread_rwlock_init(pSkipList->lock, NULL) != 0) {
- taosTFree(pSkipList->pHead);
- taosTFree(pSkipList);
-
- return NULL;
- }
- }
-
- srand((uint32_t)time(NULL));
-
-#if SKIP_LIST_RECORD_PERFORMANCE
- pSkipList->state.nTotalMemSize += sizeof(SSkipList);
-#endif
-
- return pSkipList;
-}
-
-void *tSkipListDestroy(SSkipList *pSkipList) {
- if (pSkipList == NULL) {
- return NULL;
- }
-
- if (pSkipList->lock) {
- pthread_rwlock_wrlock(pSkipList->lock);
- }
-
- if (pSkipList->keyInfo.freeNode) {
- SSkipListNode *pNode = SL_GET_FORWARD_POINTER(pSkipList->pHead, 0);
-
- while (pNode != pSkipList->pTail) {
- SSkipListNode *pTemp = pNode;
- pNode = SL_GET_FORWARD_POINTER(pNode, 0);
- taosTFree(pTemp);
- }
- }
-
- if (pSkipList->lock) {
- pthread_rwlock_unlock(pSkipList->lock);
- pthread_rwlock_destroy(pSkipList->lock);
-
- taosTFree(pSkipList->lock);
- }
-
- taosTFree(pSkipList->pHead);
- taosTFree(pSkipList);
- return NULL;
-}
-
-void tSkipListNewNodeInfo(SSkipList *pSkipList, int32_t *level, int32_t *headSize) {
- if (pSkipList == NULL) {
- *level = 1;
- *headSize = SL_NODE_HEADER_SIZE(*level);
- return;
- }
-
- *level = getSkipListRandLevel(pSkipList);
- *headSize = SL_NODE_HEADER_SIZE(*level);
-}
-
-SSkipListNode *tSkipListPut(SSkipList *pSkipList, SSkipListNode *pNode) {
- if (pSkipList == NULL || pNode == NULL) {
- return NULL;
- }
-
- if (pSkipList->lock) {
- pthread_rwlock_wrlock(pSkipList->lock);
- }
-
- // if the new key is greater than the maximum key of skip list, push back this node at the end of skip list
- char *newDatakey = SL_GET_NODE_KEY(pSkipList, pNode);
- if (pSkipList->size == 0 || pSkipList->comparFn(SL_GET_SL_MAX_KEY(pSkipList), newDatakey) < 0) {
- return tSkipListPushBack(pSkipList, pNode);
- }
-
- // if the new key is less than the minimum key of skip list, push front this node at the front of skip list
- assert(pSkipList->size > 0);
- char* minKey = SL_GET_SL_MIN_KEY(pSkipList);
- if (pSkipList->comparFn(newDatakey, minKey) < 0) {
- return tSkipListPushFront(pSkipList, pNode);
- }
-
- // find the appropriated position to insert data
- SSkipListNode *px = pSkipList->pHead;
- SSkipListNode *forward[MAX_SKIP_LIST_LEVEL] = {0};
-
- int32_t ret = -1;
- for (int32_t i = pSkipList->level - 1; i >= 0; --i) {
- SSkipListNode *p = SL_GET_FORWARD_POINTER(px, i);
- while (p != pSkipList->pTail) {
- char *key = SL_GET_NODE_KEY(pSkipList, p);
-
- // if the forward element is less than the specified key, forward one step
- ret = pSkipList->comparFn(key, newDatakey);
- if (ret < 0) {
- px = p;
- p = SL_GET_FORWARD_POINTER(px, i);
- } else {
- break;
- }
- }
-
- forward[i] = px;
- }
-
- // if the skip list does not allowed identical key inserted, the new data will be discarded.
- if (pSkipList->keyInfo.dupKey == 0 && ret == 0) {
- if (pSkipList->lock) {
- pthread_rwlock_unlock(pSkipList->lock);
- }
-
- return NULL;
- }
-
- tSkipListDoInsert(pSkipList, forward, pNode);
+ pNode->level = level;
return pNode;
}
-
-
-SArray* tSkipListGet(SSkipList *pSkipList, SSkipListKey key) {
- SArray* sa = taosArrayInit(1, POINTER_BYTES);
-
- if (pSkipList->lock) {
- pthread_rwlock_wrlock(pSkipList->lock);
- }
-
- SSkipListNode* pNode = getPriorNode(pSkipList, key, TSDB_ORDER_ASC, NULL);
- while (1) {
- SSkipListNode *p = SL_GET_FORWARD_POINTER(pNode, 0);
- if (p == pSkipList->pTail) {
- break;
- }
- if (pSkipList->comparFn(key, SL_GET_NODE_KEY(pSkipList, p)) != 0) {
- break;
- }
- taosArrayPush(sa, &p);
- pNode = p;
- }
-
- if (pSkipList->lock) {
- pthread_rwlock_unlock(pSkipList->lock);
- }
-
- return sa;
-}
-
-
-
-size_t tSkipListGetSize(const SSkipList* pSkipList) {
- if (pSkipList == NULL) {
- return 0;
- }
-
- return pSkipList->size;
-}
-
// static int32_t tSkipListEndParQuery(SSkipList *pSkipList, SSkipListNode *pStartNode, SSkipListKey *pEndKey,
// int32_t cond, SSkipListNode ***pRes) {
// pthread_rwlock_rdlock(&pSkipList->lock);
@@ -447,178 +692,13 @@ size_t tSkipListGetSize(const SSkipList* pSkipList) {
// }
//
// // compress the minimum level of skip list
-// while (pSkipList->level > 0 && SL_GET_FORWARD_POINTER(pSkipList->pHead, pSkipList->level - 1) == NULL) {
+// while (pSkipList->level > 0 && SL_NODE_GET_FORWARD_POINTER(pSkipList->pHead, pSkipList->level - 1) == NULL) {
// pSkipList->level -= 1;
// }
//
// return true;
//}
-
-uint32_t tSkipListRemove(SSkipList *pSkipList, SSkipListKey key) {
- uint32_t count = 0;
-
- if (pSkipList->lock) {
- pthread_rwlock_wrlock(pSkipList->lock);
- }
-
- SSkipListNode* pNode = getPriorNode(pSkipList, key, TSDB_ORDER_ASC, NULL);
- while (1) {
- SSkipListNode *p = SL_GET_FORWARD_POINTER(pNode, 0);
- if (p == pSkipList->pTail) {
- break;
- }
- if (pSkipList->comparFn(key, SL_GET_NODE_KEY(pSkipList, p)) != 0) {
- break;
- }
-
- for (int32_t j = p->level - 1; j >= 0; --j) {
- SSkipListNode* prev = SL_GET_BACKWARD_POINTER(p, j);
- SSkipListNode* next = SL_GET_FORWARD_POINTER(p, j);
- SL_GET_FORWARD_POINTER(prev, j) = next;
- SL_GET_BACKWARD_POINTER(next, j) = prev;
- }
-
- if (pSkipList->keyInfo.freeNode) {
- taosTFree(p);
- }
-
- ++count;
- }
-
- // compress the minimum level of skip list
- while (pSkipList->level > 0) {
- if (SL_GET_FORWARD_POINTER(pSkipList->pHead, pSkipList->level - 1) != NULL) {
- break;
- }
- pSkipList->level--;
- }
-
- pSkipList->size -= count;
-
- if (pSkipList->lock) {
- pthread_rwlock_unlock(pSkipList->lock);
- }
-
- return count;
-}
-
-void tSkipListRemoveNode(SSkipList *pSkipList, SSkipListNode *pNode) {
- int32_t level = pNode->level;
-
- if (pSkipList->lock) {
- pthread_rwlock_wrlock(pSkipList->lock);
- }
-
- for (int32_t j = level - 1; j >= 0; --j) {
- SSkipListNode* prev = SL_GET_BACKWARD_POINTER(pNode, j);
- SSkipListNode* next = SL_GET_FORWARD_POINTER(pNode, j);
-
- SL_GET_FORWARD_POINTER(prev, j) = next;
- SL_GET_BACKWARD_POINTER(next, j) = prev;
- }
-
- if (pSkipList->keyInfo.freeNode) {
- taosTFree(pNode);
- }
-
- atomic_sub_fetch_32(&pSkipList->size, 1);
-
- // compress the minimum level of skip list
- while (pSkipList->level > 0 && SL_GET_FORWARD_POINTER(pSkipList->pHead, pSkipList->level - 1) == NULL) {
- pSkipList->level -= 1;
- }
-
- if (pSkipList->lock) {
- pthread_rwlock_unlock(pSkipList->lock);
- }
-}
-
-SSkipListIterator* tSkipListCreateIter(SSkipList *pSkipList) {
- if (pSkipList == NULL) {
- return NULL;
- }
-
- return doCreateSkipListIterator(pSkipList, TSDB_ORDER_ASC);
-}
-
-SSkipListIterator *tSkipListCreateIterFromVal(SSkipList* pSkipList, const char* val, int32_t type, int32_t order) {
- assert(order == TSDB_ORDER_ASC || order == TSDB_ORDER_DESC);
- assert(pSkipList != NULL);
-
- SSkipListIterator* iter = doCreateSkipListIterator(pSkipList, order);
- if (val == NULL) {
- return iter;
- }
-
- if (pSkipList->lock) {
- pthread_rwlock_rdlock(pSkipList->lock);
- }
-
- iter->cur = getPriorNode(pSkipList, val, order, &iter->next);
-
- if (pSkipList->lock) {
- pthread_rwlock_unlock(pSkipList->lock);
- }
-
- return iter;
-}
-
-bool tSkipListIterNext(SSkipListIterator *iter) {
- if (iter->pSkipList == NULL) {
- return false;
- }
-
- SSkipList *pSkipList = iter->pSkipList;
-
- if (pSkipList->lock) {
- pthread_rwlock_rdlock(pSkipList->lock);
- }
-
- if (iter->order == TSDB_ORDER_ASC) { // ascending order iterate
- iter->cur = SL_GET_FORWARD_POINTER(iter->cur, 0);
-
- // a new node is inserted into between iter->cur and iter->next, ignore it
- if (iter->cur != iter->next && (iter->next != NULL)) {
- iter->cur = iter->next;
- }
-
- iter->next = SL_GET_FORWARD_POINTER(iter->cur, 0);
- } else { // descending order iterate
- iter->cur = SL_GET_BACKWARD_POINTER(iter->cur, 0);
-
- // a new node is inserted into between iter->cur and iter->next, ignore it
- if (iter->cur != iter->next && (iter->next != NULL)) {
- iter->cur = iter->next;
- }
-
- iter->next = SL_GET_BACKWARD_POINTER(iter->cur, 0);
- }
-
- if (pSkipList->lock) {
- pthread_rwlock_unlock(pSkipList->lock);
- }
-
- iter->step += 1;
- return (iter->order == TSDB_ORDER_ASC)? (iter->cur != pSkipList->pTail) : (iter->cur != pSkipList->pHead);
-}
-
-SSkipListNode *tSkipListIterGet(SSkipListIterator *iter) {
- if (iter == NULL || iter->cur == iter->pSkipList->pTail || iter->cur == iter->pSkipList->pHead) {
- return NULL;
- } else {
- return iter->cur;
- }
-}
-
-void* tSkipListDestroyIter(SSkipListIterator* iter) {
- if (iter == NULL) {
- return NULL;
- }
-
- taosTFree(iter);
- return NULL;
-}
-
+//
// bool tSkipListRemove(SSkipList *pSkipList, SSkipListKey *pKey) {
// SSkipListNode *forward[MAX_SKIP_LIST_LEVEL] = {0};
// __compar_fn_t filterComparFn = getComparFunc(pSkipList, pKey->nType);
@@ -638,111 +718,3 @@ void* tSkipListDestroyIter(SSkipListIterator* iter) {
//
// return ret;
//}
-
-void tSkipListPrint(SSkipList *pSkipList, int16_t nlevel) {
- if (pSkipList == NULL || pSkipList->level < nlevel || nlevel <= 0) {
- return;
- }
-
- SSkipListNode *p = SL_GET_FORWARD_POINTER(pSkipList->pHead, nlevel - 1);
-
- int32_t id = 1;
- char* prev = NULL;
-
- while (p != pSkipList->pTail) {
- char *key = SL_GET_NODE_KEY(pSkipList, p);
- if (prev != NULL) {
- assert(pSkipList->comparFn(prev, key) < 0);
- }
-
- switch (pSkipList->keyInfo.type) {
- case TSDB_DATA_TYPE_INT:
- fprintf(stdout, "%d: %d\n", id++, *(int32_t *)key);
- break;
- case TSDB_DATA_TYPE_SMALLINT:
- case TSDB_DATA_TYPE_TINYINT:
- case TSDB_DATA_TYPE_BIGINT:
- fprintf(stdout, "%d: %" PRId64 " \n", id++, *(int64_t *)key);
- break;
- case TSDB_DATA_TYPE_BINARY:
- fprintf(stdout, "%d: %s \n", id++, key);
- break;
- case TSDB_DATA_TYPE_DOUBLE:
- fprintf(stdout, "%d: %lf \n", id++, *(double *)key);
- break;
- default:
- fprintf(stdout, "\n");
- }
-
- prev = SL_GET_NODE_KEY(pSkipList, p);
-
- p = SL_GET_FORWARD_POINTER(p, nlevel - 1);
- }
-}
-
-void tSkipListDoInsert(SSkipList *pSkipList, SSkipListNode **forward, SSkipListNode *pNode) {
- DO_MEMSET_PTR_AREA(pNode);
-
- for (int32_t i = 0; i < pNode->level; ++i) {
- SSkipListNode *x = forward[i];
- SL_GET_BACKWARD_POINTER(pNode, i) = x;
-
- SSkipListNode *next = SL_GET_FORWARD_POINTER(x, i);
- SL_GET_BACKWARD_POINTER(next, i) = pNode;
-
- SL_GET_FORWARD_POINTER(pNode, i) = next;
- SL_GET_FORWARD_POINTER(x, i) = pNode;
- }
-
- atomic_add_fetch_32(&pSkipList->size, 1);
- if (pSkipList->lock) {
- pthread_rwlock_unlock(pSkipList->lock);
- }
-}
-
-SSkipListNode* tSkipListPushFront(SSkipList* pSkipList, SSkipListNode *pNode) {
- SSkipListNode* forward[MAX_SKIP_LIST_LEVEL] = {0};
- for(int32_t i = 0; i < pSkipList->level; ++i) {
- forward[i] = pSkipList->pHead;
- }
-
- tSkipListDoInsert(pSkipList, forward, pNode);
- return pNode;
-}
-
-SSkipListNode* tSkipListPushBack(SSkipList *pSkipList, SSkipListNode *pNode) {
- // do clear pointer area
- DO_MEMSET_PTR_AREA(pNode);
-
- for(int32_t i = 0; i < pNode->level; ++i) {
- SSkipListNode* prev = SL_GET_BACKWARD_POINTER(pSkipList->pTail, i);
- SL_GET_FORWARD_POINTER(prev, i) = pNode;
- SL_GET_FORWARD_POINTER(pNode, i) = pSkipList->pTail;
-
- SL_GET_BACKWARD_POINTER(pNode, i) = prev;
- SL_GET_BACKWARD_POINTER(pSkipList->pTail, i) = pNode;
- }
-
- atomic_add_fetch_32(&pSkipList->size, 1);
- if (pSkipList->lock) {
- pthread_rwlock_unlock(pSkipList->lock);
- }
-
- return pNode;
-}
-
-SSkipListIterator* doCreateSkipListIterator(SSkipList *pSkipList, int32_t order) {
- SSkipListIterator* iter = calloc(1, sizeof(SSkipListIterator));
-
- iter->pSkipList = pSkipList;
- iter->order = order;
- if(order == TSDB_ORDER_ASC) {
- iter->cur = pSkipList->pHead;
- iter->next = SL_GET_FORWARD_POINTER(iter->cur, 0);
- } else {
- iter->cur = pSkipList->pTail;
- iter->next = SL_GET_BACKWARD_POINTER(iter->cur, 0);
- }
-
- return iter;
-}
\ No newline at end of file
diff --git a/src/util/tests/skiplistTest.cpp b/src/util/tests/skiplistTest.cpp
index 77174f69fd..cd1fd1f7e1 100644
--- a/src/util/tests/skiplistTest.cpp
+++ b/src/util/tests/skiplistTest.cpp
@@ -247,7 +247,7 @@ void skiplistPerformanceTest() {
printf("total:%" PRIu64 " ms, avg:%f\n", e - s, (e - s) / (double)size);
printf("max level of skiplist:%d, actually level:%d\n ", pSkipList->maxLevel, pSkipList->level);
- assert(tSkipListGetSize(pSkipList) == size);
+ assert(SL_GET_SIZE(pSkipList) == size);
// printf("the level of skiplist is:\n");
//
@@ -273,7 +273,7 @@ void skiplistPerformanceTest() {
int64_t et = taosGetTimestampMs();
printf("delete %d data from skiplist, elapased time:%" PRIu64 "ms\n", 10000, et - st);
- assert(tSkipListGetSize(pSkipList) == size);
+ assert(SL_GET_SIZE(pSkipList) == size);
tSkipListDestroy(pSkipList);
taosTFree(total);
diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c
index 2dcdba5d7c..7d577556b9 100644
--- a/src/vnode/src/vnodeMain.c
+++ b/src/vnode/src/vnodeMain.c
@@ -140,6 +140,7 @@ int32_t vnodeCreate(SCreateVnodeMsg *pVnodeCfg) {
tsdbCfg.maxRowsPerFileBlock = pVnodeCfg->cfg.maxRowsPerFileBlock;
tsdbCfg.precision = pVnodeCfg->cfg.precision;
tsdbCfg.compression = pVnodeCfg->cfg.compression;
+ tsdbCfg.update = pVnodeCfg->cfg.update;
char tsdbDir[TSDB_FILENAME_LEN] = {0};
sprintf(tsdbDir, "%s/vnode%d/tsdb", tsVnodeDir, pVnodeCfg->cfg.vgId);
@@ -468,21 +469,6 @@ void *vnodeAcquire(int32_t vgId) {
return *ppVnode;
}
-void *vnodeAcquireRqueue(int32_t vgId) {
- SVnodeObj *pVnode = vnodeAcquire(vgId);
- if (pVnode == NULL) return NULL;
-
- int32_t code = vnodeCheckRead(pVnode);
- if (code != TSDB_CODE_SUCCESS) {
- terrno = code;
- vInfo("vgId:%d, can not provide read service, status is %s", vgId, vnodeStatus[pVnode->status]);
- vnodeRelease(pVnode);
- return NULL;
- }
-
- return pVnode->rqueue;
-}
-
void *vnodeGetWal(void *pVnode) {
return ((SVnodeObj *)pVnode)->wal;
}
diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c
index faa35b0e02..b63c1992d0 100644
--- a/src/vnode/src/vnodeRead.c
+++ b/src/vnode/src/vnodeRead.c
@@ -46,7 +46,7 @@ void vnodeInitReadFp(void) {
//
int32_t vnodeProcessRead(void *param, SVReadMsg *pReadMsg) {
SVnodeObj *pVnode = (SVnodeObj *)param;
- int msgType = pReadMsg->rpcMsg.msgType;
+ int32_t msgType = pReadMsg->msgType;
if (vnodeProcessReadMsgFp[msgType] == NULL) {
vDebug("vgId:%d, msgType:%s not processed, no handle", pVnode->vgId, taosMsg[msgType]);
@@ -56,7 +56,7 @@ int32_t vnodeProcessRead(void *param, SVReadMsg *pReadMsg) {
return (*vnodeProcessReadMsgFp[msgType])(pVnode, pReadMsg);
}
-int32_t vnodeCheckRead(void *param) {
+static int32_t vnodeCheckRead(void *param) {
SVnodeObj *pVnode = param;
if (pVnode->status != TAOS_VN_STATUS_READY) {
vDebug("vgId:%d, vnode status is %s, recCount:%d pVnode:%p", pVnode->vgId, vnodeStatus[pVnode->status],
@@ -78,24 +78,58 @@ int32_t vnodeCheckRead(void *param) {
return TSDB_CODE_SUCCESS;
}
-static int32_t vnodePutItemIntoReadQueue(SVnodeObj *pVnode, void **qhandle, void *ahandle) {
- int32_t code = vnodeCheckRead(pVnode);
- if (code != TSDB_CODE_SUCCESS) return code;
- SVReadMsg *pRead = (SVReadMsg *)taosAllocateQitem(sizeof(SVReadMsg));
- pRead->rpcMsg.msgType = TSDB_MSG_TYPE_QUERY;
- pRead->pCont = qhandle;
- pRead->contLen = 0;
- pRead->rpcMsg.ahandle = ahandle;
+int32_t vnodeWriteToRQueue(void *vparam, void *pCont, int32_t contLen, int8_t qtype, void *rparam) {
+ SVnodeObj *pVnode = vparam;
+
+ if (qtype == TAOS_QTYPE_RPC || qtype == TAOS_QTYPE_QUERY) {
+ int32_t code = vnodeCheckRead(pVnode);
+ if (code != TSDB_CODE_SUCCESS) return code;
+ }
+
+ int32_t size = sizeof(SVReadMsg) + contLen;
+ SVReadMsg *pRead = taosAllocateQitem(size);
+ if (pRead == NULL) {
+ return TSDB_CODE_VND_OUT_OF_MEMORY;
+ }
+
+ if (rparam != NULL) {
+ SRpcMsg *pRpcMsg = rparam;
+ pRead->rpcHandle = pRpcMsg->handle;
+ pRead->rpcAhandle = pRpcMsg->ahandle;
+ pRead->msgType = pRpcMsg->msgType;
+ pRead->code = pRpcMsg->code;
+ }
+
+ if (contLen != 0) {
+ pRead->contLen = contLen;
+ memcpy(pRead->pCont, pCont, contLen);
+ } else {
+ pRead->qhandle = pCont;
+ }
+
+ pRead->qtype = qtype;
atomic_add_fetch_32(&pVnode->refCount, 1);
+ vTrace("vgId:%d, get vnode rqueue, refCount:%d pVnode:%p", pVnode->vgId, pVnode->refCount, pVnode);
- vDebug("QInfo:%p add to vread queue for exec query, msg:%p", *qhandle, pRead);
- taosWriteQitem(pVnode->rqueue, TAOS_QTYPE_QUERY, pRead);
-
+ taosWriteQitem(pVnode->rqueue, qtype, pRead);
return TSDB_CODE_SUCCESS;
}
+static int32_t vnodePutItemIntoReadQueue(SVnodeObj *pVnode, void **qhandle, void *ahandle) {
+ SRpcMsg rpcMsg = {0};
+ rpcMsg.msgType = TSDB_MSG_TYPE_QUERY;
+ rpcMsg.ahandle = ahandle;
+
+ int32_t code = vnodeWriteToRQueue(pVnode, qhandle, 0, TAOS_QTYPE_QUERY, &rpcMsg);
+ if (code == TSDB_CODE_SUCCESS) {
+ vDebug("QInfo:%p add to vread queue for exec query", *qhandle);
+ }
+
+ return code;
+}
+
/**
*
* @param pRet response message object
@@ -155,18 +189,18 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
memset(pRet, 0, sizeof(SRspRet));
// qHandle needs to be freed correctly
- if (pReadMsg->rpcMsg.code == TSDB_CODE_RPC_NETWORK_UNAVAIL) {
+ if (pReadMsg->code == TSDB_CODE_RPC_NETWORK_UNAVAIL) {
SRetrieveTableMsg *killQueryMsg = (SRetrieveTableMsg *)pReadMsg->pCont;
killQueryMsg->free = htons(killQueryMsg->free);
killQueryMsg->qhandle = htobe64(killQueryMsg->qhandle);
- vWarn("QInfo:%p connection %p broken, kill query", (void *)killQueryMsg->qhandle, pReadMsg->rpcMsg.handle);
- assert(pReadMsg->rpcMsg.contLen > 0 && killQueryMsg->free == 1);
+ vWarn("QInfo:%p connection %p broken, kill query", (void *)killQueryMsg->qhandle, pReadMsg->rpcHandle);
+ assert(pReadMsg->contLen > 0 && killQueryMsg->free == 1);
void **qhandle = qAcquireQInfo(pVnode->qMgmt, (uint64_t)killQueryMsg->qhandle);
if (qhandle == NULL || *qhandle == NULL) {
vWarn("QInfo:%p invalid qhandle, no matched query handle, conn:%p", (void *)killQueryMsg->qhandle,
- pReadMsg->rpcMsg.handle);
+ pReadMsg->rpcHandle);
} else {
assert(*qhandle == (void *)killQueryMsg->qhandle);
@@ -208,9 +242,9 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
}
if (handle != NULL &&
- vnodeNotifyCurrentQhandle(pReadMsg->rpcMsg.handle, *handle, pVnode->vgId) != TSDB_CODE_SUCCESS) {
+ vnodeNotifyCurrentQhandle(pReadMsg->rpcHandle, *handle, pVnode->vgId) != TSDB_CODE_SUCCESS) {
vError("vgId:%d, QInfo:%p, query discarded since link is broken, %p", pVnode->vgId, *handle,
- pReadMsg->rpcMsg.handle);
+ pReadMsg->rpcHandle);
pRsp->code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
qReleaseQInfo(pVnode->qMgmt, (void **)&handle, true);
return pRsp->code;
@@ -221,7 +255,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
if (handle != NULL) {
vDebug("vgId:%d, QInfo:%p, dnode query msg disposed, create qhandle and returns to app", vgId, *handle);
- code = vnodePutItemIntoReadQueue(pVnode, handle, pReadMsg->rpcMsg.ahandle);
+ code = vnodePutItemIntoReadQueue(pVnode, handle, pReadMsg->rpcHandle);
if (code != TSDB_CODE_SUCCESS) {
pRsp->code = code;
qReleaseQInfo(pVnode->qMgmt, (void **)&handle, true);
@@ -230,7 +264,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
}
} else {
assert(pCont != NULL);
- void **qhandle = (void **)pCont;
+ void **qhandle = (void **)pReadMsg->qhandle;
vDebug("vgId:%d, QInfo:%p, dnode continues to exec query", pVnode->vgId, *qhandle);
@@ -242,14 +276,14 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
// build query rsp, the retrieve request has reached here already
if (buildRes) {
// update the connection info according to the retrieve connection
- pReadMsg->rpcMsg.handle = qGetResultRetrieveMsg(*qhandle);
- assert(pReadMsg->rpcMsg.handle != NULL);
+ pReadMsg->rpcHandle = qGetResultRetrieveMsg(*qhandle);
+ assert(pReadMsg->rpcHandle != NULL);
vDebug("vgId:%d, QInfo:%p, start to build retrieval rsp after query paused, %p", pVnode->vgId, *qhandle,
- pReadMsg->rpcMsg.handle);
+ pReadMsg->rpcHandle);
// set the real rsp error code
- pReadMsg->rpcMsg.code = vnodeDumpQueryResult(&pReadMsg->rspRet, pVnode, qhandle, &freehandle, pReadMsg->rpcMsg.ahandle);
+ pReadMsg->code = vnodeDumpQueryResult(&pRead->rspRet, pVnode, qhandle, &freehandle, pReadMsg->rpcHandle);
// NOTE: set return code to be TSDB_CODE_QRY_HAS_RSP to notify dnode to return msg to client
code = TSDB_CODE_QRY_HAS_RSP;
@@ -283,7 +317,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
pRetrieve->qhandle = htobe64(pRetrieve->qhandle);
vDebug("vgId:%d, QInfo:%p, retrieve msg is disposed, free:%d, conn:%p", pVnode->vgId, (void *)pRetrieve->qhandle,
- pRetrieve->free, pReadMsg->rpcMsg.handle);
+ pRetrieve->free, pReadMsg->rpcHandle);
memset(pRet, 0, sizeof(SRspRet));
@@ -298,7 +332,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
}
if (code != TSDB_CODE_SUCCESS) {
- vDebug("vgId:%d, invalid handle in retrieving result, code:0x%08x, QInfo:%p", pVnode->vgId, code, (void *)pRetrieve->qhandle);
+ vError("vgId:%d, invalid handle in retrieving result, code:0x%08x, QInfo:%p", pVnode->vgId, code, (void *)pRetrieve->qhandle);
vnodeBuildNoResultQueryRsp(pRet);
return code;
}
@@ -314,9 +348,8 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
}
// register the qhandle to connect to quit query immediate if connection is broken
- if (vnodeNotifyCurrentQhandle(pReadMsg->rpcMsg.handle, *handle, pVnode->vgId) != TSDB_CODE_SUCCESS) {
- vError("vgId:%d, QInfo:%p, retrieve discarded since link is broken, %p", pVnode->vgId, *handle,
- pReadMsg->rpcMsg.handle);
+ if (vnodeNotifyCurrentQhandle(pReadMsg->rpcHandle, *handle, pVnode->vgId) != TSDB_CODE_SUCCESS) {
+ vError("vgId:%d, QInfo:%p, retrieve discarded since link is broken, %p", pVnode->vgId, *handle, pReadMsg->rpcHandle);
code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
qKillQuery(*handle);
qReleaseQInfo(pVnode->qMgmt, (void **)&handle, true);
@@ -326,7 +359,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
bool freeHandle = true;
bool buildRes = false;
- code = qRetrieveQueryResultInfo(*handle, &buildRes, pReadMsg->rpcMsg.handle);
+ code = qRetrieveQueryResultInfo(*handle, &buildRes, pReadMsg->rpcHandle);
if (code != TSDB_CODE_SUCCESS) {
// TODO handle malloc failure
pRet->rsp = (SRetrieveTableRsp *)rpcMallocCont(sizeof(SRetrieveTableRsp));
@@ -337,7 +370,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
assert(buildRes == true);
#if _NON_BLOCKING_RETRIEVE
if (!buildRes) {
- assert(pReadMsg->rpcMsg.handle != NULL);
+ assert(pReadMsg->rpcHandle != NULL);
qReleaseQInfo(pVnode->qMgmt, (void **)&handle, false);
return TSDB_CODE_QRY_NOT_READY;
@@ -345,7 +378,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
#endif
// ahandle is the sqlObj pointer
- code = vnodeDumpQueryResult(pRet, pVnode, handle, &freeHandle, pReadMsg->rpcMsg.ahandle);
+ code = vnodeDumpQueryResult(pRet, pVnode, handle, &freeHandle, pReadMsg->rpcHandle);
}
// If qhandle is not added into vread queue, the query should be completed already or paused with error.
diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c
index 80c68b0917..3caee2fb0c 100644
--- a/src/vnode/src/vnodeWrite.c
+++ b/src/vnode/src/vnodeWrite.c
@@ -97,7 +97,7 @@ int32_t vnodeProcessWrite(void *vparam, void *wparam, int32_t qtype, void *rpara
return syncCode;
}
-int32_t vnodeCheckWrite(void *param) {
+static int32_t vnodeCheckWrite(void *param) {
SVnodeObj *pVnode = param;
if (!(pVnode->accessState & TSDB_VN_WRITE_ACCCESS)) {
vDebug("vgId:%d, no write auth, recCount:%d pVnode:%p", pVnode->vgId, pVnode->refCount, pVnode);
diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c
index 759e16d1de..be60a88ad7 100644
--- a/tests/examples/c/apitest.c
+++ b/tests/examples/c/apitest.c
@@ -9,26 +9,40 @@
static void prepare_data(TAOS* taos) {
- taos_query(taos, "drop database if exists test;");
+ TAOS_RES *result;
+ result = taos_query(taos, "drop database if exists test;");
+ taos_free_result(result);
usleep(100000);
- taos_query(taos, "create database test;");
+ result = taos_query(taos, "create database test;");
+ taos_free_result(result);
usleep(100000);
taos_select_db(taos, "test");
- taos_query(taos, "create table meters(ts timestamp, a int) tags(area int);");
+ result = taos_query(taos, "create table meters(ts timestamp, a int) tags(area int);");
+ taos_free_result(result);
- taos_query(taos, "create table t0 using meters tags(0);");
- taos_query(taos, "create table t1 using meters tags(1);");
- taos_query(taos, "create table t2 using meters tags(2);");
- taos_query(taos, "create table t3 using meters tags(3);");
- taos_query(taos, "create table t4 using meters tags(4);");
- taos_query(taos, "create table t5 using meters tags(5);");
- taos_query(taos, "create table t6 using meters tags(6);");
- taos_query(taos, "create table t7 using meters tags(7);");
- taos_query(taos, "create table t8 using meters tags(8);");
- taos_query(taos, "create table t9 using meters tags(9);");
+ result = taos_query(taos, "create table t0 using meters tags(0);");
+ taos_free_result(result);
+ result = taos_query(taos, "create table t1 using meters tags(1);");
+ taos_free_result(result);
+ result = taos_query(taos, "create table t2 using meters tags(2);");
+ taos_free_result(result);
+ result = taos_query(taos, "create table t3 using meters tags(3);");
+ taos_free_result(result);
+ result = taos_query(taos, "create table t4 using meters tags(4);");
+ taos_free_result(result);
+ result = taos_query(taos, "create table t5 using meters tags(5);");
+ taos_free_result(result);
+ result = taos_query(taos, "create table t6 using meters tags(6);");
+ taos_free_result(result);
+ result = taos_query(taos, "create table t7 using meters tags(7);");
+ taos_free_result(result);
+ result = taos_query(taos, "create table t8 using meters tags(8);");
+ taos_free_result(result);
+ result = taos_query(taos, "create table t9 using meters tags(9);");
+ taos_free_result(result);
- TAOS_RES* res = taos_query(taos, "insert into t0 values('2020-01-01 00:00:00.000', 0)"
+ result = taos_query(taos, "insert into t0 values('2020-01-01 00:00:00.000', 0)"
" ('2020-01-01 00:01:00.000', 0)"
" ('2020-01-01 00:02:00.000', 0)"
" t1 values('2020-01-01 00:00:00.000', 0)"
@@ -46,10 +60,11 @@ static void prepare_data(TAOS* taos) {
" t7 values('2020-01-01 00:01:02.000', 0)"
" t8 values('2020-01-01 00:01:02.000', 0)"
" t9 values('2020-01-01 00:01:02.000', 0)");
- int affected = taos_affected_rows(res);
+ int affected = taos_affected_rows(result);
if (affected != 18) {
printf("\033[31m%d rows affected by last insert statement, but it should be 18\033[0m\n", affected);
}
+ taos_free_result(result);
// super tables subscription
usleep(1000000);
}
@@ -135,6 +150,7 @@ static void verify_query(TAOS* taos) {
res = taos_query(taos, "select * from meters");
taos_stop_query(res);
+ taos_free_result(res);
}
@@ -153,23 +169,30 @@ static void verify_subscribe(TAOS* taos) {
res = taos_consume(tsub);
check_row_count(__LINE__, res, 0);
- taos_query(taos, "insert into t0 values('2020-01-01 00:02:00.001', 0);");
- taos_query(taos, "insert into t8 values('2020-01-01 00:01:03.000', 0);");
+ TAOS_RES *result;
+ result = taos_query(taos, "insert into t0 values('2020-01-01 00:02:00.001', 0);");
+ taos_free_result(result);
+ result = taos_query(taos, "insert into t8 values('2020-01-01 00:01:03.000', 0);");
+ taos_free_result(result);
res = taos_consume(tsub);
check_row_count(__LINE__, res, 2);
- taos_query(taos, "insert into t2 values('2020-01-01 00:01:02.001', 0);");
- taos_query(taos, "insert into t1 values('2020-01-01 00:03:00.001', 0);");
+ result = taos_query(taos, "insert into t2 values('2020-01-01 00:01:02.001', 0);");
+ taos_free_result(result);
+ result = taos_query(taos, "insert into t1 values('2020-01-01 00:03:00.001', 0);");
+ taos_free_result(result);
res = taos_consume(tsub);
check_row_count(__LINE__, res, 2);
- taos_query(taos, "insert into t1 values('2020-01-01 00:03:00.002', 0);");
+ result = taos_query(taos, "insert into t1 values('2020-01-01 00:03:00.002', 0);");
+ taos_free_result(result);
res = taos_consume(tsub);
check_row_count(__LINE__, res, 1);
// keep progress information and restart subscription
taos_unsubscribe(tsub, 1);
- taos_query(taos, "insert into t0 values('2020-01-01 00:04:00.000', 0);");
+ result = taos_query(taos, "insert into t0 values('2020-01-01 00:04:00.000', 0);");
+ taos_free_result(result);
tsub = taos_subscribe(taos, 1, "test", "select * from meters;", NULL, NULL, 0);
res = taos_consume(tsub);
check_row_count(__LINE__, res, 24);
@@ -196,7 +219,8 @@ static void verify_subscribe(TAOS* taos) {
res = taos_consume(tsub);
check_row_count(__LINE__, res, 0);
- taos_query(taos, "insert into t0 values('2020-01-01 00:04:00.001', 0);");
+ result = taos_query(taos, "insert into t0 values('2020-01-01 00:04:00.001', 0);");
+ taos_free_result(result);
res = taos_consume(tsub);
check_row_count(__LINE__, res, 1);
@@ -205,7 +229,8 @@ static void verify_subscribe(TAOS* taos) {
int blockFetch = 0;
tsub = taos_subscribe(taos, 1, "test", "select * from meters;", subscribe_callback, &blockFetch, 1000);
usleep(2000000);
- taos_query(taos, "insert into t0 values('2020-01-01 00:05:00.001', 0);");
+ result = taos_query(taos, "insert into t0 values('2020-01-01 00:05:00.001', 0);");
+ taos_free_result(result);
usleep(2000000);
taos_unsubscribe(tsub, 0);
}
@@ -213,8 +238,9 @@ static void verify_subscribe(TAOS* taos) {
void verify_prepare(TAOS* taos) {
TAOS_RES* result = taos_query(taos, "drop database if exists test;");
+ taos_free_result(result);
usleep(100000);
- taos_query(taos, "create database test;");
+ result = taos_query(taos, "create database test;");
int code = taos_errno(result);
if (code != 0) {
@@ -429,7 +455,8 @@ void verify_stream(TAOS* taos) {
NULL);
printf("waiting for stream data\n");
usleep(100000);
- taos_query(taos, "insert into t0 values(now, 0)(now+5s,1)(now+10s, 2);");
+ TAOS_RES* result = taos_query(taos, "insert into t0 values(now, 0)(now+5s,1)(now+10s, 2);");
+ taos_free_result(result);
usleep(200000000);
taos_close_stream(strm);
}
diff --git a/tests/examples/c/asyncdemo.c b/tests/examples/c/asyncdemo.c
index 1e523bd7fe..225c4f7541 100644
--- a/tests/examples/c/asyncdemo.c
+++ b/tests/examples/c/asyncdemo.c
@@ -46,6 +46,34 @@ void taos_insert_call_back(void *param, TAOS_RES *tres, int code);
void taos_select_call_back(void *param, TAOS_RES *tres, int code);
void taos_error(TAOS *taos);
+static void queryDB(TAOS *taos, char *command) {
+ int i;
+ TAOS_RES *pSql = NULL;
+ int32_t code = -1;
+
+ for (i = 0; i < 5; i++) {
+ if (NULL != pSql) {
+ taos_free_result(pSql);
+ pSql = NULL;
+ }
+
+ pSql = taos_query(taos, command);
+ code = taos_errno(pSql);
+ if (0 == code) {
+ break;
+ }
+ }
+
+ if (code != 0) {
+ fprintf(stderr, "Failed to run %s, reason: %s\n", command, taos_errstr(pSql));
+ taos_free_result(pSql);
+ taos_close(taos);
+ exit(EXIT_FAILURE);
+ }
+
+ taos_free_result(pSql);
+}
+
int main(int argc, char *argv[])
{
TAOS *taos;
@@ -78,16 +106,14 @@ int main(int argc, char *argv[])
printf("success to connect to server\n");
- sprintf(sql, "drop database %s", db);
- taos_query(taos, sql);
+ sprintf(sql, "drop database if exists %s", db);
+ queryDB(taos, sql);
sprintf(sql, "create database %s", db);
- if (taos_query(taos, sql) != 0)
- taos_error(taos);
+ queryDB(taos, sql);
sprintf(sql, "use %s", db);
- if (taos_query(taos, sql) != 0)
- taos_error(taos);
+ queryDB(taos, sql);
strcpy(prefix, "asytbl_");
for (i = 0; i < numOfTables; ++i) {
@@ -95,8 +121,7 @@ int main(int argc, char *argv[])
tableList[i].taos = taos;
sprintf(tableList[i].name, "%s%d", prefix, i);
sprintf(sql, "create table %s%d (ts timestamp, volume bigint)", prefix, i);
- if (taos_query(taos, sql) != 0)
- taos_error(taos);
+ queryDB(taos, sql);
}
gettimeofday(&systemTime, NULL);
diff --git a/tests/examples/c/demo.c b/tests/examples/c/demo.c
index 8f8a66a325..59b9c74827 100644
--- a/tests/examples/c/demo.c
+++ b/tests/examples/c/demo.c
@@ -22,6 +22,34 @@
#include
#include // TAOS header file
+static void queryDB(TAOS *taos, char *command) {
+ int i;
+ TAOS_RES *pSql = NULL;
+ int32_t code = -1;
+
+ for (i = 0; i < 5; i++) {
+ if (NULL != pSql) {
+ taos_free_result(pSql);
+ pSql = NULL;
+ }
+
+ pSql = taos_query(taos, command);
+ code = taos_errno(pSql);
+ if (0 == code) {
+ break;
+ }
+ }
+
+ if (code != 0) {
+ fprintf(stderr, "Failed to run %s, reason: %s\n", command, taos_errstr(pSql));
+ taos_free_result(pSql);
+ taos_close(taos);
+ exit(EXIT_FAILURE);
+ }
+
+ taos_free_result(pSql);
+}
+
int main(int argc, char *argv[]) {
TAOS * taos;
char qstr[1024];
@@ -44,22 +72,26 @@ int main(int argc, char *argv[]) {
printf("success to connect to server\n");
- taos_query(taos, "drop database demo");
+ //taos_query(taos, "drop database demo");
+ queryDB(taos, "drop database if exists demo");
- result = taos_query(taos, "create database demo");
- if (result == NULL) {
- printf("failed to create database, reason:%s\n", "null result"/*taos_errstr(taos)*/);
- exit(1);
- }
+ //result = taos_query(taos, "create database demo");
+ //if (result == NULL) {
+ // printf("failed to create database, reason:%s\n", "null result"/*taos_errstr(taos)*/);
+ // exit(1);
+ //}
+ queryDB(taos, "create database demo");
printf("success to create database\n");
- taos_query(taos, "use demo");
+ //taos_query(taos, "use demo");
+ queryDB(taos, "use demo");
// create table
- if (taos_query(taos, "create table m1 (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10))") == 0) {
- printf("failed to create table, reason:%s\n", taos_errstr(result));
- exit(1);
- }
+ //if (taos_query(taos, "create table m1 (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10))") == 0) {
+ // printf("failed to create table, reason:%s\n", taos_errstr(result));
+ // exit(1);
+ //}
+ queryDB(taos, "create table m1 (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10))");
printf("success to create table\n");
// sleep for one second to make sure table is created on data node
@@ -80,8 +112,10 @@ int main(int argc, char *argv[]) {
printf("insert row: %i\n", i);
} else {
printf("failed to insert row: %i, reason:%s\n", i, "null result"/*taos_errstr(result)*/);
+ taos_free_result(result);
exit(1);
}
+ taos_free_result(result);
//sleep(1);
}
@@ -91,7 +125,8 @@ int main(int argc, char *argv[]) {
sprintf(qstr, "SELECT * FROM m1");
result = taos_query(taos, qstr);
if (result == NULL || taos_errno(result) != 0) {
- printf("failed to select, reason:%s\n", taos_errstr(result));
+ printf("failed to select, reason:%s\n", taos_errstr(result));
+ taos_free_result(result);
exit(1);
}
diff --git a/tests/pytest/alter/db_update_options.py b/tests/pytest/alter/db_update_options.py
new file mode 100644
index 0000000000..224e0f25b0
--- /dev/null
+++ b/tests/pytest/alter/db_update_options.py
@@ -0,0 +1,71 @@
+
+# -*- coding: utf-8 -*-
+
+import random
+import string
+import subprocess
+import sys
+from util.log import *
+from util.cases import *
+from util.sql import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+ def run(self):
+ tdLog.debug("check database")
+ tdSql.prepare()
+
+ # check default update value
+ sql = "create database if not exists db"
+ tdSql.execute(sql)
+ tdSql.query('show databases')
+ tdSql.checkRows(1)
+ tdSql.checkData(0,16,0)
+
+ sql = "alter database db update 1"
+
+ # check update value
+ tdSql.execute(sql)
+ tdSql.query('show databases')
+ tdSql.checkRows(1)
+ tdSql.checkData(0,16,1)
+
+
+ sql = "alter database db update 0"
+ tdSql.execute(sql)
+ tdSql.query('show databases')
+ tdSql.checkRows(1)
+ tdSql.checkData(0,16,0)
+
+ sql = "alter database db update -1"
+ tdSql.error(sql)
+
+ sql = "alter database db update 100"
+ tdSql.error(sql)
+
+ tdSql.query('show databases')
+ tdSql.checkRows(1)
+ tdSql.checkData(0,16,0)
+
+ tdSql.execute('drop database db')
+ tdSql.error('create database db update 100')
+ tdSql.error('create database db update -1')
+
+ tdSql.execute('create database db update 1')
+
+ tdSql.query('show databases')
+ tdSql.checkRows(1)
+ tdSql.checkData(0,16,1)
+
+ tdSql.execute('drop database db')
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/crash_gen/crash_gen.py b/tests/pytest/crash_gen/crash_gen_main.py
similarity index 90%
rename from tests/pytest/crash_gen/crash_gen.py
rename to tests/pytest/crash_gen/crash_gen_main.py
index 8d2b0080bc..8a074500e1 100755
--- a/tests/pytest/crash_gen/crash_gen.py
+++ b/tests/pytest/crash_gen/crash_gen_main.py
@@ -38,9 +38,9 @@ import resource
from guppy import hpy
import gc
-from .service_manager import ServiceManager, TdeInstance
-from .misc import Logging, Status, CrashGenError, Dice, Helper, Progress
-from .db import DbConn, MyTDSql, DbConnNative, DbManager
+from crash_gen.service_manager import ServiceManager, TdeInstance
+from crash_gen.misc import Logging, Status, CrashGenError, Dice, Helper, Progress
+from crash_gen.db import DbConn, MyTDSql, DbConnNative, DbManager
import taos
import requests
@@ -243,7 +243,7 @@ class WorkerThread:
class ThreadCoordinator:
- WORKER_THREAD_TIMEOUT = 180 # one minute
+ WORKER_THREAD_TIMEOUT = 120 # Normal: 120
def __init__(self, pool: ThreadPool, dbManager: DbManager):
self._curStep = -1 # first step is 0
@@ -388,9 +388,9 @@ class ThreadCoordinator:
self._syncAtBarrier() # For now just cross the barrier
Progress.emit(Progress.END_THREAD_STEP)
except threading.BrokenBarrierError as err:
- Logging.info("Main loop aborted, caused by worker thread time-out")
+ Logging.info("Main loop aborted, caused by worker thread(s) time-out")
self._execStats.registerFailure("Aborted due to worker thread timeout")
- print("\n\nWorker Thread time-out detected, important thread info:")
+ print("\n\nWorker Thread time-out detected, TAOS related threads are:")
ts = ThreadStacks()
ts.print(filterInternal=True)
workerTimeout = True
@@ -435,7 +435,7 @@ class ThreadCoordinator:
Logging.debug("\r\n\n--> Main thread ready to finish up...")
Logging.debug("Main thread joining all threads")
self._pool.joinAll() # Get all threads to finish
- Logging.info("\nAll worker threads finished")
+ Logging.info(". . . All worker threads finished") # No CR/LF before
self._execStats.endExec()
def cleanup(self): # free resources
@@ -1072,17 +1072,18 @@ class Database:
t3 = datetime.datetime(2012, 1, 1) # default "keep" is 10 years
t4 = datetime.datetime.fromtimestamp(
t3.timestamp() + elSec2) # see explanation above
- Logging.info("Setting up TICKS to start from: {}".format(t4))
+ Logging.debug("Setting up TICKS to start from: {}".format(t4))
return t4
@classmethod
def getNextTick(cls):
with cls._clsLock: # prevent duplicate tick
- if cls._lastLaggingTick==0:
+ if cls._lastLaggingTick==0 or cls._lastTick==0 : # not initialized
# 10k at 1/20 chance, should be enough to avoid overlaps
- cls._lastLaggingTick = cls.setupLastTick() + datetime.timedelta(0, -10000)
- if cls._lastTick==0: # should be quite a bit into the future
- cls._lastTick = cls.setupLastTick()
+ tick = cls.setupLastTick()
+ cls._lastTick = tick
+ cls._lastLaggingTick = tick + datetime.timedelta(0, -10000)
+ # if : # should be quite a bit into the future
if Dice.throw(20) == 0: # 1 in 20 chance, return lagging tick
cls._lastLaggingTick += datetime.timedelta(0, 1) # Go back in time 100 seconds
@@ -1177,6 +1178,8 @@ class Task():
instead. But a task is always associated with a DB
'''
taskSn = 100
+ _lock = threading.Lock()
+ _tableLocks: Dict[str, threading.Lock] = {}
@classmethod
def allocTaskNum(cls):
@@ -1198,6 +1201,8 @@ class Task():
self._execStats = execStats
self._db = db # A task is always associated/for a specific DB
+
+
def isSuccess(self):
return self._err is None
@@ -1237,6 +1242,7 @@ class Task():
0x0B, # Unable to establish connection, more details in TD-1648
0x200, # invalid SQL, TODO: re-examine with TD-934
0x20F, # query terminated, possibly due to vnoding being dropped, see TD-1776
+ 0x213, # "Disconnected from service", result of "kill connection ???"
0x217, # "db not selected", client side defined error code
# 0x218, # "Table does not exist" client side defined error code
0x360, # Table already exists
@@ -1318,7 +1324,7 @@ class Task():
self._err = err
self._aborted = True
except Exception as e:
- self.logInfo("Non-TAOS exception encountered")
+ Logging.info("Non-TAOS exception encountered with: {}".format(self.__class__.__name__))
self._err = e
self._aborted = True
traceback.print_exc()
@@ -1351,6 +1357,24 @@ class Task():
def getQueryResult(self, wt: WorkerThread): # execute an SQL on the worker thread
return wt.getQueryResult()
+ def lockTable(self, ftName): # full table name
+ # print(" <<" + ftName + '_', end="", flush=True)
+ with Task._lock:
+ if not ftName in Task._tableLocks:
+ Task._tableLocks[ftName] = threading.Lock()
+
+ Task._tableLocks[ftName].acquire()
+
+ def unlockTable(self, ftName):
+ # print('_' + ftName + ">> ", end="", flush=True)
+ with Task._lock:
+ if not ftName in self._tableLocks:
+ raise RuntimeError("Corrupt state, no such lock")
+ lock = Task._tableLocks[ftName]
+ if not lock.locked():
+ raise RuntimeError("Corrupte state, already unlocked")
+ lock.release()
+
class ExecutionStats:
def __init__(self):
@@ -1461,7 +1485,7 @@ class StateTransitionTask(Task):
_baseTableNumber = None
- _endState = None
+ _endState = None # TODO: no longter used?
@classmethod
def getInfo(cls): # each sub class should supply their own information
@@ -1486,7 +1510,7 @@ class StateTransitionTask(Task):
@classmethod
def getRegTableName(cls, i):
- if ( StateTransitionTask._baseTableNumber is None):
+ if ( StateTransitionTask._baseTableNumber is None): # Set it one time
StateTransitionTask._baseTableNumber = Dice.throw(
999) if gConfig.dynamic_db_table_names else 0
return "reg_table_{}".format(StateTransitionTask._baseTableNumber + i)
@@ -1544,8 +1568,11 @@ class TaskCreateSuperTable(StateTransitionTask):
sTable = self._db.getFixedSuperTable() # type: TdSuperTable
# wt.execSql("use db") # should always be in place
+
sTable.create(wt.getDbConn(), self._db.getName(),
- {'ts':'timestamp', 'speed':'int'}, {'b':'binary(200)', 'f':'float'})
+ {'ts':'timestamp', 'speed':'int'}, {'b':'binary(200)', 'f':'float'},
+ dropIfExists = True
+ )
# self.execWtSql(wt,"create table db.{} (ts timestamp, speed int) tags (b binary(200), f float) ".format(tblName))
# No need to create the regular tables, INSERT will do that
# automatically
@@ -1558,14 +1585,41 @@ class TdSuperTable:
def getName(self):
return self._stName
+ def drop(self, dbc, dbName, skipCheck = False):
+ if self.exists(dbc, dbName) : # if myself exists
+ fullTableName = dbName + '.' + self._stName
+ dbc.execute("DROP TABLE {}".format(fullTableName))
+ else:
+ if not skipCheck:
+ raise CrashGenError("Cannot drop non-existant super table: {}".format(self._stName))
+
+ def exists(self, dbc, dbName):
+ dbc.execute("USE " + dbName)
+ return dbc.existsSuperTable(self._stName)
+
# TODO: odd semantic, create() method is usually static?
- def create(self, dbc, dbName, cols: dict, tags: dict):
+ def create(self, dbc, dbName, cols: dict, tags: dict,
+ dropIfExists = False
+ ):
+
'''Creating a super table'''
- sql = "CREATE TABLE {}.{} ({}) TAGS ({})".format(
- dbName,
- self._stName,
- ",".join(['%s %s'%(k,v) for (k,v) in cols.items()]),
- ",".join(['%s %s'%(k,v) for (k,v) in tags.items()])
+ dbc.execute("USE " + dbName)
+ fullTableName = dbName + '.' + self._stName
+ if dbc.existsSuperTable(self._stName):
+ if dropIfExists:
+ dbc.execute("DROP TABLE {}".format(fullTableName))
+ else: # error
+ raise CrashGenError("Cannot create super table, already exists: {}".format(self._stName))
+
+ # Now let's create
+ sql = "CREATE TABLE {} ({})".format(
+ fullTableName,
+ ",".join(['%s %s'%(k,v) for (k,v) in cols.items()]))
+ if tags is None :
+ sql += " TAGS (dummy int) "
+ else:
+ sql += " TAGS ({})".format(
+ ",".join(['%s %s'%(k,v) for (k,v) in tags.items()])
)
dbc.execute(sql)
@@ -1583,14 +1637,25 @@ class TdSuperTable:
def hasRegTables(self, dbc: DbConn, dbName: str):
return dbc.query("SELECT * FROM {}.{}".format(dbName, self._stName)) > 0
- def ensureTable(self, dbc: DbConn, dbName: str, regTableName: str):
+ def ensureTable(self, task: Task, dbc: DbConn, dbName: str, regTableName: str):
sql = "select tbname from {}.{} where tbname in ('{}')".format(dbName, self._stName, regTableName)
if dbc.query(sql) >= 1 : # reg table exists already
return
- sql = "CREATE TABLE {}.{} USING {}.{} tags ({})".format(
- dbName, regTableName, dbName, self._stName, self._getTagStrForSql(dbc, dbName)
- )
- dbc.execute(sql)
+
+ # acquire a lock first, so as to be able to *verify*. More details in TD-1471
+ fullTableName = dbName + '.' + regTableName
+ if task is not None: # optional lock
+ task.lockTable(fullTableName)
+ Progress.emit(Progress.CREATE_TABLE_ATTEMPT) # ATTEMPT to create a new table
+ # print("(" + fullTableName[-3:] + ")", end="", flush=True)
+ try:
+ sql = "CREATE TABLE {} USING {}.{} tags ({})".format(
+ fullTableName, dbName, self._stName, self._getTagStrForSql(dbc, dbName)
+ )
+ dbc.execute(sql)
+ finally:
+ if task is not None:
+ task.unlockTable(fullTableName) # no matter what
def _getTagStrForSql(self, dbc, dbName: str) :
tags = self._getTags(dbc, dbName)
@@ -1809,7 +1874,7 @@ class TaskRestartService(StateTransitionTask):
with self._classLock:
if self._isRunning:
- print("Skipping restart task, another running already")
+ Logging.info("Skipping restart task, another running already")
return
self._isRunning = True
@@ -1847,13 +1912,88 @@ class TaskAddData(StateTransitionTask):
def canBeginFrom(cls, state: AnyState):
return state.canAddData()
+ def _addDataInBatch(self, db, dbc, regTableName, te: TaskExecutor):
+ numRecords = self.LARGE_NUMBER_OF_RECORDS if gConfig.larger_data else self.SMALL_NUMBER_OF_RECORDS
+ fullTableName = db.getName() + '.' + regTableName
+
+ sql = "insert into {} values ".format(fullTableName)
+ for j in range(numRecords): # number of records per table
+ nextInt = db.getNextInt()
+ nextTick = db.getNextTick()
+ sql += "('{}', {});".format(nextTick, nextInt)
+ dbc.execute(sql)
+
+ def _addData(self, db, dbc, regTableName, te: TaskExecutor): # implied: NOT in batches
+ numRecords = self.LARGE_NUMBER_OF_RECORDS if gConfig.larger_data else self.SMALL_NUMBER_OF_RECORDS
+
+ for j in range(numRecords): # number of records per table
+ nextInt = db.getNextInt()
+ nextTick = db.getNextTick()
+ if gConfig.record_ops:
+ self.prepToRecordOps()
+ self.fAddLogReady.write("Ready to write {} to {}\n".format(nextInt, regTableName))
+ self.fAddLogReady.flush()
+ os.fsync(self.fAddLogReady)
+
+ # TODO: too ugly trying to lock the table reliably, refactor...
+ fullTableName = db.getName() + '.' + regTableName
+ if gConfig.verify_data:
+ self.lockTable(fullTableName)
+ # print("_w" + str(nextInt % 100), end="", flush=True) # Trace what was written
+
+ try:
+ sql = "insert into {} values ('{}', {});".format( # removed: tags ('{}', {})
+ fullTableName,
+ # ds.getFixedSuperTableName(),
+ # ds.getNextBinary(), ds.getNextFloat(),
+ nextTick, nextInt)
+ dbc.execute(sql)
+ except: # Any exception at all
+ if gConfig.verify_data:
+ self.unlockTable(fullTableName)
+ raise
+
+ # Now read it back and verify, we might encounter an error if table is dropped
+ if gConfig.verify_data: # only if command line asks for it
+ try:
+ readBack = dbc.queryScalar("SELECT speed from {}.{} WHERE ts='{}'".
+ format(db.getName(), regTableName, nextTick))
+ if readBack != nextInt :
+ raise taos.error.ProgrammingError(
+ "Failed to read back same data, wrote: {}, read: {}"
+ .format(nextInt, readBack), 0x999)
+ except taos.error.ProgrammingError as err:
+ errno = Helper.convertErrno(err.errno)
+ if errno in [0x991, 0x992] : # not a single result
+ raise taos.error.ProgrammingError(
+ "Failed to read back same data for tick: {}, wrote: {}, read: {}"
+ .format(nextTick, nextInt, "Empty Result" if errno==0x991 else "Multiple Result"),
+ errno)
+ elif errno in [0x218, 0x362]: # table doesn't exist
+ # do nothing
+ dummy = 0
+ else:
+ # Re-throw otherwise
+ raise
+ finally:
+ self.unlockTable(fullTableName) # Unlock the table no matter what
+
+ # Successfully wrote the data into the DB, let's record it somehow
+ te.recordDataMark(nextInt)
+
+ if gConfig.record_ops:
+ self.fAddLogDone.write("Wrote {} to {}\n".format(nextInt, regTableName))
+ self.fAddLogDone.flush()
+ os.fsync(self.fAddLogDone)
+
def _executeInternal(self, te: TaskExecutor, wt: WorkerThread):
# ds = self._dbManager # Quite DANGEROUS here, may result in multi-thread client access
db = self._db
dbc = wt.getDbConn()
- tblSeq = list(range(
- self.LARGE_NUMBER_OF_TABLES if gConfig.larger_data else self.SMALL_NUMBER_OF_TABLES))
- random.shuffle(tblSeq)
+ numTables = self.LARGE_NUMBER_OF_TABLES if gConfig.larger_data else self.SMALL_NUMBER_OF_TABLES
+ numRecords = self.LARGE_NUMBER_OF_RECORDS if gConfig.larger_data else self.SMALL_NUMBER_OF_RECORDS
+ tblSeq = list(range(numTables ))
+ random.shuffle(tblSeq) # now we have random sequence
for i in tblSeq:
if (i in self.activeTable): # wow already active
print("x", end="", flush=True) # concurrent insertion
@@ -1861,60 +2001,20 @@ class TaskAddData(StateTransitionTask):
self.activeTable.add(i) # marking it active
sTable = db.getFixedSuperTable()
- regTableName = self.getRegTableName(i) # "db.reg_table_{}".format(i)
- sTable.ensureTable(wt.getDbConn(), db.getName(), regTableName) # Ensure the table exists
+ regTableName = self.getRegTableName(i) # "db.reg_table_{}".format(i)
+ fullTableName = db.getName() + '.' + regTableName
+ # self._lockTable(fullTableName) # "create table" below. Stop it if the table is "locked"
+ sTable.ensureTable(self, wt.getDbConn(), db.getName(), regTableName) # Ensure the table exists
+ # self._unlockTable(fullTableName)
- for j in range(self.LARGE_NUMBER_OF_RECORDS if gConfig.larger_data else self.SMALL_NUMBER_OF_RECORDS): # number of records per table
- nextInt = db.getNextInt()
- nextTick = db.getNextTick()
- if gConfig.record_ops:
- self.prepToRecordOps()
- self.fAddLogReady.write("Ready to write {} to {}\n".format(nextInt, regTableName))
- self.fAddLogReady.flush()
- os.fsync(self.fAddLogReady)
- sql = "insert into {}.{} values ('{}', {});".format( # removed: tags ('{}', {})
- db.getName(),
- regTableName,
- # ds.getFixedSuperTableName(),
- # ds.getNextBinary(), ds.getNextFloat(),
- nextTick, nextInt)
- dbc.execute(sql)
- # Successfully wrote the data into the DB, let's record it
- # somehow
- te.recordDataMark(nextInt)
- if gConfig.record_ops:
- self.fAddLogDone.write(
- "Wrote {} to {}\n".format(
- nextInt, regTableName))
- self.fAddLogDone.flush()
- os.fsync(self.fAddLogDone)
-
- # Now read it back and verify, we might encounter an error if table is dropped
- if gConfig.verify_data: # only if command line asks for it
- try:
- readBack = dbc.queryScalar("SELECT speed from {}.{} WHERE ts= '{}'".
- format(db.getName(), regTableName, nextTick))
- if readBack != nextInt :
- raise taos.error.ProgrammingError(
- "Failed to read back same data, wrote: {}, read: {}"
- .format(nextInt, readBack), 0x999)
- except taos.error.ProgrammingError as err:
- errno = Helper.convertErrno(err.errno)
- if errno in [0x991, 0x992] : # not a single result
- raise taos.error.ProgrammingError(
- "Failed to read back same data for tick: {}, wrote: {}, read: {}"
- .format(nextTick, nextInt, "Empty Result" if errno==0x991 else "Multiple Result"),
- errno)
- # Re-throw no matter what
- raise
-
+ if Dice.throw(1) == 0: # 1 in 2 chance
+ self._addData(db, dbc, regTableName, te)
+ else:
+ self._addDataInBatch(db, dbc, regTableName, te)
self.activeTable.discard(i) # not raising an error, unlike remove
-
-
-
class ThreadStacks: # stack info for all threads
def __init__(self):
self._allStacks = {}
@@ -1936,17 +2036,18 @@ class ThreadStacks: # stack info for all threads
'__init__']: # the thread that extracted the stack
continue # ignore
# Now print
- print("\n<----- Thread Info for ID: {}".format(thNid))
+ print("\n<----- Thread Info for LWP/ID: {} (Execution stopped at Bottom Frame) <-----".format(thNid))
+ stackFrame = 0
for frame in stack:
# print(frame)
- print("File {filename}, line {lineno}, in {name}".format(
- filename=frame.filename, lineno=frame.lineno, name=frame.name))
+ print("[{sf}] File {filename}, line {lineno}, in {name}".format(
+ sf=stackFrame, filename=frame.filename, lineno=frame.lineno, name=frame.name))
print(" {}".format(frame.line))
- print("-----> End of Thread Info\n")
+ print("-----> End of Thread Info ----->\n")
class ClientManager:
def __init__(self):
- print("Starting service manager")
+ Logging.info("Starting service manager")
# signal.signal(signal.SIGTERM, self.sigIntHandler)
# signal.signal(signal.SIGINT, self.sigIntHandler)
@@ -2048,7 +2149,7 @@ class ClientManager:
thPool = ThreadPool(gConfig.num_threads, gConfig.max_steps)
self.tc = ThreadCoordinator(thPool, dbManager)
- print("Starting client instance to: {}".format(tInst))
+ Logging.info("Starting client instance: {}".format(tInst))
self.tc.run()
# print("exec stats: {}".format(self.tc.getExecStats()))
# print("TC failed = {}".format(self.tc.isFailed()))
diff --git a/tests/pytest/crash_gen/db.py b/tests/pytest/crash_gen/db.py
index 43c855647c..2a4b362f82 100644
--- a/tests/pytest/crash_gen/db.py
+++ b/tests/pytest/crash_gen/db.py
@@ -95,6 +95,11 @@ class DbConn:
# print("dbs = {}, str = {}, ret2={}, type2={}".format(dbs, dbName,ret2, type(dbName)))
return dbName in dbs # TODO: super weird type mangling seen, once here
+ def existsSuperTable(self, stName):
+ self.query("show stables")
+ sts = [v[0] for v in self.getQueryResult()]
+ return stName in sts
+
def hasTables(self):
return self.query("show tables") > 0
@@ -240,6 +245,7 @@ class MyTDSql:
def _execInternal(self, sql):
startTime = time.time()
+ # Logging.debug("Executing SQL: " + sql)
ret = self._cursor.execute(sql)
# print("\nSQL success: {}".format(sql))
queryTime = time.time() - startTime
diff --git a/tests/pytest/crash_gen/misc.py b/tests/pytest/crash_gen/misc.py
index 34a33c6af6..2d2ce99d95 100644
--- a/tests/pytest/crash_gen/misc.py
+++ b/tests/pytest/crash_gen/misc.py
@@ -27,7 +27,7 @@ class LoggingFilter(logging.Filter):
class MyLoggingAdapter(logging.LoggerAdapter):
def process(self, msg, kwargs):
- return "[{}] {}".format(threading.get_ident() % 10000, msg), kwargs
+ return "[{:04d}] {}".format(threading.get_ident() % 10000, msg), kwargs
# return '[%s] %s' % (self.extra['connid'], msg), kwargs
@@ -51,7 +51,7 @@ class Logging:
_logger.addHandler(ch)
# Logging adapter, to be used as a logger
- print("setting logger variable")
+ # print("setting logger variable")
# global logger
cls.logger = MyLoggingAdapter(_logger, [])
@@ -166,6 +166,9 @@ class Progress:
SERVICE_RECONNECT_START = 4
SERVICE_RECONNECT_SUCCESS = 5
SERVICE_RECONNECT_FAILURE = 6
+ SERVICE_START_NAP = 7
+ CREATE_TABLE_ATTEMPT = 8
+
tokens = {
STEP_BOUNDARY: '.',
BEGIN_THREAD_STEP: '[',
@@ -174,6 +177,8 @@ class Progress:
SERVICE_RECONNECT_START: '',
SERVICE_RECONNECT_FAILURE: '.xr>',
+ SERVICE_START_NAP: '_zz',
+ CREATE_TABLE_ATTEMPT: '_c',
}
@classmethod
diff --git a/tests/pytest/crash_gen/service_manager.py b/tests/pytest/crash_gen/service_manager.py
index 196e9d944a..d249abc439 100644
--- a/tests/pytest/crash_gen/service_manager.py
+++ b/tests/pytest/crash_gen/service_manager.py
@@ -47,6 +47,17 @@ class TdeInstance():
.format(selfPath, projPath))
return buildPath
+ @classmethod
+ def prepareGcovEnv(cls, env):
+ # Ref: https://gcc.gnu.org/onlinedocs/gcc/Cross-profiling.html
+ bPath = cls._getBuildPath() # build PATH
+ numSegments = len(bPath.split('/')) - 1 # "/x/TDengine/build" should yield 3
+ numSegments = numSegments - 1 # DEBUG only
+ env['GCOV_PREFIX'] = bPath + '/svc_gcov'
+ env['GCOV_PREFIX_STRIP'] = str(numSegments) # Strip every element, plus, ENV needs strings
+ Logging.info("Preparing GCOV environement to strip {} elements and use path: {}".format(
+ numSegments, env['GCOV_PREFIX'] ))
+
def __init__(self, subdir='test', tInstNum=0, port=6030, fepPort=6030):
self._buildDir = self._getBuildPath()
self._subdir = '/' + subdir # TODO: tolerate "/"
@@ -217,6 +228,11 @@ class TdeSubProcess:
# raise CrashGenError("Empty instance not allowed in TdeSubProcess")
# self._tInst = tInst # Default create at ServiceManagerThread
+ def __repr__(self):
+ if self.subProcess is None:
+ return '[TdeSubProc: Empty]'
+ return '[TdeSubProc: pid = {}]'.format(self.getPid())
+
def getStdOut(self):
return self.subProcess.stdout
@@ -235,17 +251,30 @@ class TdeSubProcess:
# Sanity check
if self.subProcess: # already there
raise RuntimeError("Corrupt process state")
-
+
+ # Prepare environment variables for coverage information
+ # Ref: https://stackoverflow.com/questions/2231227/python-subprocess-popen-with-a-modified-environment
+ myEnv = os.environ.copy()
+ TdeInstance.prepareGcovEnv(myEnv)
+
+ # print(myEnv)
+ # print(myEnv.items())
+ # print("Starting TDengine via Shell: {}".format(cmdLineStr))
+
+ useShell = True
self.subProcess = subprocess.Popen(
- cmdLine,
- shell=False,
+ ' '.join(cmdLine) if useShell else cmdLine,
+ shell=useShell,
# svcCmdSingle, shell=True, # capture core dump?
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
# bufsize=1, # not supported in binary mode
- close_fds=ON_POSIX
+ close_fds=ON_POSIX,
+ env=myEnv
) # had text=True, which interferred with reading EOF
+ STOP_SIGNAL = signal.SIGKILL # What signal to use (in kill) to stop a taosd process?
+
def stop(self):
"""
Stop a sub process, and try to return a meaningful return code.
@@ -267,7 +296,7 @@ class TdeSubProcess:
SIGUSR2 12
"""
if not self.subProcess:
- print("Sub process already stopped")
+ Logging.error("Sub process already stopped")
return # -1
retCode = self.subProcess.poll() # ret -N means killed with signal N, otherwise it's from exit(N)
@@ -278,20 +307,25 @@ class TdeSubProcess:
return retCode
# process still alive, let's interrupt it
- print("Terminate running process, send SIG_INT and wait...")
- # sub process should end, then IPC queue should end, causing IO thread to end
- # sig = signal.SIGINT
- sig = signal.SIGKILL
- self.subProcess.send_signal(sig) # SIGNINT or SIGKILL
+ Logging.info("Terminate running process, send SIG_{} and wait...".format(self.STOP_SIGNAL))
+ # sub process should end, then IPC queue should end, causing IO thread to end
+ topSubProc = psutil.Process(self.subProcess.pid)
+ for child in topSubProc.children(recursive=True): # or parent.children() for recursive=False
+ child.send_signal(self.STOP_SIGNAL)
+ time.sleep(0.2) # 200 ms
+ # topSubProc.send_signal(sig) # now kill the main sub process (likely the Shell)
+
+ self.subProcess.send_signal(self.STOP_SIGNAL) # main sub process (likely the Shell)
self.subProcess.wait(20)
retCode = self.subProcess.returncode # should always be there
# May throw subprocess.TimeoutExpired exception above, therefore
# The process is guranteed to have ended by now
self.subProcess = None
if retCode != 0: # != (- signal.SIGINT):
- Logging.error("TSP.stop(): Failed to stop sub proc properly w/ SIG {}, retCode={}".format(sig, retCode))
+ Logging.error("TSP.stop(): Failed to stop sub proc properly w/ SIG {}, retCode={}".format(
+ self.STOP_SIGNAL, retCode))
else:
- Logging.info("TSP.stop(): sub proc successfully terminated with SIG {}".format(sig))
+ Logging.info("TSP.stop(): sub proc successfully terminated with SIG {}".format(self.STOP_SIGNAL))
return - retCode
class ServiceManager:
@@ -439,7 +473,7 @@ class ServiceManager:
time.sleep(self.PAUSE_BETWEEN_IPC_CHECK) # pause, before next round
# raise CrashGenError("dummy")
- print("Service Manager Thread (with subprocess) ended, main thread exiting...")
+ Logging.info("Service Manager Thread (with subprocess) ended, main thread exiting...")
def _getFirstInstance(self):
return self._tInsts[0]
@@ -452,7 +486,7 @@ class ServiceManager:
# Find if there's already a taosd service, and then kill it
for proc in psutil.process_iter():
if proc.name() == 'taosd':
- print("Killing an existing TAOSD process in 2 seconds... press CTRL-C to interrupt")
+ Logging.info("Killing an existing TAOSD process in 2 seconds... press CTRL-C to interrupt")
time.sleep(2.0)
proc.kill()
# print("Process: {}".format(proc.name()))
@@ -559,7 +593,8 @@ class ServiceManagerThread:
for i in range(0, 100):
time.sleep(1.0)
# self.procIpcBatch() # don't pump message during start up
- print("_zz_", end="", flush=True)
+ Progress.emit(Progress.SERVICE_START_NAP)
+ # print("_zz_", end="", flush=True)
if self._status.isRunning():
Logging.info("[] TDengine service READY to process requests")
Logging.info("[] TAOS service started: {}".format(self))
@@ -595,12 +630,12 @@ class ServiceManagerThread:
def stop(self):
# can be called from both main thread or signal handler
- print("Terminating TDengine service running as the sub process...")
+ Logging.info("Terminating TDengine service running as the sub process...")
if self.getStatus().isStopped():
- print("Service already stopped")
+ Logging.info("Service already stopped")
return
if self.getStatus().isStopping():
- print("Service is already being stopped")
+ Logging.info("Service is already being stopped")
return
# Linux will send Control-C generated SIGINT to the TDengine process
# already, ref:
@@ -616,10 +651,10 @@ class ServiceManagerThread:
if retCode == signal.SIGSEGV : # SGV
Logging.error("[[--ERROR--]]: TDengine service SEGV fault (check core file!)")
except subprocess.TimeoutExpired as err:
- print("Time out waiting for TDengine service process to exit")
+ Logging.info("Time out waiting for TDengine service process to exit")
else:
if self._tdeSubProcess.isRunning(): # still running, should now never happen
- print("FAILED to stop sub process, it is still running... pid = {}".format(
+ Logging.error("FAILED to stop sub process, it is still running... pid = {}".format(
self._tdeSubProcess.getPid()))
else:
self._tdeSubProcess = None # not running any more
@@ -683,9 +718,9 @@ class ServiceManagerThread:
return # we are done with THIS BATCH
else: # got line, printing out
if forceOutput:
- Logging.info(line)
+ Logging.info('[TAOSD] ' + line)
else:
- Logging.debug(line)
+ Logging.debug('[TAOSD] ' + line)
print(">", end="", flush=True)
_ProgressBars = ["--", "//", "||", "\\\\"]
@@ -728,11 +763,11 @@ class ServiceManagerThread:
# queue.put(line)
# meaning sub process must have died
- Logging.info("\nEnd of stream detected for TDengine STDOUT: {}".format(self))
+ Logging.info("EOF for TDengine STDOUT: {}".format(self))
out.close()
def svcErrorReader(self, err: IO, queue):
for line in iter(err.readline, b''):
- print("\nTDengine Service (taosd) ERROR (from stderr): {}".format(line))
- Logging.info("\nEnd of stream detected for TDengine STDERR: {}".format(self))
+ Logging.info("TDengine STDERR: {}".format(line))
+ Logging.info("EOF for TDengine STDERR: {}".format(self))
err.close()
\ No newline at end of file
diff --git a/tests/pytest/crash_gen_bootstrap.py b/tests/pytest/crash_gen_bootstrap.py
index a3417d21a8..fd12284b9d 100644
--- a/tests/pytest/crash_gen_bootstrap.py
+++ b/tests/pytest/crash_gen_bootstrap.py
@@ -11,7 +11,7 @@
###################################################################
import sys
-from crash_gen.crash_gen import MainExec
+from crash_gen.crash_gen_main import MainExec
if __name__ == "__main__":
diff --git a/tests/pytest/query/queryLike.py b/tests/pytest/query/queryLike.py
new file mode 100644
index 0000000000..3c3b030f8f
--- /dev/null
+++ b/tests/pytest/query/queryLike.py
@@ -0,0 +1,45 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+import taos
+from util.log import *
+from util.cases import *
+from util.sql import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor())
+
+ def run(self):
+ tdSql.prepare()
+
+ tdSql.execute("create table cars(ts timestamp, c nchar(2)) tags(t1 nchar(2))")
+ tdSql.execute("insert into car0 using cars tags('aa') values(now, 'bb');")
+ tdSql.query("select count(*) from cars where t1 like '%50 90 30 04 00 00%'")
+ tdSql.checkRows(0)
+
+ tdSql.execute("create table test_cars(ts timestamp, c nchar(2)) tags(t1 nchar(20))")
+ tdSql.execute("insert into car1 using test_cars tags('150 90 30 04 00 002') values(now, 'bb');")
+ tdSql.query("select * from test_cars where t1 like '%50 90 30 04 00 00%'")
+ tdSql.checkRows(1)
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/update/allow_update-0.py b/tests/pytest/update/allow_update-0.py
new file mode 100644
index 0000000000..61295ec4b7
--- /dev/null
+++ b/tests/pytest/update/allow_update-0.py
@@ -0,0 +1,170 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+import taos
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.dnodes import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+
+ self.numOfRecords = 10
+ self.ts = 1604295582000
+
+ def restartTaosd(self):
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.execute("use udb")
+
+ def run(self):
+ tdSql.prepare()
+ startTs = self.ts
+
+ print("==============step1")
+ tdSql.execute("create database udb update 0")
+ tdSql.execute("use udb")
+ tdSql.execute("create table t (ts timestamp, a int)")
+ tdSql.execute("insert into t values (%d, 1)" % (startTs))
+ tdSql.execute("insert into t values (%d, 1)" % (startTs - 3))
+ tdSql.execute("insert into t values (%d, 1)" % (startTs + 3))
+
+ tdSql.query("select * from t")
+ tdSql.checkRows(3)
+
+ tdSql.query("select a from t")
+ tdSql.checkData(0, 0, 1)
+ tdSql.checkData(1, 0, 1)
+ tdSql.checkData(2, 0, 1)
+
+ print("==============step2")
+ tdSql.execute("insert into t values (%d, 2)" % (startTs))
+ tdSql.execute("insert into t values (%d, 2)" % (startTs - 3))
+ tdSql.execute("insert into t values (%d, 2)" % (startTs + 3))
+
+ tdSql.query("select * from t")
+ tdSql.checkRows(3)
+
+ tdSql.query("select a from t")
+ tdSql.checkData(0, 0, 1)
+ tdSql.checkData(1, 0, 1)
+ tdSql.checkData(2, 0, 1)
+
+ print("==============step3")
+ tdSql.execute("insert into t values (%d, 3)" % (startTs - 4))
+ tdSql.execute("insert into t values (%d, 3)" % (startTs - 2))
+ tdSql.execute("insert into t values (%d, 3)" % (startTs + 2))
+ tdSql.execute("insert into t values (%d, 3)" % (startTs + 4))
+
+ tdSql.query("select * from t")
+ tdSql.checkRows(7)
+
+ tdSql.query("select a from t")
+ tdSql.checkData(0, 0, 3)
+ tdSql.checkData(1, 0, 1)
+ tdSql.checkData(2, 0, 3)
+ tdSql.checkData(3, 0, 1)
+ tdSql.checkData(4, 0, 3)
+ tdSql.checkData(5, 0, 1)
+ tdSql.checkData(6, 0, 3)
+
+ print("==============step4")
+ tdSql.execute("insert into t values (%d, 4)" % (startTs - 4))
+ tdSql.execute("insert into t values (%d, 4)" % (startTs - 2))
+ tdSql.execute("insert into t values (%d, 4)" % (startTs + 2))
+ tdSql.execute("insert into t values (%d, 4)" % (startTs + 4))
+
+ tdSql.query("select * from t")
+ tdSql.checkRows(7)
+
+ tdSql.query("select a from t")
+ tdSql.checkData(0, 0, 3)
+ tdSql.checkData(1, 0, 1)
+ tdSql.checkData(2, 0, 3)
+ tdSql.checkData(3, 0, 1)
+ tdSql.checkData(4, 0, 3)
+ tdSql.checkData(5, 0, 1)
+ tdSql.checkData(6, 0, 3)
+
+ print("==============step5")
+ tdSql.execute("insert into t values (%d, 5)" % (startTs - 1))
+ tdSql.execute("insert into t values (%d, 5)" % (startTs + 1))
+
+ tdSql.query("select * from t")
+ tdSql.checkRows(9)
+
+ tdSql.query("select a from t")
+ tdSql.checkData(0, 0, 3)
+ tdSql.checkData(1, 0, 1)
+ tdSql.checkData(2, 0, 3)
+ tdSql.checkData(3, 0, 5)
+ tdSql.checkData(4, 0, 1)
+ tdSql.checkData(5, 0, 5)
+ tdSql.checkData(6, 0, 3)
+ tdSql.checkData(7, 0, 1)
+ tdSql.checkData(8, 0, 3)
+
+ print("==============step6")
+ tdSql.execute("insert into t values (%d, 6)" % (startTs - 4))
+ tdSql.execute("insert into t values (%d, 6)" % (startTs - 3))
+ tdSql.execute("insert into t values (%d, 6)" % (startTs - 2))
+ tdSql.execute("insert into t values (%d, 6)" % (startTs - 1))
+ tdSql.execute("insert into t values (%d, 6)" % (startTs))
+ tdSql.execute("insert into t values (%d, 6)" % (startTs + 1))
+ tdSql.execute("insert into t values (%d, 6)" % (startTs + 2))
+ tdSql.execute("insert into t values (%d, 6)" % (startTs + 3))
+ tdSql.execute("insert into t values (%d, 6)" % (startTs + 4))
+
+ tdSql.query("select * from t")
+ tdSql.checkRows(9)
+
+ tdSql.query("select a from t")
+ tdSql.checkData(0, 0, 3)
+ tdSql.checkData(1, 0, 1)
+ tdSql.checkData(2, 0, 3)
+ tdSql.checkData(3, 0, 5)
+ tdSql.checkData(4, 0, 1)
+ tdSql.checkData(5, 0, 5)
+ tdSql.checkData(6, 0, 3)
+ tdSql.checkData(7, 0, 1)
+ tdSql.checkData(8, 0, 3)
+
+ # restart taosd to commit, and check
+ self.restartTaosd();
+
+ tdSql.query("select * from t")
+ tdSql.checkRows(9)
+
+ tdSql.query("select a from t")
+ tdSql.checkData(0, 0, 3)
+ tdSql.checkData(1, 0, 1)
+ tdSql.checkData(2, 0, 3)
+ tdSql.checkData(3, 0, 5)
+ tdSql.checkData(4, 0, 1)
+ tdSql.checkData(5, 0, 5)
+ tdSql.checkData(6, 0, 3)
+ tdSql.checkData(7, 0, 1)
+ tdSql.checkData(8, 0, 3)
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/update/allow_update.py b/tests/pytest/update/allow_update.py
new file mode 100644
index 0000000000..5871197f02
--- /dev/null
+++ b/tests/pytest/update/allow_update.py
@@ -0,0 +1,266 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+import taos
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.dnodes import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+
+ self.numOfRecords = 10
+ self.ts = 1604295582000
+
+ def restartTaosd(self):
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.execute("use udb")
+
+ def run(self):
+ tdSql.prepare()
+ startTs = self.ts
+
+ tdSql.execute("create database udb update 1")
+ tdSql.execute("use udb")
+ tdSql.execute("create table t (ts timestamp, a int)")
+
+ print("==============step1")
+ tdSql.execute("insert into t values (%d, 1)" % (startTs))
+ tdSql.execute("insert into t values (%d, 1)" % (startTs - 3))
+ tdSql.execute("insert into t values (%d, 1)" % (startTs + 3))
+
+ tdSql.query("select * from t")
+ tdSql.checkRows(3)
+
+ tdSql.query("select a from t")
+ tdSql.checkData(0, 0, 1)
+ tdSql.checkData(1, 0, 1)
+ tdSql.checkData(2, 0, 1)
+
+ print("==============step2")
+ tdSql.execute("insert into t values (%d, 2)" % (startTs))
+ tdSql.execute("insert into t values (%d, 2)" % (startTs - 3))
+ tdSql.execute("insert into t values (%d, 2)" % (startTs + 3))
+
+ tdSql.query("select * from t")
+ tdSql.checkRows(3)
+
+ tdSql.query("select a from t")
+ tdSql.checkData(0, 0, 2)
+ tdSql.checkData(1, 0, 2)
+ tdSql.checkData(2, 0, 2)
+
+ print("==============step3")
+ tdSql.execute("insert into t values (%d, 3)" % (startTs - 4))
+ tdSql.execute("insert into t values (%d, 3)" % (startTs - 2))
+ tdSql.execute("insert into t values (%d, 3)" % (startTs + 2))
+ tdSql.execute("insert into t values (%d, 3)" % (startTs + 4))
+
+ tdSql.query("select * from t")
+ tdSql.checkRows(7)
+
+ tdSql.query("select a from t")
+ tdSql.checkData(0, 0, 3)
+ tdSql.checkData(1, 0, 2)
+ tdSql.checkData(2, 0, 3)
+ tdSql.checkData(3, 0, 2)
+ tdSql.checkData(4, 0, 3)
+ tdSql.checkData(5, 0, 2)
+ tdSql.checkData(6, 0, 3)
+
+ print("==============step4")
+ tdSql.execute("insert into t values (%d, 4)" % (startTs - 4))
+ tdSql.execute("insert into t values (%d, 4)" % (startTs - 2))
+ tdSql.execute("insert into t values (%d, 4)" % (startTs + 2))
+ tdSql.execute("insert into t values (%d, 4)" % (startTs + 4))
+
+ tdSql.query("select * from t")
+ tdSql.checkRows(7)
+
+ tdSql.query("select a from t")
+ tdSql.checkData(0, 0, 4)
+ tdSql.checkData(1, 0, 2)
+ tdSql.checkData(2, 0, 4)
+ tdSql.checkData(3, 0, 2)
+ tdSql.checkData(4, 0, 4)
+ tdSql.checkData(5, 0, 2)
+ tdSql.checkData(6, 0, 4)
+
+ print("==============step5")
+ tdSql.execute("insert into t values (%d, 5)" % (startTs - 1))
+ tdSql.execute("insert into t values (%d, 5)" % (startTs + 1))
+
+ tdSql.query("select * from t")
+ tdSql.checkRows(9)
+
+ tdSql.query("select a from t")
+ tdSql.checkData(0, 0, 4)
+ tdSql.checkData(1, 0, 2)
+ tdSql.checkData(2, 0, 4)
+ tdSql.checkData(3, 0, 5)
+ tdSql.checkData(4, 0, 2)
+ tdSql.checkData(5, 0, 5)
+ tdSql.checkData(6, 0, 4)
+ tdSql.checkData(7, 0, 2)
+ tdSql.checkData(8, 0, 4)
+
+ print("==============step6")
+ tdSql.execute("insert into t values (%d, 6)" % (startTs - 4))
+ tdSql.execute("insert into t values (%d, 6)" % (startTs - 3))
+ tdSql.execute("insert into t values (%d, 6)" % (startTs - 2))
+ tdSql.execute("insert into t values (%d, 6)" % (startTs - 1))
+ tdSql.execute("insert into t values (%d, 6)" % (startTs))
+ tdSql.execute("insert into t values (%d, 6)" % (startTs + 1))
+ tdSql.execute("insert into t values (%d, 6)" % (startTs + 2))
+ tdSql.execute("insert into t values (%d, 6)" % (startTs + 3))
+ tdSql.execute("insert into t values (%d, 6)" % (startTs + 4))
+
+ tdSql.query("select * from t")
+ tdSql.checkRows(9)
+
+ tdSql.query("select a from t")
+ tdSql.checkData(0, 0, 6)
+ tdSql.checkData(1, 0, 6)
+ tdSql.checkData(2, 0, 6)
+ tdSql.checkData(3, 0, 6)
+ tdSql.checkData(4, 0, 6)
+ tdSql.checkData(5, 0, 6)
+ tdSql.checkData(6, 0, 6)
+ tdSql.checkData(7, 0, 6)
+ tdSql.checkData(8, 0, 6)
+
+ # restart taosd to commit, and check
+ self.restartTaosd();
+
+ tdSql.query("select * from t")
+ tdSql.checkRows(9)
+
+ tdSql.query("select a from t")
+ tdSql.checkData(0, 0, 6)
+ tdSql.checkData(1, 0, 6)
+ tdSql.checkData(2, 0, 6)
+ tdSql.checkData(3, 0, 6)
+ tdSql.checkData(4, 0, 6)
+ tdSql.checkData(5, 0, 6)
+ tdSql.checkData(6, 0, 6)
+ tdSql.checkData(7, 0, 6)
+ tdSql.checkData(8, 0, 6)
+
+ tdSql.execute("create table subt (ts timestamp, a int, b float, c binary(16), d bool)")
+
+ print("==============step7")
+ tdSql.execute("insert into subt (ts, a, c) values (%d, 1, 'c+0')" % (startTs))
+ tdSql.execute("insert into subt (ts, a, c) values (%d, 1, 'c-3')" % (startTs - 3))
+ tdSql.execute("insert into subt (ts, a, c) values (%d, 1, 'c+3')" % (startTs + 3))
+
+ tdSql.query("select * from subt")
+ tdSql.checkRows(3)
+
+ tdSql.query("select a,b,c,d from subt")
+ tdSql.checkData(0, 0, 1)
+ tdSql.checkData(1, 0, 1)
+ tdSql.checkData(2, 0, 1)
+ tdSql.checkData(0, 1, None)
+ tdSql.checkData(1, 1, None)
+ tdSql.checkData(2, 1, None)
+ tdSql.checkData(0, 2, 'c-3')
+ tdSql.checkData(1, 2, 'c+0')
+ tdSql.checkData(2, 2, 'c+3')
+ tdSql.checkData(0, 3, None)
+ tdSql.checkData(1, 3, None)
+ tdSql.checkData(2, 3, None)
+
+ print("==============step8")
+ tdSql.execute("insert into subt (ts, b, d) values (%d, 2.0, true)" % (startTs))
+ tdSql.execute("insert into subt (ts, b, d) values (%d, 2.0, true)" % (startTs - 3))
+ tdSql.execute("insert into subt (ts, b, d) values (%d, 2.0, false)" % (startTs + 3))
+
+ tdSql.query("select * from subt")
+ tdSql.checkRows(3)
+
+ tdSql.query("select a,b,c,d from subt")
+ tdSql.checkData(0, 0, None)
+ tdSql.checkData(1, 0, None)
+ tdSql.checkData(2, 0, None)
+ tdSql.checkData(0, 1, 2.0)
+ tdSql.checkData(1, 1, 2.0)
+ tdSql.checkData(2, 1, 2.0)
+ tdSql.checkData(0, 2, None)
+ tdSql.checkData(1, 2, None)
+ tdSql.checkData(2, 2, None)
+ tdSql.checkData(0, 3, 1)
+ tdSql.checkData(1, 3, 1)
+ tdSql.checkData(2, 3, 0)
+
+ # restart taosd to commit, and check
+ self.restartTaosd();
+
+ tdSql.query("select * from subt")
+ tdSql.checkRows(3)
+
+ tdSql.query("select a,b,c,d from subt")
+ tdSql.checkData(0, 0, None)
+ tdSql.checkData(1, 0, None)
+ tdSql.checkData(2, 0, None)
+ tdSql.checkData(0, 1, 2.0)
+ tdSql.checkData(1, 1, 2.0)
+ tdSql.checkData(2, 1, 2.0)
+ tdSql.checkData(0, 2, None)
+ tdSql.checkData(1, 2, None)
+ tdSql.checkData(2, 2, None)
+ tdSql.checkData(0, 3, 1)
+ tdSql.checkData(1, 3, 1)
+ tdSql.checkData(2, 3, 0)
+
+
+
+ tdSql.execute("create table ct (ts timestamp, a int, b float, c binary(128))")
+
+ print("==============step9")
+ insertRows = 20000
+ for i in range(0, insertRows):
+ tdSql.execute("insert into ct values (%d , %d, %d, 'aabbccddeeffgghhiijjkkllmmoonn112233445566778899xxyyzz')" % (startTs + i, i, i))
+
+ tdSql.query("select * from ct")
+ tdSql.checkRows(insertRows)
+
+ for i in range(0, insertRows):
+ tdSql.execute("insert into ct values (%d , %d, %d, 'aabbccddeeffgghhiijjkkllmmoonn112233445566778899xxyyzz')" % (startTs + i, i+insertRows, i+insertRows))
+
+ tdSql.query("select * from ct")
+ tdSql.checkRows(insertRows)
+
+ tdSql.query("select a,b from ct limit 3")
+ tdSql.checkData(0, 0, insertRows+0)
+ tdSql.checkData(1, 0, insertRows+1)
+ tdSql.checkData(2, 0, insertRows+2)
+
+ tdSql.checkData(0, 1, insertRows+0)
+ tdSql.checkData(1, 1, insertRows+1)
+ tdSql.checkData(2, 1, insertRows+2)
+
+
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/update/append_commit_data-0.py b/tests/pytest/update/append_commit_data-0.py
new file mode 100644
index 0000000000..b844a50a08
--- /dev/null
+++ b/tests/pytest/update/append_commit_data-0.py
@@ -0,0 +1,84 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.dnodes import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+
+ def run(self):
+ print("==========step1")
+ print("create table && insert data")
+ s = 'reset query cache'
+ tdSql.execute(s)
+ s = 'drop database if exists db'
+ tdSql.execute(s)
+ s = 'create database db'
+ tdSql.execute(s)
+ s = 'use db'
+ tdSql.execute(s)
+ ret = tdSql.execute('create table t1 (ts timestamp, a int)')
+
+ insertRows = 200
+ t0 = 1604298064000
+ tdLog.info("insert %d rows" % (insertRows))
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t1 values (%d , 1)' %
+ (t0+i))
+ print("==========step2")
+ print("restart to commit ")
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from db.t1")
+ tdSql.checkRows(insertRows)
+ for k in range(0,100):
+ tdLog.info("insert %d rows" % (insertRows))
+ for i in range (0,insertRows):
+ ret = tdSql.execute(
+ 'insert into db.t1 values(%d,1)' %
+ (t0+k*200+i)
+ )
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from db.t1")
+ tdSql.checkRows(insertRows+200*k)
+ print("==========step2")
+ print("insert into another table ")
+ s = 'use db'
+ tdSql.execute(s)
+ ret = tdSql.execute('create table t2 (ts timestamp, a int)')
+ insertRows = 20000
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t2 values (%d, 1)' %
+ (t0+i))
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t2")
+ tdSql.checkRows(insertRows)
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/update/append_commit_data.py b/tests/pytest/update/append_commit_data.py
new file mode 100644
index 0000000000..3169b748e0
--- /dev/null
+++ b/tests/pytest/update/append_commit_data.py
@@ -0,0 +1,84 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.dnodes import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+
+ def run(self):
+ print("==========step1")
+ print("create table && insert data")
+ s = 'reset query cache'
+ tdSql.execute(s)
+ s = 'drop database if exists db'
+ tdSql.execute(s)
+ s = 'create database db update 1'
+ tdSql.execute(s)
+ s = 'use db'
+ tdSql.execute(s)
+ ret = tdSql.execute('create table t1 (ts timestamp, a int)')
+
+ insertRows = 200
+ t0 = 1604298064000
+ tdLog.info("insert %d rows" % (insertRows))
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t1 values (%d , 1)' %
+ (t0+i))
+ print("==========step2")
+ print("restart to commit ")
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from db.t1")
+ tdSql.checkRows(insertRows)
+ for k in range(0,100):
+ tdLog.info("insert %d rows" % (insertRows))
+ for i in range (0,insertRows):
+ ret = tdSql.execute(
+ 'insert into db.t1 values(%d,1)' %
+ (t0+k*200+i)
+ )
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from db.t1")
+ tdSql.checkRows(insertRows+200*k)
+ print("==========step2")
+ print("insert into another table ")
+ s = 'use db'
+ tdSql.execute(s)
+ ret = tdSql.execute('create table t2 (ts timestamp, a int)')
+ insertRows = 20000
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t2 values (%d, 1)' %
+ (t0+i))
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t2")
+ tdSql.checkRows(insertRows)
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/update/append_commit_last-0.py b/tests/pytest/update/append_commit_last-0.py
new file mode 100644
index 0000000000..c884207f2b
--- /dev/null
+++ b/tests/pytest/update/append_commit_last-0.py
@@ -0,0 +1,90 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+import taos
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.dnodes import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor())
+
+ self.ts = 1604298064000
+
+ def restartTaosd(self):
+ tdDnodes.stop(1)
+ tdDnodes.startWithoutSleep(1)
+ tdSql.execute("use db")
+
+ def run(self):
+ tdSql.prepare()
+
+ print("==============step1")
+ tdSql.execute("create table t1 (ts timestamp, a int)")
+
+ for i in range(10):
+ tdSql.execute("insert into t1 values(%d, 1)" % (self.ts + i))
+ self.restartTaosd()
+ tdSql.query("select * from t1")
+ tdSql.checkRows(i + 1)
+ tdSql.query("select sum(a) from t1")
+ tdSql.checkData(0, 0, i + 1)
+
+ print("==============step2")
+ tdSql.execute("create table t2 (ts timestamp, a int)")
+ tdSql.execute("insert into t2 values(%d, 1)" % self.ts)
+ self.restartTaosd()
+ tdSql.query("select * from t2")
+ tdSql.checkRows(1)
+ tdSql.checkData(0, 1, 1)
+
+ for i in range(1, 151):
+ tdSql.execute("insert into t2 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t2")
+ tdSql.checkRows(151)
+ tdSql.query("select sum(a) from t2")
+ tdSql.checkData(0, 0, 151)
+
+
+ print("==============step3")
+ tdSql.execute("create table t3 (ts timestamp, a int)")
+ tdSql.execute("insert into t3 values(%d, 1)" % self.ts)
+ self.restartTaosd()
+ tdSql.query("select * from t3")
+ tdSql.checkRows(1)
+ tdSql.checkData(0, 1, 1)
+
+ for i in range(8):
+ for j in range(1, 11):
+ tdSql.execute("insert into t3 values(%d, 1)" % (self.ts + i * 10 + j))
+
+ self.restartTaosd()
+ tdSql.query("select * from t3")
+ tdSql.checkRows(81)
+ tdSql.query("select sum(a) from t3")
+ tdSql.checkData(0, 0, 81)
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/update/append_commit_last.py b/tests/pytest/update/append_commit_last.py
new file mode 100644
index 0000000000..013983f940
--- /dev/null
+++ b/tests/pytest/update/append_commit_last.py
@@ -0,0 +1,85 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+import taos
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.dnodes import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor())
+
+ self.ts = 1604298064000
+
+ def restartTaosd(self):
+ tdDnodes.stop(1)
+ tdDnodes.startWithoutSleep(1)
+ tdSql.execute("use udb")
+
+ def run(self):
+ tdSql.prepare()
+
+ print("==============step1")
+ tdSql.execute("create database udb update 1")
+ tdSql.execute("use udb")
+ tdSql.execute("create table t1 (ts timestamp, a int)")
+
+ for i in range(10):
+ tdSql.execute("insert into t1 values(%d, 1)" % (self.ts + i))
+ self.restartTaosd()
+ tdSql.query("select * from t1")
+ tdSql.checkRows(i + 1)
+
+
+ print("==============step2")
+ tdSql.execute("create table t2 (ts timestamp, a int)")
+ tdSql.execute("insert into t2 values(%d, 1)" % self.ts)
+ self.restartTaosd()
+ tdSql.query("select * from t2")
+ tdSql.checkRows(1)
+
+ for i in range(1, 151):
+ tdSql.execute("insert into t2 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t2")
+ tdSql.checkRows(151)
+
+
+ print("==============step3")
+ tdSql.execute("create table t3 (ts timestamp, a int)")
+ tdSql.execute("insert into t3 values(%d, 1)" % self.ts)
+ self.restartTaosd()
+ tdSql.query("select * from t3")
+ tdSql.checkRows(1)
+
+ for i in range(8):
+ for j in range(1, 11):
+ tdSql.execute("insert into t3 values(%d, 1)" % (self.ts + i * 10 + j))
+
+ self.restartTaosd()
+ tdSql.query("select * from t3")
+ tdSql.checkRows(81)
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/update/merge_commit_data-0.py b/tests/pytest/update/merge_commit_data-0.py
new file mode 100644
index 0000000000..14d435f7f2
--- /dev/null
+++ b/tests/pytest/update/merge_commit_data-0.py
@@ -0,0 +1,351 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.dnodes import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+
+ def run(self):
+ print("==========step1")
+ print("UPDATE THE WHOLE DATA BLOCK REPEATEDLY")
+ s = 'reset query cache'
+ tdSql.execute(s)
+ s = 'drop database if exists db'
+ tdSql.execute(s)
+ s = 'create database db days 30'
+ tdSql.execute(s)
+ s = 'use db'
+ tdSql.execute(s)
+ ret = tdSql.execute('create table t1 (ts timestamp, a int)')
+
+ insertRows = 200
+ t0 = 1603152000000
+ tdLog.info("insert %d rows" % (insertRows))
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t1 values (%d , 1)' %
+ (t0 + i))
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t1")
+ tdSql.checkRows(insertRows)
+
+ for k in range(0,10):
+ for i in range (0,insertRows):
+ ret = tdSql.execute(
+ 'insert into t1 values(%d,1)' %
+ (t0+i)
+ )
+ tdSql.query("select * from t1")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t1")
+ tdSql.checkRows(insertRows)
+ print("==========step2")
+ print("PREPEND DATA ")
+ ret = tdSql.execute('create table t2 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t2 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t2")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t2")
+ tdSql.checkRows(insertRows)
+ for i in range(-100,0):
+ ret = tdSql.execute(
+ 'insert into t2 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t2")
+ tdSql.checkRows(insertRows+100)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t2")
+ tdSql.checkRows(insertRows+100)
+ print("==========step3")
+ print("PREPEND MASSIVE DATA ")
+ ret = tdSql.execute('create table t3 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t3 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t3")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t3")
+ tdSql.checkRows(insertRows)
+ for i in range(-6000,0):
+ ret = tdSql.execute(
+ 'insert into t3 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t3")
+ tdSql.checkRows(insertRows+6000)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t3")
+ tdSql.checkRows(insertRows+6000)
+ print("==========step4")
+ print("APPEND DATA")
+ ret = tdSql.execute('create table t4 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t4 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t4")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t4")
+ tdSql.checkRows(insertRows)
+ for i in range(0,100):
+ ret = tdSql.execute(
+ 'insert into t4 values (%d , 1)' %
+ (t0+200+i))
+ tdSql.query("select * from t4")
+ tdSql.checkRows(insertRows+100)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t4")
+ tdSql.checkRows(insertRows+100)
+ print("==========step5")
+ print("APPEND DATA")
+ ret = tdSql.execute('create table t5 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t5 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t5")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t5")
+ tdSql.checkRows(insertRows)
+ for i in range(0,6000):
+ ret = tdSql.execute(
+ 'insert into t5 values (%d , 1)' %
+ (t0+200+i))
+ tdSql.query("select * from t5")
+ tdSql.checkRows(insertRows+6000)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t5")
+ tdSql.checkRows(insertRows+6000)
+ print("==========step6")
+ print("UPDATE BLOCK IN TWO STEP")
+ ret = tdSql.execute('create table t6 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t6 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t6")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t6")
+ tdSql.checkRows(insertRows)
+ for i in range(0,100):
+ ret = tdSql.execute(
+ 'insert into t6 values (%d , 2)' %
+ (t0+i))
+ tdSql.query("select * from t6")
+ tdSql.checkRows(insertRows)
+ tdSql.query("select sum(a) from t6")
+ tdSql.checkData(0,0,'200')
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t6")
+ tdSql.checkRows(insertRows)
+ tdSql.query("select sum(a) from t6")
+ tdSql.checkData(0,0,'200')
+ for i in range(0,200):
+ ret = tdSql.execute(
+ 'insert into t6 values (%d , 2)' %
+ (t0+i))
+ tdSql.query("select * from t6")
+ tdSql.checkRows(insertRows)
+ tdSql.query("select sum(a) from t6")
+ tdSql.checkData(0,0,'200')
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t6")
+ tdSql.checkRows(insertRows)
+ tdSql.query("select sum(a) from t6")
+ tdSql.checkData(0,0,'200')
+ print("==========step7")
+ print("UPDATE LAST HALF AND INSERT LITTLE DATA")
+ ret = tdSql.execute('create table t7 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t7 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t7")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t7")
+ tdSql.checkRows(insertRows)
+ for i in range(100,300):
+ ret = tdSql.execute(
+ 'insert into t7 values (%d , 2)' %
+ (t0+i))
+ tdSql.query("select * from t7")
+ tdSql.checkRows(300)
+ tdSql.query("select sum(a) from t7")
+ tdSql.checkData(0,0,'400')
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t7")
+ tdSql.checkRows(300)
+ tdSql.query("select sum(a) from t7")
+ tdSql.checkData(0,0,'400')
+ print("==========step8")
+ print("UPDATE LAST HALF AND INSERT MASSIVE DATA")
+ ret = tdSql.execute('create table t8 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t8 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t8")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t8")
+ tdSql.checkRows(insertRows)
+ for i in range(6000):
+ ret = tdSql.execute(
+ 'insert into t8 values (%d , 2)' %
+ (t0+i))
+ tdSql.query("select * from t8")
+ tdSql.checkRows(6000)
+ tdSql.query("select sum(a) from t8")
+ tdSql.checkData(0,0,'11800')
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t8")
+ tdSql.checkRows(6000)
+ tdSql.query("select sum(a) from t8")
+ tdSql.checkData(0,0,'11800')
+ print("==========step9")
+ print("UPDATE FIRST HALF AND PREPEND LITTLE DATA")
+ ret = tdSql.execute('create table t9 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t9 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t9")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t9")
+ tdSql.checkRows(insertRows)
+ for i in range(-100,100):
+ ret = tdSql.execute(
+ 'insert into t9 values (%d , 2)' %
+ (t0+i))
+ tdSql.query("select * from t9")
+ tdSql.checkRows(300)
+ tdSql.query("select sum(a) from t9")
+ tdSql.checkData(0,0,'400')
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t9")
+ tdSql.checkRows(300)
+ tdSql.query("select sum(a) from t9")
+ tdSql.checkData(0,0,'400')
+ print("==========step10")
+ print("UPDATE FIRST HALF AND PREPEND MASSIVE DATA")
+ ret = tdSql.execute('create table t10 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t10 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t10")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t10")
+ tdSql.checkRows(insertRows)
+ for i in range(-6000,100):
+ ret = tdSql.execute(
+ 'insert into t10 values (%d , 2)' %
+ (t0+i))
+ tdSql.query("select * from t10")
+ tdSql.checkRows(6200)
+ tdSql.query("select sum(a) from t10")
+ tdSql.checkData(0,0,'12200')
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t10")
+ tdSql.checkRows(6200)
+ tdSql.query("select sum(a) from t10")
+ tdSql.checkData(0,0,'12200')
+ print("==========step11")
+ print("UPDATE FIRST HALF AND APPEND MASSIVE DATA")
+ ret = tdSql.execute('create table t11 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t11 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t11")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t11")
+ tdSql.checkRows(insertRows)
+ for i in range(100):
+ ret = tdSql.execute(
+ 'insert into t11 values (%d , 2)' %
+ (t0+i))
+ for i in range(200,6000):
+ ret = tdSql.execute(
+ 'insert into t11 values (%d , 2)' %
+ (t0+i))
+ tdSql.query("select * from t11")
+ tdSql.checkRows(6000)
+ tdSql.query("select sum(a) from t11")
+ tdSql.checkData(0,0,'11800')
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t11")
+ tdSql.checkRows(6000)
+ tdSql.query("select sum(a) from t11")
+ tdSql.checkData(0,0,'11800')
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/update/merge_commit_data.py b/tests/pytest/update/merge_commit_data.py
new file mode 100644
index 0000000000..4fb6765361
--- /dev/null
+++ b/tests/pytest/update/merge_commit_data.py
@@ -0,0 +1,351 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.dnodes import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+
+ def run(self):
+ print("==========step1")
+ print("UPDATE THE WHOLE DATA BLOCK REPEATEDLY")
+ s = 'reset query cache'
+ tdSql.execute(s)
+ s = 'drop database if exists db'
+ tdSql.execute(s)
+ s = 'create database db update 1 days 30'
+ tdSql.execute(s)
+ s = 'use db'
+ tdSql.execute(s)
+ ret = tdSql.execute('create table t1 (ts timestamp, a int)')
+
+ insertRows = 200
+ t0 = 1603152000000
+ tdLog.info("insert %d rows" % (insertRows))
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t1 values (%d , 1)' %
+ (t0 + i))
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t1")
+ tdSql.checkRows(insertRows)
+
+ for k in range(0,10):
+ for i in range (0,insertRows):
+ ret = tdSql.execute(
+ 'insert into t1 values(%d,1)' %
+ (t0+i)
+ )
+ tdSql.query("select * from t1")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t1")
+ tdSql.checkRows(insertRows)
+ print("==========step2")
+ print("PREPEND DATA ")
+ ret = tdSql.execute('create table t2 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t2 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t2")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t2")
+ tdSql.checkRows(insertRows)
+ for i in range(-100,0):
+ ret = tdSql.execute(
+ 'insert into t2 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t2")
+ tdSql.checkRows(insertRows+100)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t2")
+ tdSql.checkRows(insertRows+100)
+ print("==========step3")
+ print("PREPEND MASSIVE DATA ")
+ ret = tdSql.execute('create table t3 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t3 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t3")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t3")
+ tdSql.checkRows(insertRows)
+ for i in range(-6000,0):
+ ret = tdSql.execute(
+ 'insert into t3 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t3")
+ tdSql.checkRows(insertRows+6000)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t3")
+ tdSql.checkRows(insertRows+6000)
+ print("==========step4")
+ print("APPEND DATA")
+ ret = tdSql.execute('create table t4 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t4 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t4")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t4")
+ tdSql.checkRows(insertRows)
+ for i in range(0,100):
+ ret = tdSql.execute(
+ 'insert into t4 values (%d , 1)' %
+ (t0+200+i))
+ tdSql.query("select * from t4")
+ tdSql.checkRows(insertRows+100)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t4")
+ tdSql.checkRows(insertRows+100)
+ print("==========step5")
+ print("APPEND DATA")
+ ret = tdSql.execute('create table t5 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t5 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t5")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t5")
+ tdSql.checkRows(insertRows)
+ for i in range(0,6000):
+ ret = tdSql.execute(
+ 'insert into t5 values (%d , 1)' %
+ (t0+200+i))
+ tdSql.query("select * from t5")
+ tdSql.checkRows(insertRows+6000)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t5")
+ tdSql.checkRows(insertRows+6000)
+ print("==========step6")
+ print("UPDATE BLOCK IN TWO STEP")
+ ret = tdSql.execute('create table t6 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t6 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t6")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t6")
+ tdSql.checkRows(insertRows)
+ for i in range(0,100):
+ ret = tdSql.execute(
+ 'insert into t6 values (%d , 2)' %
+ (t0+i))
+ tdSql.query("select * from t6")
+ tdSql.checkRows(insertRows)
+ tdSql.query("select sum(a) from t6")
+ tdSql.checkData(0,0,'300')
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t6")
+ tdSql.checkRows(insertRows)
+ tdSql.query("select sum(a) from t6")
+ tdSql.checkData(0,0,'300')
+ for i in range(0,200):
+ ret = tdSql.execute(
+ 'insert into t6 values (%d , 2)' %
+ (t0+i))
+ tdSql.query("select * from t6")
+ tdSql.checkRows(insertRows)
+ tdSql.query("select sum(a) from t6")
+ tdSql.checkData(0,0,'400')
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t6")
+ tdSql.checkRows(insertRows)
+ tdSql.query("select sum(a) from t6")
+ tdSql.checkData(0,0,'400')
+ print("==========step7")
+ print("UPDATE LAST HALF AND INSERT LITTLE DATA")
+ ret = tdSql.execute('create table t7 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t7 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t7")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t7")
+ tdSql.checkRows(insertRows)
+ for i in range(100,300):
+ ret = tdSql.execute(
+ 'insert into t7 values (%d , 2)' %
+ (t0+i))
+ tdSql.query("select * from t7")
+ tdSql.checkRows(300)
+ tdSql.query("select sum(a) from t7")
+ tdSql.checkData(0,0,'500')
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t7")
+ tdSql.checkRows(300)
+ tdSql.query("select sum(a) from t7")
+ tdSql.checkData(0,0,'500')
+ print("==========step8")
+ print("UPDATE LAST HALF AND INSERT MASSIVE DATA")
+ ret = tdSql.execute('create table t8 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t8 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t8")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t8")
+ tdSql.checkRows(insertRows)
+ for i in range(6000):
+ ret = tdSql.execute(
+ 'insert into t8 values (%d , 2)' %
+ (t0+i))
+ tdSql.query("select * from t8")
+ tdSql.checkRows(6000)
+ tdSql.query("select sum(a) from t8")
+ tdSql.checkData(0,0,'12000')
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t8")
+ tdSql.checkRows(6000)
+ tdSql.query("select sum(a) from t8")
+ tdSql.checkData(0,0,'12000')
+ print("==========step9")
+ print("UPDATE FIRST HALF AND PREPEND LITTLE DATA")
+ ret = tdSql.execute('create table t9 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t9 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t9")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t9")
+ tdSql.checkRows(insertRows)
+ for i in range(-100,100):
+ ret = tdSql.execute(
+ 'insert into t9 values (%d , 2)' %
+ (t0+i))
+ tdSql.query("select * from t9")
+ tdSql.checkRows(300)
+ tdSql.query("select sum(a) from t9")
+ tdSql.checkData(0,0,'500')
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t9")
+ tdSql.checkRows(300)
+ tdSql.query("select sum(a) from t9")
+ tdSql.checkData(0,0,'500')
+ print("==========step10")
+ print("UPDATE FIRST HALF AND PREPEND MASSIVE DATA")
+ ret = tdSql.execute('create table t10 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t10 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t10")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t10")
+ tdSql.checkRows(insertRows)
+ for i in range(-6000,100):
+ ret = tdSql.execute(
+ 'insert into t10 values (%d , 2)' %
+ (t0+i))
+ tdSql.query("select * from t10")
+ tdSql.checkRows(6200)
+ tdSql.query("select sum(a) from t10")
+ tdSql.checkData(0,0,'12300')
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t10")
+ tdSql.checkRows(6200)
+ tdSql.query("select sum(a) from t10")
+ tdSql.checkData(0,0,'12300')
+ print("==========step11")
+ print("UPDATE FIRST HALF AND APPEND MASSIVE DATA")
+ ret = tdSql.execute('create table t11 (ts timestamp, a int)')
+ insertRows = 200
+ for i in range(0, insertRows):
+ ret = tdSql.execute(
+ 'insert into t11 values (%d , 1)' %
+ (t0+i))
+ tdSql.query("select * from t11")
+ tdSql.checkRows(insertRows)
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t11")
+ tdSql.checkRows(insertRows)
+ for i in range(100):
+ ret = tdSql.execute(
+ 'insert into t11 values (%d , 2)' %
+ (t0+i))
+ for i in range(200,6000):
+ ret = tdSql.execute(
+ 'insert into t11 values (%d , 2)' %
+ (t0+i))
+ tdSql.query("select * from t11")
+ tdSql.checkRows(6000)
+ tdSql.query("select sum(a) from t11")
+ tdSql.checkData(0,0,'11900')
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ tdSql.query("select * from t11")
+ tdSql.checkRows(6000)
+ tdSql.query("select sum(a) from t11")
+ tdSql.checkData(0,0,'11900')
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/update/merge_commit_data2.py b/tests/pytest/update/merge_commit_data2.py
new file mode 100644
index 0000000000..3f0fc718ad
--- /dev/null
+++ b/tests/pytest/update/merge_commit_data2.py
@@ -0,0 +1,352 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.dnodes import *
+import time
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+
+
+ def restart_taosd(self,db):
+ tdDnodes.stop(1)
+ tdDnodes.startWithoutSleep(1)
+ tdSql.execute("use %s;" % db)
+
+ def date_to_timestamp_microseconds(self, date):
+ datetime_obj = datetime.strptime(date, "%Y-%m-%d %H:%M:%S.%f")
+ obj_stamp = int(time.mktime(datetime_obj.timetuple()) * 1000.0 + datetime_obj.microsecond / 1000.0)
+ return obj_stamp
+
+ def timestamp_microseconds_to_date(self, timestamp):
+ d = datetime.datetime.fromtimestamp(timestamp/1000)
+ str1 = d.strftime("%Y-%m-%d %H:%M:%S.%f")
+ return str1
+
+
+
+ def run(self):
+ print("==========step1")
+ print("create table && insert data")
+ sql = 'reset query cache'
+ tdSql.execute(sql)
+ sql = 'drop database if exists db'
+ tdSql.execute(sql)
+ sql = 'create database db update 1 days 30;'
+ tdSql.execute(sql)
+ sql = 'use db;'
+ tdSql.execute(sql)
+ tdSql.execute('create table t1 (ts timestamp, a int)')
+
+
+ print("==================================1 start")
+ insert_rows = 200
+ t0 = 1603152000000
+ tdLog.info("insert %d rows" % insert_rows)
+ for i in range(insert_rows):
+ tdSql.execute('insert into t1 values (%d , 1)' %(t0+i))
+ print("==========step2")
+ print("restart to commit ")
+ self.restart_taosd('db')
+
+ print('check query result after restart')
+ tdSql.query('select * from db.t1;')
+ for i in range(insert_rows):
+ tdSql.checkData(i, 1, 1)
+
+ print("==========step3")
+ print('insert data')
+ for i in range(insert_rows):
+ tdSql.execute('insert into t1 values (%d , 1)' %(t0+i+5000))
+ print('check query result before restart')
+ tdSql.query('select * from db.t1;')
+ for i in range(insert_rows, insert_rows*2):
+ tdSql.checkData(i, 1, 1)
+
+ self.restart_taosd('db')
+ print('check query result after restart')
+ tdSql.query('select * from db.t1;')
+ for i in range(insert_rows, insert_rows*2):
+ tdSql.checkData(i, 1, 1)
+
+ print("==========step4")
+ print('insert data')
+ for i in range(insert_rows):
+ tdSql.execute('insert into t1 values (%d , 2)' %(t0+i))
+ for i in range(insert_rows):
+ tdSql.execute('insert into t1 values (%d , 1)' %(t0+i+5000))
+
+ print('check query result before restart')
+ tdSql.query('select * from db.t1;')
+ print(tdSql.queryResult)
+ for i in range(insert_rows):
+ tdSql.checkData(i, 1, 2)
+ for i in range(insert_rows, insert_rows*2):
+ tdSql.checkData(i, 1, 1)
+
+ print('check query result after restart')
+ self.restart_taosd('db')
+ tdSql.query('select * from db.t1;')
+ # print(tdSql.queryResult)
+ for i in range(insert_rows):
+ tdSql.checkData(i, 1, 2)
+ for i in range(insert_rows, insert_rows*2):
+ tdSql.checkData(i, 1, 1)
+
+ print("==================================2 start")
+ print("==========step1")
+ print("create table && insert data")
+ tdSql.execute('create table t2 (ts timestamp, a int)')
+ insert_rows = 200
+ t0 = 1603152000000
+ tdLog.info("insert %d rows" % insert_rows)
+ for i in range(insert_rows):
+ tdSql.execute('insert into t2 values (%d , 1)' %(t0+i))
+ print('restart to commit')
+ self.restart_taosd('db')
+ for i in range(insert_rows):
+ tdSql.execute('insert into t2 values (%d , 1)' %(t0+i+5000))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for k in range(10):
+ for i in range(10):
+ tdSql.execute('insert into t2 values (%d , 1)' %(t0 + 200 + k * 10 + i))
+ print('insert into t2 values (%d , 1)' %(t0 + 200 + k * 10 + i))
+
+
+ print("==========step2")
+ print('check query result before restart')
+ tdSql.query('select * from db.t2;')
+ for i in range(insert_rows*2+100):
+ tdSql.checkData(i, 1, 1)
+ # print(tdSql.queryResult)
+ print('restart to commit')
+ self.restart_taosd('db')
+ print('check query result after restart')
+ tdSql.query('select * from db.t2;')
+ for i in range(insert_rows*2+100):
+ tdSql.checkData(i, 1, 1)
+
+
+ print("==================================3 start")
+ print("==========step1")
+ print("create table && insert data")
+ tdSql.execute('create table t3 (ts timestamp, a int)')
+ insert_rows = 200
+ t0 = 1603152000000
+ tdLog.info("insert %d rows" % insert_rows)
+ for i in range(insert_rows):
+ tdSql.execute('insert into t3 values (%d , 1)' %(t0+i))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(insert_rows):
+ tdSql.execute('insert into t3 values (%d , 1)' %(t0+i+5000))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(5200):
+ tdSql.execute('insert into t3 values (%d , 2)' %(t0+i))
+
+ print("==========step2")
+ print('check query result before restart')
+ tdSql.query('select * from db.t3;')
+ for i in range(5200):
+ tdSql.checkData(i, 1, 2)
+ # print(tdSql.queryResult)
+ print('restart to commit')
+ self.restart_taosd('db')
+ print('check query result after restart')
+ tdSql.query('select * from db.t3;')
+ for i in range(5200):
+ tdSql.checkData(i, 1, 2)
+
+ print("==================================4 start")
+ print("==========step1")
+ print("create table && insert data")
+ tdSql.execute('create table t4 (ts timestamp, a int)')
+ insert_rows = 200
+ t0 = 1603152000000
+ tdLog.info("insert %d rows" % insert_rows)
+ for i in range(insert_rows):
+ tdSql.execute('insert into t4 values (%d , 1)' %(t0+i))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(insert_rows):
+ tdSql.execute('insert into t4 values (%d , 1)' %(t0+i+5000))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(100):
+ tdSql.execute('insert into t4 values (%d , 2)' %(t0+i))
+
+ for i in range(200, 5000):
+ tdSql.execute('insert into t4 values (%d , 2)' %(t0+i))
+
+ for i in range(100):
+ tdSql.execute('insert into t4 values (%d , 1)' %(t0+i+5000))
+
+ print('check query result before restart')
+ tdSql.query('select * from db.t4;')
+ for i in range(100):
+ tdSql.checkData(i, 1, 2)
+ for i in range(100, 200):
+ tdSql.checkData(i, 1, 1)
+ for i in range(200, 5000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(5000, 5200):
+ tdSql.checkData(i, 1, 1)
+
+ print('check query result after restart')
+ self.restart_taosd('db')
+ tdSql.query('select * from db.t4;')
+ for i in range(100):
+ tdSql.checkData(i, 1, 2)
+ for i in range(100, 200):
+ tdSql.checkData(i, 1, 1)
+ for i in range(200, 5000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(5000, 5200):
+ tdSql.checkData(i, 1, 1)
+
+ print("==================================5 start")
+ print("==========step1")
+ print("create table && insert data")
+ tdSql.execute('create table t5 (ts timestamp, a int)')
+ insert_rows = 200
+ t0 = 1603152000000
+ tdLog.info("insert %d rows" % insert_rows)
+ for i in range(insert_rows):
+ tdSql.execute('insert into t5 values (%d , 1)' %(t0+i))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(insert_rows):
+ tdSql.execute('insert into t5 values (%d , 1)' %(t0+i+5000))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(100, 200):
+ tdSql.execute('insert into t5 values (%d , 2)' %(t0+i))
+
+ for i in range(200, 5000):
+ tdSql.execute('insert into t5 values (%d , 2)' %(t0+i))
+
+ for i in range(100, 200):
+ tdSql.execute('insert into t5 values (%d , 2)' %(t0+i+5000))
+
+ print('check query result before restart')
+ tdSql.query('select * from db.t5;')
+ for i in range(100):
+ tdSql.checkData(i, 1, 1)
+ for i in range(100, 5000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(5000, 5100):
+ tdSql.checkData(i, 1, 1)
+ for i in range(5100, 5200):
+ tdSql.checkData(i, 1, 2)
+
+ print('check query result after restart')
+ self.restart_taosd('db')
+ tdSql.query('select * from db.t5;')
+ for i in range(100):
+ tdSql.checkData(i, 1, 1)
+ for i in range(100, 5000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(5000, 5100):
+ tdSql.checkData(i, 1, 1)
+ for i in range(5100, 5200):
+ tdSql.checkData(i, 1, 2)
+
+ print("==================================6 start")
+ print("==========step1")
+ print("create table && insert data")
+ tdSql.execute('create table t6 (ts timestamp, a int)')
+ insert_rows = 200
+ t0 = 1603152000000
+ tdLog.info("insert %d rows" % insert_rows)
+ for i in range(insert_rows):
+ tdSql.execute('insert into t6 values (%d , 1)' %(t0+i))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(insert_rows):
+ tdSql.execute('insert into t6 values (%d , 1)' %(t0+i+5000))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(-1000, 10000):
+ tdSql.execute('insert into t6 values (%d , 2)' %(t0+i))
+
+ print('check query result before restart')
+ tdSql.query('select * from db.t6;')
+ tdSql.checkRows(11000)
+ for i in range(11000):
+ tdSql.checkData(i, 1, 2)
+
+ print('check query result after restart')
+ self.restart_taosd('db')
+ tdSql.query('select * from db.t6;')
+ tdSql.checkRows(11000)
+ for i in range(11000):
+ tdSql.checkData(i, 1, 2)
+
+
+ print("==================================7 start")
+ print("==========step1")
+ print("create table && insert data")
+ tdSql.execute('create table t7 (ts timestamp, a int)')
+ insert_rows = 200
+ t0 = 1603152000000
+ tdLog.info("insert %d rows" % insert_rows)
+ for i in range(insert_rows):
+ tdSql.execute('insert into t7 values (%d , 1)' %(t0+i))
+
+ for i in range(insert_rows):
+ tdSql.execute('insert into t7 values (%d , 1)' %(t0+i+5000))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(-1000, 10000):
+ tdSql.execute('insert into t7 values (%d , 2)' %(t0+i))
+
+ print('check query result before restart')
+ tdSql.query('select * from db.t7;')
+ tdSql.checkRows(11000)
+ for i in range(11000):
+ tdSql.checkData(i, 1, 2)
+
+ print('check query result after restart')
+ self.restart_taosd('db')
+ tdSql.query('select * from db.t7;')
+ tdSql.checkRows(11000)
+ for i in range(11000):
+ tdSql.checkData(i, 1, 2)
+
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/update/merge_commit_data2_update0.py b/tests/pytest/update/merge_commit_data2_update0.py
new file mode 100644
index 0000000000..def50e0466
--- /dev/null
+++ b/tests/pytest/update/merge_commit_data2_update0.py
@@ -0,0 +1,384 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.dnodes import *
+import time
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+
+
+ def restart_taosd(self,db):
+ tdDnodes.stop(1)
+ tdDnodes.startWithoutSleep(1)
+ tdSql.execute("use %s;" % db)
+
+ def date_to_timestamp_microseconds(self, date):
+ datetime_obj = datetime.strptime(date, "%Y-%m-%d %H:%M:%S.%f")
+ obj_stamp = int(time.mktime(datetime_obj.timetuple()) * 1000.0 + datetime_obj.microsecond / 1000.0)
+ return obj_stamp
+
+ def timestamp_microseconds_to_date(self, timestamp):
+ d = datetime.datetime.fromtimestamp(timestamp/1000)
+ str1 = d.strftime("%Y-%m-%d %H:%M:%S.%f")
+ return str1
+
+
+
+ def run(self):
+ print("==========step1")
+ print("create table && insert data")
+ sql = 'reset query cache'
+ tdSql.execute(sql)
+ sql = 'drop database if exists db'
+ tdSql.execute(sql)
+ sql = 'create database db update 0 days 30;'
+ tdSql.execute(sql)
+ sql = 'use db;'
+ tdSql.execute(sql)
+ tdSql.execute('create table t1 (ts timestamp, a int)')
+
+
+ print("==================================1 start")
+ insert_rows = 200
+ t0 = 1603152000000
+ tdLog.info("insert %d rows" % insert_rows)
+ for i in range(insert_rows):
+ tdSql.execute('insert into t1 values (%d , 1)' %(t0+i))
+ print("==========step2")
+ print("restart to commit ")
+ self.restart_taosd('db')
+
+ print('check query result after restart')
+ tdSql.query('select * from db.t1;')
+ for i in range(insert_rows):
+ tdSql.checkData(i, 1, 1)
+
+ print("==========step3")
+ print('insert data')
+ for i in range(insert_rows):
+ tdSql.execute('insert into t1 values (%d , 1)' %(t0+i+5000))
+ print('check query result before restart')
+ tdSql.query('select * from db.t1;')
+ for i in range(insert_rows, insert_rows*2):
+ tdSql.checkData(i, 1, 1)
+
+ self.restart_taosd('db')
+ print('check query result after restart')
+ tdSql.query('select * from db.t1;')
+ for i in range(insert_rows, insert_rows*2):
+ tdSql.checkData(i, 1, 1)
+
+ print("==========step4")
+ print('insert data')
+ for i in range(insert_rows):
+ tdSql.execute('insert into t1 values (%d , 2)' %(t0+i))
+ for i in range(insert_rows):
+ tdSql.execute('insert into t1 values (%d , 1)' %(t0+i+5000))
+
+ print('check query result before restart')
+ tdSql.query('select * from db.t1;')
+ print(tdSql.queryResult)
+ for i in range(insert_rows):
+ tdSql.checkData(i, 1, 1)
+ for i in range(insert_rows, insert_rows*2):
+ tdSql.checkData(i, 1, 1)
+
+ print('check query result after restart')
+ self.restart_taosd('db')
+ tdSql.query('select * from db.t1;')
+ # print(tdSql.queryResult)
+ for i in range(insert_rows):
+ tdSql.checkData(i, 1, 1)
+ for i in range(insert_rows, insert_rows*2):
+ tdSql.checkData(i, 1, 1)
+
+ print("==================================2 start")
+ print("==========step1")
+ print("create table && insert data")
+ tdSql.execute('create table t2 (ts timestamp, a int)')
+ insert_rows = 200
+ t0 = 1603152000000
+ tdLog.info("insert %d rows" % insert_rows)
+ for i in range(insert_rows):
+ tdSql.execute('insert into t2 values (%d , 1)' %(t0+i))
+ print('restart to commit')
+ self.restart_taosd('db')
+ for i in range(insert_rows):
+ tdSql.execute('insert into t2 values (%d , 1)' %(t0+i+5000))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for k in range(10):
+ for i in range(10):
+ tdSql.execute('insert into t2 values (%d , 1)' %(t0 + 200 + k * 10 + i))
+ # print('insert into t2 values (%d , 1)' %(t0 + 200 + k * 10 + i))
+
+
+ print("==========step2")
+ print('check query result before restart')
+ tdSql.query('select * from db.t2;')
+ for i in range(insert_rows*2+100):
+ tdSql.checkData(i, 1, 1)
+ # print(tdSql.queryResult)
+ print('restart to commit')
+ self.restart_taosd('db')
+ print('check query result after restart')
+ tdSql.query('select * from db.t2;')
+ for i in range(insert_rows*2+100):
+ tdSql.checkData(i, 1, 1)
+
+
+ print("==================================3 start")
+ print("==========step1")
+ print("create table && insert data")
+ tdSql.execute('create table t3 (ts timestamp, a int)')
+ insert_rows = 200
+ t0 = 1603152000000
+ tdLog.info("insert %d rows" % insert_rows)
+ for i in range(insert_rows):
+ tdSql.execute('insert into t3 values (%d , 1)' %(t0+i))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(insert_rows):
+ tdSql.execute('insert into t3 values (%d , 1)' %(t0+i+5000))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(5200):
+ tdSql.execute('insert into t3 values (%d , 2)' %(t0+i))
+
+ print("==========step2")
+ print('check query result before restart')
+ tdSql.query('select * from db.t3;')
+ for i in range(200):
+ tdSql.checkData(i, 1, 1)
+ for i in range(200, 5000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(5000, 5200):
+ tdSql.checkData(i, 1, 1)
+ # print(tdSql.queryResult)
+ print('restart to commit')
+ self.restart_taosd('db')
+ print('check query result after restart')
+ tdSql.query('select * from db.t3;')
+ for i in range(200):
+ tdSql.checkData(i, 1, 1)
+ for i in range(200, 5000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(5000, 5200):
+ tdSql.checkData(i, 1, 1)
+
+ print("==================================4 start")
+ print("==========step1")
+ print("create table && insert data")
+ tdSql.execute('create table t4 (ts timestamp, a int)')
+ insert_rows = 200
+ t0 = 1603152000000
+ tdLog.info("insert %d rows" % insert_rows)
+ for i in range(insert_rows):
+ tdSql.execute('insert into t4 values (%d , 1)' %(t0+i))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(insert_rows):
+ tdSql.execute('insert into t4 values (%d , 1)' %(t0+i+5000))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(100):
+ tdSql.execute('insert into t4 values (%d , 2)' %(t0+i))
+
+ for i in range(200, 5000):
+ tdSql.execute('insert into t4 values (%d , 2)' %(t0+i))
+
+ for i in range(100):
+ tdSql.execute('insert into t4 values (%d , 1)' %(t0+i+5000))
+
+ print('check query result before restart')
+ tdSql.query('select * from db.t4;')
+ for i in range(200):
+ tdSql.checkData(i, 1, 1)
+ for i in range(200, 5000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(5000, 5200):
+ tdSql.checkData(i, 1, 1)
+
+ print('check query result after restart')
+ self.restart_taosd('db')
+ tdSql.query('select * from db.t4;')
+ for i in range(200):
+ tdSql.checkData(i, 1, 1)
+ for i in range(200, 5000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(5000, 5200):
+ tdSql.checkData(i, 1, 1)
+ #
+ print("==================================5 start")
+ print("==========step1")
+ print("create table && insert data")
+ tdSql.execute('create table t5 (ts timestamp, a int)')
+ insert_rows = 200
+ t0 = 1603152000000
+ tdLog.info("insert %d rows" % insert_rows)
+ for i in range(insert_rows):
+ tdSql.execute('insert into t5 values (%d , 1)' %(t0+i))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(insert_rows):
+ tdSql.execute('insert into t5 values (%d , 1)' %(t0+i+5000))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(100, 200):
+ tdSql.execute('insert into t5 values (%d , 2)' %(t0+i))
+
+ for i in range(200, 5000):
+ tdSql.execute('insert into t5 values (%d , 2)' %(t0+i))
+
+ for i in range(100, 200):
+ tdSql.execute('insert into t5 values (%d , 2)' %(t0+i+5000))
+
+ print('check query result before restart')
+ tdSql.query('select * from db.t5;')
+ for i in range(200):
+ tdSql.checkData(i, 1, 1)
+ for i in range(200, 5000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(5000, 5200):
+ tdSql.checkData(i, 1, 1)
+
+ print('check query result after restart')
+ self.restart_taosd('db')
+ tdSql.query('select * from db.t5;')
+ for i in range(200):
+ tdSql.checkData(i, 1, 1)
+ for i in range(200, 5000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(5000, 5200):
+ tdSql.checkData(i, 1, 1)
+
+ print("==================================6 start")
+ print("==========step1")
+ print("create table && insert data")
+ tdSql.execute('create table t6 (ts timestamp, a int)')
+ insert_rows = 200
+ t0 = 1603152000000
+ tdLog.info("insert %d rows" % insert_rows)
+ for i in range(insert_rows):
+ tdSql.execute('insert into t6 values (%d , 1)' %(t0+i))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(insert_rows):
+ tdSql.execute('insert into t6 values (%d , 1)' %(t0+i+5000))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(-1000, 10000):
+ tdSql.execute('insert into t6 values (%d , 2)' %(t0+i))
+
+ print('check query result before restart')
+ tdSql.query('select * from db.t6;')
+ tdSql.checkRows(11000)
+ for i in range(1000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(1000,1200):
+ tdSql.checkData(i, 1, 1)
+ for i in range(1200,6000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(6000,6200):
+ tdSql.checkData(i, 1, 1)
+ for i in range(6200, 11000):
+ tdSql.checkData(i, 1, 2)
+
+ print('check query result after restart')
+ self.restart_taosd('db')
+ tdSql.query('select * from db.t6;')
+ tdSql.checkRows(11000)
+ for i in range(1000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(1000,1200):
+ tdSql.checkData(i, 1, 1)
+ for i in range(1200,6000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(6000,6200):
+ tdSql.checkData(i, 1, 1)
+ for i in range(6200, 11000):
+ tdSql.checkData(i, 1, 2)
+
+
+ print("==================================7 start")
+ print("==========step1")
+ print("create table && insert data")
+ tdSql.execute('create table t7 (ts timestamp, a int)')
+ insert_rows = 200
+ t0 = 1603152000000
+ tdLog.info("insert %d rows" % insert_rows)
+ for i in range(insert_rows):
+ tdSql.execute('insert into t7 values (%d , 1)' %(t0+i))
+
+ for i in range(insert_rows):
+ tdSql.execute('insert into t7 values (%d , 1)' %(t0+i+5000))
+ print('restart to commit')
+ self.restart_taosd('db')
+
+ for i in range(-1000, 10000):
+ tdSql.execute('insert into t7 values (%d , 2)' %(t0+i))
+
+ print('check query result before restart')
+ tdSql.query('select * from db.t7;')
+ tdSql.checkRows(11000)
+ for i in range(1000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(1000,1200):
+ tdSql.checkData(i, 1, 1)
+ for i in range(1200,6000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(6000,6200):
+ tdSql.checkData(i, 1, 1)
+ for i in range(6200, 11000):
+ tdSql.checkData(i, 1, 2)
+
+ print('check query result after restart')
+ self.restart_taosd('db')
+ tdSql.query('select * from db.t7;')
+ tdSql.checkRows(11000)
+ for i in range(1000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(1000,1200):
+ tdSql.checkData(i, 1, 1)
+ for i in range(1200,6000):
+ tdSql.checkData(i, 1, 2)
+ for i in range(6000,6200):
+ tdSql.checkData(i, 1, 1)
+ for i in range(6200, 11000):
+ tdSql.checkData(i, 1, 2)
+
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/update/merge_commit_last-0.py b/tests/pytest/update/merge_commit_last-0.py
new file mode 100644
index 0000000000..8a247f3809
--- /dev/null
+++ b/tests/pytest/update/merge_commit_last-0.py
@@ -0,0 +1,309 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+import taos
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.dnodes import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor())
+
+ self.ts = 1603152000000
+
+ def restartTaosd(self):
+ tdDnodes.stop(1)
+ tdDnodes.startWithoutSleep(1)
+ tdSql.execute("use db")
+
+ def run(self):
+ tdSql.prepare()
+
+ print("==============step 1: UPDATE THE LAST RECORD REPEATEDLY")
+ tdSql.execute("create table t1 (ts timestamp, a int)")
+
+ for i in range(5):
+ tdSql.execute("insert into t1 values(%d, %d)" % (self.ts, i))
+ self.restartTaosd()
+ tdSql.query("select * from t1")
+ tdSql.checkRows(1)
+ tdSql.checkData(0, 1, 0)
+
+ print("==============step 2: UPDATE THE WHOLE LAST BLOCK")
+ tdSql.execute("create table t2 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t2 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t2")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t2")
+ tdSql.checkData(0, 0, 50)
+
+ for i in range(50):
+ tdSql.execute("insert into t2 values(%d, 2)" % (self.ts + i))
+ tdSql.query("select * from t2")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t2")
+ tdSql.checkData(0, 0, 50)
+
+ self.restartTaosd()
+ tdSql.query("select * from t2")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t2")
+ tdSql.checkData(0, 0, 50)
+
+ print("==============step 3: UPDATE PART OF THE LAST BLOCK")
+ tdSql.execute("create table t3 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t3 values(%d, 1)" % (self.ts + i))
+ self.restartTaosd()
+ tdSql.query("select * from t3")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t3")
+ tdSql.checkData(0, 0, 50)
+
+ for i in range(25):
+ tdSql.execute("insert into t3 values(%d, 2)" % (self.ts + i))
+
+ tdSql.query("select * from t3")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t3")
+ tdSql.checkData(0, 0, 50)
+
+ self.restartTaosd()
+ tdSql.query("select * from t3")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t3")
+ tdSql.checkData(0, 0, 50)
+
+ print("==============step 4: UPDATE AND INSERT APPEND AT END OF DATA")
+ tdSql.execute("create table t4 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t4 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t4")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t4")
+ tdSql.checkData(0, 0, 50)
+
+ for i in range(25):
+ tdSql.execute("insert into t4 values(%d, 2)" % (self.ts + i))
+
+ for i in range(50, 60):
+ tdSql.execute("insert into t4 values(%d, 2)" % (self.ts + i))
+
+ tdSql.query("select * from t4")
+ tdSql.checkRows(60)
+ tdSql.query("select sum(a) from t4")
+ tdSql.checkData(0, 0, 70)
+
+ self.restartTaosd()
+ tdSql.query("select * from t4")
+ tdSql.checkRows(60)
+ tdSql.query("select sum(a) from t4")
+ tdSql.checkData(0, 0, 70)
+
+ print("==============step 5: UPDATE AND INSERT PREPEND SOME DATA")
+ tdSql.execute("create table t5 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t5 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t5")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t5")
+ tdSql.checkData(0, 0, 50)
+
+ for i in range(-10, 0):
+ tdSql.execute("insert into t5 values(%d, 2)" % (self.ts + i))
+
+ for i in range(25):
+ tdSql.execute("insert into t5 values(%d, 2)" % (self.ts + i))
+
+ tdSql.query("select * from t5")
+ tdSql.checkRows(60)
+ tdSql.query("select sum(a) from t5")
+ tdSql.checkData(0, 0, 70)
+
+ self.restartTaosd()
+ tdSql.query("select * from t5")
+ tdSql.checkRows(60)
+ tdSql.query("select sum(a) from t5")
+ tdSql.checkData(0, 0, 70)
+
+ for i in range(-10, 0):
+ tdSql.execute("insert into t5 values(%d, 3)" % (self.ts + i))
+
+ for i in range(25, 50):
+ tdSql.execute("insert into t5 values(%d, 3)" % (self.ts + i))
+
+ tdSql.query("select * from t5")
+ tdSql.checkRows(60)
+ tdSql.query("select sum(a) from t5")
+ tdSql.checkData(0, 0, 70)
+
+ self.restartTaosd()
+ tdSql.query("select * from t5")
+ tdSql.checkRows(60)
+ tdSql.query("select sum(a) from t5")
+ tdSql.checkData(0, 0, 70)
+
+
+ print("==============step 6: INSERT AHEAD A LOT OF DATA")
+ tdSql.execute("create table t6 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t6 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t6")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t6")
+ tdSql.checkData(0, 0, 50)
+
+ for i in range(-1000, 0):
+ tdSql.execute("insert into t6 values(%d, 2)" % (self.ts + i))
+
+ tdSql.query("select * from t6")
+ tdSql.checkRows(1050)
+ tdSql.query("select sum(a) from t6")
+ tdSql.checkData(0, 0, 2050)
+
+ self.restartTaosd()
+ tdSql.query("select * from t6")
+ tdSql.checkRows(1050)
+ tdSql.query("select sum(a) from t6")
+ tdSql.checkData(0, 0, 2050)
+
+ print("==============step 7: INSERT AHEAD A LOT AND UPDATE")
+ tdSql.execute("create table t7 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t7 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t7")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t7")
+ tdSql.checkData(0, 0, 50)
+
+ for i in range(-1000, 25):
+ tdSql.execute("insert into t7 values(%d, 2)" % (self.ts + i))
+
+ tdSql.query("select * from t7")
+ tdSql.checkRows(1050)
+ tdSql.query("select sum(a) from t7")
+ tdSql.checkData(0, 0, 2050)
+
+ self.restartTaosd()
+ tdSql.query("select * from t7")
+ tdSql.checkRows(1050)
+ tdSql.query("select sum(a) from t7")
+ tdSql.checkData(0, 0, 2050)
+
+ print("==============step 8: INSERT AFTER A LOT AND UPDATE")
+ tdSql.execute("create table t8 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t8 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t8")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t8")
+ tdSql.checkData(0, 0, 50)
+
+ for i in range(25, 6000):
+ tdSql.execute("insert into t8 values(%d, 2)" % (self.ts + i))
+
+ tdSql.query("select * from t8")
+ tdSql.checkRows(6000)
+ tdSql.query("select sum(a) from t8")
+ tdSql.checkData(0, 0, 11950)
+
+ self.restartTaosd()
+ tdSql.query("select * from t8")
+ tdSql.checkRows(6000)
+ tdSql.query("select sum(a) from t8")
+ tdSql.checkData(0, 0, 11950)
+
+ print("==============step 9: UPDATE ONLY MIDDLE")
+ tdSql.execute("create table t9 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t9 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t9")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t9")
+ tdSql.checkData(0, 0, 50)
+
+ for i in range(20, 30):
+ tdSql.execute("insert into t9 values(%d, 2)" % (self.ts + i))
+
+ tdSql.query("select * from t9")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t9")
+ tdSql.checkData(0, 0, 50)
+
+ self.restartTaosd()
+ tdSql.query("select * from t9")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t9")
+ tdSql.checkData(0, 0, 50)
+
+ print("==============step 10: A LOT OF DATA COVER THE WHOLE BLOCK")
+ tdSql.execute("create table t10 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t10 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t10")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t10")
+ tdSql.checkData(0, 0, 50)
+
+ for i in range(-4000, 4000):
+ tdSql.execute("insert into t10 values(%d, 2)" % (self.ts + i))
+
+ tdSql.query("select * from t10")
+ tdSql.checkRows(8000)
+ tdSql.query("select sum(a) from t10")
+ tdSql.checkData(0, 0, 15950)
+
+ self.restartTaosd()
+ tdSql.query("select * from t10")
+ tdSql.checkRows(8000)
+ tdSql.query("select sum(a) from t10")
+ tdSql.checkData(0, 0, 15950)
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/update/merge_commit_last.py b/tests/pytest/update/merge_commit_last.py
new file mode 100644
index 0000000000..183cca0a1e
--- /dev/null
+++ b/tests/pytest/update/merge_commit_last.py
@@ -0,0 +1,321 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+import taos
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.dnodes import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor())
+
+ self.ts = 1603152000000
+
+ def restartTaosd(self):
+ tdDnodes.stop(1)
+ tdDnodes.startWithoutSleep(1)
+ tdSql.execute("use udb")
+
+ def run(self):
+ tdSql.prepare()
+
+ tdSql.execute("create database udb update 1 days 30")
+ tdSql.execute("use udb")
+
+ print("==============step 1: UPDATE THE LAST RECORD REPEATEDLY")
+ tdSql.execute("create table t1 (ts timestamp, a int)")
+
+ for i in range(5):
+ tdSql.execute("insert into t1 values(%d, %d)" % (self.ts, i))
+ self.restartTaosd()
+ tdSql.query("select * from t1")
+ tdSql.checkRows(1)
+ tdSql.checkData(0, 1, i)
+
+ print("==============step 2: UPDATE THE WHOLE LAST BLOCK")
+ tdSql.execute("create table t2 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t2 values(%d, 1)" % (self.ts + i))
+ self.restartTaosd()
+ tdSql.query("select * from t2")
+ tdSql.checkRows(50)
+ for i in range(50):
+ tdSql.checkData(i, 1, 1)
+
+ for i in range(50):
+ tdSql.execute("insert into t2 values(%d, 2)" % (self.ts + i))
+ tdSql.query("select * from t2")
+ for i in range(50):
+ tdSql.checkData(i, 1, 2)
+
+ self.restartTaosd()
+ tdSql.query("select * from t2")
+ tdSql.checkRows(50)
+ for i in range(50):
+ tdSql.checkData(i, 1, 2)
+
+ print("==============step 3: UPDATE PART OF THE LAST BLOCK")
+ tdSql.execute("create table t3 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t3 values(%d, 1)" % (self.ts + i))
+ self.restartTaosd()
+ tdSql.query("select * from t3")
+ tdSql.checkRows(50)
+ for i in range(50):
+ tdSql.checkData(i, 1, 1)
+
+ for i in range(25):
+ tdSql.execute("insert into t3 values(%d, 2)" % (self.ts + i))
+
+ tdSql.query("select * from t3")
+ for i in range(25):
+ tdSql.checkData(i, 1, 2)
+ for i in range(25, 50):
+ tdSql.checkData(i, 1, 1)
+
+ self.restartTaosd()
+ tdSql.query("select * from t3")
+ tdSql.checkRows(50)
+ for i in range(25):
+ tdSql.checkData(i, 1, 2)
+ for i in range(25, 50):
+ tdSql.checkData(i, 1, 1)
+
+ print("==============step 4: UPDATE AND INSERT APPEND AT END OF DATA")
+ tdSql.execute("create table t4 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t4 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t4")
+ tdSql.checkRows(50)
+ for i in range(50):
+ tdSql.checkData(i, 1, 1)
+
+ for i in range(25):
+ tdSql.execute("insert into t4 values(%d, 2)" % (self.ts + i))
+
+ for i in range(50, 60):
+ tdSql.execute("insert into t4 values(%d, 2)" % (self.ts + i))
+
+ tdSql.query("select * from t4")
+ tdSql.checkRows(60)
+ for i in range(25):
+ tdSql.checkData(i, 1, 2)
+ for i in range(25, 50):
+ tdSql.checkData(i, 1, 1)
+ for i in range(50, 60):
+ tdSql.checkData(i, 1, 2)
+
+ self.restartTaosd()
+ tdSql.query("select * from t4")
+ tdSql.checkRows(60)
+ for i in range(25):
+ tdSql.checkData(i, 1, 2)
+ for i in range(25, 50):
+ tdSql.checkData(i, 1, 1)
+ for i in range(50, 60):
+ tdSql.checkData(i, 1, 2)
+
+ print("==============step 5: UPDATE AND INSERT PREPEND SOME DATA")
+ tdSql.execute("create table t5 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t5 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t5")
+ tdSql.checkRows(50)
+ for i in range(50):
+ tdSql.checkData(i, 1, 1)
+
+ for i in range(-10, 0):
+ tdSql.execute("insert into t5 values(%d, 2)" % (self.ts + i))
+
+ for i in range(25):
+ tdSql.execute("insert into t5 values(%d, 2)" % (self.ts + i))
+
+ tdSql.query("select * from t5")
+ tdSql.checkRows(60)
+ tdSql.query("select sum(a) from t5")
+ tdSql.checkData(0, 0, 95)
+
+ self.restartTaosd()
+ tdSql.query("select * from t5")
+ tdSql.checkRows(60)
+ tdSql.query("select sum(a) from t5")
+ tdSql.checkData(0, 0, 95)
+
+ for i in range(-10, 0):
+ tdSql.execute("insert into t5 values(%d, 3)" % (self.ts + i))
+
+ for i in range(25, 50):
+ tdSql.execute("insert into t5 values(%d, 3)" % (self.ts + i))
+
+ tdSql.query("select * from t5")
+ tdSql.checkRows(60)
+ tdSql.query("select sum(a) from t5")
+ tdSql.checkData(0, 0, 155)
+
+ self.restartTaosd()
+ tdSql.query("select * from t5")
+ tdSql.checkRows(60)
+ tdSql.query("select sum(a) from t5")
+ tdSql.checkData(0, 0, 155)
+
+
+ print("==============step 6: INSERT AHEAD A LOT OF DATA")
+ tdSql.execute("create table t6 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t6 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t6")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t6")
+ tdSql.checkData(0, 0, 50)
+
+ for i in range(-1000, 0):
+ tdSql.execute("insert into t6 values(%d, 2)" % (self.ts + i))
+
+ tdSql.query("select * from t6")
+ tdSql.checkRows(1050)
+ tdSql.query("select sum(a) from t6")
+ tdSql.checkData(0, 0, 2050)
+
+ self.restartTaosd()
+ tdSql.query("select * from t6")
+ tdSql.checkRows(1050)
+ tdSql.query("select sum(a) from t6")
+ tdSql.checkData(0, 0, 2050)
+
+ print("==============step 7: INSERT AHEAD A LOT AND UPDATE")
+ tdSql.execute("create table t7 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t7 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t7")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t7")
+ tdSql.checkData(0, 0, 50)
+
+ for i in range(-1000, 25):
+ tdSql.execute("insert into t7 values(%d, 2)" % (self.ts + i))
+
+ tdSql.query("select * from t7")
+ tdSql.checkRows(1050)
+ tdSql.query("select sum(a) from t7")
+ tdSql.checkData(0, 0, 2075)
+
+ self.restartTaosd()
+ tdSql.query("select * from t7")
+ tdSql.checkRows(1050)
+ tdSql.query("select sum(a) from t7")
+ tdSql.checkData(0, 0, 2075)
+
+ print("==============step 8: INSERT AFTER A LOT AND UPDATE")
+ tdSql.execute("create table t8 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t8 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t8")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t8")
+ tdSql.checkData(0, 0, 50)
+
+ for i in range(25, 6000):
+ tdSql.execute("insert into t8 values(%d, 2)" % (self.ts + i))
+
+ tdSql.query("select * from t8")
+ tdSql.checkRows(6000)
+ tdSql.query("select sum(a) from t8")
+ tdSql.checkData(0, 0, 11975)
+
+ self.restartTaosd()
+ tdSql.query("select * from t8")
+ tdSql.checkRows(6000)
+ tdSql.query("select sum(a) from t8")
+ tdSql.checkData(0, 0, 11975)
+
+ print("==============step 9: UPDATE ONLY MIDDLE")
+ tdSql.execute("create table t9 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t9 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t9")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t9")
+ tdSql.checkData(0, 0, 50)
+
+ for i in range(20, 30):
+ tdSql.execute("insert into t9 values(%d, 2)" % (self.ts + i))
+
+ tdSql.query("select * from t9")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t9")
+ tdSql.checkData(0, 0, 60)
+
+ self.restartTaosd()
+ tdSql.query("select * from t9")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t9")
+ tdSql.checkData(0, 0, 60)
+
+ print("==============step 10: A LOT OF DATA COVER THE WHOLE BLOCK")
+ tdSql.execute("create table t10 (ts timestamp, a int)")
+
+ for i in range(50):
+ tdSql.execute("insert into t10 values(%d, 1)" % (self.ts + i))
+
+ self.restartTaosd()
+ tdSql.query("select * from t10")
+ tdSql.checkRows(50)
+ tdSql.query("select sum(a) from t10")
+ tdSql.checkData(0, 0, 50)
+
+ for i in range(-4000, 4000):
+ tdSql.execute("insert into t10 values(%d, 2)" % (self.ts + i))
+
+ tdSql.query("select * from t10")
+ tdSql.checkRows(8000)
+ tdSql.query("select sum(a) from t10")
+ tdSql.checkData(0, 0, 16000)
+
+ self.restartTaosd()
+ tdSql.query("select * from t10")
+ tdSql.checkRows(8000)
+ tdSql.query("select sum(a) from t10")
+ tdSql.checkData(0, 0, 16000)
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/updatetest.sh b/tests/pytest/updatetest.sh
new file mode 100644
index 0000000000..ade1180553
--- /dev/null
+++ b/tests/pytest/updatetest.sh
@@ -0,0 +1,10 @@
+# update
+python3 ./test.py -f update/allow_update.py
+python3 ./test.py -f update/allow_update-0.py
+python3 ./test.py -f update/append_commit_data.py
+python3 ./test.py -f update/append_commit_last-0.py
+python3 ./test.py -f update/append_commit_last.py
+python3 ./test.py -f update/merge_commit_data.py
+python3 ./test.py -f update/merge_commit_data2.py
+python3 ./test.py -f update/merge_commit_last-0.py
+python3 ./test.py -f update/merge_commit_last.py
\ No newline at end of file
diff --git a/tests/script/general/http/restful_full.sim b/tests/script/general/http/restful_full.sim
index 8d2f1a7c00..94ecb59f75 100644
--- a/tests/script/general/http/restful_full.sim
+++ b/tests/script/general/http/restful_full.sim
@@ -81,7 +81,7 @@ print =============== step2 - no db
#11
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/rest/sql
print 11-> $system_content
-if $system_content != @{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep1,keep2,keep(D)","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","precision","status"],"data":[],"rows":0}@ then
+if $system_content != @{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep1,keep2,keep(D)","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","precision","update","status"],"data":[],"rows":0}@ then
return -1
endi