PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
view.c File Reference
#include "postgres.h"
#include "access/relation.h"
#include "access/xact.h"
#include "catalog/namespace.h"
#include "commands/tablecmds.h"
#include "commands/view.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "parser/analyze.h"
#include "parser/parse_relation.h"
#include "rewrite/rewriteDefine.h"
#include "rewrite/rewriteHandler.h"
#include "rewrite/rewriteSupport.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
Include dependency graph for view.c:

Go to the source code of this file.

Functions

static void checkViewColumns (TupleDesc newdesc, TupleDesc olddesc)
 
static ObjectAddress DefineVirtualRelation (RangeVar *relation, List *tlist, bool replace, List *options, Query *viewParse)
 
static void DefineViewRules (Oid viewOid, Query *viewParse, bool replace)
 
ObjectAddress DefineView (ViewStmt *stmt, const char *queryString, int stmt_location, int stmt_len)
 
void StoreViewQuery (Oid viewOid, Query *viewParse, bool replace)
 

Function Documentation

◆ checkViewColumns()

static void checkViewColumns ( TupleDesc  newdesc,
TupleDesc  olddesc 
)
static

Definition at line 267 of file view.c.

268{
269 int i;
270
271 if (newdesc->natts < olddesc->natts)
273 (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
274 errmsg("cannot drop columns from view")));
275
276 for (i = 0; i < olddesc->natts; i++)
277 {
278 Form_pg_attribute newattr = TupleDescAttr(newdesc, i);
279 Form_pg_attribute oldattr = TupleDescAttr(olddesc, i);
280
281 /* XXX msg not right, but we don't support DROP COL on view anyway */
282 if (newattr->attisdropped != oldattr->attisdropped)
284 (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
285 errmsg("cannot drop columns from view")));
286
287 if (strcmp(NameStr(newattr->attname), NameStr(oldattr->attname)) != 0)
289 (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
290 errmsg("cannot change name of view column \"%s\" to \"%s\"",
291 NameStr(oldattr->attname),
292 NameStr(newattr->attname)),
293 errhint("Use ALTER VIEW ... RENAME COLUMN ... to change name of view column instead.")));
294
295 /*
296 * We cannot allow type, typmod, or collation to change, since these
297 * properties may be embedded in Vars of other views/rules referencing
298 * this one. Other column attributes can be ignored.
299 */
300 if (newattr->atttypid != oldattr->atttypid ||
301 newattr->atttypmod != oldattr->atttypmod)
303 (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
304 errmsg("cannot change data type of view column \"%s\" from %s to %s",
305 NameStr(oldattr->attname),
306 format_type_with_typemod(oldattr->atttypid,
307 oldattr->atttypmod),
308 format_type_with_typemod(newattr->atttypid,
309 newattr->atttypmod))));
310
311 /*
312 * At this point, attcollations should be both valid or both invalid,
313 * so applying get_collation_name unconditionally should be fine.
314 */
315 if (newattr->attcollation != oldattr->attcollation)
317 (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
318 errmsg("cannot change collation of view column \"%s\" from \"%s\" to \"%s\"",
319 NameStr(oldattr->attname),
320 get_collation_name(oldattr->attcollation),
321 get_collation_name(newattr->attcollation))));
322 }
323
324 /*
325 * We ignore the constraint fields. The new view desc can't have any
326 * constraints, and the only ones that could be on the old view are
327 * defaults, which we are happy to leave in place.
328 */
329}
#define NameStr(name)
Definition: c.h:700
int errhint(const char *fmt,...)
Definition: elog.c:1317
int errcode(int sqlerrcode)
Definition: elog.c:853
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
char * format_type_with_typemod(Oid type_oid, int32 typemod)
Definition: format_type.c:362
int i
Definition: isn.c:72
char * get_collation_name(Oid colloid)
Definition: lsyscache.c:1035
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:200
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Definition: tupdesc.h:152

References ereport, errcode(), errhint(), errmsg(), ERROR, format_type_with_typemod(), get_collation_name(), i, NameStr, TupleDescData::natts, and TupleDescAttr().

Referenced by DefineVirtualRelation().

◆ DefineView()

ObjectAddress DefineView ( ViewStmt stmt,
const char *  queryString,
int  stmt_location,
int  stmt_len 
)

Definition at line 356 of file view.c.

358{
359 RawStmt *rawstmt;
360 Query *viewParse;
361 RangeVar *view;
362 ListCell *cell;
363 bool check_option;
364 ObjectAddress address;
365
366 /*
367 * Run parse analysis to convert the raw parse tree to a Query. Note this
368 * also acquires sufficient locks on the source table(s).
369 */
370 rawstmt = makeNode(RawStmt);
371 rawstmt->stmt = stmt->query;
372 rawstmt->stmt_location = stmt_location;
373 rawstmt->stmt_len = stmt_len;
374
375 viewParse = parse_analyze_fixedparams(rawstmt, queryString, NULL, 0, NULL);
376
377 /*
378 * The grammar should ensure that the result is a single SELECT Query.
379 * However, it doesn't forbid SELECT INTO, so we have to check for that.
380 */
381 if (!IsA(viewParse, Query))
382 elog(ERROR, "unexpected parse analysis result");
383 if (viewParse->utilityStmt != NULL &&
384 IsA(viewParse->utilityStmt, CreateTableAsStmt))
386 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
387 errmsg("views must not contain SELECT INTO")));
388 if (viewParse->commandType != CMD_SELECT)
389 elog(ERROR, "unexpected parse analysis result");
390
391 /*
392 * Check for unsupported cases. These tests are redundant with ones in
393 * DefineQueryRewrite(), but that function will complain about a bogus ON
394 * SELECT rule, and we'd rather the message complain about a view.
395 */
396 if (viewParse->hasModifyingCTE)
398 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
399 errmsg("views must not contain data-modifying statements in WITH")));
400
401 /*
402 * If the user specified the WITH CHECK OPTION, add it to the list of
403 * reloptions.
404 */
405 if (stmt->withCheckOption == LOCAL_CHECK_OPTION)
406 stmt->options = lappend(stmt->options,
407 makeDefElem("check_option",
408 (Node *) makeString("local"), -1));
409 else if (stmt->withCheckOption == CASCADED_CHECK_OPTION)
410 stmt->options = lappend(stmt->options,
411 makeDefElem("check_option",
412 (Node *) makeString("cascaded"), -1));
413
414 /*
415 * Check that the view is auto-updatable if WITH CHECK OPTION was
416 * specified.
417 */
418 check_option = false;
419
420 foreach(cell, stmt->options)
421 {
422 DefElem *defel = (DefElem *) lfirst(cell);
423
424 if (strcmp(defel->defname, "check_option") == 0)
425 check_option = true;
426 }
427
428 /*
429 * If the check option is specified, look to see if the view is actually
430 * auto-updatable or not.
431 */
432 if (check_option)
433 {
434 const char *view_updatable_error =
435 view_query_is_auto_updatable(viewParse, true);
436
437 if (view_updatable_error)
439 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
440 errmsg("WITH CHECK OPTION is supported only on automatically updatable views"),
441 errhint("%s", _(view_updatable_error))));
442 }
443
444 /*
445 * If a list of column names was given, run through and insert these into
446 * the actual query tree. - thomas 2000-03-08
447 */
448 if (stmt->aliases != NIL)
449 {
450 ListCell *alist_item = list_head(stmt->aliases);
451 ListCell *targetList;
452
453 foreach(targetList, viewParse->targetList)
454 {
455 TargetEntry *te = lfirst_node(TargetEntry, targetList);
456
457 /* junk columns don't get aliases */
458 if (te->resjunk)
459 continue;
460 te->resname = pstrdup(strVal(lfirst(alist_item)));
461 alist_item = lnext(stmt->aliases, alist_item);
462 if (alist_item == NULL)
463 break; /* done assigning aliases */
464 }
465
466 if (alist_item != NULL)
468 (errcode(ERRCODE_SYNTAX_ERROR),
469 errmsg("CREATE VIEW specifies more column "
470 "names than columns")));
471 }
472
473 /* Unlogged views are not sensible. */
474 if (stmt->view->relpersistence == RELPERSISTENCE_UNLOGGED)
476 (errcode(ERRCODE_SYNTAX_ERROR),
477 errmsg("views cannot be unlogged because they do not have storage")));
478
479 /*
480 * If the user didn't explicitly ask for a temporary view, check whether
481 * we need one implicitly. We allow TEMP to be inserted automatically as
482 * long as the CREATE command is consistent with that --- no explicit
483 * schema name.
484 */
485 view = copyObject(stmt->view); /* don't corrupt original command */
486 if (view->relpersistence == RELPERSISTENCE_PERMANENT
487 && isQueryUsingTempRelation(viewParse))
488 {
489 view->relpersistence = RELPERSISTENCE_TEMP;
491 (errmsg("view \"%s\" will be a temporary view",
492 view->relname)));
493 }
494
495 /*
496 * Create the view relation
497 *
498 * NOTE: if it already exists and replace is false, the xact will be
499 * aborted.
500 */
501 address = DefineVirtualRelation(view, viewParse->targetList,
502 stmt->replace, stmt->options, viewParse);
503
504 return address;
505}
#define _(x)
Definition: elog.c:90
#define elog(elevel,...)
Definition: elog.h:225
#define NOTICE
Definition: elog.h:35
#define stmt
Definition: indent_codes.h:59
List * lappend(List *list, void *datum)
Definition: list.c:339
DefElem * makeDefElem(char *name, Node *arg, int location)
Definition: makefuncs.c:587
char * pstrdup(const char *in)
Definition: mcxt.c:1696
#define IsA(nodeptr, _type_)
Definition: nodes.h:158
#define copyObject(obj)
Definition: nodes.h:224
@ CMD_SELECT
Definition: nodes.h:265
#define makeNode(_type_)
Definition: nodes.h:155
bool isQueryUsingTempRelation(Query *query)
@ CASCADED_CHECK_OPTION
Definition: parsenodes.h:3765
@ LOCAL_CHECK_OPTION
Definition: parsenodes.h:3764
Query * parse_analyze_fixedparams(RawStmt *parseTree, const char *sourceText, const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv)
Definition: analyze.c:105
#define lfirst(lc)
Definition: pg_list.h:172
#define lfirst_node(type, lc)
Definition: pg_list.h:176
#define NIL
Definition: pg_list.h:68
static ListCell * list_head(const List *l)
Definition: pg_list.h:128
static ListCell * lnext(const List *l, const ListCell *c)
Definition: pg_list.h:343
const char * view_query_is_auto_updatable(Query *viewquery, bool check_cols)
char * defname
Definition: parsenodes.h:817
Definition: nodes.h:129
CmdType commandType
Definition: parsenodes.h:121
Node * utilityStmt
Definition: parsenodes.h:136
List * targetList
Definition: parsenodes.h:193
char * relname
Definition: primnodes.h:82
char relpersistence
Definition: primnodes.h:88
ParseLoc stmt_location
Definition: parsenodes.h:2023
ParseLoc stmt_len
Definition: parsenodes.h:2024
Node * stmt
Definition: parsenodes.h:2022
String * makeString(char *str)
Definition: value.c:63
#define strVal(v)
Definition: value.h:82
static ObjectAddress DefineVirtualRelation(RangeVar *relation, List *tlist, bool replace, List *options, Query *viewParse)
Definition: view.c:45

References _, CASCADED_CHECK_OPTION, CMD_SELECT, Query::commandType, copyObject, DefineVirtualRelation(), DefElem::defname, elog, ereport, errcode(), errhint(), errmsg(), ERROR, IsA, isQueryUsingTempRelation(), lappend(), lfirst, lfirst_node, list_head(), lnext(), LOCAL_CHECK_OPTION, makeDefElem(), makeNode, makeString(), NIL, NOTICE, parse_analyze_fixedparams(), pstrdup(), RangeVar::relname, RangeVar::relpersistence, RawStmt::stmt, stmt, RawStmt::stmt_len, RawStmt::stmt_location, strVal, Query::targetList, Query::utilityStmt, and view_query_is_auto_updatable().

Referenced by ProcessUtilitySlow().

◆ DefineViewRules()

static void DefineViewRules ( Oid  viewOid,
Query viewParse,
bool  replace 
)
static

Definition at line 332 of file view.c.

333{
334 /*
335 * Set up the ON SELECT rule. Since the query has already been through
336 * parse analysis, we use DefineQueryRewrite() directly.
337 */
339 viewOid,
340 NULL,
342 true,
343 replace,
344 list_make1(viewParse));
345
346 /*
347 * Someday: automatic ON INSERT, etc
348 */
349}
#define list_make1(x1)
Definition: pg_list.h:212
ObjectAddress DefineQueryRewrite(const char *rulename, Oid event_relid, Node *event_qual, CmdType event_type, bool is_instead, bool replace, List *action)
#define ViewSelectRuleName

References CMD_SELECT, DefineQueryRewrite(), list_make1, pstrdup(), and ViewSelectRuleName.

Referenced by StoreViewQuery().

◆ DefineVirtualRelation()

static ObjectAddress DefineVirtualRelation ( RangeVar relation,
List tlist,
bool  replace,
List options,
Query viewParse 
)
static

Definition at line 45 of file view.c.

47{
48 Oid viewOid;
49 LOCKMODE lockmode;
50 List *attrList;
51 ListCell *t;
52
53 /*
54 * create a list of ColumnDef nodes based on the names and types of the
55 * (non-junk) targetlist items from the view's SELECT list.
56 */
57 attrList = NIL;
58 foreach(t, tlist)
59 {
60 TargetEntry *tle = (TargetEntry *) lfirst(t);
61
62 if (!tle->resjunk)
63 {
64 ColumnDef *def = makeColumnDef(tle->resname,
65 exprType((Node *) tle->expr),
66 exprTypmod((Node *) tle->expr),
67 exprCollation((Node *) tle->expr));
68
69 /*
70 * It's possible that the column is of a collatable type but the
71 * collation could not be resolved, so double-check.
72 */
73 if (type_is_collatable(exprType((Node *) tle->expr)))
74 {
75 if (!OidIsValid(def->collOid))
77 (errcode(ERRCODE_INDETERMINATE_COLLATION),
78 errmsg("could not determine which collation to use for view column \"%s\"",
79 def->colname),
80 errhint("Use the COLLATE clause to set the collation explicitly.")));
81 }
82 else
84
85 attrList = lappend(attrList, def);
86 }
87 }
88
89 /*
90 * Look up, check permissions on, and lock the creation namespace; also
91 * check for a preexisting view with the same name. This will also set
92 * relation->relpersistence to RELPERSISTENCE_TEMP if the selected
93 * namespace is temporary.
94 */
95 lockmode = replace ? AccessExclusiveLock : NoLock;
96 (void) RangeVarGetAndCheckCreationNamespace(relation, lockmode, &viewOid);
97
98 if (OidIsValid(viewOid) && replace)
99 {
100 Relation rel;
102 List *atcmds = NIL;
103 AlterTableCmd *atcmd;
104 ObjectAddress address;
105
106 /* Relation is already locked, but we must build a relcache entry. */
107 rel = relation_open(viewOid, NoLock);
108
109 /* Make sure it *is* a view. */
110 if (rel->rd_rel->relkind != RELKIND_VIEW)
112 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
113 errmsg("\"%s\" is not a view",
115
116 /* Also check it's not in use already */
117 CheckTableNotInUse(rel, "CREATE OR REPLACE VIEW");
118
119 /*
120 * Due to the namespace visibility rules for temporary objects, we
121 * should only end up replacing a temporary view with another
122 * temporary view, and similarly for permanent views.
123 */
124 Assert(relation->relpersistence == rel->rd_rel->relpersistence);
125
126 /*
127 * Create a tuple descriptor to compare against the existing view, and
128 * verify that the old column list is an initial prefix of the new
129 * column list.
130 */
133
134 /*
135 * If new attributes have been added, we must add pg_attribute entries
136 * for them. It is convenient (although overkill) to use the ALTER
137 * TABLE ADD COLUMN infrastructure for this.
138 *
139 * Note that we must do this before updating the query for the view,
140 * since the rules system requires that the correct view columns be in
141 * place when defining the new rules.
142 *
143 * Also note that ALTER TABLE doesn't run parse transformation on
144 * AT_AddColumnToView commands. The ColumnDef we supply must be ready
145 * to execute as-is.
146 */
147 if (list_length(attrList) > rel->rd_att->natts)
148 {
149 ListCell *c;
150 int skip = rel->rd_att->natts;
151
152 foreach(c, attrList)
153 {
154 if (skip > 0)
155 {
156 skip--;
157 continue;
158 }
159 atcmd = makeNode(AlterTableCmd);
161 atcmd->def = (Node *) lfirst(c);
162 atcmds = lappend(atcmds, atcmd);
163 }
164
165 /* EventTriggerAlterTableStart called by ProcessUtilitySlow */
166 AlterTableInternal(viewOid, atcmds, true);
167
168 /* Make the new view columns visible */
170 }
171
172 /*
173 * Update the query for the view.
174 *
175 * Note that we must do this before updating the view options, because
176 * the new options may not be compatible with the old view query (for
177 * example if we attempt to add the WITH CHECK OPTION, we require that
178 * the new view be automatically updatable, but the old view may not
179 * have been).
180 */
181 StoreViewQuery(viewOid, viewParse, replace);
182
183 /* Make the new view query visible */
185
186 /*
187 * Update the view's options.
188 *
189 * The new options list replaces the existing options list, even if
190 * it's empty.
191 */
192 atcmd = makeNode(AlterTableCmd);
194 atcmd->def = (Node *) options;
195 atcmds = list_make1(atcmd);
196
197 /* EventTriggerAlterTableStart called by ProcessUtilitySlow */
198 AlterTableInternal(viewOid, atcmds, true);
199
200 /*
201 * There is very little to do here to update the view's dependencies.
202 * Most view-level dependency relationships, such as those on the
203 * owner, schema, and associated composite type, aren't changing.
204 * Because we don't allow changing type or collation of an existing
205 * view column, those dependencies of the existing columns don't
206 * change either, while the AT_AddColumnToView machinery took care of
207 * adding such dependencies for new view columns. The dependencies of
208 * the view's query could have changed arbitrarily, but that was dealt
209 * with inside StoreViewQuery. What remains is only to check that
210 * view replacement is allowed when we're creating an extension.
211 */
212 ObjectAddressSet(address, RelationRelationId, viewOid);
213
215
216 /*
217 * Seems okay, so return the OID of the pre-existing view.
218 */
219 relation_close(rel, NoLock); /* keep the lock! */
220
221 return address;
222 }
223 else
224 {
225 CreateStmt *createStmt = makeNode(CreateStmt);
226 ObjectAddress address;
227
228 /*
229 * Set the parameters for keys/inheritance etc. All of these are
230 * uninteresting for views...
231 */
232 createStmt->relation = relation;
233 createStmt->tableElts = attrList;
234 createStmt->inhRelations = NIL;
235 createStmt->constraints = NIL;
236 createStmt->options = options;
237 createStmt->oncommit = ONCOMMIT_NOOP;
238 createStmt->tablespacename = NULL;
239 createStmt->if_not_exists = false;
240
241 /*
242 * Create the relation (this will error out if there's an existing
243 * view, so we don't need more code to complain if "replace" is
244 * false).
245 */
246 address = DefineRelation(createStmt, RELKIND_VIEW, InvalidOid, NULL,
247 NULL);
248 Assert(address.objectId != InvalidOid);
249
250 /* Make the new view relation visible */
252
253 /* Store the query for the view */
254 StoreViewQuery(address.objectId, viewParse, replace);
255
256 return address;
257 }
258}
#define Assert(condition)
Definition: c.h:812
#define OidIsValid(objectId)
Definition: c.h:729
int LOCKMODE
Definition: lockdefs.h:26
#define NoLock
Definition: lockdefs.h:34
#define AccessExclusiveLock
Definition: lockdefs.h:43
bool type_is_collatable(Oid typid)
Definition: lsyscache.c:3081
ColumnDef * makeColumnDef(const char *colname, Oid typeOid, int32 typmod, Oid collOid)
Definition: makefuncs.c:515
Oid RangeVarGetAndCheckCreationNamespace(RangeVar *relation, LOCKMODE lockmode, Oid *existing_relation_id)
Definition: namespace.c:739
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:42
int32 exprTypmod(const Node *expr)
Definition: nodeFuncs.c:298
Oid exprCollation(const Node *expr)
Definition: nodeFuncs.c:816
#define ObjectAddressSet(addr, class_id, object_id)
Definition: objectaddress.h:40
@ AT_ReplaceRelOptions
Definition: parsenodes.h:2396
@ AT_AddColumnToView
Definition: parsenodes.h:2361
static const struct exclude_list_item skip[]
Definition: pg_checksums.c:107
void recordDependencyOnCurrentExtension(const ObjectAddress *object, bool isReplace)
Definition: pg_depend.c:193
static int list_length(const List *l)
Definition: pg_list.h:152
static char ** options
#define InvalidOid
Definition: postgres_ext.h:36
unsigned int Oid
Definition: postgres_ext.h:31
char * c
@ ONCOMMIT_NOOP
Definition: primnodes.h:57
#define RelationGetRelationName(relation)
Definition: rel.h:539
void relation_close(Relation relation, LOCKMODE lockmode)
Definition: relation.c:205
Relation relation_open(Oid relationId, LOCKMODE lockmode)
Definition: relation.c:47
AlterTableType subtype
Definition: parsenodes.h:2438
char * colname
Definition: parsenodes.h:728
Oid collOid
Definition: parsenodes.h:744
List * tableElts
Definition: parsenodes.h:2676
OnCommitAction oncommit
Definition: parsenodes.h:2685
List * options
Definition: parsenodes.h:2684
bool if_not_exists
Definition: parsenodes.h:2688
List * inhRelations
Definition: parsenodes.h:2677
RangeVar * relation
Definition: parsenodes.h:2675
char * tablespacename
Definition: parsenodes.h:2686
List * constraints
Definition: parsenodes.h:2682
Definition: pg_list.h:54
TupleDesc rd_att
Definition: rel.h:112
Form_pg_class rd_rel
Definition: rel.h:111
Expr * expr
Definition: primnodes.h:2190
TupleDesc BuildDescForRelation(const List *columns)
Definition: tablecmds.c:1330
void CheckTableNotInUse(Relation rel, const char *stmt)
Definition: tablecmds.c:4334
ObjectAddress DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, ObjectAddress *typaddress, const char *queryString)
Definition: tablecmds.c:713
void AlterTableInternal(Oid relid, List *cmds, bool recurse)
Definition: tablecmds.c:4481
static void checkViewColumns(TupleDesc newdesc, TupleDesc olddesc)
Definition: view.c:267
void StoreViewQuery(Oid viewOid, Query *viewParse, bool replace)
Definition: view.c:511
void CommandCounterIncrement(void)
Definition: xact.c:1099

References AccessExclusiveLock, AlterTableInternal(), Assert, AT_AddColumnToView, AT_ReplaceRelOptions, BuildDescForRelation(), CheckTableNotInUse(), checkViewColumns(), ColumnDef::collOid, ColumnDef::colname, CommandCounterIncrement(), CreateStmt::constraints, AlterTableCmd::def, DefineRelation(), ereport, errcode(), errhint(), errmsg(), ERROR, TargetEntry::expr, exprCollation(), exprType(), exprTypmod(), CreateStmt::if_not_exists, CreateStmt::inhRelations, InvalidOid, lappend(), lfirst, list_length(), list_make1, makeColumnDef(), makeNode, TupleDescData::natts, NIL, NoLock, ObjectAddressSet, ObjectAddress::objectId, OidIsValid, CreateStmt::oncommit, ONCOMMIT_NOOP, options, CreateStmt::options, RangeVarGetAndCheckCreationNamespace(), RelationData::rd_att, RelationData::rd_rel, recordDependencyOnCurrentExtension(), CreateStmt::relation, relation_close(), relation_open(), RelationGetRelationName, RangeVar::relpersistence, skip, StoreViewQuery(), AlterTableCmd::subtype, CreateStmt::tableElts, CreateStmt::tablespacename, and type_is_collatable().

Referenced by DefineView().

◆ StoreViewQuery()

void StoreViewQuery ( Oid  viewOid,
Query viewParse,
bool  replace 
)

Definition at line 511 of file view.c.

512{
513 /*
514 * Now create the rules associated with the view.
515 */
516 DefineViewRules(viewOid, viewParse, replace);
517}
static void DefineViewRules(Oid viewOid, Query *viewParse, bool replace)
Definition: view.c:332

References DefineViewRules().

Referenced by create_ctas_internal(), and DefineVirtualRelation().