support add column compress
This commit is contained in:
parent
c48db6b212
commit
c6407277dc
|
@ -158,19 +158,20 @@ typedef enum _mgmt_table {
|
|||
TSDB_MGMT_TABLE_MAX,
|
||||
} EShowType;
|
||||
|
||||
#define TSDB_ALTER_TABLE_ADD_TAG 1
|
||||
#define TSDB_ALTER_TABLE_DROP_TAG 2
|
||||
#define TSDB_ALTER_TABLE_UPDATE_TAG_NAME 3
|
||||
#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL 4
|
||||
#define TSDB_ALTER_TABLE_ADD_COLUMN 5
|
||||
#define TSDB_ALTER_TABLE_DROP_COLUMN 6
|
||||
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES 7
|
||||
#define TSDB_ALTER_TABLE_UPDATE_TAG_BYTES 8
|
||||
#define TSDB_ALTER_TABLE_UPDATE_OPTIONS 9
|
||||
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME 10
|
||||
#define TSDB_ALTER_TABLE_ADD_TAG_INDEX 11
|
||||
#define TSDB_ALTER_TABLE_DROP_TAG_INDEX 12
|
||||
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS 13
|
||||
#define TSDB_ALTER_TABLE_ADD_TAG 1
|
||||
#define TSDB_ALTER_TABLE_DROP_TAG 2
|
||||
#define TSDB_ALTER_TABLE_UPDATE_TAG_NAME 3
|
||||
#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL 4
|
||||
#define TSDB_ALTER_TABLE_ADD_COLUMN 5
|
||||
#define TSDB_ALTER_TABLE_DROP_COLUMN 6
|
||||
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES 7
|
||||
#define TSDB_ALTER_TABLE_UPDATE_TAG_BYTES 8
|
||||
#define TSDB_ALTER_TABLE_UPDATE_OPTIONS 9
|
||||
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME 10
|
||||
#define TSDB_ALTER_TABLE_ADD_TAG_INDEX 11
|
||||
#define TSDB_ALTER_TABLE_DROP_TAG_INDEX 12
|
||||
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS 13
|
||||
#define TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COMPRESS_OPTION 14
|
||||
|
||||
#define TSDB_FILL_NONE 0
|
||||
#define TSDB_FILL_NULL 1
|
||||
|
@ -2313,10 +2314,10 @@ int32_t tDeserializeSVArbHeartBeatRsp(void* buf, int32_t bufLen, SVArbHeartBeatR
|
|||
void tFreeSVArbHeartBeatRsp(SVArbHeartBeatRsp* pRsp);
|
||||
|
||||
typedef struct {
|
||||
char* arbToken;
|
||||
char* arbToken;
|
||||
int64_t arbTerm;
|
||||
char* member0Token;
|
||||
char* member1Token;
|
||||
char* member0Token;
|
||||
char* member1Token;
|
||||
} SVArbCheckSyncReq;
|
||||
|
||||
int32_t tSerializeSVArbCheckSyncReq(void* buf, int32_t bufLen, SVArbCheckSyncReq* pReq);
|
||||
|
@ -2336,9 +2337,9 @@ int32_t tDeserializeSVArbCheckSyncRsp(void* buf, int32_t bufLen, SVArbCheckSyncR
|
|||
void tFreeSVArbCheckSyncRsp(SVArbCheckSyncRsp* pRsp);
|
||||
|
||||
typedef struct {
|
||||
char* arbToken;
|
||||
int64_t arbTerm;
|
||||
char* memberToken;
|
||||
char* arbToken;
|
||||
int64_t arbTerm;
|
||||
char* memberToken;
|
||||
} SVArbSetAssignedLeaderReq;
|
||||
|
||||
int32_t tSerializeSVArbSetAssignedLeaderReq(void* buf, int32_t bufLen, SVArbSetAssignedLeaderReq* pReq);
|
||||
|
@ -2700,8 +2701,8 @@ typedef struct {
|
|||
int64_t lastTs;
|
||||
SArray* pVgroupVerList;
|
||||
// 3.3.0.0
|
||||
SArray* pCols; // array of SField
|
||||
int64_t smaId;
|
||||
SArray* pCols; // array of SField
|
||||
int64_t smaId;
|
||||
} SCMCreateStreamReq;
|
||||
|
||||
typedef struct {
|
||||
|
@ -3569,7 +3570,7 @@ static FORCE_INLINE void tqOffsetResetToData(STqOffsetVal* pOffsetVal, int64_t u
|
|||
pOffsetVal->type = TMQ_OFFSET__SNAPSHOT_DATA;
|
||||
pOffsetVal->uid = uid;
|
||||
pOffsetVal->ts = ts;
|
||||
if(IS_VAR_DATA_TYPE(pOffsetVal->primaryKey.type)){
|
||||
if (IS_VAR_DATA_TYPE(pOffsetVal->primaryKey.type)) {
|
||||
taosMemoryFree(pOffsetVal->primaryKey.pData);
|
||||
}
|
||||
pOffsetVal->primaryKey = primaryKey;
|
||||
|
@ -3669,10 +3670,10 @@ typedef struct {
|
|||
char* ast;
|
||||
int64_t deleteMark;
|
||||
int64_t lastTs;
|
||||
int64_t normSourceTbUid; // the Uid of source tb if its a normal table, otherwise 0
|
||||
int64_t normSourceTbUid; // the Uid of source tb if its a normal table, otherwise 0
|
||||
SArray* pVgroupVerList;
|
||||
int8_t recursiveTsma;
|
||||
char baseTsmaName[TSDB_TABLE_FNAME_LEN]; // base tsma name for recursively created tsma
|
||||
char baseTsmaName[TSDB_TABLE_FNAME_LEN]; // base tsma name for recursively created tsma
|
||||
} SMCreateSmaReq;
|
||||
|
||||
int32_t tSerializeSMCreateSmaReq(void* buf, int32_t bufLen, SMCreateSmaReq* pReq);
|
||||
|
@ -3901,7 +3902,7 @@ typedef struct {
|
|||
|
||||
int32_t tSerializeSMqPollReq(void* buf, int32_t bufLen, SMqPollReq* pReq);
|
||||
int32_t tDeserializeSMqPollReq(void* buf, int32_t bufLen, SMqPollReq* pReq);
|
||||
void tDestroySMqPollReq(SMqPollReq *pReq);
|
||||
void tDestroySMqPollReq(SMqPollReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
int32_t vgId;
|
||||
|
@ -3945,7 +3946,7 @@ typedef struct {
|
|||
|
||||
int32_t tEncodeMqMetaRsp(SEncoder* pEncoder, const SMqMetaRsp* pRsp);
|
||||
int32_t tDecodeMqMetaRsp(SDecoder* pDecoder, SMqMetaRsp* pRsp);
|
||||
void tDeleteMqMetaRsp(SMqMetaRsp *pRsp);
|
||||
void tDeleteMqMetaRsp(SMqMetaRsp* pRsp);
|
||||
|
||||
#define MQ_DATA_RSP_VERSION 100
|
||||
|
||||
|
@ -4292,9 +4293,9 @@ int32_t tSerializeSViewMetaRsp(void* buf, int32_t bufLen, const SViewMetaRsp* pR
|
|||
int32_t tDeserializeSViewMetaRsp(void* buf, int32_t bufLen, SViewMetaRsp* pRsp);
|
||||
void tFreeSViewMetaRsp(SViewMetaRsp* pRsp);
|
||||
typedef struct {
|
||||
char name[TSDB_TABLE_FNAME_LEN]; // table name or tsma name
|
||||
bool fetchingWithTsmaName; // if we are fetching with tsma name
|
||||
}STableTSMAInfoReq;
|
||||
char name[TSDB_TABLE_FNAME_LEN]; // table name or tsma name
|
||||
bool fetchingWithTsmaName; // if we are fetching with tsma name
|
||||
} STableTSMAInfoReq;
|
||||
|
||||
int32_t tSerializeTableTSMAInfoReq(void* buf, int32_t bufLen, const STableTSMAInfoReq* pReq);
|
||||
int32_t tDeserializeTableTSMAInfoReq(void* buf, int32_t bufLen, STableTSMAInfoReq* pReq);
|
||||
|
@ -4317,15 +4318,15 @@ typedef struct {
|
|||
int32_t version;
|
||||
int64_t interval;
|
||||
int8_t unit;
|
||||
SArray* pFuncs; // SArray<STableTSMAFuncInfo>
|
||||
SArray* pTags; // SArray<SSchema>
|
||||
SArray* pUsedCols; // SArray<SSchema>
|
||||
SArray* pFuncs; // SArray<STableTSMAFuncInfo>
|
||||
SArray* pTags; // SArray<SSchema>
|
||||
SArray* pUsedCols; // SArray<SSchema>
|
||||
char* ast;
|
||||
|
||||
int64_t streamUid;
|
||||
int64_t reqTs;
|
||||
int64_t rspTs;
|
||||
int64_t delayDuration; // ms
|
||||
int64_t delayDuration; // ms
|
||||
bool fillHistoryFinished;
|
||||
} STableTSMAInfo;
|
||||
|
||||
|
@ -4336,10 +4337,10 @@ void tFreeTableTSMAInfo(void* p);
|
|||
void tFreeAndClearTableTSMAInfo(void* p);
|
||||
void tFreeTableTSMAInfoRsp(STableTSMAInfoRsp* pRsp);
|
||||
|
||||
#define STSMAHbRsp STableTSMAInfoRsp
|
||||
#define tSerializeTSMAHbRsp tSerializeTableTSMAInfoRsp
|
||||
#define STSMAHbRsp STableTSMAInfoRsp
|
||||
#define tSerializeTSMAHbRsp tSerializeTableTSMAInfoRsp
|
||||
#define tDeserializeTSMAHbRsp tDeserializeTableTSMAInfoRsp
|
||||
#define tFreeTSMAHbRsp tFreeTableTSMAInfoRsp
|
||||
#define tFreeTSMAHbRsp tFreeTableTSMAInfoRsp
|
||||
|
||||
typedef struct SStreamProgressReq {
|
||||
int64_t streamId;
|
||||
|
@ -4365,7 +4366,7 @@ int32_t tDeserializeSStreamProgressRsp(void* buf, int32_t bufLen, SStreamProgres
|
|||
|
||||
typedef struct SDropCtbWithTsmaSingleVgReq {
|
||||
SVgroupInfo vgInfo;
|
||||
SArray* pTbs; // SVDropTbReq
|
||||
SArray* pTbs; // SVDropTbReq
|
||||
} SMDropTbReqsOnSingleVg;
|
||||
|
||||
int32_t tEncodeSMDropTbReqOnSingleVg(SEncoder* pEncoder, const SMDropTbReqsOnSingleVg* pReq);
|
||||
|
@ -4373,7 +4374,7 @@ int32_t tDecodeSMDropTbReqOnSingleVg(SDecoder* pDecoder, SMDropTbReqsOnSingleVg*
|
|||
void tFreeSMDropTbReqOnSingleVg(void* p);
|
||||
|
||||
typedef struct SDropTbsReq {
|
||||
SArray* pVgReqs; // SMDropTbReqsOnSingleVg
|
||||
SArray* pVgReqs; // SMDropTbReqsOnSingleVg
|
||||
} SMDropTbsReq;
|
||||
|
||||
int32_t tSerializeSMDropTbsReq(void* buf, int32_t bufLen, const SMDropTbsReq* pReq);
|
||||
|
|
|
@ -768,11 +768,22 @@ int32_t tSerializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq)
|
|||
if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->alterType) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->numOfFields) < 0) return -1;
|
||||
|
||||
// if (pReq->alterType == )
|
||||
for (int32_t i = 0; i < pReq->numOfFields; ++i) {
|
||||
SField *pField = taosArrayGet(pReq->pFields, i);
|
||||
if (tEncodeI8(&encoder, pField->type) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pField->bytes) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pField->name) < 0) return -1;
|
||||
if (pReq->alterType == TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COMPRESS_OPTION) {
|
||||
SFieldWithOptions *pField = taosArrayGet(pReq->pFields, i);
|
||||
if (tEncodeI8(&encoder, pField->type) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pField->bytes) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pField->name) < 0) return -1;
|
||||
if (tEncodeU32(&encoder, pField->compress) < 0) return -1;
|
||||
|
||||
} else {
|
||||
SField *pField = taosArrayGet(pReq->pFields, i);
|
||||
if (tEncodeI8(&encoder, pField->type) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pField->bytes) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pField->name) < 0) return -1;
|
||||
}
|
||||
}
|
||||
if (tEncodeI32(&encoder, pReq->ttl) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->commentLen) < 0) return -1;
|
||||
|
@ -802,13 +813,28 @@ int32_t tDeserializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < pReq->numOfFields; ++i) {
|
||||
SField field = {0};
|
||||
if (tDecodeI8(&decoder, &field.type) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &field.bytes) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, field.name) < 0) return -1;
|
||||
if (taosArrayPush(pReq->pFields, &field) == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
if (pReq->alterType == TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COMPRESS_OPTION) {
|
||||
|
||||
taosArrayDestroy(pReq->pFields);
|
||||
pReq->pFields = taosArrayInit(pReq->numOfFields, sizeof(SFieldWithOptions));
|
||||
SFieldWithOptions field = {0};
|
||||
if (tDecodeI8(&decoder, &field.type) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &field.bytes) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, field.name) < 0) return -1;
|
||||
if (tDecodeU32(&decoder, &field.compress) < 0) return -1;
|
||||
if (taosArrayPush(pReq->pFields, &field) == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
SField field = {0};
|
||||
if (tDecodeI8(&decoder, &field.type) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &field.bytes) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, field.name) < 0) return -1;
|
||||
if (taosArrayPush(pReq->pFields, &field) == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8740,6 +8766,13 @@ int32_t tEncodeSVAlterTbReq(SEncoder *pEncoder, const SVAlterTbReq *pReq) {
|
|||
if (tEncodeCStr(pEncoder, pReq->colName) < 0) return -1;
|
||||
if (tEncodeU32(pEncoder, pReq->compress) < 0) return -1;
|
||||
break;
|
||||
case TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COMPRESS_OPTION:
|
||||
if (tEncodeCStr(pEncoder, pReq->colName) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pReq->type) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pReq->flags) < 0) return -1;
|
||||
if (tEncodeI32v(pEncoder, pReq->bytes) < 0) return -1;
|
||||
if (tEncodeU32(pEncoder, pReq->compress) < 0) return -1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -8795,6 +8828,12 @@ static int32_t tDecodeSVAlterTbReqCommon(SDecoder *pDecoder, SVAlterTbReq *pReq)
|
|||
if (tDecodeCStr(pDecoder, &pReq->colName) < 0) return -1;
|
||||
if (tDecodeU32(pDecoder, &pReq->compress) < 0) return -1;
|
||||
break;
|
||||
case TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COMPRESS_OPTION:
|
||||
if (tDecodeCStr(pDecoder, &pReq->colName) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pReq->type) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pReq->flags) < 0) return -1;
|
||||
if (tDecodeI32v(pDecoder, &pReq->bytes) < 0) return -1;
|
||||
if (tDecodeU32(pDecoder, &pReq->compress) < 0) return -1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1779,7 +1779,8 @@ static int32_t mndUpdateSuperTableColumnCompress(SMnode *pMnode, const SStbObj *
|
|||
|
||||
return 0;
|
||||
}
|
||||
static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, SArray *pFields, int32_t ncols) {
|
||||
static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, SArray *pFields, int32_t ncols,
|
||||
int8_t withCompress) {
|
||||
if (pOld->numOfColumns + ncols + pOld->numOfTags > TSDB_MAX_COLUMNS) {
|
||||
terrno = TSDB_CODE_MND_TOO_MANY_COLUMNS;
|
||||
return -1;
|
||||
|
@ -1806,29 +1807,53 @@ static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, SArray
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < ncols; i++) {
|
||||
SField *pField = taosArrayGet(pFields, i);
|
||||
if (mndFindSuperTableColumnIndex(pOld, pField->name) >= 0) {
|
||||
terrno = TSDB_CODE_MND_COLUMN_ALREADY_EXIST;
|
||||
return -1;
|
||||
if (withCompress) {
|
||||
SFieldWithOptions *pField = taosArrayGet(pFields, i);
|
||||
if (mndFindSuperTableColumnIndex(pOld, pField->name) >= 0) {
|
||||
terrno = TSDB_CODE_MND_COLUMN_ALREADY_EXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mndFindSuperTableTagIndex(pOld, pField->name) >= 0) {
|
||||
terrno = TSDB_CODE_MND_TAG_ALREADY_EXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
SSchema *pSchema = &pNew->pColumns[pOld->numOfColumns + i];
|
||||
pSchema->bytes = pField->bytes;
|
||||
pSchema->type = pField->type;
|
||||
memcpy(pSchema->name, pField->name, TSDB_COL_NAME_LEN);
|
||||
pSchema->colId = 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);
|
||||
} else {
|
||||
SField *pField = taosArrayGet(pFields, i);
|
||||
if (mndFindSuperTableColumnIndex(pOld, pField->name) >= 0) {
|
||||
terrno = TSDB_CODE_MND_COLUMN_ALREADY_EXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mndFindSuperTableTagIndex(pOld, pField->name) >= 0) {
|
||||
terrno = TSDB_CODE_MND_TAG_ALREADY_EXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
SSchema *pSchema = &pNew->pColumns[pOld->numOfColumns + i];
|
||||
pSchema->bytes = pField->bytes;
|
||||
pSchema->type = pField->type;
|
||||
memcpy(pSchema->name, pField->name, TSDB_COL_NAME_LEN);
|
||||
pSchema->colId = 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);
|
||||
}
|
||||
|
||||
if (mndFindSuperTableTagIndex(pOld, pField->name) >= 0) {
|
||||
terrno = TSDB_CODE_MND_TAG_ALREADY_EXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
SSchema *pSchema = &pNew->pColumns[pOld->numOfColumns + i];
|
||||
pSchema->bytes = pField->bytes;
|
||||
pSchema->type = pField->type;
|
||||
memcpy(pSchema->name, pField->name, TSDB_COL_NAME_LEN);
|
||||
pSchema->colId = 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);
|
||||
}
|
||||
|
||||
pNew->colVer++;
|
||||
|
@ -2461,7 +2486,7 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
|
|||
code = mndAlterStbTagBytes(pMnode, pOld, &stbObj, pField0);
|
||||
break;
|
||||
case TSDB_ALTER_TABLE_ADD_COLUMN:
|
||||
code = mndAddSuperTableColumn(pOld, &stbObj, pAlter->pFields, pAlter->numOfFields);
|
||||
code = mndAddSuperTableColumn(pOld, &stbObj, pAlter->pFields, pAlter->numOfFields, 0);
|
||||
break;
|
||||
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
||||
pField0 = taosArrayGet(pAlter->pFields, 0);
|
||||
|
@ -2478,6 +2503,9 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
|
|||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS:
|
||||
code = mndUpdateSuperTableColumnCompress(pMnode, pOld, &stbObj, pAlter->pFields, pAlter->numOfFields);
|
||||
break;
|
||||
case TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COMPRESS_OPTION:
|
||||
code = mndAddSuperTableColumn(pOld, &stbObj, pAlter->pFields, pAlter->numOfFields, 1);
|
||||
break;
|
||||
default:
|
||||
needRsp = false;
|
||||
terrno = TSDB_CODE_OPS_NOT_SUPPORT;
|
||||
|
|
|
@ -1491,6 +1491,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
SSchema tScheam;
|
||||
switch (pAlterTbReq->action) {
|
||||
case TSDB_ALTER_TABLE_ADD_COLUMN:
|
||||
case TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COMPRESS_OPTION:
|
||||
if (pColumn) {
|
||||
terrno = TSDB_CODE_VND_COL_ALREADY_EXISTS;
|
||||
goto _err;
|
||||
|
@ -1522,10 +1523,21 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
(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;
|
||||
ASSERT(entry.colCmpr.nCols == pSchema->nCols);
|
||||
break;
|
||||
if (pAlterTbReq->action == TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COMPRESS_OPTION) {
|
||||
|
||||
// if (pAlterTbReq->colCmpr.nCols != pSchema->nCols) {
|
||||
// terrno = TSDB_CODE_VND_INVALID_TABLE_ACTION;
|
||||
// goto _err;
|
||||
// }
|
||||
// updataTableColCmpr(&entry.colCmpr, pCol, 1);
|
||||
// freeColCmpr = true;
|
||||
// ASSERT(entry.colCmpr.nCols == pSchema->nCols);
|
||||
} else {
|
||||
updataTableColCmpr(&entry.colCmpr, pCol, 1);
|
||||
freeColCmpr = true;
|
||||
ASSERT(entry.colCmpr.nCols == pSchema->nCols);
|
||||
break;
|
||||
}
|
||||
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
||||
if (pColumn == NULL) {
|
||||
terrno = TSDB_CODE_VND_COL_NOT_EXISTS;
|
||||
|
|
|
@ -118,44 +118,46 @@ SToken getTokenFromRawExprNode(SAstCreateContext* pCxt, SNode* pNode);
|
|||
SNodeList* createNodeList(SAstCreateContext* pCxt, SNode* pNode);
|
||||
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);
|
||||
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);
|
||||
SNode* createTimeOffsetValueNode(SAstCreateContext* pCxt, const SToken* pLiteral);
|
||||
SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt);
|
||||
SNode* createPlaceholderValueNode(SAstCreateContext* pCxt, const SToken* pLiteral);
|
||||
SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, SToken* pAlias);
|
||||
SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType type, SNode* pParam1, SNode* pParam2);
|
||||
SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pLeft, SNode* pRight);
|
||||
SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
|
||||
SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
|
||||
SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList);
|
||||
SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType dt);
|
||||
SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList);
|
||||
SNode* createNodeListNodeEx(SAstCreateContext* pCxt, SNode* p1, SNode* p2);
|
||||
SNode* createRealTableNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pTableName, SToken* pTableAlias);
|
||||
SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const SToken* pTableAlias);
|
||||
SNode* createJoinTableNode(SAstCreateContext* pCxt, EJoinType type, EJoinSubType stype, SNode* pLeft, SNode* pRight, SNode* pJoinCond);
|
||||
SNode* createViewNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pViewName);
|
||||
SNode* createLimitNode(SAstCreateContext* pCxt, const SToken* pLimit, const SToken* pOffset);
|
||||
SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order, ENullOrder nullOrder);
|
||||
SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, SNode* pGap);
|
||||
SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr);
|
||||
SNode* createEventWindowNode(SAstCreateContext* pCxt, SNode* pStartCond, SNode* pEndCond);
|
||||
SNode* createCountWindowNode(SAstCreateContext* pCxt, const SToken* pCountToken, const SToken* pSlidingToken);
|
||||
SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode* pOffset, SNode* pSliding,
|
||||
SNode* pFill);
|
||||
SNode* createWindowOffsetNode(SAstCreateContext* pCxt, SNode* pStartOffset, SNode* pEndOffset);
|
||||
SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues);
|
||||
SNode* createGroupingSetNode(SAstCreateContext* pCxt, SNode* pNode);
|
||||
SNode* createInterpTimeRange(SAstCreateContext* pCxt, SNode* pStart, SNode* pEnd);
|
||||
SNode* createInterpTimePoint(SAstCreateContext* pCxt, SNode* pPoint);
|
||||
SNode* createWhenThenNode(SAstCreateContext* pCxt, SNode* pWhen, SNode* pThen);
|
||||
SNode* createCaseWhenNode(SAstCreateContext* pCxt, SNode* pCase, SNodeList* pWhenThenList, SNode* pElse);
|
||||
SNode* createIdentifierValueNode(SAstCreateContext* pCxt, SToken* pLiteral);
|
||||
SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral);
|
||||
SNode* createTimeOffsetValueNode(SAstCreateContext* pCxt, const SToken* pLiteral);
|
||||
SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt);
|
||||
SNode* createPlaceholderValueNode(SAstCreateContext* pCxt, const SToken* pLiteral);
|
||||
SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, SToken* pAlias);
|
||||
SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType type, SNode* pParam1, SNode* pParam2);
|
||||
SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pLeft, SNode* pRight);
|
||||
SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
|
||||
SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
|
||||
SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList);
|
||||
SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType dt);
|
||||
SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList);
|
||||
SNode* createNodeListNodeEx(SAstCreateContext* pCxt, SNode* p1, SNode* p2);
|
||||
SNode* createRealTableNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pTableName, SToken* pTableAlias);
|
||||
SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const SToken* pTableAlias);
|
||||
SNode* createJoinTableNode(SAstCreateContext* pCxt, EJoinType type, EJoinSubType stype, SNode* pLeft, SNode* pRight,
|
||||
SNode* pJoinCond);
|
||||
SNode* createViewNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pViewName);
|
||||
SNode* createLimitNode(SAstCreateContext* pCxt, const SToken* pLimit, const SToken* pOffset);
|
||||
SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order, ENullOrder nullOrder);
|
||||
SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, SNode* pGap);
|
||||
SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr);
|
||||
SNode* createEventWindowNode(SAstCreateContext* pCxt, SNode* pStartCond, SNode* pEndCond);
|
||||
SNode* createCountWindowNode(SAstCreateContext* pCxt, const SToken* pCountToken, const SToken* pSlidingToken);
|
||||
SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode* pOffset, SNode* pSliding,
|
||||
SNode* pFill);
|
||||
SNode* createWindowOffsetNode(SAstCreateContext* pCxt, SNode* pStartOffset, SNode* pEndOffset);
|
||||
SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues);
|
||||
SNode* createGroupingSetNode(SAstCreateContext* pCxt, SNode* pNode);
|
||||
SNode* createInterpTimeRange(SAstCreateContext* pCxt, SNode* pStart, SNode* pEnd);
|
||||
SNode* createInterpTimePoint(SAstCreateContext* pCxt, SNode* pPoint);
|
||||
SNode* createWhenThenNode(SAstCreateContext* pCxt, SNode* pWhen, SNode* pThen);
|
||||
SNode* createCaseWhenNode(SAstCreateContext* pCxt, SNode* pCase, SNodeList* pWhenThenList, SNode* pElse);
|
||||
|
||||
SNode* addWhereClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pWhere);
|
||||
SNode* addPartitionByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pPartitionByList);
|
||||
|
@ -170,7 +172,8 @@ SNode* addEveryClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pEvery);
|
|||
SNode* addFillClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pFill);
|
||||
SNode* addJLimitClause(SAstCreateContext* pCxt, SNode* pJoin, SNode* pJLimit);
|
||||
SNode* addWindowOffsetClause(SAstCreateContext* pCxt, SNode* pJoin, SNode* pWinOffset);
|
||||
SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pProjectionList, SNode* pTable, SNodeList* pHint);
|
||||
SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pProjectionList, SNode* pTable,
|
||||
SNodeList* pHint);
|
||||
SNode* setSelectStmtTagMode(SAstCreateContext* pCxt, SNode* pStmt, bool bSelectTags);
|
||||
SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* pLeft, SNode* pRight);
|
||||
|
||||
|
@ -205,8 +208,12 @@ SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool ignoreNotExists, S
|
|||
SNode* createAlterTableModifyOptions(SAstCreateContext* pCxt, SNode* pRealTable, SNode* pOptions);
|
||||
SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, SToken* pColName,
|
||||
SDataType dataType);
|
||||
SNode* createAlterTableAddModifyColOptions(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, SToken* pColName,
|
||||
SNode* pOptions);
|
||||
|
||||
SNode* createAlterTableAddModifyColOptions2(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType,
|
||||
SToken* pColName, SDataType dataType, SNode* pOptions);
|
||||
|
||||
SNode* createAlterTableAddModifyColOptions(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType,
|
||||
SToken* pColName, SNode* pOptions);
|
||||
SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, SToken* pColName);
|
||||
SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, SToken* pOldColName,
|
||||
SToken* pNewColName);
|
||||
|
@ -217,7 +224,8 @@ SNode* setShowKind(SAstCreateContext* pCxt, SNode* pStmt, EShowKind showKind);
|
|||
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type);
|
||||
SNode* createShowStmtWithCond(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbName,
|
||||
EOperatorType tableCondType);
|
||||
SNode* createShowTablesStmt(SAstCreateContext* pCxt, SShowTablesOption option, SNode* pTbName, EOperatorType tableCondType);
|
||||
SNode* createShowTablesStmt(SAstCreateContext* pCxt, SShowTablesOption option, SNode* pTbName,
|
||||
EOperatorType tableCondType);
|
||||
SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
|
||||
SNode* createShowAliveStmt(SAstCreateContext* pCxt, SNode* pDbName, ENodeType type);
|
||||
SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable);
|
||||
|
|
|
@ -353,7 +353,7 @@ cmd ::= ALTER STABLE alter_table_clause(A).
|
|||
|
||||
alter_table_clause(A) ::= full_table_name(B) alter_table_options(C). { A = createAlterTableModifyOptions(pCxt, B, C); }
|
||||
alter_table_clause(A) ::=
|
||||
full_table_name(B) ADD COLUMN column_name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, D); }
|
||||
full_table_name(B) ADD COLUMN column_name(C) type_name(D) column_options(E). { A = createAlterTableAddModifyColOptions2(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, D, E); }
|
||||
alter_table_clause(A) ::= full_table_name(B) DROP COLUMN column_name(C). { A = createAlterTableDropCol(pCxt, B, TSDB_ALTER_TABLE_DROP_COLUMN, &C); }
|
||||
alter_table_clause(A) ::=
|
||||
full_table_name(B) MODIFY COLUMN column_name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &C, D); }
|
||||
|
|
|
@ -176,7 +176,8 @@ static bool checkDbName(SAstCreateContext* pCxt, SToken* pDbName, bool demandDb)
|
|||
|
||||
static bool checkTableName(SAstCreateContext* pCxt, SToken* pTableName) {
|
||||
trimEscape(pTableName);
|
||||
if (NULL != pTableName && pTableName->type != TK_NK_NIL && (pTableName->n >= TSDB_TABLE_NAME_LEN || pTableName->n == 0)) {
|
||||
if (NULL != pTableName && pTableName->type != TK_NK_NIL &&
|
||||
(pTableName->n >= TSDB_TABLE_NAME_LEN || pTableName->n == 0)) {
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pTableName->z);
|
||||
return false;
|
||||
}
|
||||
|
@ -185,7 +186,8 @@ static bool checkTableName(SAstCreateContext* pCxt, SToken* pTableName) {
|
|||
|
||||
static bool checkColumnName(SAstCreateContext* pCxt, SToken* pColumnName) {
|
||||
trimEscape(pColumnName);
|
||||
if (NULL != pColumnName && pColumnName->type != TK_NK_NIL && (pColumnName->n >= TSDB_COL_NAME_LEN || pColumnName->n == 0)) {
|
||||
if (NULL != pColumnName && pColumnName->type != TK_NK_NIL &&
|
||||
(pColumnName->n >= TSDB_COL_NAME_LEN || pColumnName->n == 0)) {
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pColumnName->z);
|
||||
return false;
|
||||
}
|
||||
|
@ -1893,6 +1895,24 @@ SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable,
|
|||
pStmt->dataType = dataType;
|
||||
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
||||
}
|
||||
SNode* createAlterTableAddModifyColOptions2(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType,
|
||||
SToken* pColName, SDataType dataType, SNode* pOptions) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
if (!checkColumnName(pCxt, pColName)) {
|
||||
return NULL;
|
||||
}
|
||||
SAlterTableStmt* pStmt = (SAlterTableStmt*)nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->alterType = alterType;
|
||||
COPY_STRING_FORM_ID_TOKEN(pStmt->colName, pColName);
|
||||
pStmt->dataType = dataType;
|
||||
|
||||
if (pOptions != NULL) {
|
||||
pStmt->alterType = TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COMPRESS_OPTION;
|
||||
}
|
||||
pStmt->pColOptions = (SColumnOptions*)pOptions;
|
||||
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
||||
}
|
||||
|
||||
SNode* createAlterTableAddModifyColOptions(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType,
|
||||
SToken* pColName, SNode* pOptions) {
|
||||
|
@ -2816,9 +2836,10 @@ SNode* createBalanceVgroupLeaderStmt(SAstCreateContext* pCxt, const SToken* pVgI
|
|||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createBalanceVgroupLeaderDBNameStmt(SAstCreateContext* pCxt, const SToken* pDbName){
|
||||
SNode* createBalanceVgroupLeaderDBNameStmt(SAstCreateContext* pCxt, const SToken* pDbName) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SBalanceVgroupLeaderStmt* pStmt = (SBalanceVgroupLeaderStmt*)nodesMakeNode(QUERY_NODE_BALANCE_VGROUP_LEADER_DATABASE_STMT);
|
||||
SBalanceVgroupLeaderStmt* pStmt =
|
||||
(SBalanceVgroupLeaderStmt*)nodesMakeNode(QUERY_NODE_BALANCE_VGROUP_LEADER_DATABASE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
if (NULL != pDbName) {
|
||||
COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName);
|
||||
|
|
|
@ -1003,7 +1003,7 @@ static bool isBlockTimeLineAlignedQuery(SNode* pStmt) {
|
|||
|
||||
SNodeList* buildPartitionListFromOrderList(SNodeList* pOrderList, int32_t nodesNum) {
|
||||
SNodeList* pPartitionList = NULL;
|
||||
SNode* pNode = NULL;
|
||||
SNode* pNode = NULL;
|
||||
if (pOrderList->length <= nodesNum) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1023,7 +1023,6 @@ SNodeList* buildPartitionListFromOrderList(SNodeList* pOrderList, int32_t nodesN
|
|||
return pPartitionList;
|
||||
}
|
||||
|
||||
|
||||
static bool isTimeLineAlignedQuery(SNode* pStmt) {
|
||||
SSelectStmt* pSelect = (SSelectStmt*)pStmt;
|
||||
if (!isTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery)) {
|
||||
|
@ -1036,7 +1035,8 @@ static bool isTimeLineAlignedQuery(SNode* pStmt) {
|
|||
return true;
|
||||
}
|
||||
if (pSub->timeLineFromOrderBy && pSub->pOrderByList->length > 1) {
|
||||
SNodeList* pPartitionList = buildPartitionListFromOrderList(pSub->pOrderByList, pSelect->pPartitionByList->length);
|
||||
SNodeList* pPartitionList =
|
||||
buildPartitionListFromOrderList(pSub->pOrderByList, pSelect->pPartitionByList->length);
|
||||
bool match = nodesListMatch(pSelect->pPartitionByList, pPartitionList);
|
||||
nodesDestroyList(pPartitionList);
|
||||
|
||||
|
@ -1049,7 +1049,8 @@ static bool isTimeLineAlignedQuery(SNode* pStmt) {
|
|||
if (QUERY_NODE_SET_OPERATOR == nodeType(((STempTableNode*)pSelect->pFromTable)->pSubquery)) {
|
||||
SSetOperator* pSub = (SSetOperator*)((STempTableNode*)pSelect->pFromTable)->pSubquery;
|
||||
if (pSelect->pPartitionByList && pSub->timeLineFromOrderBy && pSub->pOrderByList->length > 1) {
|
||||
SNodeList* pPartitionList = buildPartitionListFromOrderList(pSub->pOrderByList, pSelect->pPartitionByList->length);
|
||||
SNodeList* pPartitionList =
|
||||
buildPartitionListFromOrderList(pSub->pOrderByList, pSelect->pPartitionByList->length);
|
||||
bool match = nodesListMatch(pSelect->pPartitionByList, pPartitionList);
|
||||
nodesDestroyList(pPartitionList);
|
||||
|
||||
|
@ -6083,7 +6084,7 @@ static void resetResultTimeline(SSelectStmt* pSelect) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pSelect->timeLineResMode = TIME_LINE_NONE;
|
||||
}
|
||||
|
||||
|
@ -6237,8 +6238,8 @@ static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pS
|
|||
}
|
||||
snprintf(pRightExpr->aliasName, sizeof(pRightExpr->aliasName), "%s", pLeftExpr->aliasName);
|
||||
SNode* pProj = createSetOperProject(pSetOperator->stmtName, pLeft);
|
||||
bool isLeftPrimTs = isPrimaryKeyImpl(pLeft);
|
||||
bool isRightPrimTs = isPrimaryKeyImpl(pRight);
|
||||
bool isLeftPrimTs = isPrimaryKeyImpl(pLeft);
|
||||
bool isRightPrimTs = isPrimaryKeyImpl(pRight);
|
||||
|
||||
if (isLeftPrimTs && isRightPrimTs) {
|
||||
SColumnNode* pFCol = (SColumnNode*)pProj;
|
||||
|
@ -6288,9 +6289,9 @@ static int32_t translateSetOperOrderBy(STranslateContext* pCxt, SSetOperator* pS
|
|||
pSetOperator->timeLineFromOrderBy = true;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pSetOperator->timeLineResMode = TIME_LINE_NONE;
|
||||
}
|
||||
return code;
|
||||
|
@ -8156,9 +8157,9 @@ static int32_t buildAlterSuperTableReq(STranslateContext* pCxt, SAlterTableStmt*
|
|||
}
|
||||
|
||||
switch (pStmt->alterType) {
|
||||
case TSDB_ALTER_TABLE_ADD_COLUMN:
|
||||
case TSDB_ALTER_TABLE_ADD_TAG:
|
||||
case TSDB_ALTER_TABLE_DROP_TAG:
|
||||
case TSDB_ALTER_TABLE_ADD_COLUMN:
|
||||
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
||||
case TSDB_ALTER_TABLE_UPDATE_TAG_BYTES: {
|
||||
|
@ -8193,6 +8194,28 @@ static int32_t buildAlterSuperTableReq(STranslateContext* pCxt, SAlterTableStmt*
|
|||
taosArrayPush(pAlterReq->pFields, &field);
|
||||
break;
|
||||
}
|
||||
case TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COMPRESS_OPTION: {
|
||||
taosArrayDestroy(pAlterReq->pFields);
|
||||
|
||||
pAlterReq->pFields = taosArrayInit(1, sizeof(SFieldWithOptions));
|
||||
SFieldWithOptions field = {.type = pStmt->dataType.type, .bytes = calcTypeBytes(pStmt->dataType)};
|
||||
// TAOS_FIELD field = {.type = pStmt->dataType.type, .bytes = calcTypeBytes(pStmt->dataType)};
|
||||
strcpy(field.name, pStmt->colName);
|
||||
if (pStmt->pColOptions != NULL) {
|
||||
if (!checkColumnEncode(pStmt->pColOptions->encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_COMPRESS_PARAM_ERROR;
|
||||
if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR;
|
||||
int32_t code = setColCompressByOption(pStmt->dataType.type, columnEncodeVal(pStmt->pColOptions->encode),
|
||||
columnCompressVal(pStmt->pColOptions->compress),
|
||||
columnLevelVal(pStmt->pColOptions->compressLevel), false,
|
||||
(uint32_t*)&field.compress);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
taosArrayPush(pAlterReq->pFields, &field);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -10642,7 +10665,7 @@ static int32_t translateBalanceVgroup(STranslateContext* pCxt, SBalanceVgroupStm
|
|||
static int32_t translateBalanceVgroupLeader(STranslateContext* pCxt, SBalanceVgroupLeaderStmt* pStmt) {
|
||||
SBalanceVgroupLeaderReq req = {0};
|
||||
req.vgId = pStmt->vgId;
|
||||
if(pStmt->dbName != NULL) strcpy(req.db, pStmt->dbName);
|
||||
if (pStmt->dbName != NULL) strcpy(req.db, pStmt->dbName);
|
||||
int32_t code =
|
||||
buildCmdMsg(pCxt, TDMT_MND_BALANCE_VGROUP_LEADER, (FSerializeFunc)tSerializeSBalanceVgroupLeaderReq, &req);
|
||||
tFreeSBalanceVgroupLeaderReq(&req);
|
||||
|
@ -11057,7 +11080,8 @@ static int32_t buildCreateTSMAReq(STranslateContext* pCxt, SCreateTSMAStmt* pStm
|
|||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pReq->deleteMark = convertTimePrecision(tsmaDataDeleteMark, TSDB_TIME_PRECISION_MILLI, pTableMeta->tableInfo.precision);
|
||||
pReq->deleteMark =
|
||||
convertTimePrecision(tsmaDataDeleteMark, TSDB_TIME_PRECISION_MILLI, pTableMeta->tableInfo.precision);
|
||||
code = getSmaIndexSql(pCxt, &pReq->sql, &pReq->sqlLen);
|
||||
}
|
||||
|
||||
|
@ -12857,6 +12881,11 @@ static int32_t buildAddColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, S
|
|||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ROW_LENGTH, TSDB_MAX_BYTES_PER_ROW);
|
||||
}
|
||||
|
||||
// only super and normal support
|
||||
if (pStmt->pColOptions != NULL && TSDB_CHILD_TABLE == pTableMeta->tableType) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE);
|
||||
}
|
||||
|
||||
pReq->colName = taosStrdup(pStmt->colName);
|
||||
if (NULL == pReq->colName) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -12865,6 +12894,15 @@ static int32_t buildAddColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, S
|
|||
pReq->type = pStmt->dataType.type;
|
||||
pReq->flags = COL_SMA_ON;
|
||||
pReq->bytes = calcTypeBytes(pStmt->dataType);
|
||||
if (pStmt->pColOptions != NULL) {
|
||||
if (!checkColumnEncode(pStmt->pColOptions->encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_COMPRESS_PARAM_ERROR;
|
||||
if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR;
|
||||
int8_t code = setColCompressByOption(pReq->type, columnEncodeVal(pStmt->pColOptions->encode),
|
||||
columnCompressVal(pStmt->pColOptions->compress),
|
||||
columnLevelVal(pStmt->pColOptions->compressLevel), true, &pReq->compress);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue