fix: a problem of cross database join
This commit is contained in:
parent
65c318dbcc
commit
6110b7e4ca
|
@ -461,12 +461,10 @@ static bool isDistinctOrderBy(STranslateContext* pCxt) {
|
||||||
((SSelectStmt*)pCxt->pCurrStmt)->isDistinct);
|
((SSelectStmt*)pCxt->pCurrStmt)->isDistinct);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool belongTable(const char* currentDb, const SColumnNode* pCol, const STableNode* pTable) {
|
static bool belongTable(const SColumnNode* pCol, const STableNode* pTable) {
|
||||||
int cmp = 0;
|
int cmp = 0;
|
||||||
if ('\0' != pCol->dbName[0]) {
|
if ('\0' != pCol->dbName[0]) {
|
||||||
cmp = strcmp(pCol->dbName, pTable->dbName);
|
cmp = strcmp(pCol->dbName, pTable->dbName);
|
||||||
} else {
|
|
||||||
cmp = (QUERY_NODE_REAL_TABLE == nodeType(pTable) ? strcmp(currentDb, pTable->dbName) : 0);
|
|
||||||
}
|
}
|
||||||
if (0 == cmp) {
|
if (0 == cmp) {
|
||||||
cmp = strcmp(pCol->tableAlias, pTable->tableAlias);
|
cmp = strcmp(pCol->tableAlias, pTable->tableAlias);
|
||||||
|
@ -630,7 +628,7 @@ static EDealRes translateColumnWithPrefix(STranslateContext* pCxt, SColumnNode**
|
||||||
bool foundTable = false;
|
bool foundTable = false;
|
||||||
for (size_t i = 0; i < nums; ++i) {
|
for (size_t i = 0; i < nums; ++i) {
|
||||||
STableNode* pTable = taosArrayGetP(pTables, i);
|
STableNode* pTable = taosArrayGetP(pTables, i);
|
||||||
if (belongTable(pCxt->pParseCxt->db, (*pCol), pTable)) {
|
if (belongTable((*pCol), pTable)) {
|
||||||
foundTable = true;
|
foundTable = true;
|
||||||
bool foundCol = false;
|
bool foundCol = false;
|
||||||
pCxt->errCode = findAndSetColumn(pCxt, pCol, pTable, &foundCol);
|
pCxt->errCode = findAndSetColumn(pCxt, pCol, pTable, &foundCol);
|
||||||
|
|
Loading…
Reference in New Issue