mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Repair some issues with column aliases and RowExpr construction in the
presence of dropped columns. Document the already-presumed fact that eref aliases in relation RTEs are supposed to have entries for dropped columns; cause the user alias structs to have such entries too, so that there's always a one-to-one mapping to the underlying physical attnums. Adjust expandRTE() and related code to handle the case where a column that is part of a JOIN has been dropped. Generalize expandRTE()'s API so that it can be used in a couple of places that formerly rolled their own implementation of the same logic. Fix ruleutils.c to suppress display of aliases for columns that were dropped since the rule was made.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.118 2004/06/05 01:55:04 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.119 2004/08/19 20:57:40 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -57,10 +57,10 @@ static void compare_tlist_datatypes(List *tlist, List *colTypes,
|
||||
bool *differentTypes);
|
||||
static bool qual_is_pushdown_safe(Query *subquery, Index rti, Node *qual,
|
||||
bool *differentTypes);
|
||||
static void subquery_push_qual(Query *subquery,
|
||||
RangeTblEntry *rte, Index rti, Node *qual);
|
||||
static void subquery_push_qual(Query *subquery, List *rtable,
|
||||
Index rti, Node *qual);
|
||||
static void recurse_push_qual(Node *setOp, Query *topquery,
|
||||
RangeTblEntry *rte, Index rti, Node *qual);
|
||||
List *rtable, Index rti, Node *qual);
|
||||
|
||||
|
||||
/*
|
||||
@ -376,7 +376,7 @@ set_subquery_pathlist(Query *root, RelOptInfo *rel,
|
||||
if (qual_is_pushdown_safe(subquery, rti, clause, differentTypes))
|
||||
{
|
||||
/* Push it down */
|
||||
subquery_push_qual(subquery, rte, rti, clause);
|
||||
subquery_push_qual(subquery, root->rtable, rti, clause);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -780,12 +780,13 @@ qual_is_pushdown_safe(Query *subquery, Index rti, Node *qual,
|
||||
* subquery_push_qual - push down a qual that we have determined is safe
|
||||
*/
|
||||
static void
|
||||
subquery_push_qual(Query *subquery, RangeTblEntry *rte, Index rti, Node *qual)
|
||||
subquery_push_qual(Query *subquery, List *rtable, Index rti, Node *qual)
|
||||
{
|
||||
if (subquery->setOperations != NULL)
|
||||
{
|
||||
/* Recurse to push it separately to each component query */
|
||||
recurse_push_qual(subquery->setOperations, subquery, rte, rti, qual);
|
||||
recurse_push_qual(subquery->setOperations, subquery,
|
||||
rtable, rti, qual);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -799,7 +800,7 @@ subquery_push_qual(Query *subquery, RangeTblEntry *rte, Index rti, Node *qual)
|
||||
* This step also ensures that when we are pushing into a setop tree,
|
||||
* each component query gets its own copy of the qual.
|
||||
*/
|
||||
qual = ResolveNew(qual, rti, 0, rte,
|
||||
qual = ResolveNew(qual, rti, 0, rtable,
|
||||
subquery->targetList,
|
||||
CMD_SELECT, 0);
|
||||
subquery->havingQual = make_and_qual(subquery->havingQual,
|
||||
@ -818,7 +819,7 @@ subquery_push_qual(Query *subquery, RangeTblEntry *rte, Index rti, Node *qual)
|
||||
*/
|
||||
static void
|
||||
recurse_push_qual(Node *setOp, Query *topquery,
|
||||
RangeTblEntry *rte, Index rti, Node *qual)
|
||||
List *rtable, Index rti, Node *qual)
|
||||
{
|
||||
if (IsA(setOp, RangeTblRef))
|
||||
{
|
||||
@ -827,14 +828,14 @@ recurse_push_qual(Node *setOp, Query *topquery,
|
||||
Query *subquery = subrte->subquery;
|
||||
|
||||
Assert(subquery != NULL);
|
||||
subquery_push_qual(subquery, rte, rti, qual);
|
||||
subquery_push_qual(subquery, rtable, rti, qual);
|
||||
}
|
||||
else if (IsA(setOp, SetOperationStmt))
|
||||
{
|
||||
SetOperationStmt *op = (SetOperationStmt *) setOp;
|
||||
|
||||
recurse_push_qual(op->larg, topquery, rte, rti, qual);
|
||||
recurse_push_qual(op->rarg, topquery, rte, rti, qual);
|
||||
recurse_push_qual(op->larg, topquery, rtable, rti, qual);
|
||||
recurse_push_qual(op->rarg, topquery, rtable, rti, qual);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user