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
|
|
|
*
|
|
|
|
|
*
|
2015-01-06 11:43:47 -05:00
|
|
|
* Portions Copyright (c) 1996-2015, 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
|
|
|
|
2002-03-11 19:52:10 -05:00
|
|
|
extern RangeTblEntry *refnameRangeTblEntry(ParseState *pstate,
|
2002-09-04 16:31:48 -04:00
|
|
|
const char *schemaname,
|
|
|
|
|
const char *refname,
|
2008-09-01 16:42:46 -04:00
|
|
|
int location,
|
2002-09-04 16:31:48 -04:00
|
|
|
int *sublevels_up);
|
2008-10-05 22:12:56 -04:00
|
|
|
extern CommonTableExpr *scanNameSpaceForCTE(ParseState *pstate,
|
2009-06-11 10:49:15 -04:00
|
|
|
const char *refname,
|
|
|
|
|
Index *ctelevelsup);
|
2005-06-04 20:38:11 -04:00
|
|
|
extern void checkNameSpaceConflicts(ParseState *pstate, List *namespace1,
|
|
|
|
|
List *namespace2);
|
2000-09-12 17:07:18 -04:00
|
|
|
extern int RTERangeTablePosn(ParseState *pstate,
|
2001-03-21 23:01:46 -05:00
|
|
|
RangeTblEntry *rte,
|
|
|
|
|
int *sublevels_up);
|
2004-04-02 14:07:02 -05:00
|
|
|
extern RangeTblEntry *GetRTEByRangeTablePosn(ParseState *pstate,
|
2004-08-29 01:07:03 -04:00
|
|
|
int varno,
|
|
|
|
|
int sublevels_up);
|
2008-10-06 11:15:22 -04:00
|
|
|
extern CommonTableExpr *GetCTEForRTE(ParseState *pstate, RangeTblEntry *rte,
|
2009-06-11 10:49:15 -04:00
|
|
|
int rtelevelsup);
|
2004-04-02 14:07:02 -05:00
|
|
|
extern Node *scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte,
|
2006-03-14 17:48:25 -05:00
|
|
|
char *colname, int location);
|
|
|
|
|
extern Node *colNameToVar(ParseState *pstate, char *colname, bool localonly,
|
2006-10-03 20:30:14 -04:00
|
|
|
int location);
|
2009-01-22 15:16:10 -05:00
|
|
|
extern void markVarForSelectPriv(ParseState *pstate, Var *var,
|
2009-06-11 10:49:15 -04:00
|
|
|
RangeTblEntry *rte);
|
2008-09-01 16:42:46 -04:00
|
|
|
extern Relation parserOpenTable(ParseState *pstate, const RangeVar *relation,
|
2009-06-11 10:49:15 -04:00
|
|
|
int lockmode);
|
1998-09-01 00:40:42 -04:00
|
|
|
extern RangeTblEntry *addRangeTableEntry(ParseState *pstate,
|
2002-03-21 21:56:37 -05:00
|
|
|
RangeVar *relation,
|
|
|
|
|
Alias *alias,
|
|
|
|
|
bool inh,
|
|
|
|
|
bool inFromCl);
|
|
|
|
|
extern RangeTblEntry *addRangeTableEntryForRelation(ParseState *pstate,
|
2005-04-13 12:50:55 -04:00
|
|
|
Relation rel,
|
2002-09-04 16:31:48 -04:00
|
|
|
Alias *alias,
|
|
|
|
|
bool inh,
|
|
|
|
|
bool inFromCl);
|
2000-09-29 14:21:41 -04:00
|
|
|
extern RangeTblEntry *addRangeTableEntryForSubquery(ParseState *pstate,
|
2001-03-21 23:01:46 -05:00
|
|
|
Query *subquery,
|
2002-03-21 11:02:16 -05:00
|
|
|
Alias *alias,
|
2012-08-07 19:02:54 -04:00
|
|
|
bool lateral,
|
2001-03-21 23:01:46 -05:00
|
|
|
bool inFromCl);
|
2002-05-12 16:10:05 -04:00
|
|
|
extern RangeTblEntry *addRangeTableEntryForFunction(ParseState *pstate,
|
Support multi-argument UNNEST(), and TABLE() syntax for multiple functions.
This patch adds the ability to write TABLE( function1(), function2(), ...)
as a single FROM-clause entry. The result is the concatenation of the
first row from each function, followed by the second row from each
function, etc; with NULLs inserted if any function produces fewer rows than
others. This is believed to be a much more useful behavior than what
Postgres currently does with multiple SRFs in a SELECT list.
This syntax also provides a reasonable way to combine use of column
definition lists with WITH ORDINALITY: put the column definition list
inside TABLE(), where it's clear that it doesn't control the ordinality
column as well.
Also implement SQL-compliant multiple-argument UNNEST(), by turning
UNNEST(a,b,c) into TABLE(unnest(a), unnest(b), unnest(c)).
The SQL standard specifies TABLE() with only a single function, not
multiple functions, and it seems to require an implicit UNNEST() which is
not what this patch does. There may be something wrong with that reading
of the spec, though, because if it's right then the spec's TABLE() is just
a pointless alternative spelling of UNNEST(). After further review of
that, we might choose to adopt a different syntax for what this patch does,
but in any case this functionality seems clearly worthwhile.
Andrew Gierth, reviewed by Zoltán Böszörményi and Heikki Linnakangas, and
significantly revised by me
2013-11-21 19:37:02 -05:00
|
|
|
List *funcnames,
|
|
|
|
|
List *funcexprs,
|
|
|
|
|
List *coldeflists,
|
2002-09-04 16:31:48 -04:00
|
|
|
RangeFunction *rangefunc,
|
2012-08-07 19:02:54 -04:00
|
|
|
bool lateral,
|
2002-09-04 16:31:48 -04:00
|
|
|
bool inFromCl);
|
2006-08-01 21:59:48 -04:00
|
|
|
extern RangeTblEntry *addRangeTableEntryForValues(ParseState *pstate,
|
|
|
|
|
List *exprs,
|
2011-04-18 15:31:52 -04:00
|
|
|
List *collations,
|
2006-08-01 21:59:48 -04:00
|
|
|
Alias *alias,
|
2012-08-19 14:12:16 -04:00
|
|
|
bool lateral,
|
2006-08-01 21:59:48 -04:00
|
|
|
bool inFromCl);
|
2002-03-11 19:52:10 -05:00
|
|
|
extern RangeTblEntry *addRangeTableEntryForJoin(ParseState *pstate,
|
|
|
|
|
List *colnames,
|
|
|
|
|
JoinType jointype,
|
2002-04-28 15:54:29 -04:00
|
|
|
List *aliasvars,
|
2002-03-21 11:02:16 -05:00
|
|
|
Alias *alias,
|
2002-03-11 19:52:10 -05:00
|
|
|
bool inFromCl);
|
2008-10-04 17:56:55 -04:00
|
|
|
extern RangeTblEntry *addRangeTableEntryForCTE(ParseState *pstate,
|
|
|
|
|
CommonTableExpr *cte,
|
|
|
|
|
Index levelsup,
|
2011-02-25 18:56:23 -05:00
|
|
|
RangeVar *rv,
|
2008-10-04 17:56:55 -04:00
|
|
|
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,
|
2005-06-04 20:38:11 -04:00
|
|
|
bool addToJoinList,
|
|
|
|
|
bool addToRelNameSpace, bool addToVarNameSpace);
|
2013-02-12 07:13:22 -05:00
|
|
|
extern void errorMissingRTE(ParseState *pstate, RangeVar *relation) __attribute__((noreturn));
|
2012-08-07 19:02:54 -04:00
|
|
|
extern void errorMissingColumn(ParseState *pstate,
|
2013-05-29 16:58:43 -04:00
|
|
|
char *relname, char *colname, int location) __attribute__((noreturn));
|
2005-06-04 15:19:42 -04:00
|
|
|
extern void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
|
2008-09-01 16:42:46 -04:00
|
|
|
int location, bool include_dropped,
|
2004-08-29 01:07:03 -04:00
|
|
|
List **colnames, List **colvars);
|
2005-06-04 15:19:42 -04:00
|
|
|
extern List *expandRelAttrs(ParseState *pstate, RangeTblEntry *rte,
|
2008-09-01 16:42:46 -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);
|
2001-10-23 13:39:03 -04:00
|
|
|
extern Name 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
|
|
|
|
2001-11-05 12:46:40 -05:00
|
|
|
#endif /* PARSE_RELATION_H */
|