mirror of
https://github.com/postgres/postgres.git
synced 2026-01-05 23:38:41 +03:00
Commit e7cb7ee14, which introduced the infrastructure for FDWs and
custom scan providers to replace joins with scans, failed to add support
handling of pseudoconstant quals assigned to replaced joins in
createplan.c, leading to an incorrect plan without a gating Result node
when postgres_fdw replaced a join with such a qual.
To fix, we could add the support by 1) modifying the ForeignPath and
CustomPath structs to store the list of RestrictInfo nodes to apply to
the join, as in JoinPaths, if they represent foreign and custom scans
replacing a join with a scan, and by 2) modifying create_scan_plan() in
createplan.c to use that list in that case, instead of the
baserestrictinfo list, to get pseudoconstant quals assigned to the join;
but #1 would cause an ABI break. So fix by modifying the infrastructure
to just disallow replacing joins with such quals.
Back-patch to all supported branches.
Reported by Nishant Sharma. Patch by me, reviewed by Nishant Sharma and
Richard Guo.
Discussion: https://postgr.es/m/CADrsxdbcN1vejBaf8a%2BQhrZY5PXL-04mCd4GDu6qm6FigDZd6Q%40mail.gmail.com
54 lines
1.9 KiB
C
54 lines
1.9 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* restrictinfo.h
|
|
* prototypes for restrictinfo.c.
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/optimizer/restrictinfo.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef RESTRICTINFO_H
|
|
#define RESTRICTINFO_H
|
|
|
|
#include "nodes/pathnodes.h"
|
|
|
|
|
|
/* Convenience macro for the common case of a valid-everywhere qual */
|
|
#define make_simple_restrictinfo(root, clause) \
|
|
make_restrictinfo(root, clause, true, false, false, false, 0, \
|
|
NULL, NULL, NULL)
|
|
|
|
extern RestrictInfo *make_restrictinfo(PlannerInfo *root,
|
|
Expr *clause,
|
|
bool is_pushed_down,
|
|
bool has_clone,
|
|
bool is_clone,
|
|
bool pseudoconstant,
|
|
Index security_level,
|
|
Relids required_relids,
|
|
Relids incompatible_relids,
|
|
Relids outer_relids);
|
|
extern RestrictInfo *commute_restrictinfo(RestrictInfo *rinfo, Oid comm_op);
|
|
extern bool restriction_is_or_clause(RestrictInfo *restrictinfo);
|
|
extern bool restriction_is_securely_promotable(RestrictInfo *restrictinfo,
|
|
RelOptInfo *rel);
|
|
extern List *get_actual_clauses(List *restrictinfo_list);
|
|
extern List *extract_actual_clauses(List *restrictinfo_list,
|
|
bool pseudoconstant);
|
|
extern void extract_actual_join_clauses(List *restrictinfo_list,
|
|
Relids joinrelids,
|
|
List **joinquals,
|
|
List **otherquals);
|
|
extern bool has_pseudoconstant_clauses(PlannerInfo *root,
|
|
List *restrictinfo_list);
|
|
extern bool join_clause_is_movable_to(RestrictInfo *rinfo, RelOptInfo *baserel);
|
|
extern bool join_clause_is_movable_into(RestrictInfo *rinfo,
|
|
Relids currentrelids,
|
|
Relids current_and_outer);
|
|
|
|
#endif /* RESTRICTINFO_H */
|