fix: insert into select with disorder column issue
This commit is contained in:
parent
85eba36190
commit
ee719d02b4
|
@ -41,6 +41,7 @@ typedef struct SDataInserterHandle {
|
||||||
SHashObj* pCols;
|
SHashObj* pCols;
|
||||||
int32_t status;
|
int32_t status;
|
||||||
bool queryEnd;
|
bool queryEnd;
|
||||||
|
bool fullOrderColList;
|
||||||
uint64_t useconds;
|
uint64_t useconds;
|
||||||
uint64_t cachedSize;
|
uint64_t cachedSize;
|
||||||
TdThreadMutex mutex;
|
TdThreadMutex mutex;
|
||||||
|
@ -125,7 +126,6 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) {
|
||||||
int64_t uid = pInserter->pNode->tableId;
|
int64_t uid = pInserter->pNode->tableId;
|
||||||
int64_t suid = pInserter->pNode->stableId;
|
int64_t suid = pInserter->pNode->stableId;
|
||||||
int32_t vgId = pInserter->pNode->vgId;
|
int32_t vgId = pInserter->pNode->vgId;
|
||||||
bool fullCol = (pInserter->pNode->pCols->length == pTSchema->numOfCols);
|
|
||||||
|
|
||||||
SSubmitReq* ret = NULL;
|
SSubmitReq* ret = NULL;
|
||||||
int32_t sz = taosArrayGetSize(pBlocks);
|
int32_t sz = taosArrayGetSize(pBlocks);
|
||||||
|
@ -176,7 +176,7 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) {
|
||||||
const STColumn* pColumn = &pTSchema->columns[k];
|
const STColumn* pColumn = &pTSchema->columns[k];
|
||||||
SColumnInfoData* pColData = NULL;
|
SColumnInfoData* pColData = NULL;
|
||||||
int16_t colIdx = k;
|
int16_t colIdx = k;
|
||||||
if (!fullCol) {
|
if (!pInserter->fullOrderColList) {
|
||||||
int16_t* slotId = taosHashGet(pInserter->pCols, &pColumn->colId, sizeof(pColumn->colId));
|
int16_t* slotId = taosHashGet(pInserter->pCols, &pColumn->colId, sizeof(pColumn->colId));
|
||||||
if (NULL == slotId) {
|
if (NULL == slotId) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -212,7 +212,7 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) {
|
||||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, pColumn->offset, k);
|
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, pColumn->offset, k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!fullCol) {
|
if (!pInserter->fullOrderColList) {
|
||||||
rb.hasNone = true;
|
rb.hasNone = true;
|
||||||
}
|
}
|
||||||
tdSRowEnd(&rb);
|
tdSRowEnd(&rb);
|
||||||
|
@ -346,12 +346,18 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inserter->fullOrderColList = pInserterNode->pCols->length == inserter->pSchema->numOfCols;
|
||||||
|
|
||||||
inserter->pCols = taosHashInit(pInserterNode->pCols->length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT),
|
inserter->pCols = taosHashInit(pInserterNode->pCols->length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT),
|
||||||
false, HASH_NO_LOCK);
|
false, HASH_NO_LOCK);
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
|
int32_t i = 0;
|
||||||
FOREACH(pNode, pInserterNode->pCols) {
|
FOREACH(pNode, pInserterNode->pCols) {
|
||||||
SColumnNode* pCol = (SColumnNode*)pNode;
|
SColumnNode* pCol = (SColumnNode*)pNode;
|
||||||
taosHashPut(inserter->pCols, &pCol->colId, sizeof(pCol->colId), &pCol->slotId, sizeof(pCol->slotId));
|
taosHashPut(inserter->pCols, &pCol->colId, sizeof(pCol->colId), &pCol->slotId, sizeof(pCol->slotId));
|
||||||
|
if (inserter->fullOrderColList && pCol->colId != inserter->pSchema->columns[i].colId) {
|
||||||
|
inserter->fullOrderColList = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tsem_init(&inserter->ready, 0, 0);
|
tsem_init(&inserter->ready, 0, 0);
|
||||||
|
|
|
@ -42,4 +42,24 @@ if $rows != 2 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
print ======== step2
|
||||||
|
sql drop database if exists db1;
|
||||||
|
sql create database db1 vgroups 1;
|
||||||
|
sql use db1;
|
||||||
|
sql create table t1(ts timestamp, a int, b int );
|
||||||
|
sql create table t2(ts timestamp, a int, b int );
|
||||||
|
sql insert into t1 values(1648791211000,1,2);
|
||||||
|
sql insert into t2 (ts, b, a) select ts, a, b from t1;
|
||||||
|
sql select * from t2;
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data01 != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data02 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
|
Loading…
Reference in New Issue