Merge remote-tracking branch 'origin/3.0' into feat/TD-27337

This commit is contained in:
dapan1121 2024-03-19 16:04:15 +08:00
commit dcc650521a
81 changed files with 11054 additions and 5484 deletions

View File

@ -2821,8 +2821,10 @@ typedef struct {
char* tagName;
int8_t isNull;
int8_t tagType;
int8_t tagFree;
uint32_t nTagVal;
uint8_t* pTagVal;
SArray* pTagArray;
// TSDB_ALTER_TABLE_UPDATE_OPTIONS
int8_t updateTTL;
int32_t newTTL;
@ -3920,11 +3922,11 @@ int32_t tSerializeSMqAskEpReq(void* buf, int32_t bufLen, SMqAskEpReq* pReq);
int32_t tDeserializeSMqAskEpReq(void* buf, int32_t bufLen, SMqAskEpReq* pReq);
int32_t tSerializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq);
int32_t tDeserializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq);
int32_t tDeatroySMqHbReq(SMqHbReq* pReq);
void tDestroySMqHbReq(SMqHbReq* pReq);
int32_t tSerializeSMqHbRsp(void* buf, int32_t bufLen, SMqHbRsp* pRsp);
int32_t tDeserializeSMqHbRsp(void* buf, int32_t bufLen, SMqHbRsp* pRsp);
int32_t tDeatroySMqHbRsp(SMqHbRsp* pRsp);
void tDestroySMqHbRsp(SMqHbRsp* pRsp);
int32_t tSerializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq);
int32_t tDeserializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq);

View File

@ -249,140 +249,142 @@
#define TK_SPLIT 231
#define TK_DELETE 232
#define TK_INSERT 233
#define TK_NULL 234
#define TK_NK_QUESTION 235
#define TK_NK_ALIAS 236
#define TK_NK_ARROW 237
#define TK_ROWTS 238
#define TK_QSTART 239
#define TK_QEND 240
#define TK_QDURATION 241
#define TK_WSTART 242
#define TK_WEND 243
#define TK_WDURATION 244
#define TK_IROWTS 245
#define TK_ISFILLED 246
#define TK_CAST 247
#define TK_NOW 248
#define TK_TODAY 249
#define TK_TIMEZONE 250
#define TK_CLIENT_VERSION 251
#define TK_SERVER_VERSION 252
#define TK_SERVER_STATUS 253
#define TK_CURRENT_USER 254
#define TK_CASE 255
#define TK_WHEN 256
#define TK_THEN 257
#define TK_ELSE 258
#define TK_BETWEEN 259
#define TK_IS 260
#define TK_NK_LT 261
#define TK_NK_GT 262
#define TK_NK_LE 263
#define TK_NK_GE 264
#define TK_NK_NE 265
#define TK_MATCH 266
#define TK_NMATCH 267
#define TK_CONTAINS 268
#define TK_IN 269
#define TK_JOIN 270
#define TK_INNER 271
#define TK_LEFT 272
#define TK_RIGHT 273
#define TK_OUTER 274
#define TK_SEMI 275
#define TK_ANTI 276
#define TK_ASOF 277
#define TK_WINDOW 278
#define TK_WINDOW_OFFSET 279
#define TK_JLIMIT 280
#define TK_SELECT 281
#define TK_NK_HINT 282
#define TK_DISTINCT 283
#define TK_WHERE 284
#define TK_PARTITION 285
#define TK_BY 286
#define TK_SESSION 287
#define TK_STATE_WINDOW 288
#define TK_EVENT_WINDOW 289
#define TK_COUNT_WINDOW 290
#define TK_SLIDING 291
#define TK_FILL 292
#define TK_VALUE 293
#define TK_VALUE_F 294
#define TK_NONE 295
#define TK_PREV 296
#define TK_NULL_F 297
#define TK_LINEAR 298
#define TK_NEXT 299
#define TK_HAVING 300
#define TK_RANGE 301
#define TK_EVERY 302
#define TK_ORDER 303
#define TK_SLIMIT 304
#define TK_SOFFSET 305
#define TK_LIMIT 306
#define TK_OFFSET 307
#define TK_ASC 308
#define TK_NULLS 309
#define TK_ABORT 310
#define TK_AFTER 311
#define TK_ATTACH 312
#define TK_BEFORE 313
#define TK_BEGIN 314
#define TK_BITAND 315
#define TK_BITNOT 316
#define TK_BITOR 317
#define TK_BLOCKS 318
#define TK_CHANGE 319
#define TK_COMMA 320
#define TK_CONCAT 321
#define TK_CONFLICT 322
#define TK_COPY 323
#define TK_DEFERRED 324
#define TK_DELIMITERS 325
#define TK_DETACH 326
#define TK_DIVIDE 327
#define TK_DOT 328
#define TK_EACH 329
#define TK_FAIL 330
#define TK_FILE 331
#define TK_FOR 332
#define TK_GLOB 333
#define TK_ID 334
#define TK_IMMEDIATE 335
#define TK_IMPORT 336
#define TK_INITIALLY 337
#define TK_INSTEAD 338
#define TK_ISNULL 339
#define TK_KEY 340
#define TK_MODULES 341
#define TK_NK_BITNOT 342
#define TK_NK_SEMI 343
#define TK_NOTNULL 344
#define TK_OF 345
#define TK_PLUS 346
#define TK_PRIVILEGE 347
#define TK_RAISE 348
#define TK_RESTRICT 349
#define TK_ROW 350
#define TK_STAR 351
#define TK_STATEMENT 352
#define TK_STRICT 353
#define TK_STRING 354
#define TK_TIMES 355
#define TK_VALUES 356
#define TK_VARIABLE 357
#define TK_WAL 358
#define TK_NK_BIN 234
#define TK_NK_HEX 235
#define TK_NULL 236
#define TK_NK_QUESTION 237
#define TK_NK_ALIAS 238
#define TK_NK_ARROW 239
#define TK_ROWTS 240
#define TK_QSTART 241
#define TK_QEND 242
#define TK_QDURATION 243
#define TK_WSTART 244
#define TK_WEND 245
#define TK_WDURATION 246
#define TK_IROWTS 247
#define TK_ISFILLED 248
#define TK_CAST 249
#define TK_NOW 250
#define TK_TODAY 251
#define TK_TIMEZONE 252
#define TK_CLIENT_VERSION 253
#define TK_SERVER_VERSION 254
#define TK_SERVER_STATUS 255
#define TK_CURRENT_USER 256
#define TK_CASE 257
#define TK_WHEN 258
#define TK_THEN 259
#define TK_ELSE 260
#define TK_BETWEEN 261
#define TK_IS 262
#define TK_NK_LT 263
#define TK_NK_GT 264
#define TK_NK_LE 265
#define TK_NK_GE 266
#define TK_NK_NE 267
#define TK_MATCH 268
#define TK_NMATCH 269
#define TK_CONTAINS 270
#define TK_IN 271
#define TK_JOIN 272
#define TK_INNER 273
#define TK_LEFT 274
#define TK_RIGHT 275
#define TK_OUTER 276
#define TK_SEMI 277
#define TK_ANTI 278
#define TK_ASOF 279
#define TK_WINDOW 280
#define TK_WINDOW_OFFSET 281
#define TK_JLIMIT 282
#define TK_SELECT 283
#define TK_NK_HINT 284
#define TK_DISTINCT 285
#define TK_WHERE 286
#define TK_PARTITION 287
#define TK_BY 288
#define TK_SESSION 289
#define TK_STATE_WINDOW 290
#define TK_EVENT_WINDOW 291
#define TK_COUNT_WINDOW 292
#define TK_SLIDING 293
#define TK_FILL 294
#define TK_VALUE 295
#define TK_VALUE_F 296
#define TK_NONE 297
#define TK_PREV 298
#define TK_NULL_F 299
#define TK_LINEAR 300
#define TK_NEXT 301
#define TK_HAVING 302
#define TK_RANGE 303
#define TK_EVERY 304
#define TK_ORDER 305
#define TK_SLIMIT 306
#define TK_SOFFSET 307
#define TK_LIMIT 308
#define TK_OFFSET 309
#define TK_ASC 310
#define TK_NULLS 311
#define TK_ABORT 312
#define TK_AFTER 313
#define TK_ATTACH 314
#define TK_BEFORE 315
#define TK_BEGIN 316
#define TK_BITAND 317
#define TK_BITNOT 318
#define TK_BITOR 319
#define TK_BLOCKS 320
#define TK_CHANGE 321
#define TK_COMMA 322
#define TK_CONCAT 323
#define TK_CONFLICT 324
#define TK_COPY 325
#define TK_DEFERRED 326
#define TK_DELIMITERS 327
#define TK_DETACH 328
#define TK_DIVIDE 329
#define TK_DOT 330
#define TK_EACH 331
#define TK_FAIL 332
#define TK_FILE 333
#define TK_FOR 334
#define TK_GLOB 335
#define TK_ID 336
#define TK_IMMEDIATE 337
#define TK_IMPORT 338
#define TK_INITIALLY 339
#define TK_INSTEAD 340
#define TK_ISNULL 341
#define TK_KEY 342
#define TK_MODULES 343
#define TK_NK_BITNOT 344
#define TK_NK_SEMI 345
#define TK_NOTNULL 346
#define TK_OF 347
#define TK_PLUS 348
#define TK_PRIVILEGE 349
#define TK_RAISE 350
#define TK_RESTRICT 351
#define TK_ROW 352
#define TK_STAR 353
#define TK_STATEMENT 354
#define TK_STRICT 355
#define TK_STRING 356
#define TK_TIMES 357
#define TK_VALUES 358
#define TK_VARIABLE 359
#define TK_WAL 360
#define TK_NK_SPACE 600
#define TK_NK_COMMENT 601
#define TK_NK_ILLEGAL 602
#define TK_NK_HEX 603 // hex number 0x123
// #define TK_NK_HEX 603 // hex number 0x123
#define TK_NK_OCT 604 // oct number
#define TK_NK_BIN 605 // bin format data 0b111
// #define TK_NK_BIN 605 // bin format data 0b111
#define TK_BATCH_SCAN 606
#define TK_NO_BATCH_SCAN 607
#define TK_SORT_FOR_GROUP 608

View File

@ -44,6 +44,11 @@ int32_t toDoubleEx(const char *z, int32_t n, uint32_t type, double *value);
int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value);
int32_t toUInteger(const char *z, int32_t n, int32_t base, uint64_t *value);
/**
* non floating point integers
*/
int32_t toIntegerPure(const char *z, int32_t n, int32_t base, int64_t *value);
void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32_t type);
void taosVariantDestroy(SVariant *pV);

View File

@ -36,6 +36,7 @@ extern "C" {
#define CACHESCAN_RETRIEVE_LAST_ROW 0x4
#define CACHESCAN_RETRIEVE_LAST 0x8
#define META_READER_LOCK 0x0
#define META_READER_NOLOCK 0x1
#define STREAM_STATE_BUFF_HASH 1

View File

@ -779,7 +779,7 @@ int32_t tmqHbCb(void* param, SDataBuf* pMsg, int32_t code) {
taosWUnLockLatch(&tmq->lock);
taosReleaseRef(tmqMgmt.rsetId, refId);
}
tDeatroySMqHbRsp(&rsp);
tDestroySMqHbRsp(&rsp);
taosMemoryFree(pMsg->pData);
taosMemoryFree(pMsg->pEpSet);
}
@ -861,7 +861,7 @@ void tmqSendHbReq(void* param, void* tmrId) {
asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo);
OVER:
tDeatroySMqHbReq(&req);
tDestroySMqHbReq(&req);
taosTmrReset(tmqSendHbReq, DEFAULT_HEARTBEAT_INTERVAL, param, tmqMgmt.timer, &tmq->hbLiveTimer);
taosReleaseRef(tmqMgmt.rsetId, refId);
}

View File

@ -6201,9 +6201,8 @@ int32_t tDeserializeSMqAskEpReq(void *buf, int32_t bufLen, SMqAskEpReq *pReq) {
return 0;
}
int32_t tDeatroySMqHbRsp(SMqHbRsp *pRsp) {
void tDestroySMqHbRsp(SMqHbRsp *pRsp) {
taosArrayDestroy(pRsp->topicPrivileges);
return 0;
}
int32_t tSerializeSMqHbRsp(void *buf, int32_t bufLen, SMqHbRsp *pRsp) {
@ -6250,13 +6249,12 @@ int32_t tDeserializeSMqHbRsp(void *buf, int32_t bufLen, SMqHbRsp *pRsp) {
return 0;
}
int32_t tDeatroySMqHbReq(SMqHbReq *pReq) {
void tDestroySMqHbReq(SMqHbReq *pReq) {
for (int i = 0; i < taosArrayGetSize(pReq->topics); i++) {
TopicOffsetRows *vgs = taosArrayGet(pReq->topics, i);
if (vgs) taosArrayDestroy(vgs->offsetRows);
}
taosArrayDestroy(pReq->topics);
return 0;
}
int32_t tSerializeSMqHbReq(void *buf, int32_t bufLen, SMqHbReq *pReq) {

View File

@ -34,7 +34,7 @@ const int32_t TYPE_BYTES[21] = {
INT_BYTES, // TSDB_DATA_TYPE_UINT
sizeof(uint64_t), // TSDB_DATA_TYPE_UBIGINT
TSDB_MAX_JSON_TAG_LEN, // TSDB_DATA_TYPE_JSON
TSDB_MAX_TAGS_LEN, // TSDB_DATA_TYPE_VARBINARY: placeholder, not implemented
sizeof(VarDataOffsetT), // TSDB_DATA_TYPE_VARBINARY
TSDB_MAX_TAGS_LEN, // TSDB_DATA_TYPE_DECIMAL: placeholder, not implemented
TSDB_MAX_TAGS_LEN, // TSDB_DATA_TYPE_BLOB: placeholder, not implemented
TSDB_MAX_TAGS_LEN, // TSDB_DATA_TYPE_MEDIUMBLOB: placeholder, not implemented

View File

@ -19,7 +19,7 @@
#include "ttokendef.h"
#include "tvariant.h"
int32_t parseBinaryUInteger(const char *z, int32_t n, uint64_t *value) {
static int32_t parseBinaryUInteger(const char *z, int32_t n, uint64_t *value) {
// skip head 0b
const char *p = z + 2;
int32_t l = n - 2;
@ -45,7 +45,7 @@ int32_t parseBinaryUInteger(const char *z, int32_t n, uint64_t *value) {
return TSDB_CODE_SUCCESS;
}
int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint64_t *value) {
static int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint64_t *value, bool parseFloat) {
// parse sign
bool has_sign = false;
if (z[0] == '-') {
@ -65,8 +65,7 @@ int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint64_t *v
}
errno = 0;
char *endPtr = NULL;
bool parsed = false;
char *endPtr = NULL;
if (z[0] == '0' && n > 2) {
if (z[1] == 'b' || z[1] == 'B') {
// paring as binary
@ -76,44 +75,87 @@ int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint64_t *v
if (z[1] == 'x' || z[1] == 'X') {
// parsing as hex
*value = taosStr2UInt64(z, &endPtr, 16);
parsed = true;
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
return TSDB_CODE_FAILED;
}
return TSDB_CODE_SUCCESS;
}
}
if (!parsed) {
if (parseFloat) {
// parsing as double
double val = taosStr2Double(z, &endPtr);
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
return TSDB_CODE_FAILED;
}
if (val > UINT64_MAX) {
errno = ERANGE;
return TSDB_CODE_FAILED;
}
*value = round(val);
}
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
return TSDB_CODE_FAILED;
}
return TSDB_CODE_SUCCESS;
}
int32_t toDoubleEx(const char *z, int32_t n, uint32_t type, double* value) {
if (n == 0) {
*value = 0;
return TSDB_CODE_SUCCESS;
}
return TSDB_CODE_FAILED;
}
int32_t toDoubleEx(const char *z, int32_t n, uint32_t type, double *value) {
if (n == 0) {
errno = EINVAL;
return TSDB_CODE_FAILED;
}
errno = 0;
char* endPtr = NULL;
*value = taosStr2Double(z, &endPtr);
char *endPtr = NULL;
*value = taosStr2Double(z, &endPtr); // 0x already converted here
if (errno == ERANGE || errno == EINVAL) return TSDB_CODE_FAILED;
if (endPtr - z == n) return TSDB_CODE_SUCCESS;
if (errno == ERANGE || errno == EINVAL) {
return TSDB_CODE_FAILED;
if (type == TK_NK_BIN || type == TK_NK_STRING) {
bool is_neg = false;
uint64_t uv = 0;
if (TSDB_CODE_SUCCESS == parseSignAndUInteger(z, n, &is_neg, &uv, false)) {
*value = is_neg ? -(double)uv : uv;
return TSDB_CODE_SUCCESS;
}
}
if (endPtr - z != n) {
return TSDB_CODE_FAILED;
return TSDB_CODE_FAILED;
}
int32_t toIntegerPure(const char *z, int32_t n, int32_t base, int64_t *value) {
errno = 0;
char *endPtr = NULL;
*value = taosStr2Int64(z, &endPtr, base);
if (endPtr - z == n) {
if (errno == ERANGE || errno == EINVAL) {
return TSDB_CODE_FAILED;
}
return TSDB_CODE_SUCCESS;
}
return TSDB_CODE_SUCCESS;
bool is_neg = false;
uint64_t uv = 0;
int32_t code = parseSignAndUInteger(z, n, &is_neg, &uv, false); // support 0b/0x
if (code == TSDB_CODE_SUCCESS) {
if (is_neg) {
if (uv > 1ull + INT64_MAX) {
*value = INT64_MIN;
return TSDB_CODE_FAILED;
} else {
*value = -(int64_t)uv;
}
} else {
if (uv > INT64_MAX) {
*value = INT64_MAX;
return TSDB_CODE_FAILED;
}
*value = uv;
}
}
return code;
}
int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) {
@ -144,8 +186,8 @@ int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) {
}
if (n == 0) {
*value = 0;
return TSDB_CODE_SUCCESS;
errno = EINVAL;
return TSDB_CODE_FAILED;
}
// 1. try to parse as integer
@ -190,7 +232,7 @@ int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) {
// 2. parse as other
bool is_neg = false;
uint64_t uv = 0;
int32_t code = parseSignAndUInteger(z, n, &is_neg, &uv);
int32_t code = parseSignAndUInteger(z, n, &is_neg, &uv, true);
if (code == TSDB_CODE_SUCCESS) {
// truncate into int64
if (is_neg) {
@ -198,7 +240,7 @@ int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) {
*value = INT64_MIN;
return TSDB_CODE_FAILED;
} else {
*value = -uv;
*value = -(int64_t)uv;
}
} else {
if (uv > INT64_MAX) {
@ -216,9 +258,6 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) {
errno = 0;
char *endPtr = NULL;
const char *p = z;
while (*p == ' ') {
p++;
}
switch (type) {
case TK_NK_INTEGER: {
*value = taosStr2UInt64(p, &endPtr, 10);
@ -246,24 +285,22 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) {
}
if (n == 0) {
*value = 0;
return TSDB_CODE_SUCCESS;
errno = EINVAL;
return TSDB_CODE_FAILED;
}
// 1. parse as integer
*value = taosStr2UInt64(p, &endPtr, 10);
if (*p == '-' && *value) {
return TSDB_CODE_FAILED;
}
if (endPtr - z == n) {
if (errno == ERANGE || errno == EINVAL) {
if (errno == ERANGE || errno == EINVAL || (*p == '-' && *value)) {
return TSDB_CODE_FAILED;
}
return TSDB_CODE_SUCCESS;
} else if (errno == 0 && *endPtr == '.') {
const char *s = endPtr + 1;
const char *end = z + n;
bool pure = true;
bool pure = true;
while (s < end) {
if (*s < '0' || *s > '9') {
pure = false;
@ -275,13 +312,16 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) {
if (endPtr + 1 < end && endPtr[1] > '4' && *value < UINT64_MAX) {
(*value)++;
}
if (*p == '-' && *value) {
return TSDB_CODE_FAILED;
}
return TSDB_CODE_SUCCESS;
}
}
// 2. parse as other
// 2. parse as other
bool is_neg = false;
int32_t code = parseSignAndUInteger(z, n, &is_neg, value);
int32_t code = parseSignAndUInteger(z, n, &is_neg, value, true);
if (is_neg) {
if (TSDB_CODE_SUCCESS == code && 0 == *value) {
return TSDB_CODE_SUCCESS;

View File

@ -24,27 +24,22 @@ extern "C" {
enum {
MQ_CONSUMER_STATUS_REBALANCE = 1,
// MQ_CONSUMER_STATUS__MODIFY_IN_REB, // this value is not used anymore
MQ_CONSUMER_STATUS_READY,
MQ_CONSUMER_STATUS_LOST,
// MQ_CONSUMER_STATUS__LOST_IN_REB, // this value is not used anymore
// MQ_CONSUMER_STATUS__LOST_REBD,
};\
};
int32_t mndInitConsumer(SMnode *pMnode);
void mndCleanupConsumer(SMnode *pMnode);
void mndDropConsumerFromSdb(SMnode *pMnode, int64_t consumerId, SRpcHandleInfo* info);
void mndSendConsumerMsg(SMnode *pMnode, int64_t consumerId, uint16_t msgType, SRpcHandleInfo* info);
SMqConsumerObj *mndAcquireConsumer(SMnode *pMnode, int64_t consumerId);
void mndReleaseConsumer(SMnode *pMnode, SMqConsumerObj *pConsumer);
SMqConsumerObj *mndCreateConsumer(int64_t consumerId, const char *cgroup);
SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer);
SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw);
int32_t mndSetConsumerCommitLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *pConsumer);
int32_t mndSetConsumerDropLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *pConsumer);
int32_t mndSetConsumerCommitLogs(STrans *pTrans, SMqConsumerObj *pConsumer);
int32_t mndSetConsumerDropLogs(STrans *pTrans, SMqConsumerObj *pConsumer);
const char *mndConsumerStatusName(int status);

View File

@ -149,6 +149,7 @@ typedef enum {
CONSUMER_REMOVE_REB, // remove after rebalance
CONSUMER_UPDATE_REC, // update after recover
CONSUMER_UPDATE_SUB, // update after subscribe req
CONSUMER_INSERT_SUB,
} ECsmUpdateType;
typedef struct {
@ -556,8 +557,9 @@ typedef struct {
int32_t resetOffsetCfg;
} SMqConsumerObj;
SMqConsumerObj* tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_LEN]);
void tDeleteSMqConsumerObj(SMqConsumerObj* pConsumer, bool isDeleted);
SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType, char *topic, SCMSubscribeReq *subscribe);
void tClearSMqConsumerObj(SMqConsumerObj* pConsumer);
void tDeleteSMqConsumerObj(SMqConsumerObj* pConsumer);
int32_t tEncodeSMqConsumerObj(void** buf, const SMqConsumerObj* pConsumer);
void* tDecodeSMqConsumerObj(const void* buf, SMqConsumerObj* pConsumer, int8_t sver);

View File

@ -30,7 +30,7 @@ SMqSubscribeObj *mndAcquireSubscribe(SMnode *pMnode, const char *CGroup, const c
SMqSubscribeObj *mndAcquireSubscribeByKey(SMnode *pMnode, const char *key);
void mndReleaseSubscribe(SMnode *pMnode, SMqSubscribeObj *pSub);
int32_t mndMakeSubscribeKey(char *key, const char *cgroup, const char *topicName);
void mndMakeSubscribeKey(char *key, const char *cgroup, const char *topicName);
int32_t mndDropSubByTopic(SMnode *pMnode, STrans *pTrans, const char *topic);
int32_t mndSetDropSubCommitLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeObj *pSub);

File diff suppressed because it is too large Load Diff

View File

@ -249,7 +249,9 @@ void *tDecodeSMqVgEp(const void *buf, SMqVgEp *pVgEp, int8_t sver) {
return (void *)buf;
}
SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char *cgroup) {
static void *topicNameDup(void *p) { return taosStrdup((char *)p); }
SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType, char *topic, SCMSubscribeReq *subscribe) {
SMqConsumerObj *pConsumer = taosMemoryCalloc(1, sizeof(SMqConsumerObj));
if (pConsumer == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
@ -264,36 +266,64 @@ SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char *cgroup) {
pConsumer->hbStatus = 0;
taosInitRWLatch(&pConsumer->lock);
pConsumer->createTime = taosGetTimestampMs();
pConsumer->updateType = updateType;
pConsumer->currentTopics = taosArrayInit(0, sizeof(void *));
pConsumer->rebNewTopics = taosArrayInit(0, sizeof(void *));
pConsumer->rebRemovedTopics = taosArrayInit(0, sizeof(void *));
pConsumer->assignedTopics = taosArrayInit(0, sizeof(void *));
if (updateType == CONSUMER_ADD_REB){
pConsumer->rebNewTopics = taosArrayInit(0, sizeof(void *));
if(pConsumer->rebNewTopics == NULL){
terrno = TSDB_CODE_OUT_OF_MEMORY;
goto END;
}
if (pConsumer->currentTopics == NULL || pConsumer->rebNewTopics == NULL || pConsumer->rebRemovedTopics == NULL ||
pConsumer->assignedTopics == NULL) {
taosArrayDestroy(pConsumer->currentTopics);
taosArrayDestroy(pConsumer->rebNewTopics);
taosArrayDestroy(pConsumer->rebRemovedTopics);
taosArrayDestroy(pConsumer->assignedTopics);
taosMemoryFree(pConsumer);
return NULL;
char* topicTmp = taosStrdup(topic);
taosArrayPush(pConsumer->rebNewTopics, &topicTmp);
}else if (updateType == CONSUMER_REMOVE_REB) {
pConsumer->rebRemovedTopics = taosArrayInit(0, sizeof(void *));
if(pConsumer->rebRemovedTopics == NULL){
terrno = TSDB_CODE_OUT_OF_MEMORY;
goto END;
}
char* topicTmp = taosStrdup(topic);
taosArrayPush(pConsumer->rebRemovedTopics, &topicTmp);
}else if (updateType == CONSUMER_INSERT_SUB){
tstrncpy(pConsumer->clientId, subscribe->clientId, tListLen(pConsumer->clientId));
pConsumer->withTbName = subscribe->withTbName;
pConsumer->autoCommit = subscribe->autoCommit;
pConsumer->autoCommitInterval = subscribe->autoCommitInterval;
pConsumer->resetOffsetCfg = subscribe->resetOffsetCfg;
pConsumer->rebNewTopics = taosArrayDup(subscribe->topicNames, topicNameDup);
if (pConsumer->rebNewTopics == NULL){
terrno = TSDB_CODE_OUT_OF_MEMORY;
goto END;
}
pConsumer->assignedTopics = subscribe->topicNames;
subscribe->topicNames = NULL;
}else if (updateType == CONSUMER_UPDATE_SUB){
pConsumer->assignedTopics = subscribe->topicNames;
subscribe->topicNames = NULL;
}
pConsumer->createTime = taosGetTimestampMs();
return pConsumer;
END:
tDeleteSMqConsumerObj(pConsumer);
return NULL;
}
void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer, bool delete) {
void tClearSMqConsumerObj(SMqConsumerObj *pConsumer) {
if (pConsumer == NULL) return;
taosArrayDestroyP(pConsumer->currentTopics, (FDelete)taosMemoryFree);
taosArrayDestroyP(pConsumer->rebNewTopics, (FDelete)taosMemoryFree);
taosArrayDestroyP(pConsumer->rebRemovedTopics, (FDelete)taosMemoryFree);
taosArrayDestroyP(pConsumer->assignedTopics, (FDelete)taosMemoryFree);
if (delete) {
taosMemoryFree(pConsumer);
}
}
void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer) {
tClearSMqConsumerObj(pConsumer);
taosMemoryFree(pConsumer);
}
int32_t tEncodeSMqConsumerObj(void **buf, const SMqConsumerObj *pConsumer) {
@ -548,6 +578,7 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
}
void tDeleteSubscribeObj(SMqSubscribeObj *pSub) {
if (pSub == NULL) return;
void *pIter = NULL;
while (1) {
pIter = taosHashIterate(pSub->consumerHash, pIter);

View File

@ -1508,6 +1508,8 @@ static int32_t mndRetrieveStreamTask(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
}
}
pBlock->info.rows = numOfRows;
destroyStreamTaskIter(pIter);
taosRUnLockLatch(&pStream->lock);

File diff suppressed because it is too large Load Diff

View File

@ -353,6 +353,66 @@ static int32_t extractTopicTbInfo(SNode *pAst, SMqTopicObj *pTopic) {
return 0;
}
static int32_t sendCheckInfoToVnode(STrans *pTrans, SMnode *pMnode, SMqTopicObj *topicObj){
STqCheckInfo info;
memcpy(info.topic, topicObj->name, TSDB_TOPIC_FNAME_LEN);
info.ntbUid = topicObj->ntbUid;
info.colIdList = topicObj->ntbColIds;
// broadcast forbid alter info
void *pIter = NULL;
SSdb *pSdb = pMnode->pSdb;
SVgObj *pVgroup = NULL;
int32_t code = 0;
void *buf = NULL;
while (1) {
// iterate vg
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
if (pIter == NULL) break;
if (!mndVgroupInDb(pVgroup, topicObj->dbUid)) {
sdbRelease(pSdb, pVgroup);
continue;
}
// encoder check alter info
int32_t len;
tEncodeSize(tEncodeSTqCheckInfo, &info, len, code);
if (code != 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
goto END;
}
buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len);
void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
SEncoder encoder;
tEncoderInit(&encoder, abuf, len);
code = tEncodeSTqCheckInfo(&encoder, &info);
if (code < 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
goto END;
}
tEncoderClear(&encoder);
((SMsgHead *)buf)->vgId = htonl(pVgroup->vgId);
// add redo action
STransAction action = {0};
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
action.pCont = buf;
action.contLen = sizeof(SMsgHead) + len;
action.msgType = TDMT_VND_TMQ_ADD_CHECKINFO;
code = mndTransAppendRedoAction(pTrans, &action);
if (code != 0) {
goto END;
}
sdbRelease(pSdb, pVgroup);
buf = NULL;
}
END:
taosMemoryFree(buf);
sdbRelease(pSdb, pVgroup);
sdbCancelFetch(pSdb, pIter);
return code;
}
static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *pCreate, SDbObj *pDb,
const char *userName) {
mInfo("start to create topic:%s", pCreate->name);
@ -396,13 +456,6 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
topicObj.withMeta = pCreate->withMeta;
if (pCreate->subType == TOPIC_SUB_TYPE__COLUMN) {
if (pCreate->withMeta) {
terrno = TSDB_CODE_MND_INVALID_TOPIC_OPTION;
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
code = terrno;
goto _OUT;
}
topicObj.ast = taosStrdup(pCreate->ast);
topicObj.astLen = strlen(pCreate->ast) + 1;
@ -474,59 +527,9 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
if (topicObj.ntbUid != 0) {
STqCheckInfo info;
memcpy(info.topic, topicObj.name, TSDB_TOPIC_FNAME_LEN);
info.ntbUid = topicObj.ntbUid;
info.colIdList = topicObj.ntbColIds;
// broadcast forbid alter info
void *pIter = NULL;
SSdb *pSdb = pMnode->pSdb;
SVgObj *pVgroup = NULL;
while (1) {
// iterate vg
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
if (pIter == NULL) break;
if (!mndVgroupInDb(pVgroup, topicObj.dbUid)) {
sdbRelease(pSdb, pVgroup);
continue;
}
// encoder check alter info
int32_t len;
tEncodeSize(tEncodeSTqCheckInfo, &info, len, code);
if (code < 0) {
sdbRelease(pSdb, pVgroup);
sdbCancelFetch(pSdb, pIter);
goto _OUT;
}
void *buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len);
void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
SEncoder encoder;
tEncoderInit(&encoder, abuf, len);
if (tEncodeSTqCheckInfo(&encoder, &info) < 0) {
taosMemoryFree(buf);
sdbRelease(pSdb, pVgroup);
sdbCancelFetch(pSdb, pIter);
code = -1;
goto _OUT;
}
tEncoderClear(&encoder);
((SMsgHead *)buf)->vgId = htonl(pVgroup->vgId);
// add redo action
STransAction action = {0};
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
action.pCont = buf;
action.contLen = sizeof(SMsgHead) + len;
action.msgType = TDMT_VND_TMQ_ADD_CHECKINFO;
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
taosMemoryFree(buf);
sdbRelease(pSdb, pVgroup);
sdbCancelFetch(pSdb, pIter);
code = -1;
goto _OUT;
}
buf = NULL;
sdbRelease(pSdb, pVgroup);
code = sendCheckInfoToVnode(pTrans, pMnode, &topicObj);
if (code != 0){
goto _OUT;
}
}
@ -618,7 +621,7 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
tNameFromString(&topicName, createTopicReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
//reuse this function for topic
auditRecord(pReq, pMnode->clusterId, "createTopic", dbname.dbname, topicName.dbname,
auditRecord(pReq, pMnode->clusterId, "createTopic", dbname.dbname, topicName.dbname,
createTopicReq.sql, strlen(createTopicReq.sql));
_OVER:
@ -653,9 +656,104 @@ _OVER:
return code;
}
static bool checkTopic(SArray *topics, char *topicName){
int32_t sz = taosArrayGetSize(topics);
for (int32_t i = 0; i < sz; i++) {
char *name = taosArrayGetP(topics, i);
if (strcmp(name, topicName) == 0) {
return true;
}
}
return false;
}
static int32_t mndDropConsumerByTopic(SMnode *pMnode, STrans *pTrans, char *topicName){
int32_t code = 0;
SSdb *pSdb = pMnode->pSdb;
void *pIter = NULL;
SMqConsumerObj *pConsumer = NULL;
while (1) {
pIter = sdbFetch(pSdb, SDB_CONSUMER, pIter, (void **)&pConsumer);
if (pIter == NULL) {
break;
}
bool found = checkTopic(pConsumer->assignedTopics, topicName);
if (found){
if (pConsumer->status == MQ_CONSUMER_STATUS_LOST) {
code = mndSetConsumerDropLogs(pTrans, pConsumer);
if (code != 0) {
goto end;
}
sdbRelease(pSdb, pConsumer);
continue;
}
mError("topic:%s, failed to drop since subscribed by consumer:0x%" PRIx64 ", in consumer group %s",
topicName, pConsumer->consumerId, pConsumer->cgroup);
code = TSDB_CODE_MND_TOPIC_SUBSCRIBED;
goto end;
}
if (checkTopic(pConsumer->rebNewTopics, topicName) || checkTopic(pConsumer->rebRemovedTopics, topicName)) {
code = TSDB_CODE_MND_TOPIC_SUBSCRIBED;
mError("topic:%s, failed to drop since subscribed by consumer:%" PRId64 ", in consumer group %s (reb new)",
topicName, pConsumer->consumerId, pConsumer->cgroup);
goto end;
}
sdbRelease(pSdb, pConsumer);
}
end:
sdbRelease(pSdb, pConsumer);
sdbCancelFetch(pSdb, pIter);
return code;
}
static int32_t mndDropCheckInfoByTopic(SMnode *pMnode, STrans *pTrans, SMqTopicObj *pTopic){
// broadcast to all vnode
void *pIter = NULL;
SVgObj *pVgroup = NULL;
int32_t code = 0;
SSdb *pSdb = pMnode->pSdb;
void *buf = NULL;
while (1) {
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
if (pIter == NULL) break;
if (!mndVgroupInDb(pVgroup, pTopic->dbUid)) {
sdbRelease(pSdb, pVgroup);
continue;
}
buf = taosMemoryCalloc(1, sizeof(SMsgHead) + TSDB_TOPIC_FNAME_LEN);
if (buf == NULL){
code = TSDB_CODE_OUT_OF_MEMORY;
goto end;
}
void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
((SMsgHead *)buf)->vgId = htonl(pVgroup->vgId);
memcpy(abuf, pTopic->name, TSDB_TOPIC_FNAME_LEN);
STransAction action = {0};
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
action.pCont = buf;
action.contLen = sizeof(SMsgHead) + TSDB_TOPIC_FNAME_LEN;
action.msgType = TDMT_VND_TMQ_DEL_CHECKINFO;
code = mndTransAppendRedoAction(pTrans, &action);
if (code != 0) {
taosMemoryFree(buf);
goto end;
}
sdbRelease(pSdb, pVgroup);
}
end:
sdbRelease(pSdb, pVgroup);
sdbCancelFetch(pSdb, pIter);
return code;
}
static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
SMnode *pMnode = pReq->info.node;
SSdb *pSdb = pMnode->pSdb;
SMDropTopicReq dropReq = {0};
int32_t code = 0;
SMqTopicObj *pTopic = NULL;
@ -705,68 +803,9 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
goto end;
}
void *pIter = NULL;
SMqConsumerObj *pConsumer;
while (1) {
pIter = sdbFetch(pSdb, SDB_CONSUMER, pIter, (void **)&pConsumer);
if (pIter == NULL) {
break;
}
bool found = false;
int32_t sz = taosArrayGetSize(pConsumer->assignedTopics);
for (int32_t i = 0; i < sz; i++) {
char *name = taosArrayGetP(pConsumer->assignedTopics, i);
if (strcmp(name, pTopic->name) == 0) {
found = true;
break;
}
}
if (found){
if (pConsumer->status == MQ_CONSUMER_STATUS_LOST) {
mndDropConsumerFromSdb(pMnode, pConsumer->consumerId, &pReq->info);
mndReleaseConsumer(pMnode, pConsumer);
continue;
}
mndReleaseConsumer(pMnode, pConsumer);
sdbCancelFetch(pSdb, pIter);
terrno = TSDB_CODE_MND_TOPIC_SUBSCRIBED;
mError("topic:%s, failed to drop since subscribed by consumer:0x%" PRIx64 ", in consumer group %s",
dropReq.name, pConsumer->consumerId, pConsumer->cgroup);
code = -1;
goto end;
}
sz = taosArrayGetSize(pConsumer->rebNewTopics);
for (int32_t i = 0; i < sz; i++) {
char *name = taosArrayGetP(pConsumer->rebNewTopics, i);
if (strcmp(name, pTopic->name) == 0) {
mndReleaseConsumer(pMnode, pConsumer);
sdbCancelFetch(pSdb, pIter);
terrno = TSDB_CODE_MND_TOPIC_SUBSCRIBED;
mError("topic:%s, failed to drop since subscribed by consumer:%" PRId64 ", in consumer group %s (reb new)",
dropReq.name, pConsumer->consumerId, pConsumer->cgroup);
code = -1;
goto end;
}
}
sz = taosArrayGetSize(pConsumer->rebRemovedTopics);
for (int32_t i = 0; i < sz; i++) {
char *name = taosArrayGetP(pConsumer->rebRemovedTopics, i);
if (strcmp(name, pTopic->name) == 0) {
mndReleaseConsumer(pMnode, pConsumer);
sdbCancelFetch(pSdb, pIter);
terrno = TSDB_CODE_MND_TOPIC_SUBSCRIBED;
mError("topic:%s, failed to drop since subscribed by consumer:%" PRId64 ", in consumer group %s (reb remove)",
dropReq.name, pConsumer->consumerId, pConsumer->cgroup);
code = -1;
goto end;
}
}
sdbRelease(pSdb, pConsumer);
code = mndDropConsumerByTopic(pMnode, pTrans, dropReq.name);
if (code != 0) {
goto end;
}
code = mndDropSubByTopic(pMnode, pTrans, dropReq.name);
@ -776,36 +815,9 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
}
if (pTopic->ntbUid != 0) {
// broadcast to all vnode
pIter = NULL;
SVgObj *pVgroup = NULL;
while (1) {
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
if (pIter == NULL) break;
if (!mndVgroupInDb(pVgroup, pTopic->dbUid)) {
sdbRelease(pSdb, pVgroup);
continue;
}
void *buf = taosMemoryCalloc(1, sizeof(SMsgHead) + TSDB_TOPIC_FNAME_LEN);
void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
((SMsgHead *)buf)->vgId = htonl(pVgroup->vgId);
memcpy(abuf, pTopic->name, TSDB_TOPIC_FNAME_LEN);
STransAction action = {0};
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
action.pCont = buf;
action.contLen = sizeof(SMsgHead) + TSDB_TOPIC_FNAME_LEN;
action.msgType = TDMT_VND_TMQ_DEL_CHECKINFO;
code = mndTransAppendRedoAction(pTrans, &action);
if (code != 0) {
taosMemoryFree(buf);
sdbRelease(pSdb, pVgroup);
sdbCancelFetch(pSdb, pIter);
goto end;
}
sdbRelease(pSdb, pVgroup);
code = mndDropCheckInfoByTopic(pMnode, pTrans, pTopic);
if (code != 0) {
goto end;
}
}
@ -822,7 +834,6 @@ end:
SName name = {0};
tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
//reuse this function for topic
auditRecord(pReq, pMnode->clusterId, "dropTopic", name.dbname, name.tname, dropReq.sql, dropReq.sqlLen);

View File

@ -143,7 +143,7 @@ tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name) {
int metaGetTableNameByUid(void *pVnode, uint64_t uid, char *tbName) {
int code = 0;
SMetaReader mr = {0};
metaReaderDoInit(&mr, ((SVnode *)pVnode)->pMeta, 0);
metaReaderDoInit(&mr, ((SVnode *)pVnode)->pMeta, META_READER_LOCK);
code = metaReaderGetTableEntryByUid(&mr, uid);
if (code < 0) {
metaReaderClear(&mr);
@ -159,7 +159,7 @@ int metaGetTableNameByUid(void *pVnode, uint64_t uid, char *tbName) {
int metaGetTableSzNameByUid(void *meta, uint64_t uid, char *tbName) {
int code = 0;
SMetaReader mr = {0};
metaReaderDoInit(&mr, (SMeta *)meta, 0);
metaReaderDoInit(&mr, (SMeta *)meta, META_READER_LOCK);
code = metaReaderGetTableEntryByUid(&mr, uid);
if (code < 0) {
metaReaderClear(&mr);
@ -174,7 +174,7 @@ int metaGetTableSzNameByUid(void *meta, uint64_t uid, char *tbName) {
int metaGetTableUidByName(void *pVnode, char *tbName, uint64_t *uid) {
int code = 0;
SMetaReader mr = {0};
metaReaderDoInit(&mr, ((SVnode *)pVnode)->pMeta, 0);
metaReaderDoInit(&mr, ((SVnode *)pVnode)->pMeta, META_READER_LOCK);
SMetaReader *pReader = &mr;
@ -195,7 +195,7 @@ int metaGetTableUidByName(void *pVnode, char *tbName, uint64_t *uid) {
int metaGetTableTypeByName(void *pVnode, char *tbName, ETableType *tbType) {
int code = 0;
SMetaReader mr = {0};
metaReaderDoInit(&mr, ((SVnode *)pVnode)->pMeta, 0);
metaReaderDoInit(&mr, ((SVnode *)pVnode)->pMeta, META_READER_LOCK);
code = metaGetTableEntryByName(&mr, tbName);
if (code == 0) *tbType = mr.me.type;
@ -215,7 +215,7 @@ int metaReadNext(SMetaReader *pReader) {
int metaGetTableTtlByUid(void *meta, uint64_t uid, int64_t *ttlDays) {
int code = -1;
SMetaReader mr = {0};
metaReaderDoInit(&mr, (SMeta *)meta, 0);
metaReaderDoInit(&mr, (SMeta *)meta, META_READER_LOCK);
code = metaReaderGetTableEntryByUid(&mr, uid);
if (code < 0) {
goto _exit;
@ -275,7 +275,7 @@ void metaPauseTbCursor(SMTbCursor *pTbCur) {
}
void metaResumeTbCursor(SMTbCursor *pTbCur, int8_t first) {
if (pTbCur->paused) {
metaReaderDoInit(&pTbCur->mr, pTbCur->pMeta, 0);
metaReaderDoInit(&pTbCur->mr, pTbCur->pMeta, META_READER_LOCK);
tdbTbcOpen(((SMeta *)pTbCur->pMeta)->pUidIdx, (TBC **)&pTbCur->pDbc, NULL);
@ -820,7 +820,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid, bool deepCopy) {
}
SMetaReader mr = {0};
metaReaderDoInit(&mr, pMeta, 0);
metaReaderDoInit(&mr, pMeta, META_READER_LOCK);
int64_t smaId;
int smaIdx = 0;
STSma *pTSma = NULL;
@ -875,7 +875,7 @@ _err:
STSma *metaGetSmaInfoByIndex(SMeta *pMeta, int64_t indexUid) {
STSma *pTSma = NULL;
SMetaReader mr = {0};
metaReaderDoInit(&mr, pMeta, 0);
metaReaderDoInit(&mr, pMeta, META_READER_LOCK);
if (metaReaderGetTableEntryByUid(&mr, indexUid) < 0) {
metaWarn("vgId:%d, failed to get table entry for smaId:%" PRIi64, TD_VID(pMeta->pVnode), indexUid);
metaReaderClear(&mr);

View File

@ -37,7 +37,7 @@ int32_t metaCreateTSma(SMeta *pMeta, int64_t version, SSmaCfg *pCfg) {
// validate req
// save smaIndex
metaReaderDoInit(&mr, pMeta, 0);
metaReaderDoInit(&mr, pMeta, META_READER_LOCK);
if (metaReaderGetTableEntryByUidCache(&mr, pCfg->indexUid) == 0) {
#if 1
terrno = TSDB_CODE_TSMA_ALREADY_EXIST;

View File

@ -819,7 +819,7 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs
}
// validate req
metaReaderDoInit(&mr, pMeta, 0);
metaReaderDoInit(&mr, pMeta, META_READER_LOCK);
if (metaGetTableEntryByName(&mr, pReq->name) == 0) {
if (pReq->type == TSDB_CHILD_TABLE && pReq->ctb.suid != mr.me.ctbEntry.suid) {
terrno = TSDB_CODE_TDB_TABLE_IN_OTHER_STABLE;

View File

@ -1097,7 +1097,7 @@ static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables) {
}
int64_t nRsmaTables = 0;
metaReaderDoInit(&mr, SMA_META(pSma), 0);
metaReaderDoInit(&mr, SMA_META(pSma), META_READER_LOCK);
if (!(uidStore.tbUids = taosArrayInit(1024, sizeof(tb_uid_t)))) {
code = TSDB_CODE_OUT_OF_MEMORY;
TSDB_CHECK_CODE(code, lino, _exit);

View File

@ -88,10 +88,6 @@ int32_t tqMetaOpen(STQ* pTq) {
return -1;
}
// if (tqMetaRestoreHandle(pTq) < 0) {
// return -1;
// }
if (tqMetaRestoreCheckInfo(pTq) < 0) {
return -1;
}
@ -167,32 +163,30 @@ int32_t tqMetaRestoreCheckInfo(STQ* pTq) {
void* pVal = NULL;
int vLen = 0;
SDecoder decoder;
int32_t code = 0;
tdbTbcMoveToFirst(pCur);
while (tdbTbcNext(pCur, &pKey, &kLen, &pVal, &vLen) == 0) {
STqCheckInfo info;
tDecoderInit(&decoder, (uint8_t*)pVal, vLen);
if (tDecodeSTqCheckInfo(&decoder, &info) < 0) {
code = tDecodeSTqCheckInfo(&decoder, &info);
if (code != 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
tdbFree(pKey);
tdbFree(pVal);
tdbTbcClose(pCur);
return -1;
goto END;
}
tDecoderClear(&decoder);
if (taosHashPut(pTq->pCheckInfo, info.topic, strlen(info.topic), &info, sizeof(STqCheckInfo)) < 0) {
code = taosHashPut(pTq->pCheckInfo, info.topic, strlen(info.topic), &info, sizeof(STqCheckInfo));
if (code != 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
tdbFree(pKey);
tdbFree(pVal);
tdbTbcClose(pCur);
return -1;
goto END;
}
}
END:
tdbFree(pKey);
tdbFree(pVal);
tdbTbcClose(pCur);
return 0;
return code;
}
int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) {

View File

@ -115,7 +115,7 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) {
}
SMetaReader mr = {0};
metaReaderDoInit(&mr, pHandle->execHandle.pTqReader->pVnodeMeta, 0);
metaReaderDoInit(&mr, pHandle->execHandle.pTqReader->pVnodeMeta, META_READER_LOCK);
if (metaGetTableEntryByName(&mr, req.tbName) < 0) {
metaReaderClear(&mr);
@ -666,20 +666,19 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
int32_t targetIdx = 0;
int32_t sourceIdx = 0;
while (targetIdx < colActual) {
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx);
if (sourceIdx >= numOfCols) {
tqError("tqRetrieveDataBlock sourceIdx:%d >= numOfCols:%d", sourceIdx, numOfCols);
return -1;
tqError("lostdata tqRetrieveDataBlock sourceIdx:%d >= numOfCols:%d", sourceIdx, numOfCols);
colDataSetNNULL(pColData, 0, numOfRows);
targetIdx++;
continue;
}
SColData* pCol = taosArrayGet(pCols, sourceIdx);
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx);
SColVal colVal;
if (pCol->nVal != numOfRows) {
tqError("tqRetrieveDataBlock pCol->nVal:%d != numOfRows:%d", pCol->nVal, numOfRows);
return -1;
}
tqTrace("lostdata colActual:%d, sourceIdx:%d, targetIdx:%d, numOfCols:%d, source cid:%d, dst cid:%d", colActual, sourceIdx, targetIdx, numOfCols, pCol->cid, pColData->info.colId);
if (pCol->cid < pColData->info.colId) {
sourceIdx++;
} else if (pCol->cid == pColData->info.colId) {
@ -693,7 +692,7 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
sourceIdx++;
targetIdx++;
} else {
colDataSetNNULL(pColData, 0, pCol->nVal);
colDataSetNNULL(pColData, 0, numOfRows);
targetIdx++;
}
}
@ -712,9 +711,6 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
SColVal colVal;
tRowGet(pRow, pTSchema, sourceIdx, &colVal);
if (colVal.cid < pColData->info.colId) {
// tqDebug("colIndex:%d column id:%d in row, ignore, the required colId:%d, total cols in
// schema:%d",
// sourceIdx, colVal.cid, pColData->info.colId, pTSchema->numOfCols);
sourceIdx++;
continue;
} else if (colVal.cid == pColData->info.colId) {

View File

@ -47,7 +47,7 @@ static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, STaosxRsp* pRsp
static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, STaosxRsp* pRsp, int32_t n) {
SMetaReader mr = {0};
metaReaderDoInit(&mr, pTq->pVnode->pMeta, 0);
metaReaderDoInit(&mr, pTq->pVnode->pMeta, META_READER_LOCK);
// TODO add reference to gurantee success
if (metaReaderGetTableEntryByUidCache(&mr, uid) < 0) {

View File

@ -612,7 +612,7 @@ int32_t doWaitForDstTableCreated(SVnode* pVnode, SStreamTask* pTask, STableSinkI
// wait for the table to be created
SMetaReader mr = {0};
metaReaderDoInit(&mr, pVnode->pMeta, 0);
metaReaderDoInit(&mr, pVnode->pMeta, META_READER_LOCK);
int32_t code = metaGetTableEntryByName(&mr, dstTableName);
if (code == 0) { // table already exists, check its type and uid
@ -705,7 +705,7 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat
// those mismatched table uids. Only the FIRST table has the correct table uid, and those remain all have
// randomly generated, but false table uid in the WAL.
SMetaReader mr = {0};
metaReaderDoInit(&mr, pVnode->pMeta, 0);
metaReaderDoInit(&mr, pVnode->pMeta, META_READER_LOCK);
// table not in cache, let's try the extract it from tsdb meta
if (metaGetTableEntryByName(&mr, dstTableName) < 0) {

View File

@ -2014,7 +2014,7 @@ static tb_uid_t getTableSuidByUid(tb_uid_t uid, STsdb *pTsdb) {
tb_uid_t suid = 0;
SMetaReader mr = {0};
metaReaderDoInit(&mr, pTsdb->pVnode->pMeta, 0);
metaReaderDoInit(&mr, pTsdb->pVnode->pMeta, META_READER_LOCK);
if (metaReaderGetTableEntryByUidCache(&mr, uid) < 0) {
metaReaderClear(&mr); // table not esist
return 0;

View File

@ -5036,7 +5036,7 @@ int64_t tsdbGetNumOfRowsInMemTable2(STsdbReader* pReader) {
int32_t tsdbGetTableSchema(SMeta* pMeta, int64_t uid, STSchema** pSchema, int64_t* suid) {
SMetaReader mr = {0};
metaReaderDoInit(&mr, pMeta, 0);
metaReaderDoInit(&mr, pMeta, META_READER_LOCK);
int32_t code = metaReaderGetTableEntryByUidCache(&mr, uid);
if (code != TSDB_CODE_SUCCESS) {
terrno = TSDB_CODE_TDB_INVALID_TABLE_ID;

View File

@ -584,13 +584,30 @@ struct STsdbSnapWriter {
// APIs
static int32_t tsdbSnapWriteTimeSeriesRow(STsdbSnapWriter* writer, SRowInfo* row) {
int32_t code = 0;
int32_t lino = 0;
int32_t code = 0;
int32_t lino = 0;
TABLEID tbid = {0};
SMetaInfo info;
while (writer->ctx->hasData) {
SRowInfo* row1 = tsdbIterMergerGetData(writer->ctx->dataIterMerger);
if (row1 == NULL) {
writer->ctx->hasData = false;
SRowInfo* row1;
for (;;) {
row1 = tsdbIterMergerGetData(writer->ctx->dataIterMerger);
if (row1 == NULL) {
writer->ctx->hasData = false;
} else if (row1->uid != tbid.uid) {
tbid.suid = row1->suid;
tbid.uid = row1->uid;
if (metaGetInfo(writer->tsdb->pVnode->pMeta, tbid.uid, &info, NULL) != 0) {
code = tsdbIterMergerSkipTableData(writer->ctx->dataIterMerger, &tbid);
TSDB_CHECK_CODE(code, lino, _exit);
continue;
}
}
break;
}
if (writer->ctx->hasData == false) {
break;
}

View File

@ -63,7 +63,7 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
}
// query meta
metaReaderDoInit(&mer1, pVnode->pMeta, 0);
metaReaderDoInit(&mer1, pVnode->pMeta, META_READER_LOCK);
if (metaGetTableEntryByName(&mer1, infoReq.tbName) < 0) {
code = terrno;
@ -179,7 +179,7 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
}
// query meta
metaReaderDoInit(&mer1, pVnode->pMeta, 0);
metaReaderDoInit(&mer1, pVnode->pMeta, META_READER_LOCK);
if (metaGetTableEntryByName(&mer1, cfgReq.tbName) < 0) {
code = terrno;
@ -192,7 +192,7 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
code = TSDB_CODE_VND_HASH_MISMATCH;
goto _exit;
} else if (mer1.me.type == TSDB_CHILD_TABLE) {
metaReaderDoInit(&mer2, pVnode->pMeta, 0);
metaReaderDoInit(&mer2, pVnode->pMeta, META_READER_LOCK);
if (metaReaderGetTableEntryByUid(&mer2, mer1.me.ctbEntry.suid) < 0) goto _exit;
strcpy(cfgRsp.stbName, mer2.me.name);

View File

@ -3,7 +3,7 @@ aux_source_directory(src EXECUTOR_SRC)
add_library(executor STATIC ${EXECUTOR_SRC})
target_link_libraries(executor
PRIVATE os util common function parser planner qcom scalar nodes index wal tdb
PRIVATE os util common function parser planner qcom scalar nodes index wal tdb geometry
)
target_include_directories(

View File

@ -308,7 +308,7 @@ int32_t isQualifiedTable(STableKeyInfo* info, SNode* pTagCond, void* metaHandle,
int32_t code = TSDB_CODE_SUCCESS;
SMetaReader mr = {0};
pAPI->metaReaderFn.initReader(&mr, metaHandle, 0, &pAPI->metaFn);
pAPI->metaReaderFn.initReader(&mr, metaHandle, META_READER_LOCK, &pAPI->metaFn);
code = pAPI->metaReaderFn.getEntryGetUidCache(&mr, info->uid);
if (TSDB_CODE_SUCCESS != code) {
pAPI->metaReaderFn.clearReader(&mr);
@ -1225,7 +1225,7 @@ int32_t getGroupIdFromTagsVal(void* pVnode, uint64_t uid, SNodeList* pGroupNode,
SStorageAPI* pAPI) {
SMetaReader mr = {0};
pAPI->metaReaderFn.initReader(&mr, pVnode, 0, &pAPI->metaFn);
pAPI->metaReaderFn.initReader(&mr, pVnode, META_READER_LOCK, &pAPI->metaFn);
if (pAPI->metaReaderFn.getEntryGetUidCache(&mr, uid) != 0) { // table not exist
pAPI->metaReaderFn.clearReader(&mr);
return TSDB_CODE_PAR_TABLE_NOT_EXIST;

View File

@ -351,7 +351,7 @@ static SArray* filterUnqualifiedTables(const SStreamScanInfo* pScanInfo, const S
// let's discard the tables those are not created according to the queried super table.
SMetaReader mr = {0};
pAPI->metaReaderFn.initReader(&mr, pScanInfo->readHandle.vnode, 0, &pAPI->metaFn);
pAPI->metaReaderFn.initReader(&mr, pScanInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn);
for (int32_t i = 0; i < numOfUids; ++i) {
uint64_t* id = (uint64_t*)taosArrayGet(tableIdList, i);

View File

@ -127,7 +127,7 @@ int32_t initQueriedTableSchemaInfo(SReadHandle* pHandle, SScanPhysiNode* pScanNo
SStorageAPI* pAPI = &pTaskInfo->storageAPI;
pAPI->metaReaderFn.initReader(&mr, pHandle->vnode, 0, &pAPI->metaFn);
pAPI->metaReaderFn.initReader(&mr, pHandle->vnode, META_READER_LOCK, &pAPI->metaFn);
int32_t code = pAPI->metaReaderFn.getEntryGetUidCache(&mr, pScanNode->uid);
if (code != TSDB_CODE_SUCCESS) {
qError("failed to get the table meta, uid:0x%" PRIx64 ", suid:0x%" PRIx64 ", %s", pScanNode->uid, pScanNode->suid,

View File

@ -505,7 +505,7 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int
// 1. check if it is existed in meta cache
if (pCache == NULL) {
pHandle->api.metaReaderFn.initReader(&mr, pHandle->vnode, 0, &pHandle->api.metaFn);
pHandle->api.metaReaderFn.initReader(&mr, pHandle->vnode, META_READER_LOCK, &pHandle->api.metaFn);
code = pHandle->api.metaReaderFn.getEntryGetUidCache(&mr, pBlock->info.id.uid);
if (code != TSDB_CODE_SUCCESS) {
// when encounter the TSDB_CODE_PAR_TABLE_NOT_EXIST error, we proceed.
@ -534,7 +534,7 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int
h = taosLRUCacheLookup(pCache->pTableMetaEntryCache, &pBlock->info.id.uid, sizeof(pBlock->info.id.uid));
if (h == NULL) {
pHandle->api.metaReaderFn.initReader(&mr, pHandle->vnode, 0, &pHandle->api.metaFn);
pHandle->api.metaReaderFn.initReader(&mr, pHandle->vnode, META_READER_LOCK, &pHandle->api.metaFn);
code = pHandle->api.metaReaderFn.getEntryGetUidCache(&mr, pBlock->info.id.uid);
if (code != TSDB_CODE_SUCCESS) {
if (terrno == TSDB_CODE_PAR_TABLE_NOT_EXIST) {
@ -2084,6 +2084,8 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) {
blockDataCleanup(pInfo->pRes);
STimeWindow defaultWindow = {.skey = INT64_MIN, .ekey = INT64_MAX};
setBlockIntoRes(pInfo, pRes, &defaultWindow, true);
qDebug("doQueueScan after filter get data from log %" PRId64 " rows, version:%" PRId64, pInfo->pRes->info.rows,
pTaskInfo->streamInfo.currentOffset.version);
if (pInfo->pRes->info.rows > 0) {
return pInfo->pRes;
}
@ -3318,7 +3320,7 @@ static SSDataBlock* doTagScanFromMetaEntry(SOperatorInfo* pOperator) {
char str[512] = {0};
int32_t count = 0;
SMetaReader mr = {0};
pAPI->metaReaderFn.initReader(&mr, pInfo->readHandle.vnode, 0, &pAPI->metaFn);
pAPI->metaReaderFn.initReader(&mr, pInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn);
while (pInfo->curPos < size && count < pOperator->resultInfo.capacity) {
doTagScanOneTable(pOperator, pRes, count, &mr, &pTaskInfo->storageAPI);

View File

@ -14,6 +14,7 @@
*/
#include "executorInt.h"
#include "geosWrapper.h"
#include "filter.h"
#include "functionMgt.h"
#include "querynodes.h"
@ -464,7 +465,7 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
STR_TO_VARSTR(tableName, pInfo->req.filterTb);
SMetaReader smrTable = {0};
pAPI->metaReaderFn.initReader(&smrTable, pInfo->readHandle.vnode, 0, &pAPI->metaFn);
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
@ -484,7 +485,7 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
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, 0, &pAPI->metaFn);
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
@ -567,7 +568,7 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
schemaRow = *(SSchemaWrapper**)schema;
} else {
SMetaReader smrSuperTable = {0};
pAPI->metaReaderFn.initReader(&smrSuperTable, pInfo->readHandle.vnode, 0, &pAPI->metaFn);
pAPI->metaReaderFn.initReader(&smrSuperTable, pInfo->readHandle.vnode, META_READER_LOCK, &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
@ -656,7 +657,7 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
STR_TO_VARSTR(tableName, condTableName);
SMetaReader smrChildTable = {0};
pAPI->metaReaderFn.initReader(&smrChildTable, pInfo->readHandle.vnode, 0, &pAPI->metaFn);
pAPI->metaReaderFn.initReader(&smrChildTable, pInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn);
int32_t code = pAPI->metaReaderFn.getTableEntryByName(&smrChildTable, condTableName);
if (code != TSDB_CODE_SUCCESS) {
// terrno has been set by pAPI->metaReaderFn.getTableEntryByName, therefore, return directly
@ -713,7 +714,7 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
STR_TO_VARSTR(tableName, pInfo->pCur->mr.me.name);
SMetaReader smrSuperTable = {0};
pAPI->metaReaderFn.initReader(&smrSuperTable, pInfo->readHandle.vnode, 0, &pAPI->metaFn);
pAPI->metaReaderFn.initReader(&smrSuperTable, pInfo->readHandle.vnode, META_READER_NOLOCK, &pAPI->metaFn);
uint64_t suid = pInfo->pCur->mr.me.ctbEntry.suid;
int32_t code = pAPI->metaReaderFn.getTableEntryByUid(&smrSuperTable, suid);
if (code != TSDB_CODE_SUCCESS) {
@ -811,6 +812,8 @@ int32_t convertTagDataToStr(char* str, int type, void* buf, int32_t bufSize, int
break;
case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_VARBINARY:
case TSDB_DATA_TYPE_GEOMETRY:
if (bufSize < 0) {
return TSDB_CODE_TSC_INVALID_VALUE;
}
@ -854,6 +857,30 @@ int32_t convertTagDataToStr(char* str, int type, void* buf, int32_t bufSize, int
return TSDB_CODE_SUCCESS;
}
static int32_t sysTableGetGeomText(char* iGeom, int32_t nGeom, char** output, int32_t* nOutput) {
int32_t code = 0;
char* outputWKT = NULL;
if (nGeom == 0) {
if (!(*output = strdup(""))) code = TSDB_CODE_OUT_OF_MEMORY;
*nOutput = 0;
return code;
}
if (TSDB_CODE_SUCCESS != (code = initCtxAsText()) ||
TSDB_CODE_SUCCESS != (code = doAsText(iGeom, nGeom, &outputWKT))) {
qError("geo text for systable failed:%s", getThreadLocalGeosCtx()->errMsg);
*output = NULL;
*nOutput = 0;
return code;
}
*output = outputWKT;
*nOutput = strlen(outputWKT);
return code;
}
static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo, SMetaReader* smrSuperTable,
SMetaReader* smrChildTable, const char* dbname, const char* tableName,
int32_t* pNumOfRows, const SSDataBlock* dataBlock) {
@ -889,13 +916,13 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo,
pColInfoData = taosArrayGet(dataBlock->pDataBlock, 4);
char tagTypeStr[VARSTR_HEADER_SIZE + 32];
int tagTypeLen = sprintf(varDataVal(tagTypeStr), "%s", tDataTypes[tagType].name);
if (tagType == TSDB_DATA_TYPE_VARCHAR) {
tagTypeLen += sprintf(varDataVal(tagTypeStr) + tagTypeLen, "(%d)",
(int32_t)((*smrSuperTable).me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE));
} else if (tagType == TSDB_DATA_TYPE_NCHAR) {
if (tagType == TSDB_DATA_TYPE_NCHAR) {
tagTypeLen += sprintf(
varDataVal(tagTypeStr) + tagTypeLen, "(%d)",
(int32_t)(((*smrSuperTable).me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
} else if (IS_VAR_DATA_TYPE(tagType)) {
tagTypeLen += sprintf(varDataVal(tagTypeStr) + tagTypeLen, "(%d)",
(int32_t)((*smrSuperTable).me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE));
}
varDataSetLen(tagTypeStr, tagTypeLen);
colDataSetVal(pColInfoData, numOfRows, (char*)tagTypeStr, false);
@ -910,7 +937,13 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo,
} else {
bool exist = tTagGet((STag*)smrChildTable->me.ctbEntry.pTags, &tagVal);
if (exist) {
if (IS_VAR_DATA_TYPE(tagType)) {
if (tagType == TSDB_DATA_TYPE_GEOMETRY) {
sysTableGetGeomText(tagVal.pData, tagVal.nData, &tagData, &tagLen);
} else if (tagType == TSDB_DATA_TYPE_VARBINARY) {
if (taosAscii2Hex(tagVal.pData, tagVal.nData, (void**)&tagData, &tagLen) < 0) {
qError("varbinary for systable failed since %s", tstrerror(TSDB_CODE_OUT_OF_MEMORY));
}
} else if (IS_VAR_DATA_TYPE(tagType)) {
tagData = (char*)tagVal.pData;
tagLen = tagVal.nData;
} else {
@ -940,6 +973,7 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo,
pColInfoData = taosArrayGet(dataBlock->pDataBlock, 5);
colDataSetVal(pColInfoData, numOfRows, tagVarChar,
(tagData == NULL) || (tagType == TSDB_DATA_TYPE_JSON && tTagIsJsonNull(tagData)));
if (tagType == TSDB_DATA_TYPE_GEOMETRY || tagType == TSDB_DATA_TYPE_VARBINARY) taosMemoryFreeClear(tagData);
taosMemoryFree(tagVarChar);
++numOfRows;
}
@ -1129,7 +1163,7 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) {
tb_uid_t* uid = taosArrayGet(pIdx->uids, i);
SMetaReader mr = {0};
pAPI->metaReaderFn.initReader(&mr, pInfo->readHandle.vnode, 0, &pAPI->metaFn);
pAPI->metaReaderFn.initReader(&mr, pInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn);
ret = pAPI->metaReaderFn.getTableEntryByUid(&mr, *uid);
if (ret < 0) {
pAPI->metaReaderFn.clearReader(&mr);
@ -2170,7 +2204,7 @@ static int32_t doGetTableRowSize(SReadHandle* pHandle, uint64_t uid, int32_t* ro
*rowLen = 0;
SMetaReader mr = {0};
pHandle->api.metaReaderFn.initReader(&mr, pHandle->vnode, 0, &pHandle->api.metaFn);
pHandle->api.metaReaderFn.initReader(&mr, pHandle->vnode, META_READER_LOCK, &pHandle->api.metaFn);
int32_t code = pHandle->api.metaReaderFn.getTableEntryByUid(&mr, uid);
if (code != TSDB_CODE_SUCCESS) {
qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", uid, tstrerror(terrno), idstr);

View File

@ -199,6 +199,7 @@ int32_t doAsText(const unsigned char *inputGeom, size_t size, char **outputWKT)
wkt = GEOSWKTWriter_write_r(geosCtx->handle, geosCtx->WKTWriter, geom);
if (wkt == NULL) {
code = TSDB_CODE_MSG_DECODE_ERROR;
goto _exit;
}
*outputWKT = wkt;

View File

@ -108,6 +108,8 @@ SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode
SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pColumnName);
SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral);
SNode* createRawValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral, SNode *pNode);
SNode* createRawValueNodeExt(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral, SNode *pLeft, SNode *pRight);
SNodeList* createHintNodeList(SAstCreateContext* pCxt, const SToken* pLiteral);
SNode* createIdentifierValueNode(SAstCreateContext* pCxt, SToken* pLiteral);
SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral);

View File

@ -24,6 +24,15 @@ extern "C" {
#include "ttokendef.h"
#define IS_TRUE_STR(s, n) \
(n == 4 && (*(s) == 't' || *(s) == 'T') && (*((s) + 1) == 'r' || *((s) + 1) == 'R') && \
(*((s) + 2) == 'u' || *((s) + 2) == 'U') && (*((s) + 3) == 'e' || *((s) + 3) == 'E'))
#define IS_FALSE_STR(s, n) \
(n == 5 && (*(s) == 'f' || *(s) == 'F') && (*((s) + 1) == 'a' || *((s) + 1) == 'A') && \
(*((s) + 2) == 'l' || *((s) + 2) == 'L') && (*((s) + 3) == 's' || *((s) + 3) == 'S') && \
(*((s) + 4) == 'e' || *((s) + 4) == 'E'))
// used to denote the minimum unite in sql parsing
typedef struct SToken {
uint32_t n;

View File

@ -23,6 +23,7 @@ extern "C" {
#include "catalog.h"
#include "os.h"
#include "parser.h"
#include "parToken.h"
#include "query.h"
#define parserFatal(param, ...) qFatal("PARSER: " param, ##__VA_ARGS__)
@ -35,6 +36,45 @@ extern "C" {
#define ROWTS_PSEUDO_COLUMN_NAME "_rowts"
#define C0_PSEUDO_COLUMN_NAME "_c0"
#define IS_NOW_STR(s, n) \
((*(s) == 'n' || *(s) == 'N') && (*((s) + 1) == 'o' || *((s) + 1) == 'O') && \
(*((s) + 2) == 'w' || *((s) + 2) == 'W') && (n == 3 || (n == 5 && *((s) + 3) == '(' && *((s) + 4) == ')')))
#define IS_TODAY_STR(s, n) \
((*(s) == 't' || *(s) == 'T') && (*((s) + 1) == 'o' || *((s) + 1) == 'O') && \
(*((s) + 2) == 'd' || *((s) + 2) == 'D') && (*((s) + 3) == 'a' || *((s) + 3) == 'A') && \
(*((s) + 4) == 'y' || *((s) + 4) == 'Y') && (n == 5 || (n == 7 && *((s) + 5) == '(' && *((s) + 6) == ')')))
#define IS_NULL_STR(s, n) \
(n == 4 && (*(s) == 'N' || *(s) == 'n') && (*((s) + 1) == 'U' || *((s) + 1) == 'u') && \
(*((s) + 2) == 'L' || *((s) + 2) == 'l') && (*((s) + 3) == 'L' || *((s) + 3) == 'l'))
#define NEXT_TOKEN_WITH_PREV(pSql, token) \
do { \
int32_t index = 0; \
token = tStrGetToken(pSql, &index, true, NULL); \
pSql += index; \
} while (0)
#define NEXT_TOKEN_WITH_PREV_EXT(pSql, token, pIgnoreComma) \
do { \
int32_t index = 0; \
token = tStrGetToken(pSql, &index, true, pIgnoreComma); \
pSql += index; \
} while (0)
#define NEXT_TOKEN_KEEP_SQL(pSql, token, index) \
do { \
token = tStrGetToken(pSql, &index, false, NULL); \
} while (0)
#define NEXT_VALID_TOKEN(pSql, token) \
do { \
(token).n = tGetToken(pSql, &(token).type); \
(token).z = (char*)pSql; \
pSql += (token).n; \
} while (TK_NK_SPACE == (token).type)
typedef struct SMsgBuf {
int32_t len;
char* buf;
@ -90,6 +130,9 @@ int32_t getTableTypeFromTableNode(SNode *pTable);
int32_t trimString(const char* src, int32_t len, char* dst, int32_t dlen);
int32_t getVnodeSysTableTargetName(int32_t acctId, SNode* pWhere, SName* pName);
int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, SMsgBuf* pMsgBuf, int8_t type);
int32_t parseTagValue(SMsgBuf* pMsgBuf, const char** pSql, uint8_t precision, SSchema* pTagSchema, SToken* pToken,
SArray* pTagName, SArray* pTagVals, STag** pTag);
int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalogReq);
int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMetaData, SParseMetaCache* pMetaCache);

View File

@ -354,7 +354,7 @@ alter_table_clause(A) ::=
alter_table_clause(A) ::=
full_table_name(B) RENAME TAG column_name(C) column_name(D). { A = createAlterTableRenameCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &C, &D); }
alter_table_clause(A) ::=
full_table_name(B) SET TAG column_name(C) NK_EQ signed_literal(D). { A = createAlterTableSetTag(pCxt, B, &C, D); }
full_table_name(B) SET TAG column_name(C) NK_EQ tags_literal(D). { A = createAlterTableSetTag(pCxt, B, &C, D); }
%type multi_create_clause { SNodeList* }
%destructor multi_create_clause { nodesDestroyList($$); }
@ -363,7 +363,7 @@ multi_create_clause(A) ::= multi_create_clause(B) create_subtable_clause(C).
create_subtable_clause(A) ::=
not_exists_opt(B) full_table_name(C) USING full_table_name(D)
specific_cols_opt(E) TAGS NK_LP expression_list(F) NK_RP table_options(G). { A = createCreateSubTableClause(pCxt, B, C, D, E, F, G); }
specific_cols_opt(E) TAGS NK_LP tags_literal_list(F) NK_RP table_options(G). { A = createCreateSubTableClause(pCxt, B, C, D, E, F, G); }
%type multi_drop_clause { SNodeList* }
%destructor multi_drop_clause { nodesDestroyList($$); }
@ -744,6 +744,76 @@ insert_query(A) ::= INSERT INTO full_table_name(D)
NK_LP col_name_list(B) NK_RP query_or_subquery(C). { A = createInsertStmt(pCxt, D, B, C); }
insert_query(A) ::= INSERT INTO full_table_name(C) query_or_subquery(B). { A = createInsertStmt(pCxt, C, NULL, B); }
/************************************************ tags_literal *************************************************************/
tags_literal(A) ::= NK_INTEGER(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B, NULL); }
tags_literal(A) ::= NK_PLUS(B) NK_INTEGER(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
}
tags_literal(A) ::= NK_MINUS(B) NK_INTEGER(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
}
tags_literal(A) ::= NK_FLOAT(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &B, NULL); }
tags_literal(A) ::= NK_PLUS(B) NK_FLOAT(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t, NULL);
}
tags_literal(A) ::= NK_MINUS(B) NK_FLOAT(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t, NULL);
}
tags_literal(A) ::= NK_BIN(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B, NULL); }
tags_literal(A) ::= NK_PLUS(B) NK_BIN(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
}
tags_literal(A) ::= NK_MINUS(B) NK_BIN(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
}
tags_literal(A) ::= NK_HEX(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B, NULL); }
tags_literal(A) ::= NK_PLUS(B) NK_HEX(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
}
tags_literal(A) ::= NK_MINUS(B) NK_HEX(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
}
tags_literal(A) ::= NK_STRING(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B, NULL); }
tags_literal(A) ::= NK_BOOL(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &B, NULL); }
tags_literal(A) ::= NULL(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_NULL, &B, NULL); }
tags_literal(A) ::= literal_func(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, NULL, B); }
tags_literal(A) ::= literal_func(B) NK_PLUS duration_literal(C). {
SToken l = getTokenFromRawExprNode(pCxt, B);
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, B, C);
}
tags_literal(A) ::= literal_func(B) NK_MINUS duration_literal(C). {
SToken l = getTokenFromRawExprNode(pCxt, B);
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, B, C);
}
%type tags_literal_list { SNodeList* }
%destructor tags_literal_list { nodesDestroyList($$); }
tags_literal_list(A) ::= tags_literal(B). { A = createNodeList(pCxt, B); }
tags_literal_list(A) ::= tags_literal_list(B) NK_COMMA tags_literal(C). { A = addNodeToList(pCxt, B, C); }
/************************************************ literal *************************************************************/
literal(A) ::= NK_INTEGER(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B)); }
literal(A) ::= NK_FLOAT(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &B)); }
@ -924,6 +994,7 @@ function_expression(A) ::= literal_func(B).
literal_func(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &B, NULL)); }
literal_func(A) ::= NOW(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
literal_func(A) ::= TODAY(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
%type noarg_func { SToken }
%destructor noarg_func { }

View File

@ -370,6 +370,80 @@ SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken*
return (SNode*)val;
}
SNode* createRawValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral, SNode* pNode) {
CHECK_PARSER_STATUS(pCxt);
SValueNode* val = NULL;
if (!(val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE))) {
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY, "Out of memory");
goto _exit;
}
if (pLiteral) {
val->literal = strndup(pLiteral->z, pLiteral->n);
} else if (pNode) {
SRawExprNode* pRawExpr = (SRawExprNode*)pNode;
if (!nodesIsExprNode(pRawExpr->pNode)) {
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, pRawExpr->p);
goto _exit;
}
val->literal = strndup(pRawExpr->p, pRawExpr->n);
} else {
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTERNAL_ERROR, "Invalid parameters");
goto _exit;
}
if (!val->literal) {
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY, "Out of memory");
goto _exit;
}
val->node.resType.type = dataType;
val->node.resType.bytes = IS_VAR_DATA_TYPE(dataType) ? strlen(val->literal) : tDataTypes[dataType].bytes;
if (TSDB_DATA_TYPE_TIMESTAMP == dataType) {
val->node.resType.precision = TSDB_TIME_PRECISION_MILLI;
}
_exit:
nodesDestroyNode(pNode);
if (pCxt->errCode != 0) {
nodesDestroyNode((SNode*)val);
return NULL;
}
return (SNode*)val;
}
SNode* createRawValueNodeExt(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral, SNode* pLeft,
SNode* pRight) {
CHECK_PARSER_STATUS(pCxt);
SValueNode* val = NULL;
if (!(val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE))) {
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY, "Out of memory");
goto _exit;
}
if (pLiteral) {
if (!(val->literal = strndup(pLiteral->z, pLiteral->n))) {
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY, "Out of memory");
goto _exit;
}
} else {
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTERNAL_ERROR, "Invalid parameters");
goto _exit;
}
val->node.resType.type = dataType;
val->node.resType.bytes = IS_VAR_DATA_TYPE(dataType) ? strlen(val->literal) : tDataTypes[dataType].bytes;
if (TSDB_DATA_TYPE_TIMESTAMP == dataType) {
val->node.resType.precision = TSDB_TIME_PRECISION_MILLI;
}
_exit:
nodesDestroyNode(pLeft);
nodesDestroyNode(pRight);
if (pCxt->errCode != 0) {
nodesDestroyNode((SNode*)val);
return NULL;
}
return (SNode*)val;
}
static bool hasHint(SNodeList* pHintList, EHintOption hint) {
if (!pHintList) return false;
SNode* pNode;

View File

@ -72,9 +72,7 @@ int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) {
cxt.errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
goto abort_parse;
}
case TK_NK_HEX:
case TK_NK_OCT:
case TK_NK_BIN: {
case TK_NK_OCT: {
snprintf(cxt.pQueryCxt->pMsg, cxt.pQueryCxt->msgLen, "unsupported token: \"%s\"", t0.z);
cxt.errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
goto abort_parse;

View File

@ -20,32 +20,6 @@
#include "ttime.h"
#include "geosWrapper.h"
#define NEXT_TOKEN_WITH_PREV(pSql, token) \
do { \
int32_t index = 0; \
token = tStrGetToken(pSql, &index, true, NULL); \
pSql += index; \
} while (0)
#define NEXT_TOKEN_WITH_PREV_EXT(pSql, token, pIgnoreComma) \
do { \
int32_t index = 0; \
token = tStrGetToken(pSql, &index, true, pIgnoreComma); \
pSql += index; \
} while (0)
#define NEXT_TOKEN_KEEP_SQL(pSql, token, index) \
do { \
token = tStrGetToken(pSql, &index, false, NULL); \
} while (0)
#define NEXT_VALID_TOKEN(pSql, token) \
do { \
(token).n = tGetToken(pSql, &(token).type); \
(token).z = (char*)pSql; \
pSql += (token).n; \
} while (TK_NK_SPACE == (token).type)
typedef struct SInsertParseContext {
SParseContext* pComCxt;
SMsgBuf msg;
@ -63,13 +37,9 @@ typedef int32_t (*_row_append_fn_t)(SMsgBuf* pMsgBuf, const void* value, int32_t
static uint8_t TRUE_VALUE = (uint8_t)TSDB_TRUE;
static uint8_t FALSE_VALUE = (uint8_t)TSDB_FALSE;
static bool isNullStr(SToken* pToken) {
return ((pToken->type == TK_NK_STRING) && (strlen(TSDB_DATA_NULL_STR_L) == pToken->n) &&
(strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0));
}
static bool isNullValue(int8_t dataType, SToken* pToken) {
return TK_NULL == pToken->type || (!IS_STR_DATA_TYPE(dataType) && isNullStr(pToken));
static FORCE_INLINE bool isNullValue(int8_t dataType, SToken* pToken) {
return TK_NULL == pToken->type ||
(TK_NK_STRING == pToken->type && !IS_STR_DATA_TYPE(dataType) && IS_NULL_STR(pToken->z, pToken->n));
}
static FORCE_INLINE int32_t toDouble(SToken* pToken, double* value, char** endPtr) {
@ -268,7 +238,8 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, const char** pSql, E
return code;
}
static int parseTimestampOrInterval(const char** end, SToken* pToken, int16_t timePrec, int64_t* ts, int64_t* interval, SMsgBuf* pMsgBuf, bool* isTs) {
static int parseTimestampOrInterval(const char** end, SToken* pToken, int16_t timePrec, int64_t* ts, int64_t* interval,
SMsgBuf* pMsgBuf, bool* isTs) {
if (pToken->type == TK_NOW) {
*isTs = true;
*ts = taosGetTimestamp(timePrec);
@ -289,7 +260,21 @@ static int parseTimestampOrInterval(const char** end, SToken* pToken, int16_t ti
} else { // parse the RFC-3339/ISO-8601 timestamp format string
*isTs = true;
if (taosParseTime(pToken->z, ts, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) {
return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z);
if ((pToken->n == 0) ||
(pToken->type != TK_NK_STRING && pToken->type != TK_NK_HEX && pToken->type != TK_NK_BIN)) {
return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z);
}
if (IS_NOW_STR(pToken->z, pToken->n)) {
*isTs = true;
*ts = taosGetTimestamp(timePrec);
} else if (IS_TODAY_STR(pToken->z, pToken->n)) {
*isTs = true;
*ts = taosGetTimestampToday(timePrec);
} else if (TSDB_CODE_SUCCESS == toIntegerPure(pToken->z, pToken->n, 10, ts)) {
*isTs = true;
} else {
return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z);
}
}
}
@ -313,10 +298,22 @@ static int parseTime(const char** end, SToken* pToken, int16_t timePrec, int64_t
for (int k = pToken->n; pToken->z[k] != '\0'; k++) {
if (pToken->z[k] == ' ' || pToken->z[k] == '\t') continue;
if (pToken->z[k] == '(' && pToken->z[k + 1] == ')') { // for insert NOW()/TODAY()
*end = pTokenEnd = &pToken->z[k + 2];
k++;
continue;
if (pToken->z[k] == '(') { // for insert NOW()/TODAY()
if (pToken->z[k + 1] == ')') {
*end = pTokenEnd = &pToken->z[k + 2];
++k;
continue;
} else {
char nc = pToken->z[k + 1];
while (nc == ' ' || nc == '\t' || nc == '\n' || nc == '\r' || nc == '\f') {
nc = pToken->z[(++k) + 1];
}
if (nc == ')') {
*end = pTokenEnd = &pToken->z[k + 2];
++k;
continue;
}
}
}
if (pToken->z[k] == ',') {
*end = pTokenEnd;
@ -491,10 +488,12 @@ static int32_t parseTagToken(const char** end, SToken* pToken, SSchema* pSchema,
switch (pSchema->type) {
case TSDB_DATA_TYPE_BOOL: {
if ((pToken->type == TK_NK_BOOL || pToken->type == TK_NK_STRING) && (pToken->n != 0)) {
if (strncmp(pToken->z, "true", pToken->n) == 0) {
if (IS_TRUE_STR(pToken->z, pToken->n)) {
*(int8_t*)(&val->i64) = TRUE_VALUE;
} else if (strncmp(pToken->z, "false", pToken->n) == 0) {
} else if (IS_FALSE_STR(pToken->z, pToken->n)) {
*(int8_t*)(&val->i64) = FALSE_VALUE;
} else if (TSDB_CODE_SUCCESS == toDoubleEx(pToken->z, pToken->n, pToken->type, (double*)&iv)) {
*(int8_t*)(&val->i64) = (*(double*)&iv == 0 ? FALSE_VALUE : TRUE_VALUE);
} else {
return buildSyntaxErrMsg(pMsgBuf, "invalid bool data", pToken->z);
}
@ -502,6 +501,9 @@ static int32_t parseTagToken(const char** end, SToken* pToken, SSchema* pSchema,
*(int8_t*)(&val->i64) = ((taosStr2Int64(pToken->z, NULL, 10) == 0) ? FALSE_VALUE : TRUE_VALUE);
} else if (pToken->type == TK_NK_FLOAT) {
*(int8_t*)(&val->i64) = ((taosStr2Double(pToken->z, NULL) == 0) ? FALSE_VALUE : TRUE_VALUE);
} else if ((pToken->type == TK_NK_HEX || pToken->type == TK_NK_BIN) &&
(TSDB_CODE_SUCCESS == toDoubleEx(pToken->z, pToken->n, pToken->type, (double*)&iv))) {
*(int8_t*)(&val->i64) = (*(double*)&iv == 0 ? FALSE_VALUE : TRUE_VALUE);
} else {
return buildSyntaxErrMsg(pMsgBuf, "invalid bool data", pToken->z);
}
@ -709,30 +711,29 @@ static int32_t parseBoundTagsClause(SInsertParseContext* pCxt, SVnodeModifyOpStm
return parseBoundColumns(pCxt, &pStmt->pSql, BOUND_TAGS, pStmt->pTableMeta, &pCxt->tags);
}
static int32_t parseTagValue(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, const char** ppSql, SSchema* pTagSchema, SToken* pToken,
SArray* pTagName, SArray* pTagVals, STag** pTag) {
int32_t parseTagValue(SMsgBuf* pMsgBuf, const char** pSql, uint8_t precision, SSchema* pTagSchema, SToken* pToken,
SArray* pTagName, SArray* pTagVals, STag** pTag) {
bool isNull = isNullValue(pTagSchema->type, pToken);
if (!isNull) {
if (!isNull && pTagName) {
taosArrayPush(pTagName, pTagSchema->name);
}
if (pTagSchema->type == TSDB_DATA_TYPE_JSON) {
if (pToken->n > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
return buildSyntaxErrMsg(&pCxt->msg, "json string too long than 4095", pToken->z);
return buildSyntaxErrMsg(pMsgBuf, "json string too long than 4095", pToken->z);
}
if (isNull) {
return tTagNew(pTagVals, 1, true, pTag);
} else {
return parseJsontoTagData(pToken->z, pTagVals, pTag, &pCxt->msg);
return parseJsontoTagData(pToken->z, pTagVals, pTag, pMsgBuf);
}
}
if (isNull) return 0;
STagVal val = {0};
int32_t code =
parseTagToken(ppSql, pToken, pTagSchema, pStmt->pTableMeta->tableInfo.precision, &val, &pCxt->msg);
int32_t code = parseTagToken(pSql, pToken, pTagSchema, precision, &val, pMsgBuf);
if (TSDB_CODE_SUCCESS == code) {
taosArrayPush(pTagVals, &val);
}
@ -755,7 +756,7 @@ static int32_t buildCreateTbReq(SVnodeModifyOpStmt* pStmt, STag* pTag, SArray* p
return TSDB_CODE_SUCCESS;
}
static int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, SMsgBuf* pMsgBuf, int8_t type) {
int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, SMsgBuf* pMsgBuf, int8_t type) {
if ((pToken->type != TK_NOW && pToken->type != TK_TODAY && pToken->type != TK_NK_INTEGER &&
pToken->type != TK_NK_STRING && pToken->type != TK_NK_FLOAT && pToken->type != TK_NK_BOOL &&
pToken->type != TK_NULL && pToken->type != TK_NK_HEX && pToken->type != TK_NK_OCT &&
@ -911,12 +912,20 @@ static int32_t checkSubtablePrivilege(SArray* pTagVals, SArray* pTagName, SNode*
static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt) {
int32_t code = TSDB_CODE_SUCCESS;
SSchema* pSchema = getTableTagSchema(pStmt->pTableMeta);
SArray* pTagVals = taosArrayInit(pCxt->tags.numOfBound, sizeof(STagVal));
SArray* pTagName = taosArrayInit(8, TSDB_COL_NAME_LEN);
SArray* pTagVals = NULL;
SArray* pTagName = NULL;
uint8_t precision = pStmt->pTableMeta->tableInfo.precision;
SToken token;
bool isParseBindParam = false;
bool isJson = false;
STag* pTag = NULL;
if (!(pTagVals = taosArrayInit(pCxt->tags.numOfBound, sizeof(STagVal))) ||
!(pTagName = taosArrayInit(pCxt->tags.numOfBound, TSDB_COL_NAME_LEN))) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
}
for (int i = 0; TSDB_CODE_SUCCESS == code && i < pCxt->tags.numOfBound; ++i) {
NEXT_TOKEN_WITH_PREV(pStmt->pSql, token);
@ -938,11 +947,11 @@ static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt
SSchema* pTagSchema = &pSchema[pCxt->tags.pColIndex[i]];
isJson = pTagSchema->type == TSDB_DATA_TYPE_JSON;
code = checkAndTrimValue(&token, pCxt->tmpTokenBuf, &pCxt->msg, pTagSchema->type);
if (TK_NK_VARIABLE == token.type) {
if (TSDB_CODE_SUCCESS == code && TK_NK_VARIABLE == token.type) {
code = buildSyntaxErrMsg(&pCxt->msg, "not expected tags values ", token.z);
}
if (TSDB_CODE_SUCCESS == code) {
code = parseTagValue(pCxt, pStmt, &pStmt->pSql, pTagSchema, &token, pTagName, pTagVals, &pTag);
code = parseTagValue(&pCxt->msg, &pStmt->pSql, precision, pTagSchema, &token, pTagName, pTagVals, &pTag);
}
}
@ -959,8 +968,9 @@ static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt
pTag = NULL;
}
for (int i = 0; i < taosArrayGetSize(pTagVals); ++i) {
STagVal* p = (STagVal*)taosArrayGet(pTagVals, i);
_exit:
for (int32_t i = 0; i < TARRAY_SIZE(pTagVals); ++i) {
STagVal* p = (STagVal*)TARRAY_GET_ELEM(pTagVals, i);
if (IS_VAR_DATA_TYPE(p->type)) {
taosMemoryFreeClear(p->pData);
}
@ -1425,10 +1435,12 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql,
switch (pSchema->type) {
case TSDB_DATA_TYPE_BOOL: {
if ((pToken->type == TK_NK_BOOL || pToken->type == TK_NK_STRING) && (pToken->n != 0)) {
if (strncmp(pToken->z, "true", pToken->n) == 0) {
if (IS_TRUE_STR(pToken->z, pToken->n)) {
pVal->value.val = TRUE_VALUE;
} else if (strncmp(pToken->z, "false", pToken->n) == 0) {
} else if (IS_FALSE_STR(pToken->z, pToken->n)) {
pVal->value.val = FALSE_VALUE;
} else if (TSDB_CODE_SUCCESS == toDoubleEx(pToken->z, pToken->n, pToken->type, (double*)&pVal->value.val)) {
*(int8_t*)(&pVal->value.val) = (*(double*)&pVal->value.val == 0 ? FALSE_VALUE : TRUE_VALUE);
} else {
return buildSyntaxErrMsg(&pCxt->msg, "invalid bool data", pToken->z);
}
@ -1436,6 +1448,9 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql,
pVal->value.val = ((taosStr2Int64(pToken->z, NULL, 10) == 0) ? FALSE_VALUE : TRUE_VALUE);
} else if (pToken->type == TK_NK_FLOAT) {
pVal->value.val = ((taosStr2Double(pToken->z, NULL) == 0) ? FALSE_VALUE : TRUE_VALUE);
} else if ((pToken->type == TK_NK_HEX || pToken->type == TK_NK_BIN) &&
(TSDB_CODE_SUCCESS == toDoubleEx(pToken->z, pToken->n, pToken->type, (double*)&pVal->value.val))) {
*(int8_t*)(&pVal->value.val) = (*(double*)&pVal->value.val == 0 ? FALSE_VALUE : TRUE_VALUE);
} else {
return buildSyntaxErrMsg(&pCxt->msg, "invalid bool data", pToken->z);
}
@ -1510,7 +1525,7 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql,
break;
}
case TSDB_DATA_TYPE_FLOAT: {
double dv;
double dv;
int32_t code = toDoubleEx(pToken->z, pToken->n, pToken->type, &dv);
if (TSDB_CODE_SUCCESS != code) {
return buildSyntaxErrMsg(&pCxt->msg, "illegal float data", pToken->z);
@ -1523,7 +1538,7 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql,
break;
}
case TSDB_DATA_TYPE_DOUBLE: {
double dv;
double dv;
int32_t code = toDoubleEx(pToken->z, pToken->n, pToken->type, &dv);
if (TSDB_CODE_SUCCESS != code) {
return buildSyntaxErrMsg(&pCxt->msg, "illegal float data", pToken->z);
@ -1549,7 +1564,7 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql,
}
case TSDB_DATA_TYPE_VARBINARY: {
int32_t code = parseVarbinary(pToken, &pVal->value.pData, &pVal->value.nData, pSchema->bytes);
if(code != TSDB_CODE_SUCCESS){
if (code != TSDB_CODE_SUCCESS) {
return generateSyntaxErrMsg(&pCxt->msg, code, pSchema->name);
}
break;
@ -1587,9 +1602,9 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql,
break;
}
case TSDB_DATA_TYPE_GEOMETRY: {
int32_t code = TSDB_CODE_FAILED;
unsigned char *output = NULL;
size_t size = 0;
int32_t code = TSDB_CODE_FAILED;
unsigned char* output = NULL;
size_t size = 0;
code = parseGeometry(pToken, &output, &size);
if (code != TSDB_CODE_SUCCESS) {
@ -1598,13 +1613,11 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql,
// Too long values will raise the invalid sql error message
else if (size + VARSTR_HEADER_SIZE > pSchema->bytes) {
code = generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name);
}
else {
} else {
pVal->value.pData = taosMemoryMalloc(size);
if (NULL == pVal->value.pData) {
code = TSDB_CODE_OUT_OF_MEMORY;
}
else {
} else {
memcpy(pVal->value.pData, output, size);
pVal->value.nData = size;
}
@ -1639,18 +1652,14 @@ static int32_t parseValueToken(SInsertParseContext* pCxt, const char** pSql, STo
return buildSyntaxErrMsg(&pCxt->msg, "primary timestamp should not be null", pToken->z);
}
if (TK_NK_VARIABLE == pToken->type && pSchema->type != TSDB_DATA_TYPE_TIMESTAMP) {
return buildSyntaxErrMsg(&pCxt->msg, "invalid values", pToken->z);
}
pVal->flag = CV_FLAG_NULL;
return TSDB_CODE_SUCCESS;
}
if (TSDB_CODE_SUCCESS == code && IS_NUMERIC_TYPE(pSchema->type) && pToken->n == 0) {
return buildSyntaxErrMsg(&pCxt->msg, "invalid numeric data", pToken->z);
}
if (TSDB_CODE_SUCCESS == code) {
if (pToken->n == 0 && IS_NUMERIC_TYPE(pSchema->type)) {
return buildSyntaxErrMsg(&pCxt->msg, "invalid numeric data", pToken->z);
}
code = parseValueTokenImpl(pCxt, pSql, pToken, pSchema, timePrec, pVal);
}
@ -1728,18 +1737,19 @@ static int32_t processCtbTagsAfterCtbName(SInsertParseContext* pCxt, SVnodeModif
const SToken* tagTokens, SSchema* const* tagSchemas,
int numOfTagTokens) {
int32_t code = TSDB_CODE_SUCCESS;
uint8_t precision = pStmt->pTableMeta->tableInfo.precision;
if (code == TSDB_CODE_SUCCESS && ctbFirst) {
for (int32_t i = 0; code == TSDB_CODE_SUCCESS && i < numOfTagTokens; ++i) {
SToken* pTagToken = (SToken*)(tagTokens + i);
SSchema* pTagSchema = tagSchemas[i];
code = checkAndTrimValue(pTagToken, pCxt->tmpTokenBuf, &pCxt->msg, pTagSchema->type);
if (TK_NK_VARIABLE == pTagToken->type) {
if (code == TSDB_CODE_SUCCESS && TK_NK_VARIABLE == pTagToken->type) {
code = buildInvalidOperationMsg(&pCxt->msg, "not expected tag");
}
if (code == TSDB_CODE_SUCCESS) {
code = parseTagValue(pCxt, pStmt, NULL, pTagSchema, pTagToken, pStbRowsCxt->aTagNames, pStbRowsCxt->aTagVals,
code = parseTagValue(&pCxt->msg, NULL, precision, pTagSchema, pTagToken, pStbRowsCxt->aTagNames, pStbRowsCxt->aTagVals,
&pStbRowsCxt->pTag);
}
}
@ -1759,11 +1769,12 @@ static int32_t doGetStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt*
const SBoundColInfo* pCols, const SSchema* pSchemas,
SToken* tagTokens, SSchema** tagSchemas, int* pNumOfTagTokens, bool* bFoundTbName) {
int32_t code = TSDB_CODE_SUCCESS;
SArray* pTagNames = pStbRowsCxt->aTagNames;
SArray* pTagVals = pStbRowsCxt->aTagVals;
bool canParseTagsAfter = !pStbRowsCxt->pTagCond && !pStbRowsCxt->hasTimestampTag;
SArray* pTagNames = pStbRowsCxt->aTagNames;
SArray* pTagVals = pStbRowsCxt->aTagVals;
bool canParseTagsAfter = !pStbRowsCxt->pTagCond && !pStbRowsCxt->hasTimestampTag;
int32_t numOfCols = getNumOfColumns(pStbRowsCxt->pStbMeta);
int32_t tbnameIdx = getTbnameSchemaIndex(pStbRowsCxt->pStbMeta);
uint8_t precision = getTableInfo(pStbRowsCxt->pStbMeta).precision;
for (int i = 0; i < pCols->numOfBound && (code) == TSDB_CODE_SUCCESS; ++i) {
const char* pTmpSql = *ppSql;
bool ignoreComma = false;
@ -1781,7 +1792,7 @@ static int32_t doGetStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt*
if (pCols->pColIndex[i] < numOfCols) {
const SSchema* pSchema = &pSchemas[pCols->pColIndex[i]];
SColVal* pVal = taosArrayGet(pStbRowsCxt->aColVals, pCols->pColIndex[i]);
code = parseValueToken(pCxt, ppSql, pToken, (SSchema*)pSchema, getTableInfo(pStbRowsCxt->pStbMeta).precision, pVal);
code = parseValueToken(pCxt, ppSql, pToken, (SSchema*)pSchema, precision, pVal);
if (TK_NK_VARIABLE == pToken->type) {
code = buildInvalidOperationMsg(&pCxt->msg, "not expected row value");
}
@ -1793,11 +1804,11 @@ static int32_t doGetStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt*
++(*pNumOfTagTokens);
} else {
code = checkAndTrimValue(pToken, pCxt->tmpTokenBuf, &pCxt->msg, pTagSchema->type);
if (TK_NK_VARIABLE == pToken->type) {
if (code == TSDB_CODE_SUCCESS && TK_NK_VARIABLE == pToken->type) {
code = buildInvalidOperationMsg(&pCxt->msg, "not expected row value");
}
if (code == TSDB_CODE_SUCCESS) {
code = parseTagValue(pCxt, pStmt, ppSql, (SSchema*)pTagSchema, pToken, pTagNames, pTagVals, &pStbRowsCxt->pTag);
code = parseTagValue(&pCxt->msg, ppSql, precision, (SSchema*)pTagSchema, pToken, pTagNames, pTagVals, &pStbRowsCxt->pTag);
}
}
}

View File

@ -668,7 +668,7 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
*tokenId = TK_NK_ALIAS; // must be alias
return i;
}
if ((i == 4 && strncasecmp(z, "true", 4) == 0) || (i == 5 && strncasecmp(z, "false", 5) == 0)) {
if (IS_TRUE_STR(z, i) || IS_FALSE_STR(z, i)) {
*tokenId = TK_NK_BOOL;
return i;
}

View File

@ -1638,12 +1638,13 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
void* data = NULL;
uint32_t size = 0;
bool isHexChar = isHex(pVal->literal, strlen(pVal->literal));
uint32_t vlen = strlen(pVal->literal);
bool isHexChar = isHex(pVal->literal, vlen);
if (isHexChar) {
if (!isValidateHex(pVal->literal, strlen(pVal->literal))) {
if (!isValidateHex(pVal->literal, vlen)) {
return TSDB_CODE_PAR_INVALID_VARBINARY;
}
if (taosHex2Ascii(pVal->literal, strlen(pVal->literal), &data, &size) < 0) {
if (taosHex2Ascii(pVal->literal, vlen, &data, &size) < 0) {
return TSDB_CODE_OUT_OF_MEMORY;
}
} else {
@ -1667,14 +1668,15 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
}
case TSDB_DATA_TYPE_VARCHAR:
case TSDB_DATA_TYPE_GEOMETRY: {
if (strict && (pVal->node.resType.bytes > targetDt.bytes - VARSTR_HEADER_SIZE)) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
int32_t vlen = IS_VAR_DATA_TYPE(pVal->node.resType.type) ? pVal->node.resType.bytes : strlen(pVal->literal);
if (strict && (vlen > targetDt.bytes - VARSTR_HEADER_SIZE)) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_VALUE_TOO_LONG, pVal->literal);
}
pVal->datum.p = taosMemoryCalloc(1, targetDt.bytes + 1);
int32_t len = TMIN(targetDt.bytes - VARSTR_HEADER_SIZE, vlen);
pVal->datum.p = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE + 1);
if (NULL == pVal->datum.p) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY);
}
int32_t len = TMIN(targetDt.bytes - VARSTR_HEADER_SIZE, pVal->node.resType.bytes);
varDataSetLen(pVal->datum.p, len);
strncpy(varDataVal(pVal->datum.p), pVal->literal, len);
break;
@ -10749,75 +10751,6 @@ static int32_t createCastFuncForTag(STranslateContext* pCxt, SNode* pNode, SData
return code;
}
static int32_t createTagValFromExpr(STranslateContext* pCxt, SDataType targetDt, SNode* pNode, SValueNode** pVal) {
SNode* pCast = NULL;
int32_t code = createCastFuncForTag(pCxt, pNode, targetDt, &pCast);
SNode* pNew = NULL;
if (TSDB_CODE_SUCCESS == code) {
code = scalarCalculateConstants(pCast, &pNew);
}
if (TSDB_CODE_SUCCESS == code) {
pCast = pNew;
if (QUERY_NODE_VALUE != nodeType(pCast)) {
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)pNode)->aliasName);
}
}
if (TSDB_CODE_SUCCESS == code) {
*pVal = (SValueNode*)pCast;
} else {
nodesDestroyNode(pCast);
}
return code;
}
static int32_t createTagValFromVal(STranslateContext* pCxt, SDataType targetDt, SNode* pNode, SValueNode** pVal) {
SValueNode* pTempVal = (SValueNode*)nodesCloneNode(pNode);
if (NULL == pTempVal) {
return TSDB_CODE_OUT_OF_MEMORY;
}
if (DEAL_RES_ERROR == translateValueImpl(pCxt, pTempVal, targetDt, true)) {
nodesDestroyNode((SNode*)pTempVal);
return pCxt->errCode;
}
*pVal = pTempVal;
return TSDB_CODE_SUCCESS;
}
static int32_t createTagVal(STranslateContext* pCxt, uint8_t precision, SSchema* pSchema, SNode* pNode,
SValueNode** pVal) {
if (QUERY_NODE_VALUE == nodeType(pNode)) {
return createTagValFromVal(pCxt, schemaToDataType(precision, pSchema), pNode, pVal);
} else {
return createTagValFromExpr(pCxt, schemaToDataType(precision, pSchema), pNode, pVal);
}
}
static int32_t buildJsonTagVal(STranslateContext* pCxt, SSchema* pTagSchema, SValueNode* pVal, SArray* pTagArray,
STag** ppTag) {
if (pVal->literal && strlen(pVal->literal) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pVal->literal);
}
return parseJsontoTagData(pVal->literal, pTagArray, ppTag, &pCxt->msgBuf);
}
static int32_t buildNormalTagVal(STranslateContext* pCxt, SSchema* pTagSchema, SValueNode* pVal, SArray* pTagArray) {
if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) {
void* nodeVal = nodesGetValueFromNode(pVal);
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
// strcpy(val.colName, pTagSchema->name);
if (IS_VAR_DATA_TYPE(pTagSchema->type)) {
val.pData = varDataVal(nodeVal);
val.nData = varDataLen(nodeVal);
} else {
memcpy(&val.i64, nodeVal, pTagSchema->bytes);
}
taosArrayPush(pTagArray, &val);
}
return TSDB_CODE_SUCCESS;
}
static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta,
STag** ppTag, SArray* tagName) {
int32_t numOfTags = getNumOfTags(pSuperTableMeta);
@ -10833,42 +10766,56 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
int32_t code = TSDB_CODE_SUCCESS;
bool isJson = false;
SNodeList* pVals = NULL;
SNode * pTag = NULL, *pNode = NULL;
FORBOTH(pTag, pStmt->pSpecificTags, pNode, pStmt->pValsOfTags) {
SColumnNode* pCol = (SColumnNode*)pTag;
SSchema* pSchema = getTagSchema(pSuperTableMeta, pCol->colName);
if (NULL == pSchema) {
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAG_NAME, pCol->colName);
}
SValueNode* pVal = NULL;
bool isJson = false;
SNode * pTagNode = NULL, *pNode = NULL;
uint8_t precision = pSuperTableMeta->tableInfo.precision;
SToken token;
char tokenBuf[TSDB_MAX_TAGS_LEN];
const char* tagStr = NULL;
FORBOTH(pTagNode, pStmt->pSpecificTags, pNode, pStmt->pValsOfTags) {
tagStr = ((SValueNode*)pNode)->literal;
NEXT_TOKEN_WITH_PREV(tagStr, token);
SSchema* pSchema = NULL;
if (TSDB_CODE_SUCCESS == code) {
code = createTagVal(pCxt, pSuperTableMeta->tableInfo.precision, pSchema, pNode, &pVal);
if ((pSchema = getTagSchema(pSuperTableMeta, ((SColumnNode*)pTagNode)->colName))) {
code = checkAndTrimValue(&token, tokenBuf, &pCxt->msgBuf, pSchema->type);
if (TSDB_CODE_SUCCESS == code && TK_NK_VARIABLE == token.type) {
code = TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
}
} else {
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAG_NAME, ((SColumnNode*)pTagNode)->colName);
}
}
if (TSDB_CODE_SUCCESS == code) {
if (pSchema->type == TSDB_DATA_TYPE_JSON) {
isJson = true;
code = buildJsonTagVal(pCxt, pSchema, pVal, pTagArray, ppTag);
taosArrayPush(tagName, pCol->colName);
} else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) {
code = buildNormalTagVal(pCxt, pSchema, pVal, pTagArray);
taosArrayPush(tagName, pCol->colName);
}
code = parseTagValue(&pCxt->msgBuf, &tagStr, precision, pSchema, &token, tagName, pTagArray, ppTag);
}
if (TSDB_CODE_SUCCESS == code) {
NEXT_VALID_TOKEN(tagStr, token);
if (token.n != 0) {
code = buildSyntaxErrMsg(&pCxt->msgBuf, "not expected tags values", token.z);
}
}
if (TSDB_CODE_SUCCESS == code) {
code = nodesListMakeAppend(&pVals, (SNode*)pVal);
}
if (TSDB_CODE_SUCCESS != code) {
break;
}
}
if (TSDB_CODE_SUCCESS == code && !isJson) {
code = tTagNew(pTagArray, 1, false, ppTag);
}
nodesDestroyList(pVals);
for (int i = 0; i < taosArrayGetSize(pTagArray); ++i) {
STagVal* p = (STagVal*)taosArrayGet(pTagArray, i);
if (IS_VAR_DATA_TYPE(p->type)) {
taosMemoryFreeClear(p->pData);
}
}
taosArrayDestroy(pTagArray);
return code;
}
@ -10886,51 +10833,52 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau
int32_t code = TSDB_CODE_SUCCESS;
bool isJson = false;
int32_t index = 0;
SSchema* pTagSchemas = getTableTagSchema(pSuperTableMeta);
SNodeList* pVals = NULL;
SNode* pNode;
bool isJson = false;
SNode* pNode;
uint8_t precision = pSuperTableMeta->tableInfo.precision;
SSchema* pTagSchema = getTableTagSchema(pSuperTableMeta);
SToken token;
char tokenBuf[TSDB_MAX_TAGS_LEN];
const char* tagStr = NULL;
FOREACH(pNode, pStmt->pValsOfTags) {
SValueNode* pVal = NULL;
SSchema* pTagSchema = pTagSchemas + index;
code = createTagVal(pCxt, pSuperTableMeta->tableInfo.precision, pTagSchema, pNode, &pVal);
tagStr = ((SValueNode*)pNode)->literal;
NEXT_TOKEN_WITH_PREV(tagStr, token);
code = checkAndTrimValue(&token, tokenBuf, &pCxt->msgBuf, pTagSchema->type);
if (TSDB_CODE_SUCCESS == code && TK_NK_VARIABLE == token.type) {
code = buildSyntaxErrMsg(&pCxt->msgBuf, "not expected tags values", token.z);
}
if (TSDB_CODE_SUCCESS == code) {
if (pTagSchema->type == TSDB_DATA_TYPE_JSON) {
isJson = true;
code = buildJsonTagVal(pCxt, pTagSchema, pVal, pTagArray, ppTag);
if (TSDB_CODE_SUCCESS != code) {
nodesDestroyNode((SNode*)pVal);
}
taosArrayPush(tagName, pTagSchema->name);
} else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL && !pVal->isNull) {
char* tmpVal = nodesGetValueFromNode(pVal);
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
// strcpy(val.colName, pTagSchema->name);
if (IS_VAR_DATA_TYPE(pTagSchema->type)) {
val.pData = varDataVal(tmpVal);
val.nData = varDataLen(tmpVal);
} else {
memcpy(&val.i64, tmpVal, pTagSchema->bytes);
}
taosArrayPush(pTagArray, &val);
taosArrayPush(tagName, pTagSchema->name);
}
code = parseTagValue(&pCxt->msgBuf, &tagStr, precision, pTagSchema, &token, tagName, pTagArray, ppTag);
}
if (TSDB_CODE_SUCCESS == code) {
NEXT_VALID_TOKEN(tagStr, token);
if (token.n != 0) {
code = buildSyntaxErrMsg(&pCxt->msgBuf, "not expected tags values", token.z);
}
}
if (TSDB_CODE_SUCCESS == code) {
code = nodesListMakeAppend(&pVals, (SNode*)pVal);
}
if (TSDB_CODE_SUCCESS != code) {
break;
}
++index;
++pTagSchema;
}
if (TSDB_CODE_SUCCESS == code && !isJson) {
code = tTagNew(pTagArray, 1, false, ppTag);
}
nodesDestroyList(pVals);
for (int32_t i = 0; i < TARRAY_SIZE(pTagArray); ++i) {
STagVal* p = (STagVal*)TARRAY_GET_ELEM(pTagArray, i);
if (IS_VAR_DATA_TYPE(p->type)) {
taosMemoryFreeClear(p->pData);
}
}
taosArrayDestroy(pTagArray);
return code;
}
@ -11191,58 +11139,68 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE, "Invalid tag name: %s",
pStmt->colName);
}
pReq->tagName = taosStrdup(pStmt->colName);
if (NULL == pReq->tagName) {
return TSDB_CODE_OUT_OF_MEMORY;
}
pReq->pTagArray = taosArrayInit(1, sizeof(STagVal));
if (NULL == pReq->pTagArray) {
return TSDB_CODE_OUT_OF_MEMORY;
}
pReq->colId = pSchema->colId;
pReq->tagType = pSchema->type;
SDataType targetDt = schemaToDataType(pTableMeta->tableInfo.precision, pSchema);
int32_t code = 0;
if (QUERY_NODE_VALUE != pStmt->pVal->node.type) {
SValueNode* pVal = NULL;
pCxt->errCode = createTagValFromExpr(pCxt, targetDt, (SNode*)pStmt->pVal, &pVal);
if (pCxt->errCode) {
return pCxt->errCode;
}
nodesDestroyNode((SNode*)pStmt->pVal);
pStmt->pVal = pVal;
} else if (DEAL_RES_ERROR == translateValueImpl(pCxt, pStmt->pVal, targetDt, true)) {
return pCxt->errCode;
}
pReq->tagType = targetDt.type;
if (targetDt.type == TSDB_DATA_TYPE_JSON) {
if (pStmt->pVal->literal &&
strlen(pStmt->pVal->literal) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pStmt->pVal->literal);
}
SArray* pTagVals = taosArrayInit(1, sizeof(STagVal));
int32_t code = TSDB_CODE_SUCCESS;
STag* pTag = NULL;
code = parseJsontoTagData(pStmt->pVal->literal, pTagVals, &pTag, &pCxt->msgBuf);
taosArrayDestroy(pTagVals);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
pReq->nTagVal = pTag->len;
pReq->pTagVal = (uint8_t*)pTag;
pStmt->pVal->datum.p = (char*)pTag; // for free
} else {
pReq->isNull = pStmt->pVal->isNull;
pReq->nTagVal = pStmt->pVal->node.resType.bytes;
pReq->pTagVal = nodesGetValueFromNode(pStmt->pVal);
// data and length are seperated for new tag format STagVal
if (IS_VAR_DATA_TYPE(pStmt->pVal->node.resType.type)) {
pReq->nTagVal = varDataLen(pReq->pTagVal);
pReq->pTagVal = varDataVal(pReq->pTagVal);
STag* pTag = NULL;
SToken token;
char tokenBuf[TSDB_MAX_TAGS_LEN];
const char* tagStr = pStmt->pVal->literal;
NEXT_TOKEN_WITH_PREV(tagStr, token);
if (TSDB_CODE_SUCCESS == code) {
code = checkAndTrimValue(&token, tokenBuf, &pCxt->msgBuf, pSchema->type);
if (TSDB_CODE_SUCCESS == code && TK_NK_VARIABLE == token.type) {
code = buildSyntaxErrMsg(&pCxt->msgBuf, "not expected tags values", token.z);
}
}
return TSDB_CODE_SUCCESS;
if (TSDB_CODE_SUCCESS == code) {
code = parseTagValue(&pCxt->msgBuf, &tagStr, pTableMeta->tableInfo.precision, pSchema, &token, NULL,
pReq->pTagArray, &pTag);
if (pSchema->type == TSDB_DATA_TYPE_JSON && token.type == TK_NULL && code == TSDB_CODE_SUCCESS) {
pReq->tagFree = true;
}
}
if (TSDB_CODE_SUCCESS == code && tagStr) {
NEXT_VALID_TOKEN(tagStr, token);
if (token.n != 0) {
code = buildSyntaxErrMsg(&pCxt->msgBuf, "not expected tags values", token.z);
}
}
if (TSDB_CODE_SUCCESS == code) {
if (pSchema->type == TSDB_DATA_TYPE_JSON) {
pReq->nTagVal = pTag->len;
pReq->pTagVal = (uint8_t*)pTag;
pStmt->pVal->datum.p = (char*)pTag; // for free
} else {
STagVal* pTagVal = taosArrayGet(pReq->pTagArray, 0);
if (pTagVal) {
pReq->isNull = false;
if (IS_VAR_DATA_TYPE(pSchema->type)) {
pReq->nTagVal = pTagVal->nData;
pReq->pTagVal = pTagVal->pData;
} else {
pReq->nTagVal = pSchema->bytes;
pReq->pTagVal = (uint8_t*)&pTagVal->i64;
}
} else {
pReq->isNull = true;
}
}
}
return code;
}
static int32_t buildAddColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta,
@ -11466,6 +11424,14 @@ static void destoryAlterTbReq(SVAlterTbReq* pReq) {
taosMemoryFree(pReq->colNewName);
taosMemoryFree(pReq->tagName);
taosMemoryFree(pReq->newComment);
for (int i = 0; i < taosArrayGetSize(pReq->pTagArray); ++i) {
STagVal* p = (STagVal*)taosArrayGet(pReq->pTagArray, i);
if (IS_VAR_DATA_TYPE(p->type)) {
taosMemoryFreeClear(p->pData);
}
}
taosArrayDestroy(pReq->pTagArray);
if(pReq->tagFree) tTagFree((STag*)pReq->pTagVal);
}
static int32_t rewriteAlterTableImpl(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta,

View File

@ -370,7 +370,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi
SHashObj* keyHash = NULL;
int32_t size = 0;
// set json NULL data
if (!json || strtrim((char*)json) == 0 || strcasecmp(json, TSDB_DATA_NULL_STR_L) == 0) {
if (!json || strcasecmp(json, TSDB_DATA_NULL_STR_L) == 0 || strtrim((char*)json) == 0) {
retCode = TSDB_CODE_SUCCESS;
goto end;
}

File diff suppressed because it is too large Load Diff

View File

@ -784,7 +784,7 @@ TEST_F(ParserInitialATest, alterTableSemanticCheck) {
run("ALTER TABLE st1s1 DROP TAG tag1", TSDB_CODE_PAR_INVALID_ALTER_TABLE);
run("ALTER TABLE st1s1 MODIFY TAG tag2 VARCHAR(30)", TSDB_CODE_PAR_INVALID_ALTER_TABLE);
run("ALTER TABLE st1s1 RENAME TAG tag1 tag11", TSDB_CODE_PAR_INVALID_ALTER_TABLE);
run("ALTER TABLE st1s1 SET TAG tag2 = '123456789012345678901'", TSDB_CODE_PAR_WRONG_VALUE_TYPE);
run("ALTER TABLE st1s1 SET TAG tag2 = '123456789012345678901'", TSDB_CODE_PAR_VALUE_TOO_LONG);
}
/*

View File

@ -485,7 +485,7 @@ bool isHex(const char* z, uint32_t n){
}
bool isValidateHex(const char* z, uint32_t n){
if(n % 2 != 0) return false;
if((n & 1) != 0) return false;
for(size_t i = HEX_PREFIX_LEN; i < n; i++){
if(isxdigit(z[i]) == 0){
return false;
@ -494,13 +494,16 @@ bool isValidateHex(const char* z, uint32_t n){
return true;
}
int32_t taosHex2Ascii(const char *z, uint32_t n, void** data, uint32_t* size){
n -= HEX_PREFIX_LEN; // remove 0x
int32_t taosHex2Ascii(const char *z, uint32_t n, void **data, uint32_t *size) {
n -= HEX_PREFIX_LEN; // remove 0x
z += HEX_PREFIX_LEN;
*size = n / HEX_PREFIX_LEN;
if(*size == 0) return 0;
uint8_t* tmp = (uint8_t*)taosMemoryCalloc(*size, 1);
if(tmp == NULL) return -1;
if (*size == 0) {
if (!(*data = taosStrdup(""))) return -1;
return 0;
}
uint8_t *tmp = (uint8_t *)taosMemoryCalloc(*size, 1);
if (tmp == NULL) return -1;
int8_t num = 0;
uint8_t *byte = tmp + *size - 1;

View File

@ -615,7 +615,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_GET_META_ERROR, "Fail to get table i
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS, "Not unique table/alias")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_SYSTABLE_NOT_ALLOWED_FUNC, "System table not allowed")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_SYSTABLE_NOT_ALLOWED, "System table not allowed")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_VARBINARY, "Invalidate varbinary value")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_VARBINARY, "Invalid varbinary value")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_IP_RANGE, "Invalid IPV4 address ranges")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTERNAL_ERROR, "Parser internal error")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Invalid stream query")

View File

@ -229,6 +229,7 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dataFromTsdbNWal.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dataFromTsdbNWal-multiCtb.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_taosx.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_ts4563.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_replay.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqSeekAndCommit.py
,,n,system-test,python3 ./test.py -f 7-tmq/tmq_offset.py
@ -327,6 +328,7 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/db_tb_name_check.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/InsertFuturets.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/insert_wide_column.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/insert_column_value.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_benchmark.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k.py -R
@ -1056,6 +1058,13 @@
,,y,script,./test.sh -f tsim/parser/columnValue_smallint.sim
,,y,script,./test.sh -f tsim/parser/columnValue_tinyint.sim
,,y,script,./test.sh -f tsim/parser/columnValue_unsign.sim
,,y,script,./test.sh -f tsim/parser/columnValue_uint.sim
,,y,script,./test.sh -f tsim/parser/columnValue_timestamp.sim
,,y,script,./test.sh -f tsim/parser/columnValue_varchar.sim
,,y,script,./test.sh -f tsim/parser/columnValue_nchar.sim
,,y,script,./test.sh -f tsim/parser/columnValue_varbinary.sim
,,y,script,./test.sh -f tsim/parser/columnValue_json.sim
,,y,script,./test.sh -f tsim/parser/columnValue_geometry.sim
,,y,script,./test.sh -f tsim/parser/condition.sim
,,y,script,./test.sh -f tsim/parser/condition_scl.sim
,,y,script,./test.sh -f tsim/parser/constCol.sim

View File

@ -28,10 +28,26 @@ if $data05 != NULL then
return -1
endi
sql_error create table st_bigint_2 using mt_bigint tags ('NULL')
sql_error create table st_bigint_3 using mt_bigint tags ('NULL')
sql_error create table st_bigint_4 using mt_bigint tags ("NULL")
sql_error create table st_bigint_5 using mt_bigint tags ("NULL")
sql create table st_bigint_2 using mt_bigint tags ('NULL')
sql show tags from st_bigint_2
if $data05 != NULL then
return -1
endi
sql create table st_bigint_3 using mt_bigint tags ('NULL')
sql show tags from st_bigint_3
if $data05 != NULL then
return -1
endi
sql create table st_bigint_4 using mt_bigint tags ("NULL")
sql show tags from st_bigint_4
if $data05 != NULL then
return -1
endi
sql create table st_bigint_5 using mt_bigint tags ("NULL")
sql show tags from st_bigint_5
if $data05 != NULL then
return -1
endi
sql create table st_bigint_6 using mt_bigint tags (-9223372036854775807)
sql show tags from st_bigint_6
@ -97,6 +113,39 @@ if $data01 != NULL then
return -1
endi
sql insert into st_bigint_2 values (now, NULL)
sql select * from st_bigint_2
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_bigint_3 values (now, NULL)
sql select * from st_bigint_3
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_bigint_4 values (now, NULL)
sql select * from st_bigint_4
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_bigint_5 values (now, NULL)
sql select * from st_bigint_5
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_bigint_6 values (now, 9223372036854775807)
sql select * from st_bigint_6
if $rows != 1 then
@ -348,7 +397,7 @@ sql_error create table st_bigint_e0 using mt_bigint tags ("123abc")
sql_error create table st_bigint_e0 using mt_bigint tags (abc)
sql_error create table st_bigint_e0 using mt_bigint tags ("abc")
sql_error create table st_bigint_e0 using mt_bigint tags (" ")
sql create table st_bigint_e0_error using mt_bigint tags ('')
sql_error create table st_bigint_e0_error using mt_bigint tags ('')
sql create table st_bigint_e0 using mt_bigint tags (123)
sql create table st_bigint_e1 using mt_bigint tags (123)
@ -401,7 +450,7 @@ sql_error insert into st_bigint_e20 using mt_bigint tags ("123abc") values (now,
sql_error insert into st_bigint_e22 using mt_bigint tags (abc) values (now, -033)
sql_error insert into st_bigint_e23 using mt_bigint tags ("abc") values (now, -033)
sql_error insert into st_bigint_e24 using mt_bigint tags (" ") values (now, -033)
sql insert into st_bigint_e25 using mt_bigint tags ('') values (now, -033)
sql_error insert into st_bigint_e25 using mt_bigint tags ('') values (now, -033)
sql insert into st_bigint_e13 using mt_bigint tags (033) values (now, 00062)
sql insert into st_bigint_e14 using mt_bigint tags (033) values (now, 00062)
@ -417,15 +466,17 @@ sql insert into st_bigint_e23 using mt_bigint tags (033) values (now, 00062)
sql insert into st_bigint_e24 using mt_bigint tags (033) values (now, 00062)
sql insert into st_bigint_e25 using mt_bigint tags (033) values (now, 00062)
#sql alter table st_bigint_e13 set tag tagname=9223372036854775808
#sql_error alter table st_bigint_e14 set tag tagname=-9223372036854775808
#sql alter table st_bigint_e15 set tag tagname=92233720368547758080
#sql_error alter table st_bigint_e16 set tag tagname=-92233720368547758080
#sql_error alter table st_bigint_e19 set tag tagname=123abc
#sql_error alter table st_bigint_e20 set tag tagname="123abc"
#sql_error alter table st_bigint_e22 set tag tagname=abc
#sql_error alter table st_bigint_e23 set tag tagname="abc"
#sql_error alter table st_bigint_e24 set tag tagname=" "
#sql_error alter table st_bigint_e25 set tag tagname=''
sql_error alter table st_bigint_e13 set tag tagname=9223372036854775808
sql alter table st_bigint_e13 set tag tagname=9223372036854775807
sql_error alter table st_bigint_e14 set tag tagname=-9223372036854775809
sql alter table st_bigint_e14 set tag tagname=-9223372036854775808
sql_error alter table st_bigint_e15 set tag tagname=92233720368547758080
sql_error alter table st_bigint_e16 set tag tagname=-92233720368547758080
sql_error alter table st_bigint_e19 set tag tagname=123abc
sql_error alter table st_bigint_e20 set tag tagname="123abc"
sql_error alter table st_bigint_e22 set tag tagname=abc
sql_error alter table st_bigint_e23 set tag tagname="abc"
sql_error alter table st_bigint_e24 set tag tagname=" "
sql_error alter table st_bigint_e25 set tag tagname=''
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -31,26 +31,26 @@ if $data05 != NULL then
endi
sql create table st_bool_2 using mt_bool tags ('NULL')
sql show tags from st_bool_2
if $data05 != false then
print ==3== expect: false, actually: $data05
if $data05 != NULL then
print ==3== expect: NULL, actually: $data05
return -1
endi
sql create table st_bool_3 using mt_bool tags ('NULL')
sql show tags from st_bool_3
if $data05 != false then
print ==4== expect: false, actually: $data05
if $data05 != NULL then
print ==4== expect: NULL, actually: $data05
return -1
endi
sql create table st_bool_4 using mt_bool tags ("NULL")
sql show tags from st_bool_4
if $data05 != false then
print ==5== expect: false, actually: $data05
if $data05 != NULL then
print ==5== expect: NULL, actually: $data05
return -1
endi
sql create table st_bool_5 using mt_bool tags ("NULL")
sql show tags from st_bool_5
if $data05 != false then
print ==6== expect: false, actually: $data05
if $data05 != NULL then
print ==6== expect: NULL, actually: $data05
return -1
endi
sql create table st_bool_6 using mt_bool tags ("true")
@ -113,16 +113,94 @@ if $data05 != true then
print ==16== expect: 1, actually: $data00
return -1
endi
sql create table st_bool_15_0 using mt_bool tags (+300)
sql show tags from st_bool_15_0
sql create table st_bool_16 using mt_bool tags (+300)
sql show tags from st_bool_16
if $data05 != true then
print ==16== expect: 1, actually: $data00
return -1
endi
sql create table st_bool_15_1 using mt_bool tags (-8.03)
sql show tags from st_bool_15_1
sql create table st_bool_17 using mt_bool tags (-8.03)
sql show tags from st_bool_17
if $data05 != true then
print ==16== expect: 1, actually: $data00
return -1
endi
sql create table st_bool_18 using mt_bool tags ("-8.03")
sql show tags from st_bool_18
if $data05 != true then
return -1
endi
sql create table st_bool_19 using mt_bool tags ("+300")
sql show tags from st_bool_19
if $data05 != true then
return -1
endi
sql create table st_bool_20 using mt_bool tags ("-8e+2")
sql show tags from st_bool_20
if $data05 != true then
return -1
endi
sql create table st_bool_21 using mt_bool tags ("0x01")
sql show tags from st_bool_21
if $data05 != true then
return -1
endi
sql create table st_bool_22 using mt_bool tags ("0b01")
sql show tags from st_bool_22
if $data05 != true then
return -1
endi
sql create table st_bool_23 using mt_bool tags ("+0x01")
sql show tags from st_bool_23
if $data05 != true then
return -1
endi
sql create table st_bool_24 using mt_bool tags ("-0b00")
sql show tags from st_bool_24
if $data05 != false then
return -1
endi
sql create table st_bool_26 using mt_bool tags ("-0.11e-30")
sql show tags from st_bool_26
if $data05 != true then
return -1
endi
sql create table st_bool_27 using mt_bool tags ("-1.0e-307")
sql show tags from st_bool_27
if $data05 != true then
return -1
endi
sql create table st_bool_28 using mt_bool tags ( -1e-1 )
sql show tags from st_bool_28
if $data05 != true then
return -1
endi
sql create table st_bool_29 using mt_bool tags (-0.11e-30)
sql show tags from st_bool_29
if $data05 != true then
return -1
endi
sql create table st_bool_30 using mt_bool tags (-1.1e-307)
sql show tags from st_bool_30
if $data05 != true then
return -1
endi
sql create table st_bool_31 using mt_bool tags ( 0x01)
sql show tags from st_bool_31
if $data05 != true then
return -1
endi
sql create table st_bool_32 using mt_bool tags (0b01 )
sql show tags from st_bool_32
if $data05 != true then
return -1
endi
sql create table st_bool_33 using mt_bool tags (+0x01)
sql show tags from st_bool_33
if $data05 != true then
return -1
endi
sql create table st_bool_34 using mt_bool tags ( -0b00 )
sql show tags from st_bool_34
if $data05 != false then
return -1
endi
@ -271,8 +349,8 @@ if $data01 != 1 then
print ==32== expect: true, actually: $data01
return -1
endi
sql insert into st_bool_15_0 values (now, +300)
sql select * from st_bool_15_0
sql insert into st_bool_16 values (now, +300)
sql select * from st_bool_16
if $rows != 1 then
return -1
endi
@ -280,8 +358,8 @@ if $data01 != 1 then
print ==32== expect: true, actually: $data01
return -1
endi
sql insert into st_bool_15_1 values (now, -3.15)
sql select * from st_bool_15_1
sql insert into st_bool_17 values (now, -3.15)
sql select * from st_bool_17
if $rows != 1 then
return -1
endi
@ -289,304 +367,529 @@ if $data01 != 1 then
print ==32== expect: true, actually: $data01
return -1
endi
sql insert into st_bool_18 values(now,"-8.03")
sql select * from st_bool_18
if $data01 != 1 then
return -1
endi
sql insert into st_bool_19 values(now,"+300")
sql select * from st_bool_19
if $data01 != 1 then
return -1
endi
sql insert into st_bool_20 values(now,"-8e+2")
sql select * from st_bool_20
if $data01 != 1 then
return -1
endi
sql insert into st_bool_21 values(now,"0x01")
sql select * from st_bool_21
if $data01 != 1 then
return -1
endi
sql insert into st_bool_22 values(now,"0b01")
sql select * from st_bool_22
if $data01 != 1 then
return -1
endi
sql insert into st_bool_23 values(now,"+0x01")
sql select * from st_bool_23
if $data01 != 1 then
return -1
endi
sql insert into st_bool_24 values(now,"-0b00")
sql select * from st_bool_24
if $data01 != 0 then
return -1
endi
sql insert into st_bool_26 values(now,"-0.11e-30")
sql select * from st_bool_26
if $data01 != 1 then
return -1
endi
sql insert into st_bool_27 values(now,"-1.0e-307")
sql select * from st_bool_27
if $data01 != 1 then
return -1
endi
sql insert into st_bool_28 values(now, -1e-1 )
sql select * from st_bool_28
if $data01 != 1 then
return -1
endi
sql insert into st_bool_29 values(now,-0.11e-30)
sql select * from st_bool_29
if $data01 != 1 then
return -1
endi
sql insert into st_bool_30 values(now,-1.1e-307)
sql select * from st_bool_30
if $data01 != 1 then
return -1
endi
sql insert into st_bool_31 values(now, 0x01)
sql select * from st_bool_31
if $data01 != 1 then
return -1
endi
sql insert into st_bool_32 values(now,0b01 )
sql select * from st_bool_32
if $data01 != 1 then
return -1
endi
sql insert into st_bool_33 values(now,+0x01)
sql select * from st_bool_33
if $data01 != 1 then
return -1
endi
sql insert into st_bool_34 values(now, -0b00 )
sql select * from st_bool_34
if $data01 != 0 then
return -1
endi
## case 02: dynamic create table for test tag values
sql insert into st_bool_16 using mt_bool tags (NULL) values (now, NULL)
sql show create table st_bool_16
sql show tags from st_bool_16
sql insert into st_bool_116 using mt_bool tags (NULL) values (now, NULL)
sql show create table st_bool_116
sql show tags from st_bool_116
if $data05 != NULL then
print ==33== expect: NULL, actually: $data00
return -1
endi
sql select * from st_bool_16
sql select * from st_bool_116
if $data01 != NULL then
print ==34== expect: NULL, actually: $data01
return -1
endi
sql insert into st_bool_17 using mt_bool tags (NULL) values (now, NULL)
sql show tags from st_bool_17
sql insert into st_bool_117 using mt_bool tags (NULL) values (now, NULL)
sql show tags from st_bool_117
if $data05 != NULL then
print ==35== expect: NULL, actually: $data00
return -1
endi
sql select * from st_bool_17
sql select * from st_bool_117
if $data01 != NULL then
print ==36== expect: NULL, actually: $data01
return -1
endi
sql insert into st_bool_18 using mt_bool tags ('NULL') values (now, 'NULL')
sql show tags from st_bool_18
sql insert into st_bool_118 using mt_bool tags ('NULL') values (now, 'NULL')
sql show tags from st_bool_118
if $data05 != NULL then
print ==37== expect: NULL, actually: $data00
return -1
endi
sql select * from st_bool_18
sql select * from st_bool_118
if $data01 != NULL then
print ==38== expect: NULL, actually: $data01
return -1
endi
sql insert into st_bool_19 using mt_bool tags ('NULL') values (now, 'NULL')
sql show tags from st_bool_19
sql insert into st_bool_119 using mt_bool tags ('NULL') values (now, 'NULL')
sql show tags from st_bool_119
if $data05 != NULL then
print ==39== expect: NULL, actually: $data00
return -1
endi
sql select * from st_bool_19
sql select * from st_bool_119
if $data01 != NULL then
print ==40== expect: NULL, actually: $data01
return -1
endi
sql insert into st_bool_20 using mt_bool tags ("NULL") values (now, "NULL")
sql show tags from st_bool_20
sql insert into st_bool_120 using mt_bool tags ("NULL") values (now, "NULL")
sql show tags from st_bool_120
if $data05 != NULL then
print ==41== expect: NULL, actually: $data00
return -1
endi
sql select * from st_bool_20
sql select * from st_bool_120
if $data01 != NULL then
print ==42== expect: NULL, actually: $data01
return -1
endi
sql insert into st_bool_21 using mt_bool tags ("NULL") values (now, "NULL")
sql show tags from st_bool_21
sql insert into st_bool_121 using mt_bool tags ("NULL") values (now, "NULL")
sql show tags from st_bool_121
if $data05 != NULL then
print ==43== expect: NULL, actually: $data00
return -1
endi
sql select * from st_bool_21
sql select * from st_bool_121
if $data01 != NULL then
print ==44== expect: NULL, actually: $data01
return -1
endi
sql insert into st_bool_22 using mt_bool tags ("true") values (now, "true")
sql show tags from st_bool_22
sql insert into st_bool_122 using mt_bool tags ("true") values (now, "true")
sql show tags from st_bool_122
if $data05 != true then
print ==45== expect: 1, actually: $data00
return -1
endi
sql select * from st_bool_22
sql select * from st_bool_122
if $data01 != 1 then
print ==46== expect: 1, actually: $data01
return -1
endi
sql insert into st_bool_23 using mt_bool tags ('true') values (now, 'true')
sql show tags from st_bool_23
sql insert into st_bool_123 using mt_bool tags ('true') values (now, 'true')
sql show tags from st_bool_123
if $data05 != true then
print ==47== expect: 1, actually: $data00
return -1
endi
sql select * from st_bool_23
sql select * from st_bool_123
if $data01 != 1 then
print ==48== expect: 1, actually: $data01
return -1
endi
sql insert into st_bool_24 using mt_bool tags (true) values (now, true)
sql show tags from st_bool_24
sql insert into st_bool_124 using mt_bool tags (true) values (now, true)
sql show tags from st_bool_124
if $data05 != true then
print ==49== expect: 1, actually: $data00
return -1
endi
sql select * from st_bool_24
sql select * from st_bool_124
if $data01 != 1 then
print ==50== expect: 1, actually: $data01
return -1
endi
sql insert into st_bool_25 using mt_bool tags ("false") values (now, "false")
sql show tags from st_bool_25
sql insert into st_bool_125 using mt_bool tags ("false") values (now, "false")
sql show tags from st_bool_125
if $data05 != false then
print ==51== expect: 0, actually: $data00
return -1
endi
sql select * from st_bool_25
sql select * from st_bool_125
if $data01 != 0 then
print ==52== expect: 0, actually: $data01
return -1
endi
sql insert into st_bool_26 using mt_bool tags ('false') values (now, 'false')
sql show tags from st_bool_26
sql insert into st_bool_126 using mt_bool tags ('false') values (now, 'false')
sql show tags from st_bool_126
if $data05 != false then
print ==53== expect: 0, actually: $data00
return -1
endi
sql select * from st_bool_26
sql select * from st_bool_126
if $data01 != 0 then
print ==54== expect: 0, actually: $data01
return -1
endi
sql insert into st_bool_27 using mt_bool tags (false) values (now, false)
sql show tags from st_bool_27
sql insert into st_bool_127 using mt_bool tags (false) values (now, false)
sql show tags from st_bool_127
if $data05 != false then
print ==55== expect: 0, actually: $data00
return -1
endi
sql select * from st_bool_27
sql select * from st_bool_127
if $data01 != 0 then
print ==56== expect: 0, actually: $data01
return -1
endi
sql insert into st_bool_28 using mt_bool tags (0) values (now, 0)
sql show tags from st_bool_28
sql insert into st_bool_128 using mt_bool tags (0) values (now, 0)
sql show tags from st_bool_128
if $data05 != false then
print ==57== expect: 0, actually: $data00
return -1
endi
sql select * from st_bool_28
sql select * from st_bool_128
if $data01 != 0 then
print ==58== expect: 0, actually: $data01
return -1
endi
sql insert into st_bool_29 using mt_bool tags (1) values (now, 1)
sql show tags from st_bool_29
sql insert into st_bool_129 using mt_bool tags (1) values (now, 1)
sql show tags from st_bool_129
if $data05 != true then
print ==59== expect: 1, actually: $data00
return -1
endi
sql select * from st_bool_29
sql select * from st_bool_129
if $data01 != 1 then
print ==60== expect: 1, actually: $data01
return -1
endi
sql insert into st_bool_30 using mt_bool tags (6.9) values (now, 6.9)
sql show tags from st_bool_30
sql insert into st_bool_130 using mt_bool tags (6.9) values (now, 6.9)
sql show tags from st_bool_130
if $data05 != true then
print ==61== expect: 1, actually: $data00
return -1
endi
sql select * from st_bool_30
sql select * from st_bool_130
if $data01 != 1 then
print ==62== expect: 1, actually: $data01
return -1
endi
sql insert into st_bool_31 using mt_bool tags (-3) values (now, -3)
sql show tags from st_bool_31
sql insert into st_bool_131 using mt_bool tags (-3) values (now, -3)
sql show tags from st_bool_131
if $data05 != true then
print ==63== expect: 1, actually: $data00
return -1
endi
sql select * from st_bool_31
sql select * from st_bool_131
if $data01 != 1 then
print ==64== expect: 1, actually: $data01
return -1
endi
sql insert into st_bool_32 using mt_bool tags (+300) values (now, +300)
sql show tags from st_bool_32
sql insert into st_bool_132 using mt_bool tags (+300) values (now, +300)
sql show tags from st_bool_132
if $data05 != true then
print ==63== expect: 1, actually: $data00
return -1
endi
sql select * from st_bool_32
sql select * from st_bool_132
if $data01 != 1 then
print ==64== expect: 1, actually: $data01
return -1
endi
sql insert into st_bool_33 using mt_bool tags (+30.890) values (now, +30.890)
sql show tags from st_bool_33
sql insert into st_bool_133 using mt_bool tags (+30.890) values (now, +30.890)
sql show tags from st_bool_133
if $data05 != true then
print ==63== expect: 1, actually: $data00
return -1
endi
sql select * from st_bool_33
sql select * from st_bool_133
if $data01 != 1 then
print ==64== expect: 1, actually: $data01
return -1
endi
sql insert into st_bool_218 using mt_bool tags ("-8.03") values (now,"-8.03")
sql show tags from st_bool_218
if $data05 != true then
return -1
endi
sql select * from st_bool_218
if $data01 != 1 then
return -1
endi
sql insert into st_bool_219 using mt_bool tags ("+300") values (now,"+300")
sql show tags from st_bool_219
if $data05 != true then
return -1
endi
sql select * from st_bool_219
if $data01 != 1 then
return -1
endi
sql insert into st_bool_220 using mt_bool tags ("-8e+2") values (now,"-8e+2")
sql show tags from st_bool_220
if $data05 != true then
return -1
endi
sql select * from st_bool_220
if $data01 != 1 then
return -1
endi
sql insert into st_bool_221 using mt_bool tags ("0x01") values (now,"0x01")
sql show tags from st_bool_221
if $data05 != true then
return -1
endi
sql select * from st_bool_221
if $data01 != 1 then
return -1
endi
sql insert into st_bool_222 using mt_bool tags ("0b01") values (now,"0b01")
sql show tags from st_bool_222
if $data05 != true then
return -1
endi
sql select * from st_bool_222
if $data01 != 1 then
return -1
endi
sql insert into st_bool_223 using mt_bool tags ("+0x01") values (now,"+0x01")
sql show tags from st_bool_223
if $data05 != true then
return -1
endi
sql select * from st_bool_223
if $data01 != 1 then
return -1
endi
sql insert into st_bool_224 using mt_bool tags ("-0b00") values (now,"-0b00")
sql show tags from st_bool_224
if $data05 != false then
return -1
endi
sql select * from st_bool_224
if $data01 != 0 then
return -1
endi
sql insert into st_bool_226 using mt_bool tags ("-0.11e-30") values (now,"-0.11e-30")
sql show tags from st_bool_226
if $data05 != true then
return -1
endi
sql select * from st_bool_226
if $data01 != 1 then
return -1
endi
sql insert into st_bool_227 using mt_bool tags ("-1.0e-307") values (now,"-1.0e-307")
sql show tags from st_bool_227
if $data05 != true then
return -1
endi
sql select * from st_bool_227
if $data01 != 1 then
return -1
endi
sql insert into st_bool_228 using mt_bool tags ( -1e-1 ) values (now, -1e-1 )
sql show tags from st_bool_228
if $data05 != true then
return -1
endi
sql select * from st_bool_228
if $data01 != 1 then
return -1
endi
sql insert into st_bool_229 using mt_bool tags (-0.11e-30) values (now,-0.11e-30)
sql show tags from st_bool_229
if $data05 != true then
return -1
endi
sql select * from st_bool_229
if $data01 != 1 then
return -1
endi
sql insert into st_bool_230 using mt_bool tags (-1.1e-307) values (now,-1.1e-307)
sql show tags from st_bool_230
if $data05 != true then
return -1
endi
sql select * from st_bool_230
if $data01 != 1 then
return -1
endi
sql insert into st_bool_231 using mt_bool tags ( 0x01) values (now, 0x01)
sql show tags from st_bool_231
if $data05 != true then
return -1
endi
sql select * from st_bool_231
if $data01 != 1 then
return -1
endi
sql insert into st_bool_232 using mt_bool tags (0b01 ) values (now, 0b01)
sql show tags from st_bool_232
if $data05 != true then
return -1
endi
sql select * from st_bool_232
if $data01 != 1 then
return -1
endi
sql insert into st_bool_233 using mt_bool tags (+0x01) values (now,+0x01)
sql show tags from st_bool_233
if $data05 != true then
return -1
endi
sql insert into st_bool_234 using mt_bool tags ( -0b00 ) values (now, -0b00)
sql show tags from st_bool_234
if $data05 != false then
return -1
endi
sql select * from st_bool_234
if $data01 != 0 then
return -1
endi
## case 03: alter tag values
#sql alter table st_bool_0 set tag tagname=true
#sql show tags from st_bool_0
#if $data00 != true then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname=NULL
#sql show tags from st_bool_0
#if $data00 != NULL then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname=false
#sql show tags from st_bool_0
#if $data00 != false then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname=NULL
#sql show tags from st_bool_0
#if $data00 != NULL then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname='true'
#sql show tags from st_bool_0
#if $data00 != true then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname='NULL'
#sql show tags from st_bool_0
#if $data00 != NULL then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname='false'
#sql show tags from st_bool_0
#if $data00 != false then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname='NULL'
#sql show tags from st_bool_0
#if $data00 != NULL then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname="true"
#sql show tags from st_bool_0
#if $data00 != true then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname="NULL"
#sql show tags from st_bool_0
#if $data00 != NULL then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname="false"
#sql show tags from st_bool_0
#if $data00 != false then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname="NULL"
#sql show tags from st_bool_0
#if $data00 != NULL then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname=1
#sql show tags from st_bool_0
#if $data00 != true then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname=0
#sql show tags from st_bool_0
#if $data00 != false then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname=6.9
#sql show tags from st_bool_0
#if $data00 != true then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname=-3
#sql show tags from st_bool_0
#if $data00 != true then
# return -1
#endi
sql alter table st_bool_16 set tag tagname=+300
sql show tags from st_bool_16
if $data05 != true then
return -1
endi
sql alter table st_bool_17 set tag tagname=-8.03
sql show tags from st_bool_17
if $data05 != true then
return -1
endi
sql alter table st_bool_18 set tag tagname="-8.03"
sql show tags from st_bool_18
if $data05 != true then
return -1
endi
sql alter table st_bool_19 set tag tagname="+300"
sql show tags from st_bool_19
if $data05 != true then
return -1
endi
sql alter table st_bool_20 set tag tagname="-8e+2"
sql show tags from st_bool_20
if $data05 != true then
return -1
endi
sql alter table st_bool_21 set tag tagname="0x01"
sql show tags from st_bool_21
if $data05 != true then
return -1
endi
sql alter table st_bool_22 set tag tagname="0b01"
sql show tags from st_bool_22
if $data05 != true then
return -1
endi
sql alter table st_bool_23 set tag tagname="+0x01"
sql show tags from st_bool_23
if $data05 != true then
return -1
endi
sql alter table st_bool_24 set tag tagname="-0b00"
sql show tags from st_bool_24
if $data05 != false then
return -1
endi
sql alter table st_bool_26 set tag tagname="-0.11e-30"
sql show tags from st_bool_26
if $data05 != true then
return -1
endi
sql alter table st_bool_27 set tag tagname="-1.0e-307"
sql show tags from st_bool_27
if $data05 != true then
return -1
endi
sql alter table st_bool_28 set tag tagname= -1e-1
sql show tags from st_bool_28
if $data05 != true then
return -1
endi
sql alter table st_bool_29 set tag tagname=-0.11e-30
sql show tags from st_bool_29
if $data05 != true then
return -1
endi
sql alter table st_bool_30 set tag tagname=-1.1e-307
sql show tags from st_bool_30
if $data05 != true then
return -1
endi
sql alter table st_bool_31 set tag tagname= 0x01
sql show tags from st_bool_31
if $data05 != true then
return -1
endi
sql alter table st_bool_32 set tag tagname=0b01
sql show tags from st_bool_32
if $data05 != true then
return -1
endi
sql alter table st_bool_33 set tag tagname=+0x01
sql show tags from st_bool_33
if $data05 != true then
return -1
endi
sql alter table st_bool_34 set tag tagname= -0b00
sql show tags from st_bool_34
if $data05 != false then
return -1
endi
# case 04: illegal input
sql_error create table st_bool_e0 using mt_bool tags (123abc)
sql create table st_bool_e1 using mt_bool tags ("123abc")
sql_error create table st_bool_e1 using mt_bool tags ("123abc")
sql create table st_bool_e2 using mt_bool tags ("123")
sql_error create table st_bool_e3 using mt_bool tags (abc)
sql create table st_bool_e4 using mt_bool tags ("abc")
sql create table st_bool_e5 using mt_bool tags (" ")
sql create table st_bool_e6 using mt_bool tags ('')
sql_error create table st_bool_e4 using mt_bool tags ("abc")
sql_error create table st_bool_e5 using mt_bool tags (" ")
sql_error create table st_bool_e6 using mt_bool tags ('')
sql create table st_bool_f0 using mt_bool tags (true)
sql create table st_bool_f1 using mt_bool tags (true)
@ -598,7 +901,7 @@ sql create table st_bool_f6 using mt_bool tags (true)
sql_error insert into st_bool_g0 values (now, 123abc)
sql_error insert into st_bool_g1 values (now, "123abc")
sql_error insert into st_bool_g2 values (now, "123")
sql insert into st_bool_f2 values (now, "123")
sql_error insert into st_bool_g3 values (now, abc)
sql_error insert into st_bool_g4 values (now, "abc")
sql_error insert into st_bool_g5 values (now, " ")
@ -606,7 +909,7 @@ sql_error insert into st_bool_g6 values (now, '')
sql_error insert into st_bool_h0 using mt_bool tags (123abc) values (now, 1)
sql_error insert into st_bool_h1 using mt_bool tags ("123abc") values (now, 1)
sql_error insert into st_bool_h2 using mt_bool tags ("123") values (now, 1)
sql insert into st_bool_h2 using mt_bool tags ("123") values (now, 1)
sql_error insert into st_bool_h3 using mt_bool tags (abc) values (now, 1)
sql_error insert into st_bool_h4 using mt_bool tags ("abc") values (now, 1)
sql_error insert into st_bool_h5 using mt_bool tags (" ") values (now, 1)
@ -614,7 +917,7 @@ sql_error insert into st_bool_h6 using mt_bool tags ('') values (now, 1)
sql_error insert into st_bool_h0 using mt_bool tags (1) values (now, 123abc)
sql_error insert into st_bool_h1 using mt_bool tags (1) values (now, "123abc")
sql_error insert into st_bool_h2 using mt_bool tags (1) values (now, "123")
sql insert into st_bool_h2 using mt_bool tags (1) values (now, "123")
sql_error insert into st_bool_h3 using mt_bool tags (1) values (now, abc)
sql_error insert into st_bool_h4 using mt_bool tags (1) values (now, "abc")
sql_error insert into st_bool_h5 using mt_bool tags (1) values (now, " ")
@ -629,11 +932,11 @@ sql insert into st_bool_i5 using mt_bool tags (1) values (now, 1)
sql insert into st_bool_i6 using mt_bool tags (1) values (now, 1)
sql_error alter table st_bool_i0 set tag tagname=123abc
sql alter table st_bool_i1 set tag tagname="123abc"
sql alter table st_bool_i2 set tag tagname="123"
sql_error alter table st_bool_i1 set tag tagname="123abc"
sql alter table st_bool_i2 set tag tagname="123"
sql_error alter table st_bool_i3 set tag tagname=abc
sql alter table st_bool_i4 set tag tagname="abc"
sql alter table st_bool_i5 set tag tagname=" "
sql alter table st_bool_i6 set tag tagname=''
sql_error alter table st_bool_i4 set tag tagname="abc"
sql_error alter table st_bool_i5 set tag tagname=" "
sql_error alter table st_bool_i6 set tag tagname=''
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -28,22 +28,22 @@ if $data05 != NULL then
endi
sql create table st_double_2 using mt_double tags ('NULL')
sql show tags from st_double_2
if $data05 != 0.000000000 then
if $data05 != NULL then
return -1
endi
sql create table st_double_3 using mt_double tags ('NULL')
sql show tags from st_double_3
if $data05 != 0.000000000 then
if $data05 != NULL then
return -1
endi
sql create table st_double_4 using mt_double tags ("NULL")
sql show tags from st_double_4
if $data05 != 0.000000000 then
if $data05 != NULL then
return -1
endi
sql create table st_double_5 using mt_double tags ("NULL")
sql show tags from st_double_5
if $data05 != 0.000000000 then
if $data05 != NULL then
return -1
endi
sql create table st_double_6 using mt_double tags (-123.321)
@ -148,6 +148,46 @@ sql show tags from st_double_16_0
#if $data05 != 0.001500000 then
# return -1
#endi
sql create table st_double_100 using mt_double tags ("0x01")
sql show tags from st_double_100
if $data05 != 1.000000000 then
return -1
endi
sql create table st_double_101 using mt_double tags ("0b01")
sql show tags from st_double_101
if $data05 != 1.000000000 then
return -1
endi
sql create table st_double_102 using mt_double tags ("+0x01")
sql show tags from st_double_102
if $data05 != 1.000000000 then
return -1
endi
sql create table st_double_103 using mt_double tags ("-0b01")
sql show tags from st_double_103
if $data05 != -1.000000000 then
return -1
endi
sql create table st_double_200 using mt_double tags ( 0x01)
sql show tags from st_double_200
if $data05 != 1.000000000 then
return -1
endi
sql create table st_double_201 using mt_double tags (0b01 )
sql show tags from st_double_201
if $data05 != 1.000000000 then
return -1
endi
sql create table st_double_202 using mt_double tags (+0x01)
sql show tags from st_double_202
if $data05 != 1.000000000 then
return -1
endi
sql create table st_double_203 using mt_double tags ( -0b01 )
sql show tags from st_double_203
if $data05 != -1.000000000 then
return -1
endi
## case 01: insert values for test column values
sql insert into st_double_0 values (now, NULL )
@ -274,6 +314,70 @@ endi
#if $data01 != -56 then
# return -1
#endi
sql insert into st_double_100 values(now, "0x01")
sql select * from st_double_100
if $rows != 1 then
return -1
endi
if $data01 != 1.000000000 then
return -1
endi
sql insert into st_double_101 values(now, "0b01")
sql select * from st_double_101
if $rows != 1 then
return -1
endi
if $data01 != 1.000000000 then
return -1
endi
sql insert into st_double_102 values(now, "+0x01")
sql select * from st_double_102
if $rows != 1 then
return -1
endi
if $data01 != 1.000000000 then
return -1
endi
sql insert into st_double_103 values(now, "-0b01")
sql select * from st_double_103
if $rows != 1 then
return -1
endi
if $data01 != -1.000000000 then
return -1
endi
sql insert into st_double_200 values(now, 0x01)
sql select * from st_double_200
if $rows != 1 then
return -1
endi
if $data01 != 1.000000000 then
return -1
endi
sql insert into st_double_201 values(now, 0b01 )
sql select * from st_double_201
if $rows != 1 then
return -1
endi
if $data01 != 1.000000000 then
return -1
endi
sql insert into st_double_202 values(now, +0x01)
sql select * from st_double_202
if $rows != 1 then
return -1
endi
if $data01 != 1.000000000 then
return -1
endi
sql insert into st_double_203 values(now, -0b01 )
sql select * from st_double_203
if $rows != 1 then
return -1
endi
if $data01 != -1.000000000 then
return -1
endi
## case 02: dynamic create table for test tag values
sql insert into st_double_16 using mt_double tags (NULL ) values (now, NULL )
@ -394,6 +498,78 @@ sql select * from st_double_28
#if $data01 != -56 then
# return -1
#endi
sql insert into st_double_100 using mt_double tags ("0x01") values (now, "0x01")
sql show tags from st_double_100
if $data05 != 1.000000000 then
return -1
endi
sql select * from st_double_100
if $data01 != 1.000000000 then
return -1
endi
sql insert into st_double_101 using mt_double tags ("0b01") values (now, "0b01")
sql show tags from st_double_101
if $data05 != 1.000000000 then
return -1
endi
sql select * from st_double_101
if $data01 != 1.000000000 then
return -1
endi
sql insert into st_double_102 using mt_double tags ("+0x01") values (now, "+0x01")
sql show tags from st_double_102
if $data05 != 1.000000000 then
return -1
endi
sql select * from st_double_102
if $data01 != 1.000000000 then
return -1
endi
sql insert into st_double_103 using mt_double tags ("-0b01") values (now, "-0b01")
sql show tags from st_double_103
if $data05 != -1.000000000 then
return -1
endi
sql select * from st_double_103
if $data01 != -1.000000000 then
return -1
endi
sql insert into st_double_200 using mt_double tags ( 0x01) values (now, 0x01)
sql show tags from st_double_200
if $data05 != 1.000000000 then
return -1
endi
sql select * from st_double_200
if $data01 != 1.000000000 then
return -1
endi
sql insert into st_double_201 using mt_double tags (0b01 ) values (now, 0b01)
sql show tags from st_double_201
if $data05 != 1.000000000 then
return -1
endi
sql select * from st_double_201
if $data01 != 1.000000000 then
return -1
endi
sql insert into st_double_202 using mt_double tags (+0x01) values (now, +0x01)
sql show tags from st_double_202
if $data05 != 1.000000000 then
return -1
endi
sql select * from st_double_202
if $data01 != 1.000000000 then
return -1
endi
sql insert into st_double_203 using mt_double tags ( -0b01 ) values (now, -0b01)
sql show tags from st_double_203
if $data05 != -1.000000000 then
return -1
endi
sql select * from st_double_203
if $data01 != -1.000000000 then
return -1
endi
### case 03: alter tag values
#sql alter table st_double_0 set tag tagname=1.7976931348623157e+308
@ -436,6 +612,46 @@ sql select * from st_double_28
##if $data05 != -63 then
## return -1
##endi
sql alter table st_double_100 set tag tagname="0x01"
sql show tags from st_double_100
if $data05 != 1.000000000 then
return -1
endi
sql alter table st_double_101 set tag tagname="0b01"
sql show tags from st_double_101
if $data05 != 1.000000000 then
return -1
endi
sql alter table st_double_102 set tag tagname="+0x01"
sql show tags from st_double_102
if $data05 != 1.000000000 then
return -1
endi
sql alter table st_double_103 set tag tagname="-0b01"
sql show tags from st_double_103
if $data05 != -1.000000000 then
return -1
endi
sql alter table st_double_200 set tag tagname= 0x01
sql show tags from st_double_200
if $data05 != 1.000000000 then
return -1
endi
sql alter table st_double_201 set tag tagname=0b01
sql show tags from st_double_201
if $data05 != 1.000000000 then
return -1
endi
sql alter table st_double_202 set tag tagname=+0x01
sql show tags from st_double_202
if $data05 != 1.000000000 then
return -1
endi
sql alter table st_double_203 set tag tagname= -0b01
sql show tags from st_double_203
if $data05 != -1.000000000 then
return -1
endi
## case 04: illegal input
sql_error create table st_double_e0 using mt_double tags (1.8976931348623157e+308)
@ -445,11 +661,11 @@ sql_error create table st_double_e0 using mt_double tags (-31.7976931348623157e+
#sql_error create table st_double_e0 using mt_double tags (12.80) truncate integer part
#sql_error create table st_double_e0 using mt_double tags (-11.80)
sql_error create table st_double_e0 using mt_double tags (123abc)
sql create table st_double_e0_1 using mt_double tags ("123abc")
sql_error create table st_double_e0_1 using mt_double tags ("123abc")
sql_error create table st_double_e0 using mt_double tags (abc)
sql create table st_double_e0_2 using mt_double tags ("abc")
sql create table st_double_e0_3 using mt_double tags (" ")
sql create table st_double_e0_4 using mt_double tags ('')
sql_error create table st_double_e0_2 using mt_double tags ("abc")
sql_error create table st_double_e0_3 using mt_double tags (" ")
sql_error create table st_double_e0_4 using mt_double tags ('')
sql create table st_double_e0 using mt_double tags (123)
sql create table st_double_e1 using mt_double tags (123)
@ -502,7 +718,8 @@ sql_error insert into st_double_e20 using mt_double tags ("123abc") values (now,
sql_error insert into st_double_e22 using mt_double tags (abc) values (now, -033)
sql_error insert into st_double_e23 using mt_double tags ("abc") values (now, -033)
sql_error insert into st_double_e24 using mt_double tags (" ") values (now, -033)
sql insert into st_double_e25 using mt_double tags ('') values (now, -033)
sql_error insert into st_double_e25 using mt_double tags ('') values (now, -033)
sql insert into st_double_e20 using mt_double tags ("123") values (now, -033)
sql insert into st_double_e13 using mt_double tags (033) values (now, 00062)
sql insert into st_double_e14 using mt_double tags (033) values (now, 00062)
@ -523,10 +740,11 @@ sql_error alter table st_double_e14 set tag tagname=-1.8976931348623157e+308
sql_error alter table st_double_e15 set tag tagname=131.7976931348623157e+308
sql_error alter table st_double_e16 set tag tagname=-131.7976931348623157e+308
sql_error alter table st_double_e19 set tag tagname=123abc
sql alter table st_double_e20 set tag tagname="123abc"
sql_error alter table st_double_e20 set tag tagname="123abc"
sql_error alter table st_double_e22 set tag tagname=abc
sql alter table st_double_e23 set tag tagname="abc"
sql alter table st_double_e24 set tag tagname=" "
sql alter table st_double_e25 set tag tagname=''
sql_error alter table st_double_e23 set tag tagname="abc"
sql_error alter table st_double_e24 set tag tagname=" "
sql_error alter table st_double_e25 set tag tagname=''
sql alter table st_double_e25 set tag tagname='123'
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -29,22 +29,22 @@ if $data05 != NULL then
endi
sql create table st_float_2 using mt_float tags ('NULL')
sql show tags from st_float_2
if $data05 != 0.00000 then
if $data05 != NULL then
return -1
endi
sql create table st_float_3 using mt_float tags ('NULL')
sql show tags from st_float_3
if $data05 != 0.00000 then
if $data05 != NULL then
return -1
endi
sql create table st_float_4 using mt_float tags ("NULL")
sql show tags from st_float_4
if $data05 != 0.00000 then
if $data05 != NULL then
return -1
endi
sql create table st_float_5 using mt_float tags ("NULL")
sql show tags from st_float_5
if $data05 != 0.00000 then
if $data05 != NULL then
return -1
endi
sql create table st_float_6 using mt_float tags (-123.321)
@ -156,16 +156,62 @@ if $data05 != 0.00150 then
print expect 0.00150, actual: $data05
return -1
endi
#sql create table st_float_15_0 using mt_float tags (3.40282347e+38)
#sql show tags from st_float_15_0
#if $data05 != 0.001500 then
# return -1
#endi
#sql create table st_float_16_0 using mt_float tags (-3.40282347e+38)
#sql show tags from st_float_16_0
#if $data05 != 0.001500 then
# return -1
#endi
sql create table st_float_15_0 using mt_float tags (3.40282346638528859811704183484516925e+38)
sql show tags from st_float_15_0
if $data05 < 340282346638528859811704183484516925000 then
return -1
endi
if $data05 > 340282346638528859811704183484516925900 then
return -1
endi
sql create table st_float_16_0 using mt_float tags (-3.40282346638528859811704183484516925e+38)
sql show tags from st_float_16_0
if $data05 < -340282346638528859811704183484516925900 then
return -1
endi
if $data05 > -340282346638528859811704183484516925000 then
return -1
endi
sql create table st_float_100 using mt_float tags ("0x01")
sql show tags from st_float_100
if $data05 != 1.00000 then
return -1
endi
sql create table st_float_101 using mt_float tags ("0b01")
sql show tags from st_float_101
if $data05 != 1.00000 then
return -1
endi
sql create table st_float_102 using mt_float tags ("+0x01")
sql show tags from st_float_102
if $data05 != 1.00000 then
return -1
endi
sql create table st_float_103 using mt_float tags ("-0b01")
sql show tags from st_float_103
if $data05 != -1.00000 then
return -1
endi
sql create table st_float_200 using mt_float tags ( 0x01)
sql show tags from st_float_200
if $data05 != 1.00000 then
return -1
endi
sql create table st_float_201 using mt_float tags (0b01 )
sql show tags from st_float_201
if $data05 != 1.00000 then
return -1
endi
sql create table st_float_202 using mt_float tags (+0x01)
sql show tags from st_float_202
if $data05 != 1.00000 then
return -1
endi
sql create table st_float_203 using mt_float tags ( -0b01 )
sql show tags from st_float_203
if $data05 != -1.00000 then
return -1
endi
## case 01: insert values for test column values
sql insert into st_float_0 values (now, NULL)
@ -216,6 +262,70 @@ endi
if $data01 != NULL then
return -1
endi
sql insert into st_float_100 values(now, "0x01")
sql select * from st_float_100
if $rows != 1 then
return -1
endi
if $data01 != 1.00000 then
return -1
endi
sql insert into st_float_101 values(now, "0b01")
sql select * from st_float_101
if $rows != 1 then
return -1
endi
if $data01 != 1.00000 then
return -1
endi
sql insert into st_float_102 values(now, "+0x01")
sql select * from st_float_102
if $rows != 1 then
return -1
endi
if $data01 != 1.00000 then
return -1
endi
sql insert into st_float_103 values(now, "-0b01")
sql select * from st_float_103
if $rows != 1 then
return -1
endi
if $data01 != -1.00000 then
return -1
endi
sql insert into st_float_200 values(now, 0x01)
sql select * from st_float_200
if $rows != 1 then
return -1
endi
if $data01 != 1.00000 then
return -1
endi
sql insert into st_float_201 values(now, 0b01 )
sql select * from st_float_201
if $rows != 1 then
return -1
endi
if $data01 != 1.00000 then
return -1
endi
sql insert into st_float_202 values(now, +0x01)
sql select * from st_float_202
if $rows != 1 then
return -1
endi
if $data01 != 1.00000 then
return -1
endi
sql insert into st_float_203 values(now, -0b01 )
sql select * from st_float_203
if $rows != 1 then
return -1
endi
if $data01 != -1.00000 then
return -1
endi
sql_error insert into st_float_6 values (now, 3.40282347e+38)
sql_error insert into st_float_6 values (now, -3.40282347e+38)
@ -425,6 +535,78 @@ sql select * from st_float_28
if $data01 != -5.60000 then
return -1
endi
sql insert into st_float_100 using mt_float tags ("0x01") values (now, "0x01")
sql show tags from st_float_100
if $data05 != 1.00000 then
return -1
endi
sql select * from st_float_100
if $data01 != 1.00000 then
return -1
endi
sql insert into st_float_101 using mt_float tags ("0b01") values (now, "0b01")
sql show tags from st_float_101
if $data05 != 1.00000 then
return -1
endi
sql select * from st_float_101
if $data01 != 1.00000 then
return -1
endi
sql insert into st_float_102 using mt_float tags ("+0x01") values (now, "+0x01")
sql show tags from st_float_102
if $data05 != 1.00000 then
return -1
endi
sql select * from st_float_102
if $data01 != 1.00000 then
return -1
endi
sql insert into st_float_103 using mt_float tags ("-0b01") values (now, "-0b01")
sql show tags from st_float_103
if $data05 != -1.00000 then
return -1
endi
sql select * from st_float_103
if $data01 != -1.00000 then
return -1
endi
sql insert into st_float_200 using mt_float tags ( 0x01) values (now, 0x01)
sql show tags from st_float_200
if $data05 != 1.00000 then
return -1
endi
sql select * from st_float_200
if $data01 != 1.00000 then
return -1
endi
sql insert into st_float_201 using mt_float tags (0b01 ) values (now, 0b01)
sql show tags from st_float_201
if $data05 != 1.00000 then
return -1
endi
sql select * from st_float_201
if $data01 != 1.00000 then
return -1
endi
sql insert into st_float_202 using mt_float tags (+0x01) values (now, +0x01)
sql show tags from st_float_202
if $data05 != 1.00000 then
return -1
endi
sql select * from st_float_202
if $data01 != 1.00000 then
return -1
endi
sql insert into st_float_203 using mt_float tags ( -0b01 ) values (now, -0b01)
sql show tags from st_float_203
if $data05 != -1.00000 then
return -1
endi
sql select * from st_float_203
if $data01 != -1.00000 then
return -1
endi
### case 03: alter tag values
sql alter table st_float_0 set tag tagname=340282346638528859811704183484516925440.00000
@ -468,6 +650,46 @@ sql show tags from st_float_0
if $data05 != -63.58200 then
return -1
endi
sql alter table st_float_100 set tag tagname="0x01"
sql show tags from st_float_100
if $data05 != 1.00000 then
return -1
endi
sql alter table st_float_101 set tag tagname="0b01"
sql show tags from st_float_101
if $data05 != 1.00000 then
return -1
endi
sql alter table st_float_102 set tag tagname="+0x01"
sql show tags from st_float_102
if $data05 != 1.00000 then
return -1
endi
sql alter table st_float_103 set tag tagname="-0b01"
sql show tags from st_float_103
if $data05 != -1.00000 then
return -1
endi
sql alter table st_float_200 set tag tagname= 0x01
sql show tags from st_float_200
if $data05 != 1.00000 then
return -1
endi
sql alter table st_float_201 set tag tagname=0b01
sql show tags from st_float_201
if $data05 != 1.00000 then
return -1
endi
sql alter table st_float_202 set tag tagname=+0x01
sql show tags from st_float_202
if $data05 != 1.00000 then
return -1
endi
sql alter table st_float_203 set tag tagname= -0b01
sql show tags from st_float_203
if $data05 != -1.00000 then
return -1
endi
## case 04: illegal input
sql_error create table st_float_e0 using mt_float tags (3.50282347e+38)
@ -477,11 +699,11 @@ sql_error create table st_float_e0 using mt_float tags (-333.40282347e+38)
#sql_error create table st_float_e0 using mt_float tags (12.80) truncate integer part
#sql_error create table st_float_e0 using mt_float tags (-11.80)
sql_error create table st_float_e0 using mt_float tags (123abc)
sql create table st_float_e0_1 using mt_float tags ("123abc")
sql_error create table st_float_e0_1 using mt_float tags ("123abc")
sql_error create table st_float_e0 using mt_float tags (abc)
sql create table st_float_e0_2 using mt_float tags ("abc")
sql create table st_float_e0_3 using mt_float tags (" ")
sql create table st_float_e0_4 using mt_float tags ('')
sql_error create table st_float_e0_2 using mt_float tags ("abc")
sql_error create table st_float_e0_3 using mt_float tags (" ")
sql_error create table st_float_e0_4 using mt_float tags ('')
sql create table st_float_e0 using mt_float tags (123)
sql create table st_float_e1 using mt_float tags (123)
@ -534,7 +756,7 @@ sql_error insert into st_float_e20 using mt_float tags ("123abc") values (now, -
sql_error insert into st_float_e22 using mt_float tags (abc) values (now, -033)
sql_error insert into st_float_e23 using mt_float tags ("abc") values (now, -033)
sql_error insert into st_float_e24 using mt_float tags (" ") values (now, -033)
sql insert into st_float_e25_3 using mt_float tags ('') values (now, -033)
sql_error insert into st_float_e25_3 using mt_float tags ('') values (now, -033)
sql insert into st_float_e13 using mt_float tags (033) values (now, 00062)
sql insert into st_float_e14 using mt_float tags (033) values (now, 00062)
@ -555,10 +777,10 @@ sql_error alter table st_float_e14 set tag tagname=-3.50282347e+38
sql_error alter table st_float_e15 set tag tagname=13.40282347e+38
sql_error alter table st_float_e16 set tag tagname=-13.40282347e+38
sql_error alter table st_float_e19 set tag tagname=123abc
sql alter table st_float_e20 set tag tagname="123abc"
sql_error alter table st_float_e20 set tag tagname="123abc"
sql_error alter table st_float_e22 set tag tagname=abc
sql alter table st_float_e23 set tag tagname="abc"
sql alter table st_float_e24 set tag tagname=" "
sql alter table st_float_e25 set tag tagname=''
sql_error alter table st_float_e23 set tag tagname="abc"
sql_error alter table st_float_e24 set tag tagname=" "
sql_error alter table st_float_e25 set tag tagname=''
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -0,0 +1,277 @@
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value
######## case 0: geometry
print ========== geometry
sql create table mt_geometry (ts timestamp, c geometry(128)) tags(tagname geometry(128))
## case 00: static create table for test tag values
sql create table st_geometry_0 using mt_geometry tags(NULL)
sql show tags from st_geometry_0
if $data05 != NULL then
return -1
endi
sql create table st_geometry_1 using mt_geometry tags(NULL)
sql show tags from st_geometry_1
if $data05 != NULL then
return -1
endi
sql create table st_geometry_2 using mt_geometry tags('NULL')
sql show tags from st_geometry_2
if $data05 != NULL then
return -1
endi
sql create table st_geometry_3 using mt_geometry tags('NULL')
sql show tags from st_geometry_3
if $data05 != NULL then
return -1
endi
sql create table st_geometry_4 using mt_geometry tags("NULL")
sql show tags from st_geometry_4
if $data05 != NULL then
return -1
endi
sql create table st_geometry_5 using mt_geometry tags("NULL")
sql show tags from st_geometry_5
if $data05 != NULL then
return -1
endi
sql create table st_geometry_6 using mt_geometry tags("POINT(1.0 1.0)")
sql show tags from st_geometry_6
if $data05 != @POINT (1.000000 1.000000)@ then
print $data05
return -1
endi
sql create table st_geometry_7 using mt_geometry tags(" LINESTRING(1.0 1.0, 2.0 2.0)")
sql show tags from st_geometry_7
if $data05 != @LINESTRING (1.000000 1.000000, 2.000000 2.000000)@ then
print $data05
return -1
endi
sql create table st_geometry_8 using mt_geometry tags("POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))")
sql show tags from st_geometry_8
if $data05 != @POLYGON ((1.000000 1.000000, -2.000000 2.000000, 1.000000 1.000000))@ then
print $data05
return -1
endi
## case 01: insert values for test column values
sql insert into st_geometry_0 values(now, NULL)
sql select *from st_geometry_0
if $data01 != NULL then
return -1
endi
sql insert into st_geometry_1 values(now, NULL)
sql select *from st_geometry_1
if $data01 != NULL then
return -1
endi
sql insert into st_geometry_2 values(now, 'NULL')
sql select *from st_geometry_2
if $data01 != NULL then
return -1
endi
sql insert into st_geometry_3 values(now, 'NULL')
sql select *from st_geometry_3
if $data01 != NULL then
return -1
endi
sql insert into st_geometry_4 values(now, "NULL")
sql select *from st_geometry_4
if $data01 != NULL then
return -1
endi
sql insert into st_geometry_5 values(now, "NULL")
sql select *from st_geometry_5
if $data01 != NULL then
return -1
endi
sql insert into st_geometry_6 values(now, "POINT(1.0 1.0)")
sql select *from st_geometry_6
if $data01 != @POINT (1.000000 1.000000)@ then
# return -1
endi
sql insert into st_geometry_7 values(now, " LINESTRING(1.0 1.0, 2.0 2.0)")
sql select *from st_geometry_7
if $data01 != @LINESTRING (1.000000 1.000000, 2.000000 2.000000)@ then
# return -1
endi
sql insert into st_geometry_8 values(now, "POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))")
sql select *from st_geometry_8
if $data01 != @POLYGON ((1.000000 1.000000, -2.000000 2.000000, 1.000000 1.000000))@ then
# return -1
endi
## case 02: dynamic create table for test tag values
sql insert into st_geometry_100 using mt_geometry tags(NULL) values(now, NULL)
sql show tags from st_geometry_100
if $data05 != NULL then
return -1
endi
sql select *from st_geometry_100
if $data01 != NULL then
return -1
endi
sql insert into st_geometry_101 using mt_geometry tags(NULL) values(now, NULL)
sql show tags from st_geometry_101
if $data05 != NULL then
return -1
endi
sql select *from st_geometry_100
if $data01 != NULL then
return -1
endi
sql insert into st_geometry_102 using mt_geometry tags('NULL') values(now, 'NULL')
sql show tags from st_geometry_102
if $data05 != NULL then
return -1
endi
sql select *from st_geometry_100
if $data01 != NULL then
return -1
endi
sql insert into st_geometry_103 using mt_geometry tags('NULL') values(now, 'NULL')
sql show tags from st_geometry_103
if $data05 != NULL then
return -1
endi
sql select *from st_geometry_100
if $data01 != NULL then
return -1
endi
sql insert into st_geometry_104 using mt_geometry tags("NULL") values(now, "NULL")
sql show tags from st_geometry_104
if $data05 != NULL then
return -1
endi
sql select *from st_geometry_100
if $data01 != NULL then
return -1
endi
sql insert into st_geometry_105 using mt_geometry tags("NULL") values(now, "NULL")
sql show tags from st_geometry_105
if $data05 != NULL then
return -1
endi
sql select *from st_geometry_100
if $data01 != NULL then
return -1
endi
sql insert into st_geometry_106 using mt_geometry tags("POINT(1.0 1.0)") values(now, "POINT(1.0 1.0)")
sql show tags from st_geometry_106
if $data05 != @POINT (1.000000 1.000000)@ then
return -1
endi
sql select *from st_geometry_106
if $data01 != @POINT (1.000000 1.000000)@ then
# return -1
endi
sql insert into st_geometry_107 using mt_geometry tags(" LINESTRING(1.0 1.0, 2.0 2.0)") values(now, "LINESTRING(1.0 1.0, 2.0 2.0)")
sql show tags from st_geometry_107
if $data05 != @LINESTRING (1.000000 1.000000, 2.000000 2.000000)@ then
return -1
endi
sql select *from st_geometry_107
if $data01 != @LINESTRING (1.000000 1.000000, 2.000000 2.000000)@ then
# return -1
endi
sql insert into st_geometry_108 using mt_geometry tags("POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))") values(now, "POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))")
sql show tags from st_geometry_108
if $data05 != @POLYGON ((1.000000 1.000000, -2.000000 2.000000, 1.000000 1.000000))@ then
return -1
endi
sql select *from st_geometry_108
if $data01 != @POLYGON ((1.000000 1.000000, -2.000000 2.000000, 1.000000 1.000000))@ then
# return -1
endi
## case 03: alter tag values
sql alter table st_geometry_0 set tag tagname=NULL
sql show tags from st_geometry_0
if $data05 != NULL then
return -1
endi
sql alter table st_geometry_1 set tag tagname=NULL
sql show tags from st_geometry_1
if $data05 != NULL then
return -1
endi
sql alter table st_geometry_2 set tag tagname='NULL'
sql show tags from st_geometry_2
if $data05 != NULL then
return -1
endi
sql alter table st_geometry_3 set tag tagname='NULL'
sql show tags from st_geometry_3
if $data05 != NULL then
return -1
endi
sql alter table st_geometry_4 set tag tagname="NULL"
sql show tags from st_geometry_4
if $data05 != NULL then
return -1
endi
sql alter table st_geometry_5 set tag tagname="NULL"
sql show tags from st_geometry_5
if $data05 != NULL then
return -1
endi
sql alter table st_geometry_6 set tag tagname="POINT(1.0 1.0)"
sql show tags from st_geometry_6
if $data05 != @POINT (1.000000 1.000000)@ then
return -1
endi
sql alter table st_geometry_7 set tag tagname=" LINESTRING(1.0 1.0, 2.0 2.0)"
sql show tags from st_geometry_7
if $data05 != @LINESTRING (1.000000 1.000000, 2.000000 2.000000)@ then
return -1
endi
sql alter table st_geometry_8 set tag tagname="POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))"
sql show tags from st_geometry_8
if $data05 != @POLYGON ((1.000000 1.000000, -2.000000 2.000000, 1.000000 1.000000))@ then
return -1
endi
# case 04: illegal input
sql_error create table st_geometry_206 using mt_geometry tags(+0123)
sql_error create table st_geometry_207 using mt_geometry tags(-01.23)
sql_error create table st_geometry_208 using mt_geometry tags(+0x01)
sql_error create table st_geometry_209 using mt_geometry tags(-0b01)
sql_error create table st_geometry_2010 using mt_geometry tags(-0.1e-10)
sql_error create table st_geometry_2011 using mt_geometry tags(+0.1E+2)
sql_error create table st_geometry_2012 using mt_geometry tags(tRue)
sql_error create table st_geometry_2013 using mt_geometry tags(FalsE)
sql_error create table st_geometry_2014 using mt_geometry tags(noW)
sql_error create table st_geometry_2015 using mt_geometry tags(toDay)
sql_error insert into st_geometry_206 using mt_geometry tags(+0123) values(now, NULL);
sql_error insert into st_geometry_207 using mt_geometry tags(-01.23) values(now, NULL);
sql_error insert into st_geometry_208 using mt_geometry tags(+0x01) values(now, NULL);
sql_error insert into st_geometry_209 using mt_geometry tags(-0b01) values(now, NULL);
sql_error insert into st_geometry_2010 using mt_geometry tags(-0.1e-10) values(now, NULL);
sql_error insert into st_geometry_2011 using mt_geometry tags(+0.1E+2) values(now, NULL);
sql_error insert into st_geometry_2012 using mt_geometry tags(tRue) values(now, NULL);
sql_error insert into st_geometry_2013 using mt_geometry tags(FalsE) values(now, NULL);
sql_error insert into st_geometry_2014 using mt_geometry tags(noW) values(now, NULL);
sql_error insert into st_geometry_2015 using mt_geometry tags(toDay) values(now, NULL);
sql_error insert into st_geometry_106 using mt_varbinary tags(NULL) values(now(), +0123)
sql_error insert into st_geometry_107 using mt_varbinary tags(NULL) values(now(), -01.23)
sql_error insert into st_geometry_108 using mt_varbinary tags(NULL) values(now(), +0x01)
sql_error insert into st_geometry_109 using mt_varbinary tags(NULL) values(now(), -0b01)
sql_error insert into st_geometry_1010 using mt_varbinary tags(NULL) values(now(), -0.1e-10)
sql_error insert into st_geometry_1011 using mt_varbinary tags(NULL) values(now(), +0.1E+2)
sql_error insert into st_geometry_1012 using mt_varbinary tags(NULL) values(now(), tRue)
sql_error insert into st_geometry_1013 using mt_varbinary tags(NULL) values(now(), FalsE)
sql_error insert into st_geometry_1014 using mt_varbinary tags(NULL) values(now(), noW)
sql_error insert into st_geometry_1015 using mt_varbinary tags(NULL) values(now(), toDay)
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -28,10 +28,26 @@ if $data05 != NULL then
return -1
endi
sql_error create table st_int_2 using mt_int tags ('NULL')
sql_error create table st_int_3 using mt_int tags ('NULL')
sql_error create table st_int_4 using mt_int tags ("NULL")
sql_error create table st_int_5 using mt_int tags ("NULL")
sql create table st_int_2 using mt_int tags ('NULL')
sql show tags from st_int_2
if $data05 != NULL then
return -1
endi
sql create table st_int_3 using mt_int tags ('NULL')
sql show tags from st_int_3
if $data05 != NULL then
return -1
endi
sql create table st_int_4 using mt_int tags ("NULL")
sql show tags from st_int_4
if $data05 != NULL then
return -1
endi
sql create table st_int_5 using mt_int tags ("NULL")
sql show tags from st_int_5
if $data05 != NULL then
return -1
endi
sql create table st_int_6 using mt_int tags (-2147483647)
sql show tags from st_int_6
@ -78,6 +94,103 @@ sql show tags from st_int_14
if $data05 != -78 then
return -1
endi
sql create table st_int_100 using mt_int tags ("0x01")
sql show tags from st_int_100
if $data05 != 1 then
return -1
endi
sql create table st_int_101 using mt_int tags ("0b01")
sql show tags from st_int_101
if $data05 != 1 then
return -1
endi
sql create table st_int_102 using mt_int tags ("+0x01")
sql show tags from st_int_102
if $data05 != 1 then
return -1
endi
sql create table st_int_103 using mt_int tags ("-0b01")
sql show tags from st_int_103
if $data05 != -1 then
return -1
endi
sql create table st_int_104 using mt_int tags ("-123.1")
sql show tags from st_int_104
if $data05 != -123 then
return -1
endi
sql create table st_int_105 using mt_int tags ("+123.5")
sql show tags from st_int_105
if $data05 != 124 then
return -1
endi
sql create table st_int_106 using mt_int tags ("-1e-1")
sql show tags from st_int_106
if $data05 != 0 then
return -1
endi
sql create table st_int_107 using mt_int tags ("+0.1235e3")
sql show tags from st_int_107
if $data05 != 124 then
print $data05 != 124
return -1
endi
sql create table st_int_108 using mt_int tags ("-0.11e-30")
sql show tags from st_int_108
if $data05 != 0 then
print $data05 != 0
return -1
endi
sql create table st_int_109 using mt_int tags ("-1.1e-307")
sql show tags from st_int_109
if $data05 != 0 then
print $data05 != 0
return -1
endi
sql create table st_int_110 using mt_int tags ( -1e-1 )
sql show tags from st_int_110
if $data05 != 0 then
return -1
endi
sql create table st_int_111 using mt_int tags ( +0.1235e3 )
sql show tags from st_int_111
if $data05 != 124 then
print $data05 != 124
return -1
endi
sql create table st_int_112 using mt_int tags (-0.11e-30)
sql show tags from st_int_112
if $data05 != 0 then
print $data05 != 0
return -1
endi
sql create table st_int_113 using mt_int tags (-1.1e-307)
sql show tags from st_int_113
if $data05 != 0 then
print $data05 != 0
return -1
endi
sql create table st_int_200 using mt_int tags ( 0x01)
sql show tags from st_int_200
if $data05 != 1 then
return -1
endi
sql create table st_int_201 using mt_int tags (0b01 )
sql show tags from st_int_201
if $data05 != 1 then
return -1
endi
sql create table st_int_202 using mt_int tags (+0x01)
sql show tags from st_int_202
if $data05 != 1 then
return -1
endi
sql create table st_int_203 using mt_int tags ( -0b01 )
sql show tags from st_int_203
if $data05 != -1 then
return -1
endi
## case 01: insert values for test column values
sql insert into st_int_0 values (now, NULL)
@ -171,6 +284,122 @@ if $data01 != -56 then
return -1
endi
sql insert into st_int_100 values (now, "0x01")
sql select * from st_int_100
if $rows != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql insert into st_int_101 values (now, "0b01")
sql select * from st_int_101
if $rows != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql insert into st_int_102 values (now, "+0x01")
sql select * from st_int_102
if $rows != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql insert into st_int_103 values (now, "-0b01")
sql select * from st_int_103
if $data01 != -1 then
return -1
endi
sql insert into st_int_104 values (now, "-123.1")
sql select * from st_int_104
if $data01 != -123 then
return -1
endi
sql insert into st_int_105 values (now, "+123.5")
sql select * from st_int_105
if $data01 != 124 then
return -1
endi
sql insert into st_int_106 values (now, "-1e-1")
sql select * from st_int_106
if $data01 != 0 then
return -1
endi
sql insert into st_int_107 values (now, "+0.1235e3")
sql select * from st_int_107
if $data01 != 124 then
print $data05 != 124
return -1
endi
sql insert into st_int_108 values (now, "-0.11e-30")
sql select * from st_int_108
if $data01 != 0 then
print $data05 != 0
return -1
endi
sql insert into st_int_109 values (now, "-1.1e-307")
sql select * from st_int_109
if $data01 != 0 then
print $data05 != 0
return -1
endi
sql insert into st_int_110 values (now, -1e-1 )
sql select * from st_int_110
if $data01 != 0 then
return -1
endi
sql insert into st_int_111 values (now, +0.1235e3 )
sql select * from st_int_111
if $data01 != 124 then
print $data05 != 124
return -1
endi
sql insert into st_int_112 values (now, -0.11e-30)
sql select * from st_int_112
if $data01 != 0 then
print $data05 != 0
return -1
endi
sql insert into st_int_113 values (now, -1.1e-307)
sql select * from st_int_113
if $data01 != 0 then
print $data05 != 0
return -1
endi
sql insert into st_int_200 values (now, 0x01)
sql select * from st_int_200
if $rows != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql insert into st_int_201 values (now, 0b01 )
sql select * from st_int_201
if $rows != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql insert into st_int_202 values (now, +0x01)
sql select * from st_int_202
if $rows != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql insert into st_int_203 values (now, -0b01 )
sql select * from st_int_203
if $data01 != -1 then
return -1
endi
## case 02: dynamic create table for test tag values
sql insert into st_int_16 using mt_int tags (NULL) values (now, NULL)
sql show create table st_int_16
@ -291,52 +520,308 @@ sql select * from st_int_28
if $data01 != -56 then
return -1
endi
sql insert into st_int_1100 using mt_int tags ("0x01") values(now, "0x01");
sql show tags from st_int_1100
if $data05 != 1 then
return -1
endi
sql select * from st_int_1100
if $data01 != 1 then
return -1
endi
sql insert into st_int_1101 using mt_int tags ("0b01") values(now, "0b01");
sql show tags from st_int_1101
if $data05 != 1 then
return -1
endi
sql select * from st_int_1101
if $data01 != 1 then
return -1
endi
sql insert into st_int_1102 using mt_int tags ("+0x01") values(now, "+0x01");
sql show tags from st_int_1102
if $data05 != 1 then
return -1
endi
sql select * from st_int_1102
if $data01 != 1 then
return -1
endi
sql insert into st_int_1103 using mt_int tags ("-0b01") values(now, "-0b01");
sql show tags from st_int_1103
if $data05 != -1 then
return -1
endi
sql select * from st_int_1103
if $data01 != -1 then
return -1
endi
sql insert into st_int_1104 using mt_int tags ("-123.1") values(now, "-123.1");
sql show tags from st_int_1104
if $data05 != -123 then
return -1
endi
sql select * from st_int_1104
if $data01 != -123 then
return -1
endi
sql insert into st_int_1105 using mt_int tags ("+123.5") values(now, "+123.5");
sql show tags from st_int_1105
if $data05 != 124 then
return -1
endi
sql select * from st_int_1105
if $data01 != 124 then
return -1
endi
sql insert into st_int_1106 using mt_int tags ("-1e-1") values(now, "-1e-1");
sql show tags from st_int_1106
if $data05 != 0 then
return -1
endi
sql select * from st_int_1106
if $data01 != 0 then
return -1
endi
sql insert into st_int_1107 using mt_int tags ("+0.1235e3") values(now, "+0.1235e3");
sql show tags from st_int_1107
if $data05 != 124 then
return -1
endi
sql insert into st_int_1108 using mt_int tags ("-0.11e-30") values(now, "-0.11e-30");
sql show tags from st_int_1108
if $data05 != 0 then
return -1
endi
sql select * from st_int_1108
if $data01 != 0 then
return -1
endi
sql insert into st_int_1109 using mt_int tags ("-1.1e-307") values(now, "-1.1e-307");
sql show tags from st_int_1109
if $data05 != 0 then
return -1
endi
sql select * from st_int_1109
if $data01 != 0 then
return -1
endi
sql insert into st_int_1110 using mt_int tags ( -1e-1 ) values(now, -1e-1);
sql show tags from st_int_1110
if $data05 != 0 then
return -1
endi
sql select * from st_int_1110
if $data01 != 0 then
return -1
endi
sql insert into st_int_1111 using mt_int tags ( +0.1235e3 ) values(now, +0.1235e3);
sql show tags from st_int_1111
if $data05 != 124 then
return -1
endi
sql select * from st_int_1111
if $data01 != 124 then
return -1
endi
sql insert into st_int_1112 using mt_int tags (-0.11e-30) values(now, -0.11e-30);
sql show tags from st_int_1112
if $data05 != 0 then
return -1
endi
sql select * from st_int_1112
if $data01 != 0 then
return -1
endi
sql insert into st_int_1113 using mt_int tags (-1.1e-307) values(now, -1.1e-307);
sql show tags from st_int_1113
if $data05 != 0 then
return -1
endi
sql select * from st_int_1113
if $data01 != 0 then
return -1
endi
sql insert into st_int_1200 using mt_int tags ( 0x01) values(now, 0x01);
sql show tags from st_int_1200
if $data05 != 1 then
return -1
endi
sql select * from st_int_1200
if $data01 != 1 then
return -1
endi
sql insert into st_int_1201 using mt_int tags (0b01 ) values(now, 0b01);
sql show tags from st_int_1201
if $data05 != 1 then
return -1
endi
sql select * from st_int_1201
if $data01 != 1 then
return -1
endi
sql insert into st_int_1202 using mt_int tags (+0x01) values(now, +0x01);
sql show tags from st_int_1202
if $data05 != 1 then
return -1
endi
sql select * from st_int_1202
if $data01 != 1 then
return -1
endi
sql insert into st_int_1203 using mt_int tags ( -0b01 ) values(now, -0b01);
sql show tags from st_int_1203
if $data05 != -1 then
return -1
endi
sql select * from st_int_1203
if $data01 != -1 then
return -1
endi
### case 03: alter tag values
#sql alter table st_int_0 set tag tagname=2147483647
#sql show tags from st_int_0
#if $data05 != 2147483647 then
# return -1
#endi
#sql alter table st_int_0 set tag tagname=-2147483647
#sql show tags from st_int_0
#if $data05 != -2147483647 then
# return -1
#endi
#sql alter table st_int_0 set tag tagname=+100
#sql show tags from st_int_0
#if $data05 != 100 then
# return -1
#endi
#sql alter table st_int_0 set tag tagname=-33
#sql show tags from st_int_0
#if $data05 != -33 then
# return -1
#endi
#sql alter table st_int_0 set tag tagname='+98'
#sql show tags from st_int_0
#if $data05 != 98 then
# return -1
#endi
#sql alter table st_int_0 set tag tagname='-076'
#sql show tags from st_int_0
#if $data05 != -76 then
# return -1
#endi
#sql alter table st_int_0 set tag tagname=+0012
#sql show tags from st_int_0
#if $data05 != 12 then
# return -1
#endi
#sql alter table st_int_0 set tag tagname=-00063
#sql show tags from st_int_0
#if $data05 != -63 then
# return -1
#endi
sql alter table st_int_0 set tag tagname=2147483647
sql show tags from st_int_0
if $data05 != 2147483647 then
return -1
endi
sql alter table st_int_0 set tag tagname=-2147483647
sql show tags from st_int_0
if $data05 != -2147483647 then
return -1
endi
sql alter table st_int_0 set tag tagname=+100
sql show tags from st_int_0
if $data05 != 100 then
return -1
endi
sql alter table st_int_0 set tag tagname=-33
sql show tags from st_int_0
if $data05 != -33 then
return -1
endi
sql alter table st_int_0 set tag tagname='+98'
sql show tags from st_int_0
if $data05 != 98 then
return -1
endi
sql alter table st_int_0 set tag tagname='-076'
sql show tags from st_int_0
if $data05 != -76 then
return -1
endi
sql alter table st_int_0 set tag tagname=+0012
sql show tags from st_int_0
if $data05 != 12 then
return -1
endi
sql alter table st_int_0 set tag tagname=-00063
sql show tags from st_int_0
if $data05 != -63 then
return -1
endi
sql alter table st_int_100 set tag tagname="0x01"
sql show tags from st_int_100
if $data05 != 1 then
return -1
endi
sql alter table st_int_101 set tag tagname="0b01"
sql show tags from st_int_101
if $data05 != 1 then
return -1
endi
sql alter table st_int_102 set tag tagname="+0x01"
sql show tags from st_int_102
if $data05 != 1 then
return -1
endi
sql alter table st_int_103 set tag tagname="-0b01"
sql show tags from st_int_103
if $data05 != -1 then
return -1
endi
sql alter table st_int_104 set tag tagname="-123.1"
sql show tags from st_int_104
if $data05 != -123 then
return -1
endi
sql alter table st_int_105 set tag tagname="+123.5"
sql show tags from st_int_105
if $data05 != 124 then
return -1
endi
sql alter table st_int_106 set tag tagname="-1e-1"
sql show tags from st_int_106
if $data05 != 0 then
return -1
endi
sql alter table st_int_107 set tag tagname="+0.1235e3"
sql show tags from st_int_107
if $data05 != 124 then
print $data05 != 124
return -1
endi
sql alter table st_int_108 set tag tagname="-0.11e-30"
sql show tags from st_int_108
if $data05 != 0 then
print $data05 != 0
return -1
endi
sql alter table st_int_109 set tag tagname="-1.1e-307"
sql show tags from st_int_109
if $data05 != 0 then
print $data05 != 0
return -1
endi
sql alter table st_int_110 set tag tagname= -1e-1
sql show tags from st_int_110
if $data05 != 0 then
return -1
endi
sql alter table st_int_111 set tag tagname= +0.1235e3
sql show tags from st_int_111
if $data05 != 124 then
print $data05 != 124
return -1
endi
sql alter table st_int_112 set tag tagname=-0.11e-30
sql show tags from st_int_112
if $data05 != 0 then
print $data05 != 0
return -1
endi
sql alter table st_int_113 set tag tagname=-1.1e-307
sql show tags from st_int_113
if $data05 != 0 then
print $data05 != 0
return -1
endi
sql alter table st_int_200 set tag tagname= 0x01
sql show tags from st_int_200
if $data05 != 1 then
return -1
endi
sql alter table st_int_201 set tag tagname=0b01
sql show tags from st_int_201
if $data05 != 1 then
return -1
endi
sql alter table st_int_202 set tag tagname=+0x01
sql show tags from st_int_202
if $data05 != 1 then
return -1
endi
sql alter table st_int_203 set tag tagname= -0b01
sql show tags from st_int_203
if $data05 != -1 then
return -1
endi
## case 04: illegal input
sql_error create table st_int_e0 using mt_int tags (2147483648)
sql create table st_int_e0_err1 using mt_int tags (-2147483648)
sql_error create table st_int_e0_err2 using mt_int tags (-2147483649)
sql_error create table st_int_e0 using mt_int tags (214748364800)
sql_error create table st_int_e0 using mt_int tags (-214748364800)
#sql_error create table st_int_e0 using mt_int tags (12.80) truncate integer part
@ -346,7 +831,7 @@ sql_error create table st_int_e0 using mt_int tags ("123abc")
sql_error create table st_int_e0 using mt_int tags (abc)
sql_error create table st_int_e0 using mt_int tags ("abc")
sql_error create table st_int_e0 using mt_int tags (" ")
sql create table st_int_e0_err2 using mt_int tags ('')
sql_error create table st_int_e0_err2 using mt_int tags ('')
sql create table st_int_e0 using mt_int tags (123)
sql create table st_int_e1 using mt_int tags (123)
@ -399,7 +884,10 @@ sql_error insert into st_int_e20 using mt_int tags ("123abc") values (now, -033)
sql_error insert into st_int_e22 using mt_int tags (abc) values (now, -033)
sql_error insert into st_int_e23 using mt_int tags ("abc") values (now, -033)
sql_error insert into st_int_e24 using mt_int tags (" ") values (now, -033)
sql insert into st_int_e25_1 using mt_int tags ('') values (now, -033)
sql_error insert into st_int_e25_1 using mt_int tags ('') values (now, -033)
sql insert into st_int_e26_1 using mt_int tags ('123') values (now, -033)
sql insert into st_int_e27_1 using mt_int tags ('12.80') values (now, -033)
sql insert into st_int_e28_1 using mt_int tags ('-11.80') values (now, -033)
sql insert into st_int_e13 using mt_int tags (033) values (now, 00062)
sql insert into st_int_e14 using mt_int tags (033) values (now, 00062)
@ -415,8 +903,10 @@ sql insert into st_int_e23 using mt_int tags (033) values (now, 00062)
sql insert into st_int_e24 using mt_int tags (033) values (now, 00062)
sql insert into st_int_e25 using mt_int tags (033) values (now, 00062)
sql alter table st_int_e13 set tag tagname=2147483647
sql_error alter table st_int_e13 set tag tagname=2147483648
sql alter table st_int_e14 set tag tagname=-2147483648
sql_error alter table st_int_e14 set tag tagname=2147483649
sql_error alter table st_int_e15 set tag tagname=12147483648
sql_error alter table st_int_e16 set tag tagname=-3147483648
sql_error alter table st_int_e19 set tag tagname=123abc
@ -424,6 +914,9 @@ sql_error alter table st_int_e20 set tag tagname="123abc"
sql_error alter table st_int_e22 set tag tagname=abc
sql_error alter table st_int_e23 set tag tagname="abc"
sql_error alter table st_int_e24 set tag tagname=" "
sql alter table st_int_e25 set tag tagname=''
sql_error alter table st_int_e25 set tag tagname=''
sql alter table st_int_e26_1 set tag tagname='123'
sql alter table st_int_e27_1 set tag tagname='12.80'
sql alter table st_int_e28_1 set tag tagname='-11.80'
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -0,0 +1,220 @@
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value
######## case 0: json
print ========== json
sql create table mt_json (ts timestamp, c varchar(50)) tags(tagname json)
## case 00: static create table for test tag values
sql create table st_json_0 using mt_json tags(NULL)
sql show tags from st_json_0
if $data05 != NULL then
return -1
endi
sql create table st_json_1 using mt_json tags(NULL)
sql show tags from st_json_1
if $data05 != NULL then
return -1
endi
sql create table st_json_2 using mt_json tags('NULL')
sql show tags from st_json_2
if $data05 != NULL then
return -1
endi
sql create table st_json_3 using mt_json tags('NULL')
sql show tags from st_json_3
if $data05 != NULL then
return -1
endi
sql create table st_json_4 using mt_json tags("NULL")
sql show tags from st_json_4
if $data05 != NULL then
return -1
endi
sql create table st_json_5 using mt_json tags("NULL")
sql show tags from st_json_5
if $data05 != NULL then
return -1
endi
sql create table st_json_6 using mt_json tags("")
sql show tags from st_json_6
if $data05 != NULL then
return -1
endi
sql create table st_json_7 using mt_json tags(" ")
sql show tags from st_json_7
if $data05 != NULL then
return -1
endi
sql create table st_json_8 using mt_json tags("{\"k1\":\"v1\",\"k2\":\"v2\"}")
sql show tags from st_json_8
if $data05 != {"k1":"v1","k2":"v2"} then
return -1
endi
## case 01: insert values for test column values
## case 02: dynamic create table for test tag values
sql insert into st_json_100 using mt_json tags(NULL) values(now,NULL)
sql show tags from st_json_100
if $data05 != NULL then
return -1
endi
sql select * from st_json_100
if $data01 != NULL then
return -1
endi
sql insert into st_json_101 using mt_json tags(NULL) values(now,NULL)
sql show tags from st_json_101
if $data05 != NULL then
return -1
endi
sql select * from st_json_101
if $data01 != NULL then
return -1
endi
sql insert into st_json_102 using mt_json tags('NULL') values(now,'NULL')
sql show tags from st_json_102
if $data05 != NULL then
return -1
endi
sql select * from st_json_102
if $data01 != NULL then
return -1
endi
sql insert into st_json_103 using mt_json tags('NULL') values(now,'NULL')
sql show tags from st_json_103
if $data05 != NULL then
return -1
endi
sql select * from st_json_103
if $data01 != NULL then
return -1
endi
sql insert into st_json_104 using mt_json tags("NULL") values(now,"NULL")
sql show tags from st_json_104
if $data05 != NULL then
return -1
endi
sql select * from st_json_104
if $data01 != NULL then
return -1
endi
sql insert into st_json_105 using mt_json tags("NULL") values(now,"NULL")
sql show tags from st_json_105
if $data05 != NULL then
return -1
endi
sql select * from st_json_105
if $data01 != NULL then
return -1
endi
sql insert into st_json_106 using mt_json tags("") values(now,"vc")
sql show tags from st_json_106
if $data05 != NULL then
return -1
endi
sql select * from st_json_106
if $data01 != vc then
return -1
endi
sql insert into st_json_107 using mt_json tags(" ") values(now,"vc")
sql show tags from st_json_107
if $data05 != NULL then
return -1
endi
sql select * from st_json_107
if $data01 != vc then
return -1
endi
sql insert into st_json_108 using mt_json tags("{\"k1\":\"v1\",\"k2\":\"v2\"} ") values(now,"vc")
sql show tags from st_json_108
if $data05 != {"k1":"v1","k2":"v2"} then
return -1
endi
sql select * from st_json_108
if $data01 != vc then
return -1
endi
## case 03: alter tag values
sql alter table st_json_100 set tag tagname=NULL
sql show tags from st_json_100
if $data05 != NULL then
return -1
endi
sql alter table st_json_101 set tag tagname=NULL
sql show tags from st_json_101
if $data05 != NULL then
return -1
endi
sql alter table st_json_102 set tag tagname='NULL'
sql show tags from st_json_102
if $data05 != NULL then
return -1
endi
sql alter table st_json_103 set tag tagname='NULL'
sql show tags from st_json_103
if $data05 != NULL then
return -1
endi
sql alter table st_json_104 set tag tagname="NULL"
sql show tags from st_json_104
if $data05 != NULL then
return -1
endi
sql alter table st_json_105 set tag tagname="NULL"
sql show tags from st_json_105
if $data05 != NULL then
return -1
endi
sql alter table st_json_106 set tag tagname=""
sql show tags from st_json_106
if $data05 != NULL then
return -1
endi
sql alter table st_json_107 set tag tagname=" "
sql show tags from st_json_107
if $data05 != NULL then
return -1
endi
sql alter table st_json_108 set tag tagname="{\"k1\":\"v1\",\"k2\":\"v2\"}"
sql show tags from st_json_108
if $data05 != {"k1":"v1","k2":"v2"} then
return -1
endi
# case 04: illegal input
sql_error create table st_json_206 using mt_json tags(+0123)
sql_error create table st_json_207 using mt_json tags(-01.23)
sql_error create table st_json_208 using mt_json tags(+0x01)
sql_error create table st_json_209 using mt_json tags(-0b01)
sql_error create table st_json_2010 using mt_json tags(-0.1e-10)
sql_error create table st_json_2011 using mt_json tags(+0.1E+2)
sql_error create table st_json_2012 using mt_json tags(tRue)
sql_error create table st_json_2013 using mt_json tags(FalsE)
sql_error create table st_json_2014 using mt_json tags(noW)
sql_error create table st_json_2015 using mt_json tags(toDay)
sql_error insert into st_json_206 using mt_json tags(+0123) values(now, NULL);
sql_error insert into st_json_207 using mt_json tags(-01.23) values(now, NULL);
sql_error insert into st_json_208 using mt_json tags(+0x01) values(now, NULL);
sql_error insert into st_json_209 using mt_json tags(-0b01) values(now, NULL);
sql_error insert into st_json_2010 using mt_json tags(-0.1e-10) values(now, NULL);
sql_error insert into st_json_2011 using mt_json tags(+0.1E+2) values(now, NULL);
sql_error insert into st_json_2012 using mt_json tags(tRue) values(now, NULL);
sql_error insert into st_json_2013 using mt_json tags(FalsE) values(now, NULL);
sql_error insert into st_json_2014 using mt_json tags(noW) values(now, NULL);
sql_error insert into st_json_2015 using mt_json tags(toDay) values(now, NULL);
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -0,0 +1,415 @@
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value
######## case 0: nchar
print ========== nchar
sql create table mt_nchar (ts timestamp, c nchar(50)) tags (tagname nchar(50))
## case 00: static create table for test tag values
sql create table st_nchar_0 using mt_nchar tags (NULL)
sql show create table st_nchar_0
sql show tags from st_nchar_0
if $data05 != NULL then
return -1
endi
sql create table st_nchar_1 using mt_nchar tags (NULL)
sql show tags from st_nchar_1
if $data05 != NULL then
return -1
endi
sql create table st_nchar_2 using mt_nchar tags ('NULL')
sql show tags from st_nchar_2
if $data05 != NULL then
return -1
endi
sql create table st_nchar_3 using mt_nchar tags ('NULL')
sql show tags from st_nchar_3
if $data05 != NULL then
return -1
endi
sql create table st_nchar_4 using mt_nchar tags ("NULL")
sql show tags from st_nchar_4
if $data05 != NULL then
return -1
endi
sql create table st_nchar_5 using mt_nchar tags ("NULL")
sql show tags from st_nchar_5
if $data05 != NULL then
return -1
endi
sql create table st_nchar_6 using mt_nchar tags (+0123)
sql show tags from st_nchar_6
if $data05 != +0123 then
return -1
endi
sql create table st_nchar_7 using mt_nchar tags (-01.23)
sql show tags from st_nchar_7
if $data05 != -01.23 then
return -1
endi
sql create table st_nchar_8 using mt_nchar tags (+0x01)
sql show tags from st_nchar_8
if $data05 != +0x01 then
return -1
endi
sql create table st_nchar_9 using mt_nchar tags (-0b01)
sql show tags from st_nchar_9
if $data05 != -0b01 then
return -1
endi
sql create table st_nchar_10 using mt_nchar tags (-0.1e-10)
sql show tags from st_nchar_10
if $data05 != -0.1e-10 then
return -1
endi
sql create table st_nchar_11 using mt_nchar tags (+0.1E+2)
sql show tags from st_nchar_11
if $data05 != +0.1e+2 then
return -1
endi
sql create table st_nchar_12 using mt_nchar tags (tRue)
sql show tags from st_nchar_12
if $data05 != true then
return -1
endi
sql create table st_nchar_13 using mt_nchar tags (FalsE)
sql show tags from st_nchar_13
if $data05 != false then
return -1
endi
sql create table st_nchar_14 using mt_nchar tags (noW)
sql show tags from st_nchar_14
if $data05 != now then
return -1
endi
sql create table st_nchar_15 using mt_nchar tags (toDay)
sql show tags from st_nchar_15
if $data05 != today then
return -1
endi
## case 01: insert values for test column values
sql insert into st_nchar_0 values(now, NULL)
sql select * from st_nchar_0
if $data01 != NULL then
return -1
endi
sql insert into st_nchar_1 values(now, NULL)
sql select * from st_nchar_1
if $data01 != NULL then
return -1
endi
sql insert into st_nchar_2 values(now, 'NULL')
sql select * from st_nchar_2
if $data01 != NULL then
return -1
endi
sql insert into st_nchar_3 values(now, 'NULL')
sql select * from st_nchar_3
if $data01 != NULL then
return -1
endi
sql insert into st_nchar_4 values(now, "NULL")
sql select * from st_nchar_4
if $data01 != NULL then
return -1
endi
sql insert into st_nchar_5 values(now, "NULL")
sql select * from st_nchar_5
if $data01 != NULL then
return -1
endi
sql insert into st_nchar_6 values(now, +0123)
sql select * from st_nchar_6
if $data01 != +0123 then
return -1
endi
sql insert into st_nchar_7 values(now, -01.23)
sql select * from st_nchar_7
if $data01 != -01.23 then
return -1
endi
sql insert into st_nchar_8 values(now, +0x01)
sql select * from st_nchar_8
if $data01 != +0x01 then
return -1
endi
sql insert into st_nchar_9 values(now, -0b01)
sql select * from st_nchar_9
if $data01 != -0b01 then
return -1
endi
sql insert into st_nchar_10 values(now, -0.1e-10)
sql select * from st_nchar_10
if $data01 != -0.1e-10 then
return -1
endi
sql insert into st_nchar_11 values(now, +0.1E+2)
sql select * from st_nchar_11
if $data01 != +0.1e+2 then
return -1
endi
sql insert into st_nchar_12 values(now, tRue)
sql select * from st_nchar_12
if $data01 != true then
return -1
endi
sql insert into st_nchar_13 values(now, FalsE)
sql select * from st_nchar_13
if $data01 != false then
return -1
endi
sql insert into st_nchar_14 values(now, noW)
sql select * from st_nchar_14
if $data01 != now then
return -1
endi
sql insert into st_nchar_15 values(now, toDay)
sql select * from st_nchar_15
if $data01 != today then
return -1
endi
## case 02: dynamic create table for test tag values
sql insert into st_nchar_0 using mt_nchar tags (NULL) values(now, NULL)
sql show tags from st_nchar_0
if $data05 != NULL then
return -1
endi
sql select * from st_nchar_0
if $data01 != NULL then
return -1
endi
sql insert into st_nchar_1 using mt_nchar tags (NULL) values(now, NULL)
sql show tags from st_nchar_1
if $data05 != NULL then
return -1
endi
sql select * from st_nchar_1
if $data01 != NULL then
return -1
endi
sql insert into st_nchar_2 using mt_nchar tags ('NULL') values(now, 'NULL')
sql show tags from st_nchar_2
if $data05 != NULL then
return -1
endi
sql select * from st_nchar_2
if $data01 != NULL then
return -1
endi
sql insert into st_nchar_3 using mt_nchar tags ('NULL') values(now, 'NULL')
sql show tags from st_nchar_3
if $data05 != NULL then
return -1
endi
sql select * from st_nchar_3
if $data01 != NULL then
return -1
endi
sql insert into st_nchar_4 using mt_nchar tags ("NULL") values(now, "NULL")
sql show tags from st_nchar_4
if $data05 != NULL then
return -1
endi
sql select * from st_nchar_4
if $data01 != NULL then
return -1
endi
sql insert into st_nchar_5 using mt_nchar tags ("NULL") values(now, "NULL")
sql show tags from st_nchar_5
if $data05 != NULL then
return -1
endi
sql select * from st_nchar_5
if $data01 != NULL then
return -1
endi
sql insert into st_nchar_6 using mt_nchar tags (+0123) values(now, +0123)
sql show tags from st_nchar_6
if $data05 != +0123 then
return -1
endi
sql select * from st_nchar_6
if $data01 != +0123 then
return -1
endi
sql insert into st_nchar_7 using mt_nchar tags (-01.23) values(now, -01.23)
sql show tags from st_nchar_7
if $data05 != -01.23 then
return -1
endi
sql select * from st_nchar_7
if $data01 != -01.23 then
return -1
endi
sql insert into st_nchar_8 using mt_nchar tags (+0x01) values(now, +0x01)
sql show tags from st_nchar_8
if $data05 != +0x01 then
return -1
endi
sql select * from st_nchar_8
if $data01 != +0x01 then
return -1
endi
sql insert into st_nchar_9 using mt_nchar tags (-0b01) values(now, -0b01)
sql show tags from st_nchar_9
if $data05 != -0b01 then
return -1
endi
sql select * from st_nchar_9
if $data01 != -0b01 then
return -1
endi
sql insert into st_nchar_10 using mt_nchar tags (-0.1e-10) values(now, -0.1e-10)
sql show tags from st_nchar_10
if $data05 != -0.1e-10 then
return -1
endi
sql select * from st_nchar_10
if $data01 != -0.1e-10 then
return -1
endi
sql insert into st_nchar_11 using mt_nchar tags (+0.1E+2) values(now, +0.1E+2)
sql show tags from st_nchar_11
if $data05 != +0.1e+2 then
return -1
endi
sql select * from st_nchar_11
if $data01 != +0.1e+2 then
return -1
endi
sql insert into st_nchar_12 using mt_nchar tags (tRue) values(now, tRue)
sql show tags from st_nchar_12
if $data05 != true then
return -1
endi
sql select * from st_nchar_12
if $data01 != true then
return -1
endi
sql insert into st_nchar_13 using mt_nchar tags (FalsE) values(now, FalsE)
sql show tags from st_nchar_13
if $data05 != false then
return -1
endi
sql select * from st_nchar_13
if $data01 != false then
return -1
endi
sql insert into st_nchar_14 using mt_nchar tags (noW) values(now, noW)
sql show tags from st_nchar_14
if $data05 != now then
return -1
endi
sql select * from st_nchar_14
if $data01 != now then
return -1
endi
sql insert into st_nchar_15 using mt_nchar tags (toDay) values(now, toDay)
sql show tags from st_nchar_15
if $data05 != today then
return -1
endi
sql select * from st_nchar_15
if $data01 != today then
return -1
endi
## case 03: alter tag values
sql alter table st_nchar_0 set tag tagname=NULL
sql show tags from st_nchar_0
if $data05 != NULL then
return -1
endi
sql alter table st_nchar_1 set tag tagname=NULL
sql show tags from st_nchar_1
if $data05 != NULL then
return -1
endi
sql alter table st_nchar_2 set tag tagname='NULL'
sql show tags from st_nchar_2
if $data05 != NULL then
return -1
endi
sql alter table st_nchar_3 set tag tagname='NULL'
sql show tags from st_nchar_3
if $data05 != NULL then
return -1
endi
sql alter table st_nchar_4 set tag tagname="NULL"
sql show tags from st_nchar_4
if $data05 != NULL then
return -1
endi
sql alter table st_nchar_5 set tag tagname="NULL"
sql show tags from st_nchar_5
if $data05 != NULL then
return -1
endi
sql alter table st_nchar_6 set tag tagname=+0123
sql show tags from st_nchar_6
if $data05 != +0123 then
return -1
endi
sql alter table st_nchar_7 set tag tagname=-01.23
sql show tags from st_nchar_7
if $data05 != -01.23 then
return -1
endi
sql alter table st_nchar_8 set tag tagname=+0x01
sql show tags from st_nchar_8
if $data05 != +0x01 then
return -1
endi
sql alter table st_nchar_9 set tag tagname=-0b01
sql show tags from st_nchar_9
if $data05 != -0b01 then
return -1
endi
sql alter table st_nchar_10 set tag tagname=-0.1e-10
sql show tags from st_nchar_10
if $data05 != -0.1e-10 then
return -1
endi
sql alter table st_nchar_11 set tag tagname=+0.1E+2
sql show tags from st_nchar_11
if $data05 != +0.1e+2 then
return -1
endi
sql alter table st_nchar_12 set tag tagname=tRue
sql show tags from st_nchar_12
if $data05 != true then
return -1
endi
sql alter table st_nchar_13 set tag tagname=FalsE
sql show tags from st_nchar_13
if $data05 != false then
return -1
endi
sql alter table st_nchar_14 set tag tagname=noW
sql show tags from st_nchar_14
if $data05 != now then
return -1
endi
sql alter table st_nchar_15 set tag tagname=toDay
sql show tags from st_nchar_15
if $data05 != today then
return -1
endi
# case 04: illegal input
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -31,10 +31,27 @@ if $data05 != NULL then
return -1
endi
sql_error create table st_smallint_2 using mt_smallint tags ('NULL')
sql_error create table st_smallint_3 using mt_smallint tags ('NULL')
sql_error create table st_smallint_4 using mt_smallint tags ("NULL")
sql_error create table st_smallint_5 using mt_smallint tags ("NULL")
sql create table st_smallint_2 using mt_smallint tags ('NULL')
sql show tags from st_smallint_2
if $data05 != NULL then
return -1
endi
sql create table st_smallint_3 using mt_smallint tags ('NULL')
sql show tags from st_smallint_3
if $data05 != NULL then
return -1
endi
sql create table st_smallint_4 using mt_smallint tags ("NULL")
sql show tags from st_smallint_4
if $data05 != NULL then
return -1
endi
sql create table st_smallint_5 using mt_smallint tags ("NULL")
sql show tags from st_smallint_5
if $data05 != NULL then
return -1
endi
sql create table st_smallint_6 using mt_smallint tags (-32767)
sql show tags from st_smallint_6
@ -349,7 +366,8 @@ sql_error create table st_smallint_e0 using mt_smallint tags ("123abc")
sql_error create table st_smallint_e0 using mt_smallint tags (abc)
sql_error create table st_smallint_e0 using mt_smallint tags ("abc")
sql_error create table st_smallint_e0 using mt_smallint tags (" ")
sql create table st_smallint_e0_1 using mt_smallint tags ('')
sql_error create table st_smallint_e0_1 using mt_smallint tags ('')
sql create table st_smallint_e0_2 using mt_smallint tags ('123')
sql create table st_smallint_e0 using mt_smallint tags (123)
sql create table st_smallint_e1 using mt_smallint tags (123)
@ -402,7 +420,8 @@ sql_error insert into st_smallint_e20 using mt_smallint tags ("123abc") values (
sql_error insert into st_smallint_e22 using mt_smallint tags (abc) values (now, -033)
sql_error insert into st_smallint_e23 using mt_smallint tags ("abc") values (now, -033)
sql_error insert into st_smallint_e24 using mt_smallint tags (" ") values (now, -033)
sql insert into st_smallint_e25 using mt_smallint tags ('') values (now, -033)
sql_error insert into st_smallint_e25 using mt_smallint tags ('') values (now, -033)
sql insert into st_smallint_e26 using mt_smallint tags ('123') values (now, -033)
sql insert into st_smallint_e13 using mt_smallint tags (033) values (now, 00062)
sql insert into st_smallint_e14 using mt_smallint tags (033) values (now, 00062)
@ -427,6 +446,7 @@ sql_error alter table st_smallint_e20 set tag tagname="123abc"
sql_error alter table st_smallint_e22 set tag tagname=abc
sql_error alter table st_smallint_e23 set tag tagname="abc"
sql_error alter table st_smallint_e24 set tag tagname=" "
sql alter table st_smallint_e25 set tag tagname=''
sql_error alter table st_smallint_e25 set tag tagname=''
sql alter table st_smallint_e26 set tag tagname='123'
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -0,0 +1,594 @@
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value
######## case 0: timestamp
print ========== timestamp
sql create table mt_timestamp (ts timestamp, c timestamp) tags (tagname timestamp)
## case 00: static create table for test tag values
sql create table st_timestamp_0 using mt_timestamp tags (NULL)
sql show create table st_timestamp_0
sql show tags from st_timestamp_0
if $data05 != NULL then
return -1
endi
sql create table st_timestamp_1 using mt_timestamp tags (NULL)
sql show tags from st_timestamp_1
if $data05 != NULL then
return -1
endi
sql create table st_timestamp_2 using mt_timestamp tags ('NULL')
sql show tags from st_timestamp_2
if $data05 != NULL then
return -1
endi
sql create table st_timestamp_3 using mt_timestamp tags ('NULL')
sql show tags from st_timestamp_3
if $data05 != NULL then
return -1
endi
sql create table st_timestamp_4 using mt_timestamp tags ("NULL")
sql show tags from st_timestamp_4
if $data05 != NULL then
return -1
endi
sql create table st_timestamp_5 using mt_timestamp tags ("NULL")
sql show tags from st_timestamp_5
if $data05 != NULL then
return -1
endi
sql create table st_timestamp_6 using mt_timestamp tags (-2147483647)
sql show tags from st_timestamp_6
if $data05 != -2147483647 then
return -1
endi
sql create table st_timestamp_7 using mt_timestamp tags (2147483647)
sql show tags from st_timestamp_7
if $data05 != 2147483647 then
return -1
endi
sql create table st_timestamp_8 using mt_timestamp tags (37)
sql show tags from st_timestamp_8
if $data05 != 37 then
return -1
endi
sql create table st_timestamp_9 using mt_timestamp tags (-100)
sql show tags from st_timestamp_9
if $data05 != -100 then
return -1
endi
sql create table st_timestamp_10 using mt_timestamp tags (+113)
sql show tags from st_timestamp_10
if $data05 != 113 then
return -1
endi
sql create table st_timestamp_11 using mt_timestamp tags ('-100')
sql show tags from st_timestamp_11
if $data05 != -100 then
return -1
endi
sql create table st_timestamp_12 using mt_timestamp tags ("-0")
sql show tags from st_timestamp_12
if $data05 != 0 then
return -1
endi
sql create table st_timestamp_13 using mt_timestamp tags (+0078)
sql show tags from st_timestamp_13
if $data05 != 78 then
return -1
endi
sql create table st_timestamp_14 using mt_timestamp tags (-00078)
sql show tags from st_timestamp_14
if $data05 != -78 then
return -1
endi
sql create table st_timestamp_15 using mt_timestamp tags ("0x01")
sql show tags from st_timestamp_15
if $data05 != 1 then
return -1
endi
sql create table st_timestamp_16 using mt_timestamp tags ("0b01")
sql show tags from st_timestamp_16
if $data05 != 1 then
return -1
endi
sql create table st_timestamp_17 using mt_timestamp tags ("+0x01")
sql show tags from st_timestamp_17
if $data05 != 1 then
return -1
endi
sql create table st_timestamp_18 using mt_timestamp tags ("-0b01")
sql show tags from st_timestamp_18
if $data05 != -1 then
return -1
endi
sql create table st_timestamp_19 using mt_timestamp tags ( 0x01)
sql show tags from st_timestamp_19
if $data05 != 1 then
return -1
endi
sql create table st_timestamp_20 using mt_timestamp tags (0b01 )
sql show tags from st_timestamp_20
if $data05 != 1 then
return -1
endi
sql create table st_timestamp_21 using mt_timestamp tags (+0x01)
sql show tags from st_timestamp_21
if $data05 != 1 then
return -1
endi
sql create table st_timestamp_22 using mt_timestamp tags ( -0b01 )
sql show tags from st_timestamp_22
if $data05 != -1 then
return -1
endi
## case 01: insert values for test column values
sql insert into st_timestamp_0 values(now,NULL)
sql select * from st_timestamp_0
if $data01 != NULL then
return -1
endi
sql insert into st_timestamp_1 values(now,NULL)
sql select * from st_timestamp_1
if $data01 != NULL then
return -1
endi
sql insert into st_timestamp_2 values(now,'NULL')
sql select * from st_timestamp_2
if $data01 != NULL then
return -1
endi
sql insert into st_timestamp_3 values(now,'NULL')
sql select * from st_timestamp_3
if $data01 != NULL then
return -1
endi
sql insert into st_timestamp_4 values(now,"NULL")
sql select * from st_timestamp_4
if $data01 != NULL then
return -1
endi
sql insert into st_timestamp_5 values(now,"NULL")
sql select * from st_timestamp_5
if $data01 != NULL then
return -1
endi
sql insert into st_timestamp_6 values(now,-2147483647)
sql select ts, cast(c as bigint) from st_timestamp_6
if $data01 != -2147483647 then
return -1
endi
sql insert into st_timestamp_7 values(now,2147483647)
sql select ts, cast(c as bigint) from st_timestamp_7
if $data01 != 2147483647 then
return -1
endi
sql insert into st_timestamp_8 values(now,37)
sql select ts, cast(c as bigint) from st_timestamp_8
if $data01 != 37 then
return -1
endi
sql insert into st_timestamp_9 values(now,-100)
sql select ts, cast(c as bigint) from st_timestamp_9
if $data01 != -100 then
return -1
endi
sql insert into st_timestamp_10 values(now,+113)
sql select ts, cast(c as bigint) from st_timestamp_10
if $data01 != 113 then
return -1
endi
sql insert into st_timestamp_11 values(now,'-100')
sql select ts, cast(c as bigint) from st_timestamp_11
if $data01 != -100 then
return -1
endi
sql insert into st_timestamp_12 values(now,"-0")
sql select ts, cast(c as bigint) from st_timestamp_12
if $data01 != 0 then
return -1
endi
sql insert into st_timestamp_13 values(now,+0078)
sql select ts, cast(c as bigint) from st_timestamp_13
if $data01 != 78 then
return -1
endi
sql insert into st_timestamp_14 values(now,-00078)
sql select ts, cast(c as bigint) from st_timestamp_14
if $data01 != -78 then
return -1
endi
sql insert into st_timestamp_15 values(now,"0x01")
sql select ts, cast(c as bigint) from st_timestamp_15
if $data01 != 1 then
return -1
endi
sql insert into st_timestamp_16 values(now,"0b01")
sql select ts, cast(c as bigint) from st_timestamp_16
if $data01 != 1 then
return -1
endi
sql insert into st_timestamp_17 values(now,"+0x01")
sql select ts, cast(c as bigint) from st_timestamp_17
if $data01 != 1 then
return -1
endi
sql insert into st_timestamp_18 values(now,"-0b01")
sql select ts, cast(c as bigint) from st_timestamp_18
if $data01 != -1 then
return -1
endi
sql insert into st_timestamp_19 values(now, 0x01)
sql select ts, cast(c as bigint) from st_timestamp_19
if $data01 != 1 then
return -1
endi
sql insert into st_timestamp_20 values(now,0b01 )
sql select ts, cast(c as bigint) from st_timestamp_20
if $data01 != 1 then
return -1
endi
sql insert into st_timestamp_21 values(now,+0x01)
sql select ts, cast(c as bigint) from st_timestamp_21
if $data01 != 1 then
return -1
endi
sql insert into st_timestamp_22 values(now, -0b01 )
sql select ts, cast(c as bigint) from st_timestamp_22
if $data01 != -1 then
return -1
endi
## case 02: dynamic create table for test tag values
sql insert into st_timestamp_100 using mt_timestamp tags(NULL) values(now, NULL)
sql show tags from st_timestamp_100
if $data05 != NULL then
return -1
endi
sql select * from st_timestamp_100
if $data01 != NULL then
return -1
endi
sql insert into st_timestamp_101 using mt_timestamp tags(NULL) values(now, NULL)
sql show tags from st_timestamp_101
if $data05 != NULL then
return -1
endi
sql select * from st_timestamp_101
if $data01 != NULL then
return -1
endi
sql insert into st_timestamp_102 using mt_timestamp tags('NULL') values(now, 'NULL')
sql show tags from st_timestamp_102
if $data05 != NULL then
return -1
endi
sql select * from st_timestamp_102
if $data01 != NULL then
return -1
endi
sql insert into st_timestamp_103 using mt_timestamp tags('NULL') values(now, 'NULL')
sql show tags from st_timestamp_103
if $data05 != NULL then
return -1
endi
sql select * from st_timestamp_103
if $data01 != NULL then
return -1
endi
sql insert into st_timestamp_104 using mt_timestamp tags("NULL") values(now, "NULL")
sql show tags from st_timestamp_104
if $data05 != NULL then
return -1
endi
sql select * from st_timestamp_104
if $data01 != NULL then
return -1
endi
sql insert into st_timestamp_105 using mt_timestamp tags("NULL") values(now, "NULL")
sql show tags from st_timestamp_105
if $data05 != NULL then
return -1
endi
sql select * from st_timestamp_105
if $data01 != NULL then
return -1
endi
sql insert into st_timestamp_106 using mt_timestamp tags(-2147483647) values(now, -2147483647)
sql show tags from st_timestamp_106
if $data05 != -2147483647 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_106
if $data01 != -2147483647 then
return -1
endi
sql insert into st_timestamp_107 using mt_timestamp tags(2147483647) values(now, 2147483647)
sql show tags from st_timestamp_107
if $data05 != 2147483647 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_107
if $data01 != 2147483647 then
return -1
endi
sql insert into st_timestamp_108 using mt_timestamp tags(37) values(now, 37)
sql show tags from st_timestamp_108
if $data05 != 37 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_108
if $data01 != 37 then
return -1
endi
sql insert into st_timestamp_109 using mt_timestamp tags(-100) values(now, -100)
sql show tags from st_timestamp_109
if $data05 != -100 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_109
if $data01 != -100 then
return -1
endi
sql insert into st_timestamp_1010 using mt_timestamp tags(+113) values(now, +113)
sql show tags from st_timestamp_1010
if $data05 != 113 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1010
if $data01 != 113 then
return -1
endi
sql insert into st_timestamp_1011 using mt_timestamp tags('-100') values(now, '-100')
sql show tags from st_timestamp_1011
if $data05 != -100 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1011
if $data01 != -100 then
return -1
endi
sql insert into st_timestamp_1012 using mt_timestamp tags("-0") values(now, "-0")
sql show tags from st_timestamp_1012
if $data05 != 0 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1012
if $data01 != 0 then
return -1
endi
sql insert into st_timestamp_1013 using mt_timestamp tags(+0078) values(now, +0078)
sql show tags from st_timestamp_1013
if $data05 != 78 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1013
if $data01 != 78 then
return -1
endi
sql insert into st_timestamp_1014 using mt_timestamp tags(-00078) values(now, -00078)
sql show tags from st_timestamp_1014
if $data05 != -78 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1014
if $data01 != -78 then
return -1
endi
sql insert into st_timestamp_1015 using mt_timestamp tags("0x01") values(now, "0x01")
sql show tags from st_timestamp_1015
if $data05 != 1 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1015
if $data01 != 1 then
return -1
endi
sql insert into st_timestamp_1016 using mt_timestamp tags("0b01") values(now, "0b01")
sql show tags from st_timestamp_1016
if $data05 != 1 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1016
if $data01 != 1 then
return -1
endi
sql insert into st_timestamp_1017 using mt_timestamp tags("+0x01") values(now, "+0x01")
sql show tags from st_timestamp_1017
if $data05 != 1 then
return -1
endi
sql insert into st_timestamp_1018 using mt_timestamp tags("-0b01") values(now, "-0b01")
sql show tags from st_timestamp_1018
if $data05 != -1 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1018
if $data01 != -1 then
return -1
endi
sql insert into st_timestamp_1019 using mt_timestamp tags( 0x01) values(now, 0x01)
sql show tags from st_timestamp_1019
if $data05 != 1 then
return -1
endi
sql insert into st_timestamp_1020 using mt_timestamp tags(0b01 ) values(now, 0b01 )
sql show tags from st_timestamp_1020
if $data05 != 1 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1020
if $data01 != 1 then
return -1
endi
sql insert into st_timestamp_1021 using mt_timestamp tags(+0x01) values(now, +0x01)
sql show tags from st_timestamp_1021
if $data05 != 1 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1021
if $data01 != 1 then
return -1
endi
sql insert into st_timestamp_1022 using mt_timestamp tags( -0b01 ) values(now, -0b01)
sql show tags from st_timestamp_1022
if $data05 != -1 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1022
if $data01 != -1 then
return -1
endi
### case 03: alter tag values
sql alter table st_timestamp_0 set tag tagname=NULL
sql show tags from st_timestamp_0
if $data05 != NULL then
return -1
endi
sql alter table st_timestamp_1 set tag tagname=NULL
sql show tags from st_timestamp_1
if $data05 != NULL then
return -1
endi
sql alter table st_timestamp_2 set tag tagname='NULL'
sql show tags from st_timestamp_2
if $data05 != NULL then
return -1
endi
sql alter table st_timestamp_3 set tag tagname='NULL'
sql show tags from st_timestamp_3
if $data05 != NULL then
return -1
endi
sql alter table st_timestamp_4 set tag tagname="NULL"
sql show tags from st_timestamp_4
if $data05 != NULL then
return -1
endi
sql alter table st_timestamp_5 set tag tagname="NULL"
sql show tags from st_timestamp_5
if $data05 != NULL then
return -1
endi
sql alter table st_timestamp_6 set tag tagname=-2147483647
sql show tags from st_timestamp_6
if $data05 != -2147483647 then
return -1
endi
sql alter table st_timestamp_7 set tag tagname=2147483647
sql show tags from st_timestamp_7
if $data05 != 2147483647 then
return -1
endi
sql alter table st_timestamp_8 set tag tagname=37
sql show tags from st_timestamp_8
if $data05 != 37 then
return -1
endi
sql alter table st_timestamp_9 set tag tagname=-100
sql show tags from st_timestamp_9
if $data05 != -100 then
return -1
endi
sql alter table st_timestamp_10 set tag tagname=+113
sql show tags from st_timestamp_10
if $data05 != 113 then
return -1
endi
sql alter table st_timestamp_11 set tag tagname='-100'
sql show tags from st_timestamp_11
if $data05 != -100 then
return -1
endi
sql alter table st_timestamp_12 set tag tagname="-0"
sql show tags from st_timestamp_12
if $data05 != 0 then
return -1
endi
sql alter table st_timestamp_13 set tag tagname=+0078
sql show tags from st_timestamp_13
if $data05 != 78 then
return -1
endi
sql alter table st_timestamp_14 set tag tagname=-00078
sql show tags from st_timestamp_14
if $data05 != -78 then
return -1
endi
sql alter table st_timestamp_15 set tag tagname="0x01"
sql show tags from st_timestamp_15
if $data05 != 1 then
return -1
endi
sql alter table st_timestamp_16 set tag tagname="0b01"
sql show tags from st_timestamp_16
if $data05 != 1 then
return -1
endi
sql alter table st_timestamp_17 set tag tagname="+0x01"
sql show tags from st_timestamp_17
if $data05 != 1 then
return -1
endi
sql alter table st_timestamp_18 set tag tagname="-0b01"
sql show tags from st_timestamp_18
if $data05 != -1 then
return -1
endi
sql alter table st_timestamp_19 set tag tagname= 0x01
sql show tags from st_timestamp_19
if $data05 != 1 then
return -1
endi
sql alter table st_timestamp_20 set tag tagname=0b01
sql show tags from st_timestamp_20
if $data05 != 1 then
return -1
endi
sql alter table st_timestamp_21 set tag tagname=+0x01
sql show tags from st_timestamp_21
if $data05 != 1 then
return -1
endi
sql alter table st_timestamp_22 set tag tagname= -0b01
sql show tags from st_timestamp_22
if $data05 != -1 then
return -1
endi
## case 04: illegal input
sql_error create table st_timestamp_e0 using mt_timestamp tags (123abc)
sql_error create table st_timestamp_e0 using mt_timestamp tags ("123abc")
sql_error create table st_timestamp_e0 using mt_timestamp tags (abc)
sql_error create table st_timestamp_e0 using mt_timestamp tags ("abc")
sql_error create table st_timestamp_e0 using mt_timestamp tags (" ")
sql_error create table st_timestamp_e0 using mt_timestamp tags ('')
sql_error create table st_timestamp_104 using mt_timestamp tags ("-123.1")
sql_error create table st_timestamp_105 using mt_timestamp tags ("+123.5")
sql_error create table st_timestamp_106 using mt_timestamp tags ("-1e-1")
sql_error create table st_timestamp_107 using mt_timestamp tags ("+0.1235e3")
sql_error create table st_timestamp_108 using mt_timestamp tags ("-0.11e-30")
sql_error create table st_timestamp_109 using mt_timestamp tags ("-1.1e-307")
sql_error create table st_timestamp_110 using mt_timestamp tags ( -1e-1 )
sql_error create table st_timestamp_111 using mt_timestamp tags ( +0.1235e3 )
sql_error create table st_timestamp_112 using mt_timestamp tags (-0.11e-30)
sql_error create table st_timestamp_113 using mt_timestamp tags (-1.1e-307)
sql create table st_timestamp_114 using mt_timestamp tags (9223372036854775807)
sql_error create table st_timestamp_115 using mt_timestamp tags (9223372036854775808)
sql create table st_timestamp_116 using mt_timestamp tags (-9223372036854775808)
sql_error create table st_timestamp_117 using mt_timestamp tags (-9223372036854775809)
sql_error insert into st_timestamp_118 using mt_timestamp tags(9223372036854775807) values(9223372036854775807, 9223372036854775807)
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -29,10 +29,26 @@ if $data05 != NULL then
return -1
endi
sql_error create table st_tinyint_2 using mt_tinyint tags ('NULL')
sql_error create table st_tinyint_3 using mt_tinyint tags ('NULL')
sql_error create table st_tinyint_4 using mt_tinyint tags ("NULL")
sql_error create table st_tinyint_5 using mt_tinyint tags ("NULL")
sql create table st_tinyint_2 using mt_tinyint tags ('NULL')
sql show tags from st_tinyint_2
if $data05 != NULL then
return -1
endi
sql create table st_tinyint_3 using mt_tinyint tags ('NULL')
sql show tags from st_tinyint_3
if $data05 != NULL then
return -1
endi
sql create table st_tinyint_4 using mt_tinyint tags ("NULL")
sql show tags from st_tinyint_4
if $data05 != NULL then
return -1
endi
sql create table st_tinyint_5 using mt_tinyint tags ("NULL")
sql show tags from st_tinyint_5
if $data05 != NULL then
return -1
endi
sql create table st_tinyint_6 using mt_tinyint tags (-127)
sql show tags from st_tinyint_6
@ -97,6 +113,40 @@ endi
if $data01 != NULL then
return -1
endi
sql insert into st_tinyint_2 values (now, NULL)
sql select * from st_tinyint_2
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_tinyint_3 values (now, NULL)
sql select * from st_tinyint_3
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_tinyint_4 values (now, NULL)
sql select * from st_tinyint_4
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_tinyint_5 values (now, NULL)
sql select * from st_tinyint_5
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_tinyint_6 values (now, 127)
sql select * from st_tinyint_6
if $rows != 1 then
@ -347,7 +397,7 @@ sql_error create table st_tinyint_e0 using mt_tinyint tags ("123abc")
sql_error create table st_tinyint_e0 using mt_tinyint tags (abc)
sql_error create table st_tinyint_e0 using mt_tinyint tags ("abc")
sql_error create table st_tinyint_e0 using mt_tinyint tags (" ")
sql create table st_tinyint_e0_2 using mt_tinyint tags ('')
sql_error create table st_tinyint_e0_2 using mt_tinyint tags ('')
sql create table st_tinyint_e0 using mt_tinyint tags (123)
sql create table st_tinyint_e1 using mt_tinyint tags (123)
@ -400,7 +450,7 @@ sql_error insert into st_tinyint_e20 using mt_tinyint tags ("123abc") values (no
sql_error insert into st_tinyint_e22 using mt_tinyint tags (abc) values (now, -033)
sql_error insert into st_tinyint_e23 using mt_tinyint tags ("abc") values (now, -033)
sql_error insert into st_tinyint_e24 using mt_tinyint tags (" ") values (now, -033)
sql insert into st_tinyint_e25 using mt_tinyint tags ('') values (now, -033)
sql_error insert into st_tinyint_e25 using mt_tinyint tags ('') values (now, -033)
sql insert into st_tinyint_e13 using mt_tinyint tags (033) values (now, 00062)
sql insert into st_tinyint_e14 using mt_tinyint tags (033) values (now, 00062)
@ -425,6 +475,6 @@ sql_error alter table st_tinyint_e20 set tag tagname="123abc"
sql_error alter table st_tinyint_e22 set tag tagname=abc
sql_error alter table st_tinyint_e23 set tag tagname="abc"
sql_error alter table st_tinyint_e24 set tag tagname=" "
sql alter table st_tinyint_e25 set tag tagname=''
sql_error alter table st_tinyint_e25 set tag tagname=''
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -0,0 +1,904 @@
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value
######## case 0: uint
print ========== uint
sql create table mt_uint (ts timestamp, c int unsigned) tags (tagname int unsigned)
## case 00: static create table for test tag values
sql create table st_uint_0 using mt_uint tags (NULL)
sql show create table st_uint_0
sql show tags from st_uint_0
if $data05 != NULL then
return -1
endi
sql create table st_uint_1 using mt_uint tags (NULL)
sql show tags from st_uint_1
if $data05 != NULL then
return -1
endi
sql create table st_uint_2 using mt_uint tags ('NULL')
sql show tags from st_uint_2
if $data05 != NULL then
return -1
endi
sql create table st_uint_3 using mt_uint tags ('NULL')
sql show tags from st_uint_3
if $data05 != NULL then
return -1
endi
sql create table st_uint_4 using mt_uint tags ("NULL")
sql show tags from st_uint_4
if $data05 != NULL then
return -1
endi
sql create table st_uint_5 using mt_uint tags ("-0")
sql show tags from st_uint_5
if $data05 != 0 then
return -1
endi
sql create table st_uint_6 using mt_uint tags (-0 )
sql show tags from st_uint_6
if $data05 != 0 then
return -1
endi
sql create table st_uint_7 using mt_uint tags (2147483647)
sql show tags from st_uint_7
if $data05 != 2147483647 then
return -1
endi
sql create table st_uint_8 using mt_uint tags (37)
sql show tags from st_uint_8
if $data05 != 37 then
return -1
endi
sql create table st_uint_9 using mt_uint tags (098)
sql show tags from st_uint_9
if $data05 != 98 then
return -1
endi
sql create table st_uint_10 using mt_uint tags (+113)
sql show tags from st_uint_10
if $data05 != 113 then
return -1
endi
sql create table st_uint_11 using mt_uint tags (+000.000)
sql show tags from st_uint_11
if $data05 != 0 then
return -1
endi
sql create table st_uint_12 using mt_uint tags ("+78")
sql show tags from st_uint_12
if $data05 != 78 then
return -1
endi
sql create table st_uint_13 using mt_uint tags (+0078)
sql show tags from st_uint_13
if $data05 != 78 then
return -1
endi
sql create table st_uint_14 using mt_uint tags (00078)
sql show tags from st_uint_14
if $data05 != 78 then
return -1
endi
sql create table st_uint_100 using mt_uint tags ("0x01")
sql show tags from st_uint_100
if $data05 != 1 then
return -1
endi
sql create table st_uint_101 using mt_uint tags ("0b01")
sql show tags from st_uint_101
if $data05 != 1 then
return -1
endi
sql create table st_uint_102 using mt_uint tags ("+0x01")
sql show tags from st_uint_102
if $data05 != 1 then
return -1
endi
sql create table st_uint_103 using mt_uint tags ("-0b00")
sql show tags from st_uint_103
if $data05 != 0 then
return -1
endi
sql create table st_uint_104 using mt_uint tags ("123.1")
sql show tags from st_uint_104
if $data05 != 123 then
return -1
endi
sql create table st_uint_105 using mt_uint tags ("+123.5")
sql show tags from st_uint_105
if $data05 != 124 then
return -1
endi
sql create table st_uint_106 using mt_uint tags ("-1e-1")
sql show tags from st_uint_106
if $data05 != 0 then
return -1
endi
sql create table st_uint_107 using mt_uint tags ("+0.1235e3")
sql show tags from st_uint_107
if $data05 != 124 then
print $data05 != 124
return -1
endi
sql create table st_uint_108 using mt_uint tags ("-0.11e-30")
sql show tags from st_uint_108
if $data05 != 0 then
print $data05 != 0
return -1
endi
sql create table st_uint_109 using mt_uint tags ("-1.1e-307")
sql show tags from st_uint_109
if $data05 != 0 then
print $data05 != 0
return -1
endi
sql create table st_uint_110 using mt_uint tags ( -1e-1 )
sql show tags from st_uint_110
if $data05 != 0 then
return -1
endi
sql create table st_uint_111 using mt_uint tags ( +0.1235e3 )
sql show tags from st_uint_111
if $data05 != 124 then
print $data05 != 124
return -1
endi
sql create table st_uint_112 using mt_uint tags (-0.11e-30)
sql show tags from st_uint_112
if $data05 != 0 then
print $data05 != 0
return -1
endi
sql create table st_uint_113 using mt_uint tags (-1.1e-307)
sql show tags from st_uint_113
if $data05 != 0 then
print $data05 != 0
return -1
endi
sql create table st_uint_200 using mt_uint tags ( 0x01)
sql show tags from st_uint_200
if $data05 != 1 then
return -1
endi
sql create table st_uint_201 using mt_uint tags (0b01 )
sql show tags from st_uint_201
if $data05 != 1 then
return -1
endi
sql create table st_uint_202 using mt_uint tags (+0x01)
sql show tags from st_uint_202
if $data05 != 1 then
return -1
endi
sql create table st_uint_203 using mt_uint tags ( -0b00 )
sql show tags from st_uint_203
if $data05 != 0 then
return -1
endi
## case 01: insert values for test column values
sql insert into st_uint_0 values (now, NULL)
sql select * from st_uint_0
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_uint_1 values (now, "-0")
sql select * from st_uint_1
if $rows != 1 then
return -1
endi
if $data01 != 0 then
return -1
endi
sql insert into st_uint_6 values (now, 2147483647)
sql select * from st_uint_6
if $rows != 1 then
return -1
endi
if $data01 != 2147483647 then
return -1
endi
sql insert into st_uint_7 values (now, -0)
sql select * from st_uint_7
if $rows != 1 then
return -1
endi
if $data01 != 0 then
return -1
endi
sql insert into st_uint_8 values (now, +100)
sql select * from st_uint_8
if $rows != 1 then
return -1
endi
if $data01 != 100 then
return -1
endi
sql insert into st_uint_9 values (now, "098")
sql select * from st_uint_9
if $rows != 1 then
return -1
endi
if $data01 != 98 then
return -1
endi
sql insert into st_uint_10 values (now, '0')
sql select * from st_uint_10
if $rows != 1 then
return -1
endi
if $data01 != 0 then
return -1
endi
sql insert into st_uint_11 values (now, +000.000)
sql select * from st_uint_11
if $rows != 1 then
return -1
endi
if $data01 != 0 then
return -1
endi
sql insert into st_uint_12 values (now, "+056")
sql select * from st_uint_12
if $rows != 1 then
return -1
endi
if $data01 != 56 then
return -1
endi
sql insert into st_uint_13 values (now, +056)
sql select * from st_uint_13
if $rows != 1 then
return -1
endi
if $data01 != 56 then
return -1
endi
sql insert into st_uint_14 values (now, 056)
sql select * from st_uint_14
if $rows != 1 then
return -1
endi
if $data01 != 56 then
return -1
endi
sql insert into st_uint_100 values (now, "0x01")
sql select * from st_uint_100
if $rows != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql insert into st_uint_101 values (now, "0b01")
sql select * from st_uint_101
if $rows != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql insert into st_uint_102 values (now, "+0x01")
sql select * from st_uint_102
if $rows != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql insert into st_uint_103 values (now, "-0b00")
sql select * from st_uint_103
if $data01 != 0 then
return -1
endi
sql insert into st_uint_104 values (now, "123.1")
sql select * from st_uint_104
if $data01 != 123 then
return -1
endi
sql insert into st_uint_105 values (now, "+123.5")
sql select * from st_uint_105
if $data01 != 124 then
return -1
endi
sql insert into st_uint_106 values (now, "-1e-1")
sql select * from st_uint_106
if $data01 != 0 then
return -1
endi
sql insert into st_uint_107 values (now, "+0.1235e3")
sql select * from st_uint_107
if $data01 != 124 then
print $data05 != 124
return -1
endi
sql insert into st_uint_108 values (now, "-0.11e-30")
sql select * from st_uint_108
if $data01 != 0 then
print $data05 != 0
return -1
endi
sql insert into st_uint_109 values (now, "-1.1e-307")
sql select * from st_uint_109
if $data01 != 0 then
print $data05 != 0
return -1
endi
sql insert into st_uint_110 values (now, -1e-1 )
sql select * from st_uint_110
if $data01 != 0 then
return -1
endi
sql insert into st_uint_111 values (now, +0.1235e3 )
sql select * from st_uint_111
if $data01 != 124 then
print $data05 != 124
return -1
endi
sql insert into st_uint_112 values (now, -0.11e-30)
sql select * from st_uint_112
if $data01 != 0 then
print $data05 != 0
return -1
endi
sql insert into st_uint_113 values (now, -1.1e-307)
sql select * from st_uint_113
if $data01 != 0 then
print $data05 != 0
return -1
endi
sql insert into st_uint_200 values (now, 0x01)
sql select * from st_uint_200
if $rows != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql insert into st_uint_201 values (now, 0b01 )
sql select * from st_uint_201
if $rows != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql insert into st_uint_202 values (now, +0x01)
sql select * from st_uint_202
if $rows != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql insert into st_uint_203 values (now, -0b00 )
sql select * from st_uint_203
if $data01 != 0 then
return -1
endi
## case 02: dynamic create table for test tag values
sql insert into st_uint_16 using mt_uint tags (NULL) values (now, NULL)
sql show create table st_uint_16
sql show tags from st_uint_16
if $data05 != NULL then
return -1
endi
sql select * from st_uint_16
if $data01 != NULL then
return -1
endi
sql insert into st_uint_17 using mt_uint tags (NULL) values (now, NULL)
sql show tags from st_uint_17
if $data05 != NULL then
return -1
endi
sql select * from st_uint_17
if $data01 != NULL then
return -1
endi
sql insert into st_uint_18 using mt_uint tags ('NULL') values (now, 'NULL')
sql show tags from st_uint_18
if $data05 != NULL then
return -1
endi
sql select * from st_uint_18
if $data01 != NULL then
return -1
endi
sql insert into st_uint_19 using mt_uint tags ('NULL') values (now, 'NULL')
sql show tags from st_uint_19
if $data05 != NULL then
return -1
endi
sql select * from st_uint_19
if $data01 != NULL then
return -1
endi
sql insert into st_uint_20 using mt_uint tags ("NULL") values (now, "NULL")
sql show tags from st_uint_20
if $data05 != NULL then
return -1
endi
sql select * from st_uint_20
if $data01 != NULL then
return -1
endi
sql insert into st_uint_21 using mt_uint tags ("-0") values (now, "-0")
sql show tags from st_uint_21
if $data05 != 0 then
return -1
endi
sql select * from st_uint_21
if $data01 != 0 then
return -1
endi
sql insert into st_uint_22 using mt_uint tags (2147483647) values (now, 2147483647)
sql show tags from st_uint_22
if $data05 != 2147483647 then
return -1
endi
sql select * from st_uint_22
if $data01 != 2147483647 then
return -1
endi
sql insert into st_uint_23 using mt_uint tags (-0) values (now, -0)
sql show tags from st_uint_23
if $data05 != 0 then
return -1
endi
sql select * from st_uint_23
if $data01 != 0 then
return -1
endi
sql insert into st_uint_24 using mt_uint tags (10) values (now, 10)
sql show tags from st_uint_24
if $data05 != 10 then
return -1
endi
sql select * from st_uint_24
if $data01 != 10 then
return -1
endi
sql insert into st_uint_25 using mt_uint tags ("-0") values (now, "-0")
sql show tags from st_uint_25
if $data05 != 0 then
return -1
endi
sql select * from st_uint_25
if $data01 != 0 then
return -1
endi
sql insert into st_uint_26 using mt_uint tags ('123') values (now, '123')
sql show tags from st_uint_26
if $data05 != 123 then
return -1
endi
sql select * from st_uint_26
if $data01 != 123 then
return -1
endi
sql insert into st_uint_27 using mt_uint tags (+056) values (now, +00056)
sql show tags from st_uint_27
if $data05 != 56 then
return -1
endi
sql select * from st_uint_27
if $data01 != 56 then
return -1
endi
sql insert into st_uint_28 using mt_uint tags (056) values (now, 0056)
sql show tags from st_uint_28
if $data05 != 56 then
return -1
endi
sql select * from st_uint_28
if $data01 != 56 then
return -1
endi
sql insert into st_uint_1100 using mt_uint tags ("0x01") values(now, "0x01");
sql show tags from st_uint_1100
if $data05 != 1 then
return -1
endi
sql select * from st_uint_1100
if $data01 != 1 then
return -1
endi
sql insert into st_uint_1101 using mt_uint tags ("0b01") values(now, "0b01");
sql show tags from st_uint_1101
if $data05 != 1 then
return -1
endi
sql select * from st_uint_1101
if $data01 != 1 then
return -1
endi
sql insert into st_uint_1102 using mt_uint tags ("+0x01") values(now, "+0x01");
sql show tags from st_uint_1102
if $data05 != 1 then
return -1
endi
sql select * from st_uint_1102
if $data01 != 1 then
return -1
endi
sql insert into st_uint_1103 using mt_uint tags ("-0b00") values(now, "-0b000");
sql show tags from st_uint_1103
if $data05 != 0 then
return -1
endi
sql select * from st_uint_1103
if $data01 != 0 then
return -1
endi
sql insert into st_uint_1104 using mt_uint tags ("123.1") values(now, "123.1");
sql show tags from st_uint_1104
if $data05 != 123 then
return -1
endi
sql select * from st_uint_1104
if $data01 != 123 then
return -1
endi
sql insert into st_uint_1105 using mt_uint tags ("+123.5") values(now, "+123.5");
sql show tags from st_uint_1105
if $data05 != 124 then
return -1
endi
sql select * from st_uint_1105
if $data01 != 124 then
return -1
endi
sql insert into st_uint_1106 using mt_uint tags ("-1e-1") values(now, "-1e-1");
sql show tags from st_uint_1106
if $data05 != 0 then
return -1
endi
sql select * from st_uint_1106
if $data01 != 0 then
return -1
endi
sql insert into st_uint_1107 using mt_uint tags ("+0.1235e3") values(now, "+0.1235e3");
sql show tags from st_uint_1107
if $data05 != 124 then
return -1
endi
sql insert into st_uint_1108 using mt_uint tags ("-0.11e-30") values(now, "-0.11e-30");
sql show tags from st_uint_1108
if $data05 != 0 then
return -1
endi
sql select * from st_uint_1108
if $data01 != 0 then
return -1
endi
sql insert into st_uint_1109 using mt_uint tags ("-1.1e-307") values(now, "-1.1e-307");
sql show tags from st_uint_1109
if $data05 != 0 then
return -1
endi
sql select * from st_uint_1109
if $data01 != 0 then
return -1
endi
sql insert into st_uint_1110 using mt_uint tags ( -1e-1 ) values(now, -1e-1);
sql show tags from st_uint_1110
if $data05 != 0 then
return -1
endi
sql select * from st_uint_1110
if $data01 != 0 then
return -1
endi
sql insert into st_uint_1111 using mt_uint tags ( +0.1235e3 ) values(now, +0.1235e3);
sql show tags from st_uint_1111
if $data05 != 124 then
return -1
endi
sql select * from st_uint_1111
if $data01 != 124 then
return -1
endi
sql insert into st_uint_1112 using mt_uint tags (-0.11e-30) values(now, -0.11e-30);
sql show tags from st_uint_1112
if $data05 != 0 then
return -1
endi
sql select * from st_uint_1112
if $data01 != 0 then
return -1
endi
sql insert into st_uint_1113 using mt_uint tags (-1.1e-307) values(now, -1.1e-307);
sql show tags from st_uint_1113
if $data05 != 0 then
return -1
endi
sql select * from st_uint_1113
if $data01 != 0 then
return -1
endi
sql insert into st_uint_1200 using mt_uint tags ( 0x01) values(now, 0x01);
sql show tags from st_uint_1200
if $data05 != 1 then
return -1
endi
sql select * from st_uint_1200
if $data01 != 1 then
return -1
endi
sql insert into st_uint_1201 using mt_uint tags (0b01 ) values(now, 0b01);
sql show tags from st_uint_1201
if $data05 != 1 then
return -1
endi
sql select * from st_uint_1201
if $data01 != 1 then
return -1
endi
sql insert into st_uint_1202 using mt_uint tags (+0x01) values(now, +0x01);
sql show tags from st_uint_1202
if $data05 != 1 then
return -1
endi
sql select * from st_uint_1202
if $data01 != 1 then
return -1
endi
sql insert into st_uint_1203 using mt_uint tags ( 0b000000 ) values(now, -0b0000);
sql show tags from st_uint_1203
if $data05 != 0 then
return -1
endi
sql select * from st_uint_1203
if $data01 != 0 then
return -1
endi
### case 03: alter tag values
sql alter table st_uint_0 set tag tagname=2147483647
sql show tags from st_uint_0
if $data05 != 2147483647 then
return -1
endi
sql alter table st_uint_0 set tag tagname=-0
sql show tags from st_uint_0
if $data05 != 0 then
return -1
endi
sql alter table st_uint_0 set tag tagname=+100
sql show tags from st_uint_0
if $data05 != 100 then
return -1
endi
sql alter table st_uint_0 set tag tagname=+33.333
sql show tags from st_uint_0
if $data05 != 33 then
return -1
endi
sql alter table st_uint_0 set tag tagname='+98'
sql show tags from st_uint_0
if $data05 != 98 then
return -1
endi
sql alter table st_uint_0 set tag tagname='076'
sql show tags from st_uint_0
if $data05 != 76 then
return -1
endi
sql alter table st_uint_0 set tag tagname=+0012
sql show tags from st_uint_0
if $data05 != 12 then
return -1
endi
sql alter table st_uint_0 set tag tagname=00063
sql show tags from st_uint_0
if $data05 != 63 then
return -1
endi
sql alter table st_uint_100 set tag tagname="0x01"
sql show tags from st_uint_100
if $data05 != 1 then
return -1
endi
sql alter table st_uint_101 set tag tagname="0b01"
sql show tags from st_uint_101
if $data05 != 1 then
return -1
endi
sql alter table st_uint_102 set tag tagname="+0x01"
sql show tags from st_uint_102
if $data05 != 1 then
return -1
endi
sql alter table st_uint_103 set tag tagname="-0b00"
sql show tags from st_uint_103
if $data05 != 0 then
return -1
endi
sql alter table st_uint_104 set tag tagname="123.1"
sql show tags from st_uint_104
if $data05 != 123 then
return -1
endi
sql alter table st_uint_105 set tag tagname="+123.5"
sql show tags from st_uint_105
if $data05 != 124 then
return -1
endi
sql alter table st_uint_106 set tag tagname="-1e-1"
sql show tags from st_uint_106
if $data05 != 0 then
return -1
endi
sql alter table st_uint_107 set tag tagname="+0.1235e3"
sql show tags from st_uint_107
if $data05 != 124 then
print $data05 != 124
return -1
endi
sql alter table st_uint_108 set tag tagname="-0.11e-30"
sql show tags from st_uint_108
if $data05 != 0 then
print $data05 != 0
return -1
endi
sql alter table st_uint_109 set tag tagname="-1.1e-307"
sql show tags from st_uint_109
if $data05 != 0 then
print $data05 != 0
return -1
endi
sql alter table st_uint_110 set tag tagname= -1e-1
sql show tags from st_uint_110
if $data05 != 0 then
return -1
endi
sql alter table st_uint_111 set tag tagname= +0.1235e3
sql show tags from st_uint_111
if $data05 != 124 then
print $data05 != 124
return -1
endi
sql alter table st_uint_112 set tag tagname=-0.11e-30
sql show tags from st_uint_112
if $data05 != 0 then
print $data05 != 0
return -1
endi
sql alter table st_uint_113 set tag tagname=-1.1e-307
sql show tags from st_uint_113
if $data05 != 0 then
print $data05 != 0
return -1
endi
sql alter table st_uint_200 set tag tagname= 0x01
sql show tags from st_uint_200
if $data05 != 1 then
return -1
endi
sql alter table st_uint_201 set tag tagname=0b00
sql show tags from st_uint_201
if $data05 != 0 then
return -1
endi
sql alter table st_uint_202 set tag tagname=+0x01
sql show tags from st_uint_202
if $data05 != 1 then
return -1
endi
sql alter table st_uint_203 set tag tagname= -0b0
sql show tags from st_uint_203
if $data05 != 0 then
return -1
endi
## case 04: illegal input
sql_error create table st_uint_e0_err0 using mt_uint tags (4294967296)
sql_error create table st_uint_e0_err1 using mt_uint tags (-4294967297)
sql_error create table st_uint_e0_err2 using mt_uint tags (-214748364800)
sql_error create table st_uint_e0_err3 using mt_uint tags (123abc)
sql_error create table st_uint_e0_err4 using mt_uint tags ("123abc")
sql_error create table st_uint_e0_err5 using mt_uint tags (abc)
sql_error create table st_uint_e0_err6 using mt_uint tags ("abc")
sql_error create table st_uint_e0_err7 using mt_uint tags (" ")
sql_error create table st_uint_e0_err8 using mt_uint tags ('')
sql create table st_uint_e0 using mt_uint tags (123)
sql create table st_uint_e1 using mt_uint tags (123)
sql create table st_uint_e2 using mt_uint tags (123)
sql create table st_uint_e3 using mt_uint tags (123)
sql create table st_uint_e4 using mt_uint tags (123)
sql create table st_uint_e5 using mt_uint tags (123)
sql create table st_uint_e6 using mt_uint tags (123)
sql create table st_uint_e7 using mt_uint tags (123)
sql create table st_uint_e8 using mt_uint tags (123)
sql create table st_uint_e9 using mt_uint tags (123)
sql create table st_uint_e10 using mt_uint tags (123)
sql create table st_uint_e11 using mt_uint tags (123)
sql create table st_uint_e12 using mt_uint tags (123)
sql_error insert into st_uint_e0 values (now, 4294967296)
sql_error insert into st_uint_e1 values (now, -4294967297)
sql_error insert into st_uint_e3 values (now, -21474836481)
sql_error insert into st_uint_e6 values (now, 123abc)
sql_error insert into st_uint_e7 values (now, "123abc")
sql_error insert into st_uint_e9 values (now, abc)
sql_error insert into st_uint_e10 values (now, "abc")
sql_error insert into st_uint_e11 values (now, " ")
sql_error insert into st_uint_e12 values (now, '')
sql_error insert into st_uint_e13 using mt_uint tags (033) values (now, 4294967296)
sql_error insert into st_uint_e14 using mt_uint tags (033) values (now, -4294967297)
sql_error insert into st_uint_e16 using mt_uint tags (033) values (now, -21474836481)
sql_error insert into st_uint_e19 using mt_uint tags (033) values (now, 123abc)
sql_error insert into st_uint_e20 using mt_uint tags (033) values (now, "123abc")
sql_error insert into st_uint_e22 using mt_uint tags (033) values (now, abc)
sql_error insert into st_uint_e23 using mt_uint tags (033) values (now, "abc")
sql_error insert into st_uint_e24 using mt_uint tags (033) values (now, " ")
sql_error insert into st_uint_e25 using mt_uint tags (033) values (now, '')
sql_error insert into st_uint_e13 using mt_uint tags (21474294967296483648) values (now, -033)
sql_error insert into st_uint_e14_1 using mt_uint tags (-2147483648) values (now, -033)
sql_error insert into st_uint_e16 using mt_uint tags (-2147483649) values (now, -033)
sql_error insert into st_uint_e19 using mt_uint tags (123abc) values (now, -033)
sql_error insert into st_uint_e20 using mt_uint tags ("123abc") values (now, -033)
sql_error insert into st_uint_e22 using mt_uint tags (abc) values (now, -033)
sql_error insert into st_uint_e23 using mt_uint tags ("abc") values (now, -033)
sql_error insert into st_uint_e24 using mt_uint tags (" ") values (now, -033)
sql_error insert into st_uint_e25_1 using mt_uint tags ('') values (now, -033)
sql insert into st_uint_e26_1 using mt_uint tags ('123') values (now, 033)
sql insert into st_uint_e27_1 using mt_uint tags ('12.80') values (now, 033)
sql_error insert into st_uint_e28_1 using mt_uint tags ('-11.80') values (now, 033)
sql insert into st_uint_e13 using mt_uint tags (033) values (now, 00062)
sql insert into st_uint_e14 using mt_uint tags (033) values (now, 00062)
sql insert into st_uint_e15 using mt_uint tags (033) values (now, 00062)
sql insert into st_uint_e16 using mt_uint tags (033) values (now, 00062)
sql insert into st_uint_e17 using mt_uint tags (033) values (now, 00062)
sql insert into st_uint_e18 using mt_uint tags (033) values (now, 00062)
sql insert into st_uint_e19 using mt_uint tags (033) values (now, 00062)
sql insert into st_uint_e20 using mt_uint tags (033) values (now, 00062)
sql insert into st_uint_e21 using mt_uint tags (033) values (now, 00062)
sql insert into st_uint_e22 using mt_uint tags (033) values (now, 00062)
sql insert into st_uint_e23 using mt_uint tags (033) values (now, 00062)
sql insert into st_uint_e24 using mt_uint tags (033) values (now, 00062)
sql insert into st_uint_e25 using mt_uint tags (033) values (now, 00062)
sql_error alter table st_uint_e13 set tag tagname=4294967296
sql_error alter table st_uint_e14 set tag tagname=-4294967297
sql_error alter table st_uint_e16 set tag tagname=-3147483648
sql_error alter table st_uint_e19 set tag tagname=123abc
sql_error alter table st_uint_e20 set tag tagname="123abc"
sql_error alter table st_uint_e22 set tag tagname=abc
sql_error alter table st_uint_e23 set tag tagname="abc"
sql_error alter table st_uint_e24 set tag tagname=" "
sql_error alter table st_uint_e25 set tag tagname=''
sql alter table st_uint_e26_1 set tag tagname='123'
sql alter table st_uint_e27_1 set tag tagname='12.80'
sql_error alter table st_uint_e28_1 set tag tagname='-11.80'
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -0,0 +1,323 @@
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value
######## case 0: varbinary
print ========== varbinary
sql create table mt_varbinary (ts timestamp, c varbinary(50)) tags(tagname varbinary(50))
## case 00: static create table for test tag values
sql create table st_varbinary_0 using mt_varbinary tags(NULL)
sql show tags from st_varbinary_0
if $data05 != NULL then
return -1
endi
sql create table st_varbinary_1 using mt_varbinary tags(NULL)
sql show tags from st_varbinary_1
if $data05 != NULL then
return -1
endi
sql create table st_varbinary_2 using mt_varbinary tags('NULL')
sql show tags from st_varbinary_2
if $data05 != \x4E554C4C then
return -1
endi
sql create table st_varbinary_3 using mt_varbinary tags('NULL')
sql show tags from st_varbinary_3
if $data05 != \x4E554C4C then
return -1
endi
sql create table st_varbinary_4 using mt_varbinary tags("NULL")
sql show tags from st_varbinary_4
if $data05 != \x4E554C4C then
return -1
endi
sql create table st_varbinary_5 using mt_varbinary tags("NULL")
sql show tags from st_varbinary_5
if $data05 != \x4E554C4C then
return -1
endi
sql create table st_varbinary_6 using mt_varbinary tags("")
sql show tags from st_varbinary_6
if $data05 != \x then
return -1
endi
sql create table st_varbinary_7 using mt_varbinary tags(" ")
sql show tags from st_varbinary_7
if $data05 != \x20 then
return -1
endi
sql create table st_varbinary_8 using mt_varbinary tags("\x")
sql show tags from st_varbinary_8
if $data05 != \x then
return -1
endi
sql create table st_varbinary_9 using mt_varbinary tags("\xaB")
sql show tags from st_varbinary_9
if $data05 != \xAB then
return -1
endi
sql create table st_varbinary_10 using mt_varbinary tags("aB")
sql show tags from st_varbinary_10
if $data05 != \x6142 then
return -1
endi
## case 01: insert values for test column values
sql insert into st_varbinary_0 values(now, NULL)
sql select * from st_varbinary_0
if $data01 != NULL then
return -1
endi
sql insert into st_varbinary_1 values(now, NULL)
sql select * from st_varbinary_1
if $data01 != NULL then
return -1
endi
sql insert into st_varbinary_2 values(now, 'NULL')
sql select * from st_varbinary_2
if $data01 != \x4E554C4C then
# return -1
endi
sql insert into st_varbinary_3 values(now, 'NULL')
sql select * from st_varbinary_3
if $data01 != \x4E554C4C then
# return -1
endi
sql insert into st_varbinary_4 values(now, "NULL")
sql select * from st_varbinary_4
if $data01 != \x4E554C4C then
# return -1
endi
sql insert into st_varbinary_5 values(now, "NULL")
sql select * from st_varbinary_5
if $data01 != \x4E554C4C then
# return -1
endi
sql insert into st_varbinary_6 values(now, "")
sql select * from st_varbinary_6
if $data01 != \x then
# return -1
endi
sql insert into st_varbinary_7 values(now, " ")
sql select * from st_varbinary_7
if $data01 != \x20 then
# return -1
endi
sql insert into st_varbinary_8 values(now, "\x")
sql select * from st_varbinary_8
if $data01 != \x then
# return -1
endi
sql insert into st_varbinary_9 values(now, "\xaB")
sql select * from st_varbinary_9
if $data01 != \xAB then
# return -1
endi
sql insert into st_varbinary_10 values(now, "aB")
sql select * from st_varbinary_10
if $data01 != \x6142 then
# return -1
endi
## case 02: dynamic create table for test tag values
sql insert into st_varbinary_100 using mt_varbinary tags(NULL) values(now,NULL)
sql show tags from st_varbinary_100
if $data05 != NULL then
return -1
endi
sql select * from st_varbinary_100
if $data01 != NULL then
# return -1
endi
sql insert into st_varbinary_101 using mt_varbinary tags(NULL) values(now,NULL)
sql show tags from st_varbinary_101
if $data05 != NULL then
return -1
endi
sql select * from st_varbinary_101
if $data01 != NULL then
# return -1
endi
sql insert into st_varbinary_102 using mt_varbinary tags('NULL') values(now,'NULL')
sql show tags from st_varbinary_102
if $data05 != \x4E554C4C then
return -1
endi
sql select * from st_varbinary_102
if $data01 != \x4E554C4C then
# return -1
endi
sql insert into st_varbinary_103 using mt_varbinary tags('NULL') values(now,'NULL')
sql show tags from st_varbinary_103
if $data05 != \x4E554C4C then
return -1
endi
sql select * from st_varbinary_103
if $data01 != \x4E554C4C then
# return -1
endi
sql insert into st_varbinary_104 using mt_varbinary tags("NULL") values(now,"NULL")
sql show tags from st_varbinary_104
if $data05 != \x4E554C4C then
return -1
endi
sql select * from st_varbinary_104
if $data01 != \x4E554C4C then
# return -1
endi
sql insert into st_varbinary_105 using mt_varbinary tags("NULL") values(now,"NULL")
sql show tags from st_varbinary_105
if $data05 != \x4E554C4C then
return -1
endi
sql select * from st_varbinary_105
if $data01 != \x4E554C4C then
# return -1
endi
sql insert into st_varbinary_106 using mt_varbinary tags("") values(now,"")
sql show tags from st_varbinary_106
if $data05 != \x then
return -1
endi
sql select * from st_varbinary_106
if $data01 != \x then
# return -1
endi
sql insert into st_varbinary_107 using mt_varbinary tags(" ") values(now," ")
sql show tags from st_varbinary_107
if $data05 != \x20 then
return -1
endi
sql select * from st_varbinary_107
if $data01 != \x20 then
# return -1
endi
sql insert into st_varbinary_108 using mt_varbinary tags("\x") values(now,"\x")
sql show tags from st_varbinary_108
if $data05 != \x then
return -1
endi
sql select * from st_varbinary_108
if $data01 != \x then
# return -1
endi
sql insert into st_varbinary_109 using mt_varbinary tags("\xaB") values(now,"\xaB")
sql show tags from st_varbinary_109
if $data05 != \xAB then
return -1
endi
sql select * from st_varbinary_109
if $data01 != \xAB then
# return -1
endi
sql insert into st_varbinary_1010 using mt_varbinary tags("aB") values(now,"aB")
sql show tags from st_varbinary_1010
if $data05 != \x6142 then
return -1
endi
sql select * from st_varbinary_1010
if $data01 != \x6142 then
# return -1
endi
## case 03: alter tag values
sql alter table st_varbinary_100 set tag tagname=NULL
sql show tags from st_varbinary_100
if $data05 != NULL then
return -1
endi
sql alter table st_varbinary_101 set tag tagname=NULL
sql show tags from st_varbinary_101
if $data05 != NULL then
return -1
endi
sql alter table st_varbinary_102 set tag tagname='NULL'
sql show tags from st_varbinary_102
if $data05 != \x4E554C4C then
return -1
endi
sql alter table st_varbinary_103 set tag tagname='NULL'
sql show tags from st_varbinary_103
if $data05 != \x4E554C4C then
return -1
endi
sql alter table st_varbinary_104 set tag tagname="NULL"
sql show tags from st_varbinary_104
if $data05 != \x4E554C4C then
return -1
endi
sql alter table st_varbinary_105 set tag tagname="NULL"
sql show tags from st_varbinary_105
if $data05 != \x4E554C4C then
return -1
endi
sql alter table st_varbinary_106 set tag tagname=""
sql show tags from st_varbinary_106
if $data05 != \x then
return -1
endi
sql alter table st_varbinary_107 set tag tagname=" "
sql show tags from st_varbinary_107
if $data05 != \x20 then
return -1
endi
sql alter table st_varbinary_108 set tag tagname="\x"
sql show tags from st_varbinary_108
if $data05 != \x then
return -1
endi
sql alter table st_varbinary_109 set tag tagname="\xaB"
sql show tags from st_varbinary_109
if $data05 != \xAB then
return -1
endi
sql alter table st_varbinary_1010 set tag tagname="aB"
sql show tags from st_varbinary_1010
if $data05 != \x6142 then
return -1
endi
# case 04: illegal input
sql_error create table st_varbinary_106 using mt_varbinary tags(+0123)
sql_error create table st_varbinary_107 using mt_varbinary tags(-01.23)
sql_error create table st_varbinary_108 using mt_varbinary tags(+0x01)
sql_error create table st_varbinary_109 using mt_varbinary tags(-0b01)
sql_error create table st_varbinary_1010 using mt_varbinary tags(-0.1e-10)
sql_error create table st_varbinary_1011 using mt_varbinary tags(+0.1E+2)
sql_error create table st_varbinary_1012 using mt_varbinary tags(tRue)
sql_error create table st_varbinary_1013 using mt_varbinary tags(FalsE)
sql_error create table st_varbinary_1014 using mt_varbinary tags(noW)
sql_error create table st_varbinary_1015 using mt_varbinary tags(toDay)
sql_error insert into st_varbinary_106 using mt_varbinary tags(+0123) values(now, NULL);
sql_error insert into st_varbinary_107 using mt_varbinary tags(-01.23) values(now, NULL);
sql_error insert into st_varbinary_108 using mt_varbinary tags(+0x01) values(now, NULL);
sql_error insert into st_varbinary_109 using mt_varbinary tags(-0b01) values(now, NULL);
sql_error insert into st_varbinary_1010 using mt_varbinary tags(-0.1e-10) values(now, NULL);
sql_error insert into st_varbinary_1011 using mt_varbinary tags(+0.1E+2) values(now, NULL);
sql_error insert into st_varbinary_1012 using mt_varbinary tags(tRue) values(now, NULL);
sql_error insert into st_varbinary_1013 using mt_varbinary tags(FalsE) values(now, NULL);
sql_error insert into st_varbinary_1014 using mt_varbinary tags(noW) values(now, NULL);
sql_error insert into st_varbinary_1015 using mt_varbinary tags(toDay) values(now, NULL);
sql_error insert into st_varbinary_106 using mt_varbinary tags(NULL) values(now(), +0123)
sql_error insert into st_varbinary_107 using mt_varbinary tags(NULL) values(now(), -01.23)
sql_error insert into st_varbinary_108 using mt_varbinary tags(NULL) values(now(), +0x01)
sql_error insert into st_varbinary_109 using mt_varbinary tags(NULL) values(now(), -0b01)
sql_error insert into st_varbinary_1010 using mt_varbinary tags(NULL) values(now(), -0.1e-10)
sql_error insert into st_varbinary_1011 using mt_varbinary tags(NULL) values(now(), +0.1E+2)
sql_error insert into st_varbinary_1012 using mt_varbinary tags(NULL) values(now(), tRue)
sql_error insert into st_varbinary_1013 using mt_varbinary tags(NULL) values(now(), FalsE)
sql_error insert into st_varbinary_1014 using mt_varbinary tags(NULL) values(now(), noW)
sql_error insert into st_varbinary_1015 using mt_varbinary tags(NULL) values(now(), toDay)
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -0,0 +1,415 @@
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value
######## case 0: varchar
print ========== varchar
sql create table mt_varchar (ts timestamp, c varchar(50)) tags (tagname varchar(50))
## case 00: static create table for test tag values
sql create table st_varchar_0 using mt_varchar tags (NULL)
sql show create table st_varchar_0
sql show tags from st_varchar_0
if $data05 != NULL then
return -1
endi
sql create table st_varchar_1 using mt_varchar tags (NULL)
sql show tags from st_varchar_1
if $data05 != NULL then
return -1
endi
sql create table st_varchar_2 using mt_varchar tags ('NULL')
sql show tags from st_varchar_2
if $data05 != NULL then
return -1
endi
sql create table st_varchar_3 using mt_varchar tags ('NULL')
sql show tags from st_varchar_3
if $data05 != NULL then
return -1
endi
sql create table st_varchar_4 using mt_varchar tags ("NULL")
sql show tags from st_varchar_4
if $data05 != NULL then
return -1
endi
sql create table st_varchar_5 using mt_varchar tags ("NULL")
sql show tags from st_varchar_5
if $data05 != NULL then
return -1
endi
sql create table st_varchar_6 using mt_varchar tags (+0123)
sql show tags from st_varchar_6
if $data05 != +0123 then
return -1
endi
sql create table st_varchar_7 using mt_varchar tags (-01.23)
sql show tags from st_varchar_7
if $data05 != -01.23 then
return -1
endi
sql create table st_varchar_8 using mt_varchar tags (+0x01)
sql show tags from st_varchar_8
if $data05 != +0x01 then
return -1
endi
sql create table st_varchar_9 using mt_varchar tags (-0b01)
sql show tags from st_varchar_9
if $data05 != -0b01 then
return -1
endi
sql create table st_varchar_10 using mt_varchar tags (-0.1e-10)
sql show tags from st_varchar_10
if $data05 != -0.1e-10 then
return -1
endi
sql create table st_varchar_11 using mt_varchar tags (+0.1E+2)
sql show tags from st_varchar_11
if $data05 != +0.1e+2 then
return -1
endi
sql create table st_varchar_12 using mt_varchar tags (tRue)
sql show tags from st_varchar_12
if $data05 != true then
return -1
endi
sql create table st_varchar_13 using mt_varchar tags (FalsE)
sql show tags from st_varchar_13
if $data05 != false then
return -1
endi
sql create table st_varchar_14 using mt_varchar tags (noW)
sql show tags from st_varchar_14
if $data05 != now then
return -1
endi
sql create table st_varchar_15 using mt_varchar tags (toDay)
sql show tags from st_varchar_15
if $data05 != today then
return -1
endi
## case 01: insert values for test column values
sql insert into st_varchar_0 values(now, NULL)
sql select * from st_varchar_0
if $data01 != NULL then
return -1
endi
sql insert into st_varchar_1 values(now, NULL)
sql select * from st_varchar_1
if $data01 != NULL then
return -1
endi
sql insert into st_varchar_2 values(now, 'NULL')
sql select * from st_varchar_2
if $data01 != NULL then
return -1
endi
sql insert into st_varchar_3 values(now, 'NULL')
sql select * from st_varchar_3
if $data01 != NULL then
return -1
endi
sql insert into st_varchar_4 values(now, "NULL")
sql select * from st_varchar_4
if $data01 != NULL then
return -1
endi
sql insert into st_varchar_5 values(now, "NULL")
sql select * from st_varchar_5
if $data01 != NULL then
return -1
endi
sql insert into st_varchar_6 values(now, +0123)
sql select * from st_varchar_6
if $data01 != +0123 then
return -1
endi
sql insert into st_varchar_7 values(now, -01.23)
sql select * from st_varchar_7
if $data01 != -01.23 then
return -1
endi
sql insert into st_varchar_8 values(now, +0x01)
sql select * from st_varchar_8
if $data01 != +0x01 then
return -1
endi
sql insert into st_varchar_9 values(now, -0b01)
sql select * from st_varchar_9
if $data01 != -0b01 then
return -1
endi
sql insert into st_varchar_10 values(now, -0.1e-10)
sql select * from st_varchar_10
if $data01 != -0.1e-10 then
return -1
endi
sql insert into st_varchar_11 values(now, +0.1E+2)
sql select * from st_varchar_11
if $data01 != +0.1e+2 then
return -1
endi
sql insert into st_varchar_12 values(now, tRue)
sql select * from st_varchar_12
if $data01 != true then
return -1
endi
sql insert into st_varchar_13 values(now, FalsE)
sql select * from st_varchar_13
if $data01 != false then
return -1
endi
sql insert into st_varchar_14 values(now, noW)
sql select * from st_varchar_14
if $data01 != now then
return -1
endi
sql insert into st_varchar_15 values(now, toDay)
sql select * from st_varchar_15
if $data01 != today then
return -1
endi
## case 02: dynamic create table for test tag values
sql insert into st_varchar_0 using mt_varchar tags (NULL) values(now, NULL)
sql show tags from st_varchar_0
if $data05 != NULL then
return -1
endi
sql select * from st_varchar_0
if $data01 != NULL then
return -1
endi
sql insert into st_varchar_1 using mt_varchar tags (NULL) values(now, NULL)
sql show tags from st_varchar_1
if $data05 != NULL then
return -1
endi
sql select * from st_varchar_1
if $data01 != NULL then
return -1
endi
sql insert into st_varchar_2 using mt_varchar tags ('NULL') values(now, 'NULL')
sql show tags from st_varchar_2
if $data05 != NULL then
return -1
endi
sql select * from st_varchar_2
if $data01 != NULL then
return -1
endi
sql insert into st_varchar_3 using mt_varchar tags ('NULL') values(now, 'NULL')
sql show tags from st_varchar_3
if $data05 != NULL then
return -1
endi
sql select * from st_varchar_3
if $data01 != NULL then
return -1
endi
sql insert into st_varchar_4 using mt_varchar tags ("NULL") values(now, "NULL")
sql show tags from st_varchar_4
if $data05 != NULL then
return -1
endi
sql select * from st_varchar_4
if $data01 != NULL then
return -1
endi
sql insert into st_varchar_5 using mt_varchar tags ("NULL") values(now, "NULL")
sql show tags from st_varchar_5
if $data05 != NULL then
return -1
endi
sql select * from st_varchar_5
if $data01 != NULL then
return -1
endi
sql insert into st_varchar_6 using mt_varchar tags (+0123) values(now, +0123)
sql show tags from st_varchar_6
if $data05 != +0123 then
return -1
endi
sql select * from st_varchar_6
if $data01 != +0123 then
return -1
endi
sql insert into st_varchar_7 using mt_varchar tags (-01.23) values(now, -01.23)
sql show tags from st_varchar_7
if $data05 != -01.23 then
return -1
endi
sql select * from st_varchar_7
if $data01 != -01.23 then
return -1
endi
sql insert into st_varchar_8 using mt_varchar tags (+0x01) values(now, +0x01)
sql show tags from st_varchar_8
if $data05 != +0x01 then
return -1
endi
sql select * from st_varchar_8
if $data01 != +0x01 then
return -1
endi
sql insert into st_varchar_9 using mt_varchar tags (-0b01) values(now, -0b01)
sql show tags from st_varchar_9
if $data05 != -0b01 then
return -1
endi
sql select * from st_varchar_9
if $data01 != -0b01 then
return -1
endi
sql insert into st_varchar_10 using mt_varchar tags (-0.1e-10) values(now, -0.1e-10)
sql show tags from st_varchar_10
if $data05 != -0.1e-10 then
return -1
endi
sql select * from st_varchar_10
if $data01 != -0.1e-10 then
return -1
endi
sql insert into st_varchar_11 using mt_varchar tags (+0.1E+2) values(now, +0.1E+2)
sql show tags from st_varchar_11
if $data05 != +0.1e+2 then
return -1
endi
sql select * from st_varchar_11
if $data01 != +0.1e+2 then
return -1
endi
sql insert into st_varchar_12 using mt_varchar tags (tRue) values(now, tRue)
sql show tags from st_varchar_12
if $data05 != true then
return -1
endi
sql select * from st_varchar_12
if $data01 != true then
return -1
endi
sql insert into st_varchar_13 using mt_varchar tags (FalsE) values(now, FalsE)
sql show tags from st_varchar_13
if $data05 != false then
return -1
endi
sql select * from st_varchar_13
if $data01 != false then
return -1
endi
sql insert into st_varchar_14 using mt_varchar tags (noW) values(now, noW)
sql show tags from st_varchar_14
if $data05 != now then
return -1
endi
sql select * from st_varchar_14
if $data01 != now then
return -1
endi
sql insert into st_varchar_15 using mt_varchar tags (toDay) values(now, toDay)
sql show tags from st_varchar_15
if $data05 != today then
return -1
endi
sql select * from st_varchar_15
if $data01 != today then
return -1
endi
## case 03: alter tag values
sql alter table st_varchar_0 set tag tagname=NULL
sql show tags from st_varchar_0
if $data05 != NULL then
return -1
endi
sql alter table st_varchar_1 set tag tagname=NULL
sql show tags from st_varchar_1
if $data05 != NULL then
return -1
endi
sql alter table st_varchar_2 set tag tagname='NULL'
sql show tags from st_varchar_2
if $data05 != NULL then
return -1
endi
sql alter table st_varchar_3 set tag tagname='NULL'
sql show tags from st_varchar_3
if $data05 != NULL then
return -1
endi
sql alter table st_varchar_4 set tag tagname="NULL"
sql show tags from st_varchar_4
if $data05 != NULL then
return -1
endi
sql alter table st_varchar_5 set tag tagname="NULL"
sql show tags from st_varchar_5
if $data05 != NULL then
return -1
endi
sql alter table st_varchar_6 set tag tagname=+0123
sql show tags from st_varchar_6
if $data05 != +0123 then
return -1
endi
sql alter table st_varchar_7 set tag tagname=-01.23
sql show tags from st_varchar_7
if $data05 != -01.23 then
return -1
endi
sql alter table st_varchar_8 set tag tagname=+0x01
sql show tags from st_varchar_8
if $data05 != +0x01 then
return -1
endi
sql alter table st_varchar_9 set tag tagname=-0b01
sql show tags from st_varchar_9
if $data05 != -0b01 then
return -1
endi
sql alter table st_varchar_10 set tag tagname=-0.1e-10
sql show tags from st_varchar_10
if $data05 != -0.1e-10 then
return -1
endi
sql alter table st_varchar_11 set tag tagname=+0.1E+2
sql show tags from st_varchar_11
if $data05 != +0.1e+2 then
return -1
endi
sql alter table st_varchar_12 set tag tagname=tRue
sql show tags from st_varchar_12
if $data05 != true then
return -1
endi
sql alter table st_varchar_13 set tag tagname=FalsE
sql show tags from st_varchar_13
if $data05 != false then
return -1
endi
sql alter table st_varchar_14 set tag tagname=noW
sql show tags from st_varchar_14
if $data05 != now then
return -1
endi
sql alter table st_varchar_15 set tag tagname=toDay
sql show tags from st_varchar_15
if $data05 != today then
return -1
endi
# case 04: illegal input
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -187,7 +187,7 @@ sql_error create table $tb using $mt tags (abc)
sql_error create table $tb using $mt tags ('abc')
sql drop table if exists $tb
sql reset query cache
sql_error create table $tb using $mt tags (1e1)
sql create table $tb using $mt tags (1e1)
sql_error create table $tb using $mt tags ('1e1')
sql_error create table $tb using $mt tags (2147483649)

View File

@ -140,7 +140,7 @@ endi
### bool:
sql create table stx using mt2 tags ('NULL', '123aBc', 104, '123')
sql create table sty using mt2 tags ('NULL', '123aBc', 104, 'xtz')
sql_error create table sty using mt2 tags ('NULL', '123aBc', 104, 'xtz')
sql create table st4 using mt2 tags ('NULL', '123aBc', 104, 'NULL')
sql insert into st4 (ts, col1) values(now, 1)
sql select tag1,tag2,tag3,tag5 from st4
@ -156,7 +156,7 @@ endi
if $data02 != 104 then
return -1
endi
if $data03 != 0 then
if $data03 != NULL then
print ==6== expect: NULL, actually: $data03
return -1
endi
@ -182,7 +182,7 @@ endi
#### case 2: dynamic create table using super table when insert into
sql create table mt3 (ts timestamp, col1 int, col3 float, col5 binary(8), col6 bool, col9 nchar(8)) tags (tag1 binary(8), tag2 nchar(8), tag3 int, tag5 bool)
sql_error insert into st31 using mt3 tags (NULL, 'NULL', 102, 'true') values (now+1s, 31, 31, 'bin_31', '123', 'nchar_31')
sql insert into st31 using mt3 tags (NULL, 'NULL', 102, 'true') values (now+1s, 31, 31, 'bin_31', '123', 'nchar_31')
sql_error insert into st32 using mt3 tags (NULL, 'ABC', 103, 'FALSE') values (now+2s, 32, 32.12345, 'bin_32', 'abc', 'nchar_32')
sql_error insert into st33 using mt3 tags ('NULL', '123aBc', 104, 'NULL') values (now+3s, 33, 33, 'bin_33', 'false123', 'nchar_33')
sql_error insert into st34 using mt3 tags ('NULL', '123aBc', 105, NULL) values (now+4s, 34, 34.12345, 'bin_34', 'true123', 'nchar_34')
@ -306,8 +306,8 @@ if $data02 != NULL then
print ==10== expect: NULL, actually: $data02
return -1
endi
sql_error alter table st41 set tag tag_int = 'NULL'
sql alter table st41 set tag tag_int = ''
sql alter table st41 set tag tag_int = 'NULL'
sql_error alter table st41 set tag tag_int = ''
sql_error alter table st41 set tag tag_int = abc379
################### bool
@ -333,8 +333,8 @@ if $data03 != 1 then
endi
sql alter table st41 set tag tag_bool = 'NULL'
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
if $data03 != 0 then
print ==14== expect: 0, actually: $data03
if $data03 != NULL then
print ==14== expect: NULL, actually: $data03
return -1
endi
sql alter table st41 set tag tag_bool = NULL
@ -344,7 +344,7 @@ if $data03 != NULL then
endi
sql alter table st41 set tag tag_bool = '123'
sql alter table st41 set tag tag_bool = ''
sql_error alter table st41 set tag tag_bool = ''
sql_error alter table st41 set tag tag_bool = abc379
################### float
@ -380,8 +380,8 @@ if $data04 != NULL then
endi
sql alter table st41 set tag tag_float = 'NULL'
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
if $data04 != 0.00000 then
print ==17== expect: 0.00000, actually : $data04
if $data04 != NULL then
print ==17== expect: NULL, actually : $data04
return -1
endi
sql alter table st41 set tag tag_float = '54.123456'
@ -396,10 +396,10 @@ if $data04 != -54.12346 then
print ==19== expect: -54.12346, actually : $data04
return -1
endi
sql alter table st41 set tag tag_float = ''
sql_error alter table st41 set tag tag_float = ''
sql alter table st41 set tag tag_float = 'abc'
sql alter table st41 set tag tag_float = '123abc'
sql_error alter table st41 set tag tag_float = 'abc'
sql_error alter table st41 set tag tag_float = '123abc'
sql_error alter table st41 set tag tag_float = abc
################### double
@ -428,14 +428,15 @@ if $data05 != NULL then
endi
sql alter table st41 set tag tag_double = 'NULL'
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
if $data05 != 0.000000000 then
print ==20== expect: 0.000000000, actually : $data05
if $data05 != NULL then
print ==20== expect: NULL, actually : $data05
return -1
endi
sql alter table st41 set tag tag_double = ''
sql alter table st41 set tag tag_double = 'abc'
sql alter table st41 set tag tag_double = '123abc'
sql_error alter table st41 set tag tag_double = ''
sql alter table st41 set tag tag_double = '123'
sql_error alter table st41 set tag tag_double = 'abc'
sql_error alter table st41 set tag tag_double = '123abc'
sql_error alter table st41 set tag tag_double = abc
################### bigint smallint tinyint
@ -459,8 +460,8 @@ if $data00 != -9223372036854775807 then
endi
sql alter table st51 set tag tag_bigint = -9223372036854775808
sql_error alter table st51 set tag tag_bigint = 'NULL'
sql alter table st51 set tag tag_bigint = ''
sql alter table st51 set tag tag_bigint = 'NULL'
sql_error alter table st51 set tag tag_bigint = ''
sql_error alter table st51 set tag tag_bigint = abc379
####
@ -480,8 +481,8 @@ if $data01 != -32767 then
endi
sql alter table st51 set tag tag_smallint = -32768
sql_error alter table st51 set tag tag_smallint = 'NULL'
sql alter table st51 set tag tag_smallint = ''
sql alter table st51 set tag tag_smallint = 'NULL'
sql_error alter table st51 set tag tag_smallint = ''
sql_error alter table st51 set tag tag_smallint = abc379
####
@ -499,8 +500,8 @@ if $data02 != -127 then
endi
sql alter table st51 set tag tag_tinyint = '-128'
sql_error alter table st51 set tag tag_tinyint = 128
sql_error alter table st51 set tag tag_tinyint = 'NULL'
sql alter table st51 set tag tag_tinyint = ''
sql alter table st51 set tag tag_tinyint = 'NULL'
sql_error alter table st51 set tag tag_tinyint = ''
sql_error alter table st51 set tag tag_tinyint = abc379
# test end

View File

@ -409,7 +409,7 @@ endi
if $data03 != 5 then
return -1
endi
if $data04 != 0 then
if $data04 != 1 then
return -1
endi

View File

@ -113,6 +113,13 @@
./test.sh -f tsim/parser/columnValue_smallint.sim
./test.sh -f tsim/parser/columnValue_tinyint.sim
./test.sh -f tsim/parser/columnValue_unsign.sim
./test.sh -f tsim/parser/columnValue_uint.sim
./test.sh -f tsim/parser/columnValue_timestamp.sim
./test.sh -f tsim/parser/columnValue_varchar.sim
./test.sh -f tsim/parser/columnValue_nchar.sim
./test.sh -f tsim/parser/columnValue_varbinary.sim
./test.sh -f tsim/parser/columnValue_json.sim
./test.sh -f tsim/parser/columnValue_geometry.sim
./test.sh -f tsim/parser/condition.sim
./test.sh -f tsim/parser/condition_scl.sim
./test.sh -f tsim/parser/constCol.sim

View File

@ -0,0 +1,353 @@
import datetime
from enum import Enum
from util.log import *
from util.sql import *
from util.cases import *
from util.common import *
from util.dnodes import *
from util.sqlset import *
DBNAME = "db"
class TDDataType(Enum):
NULL = 0
BOOL = 1
TINYINT = 2
SMALLINT = 3
INT = 4
BIGINT = 5
FLOAT = 6
DOUBLE = 7
VARCHAR = 8
TIMESTAMP = 9
NCHAR = 10
UTINYINT = 11
USMALLINT = 12
UINT = 13
UBIGINT = 14
JSON = 15
VARBINARY = 16
DECIMAL = 17
BLOB = 18
MEDIUMBLOB = 19
BINARY = 8
GEOMETRY = 20
MAX = 21
class TDTestCase:
def init(self, conn, logSql, replicaVar=1):
self.replicaVar = int(replicaVar)
tdLog.debug(f"start to excute {__file__}")
self.TIMESTAMP_MIN = -1000
self.TIMESTAMP_BASE = 1706716800
tdSql.init(conn.cursor())
tdSql.execute(f'drop database if exists db')
tdSql.execute(f'create database if not exists db vgroups 1')
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));",
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_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_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_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);" ]
for _stb in CREATE_STB_LIST:
tdSql.execute(_stb)
tdSql.query(f'show {dbname}.stables')
tdSql.checkRows(len(CREATE_STB_LIST))
def _query_check_varchar(self, result, okv, nv, row = 0, col = 0):
for i in range(row):
for j in range(1, col):
check_result = False
check_item = result[i][j]
if result[i][j] == None:
check_item = 'null'
if check_item == okv or check_item == nv:
check_result = True
if check_result == False and (okv[0:1] == '\'' or okv[0:1] == '\"'):
if check_item == okv[1:-1]:
check_result = True
if check_result == False and (nv[0:1] == '\'' or nv[0:1] == '\"'):
if check_item == nv[1:-1]:
check_result = True
if check_result == False:
if check_item == nv.strip().lower():
check_result = True
tdSql.checkEqual(check_result, True)
def _query_check_int(self, result, okv, nv, row = 0, col = 0):
for i in range(row):
for j in range(1, col):
check_result = False
check_item = result[i][j]
if result[i][j] == None:
check_item = 'null'
if check_item == okv or check_item == nv:
check_result = True
if check_item == nv.strip().lower():
check_result = True
if check_result == False and (okv.find('1') != -1 or okv.find('2') != -1):
if check_item != 0:
check_result = True
if check_result == False and (nv.find('1') != -1 or nv.find('2') != -1):
if check_item != 0:
check_result = True
if check_item == 0:
check_result = True
tdSql.checkEqual(check_result, True)
def _query_check_bool(self, result, okv, nv, row = 0, col = 0):
for i in range(row):
for j in range(1, col):
check_result = False
check_item = result[i][j]
if result[i][j] == None:
check_item = 'null'
elif result[i][j] == True:
check_item = "true"
else:
check_item = "false"
if check_item == okv.strip().lower() or check_item == nv.strip().lower():
check_result = True
if check_result == False and (nv[0:1] == '\'' or nv[0:1] == '\"'):
if check_item == nv[1:-1].strip().lower():
check_result = True
if check_result == False and (nv.find('1') != -1 or nv.find('2') != -1): # char 1 or 2 exist for non-zero values
if check_item == "true":
check_result = True
else:
if check_item == "false":
check_result = True
tdSql.checkEqual(check_result, True)
def _query_check_timestamp(self, result, okv, nv, row = 0, col = 0):
for i in range(row):
for j in range(1, col):
check_result = False
check_item = result[i][j]
if result[i][j] == None:
check_item = 'null'
if nv.lower().find(check_item) != -1:
check_result = True
else:
check_item = int(result[i][j].timestamp())
if check_result == False and nv.lower().find("now") != -1 or nv.lower().find("today") != -1 or nv.lower().find("now") != -1 or nv.lower().find("today") != -1:
if check_item > self.TIMESTAMP_BASE:
check_result = True
if check_result == False and check_item > self.TIMESTAMP_MIN:
check_result = True
tdSql.checkEqual(check_result, True)
def _query_check(self, dbname="db", stbname="", ctbname="", 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}')
tdSql.checkRows(nRows)
result = tdSql.queryResult
if dtype == TDDataType.VARCHAR or dtype == TDDataType.NCHAR:
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_int(result, okv, nv, nRows, 4)
elif dtype == TDDataType.UINT:
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)
elif dtype == TDDataType.GEOMETRY:
pass
else:
tdLog.info(f"unknown data type %s" % (dtype))
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))
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))
tdSql.execute(f'drop table {dbname}.{ctbname}')
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)
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))
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.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}')
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.checkRows(1)
tdSql.execute(f'drop table {dbname}.{ctbname}')
def __insert_query_exec(self):
STR_EMPTY = ['\'\'', "\"\"", '\' \'', "\" \""]
STR_INTEGER_P = ["\"42\"", '\'+42\'', '\'+0\'', '\'-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\""]
STR_FLOAT_E_P = ['\'1e1\'', "\"3e-2\"", "\"-3e-5\""]
STR_FLOAT_E_M = ["\"-0.3E+1\""]
STR_MISC = ["\"123ab\"", '\'123d\'', '\'-12s\'', '\'\x012\'', '\'x12\'', '\'x\'', '\'NULL \'', '\' NULL\'', '\'True \'', '\' False\'',
'\'0B0101 \'', '\' 0B0101\'', '\' -0x01 \'', '\'-0x02 \'']
STR_OPTR = ['\'1*10\'', '\'1+2\'', '\'-2-0\'','\'1%2\'', '\'2/0\'', '\'1&31\'']
STR_TSK = ['\'now\'', '\'today\'']
STR_TSK_MISC = ['\'now+1s\'', '\' now\'', '\'today \'', '\'today+1m\'', '\'today-1w\'']
STR_TSKP = ['\'now()\'', '\'today()\'']
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_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_NULL = ['\'NuLl\'', '\'null\'', '\'NULL\'']
RAW_INTEGER_P = [' 42 ', '+042 ', ' +0', '0 ', '-0', '0', ' 0X2A', ' -0x0 ', '+0x0 ', ' 0B00101010', ' -0b00']
RAW_INTEGER_M = [' -42 ', ' -0128',' -0x1', ' -0X2A', '-0b01 ', ' -0B00101010 ']
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_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']
RAW_TSK = [' now ', 'today ']
RAW_TSK_OPTR = [' now +1s', 'today + 2d']
RAW_TSKP = ['now( ) ', ' toDay() ']
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 ']
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]
OK_NC = OK_VC
KO_NC = 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]
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]
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]
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]
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]
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]
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]
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]
]
# 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])
# 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()
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())

View File

@ -22,7 +22,7 @@ class TDTestCase:
for i in range(tb_nums):
tbname = f"{dbname}.sub_{stb_name}_{i}"
ts = self.ts + i*10000
tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )")
tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , %d , %f , %f , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )"%(i*10,i*1.0,i*1.0))
for row in range(row_nums):
ts = self.ts + row*1000

View File

@ -24,7 +24,7 @@ class TDTestCase:
for i in range(self.tb_nums):
tbname = f"{self.dbname}.sub_{self.stable}_{i}"
ts = self.ts + i*10000
tdSql.execute(f"create table {tbname} using {self.dbname}.{self.stable} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )")
tdSql.execute(f"create table {tbname} using {self.dbname}.{self.stable} tags ({ts} , {i} , %d ,%d , %f , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )"%(i*10,i*1.0,i*1.0))
def insert_db(self, tb_nums, row_nums):
for i in range(tb_nums):

View File

@ -21,7 +21,7 @@ class TDTestCase:
for i in range(tb_nums):
tbname = f"{dbname}.sub_{stb_name}_{i}"
ts = self.ts + i*1000*120
tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )")
tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , %d , %f , %f , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )"%(i*10,i*1.0,i*1.0))
for row in range(row_nums):
ts = ts + row*1000

View File

@ -1,3 +1,4 @@
import datetime
from util.log import *
from util.sql import *
from util.cases import *
@ -52,6 +53,202 @@ class TDTestCase:
)
tdSql.checkRows(0)
def __ts4421(self, dbname="db", stbname='stb4421', ctbname='ctb4421'):
TAG_BIND = [True, False]
TAG_TYPE = ['varchar', 'nchar']
TAG_LEN = [2, 8, 200]
TAG_VAL_INT = [0, -200, 123456789]
TAG_VAL_STR = ["noW()", "now", "'now'", "todAy()", "today", "\"today\"" ]
TAG_VAL_BOOL_INT = [ -1, 1, 0, -0]
TAG_VAL_BOOL_STR = ["TrUe", "\"true\"","fALse", "'FALSE'"]
TAG_VAL_TIMESTAMP = ["now()", "NoW", "'now'", "\"now()\"", "toDay()", "toDaY", "'today'", "\"today()\"", "\"2200-01-01 08:00:00\"", "'2200-01-02'","\"2200-01-02T00:00:00.000Z\"", "'2200-01-02T00:00:00.000'", "2200-01-01 08:00:00", "\"2200-01-02'", "2200-01-02T00:00:00.000Z"]
TAG_RESULT_INT = [True,False,False,True,True,False,True,True,True,True,False,False,True,True,False,True,True,True]
TAG_RESULT_STR = [False,False,False,False,False,False,False,True,True,False,True,True,False,True,True,False,True,True,False,False,False,False,False,False,False,True,True,False,True,True,False,True,True,False,True,True]
TAG_RESULT_BOOL = ["True","True","False","False"]
TAG_RESULT_TIMESTAMP = [True, True, True, True, True, True, True, True, True, True, True, True, False, False, False]
# check int for vartype(one tag)
nTagCtb = 0
for tagType in TAG_TYPE:
for tagLen in TAG_LEN:
tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 %s(%d))'%(tagType,tagLen))
for tagVal in TAG_VAL_INT:
for tagBind in TAG_BIND:
if tagBind == True:
bindStr = "(t1)"
else:
bindStr = ""
tdLog.info(f'nTagCtb={nTagCtb}, tagType={tagType}, tagLen = {tagLen}, tagVal = {tagVal}, tagBind={tagBind}')
if TAG_RESULT_INT[nTagCtb] == False:
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d)'%(bindStr,tagVal))
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d) values(now,1)'%(bindStr,tagVal))
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d")'%(bindStr,tagVal))
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d") values(now,1)'%(bindStr,tagVal))
tdSql.error(f"create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d')"%(bindStr,tagVal))
tdSql.error(f"insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d') values(now,1)"%(bindStr,tagVal))
else:
# integer as tag value
tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d)'%(bindStr,tagVal))
tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)')
tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%d) values(now,1)'%(bindStr,tagVal))
tdSql.query(f'select * from {dbname}.{stbname} where t1="%d"'%(tagVal))
tdSql.checkRows(2)
tdSql.execute(f'drop table {dbname}.{ctbname}')
tdSql.execute(f'drop table {dbname}.{ctbname}t')
# string as tag value
tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d")'%(bindStr,tagVal))
tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)')
tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags("%d") values(now,1)'%(bindStr,tagVal))
tdSql.query(f'select * from {dbname}.{stbname} where t1="%d"'%(tagVal))
tdSql.checkRows(2)
tdSql.execute(f'drop table {dbname}.{ctbname}')
tdSql.execute(f'drop table {dbname}.{ctbname}t')
tdSql.execute(f"create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d')"%(bindStr,tagVal))
tdSql.execute(f"insert into {dbname}.{ctbname} values(now,1)")
tdSql.execute(f"insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags('%d') values(now,1)"%(bindStr,tagVal))
tdSql.query(f"select * from {dbname}.{stbname} where t1='%d'"%(tagVal))
tdSql.checkRows(2)
tdSql.execute(f'drop table {dbname}.{ctbname}')
tdSql.execute(f'drop table {dbname}.{ctbname}t')
nTagCtb += 1
tdSql.execute(f'drop table {dbname}.{stbname}')
# check int for vartype(two tags/bind tags)
nTagCtb = 0
for tagType in TAG_TYPE:
for tagLen in TAG_LEN:
tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 %s(%d),t2 %s(%d) )'%(tagType,tagLen,tagType,tagLen))
for tagVal in TAG_VAL_INT:
for tagBind in TAG_BIND:
if tagBind == True:
bindStr = "(t1,t2)"
else:
bindStr = ""
if TAG_RESULT_INT[nTagCtb] == False:
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d,%d)'%(bindStr,tagVal,tagVal))
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d,%d) values(now,1)'%(bindStr,tagVal,tagVal))
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d","%d")'%(bindStr,tagVal,tagVal))
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d","%d") values(now,1)'%(bindStr,tagVal,tagVal))
tdSql.error(f"create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d','%d')"%(bindStr,tagVal,tagVal))
tdSql.error(f"insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d','%d') values(now,1)"%(bindStr,tagVal,tagVal))
else:
# integer as tag value
tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d,%d)'%(bindStr,tagVal,tagVal))
tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)')
tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%d,%d) values(now,1)'%(bindStr,tagVal,tagVal))
tdSql.query(f"select * from {dbname}.{stbname} where t1='%d' and t2='%d'"%(tagVal,tagVal))
tdSql.checkRows(2)
tdSql.execute(f'drop table {dbname}.{ctbname}')
tdSql.execute(f'drop table {dbname}.{ctbname}t')
# string as tag value
tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d","%d")'%(bindStr,tagVal,tagVal))
tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)')
tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags("%d","%d") values(now,1)'%(bindStr,tagVal,tagVal))
tdSql.query(f'select * from {dbname}.{stbname} where t1="%d" and t2="%d"'%(tagVal,tagVal))
tdSql.checkRows(2)
tdSql.execute(f'drop table {dbname}.{ctbname}')
tdSql.execute(f'drop table {dbname}.{ctbname}t')
tdSql.execute(f"create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d','%d')"%(bindStr,tagVal,tagVal))
tdSql.execute(f"insert into {dbname}.{ctbname} values(now,1)")
tdSql.execute(f"insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags('%d','%d') values(now,1)"%(bindStr,tagVal,tagVal))
tdSql.query(f"select * from {dbname}.{stbname} where t1='%d' and t2='%d'"%(tagVal,tagVal))
tdSql.checkRows(2)
tdSql.execute(f'drop table {dbname}.{ctbname}')
tdSql.execute(f'drop table {dbname}.{ctbname}t')
nTagCtb += 1
tdSql.execute(f'drop table {dbname}.{stbname}')
# check now/today for vartype
nTagCtb = 0
for tagType in TAG_TYPE:
for tagLen in TAG_LEN:
tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 %s(%d))'%(tagType,tagLen))
for tagVal in TAG_VAL_STR:
for tagBind in TAG_BIND:
if tagBind == True:
bindStr = "(t1)"
else:
bindStr = ""
if TAG_RESULT_STR[nTagCtb] == False:
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s)'%(bindStr,tagVal))
tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s) values(now,1)'%(bindStr,tagVal))
else:
tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s)'%(bindStr,tagVal))
tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)')
tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%s) values(now,1)'%(bindStr,tagVal))
if tagVal.startswith("'") or tagVal.startswith("\""):
tdSql.query(f'select * from {dbname}.{stbname} where t1=%s'%(tagVal))
else:
tdSql.query(f'select * from {dbname}.{stbname} where t1=\"%s\"'%(tagVal))
tdSql.checkRows(2)
tdSql.execute(f'drop table {dbname}.{ctbname}')
tdSql.execute(f'drop table {dbname}.{ctbname}t')
nTagCtb += 1
tdSql.execute(f'drop table {dbname}.{stbname}')
# check int for bool
nTagCtb = 0
tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 bool)')
for tagVal in TAG_VAL_BOOL_INT:
for tagBind in TAG_BIND:
if tagBind == True:
bindStr = "(t1)"
else:
bindStr = ""
tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d)'%(bindStr,tagVal))
tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)')
tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%d) values(now,1)'%(bindStr,tagVal))
tdSql.query(f'select * from {dbname}.{stbname} where t1=%s'%(TAG_RESULT_BOOL[nTagCtb]))
tdSql.checkRows(2)
tdSql.execute(f'drop table {dbname}.{ctbname}')
tdSql.execute(f'drop table {dbname}.{ctbname}t')
nTagCtb += 1
tdSql.execute(f'drop table {dbname}.{stbname}')
# check str for bool
nTagCtb = 0
tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 bool)')
for tagVal in TAG_VAL_BOOL_STR:
for tagBind in TAG_BIND:
if tagBind == True:
bindStr = "(t1)"
else:
bindStr = ""
tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s)'%(bindStr,tagVal))
tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)')
tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%s) values(now,1)'%(bindStr,tagVal))
tdSql.query(f'select * from {dbname}.{stbname} where t1=%s'%(TAG_RESULT_BOOL[nTagCtb]))
tdSql.checkRows(2)
tdSql.execute(f'drop table {dbname}.{ctbname}')
tdSql.execute(f'drop table {dbname}.{ctbname}t')
nTagCtb += 1
tdSql.execute(f'drop table {dbname}.{stbname}')
# check misc for timestamp
nTagCtb = 0
tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 timestamp)')
checkTS = datetime.datetime.today() - datetime.timedelta(days=1)
for tagVal in TAG_VAL_TIMESTAMP:
for tagBind in TAG_BIND:
if tagBind == True:
bindStr = "(t1)"
else:
bindStr = ""
if TAG_RESULT_TIMESTAMP[nTagCtb] == False:
tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s)'%(bindStr,tagVal))
tdSql.error(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%s) values(now,1)'%(bindStr,tagVal))
else:
tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s)'%(bindStr,tagVal))
tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)')
tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%s) values(now,1)'%(bindStr,tagVal))
tdSql.query(f'select * from {dbname}.{stbname} where t1>"{checkTS}"')
tdSql.checkRows(2)
tdSql.execute(f'drop table {dbname}.{ctbname}')
tdSql.execute(f'drop table {dbname}.{ctbname}t')
nTagCtb += 1
tdSql.execute(f'drop table {dbname}.{stbname}')
def run(self):
tdLog.printNoPrefix("==========step1:create table")
self.__create_tb()
@ -59,9 +256,12 @@ class TDTestCase:
tdLog.printNoPrefix("==========step2:query data")
self.__query_data(10)
tdLog.printNoPrefix("==========step3:check ts4421")
self.__ts4421()
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())

View File

@ -33,7 +33,7 @@ class TDTestCase:
for i in range(ctbNum):
tagValue = 'beijing'
if (i % 10 == 0):
sql += f" {dbName}.%s%d using %s (name,fleet,driver,device_version,load_capacity,fuel_capacity,nominal_fuel_consumption) tags('truck_%d', 'South%d','Trish%d','v2.%d', 1500+%d*20, 150+%d*2, 5+%d)"%(ctbPrefix,i,stbName,i,i,i,i,(1500+i*20),(150+i*2),(5+i))
sql += f" {dbName}.%s%d using %s (name,fleet,driver,device_version,load_capacity,fuel_capacity,nominal_fuel_consumption) tags('truck_%d', 'South%d','Trish%d','v2.%d', %d, %d, %d)"%(ctbPrefix,i,stbName,i,i,i,i,1500+(1500+i*20)*20,150+(150+i*2)*2,5+(5+i))
else:
model = 'H-%d'%i
sql += f" {dbName}.%s%d using %s tags('truck_%d', 'South%d','Trish%d','%s','v2.%d', %d, %d,%d)"%(ctbPrefix,i,stbName,i,i,i,model,i,(1500+i*20),(150+i*2),(5+i))

View File

@ -16,6 +16,7 @@ sys.path.append("./7-tmq")
from tmqCommon import *
class TDTestCase:
updatecfgDict = {'debugFlag': 135, 'asynclog': 0}
def init(self, conn, logSql, replicaVar=1):
self.replicaVar = int(replicaVar)
tdLog.debug(f"start to excute {__file__}")

View File

@ -0,0 +1,149 @@
import taos
import sys
import time
import socket
import os
import threading
from util.log import *
from util.sql import *
from util.cases import *
from util.dnodes import *
from util.common import *
from taos.tmq import *
from taos import *
sys.path.append("./7-tmq")
from tmqCommon import *
class TDTestCase:
updatecfgDict = {'debugFlag': 143, 'asynclog': 0}
def init(self, conn, logSql, replicaVar=1):
self.replicaVar = int(replicaVar)
tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor())
#tdSql.init(conn.cursor(), logSql) # output sql.txt file
def consumeTest_TS_4563(self):
tdSql.execute(f'use db_stmt')
tdSql.query("select ts,k from st")
tdSql.checkRows(2)
tdSql.execute(f'create topic t_unorder_data as select ts,k from st')
consumer_dict = {
"group.id": "g1",
"td.connect.user": "root",
"td.connect.pass": "taosdata",
"auto.offset.reset": "earliest",
}
consumer = Consumer(consumer_dict)
try:
consumer.subscribe(["t_unorder_data"])
except TmqError:
tdLog.exit(f"subscribe error")
cnt = 0
try:
while True:
res = consumer.poll(1)
print(res)
if not res:
if cnt == 0:
tdLog.exit("consume error")
break
val = res.value()
if val is None:
continue
for block in val:
cnt += len(block.fetchall())
if cnt != 2:
tdLog.exit("consume error")
finally:
consumer.close()
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosd" in files or "taosd.exe" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root)-len("/build/bin")]
break
return buildPath
def newcon(self,host,cfg):
user = "root"
password = "taosdata"
port =6030
con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port)
print(con)
return con
def test_stmt_insert_multi(self,conn):
# type: (TaosConnection) -> None
dbname = "db_stmt"
try:
conn.execute("drop database if exists %s" % dbname)
conn.execute("create database if not exists %s" % dbname)
conn.select_db(dbname)
conn.execute(
"create table st(ts timestamp, i int, j int, k int)",
)
# conn.load_table_info("log")
tdLog.debug("statement start")
start = datetime.now()
stmt = conn.statement("insert into st(ts,j) values(?, ?)")
params = new_multi_binds(2)
params[0].timestamp((1626861392589, 1626861392590))
params[1].int([3, None])
# print(type(stmt))
tdLog.debug("bind_param_batch start")
stmt.bind_param_batch(params)
tdLog.debug("bind_param_batch end")
stmt.execute()
tdLog.debug("execute end")
end = datetime.now()
print("elapsed time: ", end - start)
assert stmt.affected_rows == 2
tdLog.debug("close start")
stmt.close()
# conn.execute("drop database if exists %s" % dbname)
conn.close()
except Exception as err:
# conn.execute("drop database if exists %s" % dbname)
conn.close()
raise err
def run(self):
buildPath = self.getBuildPath()
config = buildPath+ "../sim/dnode1/cfg/"
host="localhost"
connectstmt=self.newcon(host,config)
self.test_stmt_insert_multi(connectstmt)
self.consumeTest_TS_4563()
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())

View File

@ -22,6 +22,7 @@ python3 ./test.py -f 1-insert/update_data_muti_rows.py -P
python3 ./test.py -f 1-insert/db_tb_name_check.py -P
python3 ./test.py -f 1-insert/InsertFuturets.py -P
python3 ./test.py -f 1-insert/insert_wide_column.py -P
python3 ./test.py -f 1-insert/insert_column_value.py
python3 ./test.py -f 2-query/nestedQuery.py -P
python3 ./test.py -f 2-query/nestedQuery_str.py -P
python3 ./test.py -f 2-query/nestedQuery_math.py -P

View File

@ -233,6 +233,7 @@ python3 ./test.py -f 1-insert/update_data_muti_rows.py
python3 ./test.py -f 1-insert/db_tb_name_check.py
python3 ./test.py -f 1-insert/InsertFuturets.py
python3 ./test.py -f 1-insert/insert_wide_column.py
python3 ./test.py -f 1-insert/insert_column_value.py
python3 ./test.py -f 1-insert/rowlength64k_benchmark.py
python3 ./test.py -f 1-insert/rowlength64k.py
python3 ./test.py -f 1-insert/rowlength64k.py -R

View File

@ -1866,6 +1866,9 @@ _return:
// main key press tab
void pressTabKey(SShellCmd* cmd) {
#ifdef WINDOWS
return ;
#endif
// check empty tab key
if (cmd->commandSize == 0) {
// have multi line tab key
@ -1909,6 +1912,10 @@ void pressTabKey(SShellCmd* cmd) {
// press othr key
void pressOtherKey(char c) {
#ifdef WINDOWS
return ;
#endif
// reset global variant
firstMatchIndex = -1;
lastMatchIndex = -1;

View File

@ -445,7 +445,7 @@ char taosGetConsoleChar() {
static char mbStr[5];
static unsigned long bufLen = 0;
static uint16_t bufIndex = 0, mbStrIndex = 0, mbStrLen = 0;
CONSOLE_READCONSOLE_CONTROL inputControl={ sizeof(CONSOLE_READCONSOLE_CONTROL), 0, 1<<TAB_KEY, 0 };
CONSOLE_READCONSOLE_CONTROL inputControl={ sizeof(CONSOLE_READCONSOLE_CONTROL), 0, 0, 0 };
while (bufLen == 0) {
ReadConsoleW(console, buf, SHELL_INPUT_MAX_COMMAND_SIZE, &bufLen, &inputControl);
if (bufLen > 0 && buf[0] == 0) bufLen = 0;
@ -500,13 +500,11 @@ int32_t shellReadCommand(char *command) {
}
shellInsertChar(&cmd, utf8_array, count);
pressOtherKey(c);
#ifndef WINDOWS
} else if (c == TAB_KEY) {
// press TAB key
pressTabKey(&cmd);
#endif
} else if (c < '\033') {
pressOtherKey(c);
pressOtherKey(c);
// Ctrl keys. TODO: Implement ctrl combinations
switch (c) {
case 0:

View File

@ -77,7 +77,7 @@ int shell_conn_ws_server(bool first) {
}
fprintf(stdout, "successfully connected to %s\n", host);
} else {
fprintf(stdout, "successfully connected to cloud service\n");
fprintf(stdout, "successfully connected to service\n");
}
}
fflush(stdout);