PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_type.h"
#include "nodes/nodeFuncs.h"
#include "parser/analyze.h"
#include "parser/parse_coerce.h"
#include "parser/parse_collate.h"
#include "parser/parse_cte.h"
#include "parser/parse_expr.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/typcache.h"
Go to the source code of this file.
Data Structures | |
struct | CteItem |
struct | CteState |
Typedefs | |
typedef struct CteItem | CteItem |
typedef struct CteState | CteState |
Enumerations | |
enum | RecursionContext { RECURSION_OK , RECURSION_NONRECURSIVETERM , RECURSION_SUBLINK , RECURSION_OUTERJOIN , RECURSION_INTERSECT , RECURSION_EXCEPT } |
Functions | |
static void | analyzeCTE (ParseState *pstate, CommonTableExpr *cte) |
static void | makeDependencyGraph (CteState *cstate) |
static bool | makeDependencyGraphWalker (Node *node, CteState *cstate) |
static void | TopologicalSort (ParseState *pstate, CteItem *items, int numitems) |
static void | checkWellFormedRecursion (CteState *cstate) |
static bool | checkWellFormedRecursionWalker (Node *node, CteState *cstate) |
static void | checkWellFormedSelectStmt (SelectStmt *stmt, CteState *cstate) |
List * | transformWithClause (ParseState *pstate, WithClause *withClause) |
void | analyzeCTETargetList (ParseState *pstate, CommonTableExpr *cte, List *tlist) |
Variables | |
static const char *const | recursion_errormsgs [] |
enum RecursionContext |
Enumerator | |
---|---|
RECURSION_OK | |
RECURSION_NONRECURSIVETERM | |
RECURSION_SUBLINK | |
RECURSION_OUTERJOIN | |
RECURSION_INTERSECT | |
RECURSION_EXCEPT |
Definition at line 31 of file parse_cte.c.
|
static |
Definition at line 242 of file parse_cte.c.
References analyzeCTETargetList(), Assert, castNode, CMD_SELECT, coerce_to_common_type(), Query::commandType, CommonTableExpr::ctename, CommonTableExpr::ctequery, CTECycleClause::cycle_col_list, CTECycleClause::cycle_mark_collation, CTECycleClause::cycle_mark_column, CTECycleClause::cycle_mark_default, CTECycleClause::cycle_mark_neop, CTECycleClause::cycle_mark_type, CTECycleClause::cycle_mark_typmod, CTECycleClause::cycle_mark_value, CTECycleClause::cycle_path_column, elog, TypeCacheEntry::eq_opr, ereport, errcode(), errhint(), errmsg(), ERROR, TargetEntry::expr, EXPR_KIND_CYCLE_MARK, exprCollation(), exprLocation(), exprType(), exprTypmod(), format_type_be(), format_type_with_typemod(), get_collation_name(), get_negator(), GetCTETargetList, if(), IsA, lappend(), SetOperationStmt::larg, lfirst, lfirst_int, lfirst_node, lfirst_oid, list_head(), list_make2, list_member(), lnext(), CTESearchClause::location, CTECycleClause::location, CommonTableExpr::location, lookup_type_cache(), makeString(), NIL, OidIsValid, ParseState::parentParseState, parse_sub_analyze(), parser_errposition(), SetOperationStmt::rarg, TargetEntry::resno, CTESearchClause::search_col_list, CTESearchClause::search_seq_column, select_common_collation(), select_common_type(), select_common_typmod(), Query::setOperations, strVal, transformExpr(), TYPECACHE_EQ_OPR, and Query::utilityStmt.
Referenced by transformWithClause().
void analyzeCTETargetList | ( | ParseState * | pstate, |
CommonTableExpr * | cte, | ||
List * | tlist | ||
) |
Definition at line 570 of file parse_cte.c.
References Assert, copyObject, CommonTableExpr::ctename, ereport, errcode(), errmsg(), ERROR, TargetEntry::expr, exprCollation(), exprType(), exprTypmod(), lappend(), lappend_int(), lappend_oid(), lfirst, list_length(), CommonTableExpr::location, makeString(), NIL, OidIsValid, parser_errposition(), pstrdup(), and TargetEntry::resno.
Referenced by analyzeCTE(), and determineRecursiveColTypes().
|
static |
Definition at line 849 of file parse_cte.c.
References Assert, checkWellFormedRecursionWalker(), CteState::context, CteItem::cte, CommonTableExpr::ctename, CommonTableExpr::ctequery, CteState::curitem, elog, ereport, errcode(), errmsg(), ERROR, exprLocation(), i, CteState::innerwiths, IsA, CteState::items, CommonTableExpr::location, NIL, CteState::numitems, parser_errposition(), CteState::pstate, RECURSION_NONRECURSIVETERM, RECURSION_OK, RECURSION_SUBLINK, CteState::selfrefcount, SETOP_UNION, and stmt.
Referenced by transformWithClause().
Definition at line 961 of file parse_cte.c.
References checkWellFormedSelectStmt(), CteState::context, CteItem::cte, CommonTableExpr::ctename, CommonTableExpr::ctequery, CteState::curitem, elog, ereport, errcode(), errmsg(), ERROR, CteState::innerwiths, IsA, CteState::items, j, JOIN_FULL, JOIN_INNER, JOIN_LEFT, JOIN_RIGHT, lappend(), lcons(), lfirst, list_delete_first(), list_head(), RangeVar::location, NIL, parser_errposition(), CteState::pstate, raw_expression_tree_walker, recursion_errormsgs, RECURSION_OK, RECURSION_OUTERJOIN, RECURSION_SUBLINK, RangeVar::relname, RangeVar::schemaname, CteState::selfrefcount, stmt, SubLink::subselect, and SubLink::testexpr.
Referenced by checkWellFormedRecursion(), and checkWellFormedSelectStmt().
|
static |
Definition at line 1141 of file parse_cte.c.
References checkWellFormedRecursionWalker(), CteState::context, elog, ERROR, raw_expression_tree_walker, RECURSION_EXCEPT, RECURSION_INTERSECT, RECURSION_OK, SETOP_EXCEPT, SETOP_INTERSECT, SETOP_NONE, SETOP_UNION, and stmt.
Referenced by checkWellFormedRecursionWalker().
|
static |
Definition at line 647 of file parse_cte.c.
References Assert, CteItem::cte, CommonTableExpr::ctequery, CteState::curitem, i, CteState::innerwiths, CteState::items, makeDependencyGraphWalker(), NIL, CteState::numitems, CteState::pstate, and TopologicalSort().
Referenced by transformWithClause().
Definition at line 669 of file parse_cte.c.
References bms_add_member(), CteItem::cte, CommonTableExpr::ctename, CommonTableExpr::ctequery, CteState::curitem, CteItem::depends_on, i, CteItem::id, CteState::innerwiths, IsA, CteState::items, lappend(), lcons(), lfirst, list_delete_first(), list_head(), NIL, CteState::numitems, raw_expression_tree_walker, RangeVar::relname, RangeVar::schemaname, and stmt.
Referenced by makeDependencyGraph().
|
static |
Definition at line 797 of file parse_cte.c.
References bms_del_member(), bms_is_empty, ereport, errcode(), errmsg(), ERROR, i, items, j, and parser_errposition().
Referenced by makeDependencyGraph().
List* transformWithClause | ( | ParseState * | pstate, |
WithClause * | withClause | ||
) |
Definition at line 109 of file parse_cte.c.
References analyzeCTE(), Assert, checkWellFormedRecursion(), CteItem::cte, CommonTableExpr::ctename, CommonTableExpr::ctequery, WithClause::ctes, ereport, errcode(), errmsg(), ERROR, for_each_cell, i, CteItem::id, IsA, CteState::items, lappend(), lfirst, list_copy(), list_delete_first(), list_length(), lnext(), CommonTableExpr::location, makeDependencyGraph(), NIL, CteState::numitems, ParseState::p_ctenamespace, ParseState::p_future_ctes, ParseState::p_hasModifyingCTE, palloc0(), parser_errposition(), CteState::pstate, and WithClause::recursive.
Referenced by transformDeleteStmt(), transformInsertStmt(), transformMergeStmt(), transformSelectStmt(), transformSetOperationStmt(), transformUpdateStmt(), and transformValuesClause().
|
static |
Definition at line 42 of file parse_cte.c.
Referenced by checkWellFormedRecursionWalker().