Merge remote-tracking branch 'origin/3.0' into feat/TD-27337
This commit is contained in:
commit
b688f328d1
|
@ -49,7 +49,7 @@ TDengine ODBC driver supports two kinds of connections to TDengine cluster, nati
|
|||
|
||||
4.2 [Connection Type]: required field, we choose "WebSocket"
|
||||
|
||||
4.3 [URL]: required field, the URL for the ODBC data source, for example, `http://localhost:6041` is the URL for a local TDengine cluster, `https://gw.cloud.taosdata.com?token=your_token` is the URL for a TDengine cloud service.
|
||||
4.3 [URL]: required field, the URL for the ODBC data source, for example, `http://localhost:6041` is the URL for a local TDengine cluster.
|
||||
|
||||
4.4 [Database]: optional field, the default database to access
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ If you want to start your application in a container, you need to add the corres
|
|||
FROM ubuntu:20.04
|
||||
RUN apt-get update && apt-get install -y wget
|
||||
ENV TDENGINE_VERSION=3.0.0.0
|
||||
RUN wget -c https://www.taosdata.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
RUN wget -c https://tdengine.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
&& tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
&& cd TDengine-client-${TDENGINE_VERSION} \
|
||||
&& ./install_client.sh \
|
||||
|
@ -229,7 +229,7 @@ Here is the full Dockerfile:
|
|||
```docker
|
||||
FROM golang:1.17.6-buster as builder
|
||||
ENV TDENGINE_VERSION=3.0.0.0
|
||||
RUN wget -c https://www.taosdata.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
RUN wget -c https://tdengine.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
&& tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
&& cd TDengine-client-${TDENGINE_VERSION} \
|
||||
&& ./install_client.sh \
|
||||
|
@ -245,7 +245,7 @@ RUN go build
|
|||
FROM ubuntu:20.04
|
||||
RUN apt-get update && apt-get install -y wget
|
||||
ENV TDENGINE_VERSION=3.0.0.0
|
||||
RUN wget -c https://www.taosdata.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
RUN wget -c https://tdengine.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
&& tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
|
||||
&& cd TDengine-client-${TDENGINE_VERSION} \
|
||||
&& ./install_client.sh \
|
||||
|
|
|
@ -8,7 +8,7 @@ description: This document describes how to deploy TDengine on Kubernetes.
|
|||
|
||||
As a time series database for Cloud Native architecture design, TDengine supports Kubernetes deployment. Firstly we introduce how to use YAML files to create a highly available TDengine cluster from scratch step by step for production usage, and highlight the common operations of TDengine in Kubernetes environment.
|
||||
|
||||
To meet [high availability ](https://docs.taosdata.com/tdinternal/high-availability/)requirements, clusters need to meet the following requirements:
|
||||
To meet [high availability](../../tdinternal/high-availability/) requirements, clusters need to meet the following requirements:
|
||||
|
||||
- 3 or more dnodes: multiple vnodes in the same vgroup of TDengine are not allowed to be distributed in one dnode at the same time, so if you create a database with 3 replicas, the number of dnodes is greater than or equal to 3
|
||||
- 3 mnodes: mnode is responsible for the management of the entire TDengine cluster. The default number of mnode in TDengine cluster is only one. If the dnode where the mnode located is dropped, the entire cluster is unavailable.
|
||||
|
|
|
@ -19,7 +19,7 @@ Users should not use taosdump to back up raw data, environment settings, hardwar
|
|||
|
||||
There are two ways to install taosdump:
|
||||
|
||||
- Install the taosTools official installer. Please find taosTools from [Release History](https://docs.taosdata.com/releases/tools/) page and download and install it.
|
||||
- Install the taosTools official installer. Please find taosTools from [Release History](../../releases/tools/) page and download and install it.
|
||||
|
||||
- Compile taos-tools separately and install it. Please refer to the [taos-tools](https://github.com/taosdata/taos-tools) repository for details.
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ With TDengine ODBC driver, PowerBI can access time series data stored in TDengin
|
|||
|
||||
## Install Driver
|
||||
|
||||
Depending on your TDengine server version, download appropriate version of TDengine client package from TDengine website [Download Link](https://docs.taosdata.com/get-started/package/), or TDengine explorer if you are using a local TDengine cluster. Install the TDengine client package on same Windows machine where PowerBI is running.
|
||||
Depending on your TDengine server version, download appropriate version of TDengine client package from TDengine website [Download Link](../../get-started/package/), or TDengine explorer if you are using a local TDengine cluster. Install the TDengine client package on same Windows machine where PowerBI is running.
|
||||
|
||||
### Configure Data Source
|
||||
|
||||
|
@ -38,7 +38,7 @@ To better use Power BI to analyze the data stored in TDengine, you need to under
|
|||
|
||||
1. Dimention: it's normally category (text) data to describe such information as device, collection point, model. In the supertable template of TDengine, we use tag columns to store the dimention information. You can use SQL like `select distinct tbname, tag1, tag2 from supertable` to get dimentions.
|
||||
|
||||
2. Metric: quantitive (numeric) fileds that can be calculated, like SUM, AVERAGE, MINIMUM. If the collecting frequency is 1 second, then there are 31,536,000 records in one year, it will be too low efficient to import so big data into Power BI. In TDengine, you can use data partition query, window partition query, in combination with pseudo columns related to window, to import downsampled data into Power BI. For more details, please refer to [TDengine Specialized Queries](https://docs.taosdata.com/taos-sql/distinguished/)。
|
||||
2. Metric: quantitive (numeric) fileds that can be calculated, like SUM, AVERAGE, MINIMUM. If the collecting frequency is 1 second, then there are 31,536,000 records in one year, it will be too low efficient to import so big data into Power BI. In TDengine, you can use data partition query, window partition query, in combination with pseudo columns related to window, to import downsampled data into Power BI. For more details, please refer to [TDengine Specialized Queries](../../taos-sql/distinguished/)。
|
||||
|
||||
- Window partition query: for example, thermal meters collect one data per second, but you need to query the average temperature every 10 minutes, you can use window subclause to get the downsampling data you need. The corresponding SQL is like `select tbname, _wstart date,avg(temperature) temp from table interval(10m)`, in which _wstart is a pseudo column indicting the start time of a widow, 10m is the duration of the window, `avg(temperature)` indicates the aggregate value inside a window.
|
||||
|
||||
|
|
|
@ -184,8 +184,6 @@ TDengine supports the standard JDBC 3.0 interface for manipulating databases, bu
|
|||
|
||||
To facilitate historical data migration, we provide a plug-in for the data synchronization tool DataX, which can automatically write data into TDengine.The automatic data migration of DataX can only support the data migration process of a single value model.
|
||||
|
||||
For the specific usage of DataX and how to use DataX to write data to TDengine, please refer to [DataX-based TDengine Data Migration Tool](https://www.taosdata.com/engineering/16401.html).
|
||||
|
||||
After migrating via DataX, we found that we can significantly improve the efficiency of migrating historical data by starting multiple processes and migrating numerous metrics simultaneously. The following are some records of the migration process. We provide these as a reference for application migration.
|
||||
|
||||
| Number of datax instances (number of concurrent processes) | Migration record speed (pieces/second) |
|
||||
|
|
|
@ -6,7 +6,7 @@ description: This document provides download links for all released versions of
|
|||
|
||||
taosTools installation packages can be downloaded at the following links:
|
||||
|
||||
For other historical version installers, please visit [here](https://www.taosdata.com/all-downloads).
|
||||
For other historical version installers, please visit [here](https://tdengine.com/downloads/historical/).
|
||||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
|
|
|
@ -238,12 +238,12 @@ typedef struct SStoreSnapshotFn {
|
|||
} SStoreSnapshotFn;
|
||||
|
||||
typedef struct SStoreMeta {
|
||||
SMTbCursor* (*openTableMetaCursor)(void* pVnode); // metaOpenTbCursor
|
||||
void (*closeTableMetaCursor)(SMTbCursor* pTbCur); // metaCloseTbCursor
|
||||
void (*pauseTableMetaCursor)(SMTbCursor* pTbCur); // metaPauseTbCursor
|
||||
void (*resumeTableMetaCursor)(SMTbCursor* pTbCur, int8_t first); // metaResumeTbCursor
|
||||
int32_t (*cursorNext)(SMTbCursor* pTbCur, ETableType jumpTableType); // metaTbCursorNext
|
||||
int32_t (*cursorPrev)(SMTbCursor* pTbCur, ETableType jumpTableType); // metaTbCursorPrev
|
||||
SMTbCursor* (*openTableMetaCursor)(void* pVnode); // metaOpenTbCursor
|
||||
void (*closeTableMetaCursor)(SMTbCursor* pTbCur); // metaCloseTbCursor
|
||||
void (*pauseTableMetaCursor)(SMTbCursor* pTbCur); // metaPauseTbCursor
|
||||
void (*resumeTableMetaCursor)(SMTbCursor* pTbCur, int8_t first, int8_t move); // metaResumeTbCursor
|
||||
int32_t (*cursorNext)(SMTbCursor* pTbCur, ETableType jumpTableType); // metaTbCursorNext
|
||||
int32_t (*cursorPrev)(SMTbCursor* pTbCur, ETableType jumpTableType); // metaTbCursorPrev
|
||||
|
||||
int32_t (*getTableTags)(void* pVnode, uint64_t suid, SArray* uidList);
|
||||
int32_t (*getTableTagsByUid)(void* pVnode, int64_t suid, SArray* uidList);
|
||||
|
|
|
@ -537,15 +537,25 @@ static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq) {
|
|||
|
||||
bool member0IsTimeout = mndCheckArbMemberHbTimeout(&arbGroupDup, 0, nowMs);
|
||||
bool member1IsTimeout = mndCheckArbMemberHbTimeout(&arbGroupDup, 1, nowMs);
|
||||
int32_t currentAssignedDnodeId = arbGroupDup.assignedLeader.dnodeId;
|
||||
SArbAssignedLeader* pAssignedLeader = &arbGroupDup.assignedLeader;
|
||||
int32_t currentAssignedDnodeId = pAssignedLeader->dnodeId;
|
||||
|
||||
// 1. both of the two members are timeout => skip
|
||||
// 1. has assigned && is sync => send req
|
||||
if (currentAssignedDnodeId != 0 && arbGroupDup.isSync == true) {
|
||||
(void)mndSendArbSetAssignedLeaderReq(pMnode, currentAssignedDnodeId, vgId, arbToken, term,
|
||||
pAssignedLeader->token);
|
||||
mInfo("vgId:%d, arb send set assigned leader to dnodeId:%d", vgId, currentAssignedDnodeId);
|
||||
sdbRelease(pSdb, pArbGroup);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 2. both of the two members are timeout => skip
|
||||
if (member0IsTimeout && member1IsTimeout) {
|
||||
sdbRelease(pSdb, pArbGroup);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 2. no member is timeout => check sync
|
||||
// 3. no member is timeout => check sync
|
||||
if (member0IsTimeout == false && member1IsTimeout == false) {
|
||||
// no assigned leader and not sync
|
||||
if (currentAssignedDnodeId == 0 && !arbGroupDup.isSync) {
|
||||
|
@ -556,7 +566,7 @@ static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq) {
|
|||
continue;
|
||||
}
|
||||
|
||||
// 3. one of the members is timeout => set assigned leader
|
||||
// 4. one of the members is timeout => set assigned leader
|
||||
int32_t candidateIndex = member0IsTimeout ? 1 : 0;
|
||||
SArbGroupMember *pMember = &arbGroupDup.members[candidateIndex];
|
||||
|
||||
|
@ -581,26 +591,18 @@ static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq) {
|
|||
continue;
|
||||
}
|
||||
|
||||
// no assigned leader => write to sdb
|
||||
if (currentAssignedDnodeId == 0) {
|
||||
SArbGroup newGroup = {0};
|
||||
mndArbGroupDupObj(&arbGroupDup, &newGroup);
|
||||
mndArbGroupSetAssignedLeader(&newGroup, candidateIndex);
|
||||
if (mndPullupArbUpdateGroup(pMnode, &newGroup) != 0) {
|
||||
mError("vgId:%d, arb failed to pullup set assigned leader to dnodeId:%d, since %s", vgId, pMember->info.dnodeId,
|
||||
terrstr());
|
||||
sdbRelease(pSdb, pArbGroup);
|
||||
return -1;
|
||||
}
|
||||
|
||||
mInfo("vgId:%d, arb pull up set assigned leader to dnodeId:%d", vgId, pMember->info.dnodeId);
|
||||
// is sync && no assigned leader => write to sdb
|
||||
SArbGroup newGroup = {0};
|
||||
mndArbGroupDupObj(&arbGroupDup, &newGroup);
|
||||
mndArbGroupSetAssignedLeader(&newGroup, candidateIndex);
|
||||
if (mndPullupArbUpdateGroup(pMnode, &newGroup) != 0) {
|
||||
mError("vgId:%d, arb failed to pullup set assigned leader to dnodeId:%d, since %s", vgId, pMember->info.dnodeId,
|
||||
terrstr());
|
||||
sdbRelease(pSdb, pArbGroup);
|
||||
continue;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// isSync == true && dnodeId match => send request to dnode
|
||||
(void)mndSendArbSetAssignedLeaderReq(pMnode, pMember->info.dnodeId, vgId, arbToken, term, pMember->state.token);
|
||||
mInfo("vgId:%d, arb send set assigned leader to dnodeId:%d", vgId, pMember->info.dnodeId);
|
||||
mInfo("vgId:%d, arb pull up set assigned leader to dnodeId:%d", vgId, pMember->info.dnodeId);
|
||||
|
||||
sdbRelease(pSdb, pArbGroup);
|
||||
}
|
||||
|
@ -1055,13 +1057,21 @@ static int32_t mndRetrieveArbGroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
|||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->isSync, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->assignedLeader.dnodeId, false);
|
||||
if (pGroup->assignedLeader.dnodeId != 0) {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->assignedLeader.dnodeId, false);
|
||||
|
||||
char token[TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(token, pGroup->assignedLeader.token, TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)token, false);
|
||||
char token[TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(token, pGroup->assignedLeader.token, TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)token, false);
|
||||
} else {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetNULL(pColInfo, numOfRows);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetNULL(pColInfo, numOfRows);
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&pGroup->mutex);
|
||||
|
||||
|
|
|
@ -397,11 +397,11 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
|
|||
if (pCfg->precision < TSDB_MIN_PRECISION && pCfg->precision > TSDB_MAX_PRECISION) return -1;
|
||||
if (pCfg->compression < TSDB_MIN_COMP_LEVEL || pCfg->compression > TSDB_MAX_COMP_LEVEL) return -1;
|
||||
if (pCfg->replications < TSDB_MIN_DB_REPLICA || pCfg->replications > TSDB_MAX_DB_REPLICA) return -1;
|
||||
#ifdef TD_ENTERPRISE
|
||||
#ifdef TD_ENTERPRISE
|
||||
if ((pCfg->replications == 2) ^ (pCfg->withArbitrator == TSDB_MAX_DB_WITH_ARBITRATOR)) return -1;
|
||||
#else
|
||||
#else
|
||||
if (pCfg->replications != 1 && pCfg->replications != 3) return -1;
|
||||
#endif
|
||||
#endif
|
||||
if (pCfg->strict < TSDB_DB_STRICT_OFF || pCfg->strict > TSDB_DB_STRICT_ON) return -1;
|
||||
if (pCfg->schemaless < TSDB_DB_SCHEMALESS_OFF || pCfg->schemaless > TSDB_DB_SCHEMALESS_ON) return -1;
|
||||
if (pCfg->cacheLast < TSDB_CACHE_MODEL_NONE || pCfg->cacheLast > TSDB_CACHE_MODEL_BOTH) return -1;
|
||||
|
@ -438,13 +438,14 @@ static int32_t mndCheckInChangeDbCfg(SMnode *pMnode, SDbCfg *pOldCfg, SDbCfg *pN
|
|||
if (pNewCfg->daysToKeep0 < pNewCfg->daysPerFile) return -1;
|
||||
if (pNewCfg->daysToKeep0 > pNewCfg->daysToKeep1) return -1;
|
||||
if (pNewCfg->daysToKeep1 > pNewCfg->daysToKeep2) return -1;
|
||||
if (pNewCfg->keepTimeOffset < TSDB_MIN_KEEP_TIME_OFFSET || pNewCfg->keepTimeOffset > TSDB_MAX_KEEP_TIME_OFFSET) return -1;
|
||||
if (pNewCfg->keepTimeOffset < TSDB_MIN_KEEP_TIME_OFFSET || pNewCfg->keepTimeOffset > TSDB_MAX_KEEP_TIME_OFFSET)
|
||||
return -1;
|
||||
if (pNewCfg->walFsyncPeriod < TSDB_MIN_FSYNC_PERIOD || pNewCfg->walFsyncPeriod > TSDB_MAX_FSYNC_PERIOD) return -1;
|
||||
if (pNewCfg->walLevel < TSDB_MIN_WAL_LEVEL || pNewCfg->walLevel > TSDB_MAX_WAL_LEVEL) return -1;
|
||||
if (pNewCfg->cacheLast < TSDB_CACHE_MODEL_NONE || pNewCfg->cacheLast > TSDB_CACHE_MODEL_BOTH) return -1;
|
||||
if (pNewCfg->cacheLastSize < TSDB_MIN_DB_CACHE_SIZE || pNewCfg->cacheLastSize > TSDB_MAX_DB_CACHE_SIZE) return -1;
|
||||
if (pNewCfg->replications < TSDB_MIN_DB_REPLICA || pNewCfg->replications > TSDB_MAX_DB_REPLICA) return -1;
|
||||
#ifdef TD_ENTERPRISE
|
||||
#ifdef TD_ENTERPRISE
|
||||
if ((pNewCfg->replications == 2) ^ (pNewCfg->withArbitrator == TSDB_MAX_DB_WITH_ARBITRATOR)) return -1;
|
||||
if (pNewCfg->replications == 2 && pNewCfg->withArbitrator == TSDB_MAX_DB_WITH_ARBITRATOR) {
|
||||
if (pOldCfg->replications != 1 && pOldCfg->replications != 2) {
|
||||
|
@ -452,9 +453,13 @@ static int32_t mndCheckInChangeDbCfg(SMnode *pMnode, SDbCfg *pOldCfg, SDbCfg *pN
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (pNewCfg->replications != 2 && pOldCfg->replications == 2) {
|
||||
terrno = TSDB_CODE_OPS_NOT_SUPPORT;
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
if (pNewCfg->replications != 1 && pNewCfg->replications != 3) return -1;
|
||||
#endif
|
||||
#endif
|
||||
if (pNewCfg->sstTrigger < TSDB_MIN_STT_TRIGGER || pNewCfg->sstTrigger > TSDB_MAX_STT_TRIGGER) return -1;
|
||||
if (pNewCfg->minRows < TSDB_MIN_MINROWS_FBLOCK || pNewCfg->minRows > TSDB_MAX_MINROWS_FBLOCK) return -1;
|
||||
if (pNewCfg->maxRows < TSDB_MIN_MAXROWS_FBLOCK || pNewCfg->maxRows > TSDB_MAX_MAXROWS_FBLOCK) return -1;
|
||||
|
@ -940,7 +945,7 @@ static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) {
|
|||
terrno = 0;
|
||||
}
|
||||
|
||||
if (pAlter->withArbitrator != pDb->cfg.withArbitrator) {
|
||||
if (pAlter->withArbitrator >= TSDB_MIN_DB_WITH_ARBITRATOR && pAlter->withArbitrator != pDb->cfg.withArbitrator) {
|
||||
pDb->cfg.withArbitrator = pAlter->withArbitrator;
|
||||
pDb->vgVersion++;
|
||||
terrno = 0;
|
||||
|
|
|
@ -136,7 +136,7 @@ typedef SVCreateTSmaReq SSmaCfg;
|
|||
SMTbCursor* metaOpenTbCursor(void* pVnode);
|
||||
void metaCloseTbCursor(SMTbCursor* pTbCur);
|
||||
void metaPauseTbCursor(SMTbCursor* pTbCur);
|
||||
void metaResumeTbCursor(SMTbCursor* pTbCur, int8_t first);
|
||||
void metaResumeTbCursor(SMTbCursor* pTbCur, int8_t first, int8_t move);
|
||||
int32_t metaTbCursorNext(SMTbCursor* pTbCur, ETableType jumpTableType);
|
||||
int32_t metaTbCursorPrev(SMTbCursor* pTbCur, ETableType jumpTableType);
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ SMTbCursor *metaOpenTbCursor(void *pVnode) {
|
|||
// tdbTbcMoveToFirst((TBC *)pTbCur->pDbc);
|
||||
pTbCur->pMeta = pVnodeObj->pMeta;
|
||||
pTbCur->paused = 1;
|
||||
metaResumeTbCursor(pTbCur, 1);
|
||||
metaResumeTbCursor(pTbCur, 1, 0);
|
||||
return pTbCur;
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,7 @@ void metaPauseTbCursor(SMTbCursor *pTbCur) {
|
|||
pTbCur->paused = 1;
|
||||
}
|
||||
}
|
||||
void metaResumeTbCursor(SMTbCursor *pTbCur, int8_t first) {
|
||||
void metaResumeTbCursor(SMTbCursor *pTbCur, int8_t first, int8_t move) {
|
||||
if (pTbCur->paused) {
|
||||
metaReaderDoInit(&pTbCur->mr, pTbCur->pMeta, META_READER_LOCK);
|
||||
|
||||
|
@ -282,9 +282,11 @@ void metaResumeTbCursor(SMTbCursor *pTbCur, int8_t first) {
|
|||
if (first) {
|
||||
tdbTbcMoveToFirst((TBC *)pTbCur->pDbc);
|
||||
} else {
|
||||
int c = 0;
|
||||
int c = 1;
|
||||
tdbTbcMoveTo(pTbCur->pDbc, pTbCur->pKey, pTbCur->kLen, &c);
|
||||
if (c < 0) {
|
||||
if (c == 0) {
|
||||
if (move) tdbTbcMoveToNext(pTbCur->pDbc);
|
||||
} else if (c < 0) {
|
||||
tdbTbcMoveToPrev(pTbCur->pDbc);
|
||||
} else {
|
||||
tdbTbcMoveToNext(pTbCur->pDbc);
|
||||
|
|
|
@ -642,8 +642,8 @@ SColVal *tsdbRowIterNext(STSDBRowIter *pIter) {
|
|||
return &pIter->cv;
|
||||
}
|
||||
|
||||
if (pIter->iColData < pIter->pRow->pBlockData->nColData) {
|
||||
tColDataGetValue(&pIter->pRow->pBlockData->aColData[pIter->iColData], pIter->pRow->iRow, &pIter->cv);
|
||||
if (pIter->iColData <= pIter->pRow->pBlockData->nColData) {
|
||||
tColDataGetValue(&pIter->pRow->pBlockData->aColData[pIter->iColData - 1], pIter->pRow->iRow, &pIter->cv);
|
||||
++pIter->iColData;
|
||||
return &pIter->cv;
|
||||
} else {
|
||||
|
|
|
@ -433,95 +433,113 @@ static bool sysTableIsCondOnOneTable(SNode* pCond, char* condTable) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
SStorageAPI* pAPI = &pTaskInfo->storageAPI;
|
||||
|
||||
static SSDataBlock* doOptimizeTableNameFilter(SOperatorInfo* pOperator, SSDataBlock* dataBlock, char* dbname) {
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
SStorageAPI* pAPI = &pTaskInfo->storageAPI;
|
||||
SSysTableScanInfo* pInfo = pOperator->info;
|
||||
if (pOperator->status == OP_EXEC_DONE) {
|
||||
int32_t numOfRows = 0;
|
||||
|
||||
char tableName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(tableName, pInfo->req.filterTb);
|
||||
|
||||
SMetaReader smrTable = {0};
|
||||
pAPI->metaReaderFn.initReader(&smrTable, pInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn);
|
||||
int32_t code = pAPI->metaReaderFn.getTableEntryByName(&smrTable, pInfo->req.filterTb);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
// terrno has been set by pAPI->metaReaderFn.getTableEntryByName, therefore, return directly
|
||||
pAPI->metaReaderFn.clearReader(&smrTable);
|
||||
pInfo->loadInfo.totalRows = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
blockDataCleanup(pInfo->pRes);
|
||||
int32_t numOfRows = 0;
|
||||
if (smrTable.me.type == TSDB_SUPER_TABLE) {
|
||||
pAPI->metaReaderFn.clearReader(&smrTable);
|
||||
pInfo->loadInfo.totalRows = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SSDataBlock* dataBlock = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_COLS);
|
||||
blockDataEnsureCapacity(dataBlock, pOperator->resultInfo.capacity);
|
||||
if (smrTable.me.type == TSDB_CHILD_TABLE) {
|
||||
int64_t suid = smrTable.me.ctbEntry.suid;
|
||||
pAPI->metaReaderFn.clearReader(&smrTable);
|
||||
pAPI->metaReaderFn.initReader(&smrTable, pInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn);
|
||||
code = pAPI->metaReaderFn.getTableEntryByUid(&smrTable, suid);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
// terrno has been set by pAPI->metaReaderFn.getTableEntryByName, therefore, return directly
|
||||
pAPI->metaReaderFn.clearReader(&smrTable);
|
||||
pInfo->loadInfo.totalRows = 0;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
char typeName[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
SSchemaWrapper* schemaRow = NULL;
|
||||
if (smrTable.me.type == TSDB_SUPER_TABLE) {
|
||||
schemaRow = &smrTable.me.stbEntry.schemaRow;
|
||||
STR_TO_VARSTR(typeName, "CHILD_TABLE");
|
||||
} else if (smrTable.me.type == TSDB_NORMAL_TABLE) {
|
||||
schemaRow = &smrTable.me.ntbEntry.schemaRow;
|
||||
STR_TO_VARSTR(typeName, "NORMAL_TABLE");
|
||||
}
|
||||
|
||||
sysTableUserColsFillOneTableCols(pInfo, dbname, &numOfRows, dataBlock, tableName, schemaRow, typeName);
|
||||
pAPI->metaReaderFn.clearReader(&smrTable);
|
||||
|
||||
if (numOfRows > 0) {
|
||||
relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock, pOperator->exprSupp.pFilterInfo);
|
||||
numOfRows = 0;
|
||||
}
|
||||
|
||||
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
||||
setOperatorCompleted(pOperator);
|
||||
|
||||
qDebug("get cols success, total rows:%" PRIu64 ", current:%" PRId64 " %s", pInfo->loadInfo.totalRows,
|
||||
pInfo->pRes->info.rows, GET_TASKID(pTaskInfo));
|
||||
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
||||
}
|
||||
|
||||
int32_t doExtractDbName(char* dbname, SSysTableScanInfo* pInfo, SStorageAPI* pAPI) {
|
||||
SName sn = {0};
|
||||
const char* db = NULL;
|
||||
int32_t vgId = 0;
|
||||
pAPI->metaFn.getBasicInfo(pInfo->readHandle.vnode, &db, &vgId, NULL, NULL);
|
||||
|
||||
SName sn = {0};
|
||||
char dbname[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
tNameFromString(&sn, db, T_NAME_ACCT | T_NAME_DB);
|
||||
|
||||
tNameGetDbName(&sn, varDataVal(dbname));
|
||||
varDataSetLen(dbname, strlen(varDataVal(dbname)));
|
||||
|
||||
// optimize when sql like where table_name='tablename' and xxx.
|
||||
if (pInfo->req.filterTb[0]) {
|
||||
char tableName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(tableName, pInfo->req.filterTb);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SMetaReader smrTable = {0};
|
||||
pAPI->metaReaderFn.initReader(&smrTable, pInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn);
|
||||
int32_t code = pAPI->metaReaderFn.getTableEntryByName(&smrTable, pInfo->req.filterTb);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
// terrno has been set by pAPI->metaReaderFn.getTableEntryByName, therefore, return directly
|
||||
pAPI->metaReaderFn.clearReader(&smrTable);
|
||||
blockDataDestroy(dataBlock);
|
||||
pInfo->loadInfo.totalRows = 0;
|
||||
return NULL;
|
||||
}
|
||||
static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
SStorageAPI* pAPI = &pTaskInfo->storageAPI;
|
||||
SSysTableScanInfo* pInfo = pOperator->info;
|
||||
int32_t numOfRows = 0;
|
||||
int32_t ret = 0;
|
||||
char dbname[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
SSDataBlock* pDataBlock = NULL;
|
||||
|
||||
if (smrTable.me.type == TSDB_SUPER_TABLE) {
|
||||
pAPI->metaReaderFn.clearReader(&smrTable);
|
||||
blockDataDestroy(dataBlock);
|
||||
pInfo->loadInfo.totalRows = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (smrTable.me.type == TSDB_CHILD_TABLE) {
|
||||
int64_t suid = smrTable.me.ctbEntry.suid;
|
||||
pAPI->metaReaderFn.clearReader(&smrTable);
|
||||
pAPI->metaReaderFn.initReader(&smrTable, pInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn);
|
||||
code = pAPI->metaReaderFn.getTableEntryByUid(&smrTable, suid);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
// terrno has been set by pAPI->metaReaderFn.getTableEntryByName, therefore, return directly
|
||||
pAPI->metaReaderFn.clearReader(&smrTable);
|
||||
blockDataDestroy(dataBlock);
|
||||
pInfo->loadInfo.totalRows = 0;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
char typeName[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
SSchemaWrapper* schemaRow = NULL;
|
||||
if (smrTable.me.type == TSDB_SUPER_TABLE) {
|
||||
schemaRow = &smrTable.me.stbEntry.schemaRow;
|
||||
STR_TO_VARSTR(typeName, "CHILD_TABLE");
|
||||
} else if (smrTable.me.type == TSDB_NORMAL_TABLE) {
|
||||
schemaRow = &smrTable.me.ntbEntry.schemaRow;
|
||||
STR_TO_VARSTR(typeName, "NORMAL_TABLE");
|
||||
}
|
||||
|
||||
sysTableUserColsFillOneTableCols(pInfo, dbname, &numOfRows, dataBlock, tableName, schemaRow, typeName);
|
||||
pAPI->metaReaderFn.clearReader(&smrTable);
|
||||
|
||||
if (numOfRows > 0) {
|
||||
relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock, pOperator->exprSupp.pFilterInfo);
|
||||
numOfRows = 0;
|
||||
}
|
||||
blockDataDestroy(dataBlock);
|
||||
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
||||
setOperatorCompleted(pOperator);
|
||||
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
||||
if (pOperator->status == OP_EXEC_DONE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
blockDataCleanup(pInfo->pRes);
|
||||
|
||||
pDataBlock = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_COLS);
|
||||
blockDataEnsureCapacity(pDataBlock, pOperator->resultInfo.capacity);
|
||||
doExtractDbName(dbname, pInfo, pAPI);
|
||||
|
||||
// optimize when sql like where table_name='tablename' and xxx.
|
||||
if (pInfo->req.filterTb[0]) {
|
||||
SSDataBlock* p = doOptimizeTableNameFilter(pOperator, pDataBlock, dbname);
|
||||
blockDataDestroy(pDataBlock);
|
||||
return p;
|
||||
}
|
||||
|
||||
int32_t ret = 0;
|
||||
if (pInfo->pCur == NULL) {
|
||||
pInfo->pCur = pAPI->metaFn.openTableMetaCursor(pInfo->readHandle.vnode);
|
||||
} else {
|
||||
pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0);
|
||||
}
|
||||
|
||||
if (pInfo->pSchema == NULL) {
|
||||
|
@ -532,26 +550,20 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
|
|||
if (!pInfo->pCur || !pInfo->pSchema) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
qError("sysTableScanUserCols failed since %s", terrstr(terrno));
|
||||
blockDataDestroy(dataBlock);
|
||||
blockDataDestroy(pDataBlock);
|
||||
pInfo->loadInfo.totalRows = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t restore = pInfo->restore;
|
||||
pInfo->restore = false;
|
||||
|
||||
while (restore || ((ret = pAPI->metaFn.cursorNext(pInfo->pCur, TSDB_TABLE_MAX)) == 0)) {
|
||||
if (restore) {
|
||||
restore = false;
|
||||
}
|
||||
|
||||
while (((ret = pAPI->metaFn.cursorNext(pInfo->pCur, TSDB_TABLE_MAX)) == 0)) {
|
||||
char typeName[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
char tableName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
|
||||
SSchemaWrapper* schemaRow = NULL;
|
||||
|
||||
if (pInfo->pCur->mr.me.type == TSDB_SUPER_TABLE) {
|
||||
qDebug("sysTableScanUserCols cursor get super table");
|
||||
qDebug("sysTableScanUserCols cursor get super table, %s", GET_TASKID(pTaskInfo));
|
||||
void* schema = taosHashGet(pInfo->pSchema, &pInfo->pCur->mr.me.uid, sizeof(int64_t));
|
||||
if (schema == NULL) {
|
||||
SSchemaWrapper* schemaWrapper = tCloneSSchemaWrapper(&pInfo->pCur->mr.me.stbEntry.schemaRow);
|
||||
|
@ -559,7 +571,8 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
|
|||
}
|
||||
continue;
|
||||
} else if (pInfo->pCur->mr.me.type == TSDB_CHILD_TABLE) {
|
||||
qDebug("sysTableScanUserCols cursor get child table");
|
||||
qDebug("sysTableScanUserCols cursor get child table, %s", GET_TASKID(pTaskInfo));
|
||||
|
||||
STR_TO_VARSTR(typeName, "CHILD_TABLE");
|
||||
STR_TO_VARSTR(tableName, pInfo->pCur->mr.me.name);
|
||||
int64_t suid = pInfo->pCur->mr.me.ctbEntry.suid;
|
||||
|
@ -568,13 +581,14 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
|
|||
schemaRow = *(SSchemaWrapper**)schema;
|
||||
} else {
|
||||
SMetaReader smrSuperTable = {0};
|
||||
pAPI->metaReaderFn.initReader(&smrSuperTable, pInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn);
|
||||
pAPI->metaReaderFn.initReader(&smrSuperTable, pInfo->readHandle.vnode, META_READER_NOLOCK, &pAPI->metaFn);
|
||||
int code = pAPI->metaReaderFn.getTableEntryByUid(&smrSuperTable, suid);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
// terrno has been set by pAPI->metaReaderFn.getTableEntryByName, therefore, return directly
|
||||
qError("sysTableScanUserCols get meta by suid:%" PRId64 " error, code:%d", suid, code);
|
||||
qError("sysTableScanUserCols get meta by suid:%" PRId64 " error, code:%d, %s", suid, code, GET_TASKID(pTaskInfo));
|
||||
|
||||
pAPI->metaReaderFn.clearReader(&smrSuperTable);
|
||||
blockDataDestroy(dataBlock);
|
||||
blockDataDestroy(pDataBlock);
|
||||
pInfo->loadInfo.totalRows = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -584,34 +598,35 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
|
|||
pAPI->metaReaderFn.clearReader(&smrSuperTable);
|
||||
}
|
||||
} else if (pInfo->pCur->mr.me.type == TSDB_NORMAL_TABLE) {
|
||||
qDebug("sysTableScanUserCols cursor get normal table");
|
||||
qDebug("sysTableScanUserCols cursor get normal table, %s", GET_TASKID(pTaskInfo));
|
||||
schemaRow = &pInfo->pCur->mr.me.ntbEntry.schemaRow;
|
||||
STR_TO_VARSTR(typeName, "NORMAL_TABLE");
|
||||
STR_TO_VARSTR(tableName, pInfo->pCur->mr.me.name);
|
||||
} else {
|
||||
qDebug("sysTableScanUserCols cursor get invalid table");
|
||||
qDebug("sysTableScanUserCols cursor get invalid table, %s", GET_TASKID(pTaskInfo));
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((numOfRows + schemaRow->nCols) > pOperator->resultInfo.capacity) {
|
||||
relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock, pOperator->exprSupp.pFilterInfo);
|
||||
relocateAndFilterSysTagsScanResult(pInfo, numOfRows, pDataBlock, pOperator->exprSupp.pFilterInfo);
|
||||
numOfRows = 0;
|
||||
pInfo->restore = true;
|
||||
|
||||
if (pInfo->pRes->info.rows > 0) {
|
||||
pAPI->metaFn.pauseTableMetaCursor(pInfo->pCur);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
sysTableUserColsFillOneTableCols(pInfo, dbname, &numOfRows, dataBlock, tableName, schemaRow, typeName);
|
||||
sysTableUserColsFillOneTableCols(pInfo, dbname, &numOfRows, pDataBlock, tableName, schemaRow, typeName);
|
||||
}
|
||||
}
|
||||
|
||||
if (numOfRows > 0) {
|
||||
relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock, pOperator->exprSupp.pFilterInfo);
|
||||
pAPI->metaFn.pauseTableMetaCursor(pInfo->pCur);
|
||||
relocateAndFilterSysTagsScanResult(pInfo, numOfRows, pDataBlock, pOperator->exprSupp.pFilterInfo);
|
||||
numOfRows = 0;
|
||||
}
|
||||
|
||||
blockDataDestroy(dataBlock);
|
||||
blockDataDestroy(pDataBlock);
|
||||
if (ret != 0) {
|
||||
pAPI->metaFn.closeTableMetaCursor(pInfo->pCur);
|
||||
pInfo->pCur = NULL;
|
||||
|
@ -619,8 +634,7 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
||||
qDebug("sysTableScanUserCols get cols success, rows:%" PRIu64, pInfo->loadInfo.totalRows);
|
||||
|
||||
qDebug("get cols success, rows:%" PRIu64 " %s", pInfo->loadInfo.totalRows, GET_TASKID(pTaskInfo));
|
||||
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
||||
}
|
||||
|
||||
|
@ -702,6 +716,8 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
|
|||
int32_t ret = 0;
|
||||
if (pInfo->pCur == NULL) {
|
||||
pInfo->pCur = pAPI->metaFn.openTableMetaCursor(pInfo->readHandle.vnode);
|
||||
} else {
|
||||
pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0);
|
||||
}
|
||||
|
||||
bool blockFull = false;
|
||||
|
@ -727,7 +743,6 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
if ((smrSuperTable.me.stbEntry.schemaTag.nCols + numOfRows) > pOperator->resultInfo.capacity) {
|
||||
pAPI->metaFn.cursorPrev(pInfo->pCur, TSDB_TABLE_MAX);
|
||||
blockFull = true;
|
||||
} else {
|
||||
sysTableUserTagsFillOneTableTags(pInfo, &smrSuperTable, &pInfo->pCur->mr, dbname, tableName, &numOfRows,
|
||||
|
@ -741,6 +756,7 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
|
|||
numOfRows = 0;
|
||||
|
||||
if (pInfo->pRes->info.rows > 0) {
|
||||
pAPI->metaFn.pauseTableMetaCursor(pInfo->pCur);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -749,6 +765,7 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
if (numOfRows > 0) {
|
||||
pAPI->metaFn.pauseTableMetaCursor(pInfo->pCur);
|
||||
relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock, pOperator->exprSupp.pFilterInfo);
|
||||
numOfRows = 0;
|
||||
}
|
||||
|
@ -1329,7 +1346,7 @@ static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) {
|
|||
firstMetaCursor = 1;
|
||||
}
|
||||
if (!firstMetaCursor) {
|
||||
pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0);
|
||||
pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 1);
|
||||
}
|
||||
|
||||
blockDataCleanup(pInfo->pRes);
|
||||
|
|
|
@ -1379,7 +1379,7 @@ SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) {
|
|||
pOptions->sstTrigger = -1;
|
||||
pOptions->tablePrefix = -1;
|
||||
pOptions->tableSuffix = -1;
|
||||
pOptions->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR;
|
||||
pOptions->withArbitrator = -1;
|
||||
return (SNode*)pOptions;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
|||
|
||||
taosThreadMutexLock(&ths->arbTokenMutex);
|
||||
syncUtilGenerateArbToken(ths->myNodeInfo.nodeId, ths->vgId, ths->arbToken);
|
||||
sInfo("vgId:%d, assigned leader to leader, arbToken:%s", ths->vgId, ths->arbToken);
|
||||
taosThreadMutexUnlock(&ths->arbTokenMutex);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -302,8 +302,16 @@ int32_t syncBecomeAssignedLeader(SSyncNode* ths, SRpcMsg* pRpcMsg) {
|
|||
goto _OVER;
|
||||
}
|
||||
syncNodeBecomeAssignedLeader(ths);
|
||||
|
||||
if (syncNodeAppendNoop(ths) < 0) {
|
||||
sError("vgId:%d, assigned leader failed to append noop entry since %s", ths->vgId, terrstr());
|
||||
}
|
||||
}
|
||||
errcode = TSDB_CODE_SUCCESS;
|
||||
} else {
|
||||
sInfo("vgId:%d, skip to set assigned leader, token mismatch, local:%s, msg:%s", ths->vgId, ths->arbToken,
|
||||
req.memberToken);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
SVArbSetAssignedLeaderRsp rsp = {0};
|
||||
|
@ -1056,6 +1064,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo, int32_t vnodeVersion) {
|
|||
pSyncNode->arbTerm = -1;
|
||||
taosThreadMutexInit(&pSyncNode->arbTokenMutex, NULL);
|
||||
syncUtilGenerateArbToken(pSyncNode->myNodeInfo.nodeId, pSyncInfo->vgId, pSyncNode->arbToken);
|
||||
sInfo("vgId:%d, arb token:%s", pSyncNode->vgId, pSyncNode->arbToken);
|
||||
|
||||
// init peersNum, peers, peersId
|
||||
pSyncNode->peersNum = pSyncNode->raftCfg.cfg.totalReplicaNum - 1;
|
||||
|
|
|
@ -115,13 +115,17 @@ class TDSql:
|
|||
else:
|
||||
tdLog.info("sql:%s, check passed, no ErrInfo occurred" % (sql))
|
||||
|
||||
def error(self, sql, expectedErrno = None, expectErrInfo = None, fullMatched = True):
|
||||
def error(self, sql, expectedErrno = None, expectErrInfo = None, fullMatched = True, show = False):
|
||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
expectErrNotOccured = True
|
||||
|
||||
if show:
|
||||
tdLog.info("sql:%s" % (sql))
|
||||
|
||||
try:
|
||||
self.cursor.execute(sql)
|
||||
except BaseException as e:
|
||||
tdLog.info("err:%s" % (e))
|
||||
expectErrNotOccured = False
|
||||
self.errno = e.errno
|
||||
error_info = repr(e)
|
||||
|
@ -161,7 +165,10 @@ class TDSql:
|
|||
|
||||
return self.error_info
|
||||
|
||||
def query(self, sql, row_tag=None, queryTimes=10, count_expected_res=None):
|
||||
def query(self, sql, row_tag=None, queryTimes=10, count_expected_res=None, show = False):
|
||||
if show:
|
||||
tdLog.info("sql:%s" % (sql))
|
||||
|
||||
self.sql = sql
|
||||
i=1
|
||||
while i <= queryTimes:
|
||||
|
|
|
@ -19,6 +19,8 @@ from util.common import *
|
|||
from util.sqlset import *
|
||||
|
||||
class TDTestCase:
|
||||
updatecfgDict = {'qDebugFlag':135 , 'mDebugFlag':135}
|
||||
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
self.replicaVar = int(replicaVar)
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import datetime
|
||||
import datetime, time
|
||||
from enum import Enum
|
||||
import binascii
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
from util.cases import *
|
||||
|
@ -45,24 +46,56 @@ class TDTestCase:
|
|||
tdSql.init(conn.cursor())
|
||||
tdSql.execute(f'drop database if exists db')
|
||||
tdSql.execute(f'create database if not exists db vgroups 1')
|
||||
tdLog.printNoPrefix("create table")
|
||||
self.__create_tb()
|
||||
|
||||
def __create_tb(self, dbname="db"):
|
||||
CREATE_STB_LIST = [ f"create table {dbname}.stb_vc (ts timestamp, c0 binary(50), c1 varchar(50)) tags(t0 varchar(50), t1 binary(50));",
|
||||
CREATE_STB_LIST = [ f"create table {dbname}.stb_vc (ts timestamp, c0 varchar(50), c1 varchar(50)) tags(t0 varchar(50), t1 varchar(50));",
|
||||
f"create table {dbname}.stb_nc (ts timestamp, c0 nchar(50), c1 nchar(50)) tags(t0 nchar(50), t1 nchar(50));",
|
||||
f"create table {dbname}.stb_bi (ts timestamp, c0 binary(50), c1 binary(50)) tags(t0 binary(50), t1 binary(50));",
|
||||
f"create table {dbname}.stb_ts (ts timestamp, c0 timestamp, c1 timestamp) tags(t0 timestamp, t1 timestamp);",
|
||||
f"create table {dbname}.stb_bo (ts timestamp, c0 bool, c1 bool) tags(t0 bool, t1 bool);",
|
||||
f"create table {dbname}.stb_vb (ts timestamp, c0 varbinary(50), c1 varbinary(50)) tags(t0 varbinary(50), t1 varbinary(50));",
|
||||
f"create table {dbname}.stb_in (ts timestamp, c0 int, c1 smallint) tags(t0 bigint, t1 tinyint);",
|
||||
f"create table {dbname}.stb_ui (ts timestamp, c0 int unsigned, c1 smallint unsigned) tags(t0 bigint unsigned, t1 tinyint unsigned);",
|
||||
f"create table {dbname}.stb_in (ts timestamp, c0 int, c1 int) tags(t0 int, t1 int);",
|
||||
f"create table {dbname}.stb_ui (ts timestamp, c0 int unsigned, c1 int unsigned) tags(t0 int unsigned, t1 int unsigned);",
|
||||
f"create table {dbname}.stb_bin (ts timestamp, c0 bigint, c1 bigint) tags(t0 bigint, t1 bigint);",
|
||||
f"create table {dbname}.stb_bui (ts timestamp, c0 bigint unsigned, c1 bigint unsigned) tags(t0 bigint unsigned, t1 bigint unsigned);",
|
||||
f"create table {dbname}.stb_sin (ts timestamp, c0 smallint, c1 smallint) tags(t0 smallint, t1 smallint);",
|
||||
f"create table {dbname}.stb_sui (ts timestamp, c0 smallint unsigned, c1 smallint unsigned) tags(t0 smallint unsigned, t1 smallint unsigned);",
|
||||
f"create table {dbname}.stb_tin (ts timestamp, c0 tinyint, c1 tinyint) tags(t0 tinyint, t1 tinyint);",
|
||||
f"create table {dbname}.stb_tui (ts timestamp, c0 tinyint unsigned, c1 tinyint unsigned) tags(t0 tinyint unsigned, t1 tinyint unsigned);",
|
||||
f"create table {dbname}.stb_fl (ts timestamp, c0 float, c1 float) tags(t0 float, t1 float);",
|
||||
f"create table {dbname}.stb_db (ts timestamp, c0 float, c1 float) tags(t0 float, t1 float);",
|
||||
f"create table {dbname}.stb_db (ts timestamp, c0 double, c1 double) tags(t0 double, t1 double);",
|
||||
f"create table {dbname}.stb_ge (ts timestamp, c0 geometry(512), c1 geometry(512)) tags(t0 geometry(512), t1 geometry(512));",
|
||||
f"create table {dbname}.stb_js (ts timestamp, c0 int) tags(t0 json);" ]
|
||||
f"create table {dbname}.stb_js (ts timestamp, c0 int) tags(t0 json);"]
|
||||
|
||||
CREATE_NTB_LIST = [ f"create table {dbname}.ntb_vc (ts timestamp, c0 binary(50), c1 varchar(50));",
|
||||
f"create table {dbname}.ntb_nc (ts timestamp, c0 nchar(50), c1 nchar(50));",
|
||||
f"create table {dbname}.ntb_bi (ts timestamp, c0 binary(50), c1 binary(50));",
|
||||
f"create table {dbname}.ntb_ts (ts timestamp, c0 timestamp, c1 timestamp);",
|
||||
f"create table {dbname}.ntb_bo (ts timestamp, c0 bool, c1 bool);",
|
||||
f"create table {dbname}.ntb_vb (ts timestamp, c0 varbinary(50), c1 varbinary(50));",
|
||||
f"create table {dbname}.ntb_in (ts timestamp, c0 int, c1 int);",
|
||||
f"create table {dbname}.ntb_ui (ts timestamp, c0 int unsigned, c1 int unsigned);",
|
||||
f"create table {dbname}.ntb_bin (ts timestamp, c0 bigint, c1 bigint);",
|
||||
f"create table {dbname}.ntb_bui (ts timestamp, c0 bigint unsigned, c1 bigint unsigned);",
|
||||
f"create table {dbname}.ntb_sin (ts timestamp, c0 smallint, c1 smallint);",
|
||||
f"create table {dbname}.ntb_sui (ts timestamp, c0 smallint unsigned, c1 smallint unsigned);",
|
||||
f"create table {dbname}.ntb_tin (ts timestamp, c0 tinyint, c1 tinyint);",
|
||||
f"create table {dbname}.ntb_tui (ts timestamp, c0 tinyint unsigned, c1 tinyint unsigned);",
|
||||
f"create table {dbname}.ntb_fl (ts timestamp, c0 float, c1 float);",
|
||||
f"create table {dbname}.ntb_db (ts timestamp, c0 double, c1 double);",
|
||||
f"create table {dbname}.ntb_ge (ts timestamp, c0 geometry(512), c1 geometry(512));"]
|
||||
for _stb in CREATE_STB_LIST:
|
||||
tdSql.execute(_stb)
|
||||
tdSql.query(f'show {dbname}.stables')
|
||||
tdSql.checkRows(len(CREATE_STB_LIST))
|
||||
|
||||
for _stb in CREATE_NTB_LIST:
|
||||
tdSql.execute(_stb)
|
||||
tdSql.query(f'show {dbname}.tables')
|
||||
tdSql.checkRows(len(CREATE_NTB_LIST))
|
||||
|
||||
def _query_check_varchar(self, result, okv, nv, row = 0, col = 0):
|
||||
for i in range(row):
|
||||
for j in range(1, col):
|
||||
|
@ -146,25 +179,62 @@ class TDTestCase:
|
|||
check_result = True
|
||||
tdSql.checkEqual(check_result, True)
|
||||
|
||||
def _query_check_varbinary(self, result, okv, nv, row = 0, col = 0):
|
||||
tdLog.info(f'[okv={okv}, nv={nv}')
|
||||
for i in range(row):
|
||||
for j in range(1, col):
|
||||
check_result = False
|
||||
if result[i][j]:
|
||||
check_item = result[i][j].decode('utf-8')
|
||||
else:
|
||||
check_item = ''
|
||||
# new_nv = None
|
||||
|
||||
def _query_check(self, dbname="db", stbname="", ctbname="", nRows = 0, okv = None, nv = None, dtype = TDDataType.NULL):
|
||||
if nv[0:1] == '\'' or nv[0:1] == '\"':
|
||||
nv = nv[1:-1]
|
||||
if okv[0:1] == '\'' or okv[0:1] == '\"':
|
||||
okv = okv[1:-1]
|
||||
|
||||
# if nv[0:2] == '\\x' or nv[0:2] == '\\X':
|
||||
# nv = nv[1:]
|
||||
# elif nv == '' or nv =="":
|
||||
# new_nv = nv
|
||||
# elif nv.isspace():
|
||||
# new_nv = nv
|
||||
# else:
|
||||
# hex_text = binascii.hexlify(nv.encode())
|
||||
# new_nv = '/x' + hex_text.decode().upper()
|
||||
# tdLog.info(f"okv={okv}, nv={nv}, check_item={check_item}")
|
||||
if check_item == None:
|
||||
check_item = 'null'
|
||||
if check_item in okv or check_item in nv:
|
||||
check_result = True
|
||||
tdSql.checkEqual(check_result, True)
|
||||
|
||||
def _query_check(self, dbname="db", stbname="", ctbname="", ntbname="",nRows = 0, okv = None, nv = None, dtype = TDDataType.NULL):
|
||||
result = None
|
||||
if dtype != TDDataType.GEOMETRY: # geometry query by py connector need to be supported
|
||||
tdSql.query(f'select * from {dbname}.{stbname}')
|
||||
if stbname:
|
||||
if dtype != TDDataType.GEOMETRY: # geometry query by py connector need to be supported
|
||||
tdSql.query(f'select * from {dbname}.{stbname}')
|
||||
tdSql.checkRows(nRows)
|
||||
result = tdSql.queryResult
|
||||
else:
|
||||
tdSql.query(f'select * from {dbname}.{ntbname}')
|
||||
tdSql.checkRows(nRows)
|
||||
result = tdSql.queryResult
|
||||
|
||||
|
||||
if dtype == TDDataType.VARCHAR or dtype == TDDataType.NCHAR:
|
||||
if dtype == TDDataType.VARCHAR or dtype == TDDataType.NCHAR or dtype == TDDataType.BINARY:
|
||||
self._query_check_varchar(result, okv, nv, nRows, 4)
|
||||
elif dtype == TDDataType.TIMESTAMP:
|
||||
self._query_check_timestamp(result, okv, nv, nRows, 4)
|
||||
elif dtype == TDDataType.BOOL:
|
||||
self._query_check_bool(result, okv, nv, nRows, 4)
|
||||
elif dtype == TDDataType.VARBINARY:
|
||||
pass
|
||||
elif dtype == TDDataType.INT:
|
||||
self._query_check_varbinary(result, okv, nv, nRows, 4)
|
||||
elif dtype == TDDataType.INT or dtype == TDDataType.BIGINT or dtype == TDDataType.SMALLINT or dtype == TDDataType.TINYINT:
|
||||
self._query_check_int(result, okv, nv, nRows, 4)
|
||||
elif dtype == TDDataType.UINT:
|
||||
elif dtype == TDDataType.UINT or dtype == TDDataType.UBIGINT or dtype == TDDataType.USMALLINT or dtype == TDDataType.UTINYINT:
|
||||
self._query_check_int(result, okv, nv, nRows, 4)
|
||||
elif dtype == TDDataType.FLOAT or dtype == TDDataType.DOUBLE:
|
||||
self._query_check_int(result, okv, nv, nRows, 4)
|
||||
|
@ -176,75 +246,138 @@ class TDTestCase:
|
|||
if ctbname != "":
|
||||
tdSql.execute(f'drop table {dbname}.{ctbname}')
|
||||
|
||||
def __insert_query_common(self, dbname="db", stbname="", ctbname="", oklist=[], kolist=[], okv=None, dtype = TDDataType.NULL):
|
||||
tdLog.info(f'{dbname}.{stbname} {ctbname}, oklist:%d, kolist:%d'%(len(oklist), len(kolist)))
|
||||
tdSql.checkEqual(34, len(oklist) + len(kolist))
|
||||
def __insert_query_common(self, dbname="db", stbname="", ctbname="", ntbname="", oklist=[], kolist=[], okv=None, dtype = TDDataType.NULL):
|
||||
tdLog.info(f'[Begin]{dbname}.{stbname} {ctbname}, oklist:%d, kolist:%d, TDDataType:%s'%(len(oklist), len(kolist), dtype))
|
||||
# tdSql.checkEqual(34, len(oklist) + len(kolist))
|
||||
|
||||
for _l in kolist:
|
||||
for _e in _l:
|
||||
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv})' %(_e))
|
||||
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, %s)' %(_e))
|
||||
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, %s)' %(_e, _e))
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, %s) values(now, {okv}, {okv})' %(_e))
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv}) values(now, {okv}, {okv})' %(_e))
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, %s, {okv})' %(_e))
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, {okv}, %s)' %(_e))
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, %s, %s)' %(_e, _e))
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, {okv}, {okv})')
|
||||
self._query_check(dbname,stbname, "", 1, okv, _e, dtype)
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = {okv}')
|
||||
tdSql.error(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e))
|
||||
tdSql.error(f'alter table {dbname}.{ctbname} set tag t1 = %s' %(_e))
|
||||
# tdLog.info(f'[ko:verify value "{_e}"]')
|
||||
# create sub-table manually, check tag
|
||||
tdLog.info('[ko:create sub-table manually, check tag]')
|
||||
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv})' %(_e), show=True)
|
||||
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, %s)' %(_e), show=True)
|
||||
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, %s)' %(_e, _e), show=True)
|
||||
|
||||
# create sub-table automatically, check tag
|
||||
tdLog.info('[ko:create sub-table automatically, check tag]')
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, %s) values(now, {okv}, {okv})' %(_e), show=True)
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv}) values(now, {okv}, {okv})' %(_e), show=True)
|
||||
|
||||
# create sub-table automatically, check value
|
||||
tdLog.info('[ko:create sub-table automatically, check value]')
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, %s, {okv})' %(_e), show=True)
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, {okv}, %s)' %(_e), show=True)
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, %s, %s)' %(_e, _e), show=True)
|
||||
|
||||
# check alter table tag
|
||||
tdLog.info('[ko:check alter table tag]')
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, {okv}, {okv})', show=True)
|
||||
# self._query_check(dbname,stbname, "", None, 1, okv, _e, dtype)
|
||||
# tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = {okv}', show=True)
|
||||
tdSql.error(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e), show=True)
|
||||
tdSql.error(f'alter table {dbname}.{ctbname} set tag t1 = %s' %(_e), show=True)
|
||||
tdSql.execute(f'drop table {dbname}.{ctbname}')
|
||||
|
||||
# insert into value by supper-table, check tag & value
|
||||
tdLog.info('[ko:insert into value by supper-table, check tag & value]')
|
||||
tdSql.error(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_1", %s, {okv}, now, {okv}, {okv})' %(_e), show=True)
|
||||
tdSql.error(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_2", {okv},{okv}, now + 1s, {okv}, %s)' %(_e), show=True)
|
||||
tdSql.error(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_3", %s, %s, now + 2s, %s, %s)' %(_e, _e, _e, _e), show=True)
|
||||
|
||||
# insert into normal table, check value
|
||||
tdLog.info('[ko:insert into normal table, check value]')
|
||||
tdSql.error(f'insert into {dbname}.{ntbname} values(now, %s, {okv})' %(_e), show=True)
|
||||
tdSql.error(f'insert into {dbname}.{ntbname} values(now, {okv}, %s)' %(_e), show=True)
|
||||
tdSql.error(f'insert into {dbname}.{ntbname} values(now, %s, %s)' %(_e, _e), show=True)
|
||||
|
||||
for _l in oklist:
|
||||
for _e in _l:
|
||||
tdLog.info(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv})' %(_e))
|
||||
tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv})' %(_e))
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} values(now + 0s, %s, {okv})' %(_e))
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} values(now + 1s, {okv}, %s)' %(_e))
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} values(now + 2s, %s, %s)' %(_e, _e))
|
||||
tdLog.info(f'insert into {dbname}.{ctbname} values(now + 0s, %s, {okv})' %(_e))
|
||||
tdLog.info(f'insert into {dbname}.{ctbname} values(now + 1s, {okv}, %s)' %(_e))
|
||||
tdLog.info(f'insert into {dbname}.{ctbname} values(now + 2s, %s, %s)' %(_e, _e))
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e))
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname} set tag t1 = %s' %(_e))
|
||||
self._query_check(dbname,stbname, ctbname, 3, okv, _e, dtype)
|
||||
tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, %s)' %(_e, _e))
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} values(now, %s, %s)' %(_e, _e))
|
||||
self._query_check(dbname,stbname, ctbname, 1, okv, _e, dtype)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv}) values(now, %s, {okv})' %(_e, _e))
|
||||
self._query_check(dbname,stbname, ctbname, 1, okv, _e, dtype)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, %s) values(now, {okv}, %s)' %(_e, _e))
|
||||
self._query_check(dbname,stbname, ctbname, 1, okv, _e, dtype)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, %s) values(now, %s, %s)' %(_e, _e, _e, _e))
|
||||
self._query_check(dbname,stbname, ctbname, 1, okv, _e, dtype)
|
||||
tdLog.info(f'[ok:verify value "{_e}"]')
|
||||
# 1. create sub-table manually, check tag
|
||||
tdLog.info('[ok:create sub-table manually, check tag]')
|
||||
tdSql.execute(f'create table {dbname}.{ctbname}_1 using {dbname}.{stbname} tags({_e}, {okv})', show=True)
|
||||
tdSql.execute(f'create table {dbname}.{ctbname}_2 using {dbname}.{stbname} tags({okv}, %s)' %(_e), show=True)
|
||||
tdSql.execute(f'create table {dbname}.{ctbname}_3 using {dbname}.{stbname} tags(%s, %s)' %(_e, _e), show=True)
|
||||
|
||||
|
||||
# 1.1 insert into sub-table, check value
|
||||
tdLog.info('[ok:insert into sub-table, check value]')
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname}_1 values(now + 0s, %s, {okv})' %(_e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname}_2 values(now + 1s, {okv}, %s)' %(_e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname}_3 values(now + 2s, %s, %s)' %(_e, _e), show=True)
|
||||
|
||||
# 1.2 check alter table tag
|
||||
tdLog.info('[ok:check alter table tag]')
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname}_1 set tag t1 = %s' %(_e), show=True)
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname}_2 set tag t0 = %s' %(_e), show=True)
|
||||
|
||||
# 1.3 check table data
|
||||
tdLog.info('[ok:check table data]')
|
||||
self._query_check(dbname, stbname, f'{ctbname}_1', None, 3, okv, _e, dtype)
|
||||
self._query_check(dbname, stbname, f'{ctbname}_2', None, 2, okv, _e, dtype)
|
||||
self._query_check(dbname, stbname, f'{ctbname}_3', None, 1, okv, _e, dtype)
|
||||
|
||||
# 2. insert into value by creating sub-table automatically, check tag & value
|
||||
tdLog.info('[ok:insert into value by creating sub-table automatically, check tag & value]')
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname}_1 using {dbname}.{stbname} tags(%s, {okv}) values(now, %s, {okv})' %(_e, _e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname}_2 using {dbname}.{stbname} tags({okv}, %s) values(now + 1s, {okv}, %s)' %(_e, _e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname}_3 using {dbname}.{stbname} tags(%s, %s) values(now + 2s, %s, %s)' %(_e, _e, _e, _e), show=True)
|
||||
|
||||
self._query_check(dbname, stbname, f'{ctbname}_1', None, 3, okv, _e, dtype)
|
||||
self._query_check(dbname, stbname, f'{ctbname}_2', None, 2, okv, _e, dtype)
|
||||
self._query_check(dbname, stbname, f'{ctbname}_3', None, 1, okv, _e, dtype)
|
||||
|
||||
# 3. insert into value by supper-table, check tag & value
|
||||
tdLog.info('[ok:insert into value by supper-table, check tag & value]')
|
||||
tdSql.execute(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_1", %s, {okv}, now, %s, {okv})' %(_e, _e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_2", {okv}, %s, now + 1s, {okv}, %s)' %(_e, _e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_3", %s, %s, now + 2s, %s, %s)' %(_e, _e, _e, _e), show=True)
|
||||
|
||||
self._query_check(dbname, stbname, f'{ctbname}_1', None, 3, okv, _e, dtype)
|
||||
self._query_check(dbname, stbname, f'{ctbname}_2', None, 2, okv, _e, dtype)
|
||||
self._query_check(dbname, stbname, f'{ctbname}_3', None, 1, okv, _e, dtype)
|
||||
|
||||
# 4. insert value into normal table
|
||||
tdLog.info('[ok:insert value into normal table]')
|
||||
tdSql.execute(f'insert into {dbname}.{ntbname} values(now, %s, {okv})' %(_e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{ntbname} values(now + 1s, {okv}, %s)' %(_e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{ntbname} values(now + 2s, %s, %s)' %(_e, _e), show=True)
|
||||
|
||||
if dtype != TDDataType.GEOMETRY:
|
||||
# self._query_check(dbname, None, None, ntbname, 3, okv, _e, dtype)
|
||||
tdSql.query(f'select * from {dbname}.{ntbname}')
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query(f'delete from {dbname}.{ntbname}')
|
||||
|
||||
def __insert_query_json(self, dbname="db", stbname="", ctbname="", oklist=[], kolist=[], okv=None):
|
||||
tdLog.info(f'{dbname}.{stbname} {ctbname}, oklist:%d, kolist:%d'%(len(oklist), len(kolist)))
|
||||
tdSql.checkEqual(34, len(oklist) + len(kolist))
|
||||
# tdSql.checkEqual(34, len(oklist) + len(kolist))
|
||||
|
||||
for _l in kolist:
|
||||
for _e in _l:
|
||||
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s)' %(_e))
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s) values(now, 1)' %(_e))
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}) values(now, 1)')
|
||||
tdSql.query(f'select * from {dbname}.{stbname}')
|
||||
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s)' %(_e), show=True)
|
||||
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s) values(now, 1)' %(_e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}) values(now, 1)', show=True)
|
||||
tdSql.query(f'select * from {dbname}.{stbname}', show=True)
|
||||
tdSql.checkRows(1)
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = {okv}')
|
||||
tdSql.error(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e))
|
||||
tdSql.execute(f'drop table {dbname}.{ctbname}')
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = {okv}', show=True)
|
||||
tdSql.error(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e), show=True)
|
||||
tdSql.execute(f'drop table {dbname}.{ctbname}', show=True)
|
||||
for _l in oklist:
|
||||
for _e in _l:
|
||||
tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s)' %(_e))
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} values(now, 1)')
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e))
|
||||
tdSql.query(f'select * from {dbname}.{stbname}')
|
||||
tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s)' %(_e), show=True)
|
||||
tdSql.execute(f'insert into {dbname}.{ctbname} values(now, 1)', show=True)
|
||||
tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e), show=True)
|
||||
tdSql.query(f'select * from {dbname}.{stbname}', show=True)
|
||||
tdSql.checkRows(1)
|
||||
tdSql.execute(f'drop table {dbname}.{ctbname}')
|
||||
|
||||
tdSql.execute(f'drop table {dbname}.{ctbname}', show=True)
|
||||
|
||||
def __insert_query_exec(self):
|
||||
STR_EMPTY = ['\'\'', "\"\"", '\' \'', "\" \""]
|
||||
STR_INTEGER_P = ["\"42\"", '\'+42\'', '\'+0\'', '\'-0\'', '\'0x2A\'', '\'-0X0\'', '\'+0x0\'', '\'0B00101010\'', '\'-0b00\'']
|
||||
STR_CHINESE = ['\'年年岁岁,花相似\'']
|
||||
STR_CHINESE_ILLEGAL = ['\'洛阳城东桃李花,飞来飞去落谁家。幽闺女儿爱颜色,坐见落花长叹息。今岁花开君不待。明年花开复谁在。故人不共洛阳东,今来空对落花风。年年岁岁花相似,岁岁年年人不同\'']
|
||||
STR_INTEGER_P = ["\"42\"", '\'+42\'', '\'+0\'', '\'1\'','\'-0\'', '\'0x2A\'', '\'-0X0\'', '\'+0x0\'', '\'0B00101010\'', '\'-0b00\'']
|
||||
STR_INTEGER_M = ['\'-128\'', '\'-0X1\'', '\"-0x34\"', '\'-0b01\'', '\'-0B00101010\'']
|
||||
STR_FLOAT_P = ['\'42.1\'', "\"+0.003\"", "\'-0.0\'"]
|
||||
STR_FLOAT_M = ["\"-32.001\""]
|
||||
|
@ -259,18 +392,32 @@ class TDTestCase:
|
|||
STR_TSKP_MISC = ['\'now()+1s\'', '\' now()\'', '\'now( )\'', '\'today() \'', '\'today())\'', '\'today()+1m\'', '\'today()-1w\'']
|
||||
STR_BOOL = ['\'true\'', '\'false\'', '\'TRUE\'', '\'FALSE\'', '\'tRuE\'', '\'falsE\'']
|
||||
STR_TS = ["\"2024-02-01 00:00:01.001-08:00\"", "\'2024-02-01T00:00:01.001+09:00\'", "\"2024-02-01\"", "\'2024-02-02 00:00:01\'", "\'2024-02-02 00:00:01.009\'"]
|
||||
STR_VARBIN = ['\'\\x12\'', '\'\\x13\'', '\' \\x14 \'', '\'\\x12ab\'']
|
||||
STR_TS_ILLEGAL = ["\"2023-2024-02-01 00:00:01.001-08:00\"", "\'2024-02-01T99:00:01.001+09:00\'", "\"2024-02-31\"", "\'2024-02-02 00:88:01\'", "\'2024-02-02 00:00:77.009\'"]
|
||||
STR_VARBIN = ["\'\x12\'", "\'\x13\'", "\' \x14 \'", "\'\x12ab\'"]
|
||||
STR_JSON_O = ['\'{\"k1\":\"v1\"}\'', '\' {} \'']
|
||||
STR_JSON_A = ['\'[]\'']
|
||||
STR_GEO = ['\' POINT(1.0 1.0)\'', '\'LINESTRING(1.00 +2.0, 2.1 -3.2, 5.00 5.01) \'', '\'POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))\'' ]
|
||||
STR_JSON_A = ['\'[]\'', '\"{\'k1\': \'v1\',\'k2\'}\"', '\"{\'k1\': \'v1\'}}\"']
|
||||
STR_GEO = ["\' POINT(1.0 1.0)\'", "\'LINESTRING(1.00 +2.0, 2.1 -3.2, 5.00 5.01) \'", "\'POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))\'" ]
|
||||
STR_GEO_ILLEGAL = ['\' POINT(1.0)\'', '\'LINESTRING(1.00 +2.0, -3.2, 5.00 5.01) \'', '\'POLYGON((-2.0 +2.0, 1.0 1.0))\'' ]
|
||||
STR_NULL = ['\'NuLl\'', '\'null\'', '\'NULL\'']
|
||||
STR_NONE = ['\'NoNe\'', '\'none\'', '\'NONE\'']
|
||||
STR_BINARY = ["\'\x7f8290\'", "\'\X7f8290\'", "\'x7f8290\'", "\'\\x\'"] # bug TD-29193
|
||||
STR_BINARY_ILLEGAL = ["\'\\x7f829\'"]
|
||||
|
||||
RAW_INTEGER_P = [' 42 ', '+042 ', ' +0', '0 ', '-0', '0', ' 0X2A', ' -0x0 ', '+0x0 ', ' 0B00101010', ' -0b00']
|
||||
RAW_INTEGER_M = [' -42 ', ' -0128',' -0x1', ' -0X2A', '-0b01 ', ' -0B00101010 ']
|
||||
RAW_INTEGER_INT_BOUNDARY_ILLEGAL =['2147483648', '-2147483649']
|
||||
RAW_INTEGER_UINT_BOUNDARY_ILLEGAL =['4294967296', '-1']
|
||||
RAW_INTEGER_BINT_BOUNDARY_ILLEGAL =['9223372036854775808', '-9223372036854775809']
|
||||
RAW_INTEGER_UBINT_BOUNDARY_ILLEGAL =['18446744073709551616', '-1']
|
||||
RAW_INTEGER_SINT_BOUNDARY_ILLEGAL =['32768', '-32769']
|
||||
RAW_INTEGER_USINT_BOUNDARY_ILLEGAL =['65536', '-1']
|
||||
RAW_INTEGER_TINT_BOUNDARY_ILLEGAL =['128', '-129']
|
||||
RAW_INTEGER_UTINT_BOUNDARY_ILLEGAL =['256', '-1']
|
||||
RAW_FLOAT_P = [' 123.012', ' 0.0', ' +0.0', ' -0.0 ']
|
||||
RAW_FLOAT_M = ['-128.001 ']
|
||||
RAW_FLOAT_E_P = [' 1e-100', ' +0.1E+2', ' -0.1E-10']
|
||||
RAW_FLOAT_E_M = [" -1E2 "]
|
||||
RAW_FLOAT_E_M_SPE = ["-1e-100"]
|
||||
RAW_MISC = ['123abc', "123c", '-123d', '+', '-', ' *', ' /', '% ', '&', "|", "^", "&&", "||", "!", " =", ' None ', 'NONE', 'now+1 s', 'now-1','now-1y','now+2 d',
|
||||
'today+1 s', 'today-1','today-1y','today+2 d', 'now()+1 s', 'now()-1','now()-1y','now()+2 d', 'today()+1 s', 'today()-1','today()-1y','today()+2 d']
|
||||
RAW_OPTR = ['1*10', '1+2', '-2-0','1%2', '2/0', '1&31']
|
||||
|
@ -280,68 +427,97 @@ class TDTestCase:
|
|||
RAW_TSKP_OPTR = [' noW ( ) + 1s', 'nOw( ) + 2D', 'NOW () + 000s', ' today()+1M', 'today( ) - 1w ', 'TodaY ( ) - 1U ']
|
||||
RAW_BOOL = ['true', 'false', ' TRUE ', 'FALSE ', ' tRuE', ' falsE ']
|
||||
RAW_NULL = ['NuLl', 'null ', ' NULL', ' NULL ']
|
||||
RAW_NONE = ['None', 'none ', ' NoNe', ' NONE ']
|
||||
RAW_BINARY_ILLEGAL = ['\\x7f8290', '\\X7f8290', 'x7f8290', '\\x', '\\x7f829']
|
||||
|
||||
OK_VC = [STR_EMPTY, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP,
|
||||
STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, STR_NULL, RAW_INTEGER_P, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M,
|
||||
RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_TSK, RAW_BOOL, RAW_NULL]
|
||||
KO_VC = [RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR]
|
||||
RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_TSK, RAW_BOOL, RAW_NULL, STR_CHINESE, STR_NONE]
|
||||
KO_VC = [RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_CHINESE_ILLEGAL, RAW_NONE]
|
||||
OK_NC = OK_VC
|
||||
KO_NC = KO_VC
|
||||
OK_BI = OK_VC
|
||||
KO_BI = KO_VC
|
||||
OK_TS = [STR_TSK, STR_INTEGER_P, STR_INTEGER_M, STR_TSKP, STR_TS, STR_NULL, RAW_INTEGER_P, RAW_INTEGER_M, RAW_TSK, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, RAW_NULL]
|
||||
KO_TS = [STR_EMPTY, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_MISC, STR_OPTR, STR_TSK_MISC, STR_TSKP_MISC, STR_BOOL, STR_VARBIN,
|
||||
STR_JSON_O, STR_JSON_A, STR_GEO, RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_MISC, RAW_OPTR, RAW_BOOL]
|
||||
STR_JSON_O, STR_JSON_A, STR_GEO, RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_MISC, RAW_OPTR, RAW_BOOL, STR_CHINESE, STR_NONE, STR_TS_ILLEGAL,
|
||||
STR_BINARY, RAW_NONE]
|
||||
OK_BO = [STR_BOOL, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M,RAW_BOOL, STR_NULL, RAW_INTEGER_P, RAW_INTEGER_M,
|
||||
RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_NULL]
|
||||
KO_BO = [STR_EMPTY, STR_TSK, STR_TSKP, STR_TS, STR_MISC, STR_OPTR, STR_TSK_MISC, STR_TSKP_MISC, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK,
|
||||
RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, RAW_MISC, RAW_OPTR]
|
||||
RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, RAW_MISC, RAW_OPTR, STR_CHINESE, STR_NONE, STR_BINARY, RAW_NONE]
|
||||
OK_VB = [STR_EMPTY, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP,
|
||||
STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, STR_NULL, RAW_NULL]
|
||||
KO_VB = [RAW_INTEGER_P, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_TSK, RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR]
|
||||
STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, STR_NULL, RAW_NULL, STR_CHINESE, STR_NONE, STR_BINARY]
|
||||
KO_VB = [RAW_INTEGER_P, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_TSK, RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR,
|
||||
STR_BINARY_ILLEGAL, STR_BINARY_ILLEGAL, RAW_BINARY_ILLEGAL, RAW_NONE]
|
||||
OK_IN = [STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_NULL, RAW_INTEGER_P, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M,
|
||||
RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_NULL]
|
||||
KO_IN = [STR_EMPTY, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK,
|
||||
RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR]
|
||||
OK_UI = [STR_INTEGER_P, STR_FLOAT_P, STR_FLOAT_E_P, STR_NULL, RAW_INTEGER_P, RAW_FLOAT_P, RAW_FLOAT_E_P, RAW_NULL]
|
||||
KO_UI = [STR_EMPTY, STR_MISC, STR_INTEGER_M, STR_FLOAT_M, STR_FLOAT_E_M, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN,
|
||||
STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK, RAW_BOOL, RAW_INTEGER_M, RAW_FLOAT_M, RAW_FLOAT_E_M, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR]
|
||||
BASE_KO_IN = [STR_EMPTY, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK,
|
||||
RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_CHINESE, STR_NONE, STR_BINARY, RAW_NONE]
|
||||
KO_IN = BASE_KO_IN + [RAW_INTEGER_INT_BOUNDARY_ILLEGAL]
|
||||
OK_BIN = OK_IN
|
||||
KO_BIN = BASE_KO_IN + [RAW_INTEGER_BINT_BOUNDARY_ILLEGAL]
|
||||
OK_SIN = OK_IN
|
||||
KO_SIN = BASE_KO_IN + [RAW_INTEGER_SINT_BOUNDARY_ILLEGAL]
|
||||
OK_TIN = OK_IN
|
||||
KO_TIN = BASE_KO_IN + [RAW_INTEGER_TINT_BOUNDARY_ILLEGAL]
|
||||
OK_UI = [STR_INTEGER_P, STR_FLOAT_P, STR_FLOAT_E_P, STR_NULL, RAW_INTEGER_P, RAW_FLOAT_P, RAW_FLOAT_E_P, RAW_NULL, RAW_FLOAT_E_M_SPE]
|
||||
BASE_KO_UI = [STR_EMPTY, STR_MISC, STR_INTEGER_M, STR_FLOAT_M, STR_FLOAT_E_M, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN,
|
||||
STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK, RAW_BOOL, RAW_INTEGER_M, RAW_FLOAT_M, RAW_FLOAT_E_M, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR,
|
||||
STR_CHINESE, STR_NONE, RAW_NONE]
|
||||
KO_UI = BASE_KO_UI + [RAW_INTEGER_UINT_BOUNDARY_ILLEGAL]
|
||||
OK_UBINT = OK_UI
|
||||
KO_UBINT = BASE_KO_UI + [RAW_INTEGER_UBINT_BOUNDARY_ILLEGAL]
|
||||
OK_USINT = OK_UI
|
||||
KO_USINT = BASE_KO_UI + [RAW_INTEGER_USINT_BOUNDARY_ILLEGAL]
|
||||
OK_UTINT = OK_UI
|
||||
KO_UTINT = BASE_KO_UI + [RAW_INTEGER_UTINT_BOUNDARY_ILLEGAL]
|
||||
OK_FL = [RAW_INTEGER_P, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_NULL, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M,
|
||||
RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_NULL]
|
||||
KO_FL = [STR_EMPTY, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK,
|
||||
RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR]
|
||||
RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_CHINESE, STR_NONE, STR_BINARY, RAW_NONE]
|
||||
OK_DB = OK_FL
|
||||
KO_DB = KO_FL
|
||||
OK_GE = [STR_GEO, STR_NULL, RAW_NULL]
|
||||
KO_GE = [STR_EMPTY, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_JSON_O, STR_JSON_A, STR_VARBIN, RAW_TSK, RAW_BOOL, RAW_MISC,
|
||||
RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, RAW_INTEGER_P, RAW_INTEGER_M,
|
||||
RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M]
|
||||
RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, STR_CHINESE, STR_NONE, STR_BINARY, STR_GEO_ILLEGAL, RAW_NONE]
|
||||
OK_JS = [STR_EMPTY, STR_JSON_O, STR_NULL, RAW_NULL]
|
||||
KO_JS = [STR_JSON_A, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_GEO, STR_VARBIN, RAW_TSK, RAW_BOOL, RAW_MISC, RAW_OPTR,
|
||||
RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, RAW_INTEGER_P, RAW_INTEGER_M,
|
||||
RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M]
|
||||
RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, STR_CHINESE, STR_NONE, STR_BINARY, RAW_NONE]
|
||||
|
||||
TEST = [["' POINT(1.0 1.0)'"]]
|
||||
PARAM_LIST = [
|
||||
["db", "stb_vc", "ctb_vc", OK_VC, KO_VC, "\'vc\'", TDDataType.VARCHAR],
|
||||
["db", "stb_nc", "ctb_nc", OK_NC, KO_NC, "\'nc\'", TDDataType.NCHAR],
|
||||
["db", "stb_ts", "ctb_ts", OK_TS, KO_TS, "now", TDDataType.TIMESTAMP],
|
||||
["db", "stb_bo", "ctb_bo", OK_BO, KO_BO, "true", TDDataType.BOOL],
|
||||
["db", "stb_vb", "ctb_vb", OK_VB, KO_VB, "\'\\x12\'", TDDataType.VARBINARY],
|
||||
["db", "stb_in", "ctb_in", OK_IN, KO_IN, "-1", TDDataType.UINT],
|
||||
["db", "stb_ui", "ctb_ui", OK_UI, KO_UI, "1", TDDataType.UINT],
|
||||
["db", "stb_fl", "ctb_fl", OK_FL, KO_FL, "1.0", TDDataType.FLOAT],
|
||||
["db", "stb_db", "ctb_db", OK_DB, KO_DB, "1.0", TDDataType.DOUBLE],
|
||||
["db", "stb_ge", "ctb_ge", OK_GE, KO_GE, "\'POINT(1.0 1.0)\'", TDDataType.GEOMETRY]
|
||||
["db", "stb_vc", "ctb_vc", "ntb_vc", OK_VC, KO_VC, "\'vc\'", TDDataType.VARCHAR],
|
||||
["db", "stb_nc", "ctb_nc", "ntb_nc", OK_NC, KO_NC, "\'nc\'", TDDataType.NCHAR],
|
||||
["db", "stb_bi", "ctb_bi", "ntb_bi", OK_BI, KO_BI, "\'bi\'", TDDataType.BINARY],
|
||||
["db", "stb_ts", "ctb_ts", "ntb_ts", OK_TS, KO_TS, "now", TDDataType.TIMESTAMP],
|
||||
["db", "stb_bo", "ctb_bo", "ntb_bo", OK_BO, KO_BO, "true", TDDataType.BOOL],
|
||||
["db", "stb_vb", "ctb_vb", "ntb_vb", OK_VB, KO_VB, "'hello'", TDDataType.VARBINARY],
|
||||
|
||||
["db", "stb_in", "ctb_in", "ntb_in", OK_IN, KO_IN, "-1", TDDataType.INT],
|
||||
["db", "stb_ui", "ctb_ui", "ntb_ui", OK_UI, KO_UI, "1", TDDataType.UINT],
|
||||
["db", "stb_bin", "ctb_bin", "ntb_bin", OK_BIN, KO_BIN, "-1", TDDataType.BIGINT],
|
||||
["db", "stb_bui", "ctb_bui", "ntb_bui", OK_UBINT, KO_UBINT, "1", TDDataType.UBIGINT],
|
||||
["db", "stb_sin", "ctb_sin", "ntb_sin", OK_SIN, KO_SIN, "-1", TDDataType.SMALLINT],
|
||||
["db", "stb_sui", "ctb_sui", "ntb_sui", OK_USINT, KO_USINT, "1", TDDataType.USMALLINT],
|
||||
["db", "stb_tin", "ctb_tin", "ntb_tin", OK_TIN, KO_TIN, "-1", TDDataType.TINYINT],
|
||||
["db", "stb_tui", "ctb_tui", "ntb_tui", OK_UTINT, KO_UTINT, "1", TDDataType.UTINYINT],
|
||||
|
||||
["db", "stb_fl", "ctb_fl", "ntb_fl", OK_FL, KO_FL, "1.0", TDDataType.FLOAT],
|
||||
["db", "stb_db", "ctb_db", "ntb_db", OK_DB, KO_DB, "1.0", TDDataType.DOUBLE],
|
||||
["db", "stb_ge", "ctb_ge", "ntb_ge", TEST, KO_GE, "\'POINT(100.0 100.0)\'", TDDataType.GEOMETRY]
|
||||
]
|
||||
|
||||
# check with common function
|
||||
for _pl in PARAM_LIST:
|
||||
self.__insert_query_common(_pl[0], _pl[1], _pl[2], _pl[3], _pl[4], _pl[5], _pl[6])
|
||||
self.__insert_query_common(_pl[0], _pl[1], _pl[2], _pl[3], _pl[4], _pl[5], _pl[6], _pl[7])
|
||||
# check json
|
||||
self.__insert_query_json("db", "stb_js", "ctb_js", OK_JS, KO_JS, "\'{\"k1\":\"v1\",\"k2\":\"v2\"}\'")
|
||||
|
||||
|
||||
def run(self):
|
||||
tdLog.printNoPrefix("==========step1:create table")
|
||||
self.__create_tb()
|
||||
self.__insert_query_exec()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue