修复connect by 查询中使用同义词报错
函数ColumnRefFindRelname中,当没有显式指定别名时,应该采用 rte->eref->aliasname作为查找的表名,以此适配同义词场景
This commit is contained in:
@ -3566,8 +3566,14 @@ static char *ColumnRefFindRelname(ParseState *pstate, const char *colname)
|
||||
Value *col = (Value *)lfirst(lc2);
|
||||
if (strcmp(colname, strVal(col)) == 0) {
|
||||
if (rte->rtekind == RTE_RELATION) {
|
||||
relname = (rte->alias && rte->alias->aliasname) ?
|
||||
rte->alias->aliasname : rte->relname;
|
||||
if (rte->alias && rte->alias->aliasname) {
|
||||
relname = rte->alias->aliasname;
|
||||
} else if (rte->eref && rte->eref->aliasname) {
|
||||
/* should use eref->aliasname for SYNONYM*/
|
||||
relname = rte->eref->aliasname;
|
||||
} else {
|
||||
relname = rte->relname;
|
||||
}
|
||||
} else if (rte->rtekind == RTE_SUBQUERY) {
|
||||
relname = rte->alias->aliasname;
|
||||
} else if (rte->rtekind == RTE_CTE) {
|
||||
|
||||
Reference in New Issue
Block a user