1999-02-13 18:22:53 -05:00
|
|
|
/*-------------------------------------------------------------------------
|
1997-11-25 17:07:18 -05:00
|
|
|
*
|
1999-07-18 20:26:20 -04:00
|
|
|
* parse_relation.h
|
|
|
|
|
* prototypes for parse_relation.c.
|
1997-11-25 17:07:18 -05:00
|
|
|
*
|
|
|
|
|
*
|
2019-01-02 12:44:25 -05:00
|
|
|
* Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
|
2000-01-26 00:58:53 -05:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1997-11-25 17:07:18 -05:00
|
|
|
*
|
2010-09-20 16:08:53 -04:00
|
|
|
* src/include/parser/parse_relation.h
|
1997-11-25 17:07:18 -05:00
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
1999-07-18 20:26:20 -04:00
|
|
|
#ifndef PARSE_RELATION_H
|
|
|
|
|
#define PARSE_RELATION_H
|
1997-11-25 17:07:18 -05:00
|
|
|
|
1999-07-15 19:04:24 -04:00
|
|
|
#include "parser/parse_node.h"
|
1997-11-25 17:07:18 -05:00
|
|
|
|
2015-03-11 10:44:04 -04:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Support for fuzzily matching column.
|
|
|
|
|
*
|
|
|
|
|
* This is for building diagnostic messages, where non-exact matching
|
|
|
|
|
* attributes are suggested to the user. The struct's fields may be facets of
|
|
|
|
|
* a particular RTE, or of an entire range table, depending on context.
|
|
|
|
|
*/
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2015-05-23 21:35:49 -04:00
|
|
|
int distance; /* Weighted distance (lowest so far) */
|
|
|
|
|
RangeTblEntry *rfirst; /* RTE of first */
|
|
|
|
|
AttrNumber first; /* Closest attribute so far */
|
|
|
|
|
RangeTblEntry *rsecond; /* RTE of second */
|
|
|
|
|
AttrNumber second; /* Second closest attribute so far */
|
2015-03-11 10:44:04 -04:00
|
|
|
} FuzzyAttrMatchState;
|
|
|
|
|
|
|
|
|
|
|
2002-03-11 19:52:10 -05:00
|
|
|
extern RangeTblEntry *refnameRangeTblEntry(ParseState *pstate,
|
2019-05-22 13:04:48 -04:00
|
|
|
const char *schemaname,
|
|
|
|
|
const char *refname,
|
|
|
|
|
int location,
|
|
|
|
|
int *sublevels_up);
|
2008-10-05 22:12:56 -04:00
|
|
|
extern CommonTableExpr *scanNameSpaceForCTE(ParseState *pstate,
|
2019-05-22 13:04:48 -04:00
|
|
|
const char *refname,
|
|
|
|
|
Index *ctelevelsup);
|
2017-04-01 00:17:18 -04:00
|
|
|
extern bool scanNameSpaceForENR(ParseState *pstate, const char *refname);
|
2005-06-04 20:38:11 -04:00
|
|
|
extern void checkNameSpaceConflicts(ParseState *pstate, List *namespace1,
|
2019-05-22 13:04:48 -04:00
|
|
|
List *namespace2);
|
|
|
|
|
extern int RTERangeTablePosn(ParseState *pstate,
|
|
|
|
|
RangeTblEntry *rte,
|
|
|
|
|
int *sublevels_up);
|
2004-04-02 14:07:02 -05:00
|
|
|
extern RangeTblEntry *GetRTEByRangeTablePosn(ParseState *pstate,
|
2019-05-22 13:04:48 -04:00
|
|
|
int varno,
|
|
|
|
|
int sublevels_up);
|
2008-10-06 11:15:22 -04:00
|
|
|
extern CommonTableExpr *GetCTEForRTE(ParseState *pstate, RangeTblEntry *rte,
|
2019-05-22 13:04:48 -04:00
|
|
|
int rtelevelsup);
|
2004-04-02 14:07:02 -05:00
|
|
|
extern Node *scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte,
|
2019-05-22 13:04:48 -04:00
|
|
|
const char *colname, int location,
|
|
|
|
|
int fuzzy_rte_penalty, FuzzyAttrMatchState *fuzzystate);
|
2017-10-31 10:34:31 -04:00
|
|
|
extern Node *colNameToVar(ParseState *pstate, const char *colname, bool localonly,
|
2019-05-22 13:04:48 -04:00
|
|
|
int location);
|
2009-01-22 15:16:10 -05:00
|
|
|
extern void markVarForSelectPriv(ParseState *pstate, Var *var,
|
2019-05-22 13:04:48 -04:00
|
|
|
RangeTblEntry *rte);
|
2008-09-01 16:42:46 -04:00
|
|
|
extern Relation parserOpenTable(ParseState *pstate, const RangeVar *relation,
|
2019-05-22 13:04:48 -04:00
|
|
|
int lockmode);
|
1998-09-01 00:40:42 -04:00
|
|
|
extern RangeTblEntry *addRangeTableEntry(ParseState *pstate,
|
2019-05-22 13:04:48 -04:00
|
|
|
RangeVar *relation,
|
|
|
|
|
Alias *alias,
|
|
|
|
|
bool inh,
|
|
|
|
|
bool inFromCl);
|
2002-03-21 21:56:37 -05:00
|
|
|
extern RangeTblEntry *addRangeTableEntryForRelation(ParseState *pstate,
|
2019-05-22 13:04:48 -04:00
|
|
|
Relation rel,
|
|
|
|
|
int lockmode,
|
|
|
|
|
Alias *alias,
|
|
|
|
|
bool inh,
|
|
|
|
|
bool inFromCl);
|
2000-09-29 14:21:41 -04:00
|
|
|
extern RangeTblEntry *addRangeTableEntryForSubquery(ParseState *pstate,
|
2019-05-22 13:04:48 -04:00
|
|
|
Query *subquery,
|
|
|
|
|
Alias *alias,
|
|
|
|
|
bool lateral,
|
|
|
|
|
bool inFromCl);
|
2002-05-12 16:10:05 -04:00
|
|
|
extern RangeTblEntry *addRangeTableEntryForFunction(ParseState *pstate,
|
2019-05-22 13:04:48 -04:00
|
|
|
List *funcnames,
|
|
|
|
|
List *funcexprs,
|
|
|
|
|
List *coldeflists,
|
|
|
|
|
RangeFunction *rangefunc,
|
|
|
|
|
bool lateral,
|
|
|
|
|
bool inFromCl);
|
2006-08-01 21:59:48 -04:00
|
|
|
extern RangeTblEntry *addRangeTableEntryForValues(ParseState *pstate,
|
2019-05-22 13:04:48 -04:00
|
|
|
List *exprs,
|
|
|
|
|
List *coltypes,
|
|
|
|
|
List *coltypmods,
|
|
|
|
|
List *colcollations,
|
|
|
|
|
Alias *alias,
|
|
|
|
|
bool lateral,
|
|
|
|
|
bool inFromCl);
|
2017-03-08 10:39:37 -05:00
|
|
|
extern RangeTblEntry *addRangeTableEntryForTableFunc(ParseState *pstate,
|
2019-05-22 13:04:48 -04:00
|
|
|
TableFunc *tf,
|
|
|
|
|
Alias *alias,
|
|
|
|
|
bool lateral,
|
|
|
|
|
bool inFromCl);
|
2002-03-11 19:52:10 -05:00
|
|
|
extern RangeTblEntry *addRangeTableEntryForJoin(ParseState *pstate,
|
2019-05-22 13:04:48 -04:00
|
|
|
List *colnames,
|
|
|
|
|
JoinType jointype,
|
|
|
|
|
List *aliasvars,
|
|
|
|
|
Alias *alias,
|
|
|
|
|
bool inFromCl);
|
2008-10-04 17:56:55 -04:00
|
|
|
extern RangeTblEntry *addRangeTableEntryForCTE(ParseState *pstate,
|
2019-05-22 13:04:48 -04:00
|
|
|
CommonTableExpr *cte,
|
|
|
|
|
Index levelsup,
|
|
|
|
|
RangeVar *rv,
|
|
|
|
|
bool inFromCl);
|
2017-04-01 00:17:18 -04:00
|
|
|
extern RangeTblEntry *addRangeTableEntryForENR(ParseState *pstate,
|
2019-05-22 13:04:48 -04:00
|
|
|
RangeVar *rv,
|
|
|
|
|
bool inFromCl);
|
2009-10-27 13:11:18 -04:00
|
|
|
extern bool isLockedRefname(ParseState *pstate, const char *refname);
|
2001-02-14 16:35:07 -05:00
|
|
|
extern void addRTEtoQuery(ParseState *pstate, RangeTblEntry *rte,
|
2019-05-22 13:04:48 -04:00
|
|
|
bool addToJoinList,
|
|
|
|
|
bool addToRelNameSpace, bool addToVarNameSpace);
|
2015-03-26 14:03:19 -04:00
|
|
|
extern void errorMissingRTE(ParseState *pstate, RangeVar *relation) pg_attribute_noreturn();
|
2012-08-07 19:02:54 -04:00
|
|
|
extern void errorMissingColumn(ParseState *pstate,
|
2019-05-22 13:04:48 -04:00
|
|
|
const char *relname, const char *colname, int location) pg_attribute_noreturn();
|
2005-06-04 15:19:42 -04:00
|
|
|
extern void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
|
2019-05-22 13:04:48 -04:00
|
|
|
int location, bool include_dropped,
|
|
|
|
|
List **colnames, List **colvars);
|
2005-06-04 15:19:42 -04:00
|
|
|
extern List *expandRelAttrs(ParseState *pstate, RangeTblEntry *rte,
|
2019-05-22 13:04:48 -04:00
|
|
|
int rtindex, int sublevels_up, int location);
|
2002-08-02 14:15:10 -04:00
|
|
|
extern int attnameAttNum(Relation rd, const char *attname, bool sysColOK);
|
2018-10-16 12:44:43 -04:00
|
|
|
extern const NameData *attnumAttName(Relation rd, int attid);
|
1998-02-25 23:46:47 -05:00
|
|
|
extern Oid attnumTypeId(Relation rd, int attid);
|
2011-04-11 21:32:53 -04:00
|
|
|
extern Oid attnumCollationId(Relation rd, int attid);
|
Clean up the mess around EXPLAIN and materialized views.
Revert the matview-related changes in explain.c's API, as per recent
complaint from Robert Haas. The reason for these appears to have been
principally some ill-considered choices around having intorel_startup do
what ought to be parse-time checking, plus a poor arrangement for passing
it the view parsetree it needs to store into pg_rewrite when creating a
materialized view. Do the latter by having parse analysis stick a copy
into the IntoClause, instead of doing it at runtime. (On the whole,
I seriously question the choice to represent CREATE MATERIALIZED VIEW as a
variant of SELECT INTO/CREATE TABLE AS, because that means injecting even
more complexity into what was already a horrid legacy kluge. However,
I didn't go so far as to rethink that choice ... yet.)
I also moved several error checks into matview parse analysis, and
made the check for external Params in a matview more accurate.
In passing, clean things up a bit more around interpretOidsOption(),
and fix things so that we can use that to force no-oids for views,
sequences, etc, thereby eliminating the need to cons up "oids = false"
options when creating them.
catversion bump due to change in IntoClause. (I wonder though if we
really need readfuncs/outfuncs support for IntoClause anymore.)
2013-04-12 19:25:20 -04:00
|
|
|
extern bool isQueryUsingTempRelation(Query *query);
|
2001-10-28 01:26:15 -05:00
|
|
|
|
Phase 2 of pgindent updates.
Change pg_bsd_indent to follow upstream rules for placement of comments
to the right of code, and remove pgindent hack that caused comments
following #endif to not obey the general rule.
Commit e3860ffa4dd0dad0dd9eea4be9cc1412373a8c89 wasn't actually using
the published version of pg_bsd_indent, but a hacked-up version that
tried to minimize the amount of movement of comments to the right of
code. The situation of interest is where such a comment has to be
moved to the right of its default placement at column 33 because there's
code there. BSD indent has always moved right in units of tab stops
in such cases --- but in the previous incarnation, indent was working
in 8-space tab stops, while now it knows we use 4-space tabs. So the
net result is that in about half the cases, such comments are placed
one tab stop left of before. This is better all around: it leaves
more room on the line for comment text, and it means that in such
cases the comment uniformly starts at the next 4-space tab stop after
the code, rather than sometimes one and sometimes two tabs after.
Also, ensure that comments following #endif are indented the same
as comments following other preprocessor commands such as #else.
That inconsistency turns out to have been self-inflicted damage
from a poorly-thought-through post-indent "fixup" in pgindent.
This patch is much less interesting than the first round of indent
changes, but also bulkier, so I thought it best to separate the effects.
Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
2017-06-21 15:18:54 -04:00
|
|
|
#endif /* PARSE_RELATION_H */
|