PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <ctype.h>
#include "access/htup_details.h"
#include "access/relation.h"
#include "access/sysattr.h"
#include "access/table.h"
#include "catalog/heap.h"
#include "catalog/namespace.h"
#include "catalog/pg_type.h"
#include "funcapi.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "parser/parse_enr.h"
#include "parser/parse_relation.h"
#include "parser/parse_type.h"
#include "parser/parsetree.h"
#include "storage/lmgr.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/syscache.h"
#include "utils/varlena.h"
Go to the source code of this file.
Data Structures | |
struct | FuzzyAttrMatchState |
Macros | |
#define | MAX_FUZZY_DISTANCE 3 |
Functions | |
static ParseNamespaceItem * | scanNameSpaceForRefname (ParseState *pstate, const char *refname, int location) |
static ParseNamespaceItem * | scanNameSpaceForRelid (ParseState *pstate, Oid relid, int location) |
static void | check_lateral_ref_ok (ParseState *pstate, ParseNamespaceItem *nsitem, int location) |
static int | scanRTEForColumn (ParseState *pstate, RangeTblEntry *rte, Alias *eref, const char *colname, int location, int fuzzy_rte_penalty, FuzzyAttrMatchState *fuzzystate) |
static void | markRTEForSelectPriv (ParseState *pstate, int rtindex, AttrNumber col) |
static void | expandRelation (Oid relid, Alias *eref, int rtindex, int sublevels_up, int location, bool include_dropped, List **colnames, List **colvars) |
static void | expandTupleDesc (TupleDesc tupdesc, Alias *eref, int count, int offset, int rtindex, int sublevels_up, int location, bool include_dropped, List **colnames, List **colvars) |
static int | specialAttNum (const char *attname) |
static bool | rte_visible_if_lateral (ParseState *pstate, RangeTblEntry *rte) |
static bool | rte_visible_if_qualified (ParseState *pstate, RangeTblEntry *rte) |
static bool | isQueryUsingTempRelation_walker (Node *node, void *context) |
ParseNamespaceItem * | refnameNamespaceItem (ParseState *pstate, const char *schemaname, const char *refname, int location, int *sublevels_up) |
CommonTableExpr * | scanNameSpaceForCTE (ParseState *pstate, const char *refname, Index *ctelevelsup) |
static bool | isFutureCTE (ParseState *pstate, const char *refname) |
bool | scanNameSpaceForENR (ParseState *pstate, const char *refname) |
static RangeTblEntry * | searchRangeTableForRel (ParseState *pstate, RangeVar *relation) |
void | checkNameSpaceConflicts (ParseState *pstate, List *namespace1, List *namespace2) |
ParseNamespaceItem * | GetNSItemByRangeTablePosn (ParseState *pstate, int varno, int sublevels_up) |
RangeTblEntry * | GetRTEByRangeTablePosn (ParseState *pstate, int varno, int sublevels_up) |
CommonTableExpr * | GetCTEForRTE (ParseState *pstate, RangeTblEntry *rte, int rtelevelsup) |
static void | updateFuzzyAttrMatchState (int fuzzy_rte_penalty, FuzzyAttrMatchState *fuzzystate, RangeTblEntry *rte, const char *actual, const char *match, int attnum) |
Node * | scanNSItemForColumn (ParseState *pstate, ParseNamespaceItem *nsitem, int sublevels_up, const char *colname, int location) |
Node * | colNameToVar (ParseState *pstate, const char *colname, bool localonly, int location) |
static FuzzyAttrMatchState * | searchRangeTableForCol (ParseState *pstate, const char *alias, const char *colname, int location) |
void | markNullableIfNeeded (ParseState *pstate, Var *var) |
void | markVarForSelectPriv (ParseState *pstate, Var *var) |
static void | buildRelationAliases (TupleDesc tupdesc, Alias *alias, Alias *eref) |
static char * | chooseScalarFunctionAlias (Node *funcexpr, char *funcname, Alias *alias, int nfuncs) |
static ParseNamespaceItem * | buildNSItemFromTupleDesc (RangeTblEntry *rte, Index rtindex, RTEPermissionInfo *perminfo, TupleDesc tupdesc) |
static ParseNamespaceItem * | buildNSItemFromLists (RangeTblEntry *rte, Index rtindex, List *coltypes, List *coltypmods, List *colcollations) |
Relation | parserOpenTable (ParseState *pstate, const RangeVar *relation, int lockmode) |
ParseNamespaceItem * | addRangeTableEntry (ParseState *pstate, RangeVar *relation, Alias *alias, bool inh, bool inFromCl) |
ParseNamespaceItem * | addRangeTableEntryForRelation (ParseState *pstate, Relation rel, int lockmode, Alias *alias, bool inh, bool inFromCl) |
ParseNamespaceItem * | addRangeTableEntryForSubquery (ParseState *pstate, Query *subquery, Alias *alias, bool lateral, bool inFromCl) |
ParseNamespaceItem * | addRangeTableEntryForFunction (ParseState *pstate, List *funcnames, List *funcexprs, List *coldeflists, RangeFunction *rangefunc, bool lateral, bool inFromCl) |
ParseNamespaceItem * | addRangeTableEntryForTableFunc (ParseState *pstate, TableFunc *tf, Alias *alias, bool lateral, bool inFromCl) |
ParseNamespaceItem * | addRangeTableEntryForValues (ParseState *pstate, List *exprs, List *coltypes, List *coltypmods, List *colcollations, Alias *alias, bool lateral, bool inFromCl) |
ParseNamespaceItem * | addRangeTableEntryForJoin (ParseState *pstate, List *colnames, ParseNamespaceColumn *nscolumns, JoinType jointype, int nummergedcols, List *aliasvars, List *leftcols, List *rightcols, Alias *join_using_alias, Alias *alias, bool inFromCl) |
ParseNamespaceItem * | addRangeTableEntryForCTE (ParseState *pstate, CommonTableExpr *cte, Index levelsup, RangeVar *rv, bool inFromCl) |
ParseNamespaceItem * | addRangeTableEntryForENR (ParseState *pstate, RangeVar *rv, bool inFromCl) |
ParseNamespaceItem * | addRangeTableEntryForGroup (ParseState *pstate, List *groupClauses) |
bool | isLockedRefname (ParseState *pstate, const char *refname) |
void | addNSItemToQuery (ParseState *pstate, ParseNamespaceItem *nsitem, bool addToJoinList, bool addToRelNameSpace, bool addToVarNameSpace) |
void | expandRTE (RangeTblEntry *rte, int rtindex, int sublevels_up, int location, bool include_dropped, List **colnames, List **colvars) |
List * | expandNSItemVars (ParseState *pstate, ParseNamespaceItem *nsitem, int sublevels_up, int location, List **colnames) |
List * | expandNSItemAttrs (ParseState *pstate, ParseNamespaceItem *nsitem, int sublevels_up, bool require_col_privs, int location) |
char * | get_rte_attribute_name (RangeTblEntry *rte, AttrNumber attnum) |
bool | get_rte_attribute_is_dropped (RangeTblEntry *rte, AttrNumber attnum) |
TargetEntry * | get_tle_by_resno (List *tlist, AttrNumber resno) |
RowMarkClause * | get_parse_rowmark (Query *qry, Index rtindex) |
int | attnameAttNum (Relation rd, const char *attname, bool sysColOK) |
const NameData * | attnumAttName (Relation rd, int attid) |
Oid | attnumTypeId (Relation rd, int attid) |
Oid | attnumCollationId (Relation rd, int attid) |
void | errorMissingRTE (ParseState *pstate, RangeVar *relation) |
void | errorMissingColumn (ParseState *pstate, const char *relname, const char *colname, int location) |
static ParseNamespaceItem * | findNSItemForRTE (ParseState *pstate, RangeTblEntry *rte) |
bool | isQueryUsingTempRelation (Query *query) |
RTEPermissionInfo * | addRTEPermissionInfo (List **rteperminfos, RangeTblEntry *rte) |
RTEPermissionInfo * | getRTEPermissionInfo (List *rteperminfos, RangeTblEntry *rte) |
#define MAX_FUZZY_DISTANCE 3 |
Definition at line 75 of file parse_relation.c.
void addNSItemToQuery | ( | ParseState * | pstate, |
ParseNamespaceItem * | nsitem, | ||
bool | addToJoinList, | ||
bool | addToRelNameSpace, | ||
bool | addToVarNameSpace | ||
) |
Definition at line 2692 of file parse_relation.c.
References lappend(), makeNode, ParseNamespaceItem::p_cols_visible, ParseState::p_joinlist, ParseNamespaceItem::p_lateral_ok, ParseNamespaceItem::p_lateral_only, ParseState::p_namespace, ParseNamespaceItem::p_rel_visible, ParseNamespaceItem::p_rtindex, and RangeTblRef::rtindex.
Referenced by AddRelationNewConstraints(), AlterPolicy(), CreatePolicy(), CreateTriggerFiringOn(), DefineRelation(), DoCopy(), setTargetTable(), test_rls_hooks_permissive(), test_rls_hooks_restrictive(), transformAlterTableStmt(), transformIndexStmt(), transformInsertStmt(), transformMergeStmt(), transformOnConflictClause(), transformPartitionSpec(), TransformPubWhereClauses(), transformRuleStmt(), transformSetOperationStmt(), transformStatsStmt(), and transformValuesClause().
ParseNamespaceItem* addRangeTableEntry | ( | ParseState * | pstate, |
RangeVar * | relation, | ||
Alias * | alias, | ||
bool | inh, | ||
bool | inFromCl | ||
) |
Definition at line 1470 of file parse_relation.c.
References AccessShareLock, ACL_SELECT, addRTEPermissionInfo(), Alias::aliasname, Assert, buildNSItemFromTupleDesc(), buildRelationAliases(), RangeTblEntry::inh, isLockedRefname(), lappend(), list_length(), makeAlias(), makeNode, NIL, NoLock, ParseState::p_rtable, ParseState::p_rteperminfos, parserOpenTable(), RelationData::rd_att, RelationData::rd_rel, RelationGetRelid, RangeTblEntry::relid, RangeVar::relname, RTEPermissionInfo::requiredPerms, RowShareLock, RTE_RELATION, RangeTblEntry::rtekind, and table_close().
Referenced by transformTableEntry().
ParseNamespaceItem* addRangeTableEntryForCTE | ( | ParseState * | pstate, |
CommonTableExpr * | cte, | ||
Index | levelsup, | ||
RangeVar * | rv, | ||
bool | inFromCl | ||
) |
Definition at line 2314 of file parse_relation.c.
References RangeVar::alias, Alias::aliasname, Assert, buildNSItemFromLists(), CMD_SELECT, Alias::colnames, Query::commandType, copyObject, RangeTblEntry::ctelevelsup, RangeTblEntry::ctename, CommonTableExpr::ctename, CommonTableExpr::ctequery, ereport, errcode(), errmsg(), ERROR, i, if(), InvalidOid, IsA, lappend(), lappend_int(), lappend_oid(), lfirst, list_copy(), list_length(), RangeVar::location, makeAlias(), makeNode, makeString(), NIL, ParseNamespaceColumn::p_dontexpand, ParseNamespaceItem::p_names, ParseNamespaceItem::p_nscolumns, ParseState::p_rtable, parser_errposition(), Query::returningList, RTE_CTE, and RangeTblEntry::rtekind.
Referenced by getNSItemForSpecialRelationTypes().
ParseNamespaceItem* addRangeTableEntryForENR | ( | ParseState * | pstate, |
RangeVar * | rv, | ||
bool | inFromCl | ||
) |
Definition at line 2466 of file parse_relation.c.
References RangeVar::alias, Alias::aliasname, Assert, buildNSItemFromTupleDesc(), buildRelationAliases(), elog, ENR_NAMED_TUPLESTORE, ENRMetadataGetTupDesc(), RangeTblEntry::enrname, EphemeralNamedRelationMetadataData::enrtuples, EphemeralNamedRelationMetadataData::enrtype, ERROR, get_visible_ENR(), InvalidOid, lappend(), lappend_int(), lappend_oid(), list_length(), makeAlias(), makeNode, EphemeralNamedRelationMetadataData::name, TupleDescData::natts, NIL, ParseState::p_rtable, RangeTblEntry::relid, EphemeralNamedRelationMetadataData::reliddesc, RangeVar::relname, RTE_NAMEDTUPLESTORE, RangeTblEntry::rtekind, and TupleDescAttr.
Referenced by getNSItemForSpecialRelationTypes().
ParseNamespaceItem* addRangeTableEntryForFunction | ( | ParseState * | pstate, |
List * | funcnames, | ||
List * | funcexprs, | ||
List * | coldeflists, | ||
RangeFunction * | rangefunc, | ||
bool | lateral, | ||
bool | inFromCl | ||
) |
Definition at line 1734 of file parse_relation.c.
References RangeFunction::alias, Alias::aliasname, Assert, buildNSItemFromTupleDesc(), buildRelationAliases(), CheckAttributeNamesTypes(), CHKATYPE_ANYRECORD, chooseScalarFunctionAlias(), ColumnDef::colname, CreateTemplateTupleDesc(), ereport, errcode(), errmsg(), ERROR, exprCollation(), exprLocation(), exprType(), exprTypmod(), format_type_be(), forthree, RangeTblFunction::funcexpr, funcname, RangeTblEntry::funcordinality, RangeTblEntry::functions, get_expr_result_type(), GetColumnDefCollation(), i, InvalidOid, j, lappend(), lappend_int(), lappend_oid(), lfirst, linitial, list_length(), ColumnDef::location, makeAlias(), makeNode, makeString(), MaxHeapAttributeNumber, MaxTupleAttributeNumber, TupleDescData::natts, NIL, RangeFunction::ordinality, ParseState::p_rtable, palloc(), parser_errposition(), pstrdup(), RangeTblEntry::relid, RTE_FUNCTION, RangeTblEntry::rtekind, TypeName::setof, RangeTblEntry::subquery, TupleDescCopyEntry(), TupleDescInitEntry(), TupleDescInitEntryCollation(), TYPEFUNC_COMPOSITE, TYPEFUNC_COMPOSITE_DOMAIN, TYPEFUNC_RECORD, TYPEFUNC_SCALAR, ColumnDef::typeName, and typenameTypeIdAndMod().
Referenced by transformRangeFunction().
ParseNamespaceItem* addRangeTableEntryForGroup | ( | ParseState * | pstate, |
List * | groupClauses | ||
) |
Definition at line 2565 of file parse_relation.c.
References Assert, buildNSItemFromLists(), Alias::colnames, copyObject, TargetEntry::expr, exprCollation(), exprType(), exprTypmod(), lappend(), lappend_int(), lappend_oid(), lfirst, list_length(), makeAlias(), makeNode, makeString(), NIL, ParseState::p_rtable, pstrdup(), RTE_GROUP, and RangeTblEntry::rtekind.
Referenced by parseCheckAggregates().
ParseNamespaceItem* addRangeTableEntryForJoin | ( | ParseState * | pstate, |
List * | colnames, | ||
ParseNamespaceColumn * | nscolumns, | ||
JoinType | jointype, | ||
int | nummergedcols, | ||
List * | aliasvars, | ||
List * | leftcols, | ||
List * | rightcols, | ||
Alias * | join_using_alias, | ||
Alias * | alias, | ||
bool | inFromCl | ||
) |
Definition at line 2216 of file parse_relation.c.
References Alias::aliasname, Assert, Alias::colnames, copyObject, ereport, errcode(), errmsg(), ERROR, InvalidOid, RangeTblEntry::jointype, lappend(), list_concat(), list_copy_tail(), list_length(), makeAlias(), makeNode, MaxAttrNumber, NIL, ParseNamespaceItem::p_cols_visible, ParseNamespaceItem::p_lateral_ok, ParseNamespaceItem::p_lateral_only, ParseNamespaceItem::p_names, ParseNamespaceItem::p_nscolumns, ParseNamespaceItem::p_perminfo, ParseNamespaceItem::p_rel_visible, ParseState::p_rtable, ParseNamespaceItem::p_rte, ParseNamespaceItem::p_rtindex, palloc(), RangeTblEntry::relid, RTE_JOIN, RangeTblEntry::rtekind, and RangeTblEntry::subquery.
Referenced by transformFromClauseItem(), and transformSetOperationStmt().
ParseNamespaceItem* addRangeTableEntryForRelation | ( | ParseState * | pstate, |
Relation | rel, | ||
int | lockmode, | ||
Alias * | alias, | ||
bool | inh, | ||
bool | inFromCl | ||
) |
Definition at line 1567 of file parse_relation.c.
References AccessShareLock, ACL_SELECT, addRTEPermissionInfo(), Alias::aliasname, Assert, buildNSItemFromTupleDesc(), buildRelationAliases(), CheckRelationLockedByMe(), RangeTblEntry::inh, lappend(), list_length(), makeAlias(), makeNode, NIL, ParseState::p_rtable, ParseState::p_rteperminfos, RelationData::rd_att, RelationData::rd_rel, RelationGetRelationName, RelationGetRelid, RangeTblEntry::relid, RTEPermissionInfo::requiredPerms, RowExclusiveLock, RowShareLock, RTE_RELATION, and RangeTblEntry::rtekind.
Referenced by AddRelationNewConstraints(), AlterPolicy(), copy_table(), CreatePolicy(), CreateTriggerFiringOn(), DefineRelation(), DoCopy(), rewriteTargetView(), setTargetTable(), test_rls_hooks_permissive(), test_rls_hooks_restrictive(), transformAlterTableStmt(), transformIndexStmt(), transformOnConflictClause(), transformPartitionSpec(), TransformPubWhereClauses(), transformRuleStmt(), and transformStatsStmt().
ParseNamespaceItem* addRangeTableEntryForSubquery | ( | ParseState * | pstate, |
Query * | subquery, | ||
Alias * | alias, | ||
bool | lateral, | ||
bool | inFromCl | ||
) |
Definition at line 1638 of file parse_relation.c.
References Alias::aliasname, Assert, buildNSItemFromLists(), Alias::colnames, copyObject, ereport, errcode(), errmsg(), ERROR, TargetEntry::expr, exprCollation(), exprType(), exprTypmod(), lappend(), lappend_int(), lappend_oid(), lfirst, list_length(), makeAlias(), makeNode, makeString(), NIL, ParseNamespaceItem::p_rel_visible, ParseState::p_rtable, pstrdup(), TargetEntry::resno, RTE_SUBQUERY, RangeTblEntry::rtekind, RangeTblEntry::subquery, and Query::targetList.
Referenced by convert_ANY_sublink_to_join(), transformInsertStmt(), transformRangeSubselect(), and transformSetOperationTree().
ParseNamespaceItem* addRangeTableEntryForTableFunc | ( | ParseState * | pstate, |
TableFunc * | tf, | ||
Alias * | alias, | ||
bool | lateral, | ||
bool | inFromCl | ||
) |
Definition at line 2049 of file parse_relation.c.
References Alias::aliasname, Assert, buildNSItemFromLists(), Alias::colnames, copyObject, ereport, errcode(), errmsg(), ERROR, exprLocation(), TableFunc::functype, InvalidOid, lappend(), list_concat(), list_copy_tail(), list_length(), makeAlias(), makeNode, MaxTupleAttributeNumber, NIL, ParseState::p_rtable, parser_errposition(), pstrdup(), RangeTblEntry::relid, RTE_TABLEFUNC, RangeTblEntry::rtekind, RangeTblEntry::subquery, RangeTblEntry::tablefunc, and TFT_XMLTABLE.
Referenced by transformJsonTable(), and transformRangeTableFunc().
ParseNamespaceItem* addRangeTableEntryForValues | ( | ParseState * | pstate, |
List * | exprs, | ||
List * | coltypes, | ||
List * | coltypmods, | ||
List * | colcollations, | ||
Alias * | alias, | ||
bool | lateral, | ||
bool | inFromCl | ||
) |
Definition at line 2134 of file parse_relation.c.
References Alias::aliasname, Assert, buildNSItemFromLists(), Alias::colnames, copyObject, ereport, errcode(), errmsg(), ERROR, InvalidOid, lappend(), linitial, list_length(), makeAlias(), makeNode, makeString(), NIL, ParseState::p_rtable, pstrdup(), RangeTblEntry::relid, RTE_VALUES, RangeTblEntry::rtekind, snprintf, RangeTblEntry::subquery, and RangeTblEntry::values_lists.
Referenced by transformValuesClause().
RTEPermissionInfo* addRTEPermissionInfo | ( | List ** | rteperminfos, |
RangeTblEntry * | rte | ||
) |
Definition at line 3949 of file parse_relation.c.
References Assert, RangeTblEntry::inh, RTEPermissionInfo::inh, lappend(), list_length(), makeNode, OidIsValid, RangeTblEntry::relid, and RTEPermissionInfo::relid.
Referenced by add_rte_to_flat_rtable(), addRangeTableEntry(), addRangeTableEntryForRelation(), create_edata_for_relation(), create_estate_for_relation(), plan_cluster_use_sort(), plan_create_index_workers(), and rewriteTargetView().
Definition at line 3558 of file parse_relation.c.
References attname, i, InvalidAttrNumber, namestrcmp(), RelationData::rd_att, RelationGetNumberOfAttributes, specialAttNum(), and TupleDescAttr.
Referenced by checkInsertTargets(), CreateTriggerFiringOn(), do_analyze_rel(), and transformUpdateTargetList().
Definition at line 3608 of file parse_relation.c.
References elog, ERROR, FormData_pg_attribute, TupleDescData::natts, RelationData::rd_att, SystemAttributeDefinition(), and TupleDescAttr.
Referenced by transformFkeyGetPrimaryKey().
Definition at line 3650 of file parse_relation.c.
References elog, ERROR, InvalidOid, TupleDescData::natts, RelationData::rd_att, and TupleDescAttr.
Definition at line 3630 of file parse_relation.c.
References elog, ERROR, FormData_pg_attribute, TupleDescData::natts, RelationData::rd_att, SystemAttributeDefinition(), and TupleDescAttr.
Referenced by transformAssignedExpr(), and transformFkeyGetPrimaryKey().
|
static |
Definition at line 1354 of file parse_relation.c.
References Assert, forthree, lfirst_int, lfirst_oid, list_length(), ParseNamespaceItem::p_cols_visible, ParseNamespaceItem::p_lateral_ok, ParseNamespaceItem::p_lateral_only, ParseNamespaceItem::p_names, ParseNamespaceItem::p_nscolumns, ParseNamespaceItem::p_perminfo, ParseNamespaceItem::p_rel_visible, ParseNamespaceItem::p_rte, ParseNamespaceItem::p_rtindex, ParseNamespaceColumn::p_varattno, ParseNamespaceColumn::p_varattnosyn, ParseNamespaceColumn::p_varcollid, ParseNamespaceColumn::p_varno, ParseNamespaceColumn::p_varnosyn, ParseNamespaceColumn::p_vartype, ParseNamespaceColumn::p_vartypmod, palloc(), and palloc0().
Referenced by addRangeTableEntryForCTE(), addRangeTableEntryForGroup(), addRangeTableEntryForSubquery(), addRangeTableEntryForTableFunc(), and addRangeTableEntryForValues().
|
static |
Definition at line 1294 of file parse_relation.c.
References Assert, list_length(), TupleDescData::natts, ParseNamespaceItem::p_cols_visible, ParseNamespaceItem::p_lateral_ok, ParseNamespaceItem::p_lateral_only, ParseNamespaceItem::p_names, ParseNamespaceItem::p_nscolumns, ParseNamespaceItem::p_perminfo, ParseNamespaceItem::p_rel_visible, ParseNamespaceItem::p_rte, ParseNamespaceItem::p_rtindex, ParseNamespaceColumn::p_varattno, ParseNamespaceColumn::p_varattnosyn, ParseNamespaceColumn::p_varcollid, ParseNamespaceColumn::p_varno, ParseNamespaceColumn::p_varnosyn, ParseNamespaceColumn::p_vartype, ParseNamespaceColumn::p_vartypmod, palloc(), palloc0(), and TupleDescAttr.
Referenced by addRangeTableEntry(), addRangeTableEntryForENR(), addRangeTableEntryForFunction(), and addRangeTableEntryForRelation().
Definition at line 1177 of file parse_relation.c.
References Alias::aliasname, Assert, Alias::colnames, ereport, errcode(), errmsg(), ERROR, lappend(), lfirst_node, list_head(), list_length(), lnext(), makeString(), NameStr, TupleDescData::natts, NIL, pstrdup(), and TupleDescAttr.
Referenced by addRangeTableEntry(), addRangeTableEntryForENR(), addRangeTableEntryForFunction(), and addRangeTableEntryForRelation().
|
static |
Definition at line 483 of file parse_relation.c.
References Alias::aliasname, ereport, errcode(), errdetail(), errhint(), errmsg(), ERROR, ParseNamespaceItem::p_lateral_ok, ParseNamespaceItem::p_lateral_only, ParseNamespaceItem::p_names, ParseNamespaceItem::p_rte, ParseState::p_target_nsitem, and parser_errposition().
Referenced by colNameToVar(), scanNameSpaceForRefname(), and scanNameSpaceForRelid().
void checkNameSpaceConflicts | ( | ParseState * | pstate, |
List * | namespace1, | ||
List * | namespace2 | ||
) |
Definition at line 434 of file parse_relation.c.
References Alias::aliasname, ereport, errcode(), errmsg(), ERROR, lfirst, ParseNamespaceItem::p_names, ParseNamespaceItem::p_rel_visible, ParseNamespaceItem::p_rte, RangeTblEntry::relid, RTE_RELATION, and RangeTblEntry::rtekind.
Referenced by transformFromClause(), and transformFromClauseItem().
|
static |
Definition at line 1254 of file parse_relation.c.
References Alias::aliasname, funcname, get_func_result_name(), and IsA.
Referenced by addRangeTableEntryForFunction().
Node* colNameToVar | ( | ParseState * | pstate, |
const char * | colname, | ||
bool | localonly, | ||
int | location | ||
) |
Definition at line 883 of file parse_relation.c.
References check_lateral_ref_ok(), ereport, errcode(), errmsg(), ERROR, lfirst, ParseNamespaceItem::p_cols_visible, ParseState::p_lateral_active, ParseNamespaceItem::p_lateral_only, ParseState::p_namespace, ParseState::parentParseState, parser_errposition(), and scanNSItemForColumn().
Referenced by findTargetlistEntrySQL92(), and transformColumnRef().
void errorMissingColumn | ( | ParseState * | pstate, |
const char * | relname, | ||
const char * | colname, | ||
int | location | ||
) |
Definition at line 3740 of file parse_relation.c.
References ereport, errcode(), errdetail(), errhint(), errmsg(), ERROR, list_nth(), parser_errposition(), relname, rte_visible_if_lateral(), rte_visible_if_qualified(), searchRangeTableForCol(), and strVal.
Referenced by transformColumnRef().
void errorMissingRTE | ( | ParseState * | pstate, |
RangeVar * | relation | ||
) |
Definition at line 3669 of file parse_relation.c.
References ereport, errcode(), ERRCODE_UNDEFINED_TABLE, errdetail(), errhint(), errmsg(), ERROR, RangeVar::location, ParseNamespaceItem::p_rte, parser_errposition(), refnameNamespaceItem(), RangeVar::relname, rte_visible_if_lateral(), and searchRangeTableForRel().
Referenced by ExpandColumnRefStar(), and transformColumnRef().
List* expandNSItemAttrs | ( | ParseState * | pstate, |
ParseNamespaceItem * | nsitem, | ||
int | sublevels_up, | ||
bool | require_col_privs, | ||
int | location | ||
) |
Definition at line 3261 of file parse_relation.c.
References ACL_SELECT, Assert, expandNSItemVars(), forboth, label, lappend(), lfirst, makeTargetEntry(), markVarForSelectPriv(), name, NIL, ParseState::p_next_resno, ParseNamespaceItem::p_perminfo, ParseNamespaceItem::p_rte, RTEPermissionInfo::requiredPerms, RTE_RELATION, RangeTblEntry::rtekind, and strVal.
Referenced by ExpandAllTables(), ExpandSingleTable(), and transformValuesClause().
List* expandNSItemVars | ( | ParseState * | pstate, |
ParseNamespaceItem * | nsitem, | ||
int | sublevels_up, | ||
int | location, | ||
List ** | colnames | ||
) |
Definition at line 3197 of file parse_relation.c.
References Assert, Alias::colnames, lappend(), lfirst, Var::location, makeVar(), markNullableIfNeeded(), NIL, ParseNamespaceColumn::p_dontexpand, ParseNamespaceItem::p_names, ParseNamespaceItem::p_nscolumns, ParseNamespaceColumn::p_varattno, ParseNamespaceColumn::p_varattnosyn, ParseNamespaceColumn::p_varcollid, ParseNamespaceColumn::p_varno, ParseNamespaceColumn::p_varnosyn, ParseNamespaceColumn::p_vartype, ParseNamespaceColumn::p_vartypmod, and strVal.
Referenced by coerce_record_to_complex(), expandNSItemAttrs(), and ExpandSingleTable().
|
static |
Definition at line 3091 of file parse_relation.c.
References AccessShareLock, expandTupleDesc(), TupleDescData::natts, RelationData::rd_att, relation_close(), and relation_open().
Referenced by expandRTE().
void expandRTE | ( | RangeTblEntry * | rte, |
int | rtindex, | ||
int | sublevels_up, | ||
int | location, | ||
bool | include_dropped, | ||
List ** | colnames, | ||
List ** | colvars | ||
) |
Definition at line 2732 of file parse_relation.c.
References Assert, attnum, copyObject, elog, ERROR, expandRelation(), expandTupleDesc(), TargetEntry::expr, exprCollation(), exprType(), exprTypmod(), forboth, forthree, RangeTblFunction::funcexpr, RangeTblEntry::funcordinality, RangeTblEntry::functions, get_expr_result_type(), InvalidOid, IsA, label, lappend(), lfirst, lfirst_int, lfirst_oid, list_concat(), list_copy_tail(), list_head(), list_length(), list_nth(), list_truncate(), llast, lnext(), Var::location, makeNullConst(), makeString(), makeVar(), NIL, OidIsValid, pstrdup(), RangeTblEntry::relid, TargetEntry::resno, RTE_CTE, RTE_FUNCTION, RTE_GROUP, RTE_JOIN, RTE_NAMEDTUPLESTORE, RTE_RELATION, RTE_RESULT, RTE_SUBQUERY, RTE_TABLEFUNC, RTE_VALUES, RangeTblEntry::rtekind, strVal, RangeTblEntry::subquery, Query::targetList, TYPEFUNC_COMPOSITE, TYPEFUNC_COMPOSITE_DOMAIN, TYPEFUNC_RECORD, TYPEFUNC_SCALAR, and Var::varlevelsup.
Referenced by build_physical_tlist(), expandRecordVariable(), pullup_replace_vars_callback(), ReplaceVarsFromTargetList_callback(), set_relation_column_names(), and transformWholeRowRef().
|
static |
Definition at line 3116 of file parse_relation.c.
References Assert, Alias::colnames, InvalidOid, label, lappend(), lfirst, list_length(), list_nth_cell(), lnext(), Var::location, makeNullConst(), makeString(), makeVar(), NameStr, pstrdup(), strVal, and TupleDescAttr.
Referenced by expandRelation(), and expandRTE().
|
static |
Definition at line 3833 of file parse_relation.c.
References lfirst, ParseState::p_namespace, ParseNamespaceItem::p_rte, and ParseState::parentParseState.
Referenced by rte_visible_if_lateral(), and rte_visible_if_qualified().
RowMarkClause* get_parse_rowmark | ( | Query * | qry, |
Index | rtindex | ||
) |
Definition at line 3534 of file parse_relation.c.
References lfirst, Query::rowMarks, and RowMarkClause::rti.
Referenced by AcquireRewriteLocks(), applyLockingClause(), and ApplyRetrieveRule().
bool get_rte_attribute_is_dropped | ( | RangeTblEntry * | rte, |
AttrNumber | attnum | ||
) |
Definition at line 3365 of file parse_relation.c.
References Assert, attnum, elog, ereport, errcode(), errmsg(), ERROR, RangeTblFunction::funcexpr, RangeTblEntry::funcordinality, RangeTblEntry::functions, get_expr_result_tupdesc(), GETSTRUCT, HeapTupleIsValid, Int16GetDatum(), lfirst, list_length(), list_nth(), list_nth_oid(), NIL, ObjectIdGetDatum(), OidIsValid, ReleaseSysCache(), RangeTblEntry::relid, RTE_CTE, RTE_FUNCTION, RTE_GROUP, RTE_JOIN, RTE_NAMEDTUPLESTORE, RTE_RELATION, RTE_RESULT, RTE_SUBQUERY, RTE_TABLEFUNC, RTE_VALUES, RangeTblEntry::rtekind, SearchSysCache2(), and TupleDescAttr.
Referenced by AcquireRewriteLocks().
char* get_rte_attribute_name | ( | RangeTblEntry * | rte, |
AttrNumber | attnum | ||
) |
Definition at line 3327 of file parse_relation.c.
References attnum, elog, ERROR, get_attname(), InvalidAttrNumber, list_length(), list_nth(), RangeTblEntry::relid, RTE_RELATION, RangeTblEntry::rtekind, and strVal.
Referenced by get_name_for_var_field(), get_variable(), print_expr(), and substitute_grouped_columns_mutator().
TargetEntry* get_tle_by_resno | ( | List * | tlist, |
AttrNumber | resno | ||
) |
Definition at line 3514 of file parse_relation.c.
References lfirst, and TargetEntry::resno.
Referenced by adjust_view_column_set(), count_rowexpr_columns(), create_unique_plan(), currtid_for_view(), examine_simple_variable(), expandRecordVariable(), get_name_for_var_field(), get_variable(), make_sort_from_groupcols(), markTargetListOrigin(), prepare_sort_from_pathkeys(), pullup_replace_vars_callback(), ReplaceVarsFromTargetList_callback(), resolve_special_varno(), rewriteTargetView(), show_grouping_set_keys(), and show_sort_group_keys().
CommonTableExpr* GetCTEForRTE | ( | ParseState * | pstate, |
RangeTblEntry * | rte, | ||
int | rtelevelsup | ||
) |
Definition at line 557 of file parse_relation.c.
References Assert, RangeTblEntry::ctelevelsup, RangeTblEntry::ctename, CommonTableExpr::ctename, elog, ERROR, lfirst, ParseState::p_ctenamespace, ParseState::parentParseState, RTE_CTE, and RangeTblEntry::rtekind.
Referenced by expandRecordVariable(), and markTargetListOrigin().
ParseNamespaceItem* GetNSItemByRangeTablePosn | ( | ParseState * | pstate, |
int | varno, | ||
int | sublevels_up | ||
) |
Definition at line 510 of file parse_relation.c.
References Assert, elog, ERROR, lfirst, ParseState::p_namespace, ParseNamespaceItem::p_rtindex, and ParseState::parentParseState.
Referenced by coerce_record_to_complex(), ExpandRowReference(), ParseComplexProjection(), and transformMergeStmt().
RangeTblEntry* GetRTEByRangeTablePosn | ( | ParseState * | pstate, |
int | varno, | ||
int | sublevels_up | ||
) |
Definition at line 537 of file parse_relation.c.
References Assert, list_length(), ParseState::p_rtable, ParseState::parentParseState, and rt_fetch.
Referenced by count_rowexpr_columns(), expandRecordVariable(), markTargetListOrigin(), and unknown_attribute().
RTEPermissionInfo* getRTEPermissionInfo | ( | List * | rteperminfos, |
RangeTblEntry * | rte | ||
) |
Definition at line 3978 of file parse_relation.c.
References elog, ERROR, list_length(), list_nth_node, RangeTblEntry::relid, and RTEPermissionInfo::relid.
Referenced by add_rte_to_flat_rtable(), build_simple_rel(), examine_simple_variable(), ExecCheckPermissions(), expand_inherited_rtentry(), get_rel_all_updated_cols(), get_row_security_policies(), GetResultRTEPermissionInfo(), markQueryForLocking(), markRTEForSelectPriv(), rewriteTargetView(), and transformLockingClause().
|
static |
Definition at line 313 of file parse_relation.c.
References CommonTableExpr::ctename, lfirst, ParseState::p_future_ctes, and ParseState::parentParseState.
Referenced by parserOpenTable().
bool isLockedRefname | ( | ParseState * | pstate, |
const char * | refname | ||
) |
Definition at line 2648 of file parse_relation.c.
References lfirst, LockingClause::lockedRels, NIL, ParseState::p_locked_from_parent, ParseState::p_locking_clause, and RangeVar::relname.
Referenced by addRangeTableEntry(), and transformRangeSubselect().
Definition at line 3899 of file parse_relation.c.
References isQueryUsingTempRelation_walker().
Referenced by DefineView(), and transformCreateTableAsStmt().
Definition at line 3905 of file parse_relation.c.
References AccessShareLock, context, expression_tree_walker, IsA, lfirst, QTW_IGNORE_JOINALIASES, query_tree_walker, RelationData::rd_rel, RangeTblEntry::relid, Query::rtable, RTE_RELATION, RangeTblEntry::rtekind, table_close(), and table_open().
Referenced by isQueryUsingTempRelation().
void markNullableIfNeeded | ( | ParseState * | pstate, |
Var * | var | ||
) |
Definition at line 1035 of file parse_relation.c.
References bms_union(), if(), list_length(), list_nth(), ParseState::p_nullingrels, ParseState::parentParseState, Var::varlevelsup, and Var::varno.
Referenced by buildVarFromNSColumn(), expandNSItemVars(), scanNSItemForColumn(), and transformWholeRowRef().
|
static |
Definition at line 1066 of file parse_relation.c.
References ACL_SELECT, bms_add_member(), elog, ERROR, FirstLowInvalidHeapAttributeNumber, getRTEPermissionInfo(), InvalidAttrNumber, IsA, j, list_length(), list_nth_node, nodeTag, ParseState::p_joinexprs, ParseState::p_rtable, ParseState::p_rteperminfos, RTEPermissionInfo::requiredPerms, rt_fetch, RTE_JOIN, RTE_RELATION, RangeTblEntry::rtekind, and RTEPermissionInfo::selectedCols.
Referenced by markVarForSelectPriv().
void markVarForSelectPriv | ( | ParseState * | pstate, |
Var * | var | ||
) |
Definition at line 1150 of file parse_relation.c.
References Assert, IsA, markRTEForSelectPriv(), ParseState::parentParseState, Var::varattno, Var::varlevelsup, and Var::varno.
Referenced by expandNSItemAttrs(), ExpandSingleTable(), scanNSItemForColumn(), transformJoinUsingClause(), and transformWholeRowRef().
Relation parserOpenTable | ( | ParseState * | pstate, |
const RangeVar * | relation, | ||
int | lockmode | ||
) |
Definition at line 1418 of file parse_relation.c.
References cancel_parser_errposition_callback(), ereport, errcode(), ERRCODE_UNDEFINED_TABLE, errdetail(), errhint(), errmsg(), ERROR, isFutureCTE(), RangeVar::location, RangeVar::relname, RangeVar::schemaname, setup_parser_errposition_callback(), and table_openrv_extended().
Referenced by addRangeTableEntry(), and setTargetTable().
ParseNamespaceItem* refnameNamespaceItem | ( | ParseState * | pstate, |
const char * | schemaname, | ||
const char * | refname, | ||
int | location, | ||
int * | sublevels_up | ||
) |
Definition at line 129 of file parse_relation.c.
References get_relname_relid(), InvalidOid, LookupNamespaceNoError(), OidIsValid, ParseState::parentParseState, scanNameSpaceForRefname(), and scanNameSpaceForRelid().
Referenced by errorMissingRTE(), ExpandColumnRefStar(), and transformColumnRef().
|
static |
Definition at line 3861 of file parse_relation.c.
References findNSItemForRTE(), ParseState::p_lateral_active, ParseNamespaceItem::p_lateral_ok, and ParseNamespaceItem::p_lateral_only.
Referenced by errorMissingColumn(), and errorMissingRTE().
|
static |
Definition at line 3881 of file parse_relation.c.
References findNSItemForRTE(), ParseNamespaceItem::p_cols_visible, and ParseNamespaceItem::p_rel_visible.
Referenced by errorMissingColumn().
CommonTableExpr* scanNameSpaceForCTE | ( | ParseState * | pstate, |
const char * | refname, | ||
Index * | ctelevelsup | ||
) |
Definition at line 282 of file parse_relation.c.
References CommonTableExpr::ctename, lfirst, ParseState::p_ctenamespace, and ParseState::parentParseState.
Referenced by getNSItemForSpecialRelationTypes(), and searchRangeTableForRel().
bool scanNameSpaceForENR | ( | ParseState * | pstate, |
const char * | refname | ||
) |
Definition at line 335 of file parse_relation.c.
References name_matches_visible_ENR().
Referenced by getNSItemForSpecialRelationTypes(), searchRangeTableForRel(), and setTargetTable().
|
static |
Definition at line 200 of file parse_relation.c.
References Alias::aliasname, check_lateral_ref_ok(), ereport, errcode(), errmsg(), ERROR, lfirst, ParseState::p_lateral_active, ParseNamespaceItem::p_lateral_only, ParseNamespaceItem::p_names, ParseState::p_namespace, ParseNamespaceItem::p_rel_visible, and parser_errposition().
Referenced by refnameNamespaceItem().
|
static |
Definition at line 240 of file parse_relation.c.
References check_lateral_ref_ok(), ereport, errcode(), errmsg(), ERROR, lfirst, ParseState::p_lateral_active, ParseNamespaceItem::p_lateral_only, ParseState::p_namespace, ParseNamespaceItem::p_rel_visible, ParseNamespaceItem::p_rte, parser_errposition(), RangeTblEntry::relid, RTE_RELATION, and RangeTblEntry::rtekind.
Referenced by refnameNamespaceItem().
Node* scanNSItemForColumn | ( | ParseState * | pstate, |
ParseNamespaceItem * | nsitem, | ||
int | sublevels_up, | ||
const char * | colname, | ||
int | location | ||
) |
Definition at line 680 of file parse_relation.c.
References Alias::aliasname, attnum, ereport, errcode(), errmsg(), ERROR, EXPR_KIND_CHECK_CONSTRAINT, EXPR_KIND_GENERATED_COLUMN, EXPR_KIND_MERGE_WHEN, FormData_pg_attribute, InvalidAttrNumber, Var::location, makeVar(), markNullableIfNeeded(), markVarForSelectPriv(), ParseState::p_expr_kind, ParseNamespaceItem::p_names, ParseNamespaceItem::p_nscolumns, ParseNamespaceItem::p_rte, ParseNamespaceItem::p_rtindex, ParseNamespaceColumn::p_varattno, ParseNamespaceColumn::p_varattnosyn, ParseNamespaceColumn::p_varcollid, ParseNamespaceColumn::p_varno, ParseNamespaceColumn::p_varnosyn, ParseNamespaceColumn::p_vartype, ParseNamespaceColumn::p_vartypmod, parser_errposition(), scanRTEForColumn(), SystemAttributeDefinition(), and TableOidAttributeNumber.
Referenced by colNameToVar(), ParseComplexProjection(), and transformColumnRef().
|
static |
Definition at line 800 of file parse_relation.c.
References attnum, Alias::colnames, ereport, errcode(), errmsg(), ERROR, Int16GetDatum(), InvalidAttrNumber, lfirst, ObjectIdGetDatum(), parser_errposition(), RangeTblEntry::relid, RTE_RELATION, RangeTblEntry::rtekind, SearchSysCacheExists2, specialAttNum(), strVal, and updateFuzzyAttrMatchState().
Referenced by scanNSItemForColumn(), and searchRangeTableForCol().
|
static |
Definition at line 952 of file parse_relation.c.
References attnum, FuzzyAttrMatchState::distance, FuzzyAttrMatchState::exact1, FuzzyAttrMatchState::exact2, InvalidAttrNumber, lfirst, MAX_FUZZY_DISTANCE, ParseState::p_rtable, palloc(), ParseState::parentParseState, FuzzyAttrMatchState::rexact1, FuzzyAttrMatchState::rexact2, FuzzyAttrMatchState::rfirst, FuzzyAttrMatchState::rsecond, RTE_JOIN, RangeTblEntry::rtekind, scanRTEForColumn(), and varstr_levenshtein_less_equal().
Referenced by errorMissingColumn().
|
static |
Definition at line 356 of file parse_relation.c.
References RangeTblEntry::ctelevelsup, RangeTblEntry::ctename, RangeTblEntry::enrname, InvalidOid, lfirst, NoLock, OidIsValid, ParseState::p_rtable, ParseState::parentParseState, RangeVarGetRelid, RangeTblEntry::relid, RangeVar::relname, RTE_CTE, RTE_NAMEDTUPLESTORE, RTE_RELATION, RangeTblEntry::rtekind, scanNameSpaceForCTE(), scanNameSpaceForENR(), and RangeVar::schemaname.
Referenced by errorMissingRTE().
|
static |
Definition at line 3589 of file parse_relation.c.
References attname, FormData_pg_attribute, InvalidAttrNumber, and SystemAttributeByName().
Referenced by attnameAttNum(), and scanRTEForColumn().
|
static |
Definition at line 587 of file parse_relation.c.
References attnum, FuzzyAttrMatchState::distance, FuzzyAttrMatchState::first, FuzzyAttrMatchState::rfirst, FuzzyAttrMatchState::rsecond, FuzzyAttrMatchState::second, and varstr_levenshtein_less_equal().
Referenced by scanRTEForColumn().