PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "catalog/namespace.h"
#include "catalog/pg_type.h"
#include "commands/dbcommands.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "parser/parse_coerce.h"
#include "parser/parse_expr.h"
#include "parser/parse_relation.h"
#include "parser/parse_target.h"
#include "parser/parse_type.h"
#include "parser/parsetree.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
Go to the source code of this file.
Functions | |
static void | markTargetListOrigin (ParseState *pstate, TargetEntry *tle, Var *var, int levelsup) |
static Node * | transformAssignmentSubscripts (ParseState *pstate, Node *basenode, const char *targetName, Oid targetTypeId, int32 targetTypMod, Oid targetCollation, List *subscripts, List *indirection, ListCell *next_indirection, Node *rhs, CoercionContext ccontext, int location) |
static List * | ExpandColumnRefStar (ParseState *pstate, ColumnRef *cref, bool make_target_entry) |
static List * | ExpandAllTables (ParseState *pstate, int location) |
static List * | ExpandIndirectionStar (ParseState *pstate, A_Indirection *ind, bool make_target_entry, ParseExprKind exprKind) |
static List * | ExpandSingleTable (ParseState *pstate, ParseNamespaceItem *nsitem, int sublevels_up, int location, bool make_target_entry) |
static List * | ExpandRowReference (ParseState *pstate, Node *expr, bool make_target_entry) |
static int | FigureColnameInternal (Node *node, char **name) |
TargetEntry * | transformTargetEntry (ParseState *pstate, Node *node, Node *expr, ParseExprKind exprKind, char *colname, bool resjunk) |
List * | transformTargetList (ParseState *pstate, List *targetlist, ParseExprKind exprKind) |
List * | transformExpressionList (ParseState *pstate, List *exprlist, ParseExprKind exprKind, bool allowDefault) |
void | resolveTargetListUnknowns (ParseState *pstate, List *targetlist) |
void | markTargetListOrigins (ParseState *pstate, List *targetlist) |
Expr * | transformAssignedExpr (ParseState *pstate, Expr *expr, ParseExprKind exprKind, const char *colname, int attrno, List *indirection, int location) |
void | updateTargetListEntry (ParseState *pstate, TargetEntry *tle, char *colname, int attrno, List *indirection, int location) |
Node * | transformAssignmentIndirection (ParseState *pstate, Node *basenode, const char *targetName, bool targetIsSubscripting, Oid targetTypeId, int32 targetTypMod, Oid targetCollation, List *indirection, ListCell *indirection_cell, Node *rhs, CoercionContext ccontext, int location) |
List * | checkInsertTargets (ParseState *pstate, List *cols, List **attrnos) |
TupleDesc | expandRecordVariable (ParseState *pstate, Var *var, int levelsup) |
char * | FigureColname (Node *node) |
char * | FigureIndexColname (Node *node) |
List* checkInsertTargets | ( | ParseState * | pstate, |
List * | cols, | ||
List ** | attrnos | ||
) |
Definition at line 1018 of file parse_target.c.
References attnameAttNum(), bms_add_member(), bms_is_member(), ereport, errcode(), errmsg(), ERROR, i, ResTarget::indirection, InvalidAttrNumber, lappend(), lappend_int(), lfirst, ResTarget::location, makeNode, name, ResTarget::name, NameStr, NIL, ParseState::p_target_relation, parser_errposition(), pstrdup(), RelationData::rd_att, RelationGetNumberOfAttributes, RelationGetRelationName, TupleDescAttr, and ResTarget::val.
Referenced by transformInsertStmt(), and transformMergeStmt().
|
static |
Definition at line 1296 of file parse_target.c.
References Assert, ereport, errcode(), errmsg(), ERROR, expandNSItemAttrs(), lfirst, list_concat(), NIL, ParseNamespaceItem::p_cols_visible, ParseNamespaceItem::p_lateral_only, ParseState::p_namespace, and parser_errposition().
Referenced by ExpandColumnRefStar().
|
static |
Definition at line 1123 of file parse_target.c.
References Assert, ereport, errcode(), errmsg(), ERROR, errorMissingRTE(), ExpandAllTables(), ExpandRowReference(), ExpandSingleTable(), ColumnRef::fields, get_database_name(), linitial, list_length(), ColumnRef::location, lsecond, lthird, makeRangeVar(), MyDatabaseId, NameListToString(), ParseState::p_post_columnref_hook, ParseState::p_pre_columnref_hook, ParseNamespaceItem::p_rte, parser_errposition(), refnameNamespaceItem(), relname, and strVal.
Referenced by transformExpressionList(), and transformTargetList().
|
static |
Definition at line 1348 of file parse_target.c.
References copyObject, ExpandRowReference(), list_length(), list_truncate(), and transformExpr().
Referenced by transformExpressionList(), and transformTargetList().
TupleDesc expandRecordVariable | ( | ParseState * | pstate, |
Var * | var, | ||
int | levelsup | ||
) |
Definition at line 1522 of file parse_target.c.
References Assert, attnum, CreateTemplateTupleDesc(), RangeTblEntry::ctelevelsup, CommonTableExpr::ctequery, elog, ERROR, expandRTE(), TargetEntry::expr, exprCollation(), exprType(), exprTypmod(), forboth, get_expr_result_tupdesc(), get_tle_by_resno(), GetCTEForRTE(), GetCTETargetList, GetRTEByRangeTablePosn(), i, if(), InvalidAttrNumber, IsA, label, lfirst, list_length(), list_nth(), Var::location, ParseState::p_rtable, ParseState::parentParseState, Query::rtable, 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, TupleDescInitEntry(), TupleDescInitEntryCollation(), Var::varattno, Var::varlevelsup, and Var::varno.
Referenced by ExpandRowReference(), and ParseComplexProjection().
|
static |
Definition at line 1426 of file parse_target.c.
References FieldSelect::arg, Assert, copyObject, expandRecordVariable(), ExpandSingleTable(), FieldSelect::fieldnum, get_expr_result_tupdesc(), GetNSItemByRangeTablePosn(), i, InvalidAttrNumber, IsA, lappend(), Var::location, makeNode, makeTargetEntry(), NameStr, TupleDescData::natts, NIL, ParseState::p_next_resno, pstrdup(), TupleDescAttr, Var::varlevelsup, and Var::varno.
Referenced by ExpandColumnRefStar(), and ExpandIndirectionStar().
|
static |
Definition at line 1375 of file parse_target.c.
References ACL_SELECT, Assert, expandNSItemAttrs(), expandNSItemVars(), lfirst, markVarForSelectPriv(), ParseNamespaceItem::p_perminfo, ParseNamespaceItem::p_rte, RTEPermissionInfo::requiredPerms, RTE_RELATION, and RangeTblEntry::rtekind.
Referenced by ExpandColumnRefStar(), and ExpandRowReference().
char* FigureColname | ( | Node * | node | ) |
Definition at line 1713 of file parse_target.c.
References FigureColnameInternal(), and name.
Referenced by transformRangeFunction(), transformTargetEntry(), and transformXmlExpr().
|
static |
Definition at line 1752 of file parse_target.c.
References AEXPR_NULLIF, ALL_SUBLINK, ANY_SUBLINK, arg, ARRAY_SUBLINK, CTE_SUBLINK, elog, ERROR, EXISTS_SUBLINK, EXPR_SUBLINK, funcname, i, if(), IS_DOCUMENT, IS_GREATEST, IS_LEAST, IS_XMLCONCAT, IS_XMLELEMENT, IS_XMLFOREST, IS_XMLPARSE, IS_XMLPI, IS_XMLROOT, IS_XMLSERIALIZE, IsA, JSON_EXISTS_OP, JSON_QUERY_OP, JSON_VALUE_OP, lfirst, linitial, llast, MULTIEXPR_SUBLINK, name, nodeTag, ROWCOMPARE_SUBLINK, strVal, SubLink::subselect, SVFOP_CURRENT_CATALOG, SVFOP_CURRENT_DATE, SVFOP_CURRENT_ROLE, SVFOP_CURRENT_SCHEMA, SVFOP_CURRENT_TIME, SVFOP_CURRENT_TIME_N, SVFOP_CURRENT_TIMESTAMP, SVFOP_CURRENT_TIMESTAMP_N, SVFOP_CURRENT_USER, SVFOP_LOCALTIME, SVFOP_LOCALTIME_N, SVFOP_LOCALTIMESTAMP, SVFOP_LOCALTIMESTAMP_N, SVFOP_SESSION_USER, SVFOP_USER, and Query::targetList.
Referenced by FigureColname(), and FigureIndexColname().
char* FigureIndexColname | ( | Node * | node | ) |
Definition at line 1732 of file parse_target.c.
References FigureColnameInternal(), and name.
Referenced by transformIndexStmt().
|
static |
Definition at line 343 of file parse_target.c.
References attnum, elog, ERROR, get_tle_by_resno(), GetCTEForRTE(), GetCTETargetList, GetRTEByRangeTablePosn(), InvalidAttrNumber, IsA, list_length(), RangeTblEntry::relid, RTE_CTE, RTE_FUNCTION, RTE_GROUP, RTE_JOIN, RTE_NAMEDTUPLESTORE, RTE_RELATION, RTE_RESULT, RTE_SUBQUERY, RTE_TABLEFUNC, RTE_VALUES, RangeTblEntry::rtekind, RangeTblEntry::subquery, Query::targetList, Var::varattno, Var::varlevelsup, and Var::varno.
Referenced by markTargetListOrigins().
void markTargetListOrigins | ( | ParseState * | pstate, |
List * | targetlist | ||
) |
Definition at line 318 of file parse_target.c.
References TargetEntry::expr, lfirst, and markTargetListOrigin().
Referenced by transformReturningList(), and transformSelectStmt().
void resolveTargetListUnknowns | ( | ParseState * | pstate, |
List * | targetlist | ||
) |
Definition at line 288 of file parse_target.c.
References COERCE_IMPLICIT_CAST, coerce_type(), COERCION_IMPLICIT, TargetEntry::expr, exprType(), and lfirst.
Referenced by transformReturningList(), transformReturnStmt(), and transformSelectStmt().
Expr* transformAssignedExpr | ( | ParseState * | pstate, |
Expr * | expr, | ||
ParseExprKind | exprKind, | ||
const char * | colname, | ||
int | attrno, | ||
List * | indirection, | ||
int | location | ||
) |
Definition at line 455 of file parse_target.c.
References Assert, attnumTypeId(), COERCE_IMPLICIT_CAST, coerce_to_target_type(), COERCION_ASSIGNMENT, ereport, errcode(), errhint(), errmsg(), ERROR, EXPR_KIND_NONE, exprLocation(), exprType(), format_type_be(), IsA, linitial, list_head(), Var::location, makeNullConst(), makeVar(), ParseState::p_expr_kind, ParseState::p_is_insert, ParseNamespaceItem::p_rtindex, ParseState::p_target_nsitem, ParseState::p_target_relation, parser_errposition(), RelationData::rd_att, transformAssignmentIndirection(), TupleDescAttr, and SetToDefault::typeId.
Referenced by transformInsertRow(), and updateTargetListEntry().
Node* transformAssignmentIndirection | ( | ParseState * | pstate, |
Node * | basenode, | ||
const char * | targetName, | ||
bool | targetIsSubscripting, | ||
Oid | targetTypeId, | ||
int32 | targetTypMod, | ||
Oid | targetCollation, | ||
List * | indirection, | ||
ListCell * | indirection_cell, | ||
Node * | rhs, | ||
CoercionContext | ccontext, | ||
int | location | ||
) |
Definition at line 686 of file parse_target.c.
References FieldStore::arg, Assert, attnum, COERCE_IMPLICIT_CAST, coerce_to_domain(), coerce_to_target_type(), COERCION_IMPLICIT, ereport, errcode(), errhint(), errmsg(), ERROR, exprType(), for_each_cell, format_type_be(), get_attnum(), get_atttypetypmodcoll(), getBaseTypeAndTypmod(), i, InvalidAttrNumber, IsA, lappend(), lfirst, list_make1, list_make1_int, lnext(), makeNode, FieldStore::newvals, NIL, parser_errposition(), strVal, transformAssignmentSubscripts(), CaseTestExpr::typeId, and typeidTypeRelid().
Referenced by transformAssignedExpr(), transformAssignmentSubscripts(), and transformPLAssignStmt().
|
static |
Definition at line 906 of file parse_target.c.
References Assert, COERCE_IMPLICIT_CAST, coerce_to_target_type(), ereport, errcode(), errmsg(), ERROR, exprType(), format_type_be(), get_typcollation(), NIL, parser_errposition(), SubscriptingRef::refassgnexpr, transformAssignmentIndirection(), transformContainerSubscripts(), and transformContainerType().
Referenced by transformAssignmentIndirection().
List* transformExpressionList | ( | ParseState * | pstate, |
List * | exprlist, | ||
ParseExprKind | exprKind, | ||
bool | allowDefault | ||
) |
Definition at line 220 of file parse_target.c.
References ExpandColumnRefStar(), ExpandIndirectionStar(), ColumnRef::fields, IsA, lappend(), lfirst, list_concat(), llast, NIL, and transformExpr().
Referenced by transformMergeStmt(), transformRowExpr(), and transformValuesClause().
TargetEntry* transformTargetEntry | ( | ParseState * | pstate, |
Node * | node, | ||
Node * | expr, | ||
ParseExprKind | exprKind, | ||
char * | colname, | ||
bool | resjunk | ||
) |
Definition at line 75 of file parse_target.c.
References EXPR_KIND_UPDATE_SOURCE, FigureColname(), IsA, makeTargetEntry(), ParseState::p_next_resno, and transformExpr().
Referenced by findTargetlistEntrySQL99(), and transformTargetList().
List* transformTargetList | ( | ParseState * | pstate, |
List * | targetlist, | ||
ParseExprKind | exprKind | ||
) |
Definition at line 121 of file parse_target.c.
References Assert, ExpandColumnRefStar(), ExpandIndirectionStar(), EXPR_KIND_UPDATE_SOURCE, ColumnRef::fields, if(), IsA, lappend(), lfirst, list_concat(), llast, NIL, ParseState::p_multiassign_exprs, res, and transformTargetEntry().
Referenced by transformPLAssignStmt(), transformReturningList(), transformSelectStmt(), and transformUpdateTargetList().
void updateTargetListEntry | ( | ParseState * | pstate, |
TargetEntry * | tle, | ||
char * | colname, | ||
int | attrno, | ||
List * | indirection, | ||
int | location | ||
) |
Definition at line 622 of file parse_target.c.
References TargetEntry::expr, EXPR_KIND_UPDATE_TARGET, TargetEntry::resno, and transformAssignedExpr().
Referenced by transformUpdateTargetList().