Merge branch 'feat/TS-4243-3.0' of https://github.com/taosdata/TDengine into feat/ly-TS-4243-3.0
This commit is contained in:
commit
39a89c20bd
|
@ -765,6 +765,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_TAG_IS_PRIMARY_KEY TAOS_DEF_ERROR_CODE(0, 0x2671)
|
||||
#define TSDB_CODE_PAR_SECOND_COL_PK TAOS_DEF_ERROR_CODE(0, 0x2672)
|
||||
#define TSDB_CODE_PAR_COL_PK_TYPE TAOS_DEF_ERROR_CODE(0, 0x2673)
|
||||
#define TSDB_CODE_PAR_INVALID_PK_OP TAOS_DEF_ERROR_CODE(0, 0x2674)
|
||||
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF)
|
||||
|
||||
//planner
|
||||
|
|
|
@ -927,7 +927,7 @@ static bool isPrimaryKey(STempTableNode* pTable, SNode* pExpr) {
|
|||
return isPrimaryKeyImpl(pExpr);
|
||||
}
|
||||
|
||||
static bool hasPkInTable(STableMeta* pTableMeta) {
|
||||
static bool hasPkInTable(const STableMeta* pTableMeta) {
|
||||
return pTableMeta->tableInfo.numOfColumns>=2 && pTableMeta->schema[1].flags & COL_IS_KEY;
|
||||
}
|
||||
|
||||
|
@ -6766,7 +6766,13 @@ static int32_t checkAlterSuperTableBySchema(STranslateContext* pCxt, SAlterTable
|
|||
: TSDB_CODE_PAR_INVALID_TAG_NAME,
|
||||
pStmt->colName);
|
||||
}
|
||||
|
||||
if (hasPkInTable(pTableMeta) && (pSchema->flags & COL_IS_KEY)) {
|
||||
if (TSDB_ALTER_TABLE_DROP_COLUMN == pStmt->alterType ||
|
||||
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES == pStmt->alterType ||
|
||||
TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME == pStmt->alterType) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PK_OP, pStmt->colName);
|
||||
}
|
||||
}
|
||||
if ((TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES == pStmt->alterType ||
|
||||
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES == pStmt->alterType) &&
|
||||
(!IS_VAR_DATA_TYPE(pSchema->type) || pSchema->type != pStmt->dataType.type ||
|
||||
|
@ -10959,6 +10965,14 @@ static int32_t rewriteAlterTableImpl(STranslateContext* pCxt, SAlterTableStmt* p
|
|||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE);
|
||||
}
|
||||
|
||||
const SSchema* pSchema = getNormalColSchema(pTableMeta, pStmt->colName);
|
||||
if (hasPkInTable(pTableMeta) && pSchema && (pSchema->flags & COL_IS_KEY) &&
|
||||
(TSDB_ALTER_TABLE_DROP_COLUMN == pStmt->alterType ||
|
||||
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES == pStmt->alterType ||
|
||||
TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME == pStmt->alterType)) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PK_OP);
|
||||
}
|
||||
|
||||
SVAlterTbReq req = {0};
|
||||
int32_t code = buildAlterTbReq(pCxt, pStmt, pTableMeta, &req);
|
||||
|
||||
|
|
|
@ -199,7 +199,9 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
|||
case TSDB_CODE_PAR_SECOND_COL_PK:
|
||||
return "primary key column must be second column";
|
||||
case TSDB_CODE_PAR_COL_PK_TYPE:
|
||||
return "primary key column must be of type int, uint, bigint, ubigint, and varchar";
|
||||
return "primary key column must be of type int, uint, bigint, ubigint, and varchar";
|
||||
case TSDB_CODE_PAR_INVALID_PK_OP:
|
||||
return "primary key column can not be added, modified, and dropped";
|
||||
default:
|
||||
return "Unknown error";
|
||||
}
|
||||
|
|
|
@ -1696,6 +1696,11 @@ static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p
|
|||
}
|
||||
}
|
||||
|
||||
STableMeta* pMeta = ((SRealTableNode*)pDelete->pFromTable)->pMeta;
|
||||
if (TSDB_CODE_SUCCESS == code && hasPkInTable(pMeta)) {
|
||||
code = addPkCol(pMeta->uid, pMeta->schema + 1, &pScan->pScanCols, pMeta);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pDelete->pTagCond) {
|
||||
pScan->pTagCond = nodesCloneNode(pDelete->pTagCond);
|
||||
if (NULL == pScan->pTagCond) {
|
||||
|
|
|
@ -627,6 +627,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_NOT_SUPPORT_MULTI_RESULT, "Operator not suppor
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_TAG_IS_PRIMARY_KEY, "tag can not be primary key")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_SECOND_COL_PK, "primary key must be second column")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_COL_PK_TYPE, "primary key column must be of type int, uint, bigint, ubigint, and varchar")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_PK_OP, "primary key column can not be added, modified, and dropped")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTERNAL_ERROR, "Parser internal error")
|
||||
|
||||
//planner
|
||||
|
|
Loading…
Reference in New Issue