PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
#include "access/table.h"
#include "catalog/pg_aggregate.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "commands/defrem.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/plannodes.h"
#include "optimizer/optimizer.h"
#include "optimizer/prep.h"
#include "optimizer/tlist.h"
#include "parser/parsetree.h"
#include "postgres_fdw.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/syscache.h"
#include "utils/typcache.h"
Go to the source code of this file.
Data Structures | |
struct | foreign_glob_cxt |
struct | foreign_loc_cxt |
struct | deparse_expr_cxt |
Macros | |
#define | REL_ALIAS_PREFIX "r" |
#define | ADD_REL_QUALIFIER(buf, varno) appendStringInfo((buf), "%s%d.", REL_ALIAS_PREFIX, (varno)) |
#define | SUBQUERY_REL_ALIAS_PREFIX "s" |
#define | SUBQUERY_COL_ALIAS_PREFIX "c" |
Typedefs | |
typedef struct foreign_glob_cxt | foreign_glob_cxt |
typedef struct foreign_loc_cxt | foreign_loc_cxt |
typedef struct deparse_expr_cxt | deparse_expr_cxt |
Enumerations | |
enum | FDWCollateState { FDW_COLLATE_NONE, FDW_COLLATE_SAFE, FDW_COLLATE_UNSAFE } |
Functions | |
static bool | foreign_expr_walker (Node *node, foreign_glob_cxt *glob_cxt, foreign_loc_cxt *outer_cxt) |
static char * | deparse_type_name (Oid type_oid, int32 typemod) |
static void | deparseTargetList (StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, bool is_returning, Bitmapset *attrs_used, bool qualify_col, List **retrieved_attrs) |
static void | deparseExplicitTargetList (List *tlist, bool is_returning, List **retrieved_attrs, deparse_expr_cxt *context) |
static void | deparseSubqueryTargetList (deparse_expr_cxt *context) |
static void | deparseReturningList (StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, bool trig_after_row, List *withCheckOptionList, List *returningList, List **retrieved_attrs) |
static void | deparseColumnRef (StringInfo buf, int varno, int varattno, RangeTblEntry *rte, bool qualify_col) |
static void | deparseRelation (StringInfo buf, Relation rel) |
static void | deparseExpr (Expr *expr, deparse_expr_cxt *context) |
static void | deparseVar (Var *node, deparse_expr_cxt *context) |
static void | deparseConst (Const *node, deparse_expr_cxt *context, int showtype) |
static void | deparseParam (Param *node, deparse_expr_cxt *context) |
static void | deparseSubscriptingRef (SubscriptingRef *node, deparse_expr_cxt *context) |
static void | deparseFuncExpr (FuncExpr *node, deparse_expr_cxt *context) |
static void | deparseOpExpr (OpExpr *node, deparse_expr_cxt *context) |
static void | deparseOperatorName (StringInfo buf, Form_pg_operator opform) |
static void | deparseDistinctExpr (DistinctExpr *node, deparse_expr_cxt *context) |
static void | deparseScalarArrayOpExpr (ScalarArrayOpExpr *node, deparse_expr_cxt *context) |
static void | deparseRelabelType (RelabelType *node, deparse_expr_cxt *context) |
static void | deparseBoolExpr (BoolExpr *node, deparse_expr_cxt *context) |
static void | deparseNullTest (NullTest *node, deparse_expr_cxt *context) |
static void | deparseArrayExpr (ArrayExpr *node, deparse_expr_cxt *context) |
static void | printRemoteParam (int paramindex, Oid paramtype, int32 paramtypmod, deparse_expr_cxt *context) |
static void | printRemotePlaceholder (Oid paramtype, int32 paramtypmod, deparse_expr_cxt *context) |
static void | deparseSelectSql (List *tlist, bool is_subquery, List **retrieved_attrs, deparse_expr_cxt *context) |
static void | deparseLockingClause (deparse_expr_cxt *context) |
static void | appendOrderByClause (List *pathkeys, bool has_final_sort, deparse_expr_cxt *context) |
static void | appendLimitClause (deparse_expr_cxt *context) |
static void | appendConditions (List *exprs, deparse_expr_cxt *context) |
static void | deparseFromExprForRel (StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel, bool use_alias, Index ignore_rel, List **ignore_conds, List **params_list) |
static void | deparseFromExpr (List *quals, deparse_expr_cxt *context) |
static void | deparseRangeTblRef (StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel, bool make_subquery, Index ignore_rel, List **ignore_conds, List **params_list) |
static void | deparseAggref (Aggref *node, deparse_expr_cxt *context) |
static void | appendGroupByClause (List *tlist, deparse_expr_cxt *context) |
static void | appendAggOrderBy (List *orderList, List *targetList, deparse_expr_cxt *context) |
static void | appendFunctionName (Oid funcid, deparse_expr_cxt *context) |
static Node * | deparseSortGroupClause (Index ref, List *tlist, bool force_colno, deparse_expr_cxt *context) |
static bool | is_subquery_var (Var *node, RelOptInfo *foreignrel, int *relno, int *colno) |
static void | get_relation_column_alias_ids (Var *node, RelOptInfo *foreignrel, int *relno, int *colno) |
void | classifyConditions (PlannerInfo *root, RelOptInfo *baserel, List *input_conds, List **remote_conds, List **local_conds) |
bool | is_foreign_expr (PlannerInfo *root, RelOptInfo *baserel, Expr *expr) |
bool | is_foreign_param (PlannerInfo *root, RelOptInfo *baserel, Expr *expr) |
List * | build_tlist_to_deparse (RelOptInfo *foreignrel) |
void | deparseSelectStmtForRel (StringInfo buf, PlannerInfo *root, RelOptInfo *rel, List *tlist, List *remote_conds, List *pathkeys, bool has_final_sort, bool has_limit, bool is_subquery, List **retrieved_attrs, List **params_list) |
const char * | get_jointype_name (JoinType jointype) |
void | deparseInsertSql (StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, List *targetAttrs, bool doNothing, List *withCheckOptionList, List *returningList, List **retrieved_attrs, int *values_end_len) |
void | rebuildInsertSql (StringInfo buf, char *orig_query, int values_end_len, int num_cols, int num_rows) |
void | deparseUpdateSql (StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, List *targetAttrs, List *withCheckOptionList, List *returningList, List **retrieved_attrs) |
void | deparseDirectUpdateSql (StringInfo buf, PlannerInfo *root, Index rtindex, Relation rel, RelOptInfo *foreignrel, List *targetlist, List *targetAttrs, List *remote_conds, List **params_list, List *returningList, List **retrieved_attrs) |
void | deparseDeleteSql (StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, List *returningList, List **retrieved_attrs) |
void | deparseDirectDeleteSql (StringInfo buf, PlannerInfo *root, Index rtindex, Relation rel, RelOptInfo *foreignrel, List *remote_conds, List **params_list, List *returningList, List **retrieved_attrs) |
void | deparseAnalyzeSizeSql (StringInfo buf, Relation rel) |
void | deparseAnalyzeSql (StringInfo buf, Relation rel, List **retrieved_attrs) |
void | deparseStringLiteral (StringInfo buf, const char *val) |
#define ADD_REL_QUALIFIER | ( | buf, | |
varno | |||
) | appendStringInfo((buf), "%s%d.", REL_ALIAS_PREFIX, (varno)) |
Definition at line 107 of file deparse.c.
Referenced by deparseColumnRef(), and deparseTargetList().
#define REL_ALIAS_PREFIX "r" |
Definition at line 105 of file deparse.c.
Referenced by deparseDirectDeleteSql(), deparseDirectUpdateSql(), deparseFromExprForRel(), and deparseLockingClause().
#define SUBQUERY_COL_ALIAS_PREFIX "c" |
Definition at line 110 of file deparse.c.
Referenced by deparseRangeTblRef(), and deparseVar().
#define SUBQUERY_REL_ALIAS_PREFIX "s" |
Definition at line 109 of file deparse.c.
Referenced by deparseRangeTblRef(), and deparseVar().
typedef struct deparse_expr_cxt deparse_expr_cxt |
typedef struct foreign_glob_cxt foreign_glob_cxt |
typedef struct foreign_loc_cxt foreign_loc_cxt |
enum FDWCollateState |
Enumerator | |
---|---|
FDW_COLLATE_NONE | |
FDW_COLLATE_SAFE | |
FDW_COLLATE_UNSAFE |
|
static |
Definition at line 3097 of file deparse.c.
References appendStringInfoString(), buf, deparse_expr_cxt::buf, deparseOperatorName(), deparseSortGroupClause(), elog, ERROR, exprType(), GETSTRUCT, TypeCacheEntry::gt_opr, HeapTupleIsValid, lfirst, lookup_type_cache(), TypeCacheEntry::lt_opr, SortGroupClause::nulls_first, ObjectIdGetDatum, OPEROID, ReleaseSysCache(), SearchSysCache1(), SortGroupClause::sortop, SortGroupClause::tleSortGroupRef, TYPECACHE_GT_OPR, and TYPECACHE_LT_OPR.
Referenced by deparseAggref().
|
static |
Definition at line 1340 of file deparse.c.
References appendStringInfoChar(), appendStringInfoString(), buf, deparse_expr_cxt::buf, deparseExpr(), IsA, lfirst, reset_transmission_modes(), and set_transmission_modes().
Referenced by deparseDirectDeleteSql(), deparseDirectUpdateSql(), deparseFromExpr(), deparseFromExprForRel(), and deparseSelectStmtForRel().
|
static |
Definition at line 3314 of file deparse.c.
References appendStringInfo(), appendStringInfoString(), buf, deparse_expr_cxt::buf, elog, ERROR, get_namespace_name(), GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum, PROCOID, proname, quote_identifier(), ReleaseSysCache(), and SearchSysCache1().
Referenced by deparseAggref(), and deparseFuncExpr().
|
static |
Definition at line 3195 of file deparse.c.
References appendStringInfoString(), Assert, buf, deparse_expr_cxt::buf, deparseSortGroupClause(), Query::groupClause, Query::groupingSets, lfirst, PlannerInfo::parse, deparse_expr_cxt::root, and SortGroupClause::tleSortGroupRef.
Referenced by deparseSelectStmtForRel().
|
static |
Definition at line 3286 of file deparse.c.
References appendStringInfoString(), buf, deparse_expr_cxt::buf, deparseExpr(), Query::limitCount, Query::limitOffset, PlannerInfo::parse, reset_transmission_modes(), foreign_glob_cxt::root, deparse_expr_cxt::root, and set_transmission_modes().
Referenced by deparseSelectStmtForRel().
|
static |
Definition at line 3232 of file deparse.c.
References appendStringInfoString(), Assert, BTLessStrategyNumber, buf, deparse_expr_cxt::buf, deparseExpr(), find_em_expr_for_input_target(), find_em_expr_for_rel(), deparse_expr_cxt::foreignrel, lfirst, PathKey::pk_eclass, PathKey::pk_nulls_first, PathKey::pk_strategy, RelOptInfo::reltarget, reset_transmission_modes(), deparse_expr_cxt::root, deparse_expr_cxt::scanrel, and set_transmission_modes().
Referenced by deparseSelectStmtForRel().
List* build_tlist_to_deparse | ( | RelOptInfo * | foreignrel | ) |
Definition at line 943 of file deparse.c.
References add_to_flat_tlist(), RestrictInfo::clause, PathTarget::exprs, RelOptInfo::fdw_private, PgFdwRelationInfo::grouped_tlist, IS_UPPER_REL, lfirst_node, PgFdwRelationInfo::local_conds, NIL, pull_var_clause(), PVC_RECURSE_PLACEHOLDERS, and RelOptInfo::reltarget.
Referenced by estimate_path_cost_size(), and postgresGetForeignPlan().
void classifyConditions | ( | PlannerInfo * | root, |
RelOptInfo * | baserel, | ||
List * | input_conds, | ||
List ** | remote_conds, | ||
List ** | local_conds | ||
) |
Definition at line 204 of file deparse.c.
References RestrictInfo::clause, is_foreign_expr(), lappend(), lfirst_node, and NIL.
Referenced by estimate_path_cost_size(), and postgresGetForeignRelSize().
Definition at line 924 of file deparse.c.
References format_type_extended(), FORMAT_TYPE_FORCE_QUALIFY, FORMAT_TYPE_TYPEMOD_GIVEN, and is_builtin().
Referenced by deparseArrayExpr(), deparseConst(), deparseFuncExpr(), deparseRelabelType(), printRemoteParam(), and printRemotePlaceholder().
|
static |
Definition at line 3005 of file deparse.c.
References Aggref::aggdirectargs, Aggref::aggdistinct, Aggref::aggfilter, Aggref::aggfnoid, Aggref::aggkind, Aggref::aggorder, Aggref::aggsplit, AGGSPLIT_SIMPLE, Aggref::aggstar, Aggref::aggvariadic, appendAggOrderBy(), appendFunctionName(), appendStringInfoChar(), appendStringInfoString(), arg, Aggref::args, Assert, buf, deparse_expr_cxt::buf, deparseExpr(), TargetEntry::expr, lfirst, lnext(), NIL, and TargetEntry::resjunk.
Referenced by deparseExpr().
void deparseAnalyzeSizeSql | ( | StringInfo | buf, |
Relation | rel | ||
) |
Definition at line 2100 of file deparse.c.
References appendStringInfo(), appendStringInfoString(), StringInfoData::data, deparseRelation(), deparseStringLiteral(), initStringInfo(), and relname.
Referenced by postgresAnalyzeForeignTable().
void deparseAnalyzeSql | ( | StringInfo | buf, |
Relation | rel, | ||
List ** | retrieved_attrs | ||
) |
Definition at line 2120 of file deparse.c.
References appendStringInfoString(), attname, defGetString(), DefElem::defname, deparseRelation(), GetForeignColumnOptions(), i, lappend_int(), lfirst, NameStr, TupleDescData::natts, NIL, options, quote_identifier(), RelationGetDescr, RelationGetRelid, and TupleDescAttr.
Referenced by postgresAcquireSampleRowsFunc().
|
static |
Definition at line 2979 of file deparse.c.
References appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), ArrayExpr::array_typeid, buf, deparse_expr_cxt::buf, deparse_type_name(), deparseExpr(), ArrayExpr::elements, lfirst, and NIL.
Referenced by deparseExpr().
|
static |
Definition at line 2908 of file deparse.c.
References AND_EXPR, appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), BoolExpr::args, BoolExpr::boolop, buf, deparse_expr_cxt::buf, deparseExpr(), lfirst, linitial, NOT_EXPR, and OR_EXPR.
Referenced by deparseExpr().
|
static |
Definition at line 2181 of file deparse.c.
References ADD_REL_QUALIFIER, appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), Assert, bms_add_member(), bms_free(), defGetString(), DefElem::defname, deparseTargetList(), FirstLowInvalidHeapAttributeNumber, get_attname(), GetForeignColumnOptions(), IS_SPECIAL_VARNO, lfirst, NoLock, options, quote_identifier(), RangeTblEntry::relid, SelfItemPointerAttributeNumber, table_close(), table_open(), and TableOidAttributeNumber.
Referenced by deparseDirectUpdateSql(), deparseInsertSql(), deparseTargetList(), deparseUpdateSql(), and deparseVar().
|
static |
Definition at line 2512 of file deparse.c.
References appendStringInfo(), appendStringInfoString(), buf, deparse_expr_cxt::buf, Const::constisnull, Const::consttype, Const::consttypmod, Const::constvalue, deparse_type_name(), deparseStringLiteral(), getTypeOutputInfo(), OidOutputFunctionCall(), and pfree().
Referenced by deparseExpr(), and deparseSortGroupClause().
void deparseDeleteSql | ( | StringInfo | buf, |
RangeTblEntry * | rte, | ||
Index | rtindex, | ||
Relation | rel, | ||
List * | returningList, | ||
List ** | retrieved_attrs | ||
) |
Definition at line 1963 of file deparse.c.
References appendStringInfoString(), deparseRelation(), deparseReturningList(), NIL, TriggerDesc::trig_delete_after_row, and RelationData::trigdesc.
Referenced by postgresPlanForeignModify().
void deparseDirectDeleteSql | ( | StringInfo | buf, |
PlannerInfo * | root, | ||
Index | rtindex, | ||
Relation | rel, | ||
RelOptInfo * | foreignrel, | ||
List * | remote_conds, | ||
List ** | params_list, | ||
List * | returningList, | ||
List ** | retrieved_attrs | ||
) |
Definition at line 1992 of file deparse.c.
References appendConditions(), appendStringInfo(), appendStringInfoString(), buf, deparse_expr_cxt::buf, deparseExplicitTargetList(), deparseFromExprForRel(), deparseRelation(), deparseReturningList(), foreign_glob_cxt::foreignrel, deparse_expr_cxt::foreignrel, list_concat(), NIL, deparse_expr_cxt::params_list, planner_rt_fetch, REL_ALIAS_PREFIX, RELOPT_JOINREL, RelOptInfo::reloptkind, foreign_glob_cxt::root, deparse_expr_cxt::root, and deparse_expr_cxt::scanrel.
Referenced by postgresPlanDirectModify().
void deparseDirectUpdateSql | ( | StringInfo | buf, |
PlannerInfo * | root, | ||
Index | rtindex, | ||
Relation | rel, | ||
RelOptInfo * | foreignrel, | ||
List * | targetlist, | ||
List * | targetAttrs, | ||
List * | remote_conds, | ||
List ** | params_list, | ||
List * | returningList, | ||
List ** | retrieved_attrs | ||
) |
Definition at line 1878 of file deparse.c.
References appendConditions(), appendStringInfo(), appendStringInfoString(), attnum, buf, deparse_expr_cxt::buf, deparseColumnRef(), deparseExplicitTargetList(), deparseExpr(), deparseFromExprForRel(), deparseRelation(), deparseReturningList(), elog, ERROR, TargetEntry::expr, foreign_glob_cxt::foreignrel, deparse_expr_cxt::foreignrel, get_tle_by_resno(), lfirst_int, list_concat(), NIL, deparse_expr_cxt::params_list, planner_rt_fetch, REL_ALIAS_PREFIX, RELOPT_JOINREL, RelOptInfo::reloptkind, reset_transmission_modes(), foreign_glob_cxt::root, deparse_expr_cxt::root, deparse_expr_cxt::scanrel, and set_transmission_modes().
Referenced by postgresPlanDirectModify().
|
static |
Definition at line 2832 of file deparse.c.
References appendStringInfoChar(), appendStringInfoString(), OpExpr::args, Assert, buf, deparse_expr_cxt::buf, deparseExpr(), linitial, list_length(), and lsecond.
Referenced by deparseExpr().
|
static |
Definition at line 1411 of file deparse.c.
References appendStringInfoString(), buf, deparse_expr_cxt::buf, deparseExpr(), TargetEntry::expr, i, lappend_int(), lfirst_node, and NIL.
Referenced by deparseDirectDeleteSql(), deparseDirectUpdateSql(), and deparseSelectSql().
|
static |
Definition at line 2384 of file deparse.c.
References deparseAggref(), deparseArrayExpr(), deparseBoolExpr(), deparseConst(), deparseDistinctExpr(), deparseFuncExpr(), deparseNullTest(), deparseOpExpr(), deparseParam(), deparseRelabelType(), deparseScalarArrayOpExpr(), deparseSubscriptingRef(), deparseVar(), elog, ERROR, nodeTag, T_Aggref, T_ArrayExpr, T_BoolExpr, T_Const, T_DistinctExpr, T_FuncExpr, T_NullTest, T_OpExpr, T_Param, T_RelabelType, T_ScalarArrayOpExpr, T_SubscriptingRef, and T_Var.
Referenced by appendConditions(), appendLimitClause(), appendOrderByClause(), deparseAggref(), deparseArrayExpr(), deparseBoolExpr(), deparseDirectUpdateSql(), deparseDistinctExpr(), deparseExplicitTargetList(), deparseFuncExpr(), deparseNullTest(), deparseOpExpr(), deparseRelabelType(), deparseScalarArrayOpExpr(), deparseSortGroupClause(), deparseSubqueryTargetList(), and deparseSubscriptingRef().
|
static |
Definition at line 1140 of file deparse.c.
References appendConditions(), appendStringInfoString(), Assert, bms_membership(), BMS_MULTIPLE, buf, deparse_expr_cxt::buf, deparseFromExprForRel(), deparse_expr_cxt::foreignrel, IS_JOIN_REL, IS_SIMPLE_REL, IS_UPPER_REL, NIL, deparse_expr_cxt::params_list, RelOptInfo::relids, deparse_expr_cxt::root, and deparse_expr_cxt::scanrel.
Referenced by deparseSelectStmtForRel().
|
static |
Definition at line 1488 of file deparse.c.
References appendBinaryStringInfo(), appendConditions(), appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), Assert, bms_is_member(), buf, deparse_expr_cxt::buf, StringInfoData::data, deparseRangeTblRef(), deparseRelation(), RelOptInfo::fdw_private, foreign_glob_cxt::foreignrel, deparse_expr_cxt::foreignrel, get_jointype_name(), initStringInfo(), PgFdwRelationInfo::innerrel, IS_JOIN_REL, JOIN_INNER, PgFdwRelationInfo::joinclauses, PgFdwRelationInfo::jointype, StringInfoData::len, list_concat(), PgFdwRelationInfo::make_innerrel_subquery, PgFdwRelationInfo::make_outerrel_subquery, NIL, NoLock, PgFdwRelationInfo::outerrel, deparse_expr_cxt::params_list, planner_rt_fetch, REL_ALIAS_PREFIX, RelOptInfo::relid, RangeTblEntry::relid, RelOptInfo::relids, foreign_glob_cxt::root, deparse_expr_cxt::root, deparse_expr_cxt::scanrel, table_close(), and table_open().
Referenced by deparseDirectDeleteSql(), deparseDirectUpdateSql(), deparseFromExpr(), and deparseRangeTblRef().
|
static |
Definition at line 2697 of file deparse.c.
References appendFunctionName(), appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), arg, FuncExpr::args, buf, deparse_expr_cxt::buf, COERCE_EXPLICIT_CAST, COERCE_IMPLICIT_CAST, deparse_type_name(), deparseExpr(), exprIsLengthCoercion(), FuncExpr::funcformat, FuncExpr::funcid, FuncExpr::funcresulttype, FuncExpr::funcvariadic, lfirst, linitial, and lnext().
Referenced by deparseExpr().
void deparseInsertSql | ( | StringInfo | buf, |
RangeTblEntry * | rte, | ||
Index | rtindex, | ||
Relation | rel, | ||
List * | targetAttrs, | ||
bool | doNothing, | ||
List * | withCheckOptionList, | ||
List * | returningList, | ||
List ** | retrieved_attrs, | ||
int * | values_end_len | ||
) |
Definition at line 1713 of file deparse.c.
References appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), attnum, deparseColumnRef(), deparseRelation(), deparseReturningList(), StringInfoData::len, lfirst_int, TriggerDesc::trig_insert_after_row, and RelationData::trigdesc.
Referenced by postgresBeginForeignInsert(), and postgresPlanForeignModify().
|
static |
Definition at line 1250 of file deparse.c.
References appendStringInfo(), appendStringInfoString(), bms_is_member(), bms_membership(), BMS_MULTIPLE, bms_next_member(), buf, deparse_expr_cxt::buf, CMD_DELETE, CMD_UPDATE, Query::commandType, RelOptInfo::fdw_private, get_plan_rowmark(), IS_JOIN_REL, LCS_FORKEYSHARE, LCS_FORNOKEYUPDATE, LCS_FORSHARE, LCS_FORUPDATE, LCS_NONE, PgFdwRelationInfo::lower_subquery_rels, PlannerInfo::parse, REL_ALIAS_PREFIX, RelOptInfo::relids, Query::resultRelation, foreign_glob_cxt::root, deparse_expr_cxt::root, PlannerInfo::rowMarks, deparse_expr_cxt::scanrel, and PlanRowMark::strength.
Referenced by deparseSelectStmtForRel().
|
static |
Definition at line 2946 of file deparse.c.
References appendStringInfoChar(), appendStringInfoString(), NullTest::arg, NullTest::argisrow, buf, deparse_expr_cxt::buf, deparseExpr(), exprType(), IS_NULL, NullTest::nulltesttype, and type_is_rowtype().
Referenced by deparseExpr().
|
static |
Definition at line 2804 of file deparse.c.
References appendStringInfo(), appendStringInfoString(), get_namespace_name(), NameStr, and quote_identifier().
Referenced by appendAggOrderBy(), deparseOpExpr(), and deparseScalarArrayOpExpr().
|
static |
Definition at line 2760 of file deparse.c.
References appendStringInfoChar(), OpExpr::args, Assert, buf, deparse_expr_cxt::buf, deparseExpr(), deparseOperatorName(), elog, ERROR, GETSTRUCT, HeapTupleIsValid, linitial, list_length(), llast, ObjectIdGetDatum, OPEROID, OpExpr::opno, ReleaseSysCache(), and SearchSysCache1().
Referenced by deparseExpr().
|
static |
Definition at line 2618 of file deparse.c.
References equal(), lappend(), lfirst, deparse_expr_cxt::params_list, Param::paramtype, Param::paramtypmod, printRemoteParam(), and printRemotePlaceholder().
Referenced by deparseExpr().
|
static |
Definition at line 1639 of file deparse.c.
References appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), Assert, bms_is_member(), deparseFromExprForRel(), deparseSelectStmtForRel(), PathTarget::exprs, RelOptInfo::fdw_private, i, IS_JOIN_REL, IS_SIMPLE_REL, list_length(), PgFdwRelationInfo::local_conds, NIL, PgFdwRelationInfo::relation_index, RelOptInfo::relids, RelOptInfo::reltarget, PgFdwRelationInfo::remote_conds, SUBQUERY_COL_ALIAS_PREFIX, and SUBQUERY_REL_ALIAS_PREFIX.
Referenced by deparseFromExprForRel().
|
static |
Definition at line 2895 of file deparse.c.
References appendStringInfo(), RelabelType::arg, deparse_expr_cxt::buf, COERCE_IMPLICIT_CAST, deparse_type_name(), deparseExpr(), RelabelType::relabelformat, RelabelType::resulttype, and RelabelType::resulttypmod.
Referenced by deparseExpr().
|
static |
Definition at line 2309 of file deparse.c.
References appendStringInfo(), defGetString(), DefElem::defname, get_namespace_name(), GetForeignTable(), lfirst, ForeignTable::options, quote_identifier(), RelationGetNamespace, RelationGetRelationName, RelationGetRelid, and relname.
Referenced by deparseAnalyzeSizeSql(), deparseAnalyzeSql(), deparseDeleteSql(), deparseDirectDeleteSql(), deparseDirectUpdateSql(), deparseFromExprForRel(), deparseInsertSql(), and deparseUpdateSql().
|
static |
Definition at line 2043 of file deparse.c.
References bms_make_singleton(), deparseTargetList(), FirstLowInvalidHeapAttributeNumber, NIL, and pull_varattnos().
Referenced by deparseDeleteSql(), deparseDirectDeleteSql(), deparseDirectUpdateSql(), deparseInsertSql(), and deparseUpdateSql().
|
static |
Definition at line 2850 of file deparse.c.
References appendStringInfo(), appendStringInfoChar(), ScalarArrayOpExpr::args, Assert, buf, deparse_expr_cxt::buf, deparseExpr(), deparseOperatorName(), elog, ERROR, GETSTRUCT, HeapTupleIsValid, linitial, list_length(), lsecond, ObjectIdGetDatum, OPEROID, ScalarArrayOpExpr::opno, ReleaseSysCache(), SearchSysCache1(), and ScalarArrayOpExpr::useOr.
Referenced by deparseExpr().
|
static |
Definition at line 1082 of file deparse.c.
References appendStringInfoString(), PgFdwRelationInfo::attrs_used, buf, deparse_expr_cxt::buf, deparseExplicitTargetList(), deparseSubqueryTargetList(), deparseTargetList(), RelOptInfo::fdw_private, foreign_glob_cxt::foreignrel, deparse_expr_cxt::foreignrel, IS_JOIN_REL, IS_UPPER_REL, NoLock, planner_rt_fetch, RelOptInfo::relid, RangeTblEntry::relid, foreign_glob_cxt::root, deparse_expr_cxt::root, table_close(), and table_open().
Referenced by deparseSelectStmtForRel().
void deparseSelectStmtForRel | ( | StringInfo | buf, |
PlannerInfo * | root, | ||
RelOptInfo * | rel, | ||
List * | tlist, | ||
List * | remote_conds, | ||
List * | pathkeys, | ||
bool | has_final_sort, | ||
bool | has_limit, | ||
bool | is_subquery, | ||
List ** | retrieved_attrs, | ||
List ** | params_list | ||
) |
Definition at line 1000 of file deparse.c.
References appendConditions(), appendGroupByClause(), appendLimitClause(), appendOrderByClause(), appendStringInfoString(), Assert, buf, deparse_expr_cxt::buf, deparseFromExpr(), deparseLockingClause(), deparseSelectSql(), RelOptInfo::fdw_private, deparse_expr_cxt::foreignrel, IS_JOIN_REL, IS_SIMPLE_REL, IS_UPPER_REL, PgFdwRelationInfo::outerrel, deparse_expr_cxt::params_list, PgFdwRelationInfo::remote_conds, foreign_glob_cxt::root, deparse_expr_cxt::root, and deparse_expr_cxt::scanrel.
Referenced by deparseRangeTblRef(), estimate_path_cost_size(), and postgresGetForeignPlan().
|
static |
Definition at line 3349 of file deparse.c.
References appendStringInfo(), appendStringInfoChar(), Assert, buf, deparse_expr_cxt::buf, deparseConst(), deparseExpr(), TargetEntry::expr, get_sortgroupref_tle(), IsA, TargetEntry::resjunk, and TargetEntry::resno.
Referenced by appendAggOrderBy(), and appendGroupByClause().
void deparseStringLiteral | ( | StringInfo | buf, |
const char * | val | ||
) |
Definition at line 2349 of file deparse.c.
References appendStringInfoChar(), ESCAPE_STRING_SYNTAX, and SQL_STR_DOUBLE.
Referenced by deparseAnalyzeSizeSql(), deparseConst(), and postgresImportForeignSchema().
|
static |
Definition at line 1447 of file deparse.c.
References appendStringInfoString(), Assert, buf, deparse_expr_cxt::buf, deparseExpr(), PathTarget::exprs, foreign_glob_cxt::foreignrel, deparse_expr_cxt::foreignrel, IS_JOIN_REL, IS_SIMPLE_REL, lfirst, and RelOptInfo::reltarget.
Referenced by deparseSelectSql().
|
static |
Definition at line 2651 of file deparse.c.
References appendStringInfoChar(), buf, deparse_expr_cxt::buf, deparseExpr(), IsA, lfirst, list_head(), lnext(), SubscriptingRef::refexpr, SubscriptingRef::reflowerindexpr, and SubscriptingRef::refupperindexpr.
Referenced by deparseExpr().
|
static |
Definition at line 1174 of file deparse.c.
References ADD_REL_QUALIFIER, appendStringInfoString(), bms_is_member(), deparseColumnRef(), FirstLowInvalidHeapAttributeNumber, i, lappend_int(), TupleDescData::natts, NIL, RelationGetDescr, SelfItemPointerAttributeNumber, and TupleDescAttr.
Referenced by deparseColumnRef(), deparseReturningList(), and deparseSelectSql().
void deparseUpdateSql | ( | StringInfo | buf, |
RangeTblEntry * | rte, | ||
Index | rtindex, | ||
Relation | rel, | ||
List * | targetAttrs, | ||
List * | withCheckOptionList, | ||
List * | returningList, | ||
List ** | retrieved_attrs | ||
) |
Definition at line 1826 of file deparse.c.
References appendStringInfo(), appendStringInfoString(), attnum, deparseColumnRef(), deparseRelation(), deparseReturningList(), lfirst_int, TriggerDesc::trig_update_after_row, and RelationData::trigdesc.
Referenced by postgresPlanForeignModify().
|
static |
Definition at line 2446 of file deparse.c.
References appendStringInfo(), bms_is_member(), bms_membership(), BMS_MULTIPLE, deparse_expr_cxt::buf, deparseColumnRef(), equal(), is_subquery_var(), lappend(), lfirst, deparse_expr_cxt::params_list, planner_rt_fetch, printRemoteParam(), printRemotePlaceholder(), foreign_glob_cxt::relids, RelOptInfo::relids, deparse_expr_cxt::root, deparse_expr_cxt::scanrel, SUBQUERY_COL_ALIAS_PREFIX, SUBQUERY_REL_ALIAS_PREFIX, Var::varattno, Var::varlevelsup, Var::varno, Var::vartype, and Var::vartypmod.
Referenced by deparseExpr().
|
static |
Definition at line 294 of file deparse.c.
References Aggref::aggcollid, Aggref::aggfilter, Aggref::aggfnoid, Aggref::aggorder, Aggref::aggsplit, AGGSPLIT_SIMPLE, RelabelType::arg, NullTest::arg, Aggref::args, FuncExpr::args, OpExpr::args, ScalarArrayOpExpr::args, BoolExpr::args, ArrayExpr::array_collid, bms_is_member(), foreign_loc_cxt::collation, Const::constcollid, ArrayExpr::elements, TargetEntry::expr, exprType(), FDW_COLLATE_NONE, FDW_COLLATE_SAFE, FDW_COLLATE_UNSAFE, RelOptInfo::fdw_private, fe(), foreign_glob_cxt::foreignrel, FuncExpr::funccollid, FuncExpr::funcid, get_sortgroupref_tle(), TypeCacheEntry::gt_opr, Aggref::inputcollid, FuncExpr::inputcollid, OpExpr::inputcollid, ScalarArrayOpExpr::inputcollid, InvalidOid, is_shippable(), IS_UPPER_REL, IsA, lfirst, lookup_type_cache(), TypeCacheEntry::lt_opr, nodeTag, OidIsValid, OpExpr::opcollid, OpExpr::opno, ScalarArrayOpExpr::opno, PARAM_MULTIEXPR, Param::paramcollid, Param::paramkind, SubscriptingRef::refassgnexpr, SubscriptingRef::refcollid, SubscriptingRef::refexpr, SubscriptingRef::reflowerindexpr, SubscriptingRef::refupperindexpr, foreign_glob_cxt::relids, RelabelType::resultcollid, SelfItemPointerAttributeNumber, SortGroupClause::sortop, foreign_loc_cxt::state, T_Aggref, T_ArrayExpr, T_BoolExpr, T_Const, T_DistinctExpr, T_FuncExpr, T_List, T_NullTest, T_OpExpr, T_Param, T_RelabelType, T_ScalarArrayOpExpr, T_SubscriptingRef, T_Var, SortGroupClause::tleSortGroupRef, TYPECACHE_GT_OPR, TYPECACHE_LT_OPR, Var::varattno, Var::varcollid, Var::varlevelsup, and Var::varno.
Referenced by is_foreign_expr().
const char* get_jointype_name | ( | JoinType | jointype | ) |
Definition at line 1374 of file deparse.c.
References elog, ERROR, JOIN_FULL, JOIN_INNER, JOIN_LEFT, and JOIN_RIGHT.
Referenced by deparseFromExprForRel(), and foreign_join_ok().
|
static |
Definition at line 3456 of file deparse.c.
References elog, equal(), ERROR, PathTarget::exprs, RelOptInfo::fdw_private, i, lfirst, PgFdwRelationInfo::relation_index, and RelOptInfo::reltarget.
Referenced by is_subquery_var().
bool is_foreign_expr | ( | PlannerInfo * | root, |
RelOptInfo * | baserel, | ||
Expr * | expr | ||
) |
Definition at line 230 of file deparse.c.
References foreign_loc_cxt::collation, contain_mutable_functions(), FDW_COLLATE_NONE, FDW_COLLATE_UNSAFE, RelOptInfo::fdw_private, foreign_expr_walker(), foreign_glob_cxt::foreignrel, InvalidOid, IS_UPPER_REL, PgFdwRelationInfo::outerrel, foreign_glob_cxt::relids, RelOptInfo::relids, foreign_glob_cxt::root, and foreign_loc_cxt::state.
Referenced by add_foreign_final_paths(), add_foreign_ordered_paths(), classifyConditions(), foreign_grouping_ok(), foreign_join_ok(), get_useful_pathkeys_for_relation(), postgresGetForeignPaths(), postgresGetForeignPlan(), and postgresPlanDirectModify().
bool is_foreign_param | ( | PlannerInfo * | root, |
RelOptInfo * | baserel, | ||
Expr * | expr | ||
) |
Definition at line 876 of file deparse.c.
References bms_is_member(), RelOptInfo::fdw_private, IS_UPPER_REL, nodeTag, PgFdwRelationInfo::outerrel, foreign_glob_cxt::relids, RelOptInfo::relids, T_Param, T_Var, Var::varlevelsup, and Var::varno.
Referenced by foreign_grouping_ok().
|
static |
Definition at line 3394 of file deparse.c.
References Assert, bms_is_member(), RelOptInfo::fdw_private, get_relation_column_alias_ids(), PgFdwRelationInfo::innerrel, IS_JOIN_REL, IS_SIMPLE_REL, PgFdwRelationInfo::lower_subquery_rels, PgFdwRelationInfo::make_innerrel_subquery, PgFdwRelationInfo::make_outerrel_subquery, PgFdwRelationInfo::outerrel, and Var::varno.
Referenced by deparseVar().
|
static |
Definition at line 3156 of file deparse.c.
References appendStringInfo(), buf, deparse_expr_cxt::buf, and deparse_type_name().
Referenced by deparseParam(), and deparseVar().
|
static |
Definition at line 3182 of file deparse.c.
References appendStringInfo(), buf, deparse_expr_cxt::buf, and deparse_type_name().
Referenced by deparseParam(), and deparseVar().
void rebuildInsertSql | ( | StringInfo | buf, |
char * | orig_query, | ||
int | values_end_len, | ||
int | num_cols, | ||
int | num_rows | ||
) |
Definition at line 1777 of file deparse.c.
References appendBinaryStringInfo(), appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), Assert, and i.
Referenced by execute_foreign_modify().