Merge branch 'feat/TS-4243-3.0' into enh/TD-28945-pk
This commit is contained in:
commit
0761692b14
|
@ -126,7 +126,7 @@ int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int8_t flag);
|
||||||
int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData, int32_t flag);
|
int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData, int32_t flag);
|
||||||
void tRowGetKey(SRow *pRow, SRowKey *key);
|
void tRowGetKey(SRow *pRow, SRowKey *key);
|
||||||
int32_t tRowKeyCompare(const void *p1, const void *p2);
|
int32_t tRowKeyCompare(const void *p1, const void *p2);
|
||||||
int32_t tRowKeyAssign(SRowKey* pDst, SRowKey* pSrc);
|
int32_t tRowKeyAssign(SRowKey *pDst, SRowKey *pSrc);
|
||||||
|
|
||||||
// SRowIter ================================
|
// SRowIter ================================
|
||||||
int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter);
|
int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter);
|
||||||
|
@ -174,6 +174,7 @@ int32_t tColDataUpdateValue(SColData *pColData, SColVal *pColVal, bool forward);
|
||||||
void tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal);
|
void tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal);
|
||||||
uint8_t tColDataGetBitValue(const SColData *pColData, int32_t iVal);
|
uint8_t tColDataGetBitValue(const SColData *pColData, int32_t iVal);
|
||||||
int32_t tColDataCopy(SColData *pColDataFrom, SColData *pColData, xMallocFn xMalloc, void *arg);
|
int32_t tColDataCopy(SColData *pColDataFrom, SColData *pColData, xMallocFn xMalloc, void *arg);
|
||||||
|
void tColDataArrGetRowKey(SColData *aColData, int32_t nColData, int32_t iRow, SRowKey *key);
|
||||||
|
|
||||||
extern void (*tColDataCalcSMA[])(SColData *pColData, int64_t *sum, int64_t *max, int64_t *min, int16_t *numOfNull);
|
extern void (*tColDataCalcSMA[])(SColData *pColData, int64_t *sum, int64_t *max, int64_t *min, int16_t *numOfNull);
|
||||||
|
|
||||||
|
@ -188,8 +189,8 @@ void tColDataSortMerge(SArray *colDataArr);
|
||||||
int32_t tColDataAddValueByDataBlock(SColData *pColData, int8_t type, int32_t bytes, int32_t nRows, char *lengthOrbitmap,
|
int32_t tColDataAddValueByDataBlock(SColData *pColData, int8_t type, int32_t bytes, int32_t nRows, char *lengthOrbitmap,
|
||||||
char *data);
|
char *data);
|
||||||
// for encode/decode
|
// for encode/decode
|
||||||
int32_t tPutColData(uint8_t *pBuf, SColData *pColData);
|
int32_t tPutColData(uint8_t version, uint8_t *pBuf, SColData *pColData);
|
||||||
int32_t tGetColData(uint8_t *pBuf, SColData *pColData);
|
int32_t tGetColData(uint8_t version, uint8_t *pBuf, SColData *pColData);
|
||||||
|
|
||||||
// STRUCT ================================
|
// STRUCT ================================
|
||||||
struct STColumn {
|
struct STColumn {
|
||||||
|
|
|
@ -4065,6 +4065,7 @@ int32_t tDeserializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq);
|
||||||
#define SUBMIT_REQ_COLUMN_DATA_FORMAT 0x2
|
#define SUBMIT_REQ_COLUMN_DATA_FORMAT 0x2
|
||||||
#define SUBMIT_REQ_FROM_FILE 0x4
|
#define SUBMIT_REQ_FROM_FILE 0x4
|
||||||
#define TD_REQ_FROM_TAOX 0x8
|
#define TD_REQ_FROM_TAOX 0x8
|
||||||
|
#define SUBMIT_REQUEST_VERSION (1)
|
||||||
|
|
||||||
#define TD_REQ_FROM_TAOX_OLD 0x1 // for compatibility
|
#define TD_REQ_FROM_TAOX_OLD 0x1 // for compatibility
|
||||||
|
|
||||||
|
|
|
@ -375,6 +375,7 @@
|
||||||
#define TK_VARIABLE 357
|
#define TK_VARIABLE 357
|
||||||
#define TK_WAL 358
|
#define TK_WAL 358
|
||||||
|
|
||||||
|
|
||||||
#define TK_NK_SPACE 600
|
#define TK_NK_SPACE 600
|
||||||
#define TK_NK_COMMENT 601
|
#define TK_NK_COMMENT 601
|
||||||
#define TK_NK_ILLEGAL 602
|
#define TK_NK_ILLEGAL 602
|
||||||
|
|
|
@ -3111,7 +3111,7 @@ static int32_t tColDataCopyRowAppend(SColData *aFromColData, int32_t iFromRow, S
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void tColDataArrGetRowKey(SColData *aColData, int32_t nColData, int32_t iRow, SRowKey *key) {
|
void tColDataArrGetRowKey(SColData *aColData, int32_t nColData, int32_t iRow, SRowKey *key) {
|
||||||
SColVal cv;
|
SColVal cv;
|
||||||
|
|
||||||
key->ts = ((TSKEY *)aColData[0].pData)[iRow];
|
key->ts = ((TSKEY *)aColData[0].pData)[iRow];
|
||||||
|
@ -3490,7 +3490,7 @@ _exit:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tPutColData(uint8_t *pBuf, SColData *pColData) {
|
static int32_t tPutColDataVersion0(uint8_t *pBuf, SColData *pColData) {
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
|
|
||||||
n += tPutI16v(pBuf ? pBuf + n : NULL, pColData->cid);
|
n += tPutI16v(pBuf ? pBuf + n : NULL, pColData->cid);
|
||||||
|
@ -3532,7 +3532,7 @@ int32_t tPutColData(uint8_t *pBuf, SColData *pColData) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tGetColData(uint8_t *pBuf, SColData *pColData) {
|
static int32_t tGetColDataVersion0(uint8_t *pBuf, SColData *pColData) {
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
|
|
||||||
n += tGetI16v(pBuf + n, &pColData->cid);
|
n += tGetI16v(pBuf + n, &pColData->cid);
|
||||||
|
@ -3571,10 +3571,45 @@ int32_t tGetColData(uint8_t *pBuf, SColData *pColData) {
|
||||||
n += pColData->nData;
|
n += pColData->nData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pColData->cflag = 0;
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t tPutColDataVersion1(uint8_t *pBuf, SColData *pColData) {
|
||||||
|
int32_t n = tPutColDataVersion0(pBuf, pColData);
|
||||||
|
n += tPutI8(pBuf ? pBuf + n : NULL, pColData->cflag);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tGetColDataVersion1(uint8_t *pBuf, SColData *pColData) {
|
||||||
|
int32_t n = tGetColDataVersion0(pBuf, pColData);
|
||||||
|
n += tGetI8(pBuf ? pBuf + n : NULL, &pColData->cflag);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tPutColData(uint8_t version, uint8_t *pBuf, SColData *pColData) {
|
||||||
|
if (version == 0) {
|
||||||
|
return tPutColDataVersion0(pBuf, pColData);
|
||||||
|
} else if (version == 1) {
|
||||||
|
return tPutColDataVersion1(pBuf, pColData);
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tGetColData(uint8_t version, uint8_t *pBuf, SColData *pColData) {
|
||||||
|
if (version == 0) {
|
||||||
|
return tGetColDataVersion0(pBuf, pColData);
|
||||||
|
} else if (version == 1) {
|
||||||
|
return tGetColDataVersion1(pBuf, pColData);
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define CALC_SUM_MAX_MIN(SUM, MAX, MIN, VAL) \
|
#define CALC_SUM_MAX_MIN(SUM, MAX, MIN, VAL) \
|
||||||
do { \
|
do { \
|
||||||
(SUM) += (VAL); \
|
(SUM) += (VAL); \
|
||||||
|
|
|
@ -9181,7 +9181,8 @@ int32_t tDecodeSBatchDeleteReqSetCtime(SDecoder *pDecoder, SBatchDeleteReq *pReq
|
||||||
static int32_t tEncodeSSubmitTbData(SEncoder *pCoder, const SSubmitTbData *pSubmitTbData) {
|
static int32_t tEncodeSSubmitTbData(SEncoder *pCoder, const SSubmitTbData *pSubmitTbData) {
|
||||||
if (tStartEncode(pCoder) < 0) return -1;
|
if (tStartEncode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
if (tEncodeI32v(pCoder, pSubmitTbData->flags) < 0) return -1;
|
int32_t flags = pSubmitTbData->flags | ((SUBMIT_REQUEST_VERSION) << 8);
|
||||||
|
if (tEncodeI32v(pCoder, flags) < 0) return -1;
|
||||||
|
|
||||||
// auto create table
|
// auto create table
|
||||||
if (pSubmitTbData->flags & SUBMIT_REQ_AUTO_CREATE_TABLE) {
|
if (pSubmitTbData->flags & SUBMIT_REQ_AUTO_CREATE_TABLE) {
|
||||||
|
@ -9201,7 +9202,8 @@ static int32_t tEncodeSSubmitTbData(SEncoder *pCoder, const SSubmitTbData *pSubm
|
||||||
if (tEncodeU64v(pCoder, nColData) < 0) return -1;
|
if (tEncodeU64v(pCoder, nColData) < 0) return -1;
|
||||||
|
|
||||||
for (uint64_t i = 0; i < nColData; i++) {
|
for (uint64_t i = 0; i < nColData; i++) {
|
||||||
pCoder->pos += tPutColData(pCoder->data ? pCoder->data + pCoder->pos : NULL, &aColData[i]);
|
pCoder->pos +=
|
||||||
|
tPutColData(SUBMIT_REQUEST_VERSION, pCoder->data ? pCoder->data + pCoder->pos : NULL, &aColData[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tEncodeU64v(pCoder, TARRAY_SIZE(pSubmitTbData->aRowP)) < 0) return -1;
|
if (tEncodeU64v(pCoder, TARRAY_SIZE(pSubmitTbData->aRowP)) < 0) return -1;
|
||||||
|
@ -9220,13 +9222,18 @@ static int32_t tEncodeSSubmitTbData(SEncoder *pCoder, const SSubmitTbData *pSubm
|
||||||
|
|
||||||
static int32_t tDecodeSSubmitTbData(SDecoder *pCoder, SSubmitTbData *pSubmitTbData) {
|
static int32_t tDecodeSSubmitTbData(SDecoder *pCoder, SSubmitTbData *pSubmitTbData) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
int32_t flags;
|
||||||
|
uint8_t version;
|
||||||
|
|
||||||
if (tStartDecode(pCoder) < 0) {
|
if (tStartDecode(pCoder) < 0) {
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tDecodeI32v(pCoder, &pSubmitTbData->flags) < 0) return -1;
|
if (tDecodeI32v(pCoder, &flags) < 0) return -1;
|
||||||
|
|
||||||
|
pSubmitTbData->flags = flags & 0xff;
|
||||||
|
version = (flags >> 8) & 0xff;
|
||||||
|
|
||||||
if (pSubmitTbData->flags & SUBMIT_REQ_AUTO_CREATE_TABLE) {
|
if (pSubmitTbData->flags & SUBMIT_REQ_AUTO_CREATE_TABLE) {
|
||||||
pSubmitTbData->pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq));
|
pSubmitTbData->pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq));
|
||||||
|
@ -9270,7 +9277,7 @@ static int32_t tDecodeSSubmitTbData(SDecoder *pCoder, SSubmitTbData *pSubmitTbDa
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < nColData; ++i) {
|
for (int32_t i = 0; i < nColData; ++i) {
|
||||||
pCoder->pos += tGetColData(pCoder->data + pCoder->pos, taosArrayReserve(pSubmitTbData->aCol, 1));
|
pCoder->pos += tGetColData(version, pCoder->data + pCoder->pos, taosArrayReserve(pSubmitTbData->aCol, 1));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uint64_t nRow;
|
uint64_t nRow;
|
||||||
|
|
|
@ -241,10 +241,13 @@ static int32_t vnodePreProcessSubmitTbData(SVnode *pVnode, SDecoder *pCoder, int
|
||||||
}
|
}
|
||||||
|
|
||||||
SSubmitTbData submitTbData;
|
SSubmitTbData submitTbData;
|
||||||
|
uint8_t version;
|
||||||
if (tDecodeI32v(pCoder, &submitTbData.flags) < 0) {
|
if (tDecodeI32v(pCoder, &submitTbData.flags) < 0) {
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
version = (submitTbData.flags >> 8) & 0xff;
|
||||||
|
submitTbData.flags = submitTbData.flags & 0xff;
|
||||||
|
|
||||||
if (submitTbData.flags & SUBMIT_REQ_FROM_FILE) {
|
if (submitTbData.flags & SUBMIT_REQ_FROM_FILE) {
|
||||||
code = grantCheck(TSDB_GRANT_CSV);
|
code = grantCheck(TSDB_GRANT_CSV);
|
||||||
|
@ -308,7 +311,7 @@ static int32_t vnodePreProcessSubmitTbData(SVnode *pVnode, SDecoder *pCoder, int
|
||||||
}
|
}
|
||||||
|
|
||||||
SColData colData = {0};
|
SColData colData = {0};
|
||||||
pCoder->pos += tGetColData(pCoder->data + pCoder->pos, &colData);
|
pCoder->pos += tGetColData(version, pCoder->data + pCoder->pos, &colData);
|
||||||
if (colData.flag != HAS_VALUE) {
|
if (colData.flag != HAS_VALUE) {
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
@ -322,7 +325,7 @@ static int32_t vnodePreProcessSubmitTbData(SVnode *pVnode, SDecoder *pCoder, int
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint64_t i = 1; i < nColData; i++) {
|
for (uint64_t i = 1; i < nColData; i++) {
|
||||||
pCoder->pos += tGetColData(pCoder->data + pCoder->pos, &colData);
|
pCoder->pos += tGetColData(version, pCoder->data + pCoder->pos, &colData);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uint64_t nRow;
|
uint64_t nRow;
|
||||||
|
@ -1596,17 +1599,18 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t ver, void *pReq, in
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
SColData *pColData = (SColData *)taosArrayGet(pSubmitTbData->aCol, 0);
|
SColData *colDataArr = TARRAY_DATA(pSubmitTbData->aCol);
|
||||||
TSKEY *aKey = (TSKEY *)(pColData->pData);
|
SRowKey lastKey;
|
||||||
|
tColDataArrGetRowKey(colDataArr, TARRAY_SIZE(pSubmitTbData->aCol), 0, &lastKey);
|
||||||
for (int32_t iRow = 0; iRow < pColData->nVal; iRow++) {
|
for (int32_t iRow = 1; iRow < colDataArr[0].nVal; iRow++) {
|
||||||
if (aKey[iRow] < minKey || aKey[iRow] > maxKey || (iRow > 0 && aKey[iRow] <= aKey[iRow - 1])) {
|
SRowKey key;
|
||||||
|
tColDataArrGetRowKey(TARRAY_DATA(pSubmitTbData->aCol), TARRAY_SIZE(pSubmitTbData->aCol), iRow, &key);
|
||||||
|
if (tRowKeyCompare(&lastKey, &key) >= 0) {
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
vError("vgId:%d %s failed since %s, version:%" PRId64, TD_VID(pVnode), __func__, tstrerror(terrno), ver);
|
vError("vgId:%d %s failed since %s, version:%" PRId64, TD_VID(pVnode), __func__, tstrerror(terrno), ver);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
int32_t nRow = TARRAY_SIZE(pSubmitTbData->aRowP);
|
int32_t nRow = TARRAY_SIZE(pSubmitTbData->aRowP);
|
||||||
SRow **aRow = (SRow **)TARRAY_DATA(pSubmitTbData->aRowP);
|
SRow **aRow = (SRow **)TARRAY_DATA(pSubmitTbData->aRowP);
|
||||||
|
|
|
@ -2018,9 +2018,17 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
if (IS_STR_DATA_TYPE(para2Type)) {
|
if (IS_STR_DATA_TYPE(para2Type)) {
|
||||||
para2Bytes -= VARSTR_HEADER_SIZE;
|
para2Bytes -= VARSTR_HEADER_SIZE;
|
||||||
}
|
}
|
||||||
if (para2Bytes <= 0 || para2Bytes > 4096) { // cast dst var type length limits to 4096 bytes
|
if (para2Bytes <= 0 ||
|
||||||
|
para2Bytes > TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE) { // cast dst var type length limits to 4096 bytes
|
||||||
|
if (TSDB_DATA_TYPE_NCHAR == para2Type) {
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
"CAST function converted length should be in range (0, 4096] bytes");
|
"CAST function converted length should be in range (0, %d] NCHARS",
|
||||||
|
(TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE)/TSDB_NCHAR_SIZE);
|
||||||
|
} else {
|
||||||
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
|
"CAST function converted length should be in range (0, %d] bytes",
|
||||||
|
TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add database precision as param
|
// add database precision as param
|
||||||
|
|
|
@ -424,6 +424,13 @@ type_name(A) ::= DECIMAL.
|
||||||
type_name(A) ::= DECIMAL NK_LP NK_INTEGER NK_RP. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
|
type_name(A) ::= DECIMAL NK_LP NK_INTEGER NK_RP. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
|
||||||
type_name(A) ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
|
type_name(A) ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
|
||||||
|
|
||||||
|
%type type_name_default_len { SDataType }
|
||||||
|
%destructor type_name_default_len { }
|
||||||
|
type_name_default_len(A) ::= BINARY. { A = createVarLenDataType(TSDB_DATA_TYPE_BINARY, NULL); }
|
||||||
|
type_name_default_len(A) ::= NCHAR. { A = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, NULL); }
|
||||||
|
type_name_default_len(A) ::= VARCHAR. { A = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, NULL); }
|
||||||
|
type_name_default_len(A) ::= VARBINARY. { A = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, NULL); }
|
||||||
|
|
||||||
%type tags_def_opt { SNodeList* }
|
%type tags_def_opt { SNodeList* }
|
||||||
%destructor tags_def_opt { nodesDestroyList($$); }
|
%destructor tags_def_opt { nodesDestroyList($$); }
|
||||||
tags_def_opt(A) ::= . { A = NULL; }
|
tags_def_opt(A) ::= . { A = NULL; }
|
||||||
|
@ -1130,6 +1137,9 @@ function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D).
|
||||||
function_expression(A) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
function_expression(A) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||||
function_expression(A) ::=
|
function_expression(A) ::=
|
||||||
CAST(B) NK_LP expr_or_subquery(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
CAST(B) NK_LP expr_or_subquery(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||||
|
function_expression(A) ::=
|
||||||
|
CAST(B) NK_LP expr_or_subquery(C) AS type_name_default_len(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||||
|
|
||||||
function_expression(A) ::= literal_func(B). { A = B; }
|
function_expression(A) ::= literal_func(B). { A = B; }
|
||||||
|
|
||||||
literal_func(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &B, NULL)); }
|
literal_func(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &B, NULL)); }
|
||||||
|
|
|
@ -1632,7 +1632,10 @@ SDataType createDataType(uint8_t type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataType createVarLenDataType(uint8_t type, const SToken* pLen) {
|
SDataType createVarLenDataType(uint8_t type, const SToken* pLen) {
|
||||||
SDataType dt = {.type = type, .precision = 0, .scale = 0, .bytes = taosStr2Int32(pLen->z, NULL, 10)};
|
int32_t len = TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE;
|
||||||
|
if (type == TSDB_DATA_TYPE_NCHAR) len /= TSDB_NCHAR_SIZE;
|
||||||
|
if(pLen) len = taosStr2Int32(pLen->z, NULL, 10);
|
||||||
|
SDataType dt = {.type = type, .precision = 0, .scale = 0, .bytes = len};
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8240,6 +8240,7 @@ static int32_t adjustOrderOfProjections(STranslateContext* pCxt, SNodeList** ppC
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
bool hasTsKey = false;
|
||||||
bool hasPrimaryKey = false;
|
bool hasPrimaryKey = false;
|
||||||
SNode* pCol = NULL;
|
SNode* pCol = NULL;
|
||||||
SNode* pProj = NULL;
|
SNode* pProj = NULL;
|
||||||
|
@ -8255,13 +8256,22 @@ static int32_t adjustOrderOfProjections(STranslateContext* pCxt, SNodeList** ppC
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (PRIMARYKEY_TIMESTAMP_COL_ID == pSchema->colId) {
|
if (PRIMARYKEY_TIMESTAMP_COL_ID == pSchema->colId) {
|
||||||
|
hasTsKey = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pSchema->flags & COL_IS_KEY) {
|
||||||
hasPrimaryKey = true;
|
hasPrimaryKey = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code && !hasPrimaryKey) {
|
if (TSDB_CODE_SUCCESS == code && !hasTsKey) {
|
||||||
code = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMNS_NUM,
|
code = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMNS_NUM,
|
||||||
"primary timestamp column can not be null");
|
"Primary timestamp column of dest table can not be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TSDB_CODE_SUCCESS == code && !hasPrimaryKey && hasPkInTable(pMeta)) {
|
||||||
|
code = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMNS_NUM,
|
||||||
|
"Primary key column of dest table can not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
SNodeList* pNewProjections = NULL;
|
SNodeList* pNewProjections = NULL;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -158,6 +158,10 @@ int transResetBuffer(SConnBuffer* connBuf) {
|
||||||
p->left = -1;
|
p->left = -1;
|
||||||
p->total = 0;
|
p->total = 0;
|
||||||
p->len = 0;
|
p->len = 0;
|
||||||
|
if (p->cap > BUFFER_CAP) {
|
||||||
|
p->cap = BUFFER_CAP;
|
||||||
|
p->buf = taosMemoryRealloc(p->buf, p->cap);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ASSERTS(0, "invalid read from sock buf");
|
ASSERTS(0, "invalid read from sock buf");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -242,6 +242,7 @@ void taosCloseLog() {
|
||||||
taosMemoryFreeClear(tsLogObj.logHandle->buffer);
|
taosMemoryFreeClear(tsLogObj.logHandle->buffer);
|
||||||
taosThreadMutexDestroy(&tsLogObj.logMutex);
|
taosThreadMutexDestroy(&tsLogObj.logMutex);
|
||||||
taosMemoryFreeClear(tsLogObj.logHandle);
|
taosMemoryFreeClear(tsLogObj.logHandle);
|
||||||
|
tsLogObj.logHandle = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,8 +286,11 @@ static void taosKeepOldLog(char *oldName) {
|
||||||
taosRemoveOldFiles(tsLogDir, tsLogKeepDays);
|
taosRemoveOldFiles(tsLogDir, tsLogKeepDays);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
typedef struct {
|
||||||
static void *taosThreadToOpenNewFile(void *param) {
|
TdFilePtr pOldFile;
|
||||||
|
char keepName[LOG_FILE_NAME_LEN + 20];
|
||||||
|
} OldFileKeeper;
|
||||||
|
static OldFileKeeper *taosOpenNewFile() {
|
||||||
char keepName[LOG_FILE_NAME_LEN + 20];
|
char keepName[LOG_FILE_NAME_LEN + 20];
|
||||||
sprintf(keepName, "%s.%d", tsLogObj.logName, tsLogObj.flag);
|
sprintf(keepName, "%s.%d", tsLogObj.logName, tsLogObj.flag);
|
||||||
|
|
||||||
|
@ -312,13 +316,26 @@ static void *taosThreadToOpenNewFile(void *param) {
|
||||||
tsLogObj.logHandle->pFile = pFile;
|
tsLogObj.logHandle->pFile = pFile;
|
||||||
tsLogObj.lines = 0;
|
tsLogObj.lines = 0;
|
||||||
tsLogObj.openInProgress = 0;
|
tsLogObj.openInProgress = 0;
|
||||||
taosSsleep(20);
|
OldFileKeeper* oldFileKeeper = taosMemoryMalloc(sizeof(OldFileKeeper));
|
||||||
taosCloseLogByFd(pOldFile);
|
if (oldFileKeeper == NULL) {
|
||||||
|
uError("create old log keep info faild! mem is not enough.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
oldFileKeeper->pOldFile = pOldFile;
|
||||||
|
memcpy(oldFileKeeper->keepName, keepName, LOG_FILE_NAME_LEN + 20);
|
||||||
|
|
||||||
uInfo(" new log file:%d is opened", tsLogObj.flag);
|
uInfo(" new log file:%d is opened", tsLogObj.flag);
|
||||||
uInfo("==================================");
|
uInfo("==================================");
|
||||||
taosKeepOldLog(keepName);
|
return oldFileKeeper;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *taosThreadToCloseOldFile(void* param) {
|
||||||
|
if(!param) return NULL;
|
||||||
|
OldFileKeeper* oldFileKeeper = (OldFileKeeper*)param;
|
||||||
|
taosSsleep(20);
|
||||||
|
taosCloseLogByFd(oldFileKeeper->pOldFile);
|
||||||
|
taosKeepOldLog(oldFileKeeper->keepName);
|
||||||
|
taosMemoryFree(oldFileKeeper);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +351,8 @@ static int32_t taosOpenNewLogFile() {
|
||||||
taosThreadAttrInit(&attr);
|
taosThreadAttrInit(&attr);
|
||||||
taosThreadAttrSetDetachState(&attr, PTHREAD_CREATE_DETACHED);
|
taosThreadAttrSetDetachState(&attr, PTHREAD_CREATE_DETACHED);
|
||||||
|
|
||||||
taosThreadCreate(&thread, &attr, taosThreadToOpenNewFile, NULL);
|
OldFileKeeper* oldFileKeeper = taosOpenNewFile();
|
||||||
|
taosThreadCreate(&thread, &attr, taosThreadToCloseOldFile, oldFileKeeper);
|
||||||
taosThreadAttrDestroy(&attr);
|
taosThreadAttrDestroy(&attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,10 +365,11 @@ void taosResetLog() {
|
||||||
// force create a new log file
|
// force create a new log file
|
||||||
tsLogObj.lines = tsNumOfLogLines + 10;
|
tsLogObj.lines = tsNumOfLogLines + 10;
|
||||||
|
|
||||||
|
if (tsLogObj.logHandle) {
|
||||||
taosOpenNewLogFile();
|
taosOpenNewLogFile();
|
||||||
|
|
||||||
uInfo("==================================");
|
uInfo("==================================");
|
||||||
uInfo(" reset log file ");
|
uInfo(" reset log file ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool taosCheckFileIsOpen(char *logFileName) {
|
static bool taosCheckFileIsOpen(char *logFileName) {
|
||||||
|
|
|
@ -80,6 +80,10 @@ class TDTestCase:
|
||||||
for i in range(len(data_t1_c1)):
|
for i in range(len(data_t1_c1)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c1[i]) )
|
tdSql.checkData( i, 0, str(data_t1_c1[i]) )
|
||||||
|
|
||||||
|
tdSql.query(f"select cast(c1 as binary) as b from {self.dbname}.t1")
|
||||||
|
for i in range(len(data_t1_c1)):
|
||||||
|
tdSql.checkData( i, 0, str(data_t1_c1[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step6: cast int to nchar, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step6: cast int to nchar, expect changes to str(int) ")
|
||||||
|
|
||||||
tdSql.query(f"select cast(c1 as nchar(32)) as b from {self.dbname}.ct4")
|
tdSql.query(f"select cast(c1 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
|
@ -131,6 +135,13 @@ class TDTestCase:
|
||||||
for i in range(len(data_t1_c2)):
|
for i in range(len(data_t1_c2)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c2[i]) )
|
tdSql.checkData( i, 0, str(data_t1_c2[i]) )
|
||||||
|
|
||||||
|
tdSql.query(f"select cast(c2 as binary) as b from {self.dbname}.ct4")
|
||||||
|
for i in range(len(data_ct4_c2)):
|
||||||
|
tdSql.checkData( i, 0, str(data_ct4_c2[i]) )
|
||||||
|
tdSql.query(f"select cast(c2 as binary) as b from {self.dbname}.t1")
|
||||||
|
for i in range(len(data_t1_c2)):
|
||||||
|
tdSql.checkData( i, 0, str(data_t1_c2[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step10: cast bigint to nchar, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step10: cast bigint to nchar, expect changes to str(int) ")
|
||||||
|
|
||||||
tdSql.query(f"select cast(c2 as nchar(32)) as b from {self.dbname}.ct4")
|
tdSql.query(f"select cast(c2 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
|
@ -185,6 +196,13 @@ class TDTestCase:
|
||||||
for i in range(len(data_t1_c3)):
|
for i in range(len(data_t1_c3)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c3[i]) )
|
tdSql.checkData( i, 0, str(data_t1_c3[i]) )
|
||||||
|
|
||||||
|
tdSql.query(f"select cast(c3 as binary) as b from {self.dbname}.ct4")
|
||||||
|
for i in range(len(data_ct4_c3)):
|
||||||
|
tdSql.checkData( i, 0, str(data_ct4_c3[i]) )
|
||||||
|
tdSql.query(f"select cast(c3 as binary) as b from {self.dbname}.t1")
|
||||||
|
for i in range(len(data_t1_c3)):
|
||||||
|
tdSql.checkData( i, 0, str(data_t1_c3[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step14: cast smallint to nchar, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step14: cast smallint to nchar, expect changes to str(int) ")
|
||||||
|
|
||||||
tdSql.query(f"select cast(c3 as nchar(32)) as b from {self.dbname}.ct4")
|
tdSql.query(f"select cast(c3 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
|
@ -236,6 +254,13 @@ class TDTestCase:
|
||||||
for i in range(len(data_t1_c4)):
|
for i in range(len(data_t1_c4)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c4[i]) )
|
tdSql.checkData( i, 0, str(data_t1_c4[i]) )
|
||||||
|
|
||||||
|
tdSql.query(f"select cast(c4 as binary) as b from {self.dbname}.ct4")
|
||||||
|
for i in range(len(data_ct4_c4)):
|
||||||
|
tdSql.checkData( i, 0, str(data_ct4_c4[i]) )
|
||||||
|
tdSql.query(f"select cast(c4 as binary) as b from {self.dbname}.t1")
|
||||||
|
for i in range(len(data_t1_c4)):
|
||||||
|
tdSql.checkData( i, 0, str(data_t1_c4[i]) )
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step18: cast tinyint to nchar, expect changes to str(int) ")
|
tdLog.printNoPrefix("==========step18: cast tinyint to nchar, expect changes to str(int) ")
|
||||||
|
|
||||||
tdSql.query(f"select cast(c4 as nchar(32)) as b from {self.dbname}.ct4")
|
tdSql.query(f"select cast(c4 as nchar(32)) as b from {self.dbname}.ct4")
|
||||||
|
@ -282,6 +307,12 @@ class TDTestCase:
|
||||||
for i in range(len(data_ct4_c5)):
|
for i in range(len(data_ct4_c5)):
|
||||||
tdSql.checkData( i, 0, str(data_ct4_c5[i]) ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' )
|
tdSql.checkData( i, 0, str(data_ct4_c5[i]) ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' )
|
||||||
tdSql.query(f"select cast(c5 as binary(32)) as b from {self.dbname}.t1")
|
tdSql.query(f"select cast(c5 as binary(32)) as b from {self.dbname}.t1")
|
||||||
|
for i in range(len(data_t1_c5)):
|
||||||
|
tdSql.checkData( i, 0, str(data_t1_c5[i]) ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
||||||
|
tdSql.query(f"select cast(c5 as binary) as b from {self.dbname}.ct4")
|
||||||
|
for i in range(len(data_ct4_c5)):
|
||||||
|
tdSql.checkData( i, 0, str(data_ct4_c5[i]) ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' )
|
||||||
|
tdSql.query(f"select cast(c5 as binary) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c5)):
|
for i in range(len(data_t1_c5)):
|
||||||
tdSql.checkData( i, 0, str(data_t1_c5[i]) ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
tdSql.checkData( i, 0, str(data_t1_c5[i]) ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
||||||
|
|
||||||
|
@ -290,6 +321,12 @@ class TDTestCase:
|
||||||
for i in range(len(data_ct4_c5)):
|
for i in range(len(data_ct4_c5)):
|
||||||
tdSql.checkData( i, 0, None ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' )
|
tdSql.checkData( i, 0, None ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' )
|
||||||
tdSql.query(f"select cast(c5 as nchar(32)) as b from {self.dbname}.t1")
|
tdSql.query(f"select cast(c5 as nchar(32)) as b from {self.dbname}.t1")
|
||||||
|
for i in range(len(data_t1_c5)):
|
||||||
|
tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
||||||
|
tdSql.query(f"select cast(c5 as nchar) as b from {self.dbname}.t1")
|
||||||
|
for i in range(len(data_t1_c5)):
|
||||||
|
tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
||||||
|
tdSql.query(f"select cast(c5 as varchar) as b from {self.dbname}.t1")
|
||||||
for i in range(len(data_t1_c5)):
|
for i in range(len(data_t1_c5)):
|
||||||
tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' )
|
||||||
|
|
||||||
|
@ -580,6 +617,10 @@ class TDTestCase:
|
||||||
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as binary(2)) as b from {self.dbname}.ct4")
|
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as binary(2)) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
||||||
|
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as binary) as b from {self.dbname}.ct4")
|
||||||
|
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
||||||
|
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as binary) as b from {self.dbname}.ct4")
|
||||||
|
( tdSql.checkData(i, 0, '12') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as nchar(16)) as b from {self.dbname}.ct4")
|
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as nchar(16)) as b from {self.dbname}.ct4")
|
||||||
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
( tdSql.checkData(i, 0, '12121.233231') for i in range(tdSql.queryRows) )
|
||||||
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as nchar(2)) as b from {self.dbname}.ct4")
|
tdSql.query(f"select cast(12121.23323131 + 'test~!@`#$%^&*(){'}'}{'{'}][;><.,' as nchar(2)) as b from {self.dbname}.ct4")
|
||||||
|
|
Loading…
Reference in New Issue