Merge branch '3.0' into feature/compressData
This commit is contained in:
parent
0cce8df6b5
commit
aa5ccf2b0b
|
@ -89,9 +89,13 @@ bool checkColumnLevelOrSetDefault(uint8_t type, char level[TSDB_CL_COMPRESS_OPTI
|
||||||
void setColEncode(uint32_t* compress, uint8_t encode);
|
void setColEncode(uint32_t* compress, uint8_t encode);
|
||||||
void setColCompress(uint32_t* compress, uint16_t compressType);
|
void setColCompress(uint32_t* compress, uint16_t compressType);
|
||||||
void setColLevel(uint32_t* compress, uint8_t level);
|
void setColLevel(uint32_t* compress, uint8_t level);
|
||||||
int8_t setColCompressByOption(uint8_t type, uint32_t* compress, uint8_t encode, uint16_t compressType, uint8_t level);
|
int8_t setColCompressByOption(uint8_t type, uint8_t encode, uint16_t compressType, uint8_t level, bool check,
|
||||||
|
uint32_t* compress);
|
||||||
|
|
||||||
int8_t validColCompressLevel(uint8_t type, uint8_t level);
|
int8_t validColCompressLevel(uint8_t type, uint8_t level);
|
||||||
int8_t validColCompress(uint8_t type, uint8_t l2);
|
int8_t validColCompress(uint8_t type, uint8_t l2);
|
||||||
int8_t validColEncode(uint8_t type, uint8_t l1);
|
int8_t validColEncode(uint8_t type, uint8_t l1);
|
||||||
|
|
||||||
|
uint32_t createDefaultColCmprByType(uint8_t type);
|
||||||
|
bool validColCmprByType(uint8_t type, uint32_t cmpr);
|
||||||
#endif /*_TD_TCOL_H_*/
|
#endif /*_TD_TCOL_H_*/
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tcol.h"
|
#include "tcol.h"
|
||||||
|
#include "tcompression.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
|
||||||
const char* supportedEncode[5] = {TSDB_COLUMN_ENCODE_SIMPLE8B, TSDB_COLUMN_ENCODE_XOR, TSDB_COLUMN_ENCODE_RLE,
|
const char* supportedEncode[5] = {TSDB_COLUMN_ENCODE_SIMPLE8B, TSDB_COLUMN_ENCODE_XOR, TSDB_COLUMN_ENCODE_RLE,
|
||||||
|
@ -303,18 +304,19 @@ void setColLevel(uint32_t* compress, uint8_t level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t setColCompressByOption(uint8_t type, uint32_t* compress, uint8_t encode, uint16_t compressType, uint8_t level) {
|
int8_t setColCompressByOption(uint8_t type, uint8_t encode, uint16_t compressType, uint8_t level, bool check,
|
||||||
if (!validColEncode(type, encode)) return 0;
|
uint32_t* compress) {
|
||||||
|
if (check && !validColEncode(type, encode)) return 0;
|
||||||
setColEncode(compress, encode);
|
setColEncode(compress, encode);
|
||||||
|
|
||||||
if (compressType == TSDB_COLVAL_COMPRESS_DISABLED) {
|
if (compressType == TSDB_COLVAL_COMPRESS_DISABLED) {
|
||||||
setColCompress(compress, compressType);
|
setColCompress(compress, compressType);
|
||||||
setColLevel(compress, TSDB_COLVAL_LEVEL_DISABLED);
|
setColLevel(compress, TSDB_COLVAL_LEVEL_DISABLED);
|
||||||
} else {
|
} else {
|
||||||
if (!validColCompress(type, compressType)) return 0;
|
if (check && !validColCompress(type, compressType)) return 0;
|
||||||
setColCompress(compress, compressType);
|
setColCompress(compress, compressType);
|
||||||
|
|
||||||
if (!validColCompressLevel(type, level)) return 0;
|
if (check && !validColCompressLevel(type, level)) return 0;
|
||||||
setColLevel(compress, level);
|
setColLevel(compress, level);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -323,21 +325,15 @@ int8_t setColCompressByOption(uint8_t type, uint32_t* compress, uint8_t encode,
|
||||||
bool useCompress(uint8_t tableType) { return TSDB_SUPER_TABLE == tableType || TSDB_NORMAL_TABLE == tableType; }
|
bool useCompress(uint8_t tableType) { return TSDB_SUPER_TABLE == tableType || TSDB_NORMAL_TABLE == tableType; }
|
||||||
|
|
||||||
int8_t validColCompressLevel(uint8_t type, uint8_t level) {
|
int8_t validColCompressLevel(uint8_t type, uint8_t level) {
|
||||||
if (level < TSDB_COLVAL_LEVEL_LOW || level > TSDB_COLVAL_LEVEL_HIGH) {
|
if (level < TSDB_COLVAL_LEVEL_NOCHANGE || level > TSDB_COLVAL_LEVEL_HIGH) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
int8_t validColCompress(uint8_t type, uint8_t l2) {
|
int8_t validColCompress(uint8_t type, uint8_t l2) {
|
||||||
// if (type == TSDB_DATA_TYPE_DOUBLE || type == TSDB_DATA_TYPE_FLOAT) {
|
if (l2 > TSDB_COLVAL_COMPRESS_XZ && l2 < TSDB_COLVAL_COMPRESS_DISABLED) {
|
||||||
// if (l2 != TSDB_COLVAL_COMPRESS_TSZ) {
|
return 0;
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
if (l2 <= TSDB_COLVAL_COMPRESS_NOCHANGE || l2 >= TSDB_COLVAL_COMPRESS_DISABLED) {
|
|
||||||
return TSDB_COLVAL_COMPRESS_DISABLED == l2 ? 1 : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,6 +345,9 @@ int8_t validColCompress(uint8_t type, uint8_t l2) {
|
||||||
// | flout/double | delta-d |
|
// | flout/double | delta-d |
|
||||||
//
|
//
|
||||||
int8_t validColEncode(uint8_t type, uint8_t l1) {
|
int8_t validColEncode(uint8_t type, uint8_t l1) {
|
||||||
|
if (l1 == TSDB_COLVAL_ENCODE_NOCHANGE) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if (type == TSDB_DATA_TYPE_BOOL) {
|
if (type == TSDB_DATA_TYPE_BOOL) {
|
||||||
return TSDB_COLVAL_ENCODE_RLE == l1 ? 1 : 0;
|
return TSDB_COLVAL_ENCODE_RLE == l1 ? 1 : 0;
|
||||||
} else if (type >= TSDB_DATA_TYPE_TINYINT && type <= TSDB_DATA_TYPE_INT) {
|
} else if (type >= TSDB_DATA_TYPE_TINYINT && type <= TSDB_DATA_TYPE_INT) {
|
||||||
|
@ -368,7 +367,7 @@ int8_t validColEncode(uint8_t type, uint8_t l1) {
|
||||||
}
|
}
|
||||||
} else if (type == TSDB_DATA_TYPE_TIMESTAMP) {
|
} else if (type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
return TSDB_COLVAL_ENCODE_XOR == l1 ? 1 : 0;
|
return TSDB_COLVAL_ENCODE_XOR == l1 ? 1 : 0;
|
||||||
} else if (type >= TSDB_DATA_TYPE_USMALLINT || type <= TSDB_DATA_TYPE_UINT) {
|
} else if (type >= TSDB_DATA_TYPE_USMALLINT && type <= TSDB_DATA_TYPE_UINT) {
|
||||||
return TSDB_COLVAL_ENCODE_SIMPLE8B == l1 ? 1 : 0;
|
return TSDB_COLVAL_ENCODE_SIMPLE8B == l1 ? 1 : 0;
|
||||||
} else if (type == TSDB_DATA_TYPE_UBIGINT) {
|
} else if (type == TSDB_DATA_TYPE_UBIGINT) {
|
||||||
return TSDB_COLVAL_ENCODE_SIMPLE8B == l1 || TSDB_COLVAL_ENCODE_XOR == l1 ? 1 : 0;
|
return TSDB_COLVAL_ENCODE_SIMPLE8B == l1 || TSDB_COLVAL_ENCODE_XOR == l1 ? 1 : 0;
|
||||||
|
@ -376,3 +375,20 @@ int8_t validColEncode(uint8_t type, uint8_t l1) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t createDefaultColCmprByType(uint8_t type) {
|
||||||
|
uint32_t ret = 0;
|
||||||
|
uint8_t encode = getDefaultEncode(type);
|
||||||
|
uint8_t compress = getDefaultCompress(type);
|
||||||
|
uint8_t lvl = getDefaultLevel(type);
|
||||||
|
|
||||||
|
SET_COMPRESS(encode, compress, lvl, ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
bool validColCmprByType(uint8_t type, uint32_t cmpr) {
|
||||||
|
DEFINE_VAR(cmpr);
|
||||||
|
if (validColEncode(type, l1) && validColCompress(type, l2) && validColCompressLevel(type, lvl)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -287,9 +287,10 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
|
||||||
// compatible with old data, setup default compress value
|
// compatible with old data, setup default compress value
|
||||||
// impl later
|
// impl later
|
||||||
for (int i = 0; i < pStb->numOfColumns; i++) {
|
for (int i = 0; i < pStb->numOfColumns; i++) {
|
||||||
|
SSchema *pSchema = &pStb->pColumns[i];
|
||||||
SColCmpr *pCmpr = &pStb->pCmpr[i];
|
SColCmpr *pCmpr = &pStb->pCmpr[i];
|
||||||
pCmpr->id = 0;
|
pCmpr->id = pSchema->colId;
|
||||||
pCmpr->alg = 0;
|
pCmpr->alg = createDefaultColCmprByType(pSchema->type);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < pStb->numOfColumns; i++) {
|
for (int i = 0; i < pStb->numOfColumns; i++) {
|
||||||
|
@ -345,7 +346,7 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
|
||||||
mTrace("stb:%s, perform update action, old row:%p new row:%p", pOld->name, pOld, pNew);
|
mTrace("stb:%s, perform update action, old row:%p new row:%p", pOld->name, pOld, pNew);
|
||||||
|
|
||||||
taosWLockLatch(&pOld->lock);
|
taosWLockLatch(&pOld->lock);
|
||||||
|
int32_t numOfColumns = pOld->numOfColumns;
|
||||||
if (pOld->numOfColumns < pNew->numOfColumns) {
|
if (pOld->numOfColumns < pNew->numOfColumns) {
|
||||||
void *pColumns = taosMemoryMalloc(pNew->numOfColumns * sizeof(SSchema));
|
void *pColumns = taosMemoryMalloc(pNew->numOfColumns * sizeof(SSchema));
|
||||||
if (pColumns != NULL) {
|
if (pColumns != NULL) {
|
||||||
|
@ -433,7 +434,13 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
|
||||||
memcpy(pOld->pAst2, pNew->pAst2, pNew->ast2Len);
|
memcpy(pOld->pAst2, pNew->pAst2, pNew->ast2Len);
|
||||||
pOld->ast2Len = pNew->ast2Len;
|
pOld->ast2Len = pNew->ast2Len;
|
||||||
}
|
}
|
||||||
memcpy(pOld->pCmpr, pNew->pCmpr, pOld->numOfColumns * sizeof(SColCmpr));
|
if (numOfColumns < pNew->numOfColumns) {
|
||||||
|
taosMemoryFree(pOld->pCmpr);
|
||||||
|
pOld->pCmpr = taosMemoryCalloc(pNew->numOfColumns, sizeof(SColCmpr));
|
||||||
|
memcpy(pOld->pCmpr, pNew->pCmpr, pNew->numOfColumns * sizeof(SColCmpr));
|
||||||
|
} else {
|
||||||
|
memcpy(pOld->pCmpr, pNew->pCmpr, pNew->numOfColumns * sizeof(SColCmpr));
|
||||||
|
}
|
||||||
|
|
||||||
taosWUnLockLatch(&pOld->lock);
|
taosWUnLockLatch(&pOld->lock);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1164,10 +1171,8 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
|
||||||
mInfo("stb:%s, schema version is not incremented and nothing needs to be done", createReq.name);
|
mInfo("stb:%s, schema version is not incremented and nothing needs to be done", createReq.name);
|
||||||
code = 0;
|
code = 0;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
} else if ((tagDelta == 1 && colDelta == 0) ||
|
} else if ((tagDelta == 1 && colDelta == 0) || (tagDelta == 0 && colDelta == 1) ||
|
||||||
(tagDelta == 0 && colDelta == 1) ||
|
(pStb->colVer == 1 && createReq.colVer > 1) || (pStb->tagVer == 1 && createReq.tagVer > 1)) {
|
||||||
(pStb->colVer == 1 && createReq.colVer > 1) ||
|
|
||||||
(pStb->tagVer == 1 && createReq.tagVer > 1)) {
|
|
||||||
isAlter = true;
|
isAlter = true;
|
||||||
mInfo("stb:%s, schema version is only increased by 1 number, do alter operation", createReq.name);
|
mInfo("stb:%s, schema version is only increased by 1 number, do alter operation", createReq.name);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1673,7 +1678,8 @@ static int32_t mndUpdateSuperTableColumnCompress(SMnode *pMnode, const SStbObj *
|
||||||
terrno = TSDB_CODE_MND_COLUMN_NOT_EXIST;
|
terrno = TSDB_CODE_MND_COLUMN_NOT_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
col_id_t colId = pOld->pColumns[idx].colId;
|
SSchema *pTarget = &pOld->pColumns[idx];
|
||||||
|
col_id_t colId = pTarget->colId;
|
||||||
if (mndCheckColAndTagModifiable(pMnode, pOld->name, pOld->uid, colId) != 0) {
|
if (mndCheckColAndTagModifiable(pMnode, pOld->name, pOld->uid, colId) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1681,6 +1687,10 @@ static int32_t mndUpdateSuperTableColumnCompress(SMnode *pMnode, const SStbObj *
|
||||||
if (mndAllocStbSchemas(pOld, pNew) != 0) {
|
if (mndAllocStbSchemas(pOld, pNew) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (!validColCmprByType(pTarget->type, p->bytes)) {
|
||||||
|
terrno = TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int8_t updated = 0;
|
int8_t updated = 0;
|
||||||
for (int i = 0; i < pNew->numOfColumns; i++) {
|
for (int i = 0; i < pNew->numOfColumns; i++) {
|
||||||
|
@ -1718,6 +1728,7 @@ static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, SArray
|
||||||
}
|
}
|
||||||
|
|
||||||
pNew->numOfColumns = pNew->numOfColumns + ncols;
|
pNew->numOfColumns = pNew->numOfColumns + ncols;
|
||||||
|
|
||||||
if (mndAllocStbSchemas(pOld, pNew) != 0) {
|
if (mndAllocStbSchemas(pOld, pNew) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1746,6 +1757,10 @@ static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, SArray
|
||||||
pSchema->colId = pNew->nextColId;
|
pSchema->colId = pNew->nextColId;
|
||||||
pNew->nextColId++;
|
pNew->nextColId++;
|
||||||
|
|
||||||
|
SColCmpr *pCmpr = &pNew->pCmpr[pOld->numOfColumns + i];
|
||||||
|
pCmpr->id = pSchema->colId;
|
||||||
|
pCmpr->alg = createDefaultColCmprByType(pSchema->type);
|
||||||
|
|
||||||
mInfo("stb:%s, start to add column %s", pNew->name, pSchema->name);
|
mInfo("stb:%s, start to add column %s", pNew->name, pSchema->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1779,7 +1794,9 @@ static int32_t mndDropSuperTableColumn(SMnode *pMnode, const SStbObj *pOld, SStb
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(pNew->pColumns + col, pNew->pColumns + col + 1, sizeof(SSchema) * (pNew->numOfColumns - col - 1));
|
int32_t sz = pNew->numOfColumns - col - 1;
|
||||||
|
memmove(pNew->pColumns + col, pNew->pColumns + col + 1, sizeof(SSchema) * sz);
|
||||||
|
memmove(pNew->pCmpr + col, pNew->pCmpr + col + 1, sizeof(SColCmpr) * sz);
|
||||||
pNew->numOfColumns--;
|
pNew->numOfColumns--;
|
||||||
|
|
||||||
pNew->colVer++;
|
pNew->colVer++;
|
||||||
|
|
|
@ -54,7 +54,7 @@ static FORCE_INLINE void metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SCo
|
||||||
SColCmpr *pColCmpr = &pCmpr->pColCmpr[i];
|
SColCmpr *pColCmpr = &pCmpr->pColCmpr[i];
|
||||||
SSchema *pColSchema = &pSchema->pSchema[i];
|
SSchema *pColSchema = &pSchema->pSchema[i];
|
||||||
pColCmpr->id = pColSchema->colId;
|
pColCmpr->id = pColSchema->colId;
|
||||||
pColCmpr->alg = 0;
|
pColCmpr->alg = createDefaultColCmprByType(pColSchema->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,36 @@ static int metaDeleteBtimeIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||||
static int metaUpdateNcolIdx(SMeta *pMeta, const SMetaEntry *pME);
|
static int metaUpdateNcolIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||||
static int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME);
|
static int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||||
|
|
||||||
|
int8_t updataTableColCmpr(SColCmprWrapper *pWp, SSchema *pSchema, int8_t add) {
|
||||||
|
int32_t nCols = pWp->nCols;
|
||||||
|
int32_t ver = pWp->version;
|
||||||
|
if (add) {
|
||||||
|
SColCmpr *p = taosMemoryCalloc(1, sizeof(SColCmpr) * (nCols + 1));
|
||||||
|
memcpy(p, pWp->pColCmpr, sizeof(SColCmpr) * nCols);
|
||||||
|
|
||||||
|
SColCmpr *pCol = p + nCols;
|
||||||
|
pCol->id = pSchema->colId;
|
||||||
|
pCol->alg = createDefaultColCmprByType(pSchema->type);
|
||||||
|
pWp->nCols = nCols + 1;
|
||||||
|
pWp->version = ver;
|
||||||
|
pWp->pColCmpr = p;
|
||||||
|
} else {
|
||||||
|
for (int32_t i = 0; i < nCols; i++) {
|
||||||
|
SColCmpr *pOCmpr = &pWp->pColCmpr[i];
|
||||||
|
if (pOCmpr->id == pSchema->colId) {
|
||||||
|
int32_t left = (nCols - i - 1) * sizeof(SColCmpr);
|
||||||
|
if (left) {
|
||||||
|
memmove(pWp->pColCmpr + i, pWp->pColCmpr + i + 1, left);
|
||||||
|
}
|
||||||
|
nCols--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pWp->nCols = nCols;
|
||||||
|
pWp->version = ver;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
static void metaGetEntryInfo(const SMetaEntry *pEntry, SMetaInfo *pInfo) {
|
static void metaGetEntryInfo(const SMetaEntry *pEntry, SMetaInfo *pInfo) {
|
||||||
pInfo->uid = pEntry->uid;
|
pInfo->uid = pEntry->uid;
|
||||||
pInfo->version = pEntry->version;
|
pInfo->version = pEntry->version;
|
||||||
|
@ -1363,7 +1393,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
SMetaEntry entry = {0};
|
SMetaEntry entry = {0};
|
||||||
SSchemaWrapper *pSchema;
|
SSchemaWrapper *pSchema;
|
||||||
int c;
|
int c;
|
||||||
|
bool freeColCmpr = false;
|
||||||
if (pAlterTbReq->colName == NULL) {
|
if (pAlterTbReq->colName == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
metaError("meta/table: null pAlterTbReq->colName");
|
metaError("meta/table: null pAlterTbReq->colName");
|
||||||
|
@ -1492,6 +1522,9 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
int8_t col_type = pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1].type;
|
int8_t col_type = pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1].type;
|
||||||
(void)tsdbCacheNewNTableColumn(pMeta->pVnode->pTsdb, entry.uid, cid, col_type);
|
(void)tsdbCacheNewNTableColumn(pMeta->pVnode->pTsdb, entry.uid, cid, col_type);
|
||||||
}
|
}
|
||||||
|
SSchema *pCol = &pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1];
|
||||||
|
updataTableColCmpr(&entry.colCmpr, pCol, 1);
|
||||||
|
freeColCmpr = true;
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
||||||
if (pColumn == NULL) {
|
if (pColumn == NULL) {
|
||||||
|
@ -1521,6 +1554,8 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
|
|
||||||
(void)tsdbCacheDropNTableColumn(pMeta->pVnode->pTsdb, entry.uid, cid, col_type);
|
(void)tsdbCacheDropNTableColumn(pMeta->pVnode->pTsdb, entry.uid, cid, col_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updataTableColCmpr(&entry.colCmpr, pColumn, 0);
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
||||||
if (pColumn == NULL) {
|
if (pColumn == NULL) {
|
||||||
|
@ -1582,6 +1617,8 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
|
|
||||||
if (entry.pBuf) taosMemoryFree(entry.pBuf);
|
if (entry.pBuf) taosMemoryFree(entry.pBuf);
|
||||||
if (pNewSchema) taosMemoryFree(pNewSchema);
|
if (pNewSchema) taosMemoryFree(pNewSchema);
|
||||||
|
if (freeColCmpr) taosMemoryFree(entry.colCmpr.pColCmpr);
|
||||||
|
|
||||||
tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
|
|
|
@ -1197,6 +1197,7 @@ _exit:
|
||||||
tEncoderClear(&ec);
|
tEncoderClear(&ec);
|
||||||
if (vMetaRsp.pSchemas) {
|
if (vMetaRsp.pSchemas) {
|
||||||
taosMemoryFree(vMetaRsp.pSchemas);
|
taosMemoryFree(vMetaRsp.pSchemas);
|
||||||
|
taosMemoryFree(vMetaRsp.pSchemaExt);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -931,7 +931,7 @@ static bool isPrimaryKey(STempTableNode* pTable, SNode* pExpr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hasPkInTable(const STableMeta* pTableMeta) {
|
static bool hasPkInTable(const STableMeta* pTableMeta) {
|
||||||
return pTableMeta->tableInfo.numOfColumns>=2 && pTableMeta->schema[1].flags & COL_IS_KEY;
|
return pTableMeta->tableInfo.numOfColumns >= 2 && pTableMeta->schema[1].flags & COL_IS_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* pColSchema, int32_t tagFlag,
|
static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* pColSchema, int32_t tagFlag,
|
||||||
|
@ -1187,9 +1187,8 @@ static SNode* biMakeTbnameProjectAstNode(char* funcName, char* tableAlias) {
|
||||||
if (valNode != NULL) {
|
if (valNode != NULL) {
|
||||||
nodesListMakeAppend(&tbNameFunc->pParameterList, (SNode*)valNode);
|
nodesListMakeAppend(&tbNameFunc->pParameterList, (SNode*)valNode);
|
||||||
}
|
}
|
||||||
snprintf(tbNameFunc->node.userAlias, sizeof(tbNameFunc->node.userAlias),
|
snprintf(tbNameFunc->node.userAlias, sizeof(tbNameFunc->node.userAlias), (tableAlias) ? "%s.tbname" : "%stbname",
|
||||||
(tableAlias)? "%s.tbname" : "%stbname",
|
(tableAlias) ? tableAlias : "");
|
||||||
(tableAlias)? tableAlias : "");
|
|
||||||
strncpy(tbNameFunc->node.aliasName, tbNameFunc->functionName, TSDB_COL_NAME_LEN);
|
strncpy(tbNameFunc->node.aliasName, tbNameFunc->functionName, TSDB_COL_NAME_LEN);
|
||||||
|
|
||||||
if (funcName == NULL) {
|
if (funcName == NULL) {
|
||||||
|
@ -1201,14 +1200,13 @@ static SNode* biMakeTbnameProjectAstNode(char* funcName, char* tableAlias) {
|
||||||
|
|
||||||
if (tsKeepColumnName) {
|
if (tsKeepColumnName) {
|
||||||
snprintf(multiResFunc->node.userAlias, sizeof(tbNameFunc->node.userAlias),
|
snprintf(multiResFunc->node.userAlias, sizeof(tbNameFunc->node.userAlias),
|
||||||
(tableAlias)? "%s.tbname" : "%stbname",
|
(tableAlias) ? "%s.tbname" : "%stbname", (tableAlias) ? tableAlias : "");
|
||||||
(tableAlias)? tableAlias : "");
|
|
||||||
strcpy(multiResFunc->node.aliasName, tbNameFunc->functionName);
|
strcpy(multiResFunc->node.aliasName, tbNameFunc->functionName);
|
||||||
} else {
|
} else {
|
||||||
snprintf(multiResFunc->node.userAlias, sizeof(multiResFunc->node.userAlias),
|
snprintf(multiResFunc->node.userAlias, sizeof(multiResFunc->node.userAlias),
|
||||||
tableAlias? "%s(%s.tbname)" : "%s(%stbname)", funcName,
|
tableAlias ? "%s(%s.tbname)" : "%s(%stbname)", funcName, tableAlias ? tableAlias : "");
|
||||||
tableAlias? tableAlias: "");
|
biMakeAliasNameInMD5(multiResFunc->node.userAlias, strlen(multiResFunc->node.userAlias),
|
||||||
biMakeAliasNameInMD5(multiResFunc->node.userAlias, strlen(multiResFunc->node.userAlias), multiResFunc->node.aliasName);
|
multiResFunc->node.aliasName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (SNode*)multiResFunc;
|
return (SNode*)multiResFunc;
|
||||||
|
@ -1220,8 +1218,7 @@ static int32_t biRewriteSelectFuncParamStar(STranslateContext* pCxt, SSelectStmt
|
||||||
SNodeList* pTbnameNodeList = nodesMakeList();
|
SNodeList* pTbnameNodeList = nodesMakeList();
|
||||||
|
|
||||||
SFunctionNode* pFunc = (SFunctionNode*)pNode;
|
SFunctionNode* pFunc = (SFunctionNode*)pNode;
|
||||||
if (strcasecmp(pFunc->functionName, "last") == 0 ||
|
if (strcasecmp(pFunc->functionName, "last") == 0 || strcasecmp(pFunc->functionName, "last_row") == 0 ||
|
||||||
strcasecmp(pFunc->functionName, "last_row") == 0 ||
|
|
||||||
strcasecmp(pFunc->functionName, "first") == 0) {
|
strcasecmp(pFunc->functionName, "first") == 0) {
|
||||||
SNodeList* pParams = pFunc->pParameterList;
|
SNodeList* pParams = pFunc->pParameterList;
|
||||||
SNode* pPara = NULL;
|
SNode* pPara = NULL;
|
||||||
|
@ -1270,8 +1267,7 @@ int32_t biRewriteSelectStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
size_t n = taosArrayGetSize(pTables);
|
size_t n = taosArrayGetSize(pTables);
|
||||||
for (int32_t i = 0; i < n; ++i) {
|
for (int32_t i = 0; i < n; ++i) {
|
||||||
STableNode* pTable = taosArrayGetP(pTables, i);
|
STableNode* pTable = taosArrayGetP(pTables, i);
|
||||||
if (nodeType(pTable) == QUERY_NODE_REAL_TABLE &&
|
if (nodeType(pTable) == QUERY_NODE_REAL_TABLE && ((SRealTableNode*)pTable)->pMeta != NULL &&
|
||||||
((SRealTableNode*)pTable)->pMeta != NULL &&
|
|
||||||
((SRealTableNode*)pTable)->pMeta->tableType == TSDB_SUPER_TABLE) {
|
((SRealTableNode*)pTable)->pMeta->tableType == TSDB_SUPER_TABLE) {
|
||||||
SNode* pTbnameNode = biMakeTbnameProjectAstNode(NULL, NULL);
|
SNode* pTbnameNode = biMakeTbnameProjectAstNode(NULL, NULL);
|
||||||
nodesListAppend(pTbnameNodeList, pTbnameNode);
|
nodesListAppend(pTbnameNodeList, pTbnameNode);
|
||||||
|
@ -1284,10 +1280,8 @@ int32_t biRewriteSelectStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
char* pTableAlias = ((SColumnNode*)pNode)->tableAlias;
|
char* pTableAlias = ((SColumnNode*)pNode)->tableAlias;
|
||||||
STableNode* pTable = NULL;
|
STableNode* pTable = NULL;
|
||||||
int32_t code = findTable(pCxt, pTableAlias, &pTable);
|
int32_t code = findTable(pCxt, pTableAlias, &pTable);
|
||||||
if (TSDB_CODE_SUCCESS == code &&
|
if (TSDB_CODE_SUCCESS == code && nodeType(pTable) == QUERY_NODE_REAL_TABLE &&
|
||||||
nodeType(pTable) == QUERY_NODE_REAL_TABLE &&
|
((SRealTableNode*)pTable)->pMeta != NULL && ((SRealTableNode*)pTable)->pMeta->tableType == TSDB_SUPER_TABLE) {
|
||||||
((SRealTableNode*)pTable)->pMeta != NULL &&
|
|
||||||
((SRealTableNode*)pTable)->pMeta->tableType == TSDB_SUPER_TABLE) {
|
|
||||||
SNode* pTbnameNode = biMakeTbnameProjectAstNode(NULL, pTableAlias);
|
SNode* pTbnameNode = biMakeTbnameProjectAstNode(NULL, pTableAlias);
|
||||||
nodesListAppend(pTbnameNodeList, pTbnameNode);
|
nodesListAppend(pTbnameNodeList, pTbnameNode);
|
||||||
}
|
}
|
||||||
|
@ -2300,16 +2294,16 @@ static int32_t replacePsedudoColumnFuncWithColumn(STranslateContext* pCxt, SNode
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t rewriteToColumnAndRetranslate(STranslateContext* pCxt, SNode** ppNode, int32_t errCode) {
|
static int32_t rewriteToColumnAndRetranslate(STranslateContext* pCxt, SNode** ppNode, int32_t errCode) {
|
||||||
int32_t code = replacePsedudoColumnFuncWithColumn(pCxt, ppNode);
|
int32_t code = replacePsedudoColumnFuncWithColumn(pCxt, ppNode);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
translateColumn(pCxt, (SColumnNode**)ppNode);
|
translateColumn(pCxt, (SColumnNode**)ppNode);
|
||||||
if (pCxt->errCode != TSDB_CODE_SUCCESS) {
|
if (pCxt->errCode != TSDB_CODE_SUCCESS) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, errCode);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, errCode);
|
||||||
} else {
|
} else {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateWindowPseudoColumnFunc(STranslateContext* pCxt, SNode** ppNode, bool* pRewriteToColumn) {
|
static int32_t translateWindowPseudoColumnFunc(STranslateContext* pCxt, SNode** ppNode, bool* pRewriteToColumn) {
|
||||||
|
@ -2844,8 +2838,8 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
|
||||||
if (!pSelect->isDistinct) {
|
if (!pSelect->isDistinct) {
|
||||||
nodesRewriteExprs(pSelect->pOrderByList, doCheckAggColCoexist, &cxt);
|
nodesRewriteExprs(pSelect->pOrderByList, doCheckAggColCoexist, &cxt);
|
||||||
}
|
}
|
||||||
if (((!cxt.existCol && 0 < pSelect->selectFuncNum) || (cxt.existCol && 1 == pSelect->selectFuncNum) )
|
if (((!cxt.existCol && 0 < pSelect->selectFuncNum) || (cxt.existCol && 1 == pSelect->selectFuncNum)) &&
|
||||||
&& !pSelect->hasOtherVectorFunc) {
|
!pSelect->hasOtherVectorFunc) {
|
||||||
return rewriteColsToSelectValFunc(pCxt, pSelect);
|
return rewriteColsToSelectValFunc(pCxt, pSelect);
|
||||||
}
|
}
|
||||||
if (cxt.existCol) {
|
if (cxt.existCol) {
|
||||||
|
@ -4390,8 +4384,8 @@ static bool findEqCondTbNameInOperatorNode(STranslateContext* pCxt, SNode* pWher
|
||||||
} else {
|
} else {
|
||||||
code = findTable(pCxt, pTableAlias, &pTable);
|
code = findTable(pCxt, pTableAlias, &pTable);
|
||||||
}
|
}
|
||||||
if (code == TSDB_CODE_SUCCESS && nodeType(pTable) == QUERY_NODE_REAL_TABLE &&
|
if (code == TSDB_CODE_SUCCESS && nodeType(pTable) == QUERY_NODE_REAL_TABLE && ((SRealTableNode*)pTable)->pMeta &&
|
||||||
((SRealTableNode*)pTable)->pMeta && ((SRealTableNode*)pTable)->pMeta->tableType == TSDB_SUPER_TABLE) {
|
((SRealTableNode*)pTable)->pMeta->tableType == TSDB_SUPER_TABLE) {
|
||||||
pInfo->pRealTable = (SRealTableNode*)pTable;
|
pInfo->pRealTable = (SRealTableNode*)pTable;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -4426,7 +4420,7 @@ static void findEqualCondTbnameInLogicCondAnd(STranslateContext* pCxt, SNode* pW
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//TODO: logic cond
|
// TODO: logic cond
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4657,7 +4651,6 @@ static int32_t createPkColByTable(STranslateContext* pCxt, SRealTableNode* pTabl
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static EDealRes hasPkColImpl(SNode* pNode, void* pContext) {
|
static EDealRes hasPkColImpl(SNode* pNode, void* pContext) {
|
||||||
if (nodeType(pNode) == QUERY_NODE_COLUMN && ((SColumnNode*)pNode)->tableHasPk) {
|
if (nodeType(pNode) == QUERY_NODE_COLUMN && ((SColumnNode*)pNode)->tableHasPk) {
|
||||||
*(bool*)pContext = true;
|
*(bool*)pContext = true;
|
||||||
|
@ -4674,12 +4667,12 @@ static bool hasPkCol(SNode* pNode) {
|
||||||
|
|
||||||
static EDealRes appendPkForPkFuncImpl(SNode* pNode, void* pContext) {
|
static EDealRes appendPkForPkFuncImpl(SNode* pNode, void* pContext) {
|
||||||
STranslateContext* pCxt = pContext;
|
STranslateContext* pCxt = pContext;
|
||||||
STableNode* pTable = NULL;
|
STableNode* pTable = NULL;
|
||||||
int32_t code = findTable(pCxt, NULL, &pTable);
|
int32_t code = findTable(pCxt, NULL, &pTable);
|
||||||
if (TSDB_CODE_SUCCESS == code && QUERY_NODE_REAL_TABLE == nodeType(pTable) && isPkFunc(pNode) && hasPkCol(pNode)) {
|
if (TSDB_CODE_SUCCESS == code && QUERY_NODE_REAL_TABLE == nodeType(pTable) && isPkFunc(pNode) && hasPkCol(pNode)) {
|
||||||
SFunctionNode* pFunc = (SFunctionNode*)pNode;
|
SFunctionNode* pFunc = (SFunctionNode*)pNode;
|
||||||
SRealTableNode* pRealTable = (SRealTableNode*)pTable;
|
SRealTableNode* pRealTable = (SRealTableNode*)pTable;
|
||||||
SNode* pPk = NULL;
|
SNode* pPk = NULL;
|
||||||
pCxt->errCode = createPkColByTable(pCxt, pRealTable, &pPk);
|
pCxt->errCode = createPkColByTable(pCxt, pRealTable, &pPk);
|
||||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||||
pCxt->errCode = nodesListMakeStrictAppend(&pFunc->pParameterList, pPk);
|
pCxt->errCode = nodesListMakeStrictAppend(&pFunc->pParameterList, pPk);
|
||||||
|
@ -4840,7 +4833,7 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = appendPkParamForPkFunc(pCxt, pSelect);
|
code = appendPkParamForPkFunc(pCxt, pSelect);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = replaceOrderByAliasForSelect(pCxt, pSelect);
|
code = replaceOrderByAliasForSelect(pCxt, pSelect);
|
||||||
}
|
}
|
||||||
|
@ -5125,7 +5118,6 @@ static int32_t translateInsertTable(STranslateContext* pCxt, SNode** pTable) {
|
||||||
if (TSDB_CODE_SUCCESS == code && TSDB_CHILD_TABLE != ((SRealTableNode*)*pTable)->pMeta->tableType &&
|
if (TSDB_CODE_SUCCESS == code && TSDB_CHILD_TABLE != ((SRealTableNode*)*pTable)->pMeta->tableType &&
|
||||||
TSDB_NORMAL_TABLE != ((SRealTableNode*)*pTable)->pMeta->tableType) {
|
TSDB_NORMAL_TABLE != ((SRealTableNode*)*pTable)->pMeta->tableType) {
|
||||||
code = buildInvalidOperationMsg(&pCxt->msgBuf, "insert data into super table is not supported");
|
code = buildInvalidOperationMsg(&pCxt->msgBuf, "insert data into super table is not supported");
|
||||||
|
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -6066,10 +6058,8 @@ static int32_t checkTableColsSchema(STranslateContext* pCxt, SHashObj* pHash, in
|
||||||
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SECOND_COL_PK);
|
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SECOND_COL_PK);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && pCol->is_pk &&
|
if (TSDB_CODE_SUCCESS == code && pCol->is_pk &&
|
||||||
!(TSDB_DATA_TYPE_INT == pCol->dataType.type ||
|
!(TSDB_DATA_TYPE_INT == pCol->dataType.type || TSDB_DATA_TYPE_UINT == pCol->dataType.type ||
|
||||||
TSDB_DATA_TYPE_UINT == pCol->dataType.type ||
|
TSDB_DATA_TYPE_BIGINT == pCol->dataType.type || TSDB_DATA_TYPE_UBIGINT == pCol->dataType.type ||
|
||||||
TSDB_DATA_TYPE_BIGINT == pCol->dataType.type ||
|
|
||||||
TSDB_DATA_TYPE_UBIGINT == pCol->dataType.type ||
|
|
||||||
TSDB_DATA_TYPE_VARCHAR == pCol->dataType.type)) {
|
TSDB_DATA_TYPE_VARCHAR == pCol->dataType.type)) {
|
||||||
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_COL_PK_TYPE);
|
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_COL_PK_TYPE);
|
||||||
}
|
}
|
||||||
|
@ -6722,9 +6712,10 @@ static int32_t buildAlterSuperTableReq(STranslateContext* pCxt, SAlterTableStmt*
|
||||||
if (!checkColumnEncode(pStmt->pColOptions->encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
if (!checkColumnEncode(pStmt->pColOptions->encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||||
if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||||
if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||||
int8_t valid = setColCompressByOption(
|
int8_t valid =
|
||||||
pStmt->dataType.type, (uint32_t*)&field.bytes, columnEncodeVal(pStmt->pColOptions->encode),
|
setColCompressByOption(pStmt->dataType.type, columnEncodeVal(pStmt->pColOptions->encode),
|
||||||
columnCompressVal(pStmt->pColOptions->compress), columnLevelVal(pStmt->pColOptions->compressLevel));
|
columnCompressVal(pStmt->pColOptions->compress),
|
||||||
|
columnLevelVal(pStmt->pColOptions->compressLevel), false, (uint32_t*)&field.bytes);
|
||||||
if (!valid) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
if (!valid) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||||
taosArrayPush(pAlterReq->pFields, &field);
|
taosArrayPush(pAlterReq->pFields, &field);
|
||||||
break;
|
break;
|
||||||
|
@ -6806,9 +6797,9 @@ static int32_t checkAlterSuperTableBySchema(STranslateContext* pCxt, SAlterTable
|
||||||
if (TSDB_ALTER_TABLE_DROP_COLUMN == pStmt->alterType ||
|
if (TSDB_ALTER_TABLE_DROP_COLUMN == pStmt->alterType ||
|
||||||
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES == pStmt->alterType ||
|
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES == pStmt->alterType ||
|
||||||
TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME == pStmt->alterType) {
|
TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME == pStmt->alterType) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PK_OP, pStmt->colName);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PK_OP, pStmt->colName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES == pStmt->alterType ||
|
if ((TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES == pStmt->alterType ||
|
||||||
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES == pStmt->alterType) &&
|
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES == pStmt->alterType) &&
|
||||||
(!IS_VAR_DATA_TYPE(pSchema->type) || pSchema->type != pStmt->dataType.type ||
|
(!IS_VAR_DATA_TYPE(pSchema->type) || pSchema->type != pStmt->dataType.type ||
|
||||||
|
@ -8752,7 +8743,8 @@ static int32_t translateCreateView(STranslateContext* pCxt, SCreateViewStmt* pSt
|
||||||
|
|
||||||
int32_t code = validateCreateView(pCxt, pStmt);
|
int32_t code = validateCreateView(pCxt, pStmt);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = (*pCxt->pParseCxt->parseSqlFp)(pCxt->pParseCxt->parseSqlParam, pStmt->dbName, pStmt->pQuerySql, false, NULL, &res);
|
code = (*pCxt->pParseCxt->parseSqlFp)(pCxt->pParseCxt->parseSqlParam, pStmt->dbName, pStmt->pQuerySql, false, NULL,
|
||||||
|
&res);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = collectUseTable(&name, pCxt->pTargetTables);
|
code = collectUseTable(&name, pCxt->pTargetTables);
|
||||||
|
@ -10031,8 +10023,8 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
|
||||||
if (pColDef->pOptions) {
|
if (pColDef->pOptions) {
|
||||||
req.colCmpr.pColCmpr[index].id = index + 1;
|
req.colCmpr.pColCmpr[index].id = index + 1;
|
||||||
int8_t valid = setColCompressByOption(
|
int8_t valid = setColCompressByOption(
|
||||||
pScheam->type, &req.colCmpr.pColCmpr[index].alg, columnEncodeVal(pColDef->pOptions->encode),
|
pScheam->type, columnEncodeVal(pColDef->pOptions->encode), columnCompressVal(pColDef->pOptions->compress),
|
||||||
columnCompressVal(pColDef->pOptions->compress), columnLevelVal(pColDef->pOptions->compressLevel));
|
columnLevelVal(pColDef->pOptions->compressLevel), true, &req.colCmpr.pColCmpr[index].alg);
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
tdDestroySVCreateTbReq(&req);
|
tdDestroySVCreateTbReq(&req);
|
||||||
return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||||
|
@ -10627,9 +10619,9 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
STag* pTag = NULL;
|
STag* pTag = NULL;
|
||||||
SToken token;
|
SToken token;
|
||||||
char tokenBuf[TSDB_MAX_TAGS_LEN];
|
char tokenBuf[TSDB_MAX_TAGS_LEN];
|
||||||
const char* tagStr = pStmt->pVal->literal;
|
const char* tagStr = pStmt->pVal->literal;
|
||||||
NEXT_TOKEN_WITH_PREV(tagStr, token);
|
NEXT_TOKEN_WITH_PREV(tagStr, token);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -10818,9 +10810,9 @@ static int buildAlterTableColumnCompress(STranslateContext* pCxt, SAlterTableStm
|
||||||
if (!checkColumnEncode(pStmt->pColOptions->encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
if (!checkColumnEncode(pStmt->pColOptions->encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||||
if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||||
if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||||
int8_t valid = setColCompressByOption(pSchema->type, &pReq->compress, columnEncodeVal(pStmt->pColOptions->encode),
|
int8_t valid = setColCompressByOption(pSchema->type, columnEncodeVal(pStmt->pColOptions->encode),
|
||||||
columnCompressVal(pStmt->pColOptions->compress),
|
columnCompressVal(pStmt->pColOptions->compress),
|
||||||
columnLevelVal(pStmt->pColOptions->compressLevel));
|
columnLevelVal(pStmt->pColOptions->compressLevel), true, &pReq->compress);
|
||||||
if (!valid) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
if (!valid) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -10936,7 +10928,7 @@ static void destoryAlterTbReq(SVAlterTbReq* pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosArrayDestroy(pReq->pTagArray);
|
taosArrayDestroy(pReq->pTagArray);
|
||||||
if(pReq->tagFree) tTagFree((STag*)pReq->pTagVal);
|
if (pReq->tagFree) tTagFree((STag*)pReq->pTagVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t rewriteAlterTableImpl(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta,
|
static int32_t rewriteAlterTableImpl(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta,
|
||||||
|
@ -10948,9 +10940,8 @@ static int32_t rewriteAlterTableImpl(STranslateContext* pCxt, SAlterTableStmt* p
|
||||||
}
|
}
|
||||||
|
|
||||||
const SSchema* pSchema = getNormalColSchema(pTableMeta, pStmt->colName);
|
const SSchema* pSchema = getNormalColSchema(pTableMeta, pStmt->colName);
|
||||||
if (hasPkInTable(pTableMeta) && pSchema && (pSchema->flags & COL_IS_KEY) &&
|
if (hasPkInTable(pTableMeta) && pSchema && (pSchema->flags & COL_IS_KEY) &&
|
||||||
(TSDB_ALTER_TABLE_DROP_COLUMN == pStmt->alterType ||
|
(TSDB_ALTER_TABLE_DROP_COLUMN == pStmt->alterType || TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES == pStmt->alterType ||
|
||||||
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES == pStmt->alterType ||
|
|
||||||
TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME == pStmt->alterType)) {
|
TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME == pStmt->alterType)) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PK_OP);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PK_OP);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue