chore: allow source table with primary key
This commit is contained in:
parent
cc660de9d0
commit
62ab1b1c41
|
@ -5088,7 +5088,6 @@ static int32_t translateInsertProject(STranslateContext* pCxt, SInsertStmt* pIns
|
||||||
SNode* pPrimaryKeyExpr = NULL;
|
SNode* pPrimaryKeyExpr = NULL;
|
||||||
SNode* pBoundCol = NULL;
|
SNode* pBoundCol = NULL;
|
||||||
SNode* pProj = NULL;
|
SNode* pProj = NULL;
|
||||||
int16_t numOfSourcePKs = 0;
|
|
||||||
int16_t numOfTargetPKs = 0;
|
int16_t numOfTargetPKs = 0;
|
||||||
int16_t numOfBoundPKs = 0;
|
int16_t numOfBoundPKs = 0;
|
||||||
FORBOTH(pBoundCol, pInsert->pCols, pProj, pProjects) {
|
FORBOTH(pBoundCol, pInsert->pCols, pProj, pProjects) {
|
||||||
|
@ -5107,7 +5106,6 @@ static int32_t translateInsertProject(STranslateContext* pCxt, SInsertStmt* pIns
|
||||||
if (PRIMARYKEY_TIMESTAMP_COL_ID == pCol->colId) {
|
if (PRIMARYKEY_TIMESTAMP_COL_ID == pCol->colId) {
|
||||||
pPrimaryKeyExpr = (SNode*)pExpr;
|
pPrimaryKeyExpr = (SNode*)pExpr;
|
||||||
numOfTargetPKs = pCol->numOfPKs;
|
numOfTargetPKs = pCol->numOfPKs;
|
||||||
numOfSourcePKs = ((SColumnNode*)pProj)->numOfPKs;
|
|
||||||
}
|
}
|
||||||
if (pCol->isPk) ++numOfBoundPKs;
|
if (pCol->isPk) ++numOfBoundPKs;
|
||||||
}
|
}
|
||||||
|
@ -5121,12 +5119,6 @@ static int32_t translateInsertProject(STranslateContext* pCxt, SInsertStmt* pIns
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, "Primary key column should not be none");
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, "Primary key column should not be none");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numOfTargetPKs < numOfSourcePKs) {
|
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR,
|
|
||||||
"Target table has less primary keys:%" PRIi16 " than source:%" PRIi16,
|
|
||||||
numOfTargetPKs, numOfSourcePKs);
|
|
||||||
}
|
|
||||||
|
|
||||||
return addOrderByPrimaryKeyToQuery(pCxt, pPrimaryKeyExpr, pInsert->pQuery);
|
return addOrderByPrimaryKeyToQuery(pCxt, pPrimaryKeyExpr, pInsert->pQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue