commit
099f6f9e76
|
@ -278,10 +278,13 @@ void* tDeserializeSMDropStbReq(void* buf, SMDropStbReq* pReq);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TABLE_FNAME_LEN];
|
char name[TSDB_TABLE_FNAME_LEN];
|
||||||
int8_t alterType;
|
int8_t alterType;
|
||||||
int32_t numOfSchemas;
|
int32_t numOfFields;
|
||||||
SSchema pSchemas[];
|
SArray* pFields;
|
||||||
} SMAltertbReq;
|
} SMAltertbReq;
|
||||||
|
|
||||||
|
int32_t tSerializeSMAlterStbReq(void** buf, SMAltertbReq* pReq);
|
||||||
|
void* tDeserializeSMAlterStbReq(void* buf, SMAltertbReq* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t pid;
|
int32_t pid;
|
||||||
char app[TSDB_APP_NAME_LEN];
|
char app[TSDB_APP_NAME_LEN];
|
||||||
|
|
|
@ -415,3 +415,45 @@ void *tDeserializeSMDropStbReq(void *buf, SMDropStbReq *pReq) {
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSMAlterStbReq(void **buf, SMAltertbReq *pReq) {
|
||||||
|
int32_t tlen = 0;
|
||||||
|
|
||||||
|
tlen += taosEncodeString(buf, pReq->name);
|
||||||
|
tlen += taosEncodeFixedI8(buf, pReq->alterType);
|
||||||
|
tlen += taosEncodeFixedI32(buf, pReq->numOfFields);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pReq->numOfFields; ++i) {
|
||||||
|
SField *pField = taosArrayGet(pReq->pFields, i);
|
||||||
|
tlen += taosEncodeFixedU8(buf, pField->type);
|
||||||
|
tlen += taosEncodeFixedI32(buf, pField->bytes);
|
||||||
|
tlen += taosEncodeString(buf, pField->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *tDeserializeSMAlterStbReq(void *buf, SMAltertbReq *pReq) {
|
||||||
|
buf = taosDecodeStringTo(buf, pReq->name);
|
||||||
|
buf = taosDecodeFixedI8(buf, &pReq->alterType);
|
||||||
|
buf = taosDecodeFixedI32(buf, &pReq->numOfFields);
|
||||||
|
|
||||||
|
pReq->pFields = taosArrayInit(pReq->numOfFields, sizeof(SField));
|
||||||
|
if (pReq->pFields == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pReq->numOfFields; ++i) {
|
||||||
|
SField field = {0};
|
||||||
|
buf = taosDecodeFixedU8(buf, &field.type);
|
||||||
|
buf = taosDecodeFixedI32(buf, &field.bytes);
|
||||||
|
buf = taosDecodeStringTo(buf, field.name);
|
||||||
|
if (taosArrayPush(pReq->pFields, &field) == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
|
@ -601,26 +601,23 @@ static int32_t mndProcessVCreateStbRsp(SMnodeMsg *pRsp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndCheckAlterStbReq(SMAltertbReq *pAlter) {
|
static int32_t mndCheckAlterStbReq(SMAltertbReq *pAlter) {
|
||||||
pAlter->numOfSchemas = htonl(pAlter->numOfSchemas);
|
if (pAlter->numOfFields < 1 || pAlter->numOfFields != (int32_t)taosArrayGetSize(pAlter->pFields)) {
|
||||||
|
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < pAlter->numOfSchemas; ++i) {
|
for (int32_t i = 0; i < pAlter->numOfFields; ++i) {
|
||||||
SSchema *pSchema = &pAlter->pSchemas[i];
|
SField *pField = taosArrayGet(pAlter->pFields, i);
|
||||||
pSchema->colId = htonl(pSchema->colId);
|
|
||||||
pSchema->bytes = htonl(pSchema->bytes);
|
|
||||||
|
|
||||||
if (pSchema->type <= 0) {
|
if (pField->type <= 0) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (pSchema->colId < 0 || pSchema->colId >= (TSDB_MAX_COLUMNS + TSDB_MAX_TAGS)) {
|
if (pField->bytes <= 0) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (pSchema->bytes <= 0) {
|
if (pField->name[0] == 0) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (pSchema->name[0] == 0) {
|
|
||||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -662,7 +659,7 @@ static int32_t mndAllocStbSchemas(const SStbObj *pOld, SStbObj *pNew) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndAddSuperTableTag(const SStbObj *pOld, SStbObj *pNew, const SSchema *pSchemas, int32_t ntags) {
|
static int32_t mndAddSuperTableTag(const SStbObj *pOld, SStbObj *pNew, SArray *pFields, int32_t ntags) {
|
||||||
if (pOld->numOfTags + ntags > TSDB_MAX_TAGS) {
|
if (pOld->numOfTags + ntags > TSDB_MAX_TAGS) {
|
||||||
terrno = TSDB_CODE_MND_TOO_MANY_TAGS;
|
terrno = TSDB_CODE_MND_TOO_MANY_TAGS;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -673,33 +670,34 @@ static int32_t mndAddSuperTableTag(const SStbObj *pOld, SStbObj *pNew, const SSc
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < ntags; i++) {
|
|
||||||
if (mndFindSuperTableColumnIndex(pOld, pSchemas[i].name) > 0) {
|
|
||||||
terrno = TSDB_CODE_MND_COLUMN_ALREADY_EXIST;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndFindSuperTableTagIndex(pOld, pSchemas[i].name) > 0) {
|
|
||||||
terrno = TSDB_CODE_MND_TAG_ALREADY_EXIST;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pNew->numOfTags = pNew->numOfTags + ntags;
|
pNew->numOfTags = pNew->numOfTags + ntags;
|
||||||
if (mndAllocStbSchemas(pOld, pNew) != 0) {
|
if (mndAllocStbSchemas(pOld, pNew) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(pNew->pTags + pOld->numOfTags, pSchemas, sizeof(SSchema) * ntags);
|
for (int32_t i = 0; i < ntags; i++) {
|
||||||
|
SField *pField = taosArrayGet(pFields, i);
|
||||||
|
if (mndFindSuperTableColumnIndex(pOld, pField->name) > 0) {
|
||||||
|
terrno = TSDB_CODE_MND_COLUMN_ALREADY_EXIST;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t i = pOld->numOfTags; i < pNew->numOfTags; i++) {
|
if (mndFindSuperTableTagIndex(pOld, pField->name) > 0) {
|
||||||
SSchema *pSchema = &pNew->pTags[i];
|
terrno = TSDB_CODE_MND_TAG_ALREADY_EXIST;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSchema *pSchema = &pNew->pTags[pOld->numOfTags + i];
|
||||||
|
pSchema->bytes = pField->bytes;
|
||||||
|
pSchema->type = pField->type;
|
||||||
|
memcpy(pSchema->name, pField->name, TSDB_COL_NAME_LEN);
|
||||||
pSchema->colId = pNew->nextColId;
|
pSchema->colId = pNew->nextColId;
|
||||||
pNew->nextColId++;
|
pNew->nextColId++;
|
||||||
|
|
||||||
|
mDebug("stb:%s, start to add tag %s", pNew->name, pSchema->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
pNew->version++;
|
pNew->version++;
|
||||||
mDebug("stb:%s, start to add tag %s", pNew->name, pSchemas[0].name);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -722,7 +720,18 @@ static int32_t mndDropSuperTableTag(const SStbObj *pOld, SStbObj *pNew, const ch
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndAlterStbTagName(const SStbObj *pOld, SStbObj *pNew, const char *oldTagName, const char *newTagName) {
|
static int32_t mndAlterStbTagName(const SStbObj *pOld, SStbObj *pNew, SArray *pFields) {
|
||||||
|
if ((int32_t)taosArrayGetSize(pFields) != 2) {
|
||||||
|
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SField *pField0 = taosArrayGet(pFields, 0);
|
||||||
|
SField *pField1 = taosArrayGet(pFields, 1);
|
||||||
|
|
||||||
|
const char *oldTagName = pField0->name;
|
||||||
|
const char *newTagName = pField1->name;
|
||||||
|
|
||||||
int32_t tag = mndFindSuperTableTagIndex(pOld, oldTagName);
|
int32_t tag = mndFindSuperTableTagIndex(pOld, oldTagName);
|
||||||
if (tag < 0) {
|
if (tag < 0) {
|
||||||
terrno = TSDB_CODE_MND_TAG_NOT_EXIST;
|
terrno = TSDB_CODE_MND_TAG_NOT_EXIST;
|
||||||
|
@ -751,8 +760,8 @@ static int32_t mndAlterStbTagName(const SStbObj *pOld, SStbObj *pNew, const char
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndAlterStbTagBytes(const SStbObj *pOld, SStbObj *pNew, const SSchema *pSchema) {
|
static int32_t mndAlterStbTagBytes(const SStbObj *pOld, SStbObj *pNew, const SField *pField) {
|
||||||
int32_t tag = mndFindSuperTableTagIndex(pOld, pSchema->name);
|
int32_t tag = mndFindSuperTableTagIndex(pOld, pField->name);
|
||||||
if (tag < 0) {
|
if (tag < 0) {
|
||||||
terrno = TSDB_CODE_MND_TAG_NOT_EXIST;
|
terrno = TSDB_CODE_MND_TAG_NOT_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -769,51 +778,52 @@ static int32_t mndAlterStbTagBytes(const SStbObj *pOld, SStbObj *pNew, const SSc
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSchema->bytes <= pTag->bytes) {
|
if (pField->bytes <= pTag->bytes) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_ROW_BYTES;
|
terrno = TSDB_CODE_MND_INVALID_ROW_BYTES;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTag->bytes = pSchema->bytes;
|
pTag->bytes = pField->bytes;
|
||||||
pNew->version++;
|
pNew->version++;
|
||||||
|
|
||||||
mDebug("stb:%s, start to modify tag len %s to %d", pNew->name, pSchema->name, pSchema->bytes);
|
mDebug("stb:%s, start to modify tag len %s to %d", pNew->name, pField->name, pField->bytes);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, const SSchema *pSchemas, int32_t ncols) {
|
static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, SArray *pFields, int32_t ncols) {
|
||||||
if (pOld->numOfColumns + ncols + pOld->numOfTags > TSDB_MAX_COLUMNS) {
|
if (pOld->numOfColumns + ncols + pOld->numOfTags > TSDB_MAX_COLUMNS) {
|
||||||
terrno = TSDB_CODE_MND_TOO_MANY_COLUMNS;
|
terrno = TSDB_CODE_MND_TOO_MANY_COLUMNS;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < ncols; i++) {
|
|
||||||
if (mndFindSuperTableColumnIndex(pOld, pSchemas[i].name) > 0) {
|
|
||||||
terrno = TSDB_CODE_MND_COLUMN_ALREADY_EXIST;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mndFindSuperTableTagIndex(pOld, pSchemas[i].name) > 0) {
|
|
||||||
terrno = TSDB_CODE_MND_TAG_ALREADY_EXIST;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pNew->numOfColumns = pNew->numOfColumns + ncols;
|
pNew->numOfColumns = pNew->numOfColumns + ncols;
|
||||||
if (mndAllocStbSchemas(pOld, pNew) != 0) {
|
if (mndAllocStbSchemas(pOld, pNew) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(pNew->pColumns + pOld->numOfColumns, pSchemas, sizeof(SSchema) * ncols);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t i = pOld->numOfColumns; i < pNew->numOfColumns; i++) {
|
if (mndFindSuperTableTagIndex(pOld, pField->name) > 0) {
|
||||||
SSchema *pSchema = &pNew->pColumns[i];
|
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;
|
pSchema->colId = pNew->nextColId;
|
||||||
pNew->nextColId++;
|
pNew->nextColId++;
|
||||||
|
|
||||||
|
mDebug("stb:%s, start to add column %s", pNew->name, pSchema->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
pNew->version++;
|
pNew->version++;
|
||||||
mDebug("stb:%s, start to add column %s", pNew->name, pSchemas[0].name);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -846,8 +856,8 @@ static int32_t mndDropSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndAlterStbColumnBytes(const SStbObj *pOld, SStbObj *pNew, const SSchema *pSchema) {
|
static int32_t mndAlterStbColumnBytes(const SStbObj *pOld, SStbObj *pNew, const SField *pField) {
|
||||||
int32_t col = mndFindSuperTableColumnIndex(pOld, pSchema->name);
|
int32_t col = mndFindSuperTableColumnIndex(pOld, pField->name);
|
||||||
if (col < 0) {
|
if (col < 0) {
|
||||||
terrno = TSDB_CODE_MND_COLUMN_NOT_EXIST;
|
terrno = TSDB_CODE_MND_COLUMN_NOT_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -855,7 +865,7 @@ static int32_t mndAlterStbColumnBytes(const SStbObj *pOld, SStbObj *pNew, const
|
||||||
|
|
||||||
uint32_t nLen = 0;
|
uint32_t nLen = 0;
|
||||||
for (int32_t i = 0; i < pOld->numOfColumns; ++i) {
|
for (int32_t i = 0; i < pOld->numOfColumns; ++i) {
|
||||||
nLen += (pOld->pColumns[i].colId == col) ? pSchema->bytes : pOld->pColumns[i].bytes;
|
nLen += (pOld->pColumns[i].colId == col) ? pField->bytes : pOld->pColumns[i].bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nLen > TSDB_MAX_BYTES_PER_ROW) {
|
if (nLen > TSDB_MAX_BYTES_PER_ROW) {
|
||||||
|
@ -873,15 +883,15 @@ static int32_t mndAlterStbColumnBytes(const SStbObj *pOld, SStbObj *pNew, const
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSchema->bytes <= pCol->bytes) {
|
if (pField->bytes <= pCol->bytes) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_ROW_BYTES;
|
terrno = TSDB_CODE_MND_INVALID_ROW_BYTES;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pCol->bytes = pSchema->bytes;
|
pCol->bytes = pField->bytes;
|
||||||
pNew->version++;
|
pNew->version++;
|
||||||
|
|
||||||
mDebug("stb:%s, start to modify col len %s to %d", pNew->name, pSchema->name, pSchema->bytes);
|
mDebug("stb:%s, start to modify col len %s to %d", pNew->name, pField->name, pField->bytes);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -950,28 +960,29 @@ static int32_t mndAlterStb(SMnode *pMnode, SMnodeMsg *pReq, const SMAltertbReq *
|
||||||
|
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
STrans *pTrans = NULL;
|
STrans *pTrans = NULL;
|
||||||
|
SField *pField0 = taosArrayGet(pAlter->pFields, 0);
|
||||||
|
|
||||||
switch (pAlter->alterType) {
|
switch (pAlter->alterType) {
|
||||||
case TSDB_ALTER_TABLE_ADD_TAG:
|
case TSDB_ALTER_TABLE_ADD_TAG:
|
||||||
code = mndAddSuperTableTag(pOld, &stbObj, pAlter->pSchemas, 1);
|
code = mndAddSuperTableTag(pOld, &stbObj, pAlter->pFields, pAlter->numOfFields);
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_DROP_TAG:
|
case TSDB_ALTER_TABLE_DROP_TAG:
|
||||||
code = mndDropSuperTableTag(pOld, &stbObj, pAlter->pSchemas[0].name);
|
code = mndDropSuperTableTag(pOld, &stbObj, pField0->name);
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_UPDATE_TAG_NAME:
|
case TSDB_ALTER_TABLE_UPDATE_TAG_NAME:
|
||||||
code = mndAlterStbTagName(pOld, &stbObj, pAlter->pSchemas[0].name, pAlter->pSchemas[1].name);
|
code = mndAlterStbTagName(pOld, &stbObj, pAlter->pFields);
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_UPDATE_TAG_BYTES:
|
case TSDB_ALTER_TABLE_UPDATE_TAG_BYTES:
|
||||||
code = mndAlterStbTagBytes(pOld, &stbObj, &pAlter->pSchemas[0]);
|
code = mndAlterStbTagBytes(pOld, &stbObj, pField0);
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_ADD_COLUMN:
|
case TSDB_ALTER_TABLE_ADD_COLUMN:
|
||||||
code = mndAddSuperTableColumn(pOld, &stbObj, pAlter->pSchemas, 1);
|
code = mndAddSuperTableColumn(pOld, &stbObj, pAlter->pFields, pAlter->numOfFields);
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
||||||
code = mndDropSuperTableColumn(pOld, &stbObj, pAlter->pSchemas[0].name);
|
code = mndDropSuperTableColumn(pOld, &stbObj, pField0->name);
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
||||||
code = mndAlterStbColumnBytes(pOld, &stbObj, &pAlter->pSchemas[0]);
|
code = mndAlterStbColumnBytes(pOld, &stbObj, pField0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||||
|
@ -1001,40 +1012,43 @@ ALTER_STB_OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessMAlterStbReq(SMnodeMsg *pReq) {
|
static int32_t mndProcessMAlterStbReq(SMnodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pMnode;
|
SMnode *pMnode = pReq->pMnode;
|
||||||
SMAltertbReq *pAlter = pReq->rpcMsg.pCont;
|
int32_t code = -1;
|
||||||
|
SDbObj *pDb = NULL;
|
||||||
|
SStbObj *pStb = NULL;
|
||||||
|
SMAltertbReq alterReq = {0};
|
||||||
|
|
||||||
mDebug("stb:%s, start to alter", pAlter->name);
|
if (tDeserializeSMAlterStbReq(pReq->rpcMsg.pCont, &alterReq) == NULL) goto ALTER_STB_OVER;
|
||||||
|
|
||||||
if (mndCheckAlterStbReq(pAlter) != 0) {
|
mDebug("stb:%s, start to alter", alterReq.name);
|
||||||
mError("stb:%s, failed to alter since %s", pAlter->name, terrstr());
|
if (mndCheckAlterStbReq(&alterReq) != 0) goto ALTER_STB_OVER;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDbObj *pDb = mndAcquireDbByStb(pMnode, pAlter->name);
|
pDb = mndAcquireDbByStb(pMnode, alterReq.name);
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_DB;
|
terrno = TSDB_CODE_MND_INVALID_DB;
|
||||||
mError("stb:%s, failed to alter since %s", pAlter->name, terrstr());
|
goto ALTER_STB_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SStbObj *pStb = mndAcquireStb(pMnode, pAlter->name);
|
pStb = mndAcquireStb(pMnode, alterReq.name);
|
||||||
if (pStb == NULL) {
|
if (pStb == NULL) {
|
||||||
mndReleaseDb(pMnode, pDb);
|
|
||||||
terrno = TSDB_CODE_MND_STB_NOT_EXIST;
|
terrno = TSDB_CODE_MND_STB_NOT_EXIST;
|
||||||
mError("stb:%s, failed to alter since %s", pAlter->name, terrstr());
|
goto ALTER_STB_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = mndAlterStb(pMnode, pReq, pAlter, pDb, pStb);
|
code = mndAlterStb(pMnode, pReq, &alterReq, pDb, pStb);
|
||||||
mndReleaseStb(pMnode, pStb);
|
|
||||||
|
|
||||||
|
ALTER_STB_OVER:
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
mError("stb:%s, failed to alter since %s", pAlter->name, terrstr());
|
mError("stb:%s, failed to alter since %s", alterReq.name, terrstr());
|
||||||
return code;
|
} else {
|
||||||
|
code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
mndReleaseStb(pMnode, pStb);
|
||||||
|
mndReleaseDb(pMnode, pDb);
|
||||||
|
taosArrayClear(alterReq.pFields);
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessVAlterStbRsp(SMnodeMsg *pRsp) {
|
static int32_t mndProcessVAlterStbRsp(SMnodeMsg *pRsp) {
|
||||||
|
|
|
@ -22,24 +22,22 @@ class MndTestStb : public ::testing::Test {
|
||||||
void SetUp() override {}
|
void SetUp() override {}
|
||||||
void TearDown() override {}
|
void TearDown() override {}
|
||||||
|
|
||||||
SCreateDbReq* BuildCreateDbReq(const char* dbname, int32_t* pContLen);
|
void* BuildCreateDbReq(const char* dbname, int32_t* pContLen);
|
||||||
SDropDbReq* BuildDropDbReq(const char* dbname, int32_t* pContLen);
|
void* BuildDropDbReq(const char* dbname, int32_t* pContLen);
|
||||||
void* BuildCreateStbReq(const char* stbname, int32_t* pContLen);
|
void* BuildCreateStbReq(const char* stbname, int32_t* pContLen);
|
||||||
SMAltertbReq* BuildAlterStbAddTagReq(const char* stbname, const char* tagname, int32_t* pContLen);
|
void* BuildAlterStbAddTagReq(const char* stbname, const char* tagname, int32_t* pContLen);
|
||||||
SMAltertbReq* BuildAlterStbDropTagReq(const char* stbname, const char* tagname, int32_t* pContLen);
|
void* BuildAlterStbDropTagReq(const char* stbname, const char* tagname, int32_t* pContLen);
|
||||||
SMAltertbReq* BuildAlterStbUpdateTagNameReq(const char* stbname, const char* tagname, const char* newtagname,
|
void* BuildAlterStbUpdateTagNameReq(const char* stbname, const char* tagname, const char* newtagname,
|
||||||
int32_t* pContLen);
|
int32_t* pContLen);
|
||||||
SMAltertbReq* BuildAlterStbUpdateTagBytesReq(const char* stbname, const char* tagname, int32_t bytes,
|
void* BuildAlterStbUpdateTagBytesReq(const char* stbname, const char* tagname, int32_t bytes, int32_t* pContLen);
|
||||||
int32_t* pContLen);
|
void* BuildAlterStbAddColumnReq(const char* stbname, const char* colname, int32_t* pContLen);
|
||||||
SMAltertbReq* BuildAlterStbAddColumnReq(const char* stbname, const char* colname, int32_t* pContLen);
|
void* BuildAlterStbDropColumnReq(const char* stbname, const char* colname, int32_t* pContLen);
|
||||||
SMAltertbReq* BuildAlterStbDropColumnReq(const char* stbname, const char* colname, int32_t* pContLen);
|
void* BuildAlterStbUpdateColumnBytesReq(const char* stbname, const char* colname, int32_t bytes, int32_t* pContLen);
|
||||||
SMAltertbReq* BuildAlterStbUpdateColumnBytesReq(const char* stbname, const char* colname, int32_t bytes,
|
|
||||||
int32_t* pContLen);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Testbase MndTestStb::test;
|
Testbase MndTestStb::test;
|
||||||
|
|
||||||
SCreateDbReq* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen) {
|
void* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen) {
|
||||||
int32_t contLen = sizeof(SCreateDbReq);
|
int32_t contLen = sizeof(SCreateDbReq);
|
||||||
|
|
||||||
SCreateDbReq* pReq = (SCreateDbReq*)rpcMallocCont(contLen);
|
SCreateDbReq* pReq = (SCreateDbReq*)rpcMallocCont(contLen);
|
||||||
|
@ -68,7 +66,7 @@ SCreateDbReq* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen
|
||||||
return pReq;
|
return pReq;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDropDbReq* MndTestStb::BuildDropDbReq(const char* dbname, int32_t* pContLen) {
|
void* MndTestStb::BuildDropDbReq(const char* dbname, int32_t* pContLen) {
|
||||||
int32_t contLen = sizeof(SDropDbReq);
|
int32_t contLen = sizeof(SDropDbReq);
|
||||||
|
|
||||||
SDropDbReq* pReq = (SDropDbReq*)rpcMallocCont(contLen);
|
SDropDbReq* pReq = (SDropDbReq*)rpcMallocCont(contLen);
|
||||||
|
@ -136,124 +134,167 @@ void* MndTestStb::BuildCreateStbReq(const char* stbname, int32_t* pContLen) {
|
||||||
return pHead;
|
return pHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMAltertbReq* MndTestStb::BuildAlterStbAddTagReq(const char* stbname, const char* tagname, int32_t* pContLen) {
|
void* MndTestStb::BuildAlterStbAddTagReq(const char* stbname, const char* tagname, int32_t* pContLen) {
|
||||||
int32_t contLen = sizeof(SMAltertbReq) + sizeof(SSchema);
|
SMAltertbReq req = {0};
|
||||||
SMAltertbReq* pReq = (SMAltertbReq*)rpcMallocCont(contLen);
|
strcpy(req.name, stbname);
|
||||||
strcpy(pReq->name, stbname);
|
req.numOfFields = 1;
|
||||||
pReq->numOfSchemas = htonl(1);
|
req.pFields = taosArrayInit(1, sizeof(SField));
|
||||||
pReq->alterType = TSDB_ALTER_TABLE_ADD_TAG;
|
req.alterType = TSDB_ALTER_TABLE_ADD_TAG;
|
||||||
|
|
||||||
SSchema* pSchema = &pReq->pSchemas[0];
|
SField field = {0};
|
||||||
pSchema->bytes = htonl(12);
|
field.bytes = 12;
|
||||||
pSchema->type = TSDB_DATA_TYPE_BINARY;
|
field.type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema->name, tagname);
|
strcpy(field.name, tagname);
|
||||||
|
taosArrayPush(req.pFields, &field);
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSMAlterStbReq(NULL, &req);
|
||||||
|
void* pHead = rpcMallocCont(contLen);
|
||||||
|
void* pBuf = pHead;
|
||||||
|
tSerializeSMAlterStbReq(&pBuf, &req);
|
||||||
|
|
||||||
*pContLen = contLen;
|
*pContLen = contLen;
|
||||||
return pReq;
|
return pHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMAltertbReq* MndTestStb::BuildAlterStbDropTagReq(const char* stbname, const char* tagname, int32_t* pContLen) {
|
void* MndTestStb::BuildAlterStbDropTagReq(const char* stbname, const char* tagname, int32_t* pContLen) {
|
||||||
int32_t contLen = sizeof(SMAltertbReq) + sizeof(SSchema);
|
SMAltertbReq req = {0};
|
||||||
SMAltertbReq* pReq = (SMAltertbReq*)rpcMallocCont(contLen);
|
strcpy(req.name, stbname);
|
||||||
strcpy(pReq->name, stbname);
|
req.numOfFields = 1;
|
||||||
pReq->numOfSchemas = htonl(1);
|
req.pFields = taosArrayInit(1, sizeof(SField));
|
||||||
pReq->alterType = TSDB_ALTER_TABLE_DROP_TAG;
|
req.alterType = TSDB_ALTER_TABLE_DROP_TAG;
|
||||||
|
|
||||||
SSchema* pSchema = &pReq->pSchemas[0];
|
SField field = {0};
|
||||||
pSchema->bytes = htonl(12);
|
field.bytes = 12;
|
||||||
pSchema->type = TSDB_DATA_TYPE_BINARY;
|
field.type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema->name, tagname);
|
strcpy(field.name, tagname);
|
||||||
|
taosArrayPush(req.pFields, &field);
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSMAlterStbReq(NULL, &req);
|
||||||
|
void* pHead = rpcMallocCont(contLen);
|
||||||
|
void* pBuf = pHead;
|
||||||
|
tSerializeSMAlterStbReq(&pBuf, &req);
|
||||||
|
|
||||||
*pContLen = contLen;
|
*pContLen = contLen;
|
||||||
return pReq;
|
return pHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMAltertbReq* MndTestStb::BuildAlterStbUpdateTagNameReq(const char* stbname, const char* tagname,
|
void* MndTestStb::BuildAlterStbUpdateTagNameReq(const char* stbname, const char* tagname, const char* newtagname,
|
||||||
const char* newtagname, int32_t* pContLen) {
|
int32_t* pContLen) {
|
||||||
int32_t contLen = sizeof(SMAltertbReq) + 2 * sizeof(SSchema);
|
SMAltertbReq req = {0};
|
||||||
SMAltertbReq* pReq = (SMAltertbReq*)rpcMallocCont(contLen);
|
strcpy(req.name, stbname);
|
||||||
strcpy(pReq->name, stbname);
|
req.numOfFields = 2;
|
||||||
pReq->numOfSchemas = htonl(1);
|
req.pFields = taosArrayInit(2, sizeof(SField));
|
||||||
pReq->alterType = TSDB_ALTER_TABLE_UPDATE_TAG_NAME;
|
req.alterType = TSDB_ALTER_TABLE_UPDATE_TAG_NAME;
|
||||||
|
|
||||||
SSchema* pSchema = &pReq->pSchemas[0];
|
SField field = {0};
|
||||||
pSchema->bytes = htonl(12);
|
field.bytes = 12;
|
||||||
pSchema->type = TSDB_DATA_TYPE_BINARY;
|
field.type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema->name, tagname);
|
strcpy(field.name, tagname);
|
||||||
|
taosArrayPush(req.pFields, &field);
|
||||||
|
|
||||||
pSchema = &pReq->pSchemas[1];
|
SField field2 = {0};
|
||||||
pSchema->bytes = htonl(12);
|
field2.bytes = 12;
|
||||||
pSchema->type = TSDB_DATA_TYPE_BINARY;
|
field2.type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema->name, newtagname);
|
strcpy(field2.name, newtagname);
|
||||||
|
taosArrayPush(req.pFields, &field2);
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSMAlterStbReq(NULL, &req);
|
||||||
|
void* pHead = rpcMallocCont(contLen);
|
||||||
|
void* pBuf = pHead;
|
||||||
|
tSerializeSMAlterStbReq(&pBuf, &req);
|
||||||
|
|
||||||
*pContLen = contLen;
|
*pContLen = contLen;
|
||||||
return pReq;
|
return pHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMAltertbReq* MndTestStb::BuildAlterStbUpdateTagBytesReq(const char* stbname, const char* tagname, int32_t bytes,
|
void* MndTestStb::BuildAlterStbUpdateTagBytesReq(const char* stbname, const char* tagname, int32_t bytes,
|
||||||
int32_t* pContLen) {
|
int32_t* pContLen) {
|
||||||
int32_t contLen = sizeof(SMAltertbReq) + sizeof(SSchema);
|
SMAltertbReq req = {0};
|
||||||
SMAltertbReq* pReq = (SMAltertbReq*)rpcMallocCont(contLen);
|
strcpy(req.name, stbname);
|
||||||
strcpy(pReq->name, stbname);
|
req.numOfFields = 1;
|
||||||
pReq->numOfSchemas = htonl(1);
|
req.pFields = taosArrayInit(1, sizeof(SField));
|
||||||
pReq->alterType = TSDB_ALTER_TABLE_UPDATE_TAG_BYTES;
|
req.alterType = TSDB_ALTER_TABLE_UPDATE_TAG_BYTES;
|
||||||
|
|
||||||
SSchema* pSchema = &pReq->pSchemas[0];
|
SField field = {0};
|
||||||
pSchema->bytes = htonl(bytes);
|
field.bytes = bytes;
|
||||||
pSchema->type = TSDB_DATA_TYPE_BINARY;
|
field.type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema->name, tagname);
|
strcpy(field.name, tagname);
|
||||||
|
taosArrayPush(req.pFields, &field);
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSMAlterStbReq(NULL, &req);
|
||||||
|
void* pHead = rpcMallocCont(contLen);
|
||||||
|
void* pBuf = pHead;
|
||||||
|
tSerializeSMAlterStbReq(&pBuf, &req);
|
||||||
|
|
||||||
*pContLen = contLen;
|
*pContLen = contLen;
|
||||||
return pReq;
|
return pHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMAltertbReq* MndTestStb::BuildAlterStbAddColumnReq(const char* stbname, const char* colname, int32_t* pContLen) {
|
void* MndTestStb::BuildAlterStbAddColumnReq(const char* stbname, const char* colname, int32_t* pContLen) {
|
||||||
int32_t contLen = sizeof(SMAltertbReq) + sizeof(SSchema);
|
SMAltertbReq req = {0};
|
||||||
SMAltertbReq* pReq = (SMAltertbReq*)rpcMallocCont(contLen);
|
strcpy(req.name, stbname);
|
||||||
strcpy(pReq->name, stbname);
|
req.numOfFields = 1;
|
||||||
pReq->numOfSchemas = htonl(1);
|
req.pFields = taosArrayInit(1, sizeof(SField));
|
||||||
pReq->alterType = TSDB_ALTER_TABLE_ADD_COLUMN;
|
req.alterType = TSDB_ALTER_TABLE_ADD_COLUMN;
|
||||||
|
|
||||||
SSchema* pSchema = &pReq->pSchemas[0];
|
SField field = {0};
|
||||||
pSchema->bytes = htonl(12);
|
field.bytes = 12;
|
||||||
pSchema->type = TSDB_DATA_TYPE_BINARY;
|
field.type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema->name, colname);
|
strcpy(field.name, colname);
|
||||||
|
taosArrayPush(req.pFields, &field);
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSMAlterStbReq(NULL, &req);
|
||||||
|
void* pHead = rpcMallocCont(contLen);
|
||||||
|
void* pBuf = pHead;
|
||||||
|
tSerializeSMAlterStbReq(&pBuf, &req);
|
||||||
|
|
||||||
*pContLen = contLen;
|
*pContLen = contLen;
|
||||||
return pReq;
|
return pHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMAltertbReq* MndTestStb::BuildAlterStbDropColumnReq(const char* stbname, const char* colname, int32_t* pContLen) {
|
void* MndTestStb::BuildAlterStbDropColumnReq(const char* stbname, const char* colname, int32_t* pContLen) {
|
||||||
int32_t contLen = sizeof(SMAltertbReq) + sizeof(SSchema);
|
SMAltertbReq req = {0};
|
||||||
SMAltertbReq* pReq = (SMAltertbReq*)rpcMallocCont(contLen);
|
strcpy(req.name, stbname);
|
||||||
strcpy(pReq->name, stbname);
|
req.numOfFields = 1;
|
||||||
pReq->numOfSchemas = htonl(1);
|
req.pFields = taosArrayInit(1, sizeof(SField));
|
||||||
pReq->alterType = TSDB_ALTER_TABLE_DROP_COLUMN;
|
req.alterType = TSDB_ALTER_TABLE_DROP_COLUMN;
|
||||||
|
|
||||||
SSchema* pSchema = &pReq->pSchemas[0];
|
SField field = {0};
|
||||||
pSchema->bytes = htonl(12);
|
field.bytes = 12;
|
||||||
pSchema->type = TSDB_DATA_TYPE_BINARY;
|
field.type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema->name, colname);
|
strcpy(field.name, colname);
|
||||||
|
taosArrayPush(req.pFields, &field);
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSMAlterStbReq(NULL, &req);
|
||||||
|
void* pHead = rpcMallocCont(contLen);
|
||||||
|
void* pBuf = pHead;
|
||||||
|
tSerializeSMAlterStbReq(&pBuf, &req);
|
||||||
|
|
||||||
*pContLen = contLen;
|
*pContLen = contLen;
|
||||||
return pReq;
|
return pHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMAltertbReq* MndTestStb::BuildAlterStbUpdateColumnBytesReq(const char* stbname, const char* colname, int32_t bytes,
|
void* MndTestStb::BuildAlterStbUpdateColumnBytesReq(const char* stbname, const char* colname, int32_t bytes,
|
||||||
int32_t* pContLen) {
|
int32_t* pContLen) {
|
||||||
int32_t contLen = sizeof(SMAltertbReq) + sizeof(SSchema);
|
SMAltertbReq req = {0};
|
||||||
SMAltertbReq* pReq = (SMAltertbReq*)rpcMallocCont(contLen);
|
strcpy(req.name, stbname);
|
||||||
strcpy(pReq->name, stbname);
|
req.numOfFields = 1;
|
||||||
pReq->numOfSchemas = htonl(1);
|
req.pFields = taosArrayInit(1, sizeof(SField));
|
||||||
pReq->alterType = TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES;
|
req.alterType = TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES;
|
||||||
|
|
||||||
SSchema* pSchema = &pReq->pSchemas[0];
|
SField field = {0};
|
||||||
pSchema->bytes = htonl(bytes);
|
field.bytes = bytes;
|
||||||
pSchema->type = TSDB_DATA_TYPE_BINARY;
|
field.type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema->name, colname);
|
strcpy(field.name, colname);
|
||||||
|
taosArrayPush(req.pFields, &field);
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSMAlterStbReq(NULL, &req);
|
||||||
|
void* pHead = rpcMallocCont(contLen);
|
||||||
|
void* pBuf = pHead;
|
||||||
|
tSerializeSMAlterStbReq(&pBuf, &req);
|
||||||
|
|
||||||
*pContLen = contLen;
|
*pContLen = contLen;
|
||||||
return pReq;
|
return pHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
||||||
|
@ -261,9 +302,9 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
||||||
const char* stbname = "1.d1.stb";
|
const char* stbname = "1.d1.stb";
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
SCreateDbReq* pReq = BuildCreateDbReq(dbname, &contLen);
|
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
@ -409,9 +450,9 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
SDropDbReq* pReq = BuildDropDbReq(dbname, &contLen);
|
void* pReq = BuildDropDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
@ -423,8 +464,8 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) {
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
SCreateDbReq* pReq = BuildCreateDbReq(dbname, &contLen);
|
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
@ -437,32 +478,32 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbAddTagReq("1.d3.stb", "tag4", &contLen);
|
void* pReq = BuildAlterStbAddTagReq("1.d3.stb", "tag4", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_DB);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_DB);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbAddTagReq("1.d2.stb3", "tag4", &contLen);
|
void* pReq = BuildAlterStbAddTagReq("1.d2.stb3", "tag4", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_STB_NOT_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_STB_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbAddTagReq(stbname, "tag3", &contLen);
|
void* pReq = BuildAlterStbAddTagReq(stbname, "tag3", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_ALREADY_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_ALREADY_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbAddTagReq(stbname, "col1", &contLen);
|
void* pReq = BuildAlterStbAddTagReq(stbname, "col1", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_ALREADY_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_ALREADY_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbAddTagReq(stbname, "tag4", &contLen);
|
void* pReq = BuildAlterStbAddTagReq(stbname, "tag4", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
|
|
||||||
|
@ -476,8 +517,8 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SDropDbReq* pReq = BuildDropDbReq(dbname, &contLen);
|
void* pReq = BuildDropDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
@ -489,8 +530,8 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) {
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
SCreateDbReq* pReq = BuildCreateDbReq(dbname, &contLen);
|
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,14 +542,14 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbDropTagReq(stbname, "tag5", &contLen);
|
void* pReq = BuildAlterStbDropTagReq(stbname, "tag5", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_NOT_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbDropTagReq(stbname, "tag3", &contLen);
|
void* pReq = BuildAlterStbDropTagReq(stbname, "tag3", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
|
|
||||||
|
@ -522,8 +563,8 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SDropDbReq* pReq = BuildDropDbReq(dbname, &contLen);
|
void* pReq = BuildDropDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
@ -535,8 +576,8 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) {
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
SCreateDbReq* pReq = BuildCreateDbReq(dbname, &contLen);
|
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,37 +588,37 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbUpdateTagNameReq(stbname, "tag5", "tag6", &contLen);
|
void* pReq = BuildAlterStbUpdateTagNameReq(stbname, "tag5", "tag6", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_NOT_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbUpdateTagNameReq(stbname, "col1", "tag6", &contLen);
|
void* pReq = BuildAlterStbUpdateTagNameReq(stbname, "col1", "tag6", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_NOT_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbUpdateTagNameReq(stbname, "tag3", "col1", &contLen);
|
void* pReq = BuildAlterStbUpdateTagNameReq(stbname, "tag3", "col1", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_ALREADY_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_ALREADY_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbUpdateTagNameReq(stbname, "tag3", "tag2", &contLen);
|
void* pReq = BuildAlterStbUpdateTagNameReq(stbname, "tag3", "tag2", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_ALREADY_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_ALREADY_EXIST);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbUpdateTagNameReq(stbname, "tag3", "tag2", &contLen);
|
void* pReq = BuildAlterStbUpdateTagNameReq(stbname, "tag3", "tag2", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_ALREADY_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_ALREADY_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbUpdateTagNameReq(stbname, "tag3", "tag4", &contLen);
|
void* pReq = BuildAlterStbUpdateTagNameReq(stbname, "tag3", "tag4", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
|
|
||||||
|
@ -591,8 +632,8 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SDropDbReq* pReq = BuildDropDbReq(dbname, &contLen);
|
void* pReq = BuildDropDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
@ -604,8 +645,8 @@ TEST_F(MndTestStb, 05_Alter_Stb_AlterTagBytes) {
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
SCreateDbReq* pReq = BuildCreateDbReq(dbname, &contLen);
|
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -616,26 +657,26 @@ TEST_F(MndTestStb, 05_Alter_Stb_AlterTagBytes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbUpdateTagBytesReq(stbname, "tag5", 12, &contLen);
|
void* pReq = BuildAlterStbUpdateTagBytesReq(stbname, "tag5", 12, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_NOT_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbUpdateTagBytesReq(stbname, "tag1", 13, &contLen);
|
void* pReq = BuildAlterStbUpdateTagBytesReq(stbname, "tag1", 13, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_STB_OPTION);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_STB_OPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbUpdateTagBytesReq(stbname, "tag3", 8, &contLen);
|
void* pReq = BuildAlterStbUpdateTagBytesReq(stbname, "tag3", 8, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_ROW_BYTES);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_ROW_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbUpdateTagBytesReq(stbname, "tag3", 20, &contLen);
|
void* pReq = BuildAlterStbUpdateTagBytesReq(stbname, "tag3", 20, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
|
|
||||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
||||||
|
@ -648,8 +689,8 @@ TEST_F(MndTestStb, 05_Alter_Stb_AlterTagBytes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SDropDbReq* pReq = BuildDropDbReq(dbname, &contLen);
|
void* pReq = BuildDropDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
@ -661,8 +702,8 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) {
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
SCreateDbReq* pReq = BuildCreateDbReq(dbname, &contLen);
|
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
@ -675,32 +716,32 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbAddColumnReq("1.d7.stb", "tag4", &contLen);
|
void* pReq = BuildAlterStbAddColumnReq("1.d7.stb", "tag4", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_DB);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_DB);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbAddColumnReq("1.d6.stb3", "tag4", &contLen);
|
void* pReq = BuildAlterStbAddColumnReq("1.d6.stb3", "tag4", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_STB_NOT_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_STB_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbAddColumnReq(stbname, "tag3", &contLen);
|
void* pReq = BuildAlterStbAddColumnReq(stbname, "tag3", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_ALREADY_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_ALREADY_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbAddColumnReq(stbname, "col1", &contLen);
|
void* pReq = BuildAlterStbAddColumnReq(stbname, "col1", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_ALREADY_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_ALREADY_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbAddColumnReq(stbname, "col2", &contLen);
|
void* pReq = BuildAlterStbAddColumnReq(stbname, "col2", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
|
|
||||||
|
@ -714,8 +755,8 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SDropDbReq* pReq = BuildDropDbReq(dbname, &contLen);
|
void* pReq = BuildDropDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
@ -727,8 +768,8 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) {
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
SCreateDbReq* pReq = BuildCreateDbReq(dbname, &contLen);
|
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -739,33 +780,33 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbDropColumnReq(stbname, "col4", &contLen);
|
void* pReq = BuildAlterStbDropColumnReq(stbname, "col4", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_NOT_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbDropColumnReq(stbname, "col1", &contLen);
|
void* pReq = BuildAlterStbDropColumnReq(stbname, "col1", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_STB_ALTER_OPTION);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_STB_ALTER_OPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbDropColumnReq(stbname, "ts", &contLen);
|
void* pReq = BuildAlterStbDropColumnReq(stbname, "ts", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_STB_ALTER_OPTION);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_STB_ALTER_OPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbAddColumnReq(stbname, "col2", &contLen);
|
void* pReq = BuildAlterStbAddColumnReq(stbname, "col2", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbDropColumnReq(stbname, "col1", &contLen);
|
void* pReq = BuildAlterStbDropColumnReq(stbname, "col1", &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
|
|
||||||
|
@ -779,8 +820,8 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SDropDbReq* pReq = BuildDropDbReq(dbname, &contLen);
|
void* pReq = BuildDropDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
@ -792,8 +833,8 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) {
|
||||||
int32_t contLen = 0;
|
int32_t contLen = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
SCreateDbReq* pReq = BuildCreateDbReq(dbname, &contLen);
|
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -804,32 +845,32 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col5", 12, &contLen);
|
void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col5", 12, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_NOT_EXIST);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "ts", 8, &contLen);
|
void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "ts", 8, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_STB_OPTION);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_STB_OPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col1", 8, &contLen);
|
void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col1", 8, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_ROW_BYTES);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_ROW_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col1", TSDB_MAX_BYTES_PER_ROW, &contLen);
|
void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col1", TSDB_MAX_BYTES_PER_ROW, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_ROW_BYTES);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_ROW_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SMAltertbReq* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col1", 20, &contLen);
|
void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col1", 20, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
|
|
||||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
|
||||||
|
@ -842,8 +883,8 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SDropDbReq* pReq = BuildDropDbReq(dbname, &contLen);
|
void* pReq = BuildDropDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue