78 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
79 errmsg(
"could not determine which collation to use for view column \"%s\"",
81 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
86 attrList =
lappend(attrList, def);
111 if (rel->
rd_rel->relkind != RELKIND_VIEW)
113 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
114 errmsg(
"\"%s\" is not a view",
163 atcmds =
lappend(atcmds, atcmd);
273 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
274 errmsg(
"cannot drop columns from view")));
276 for (
i = 0;
i < olddesc->
natts;
i++)
282 if (newattr->attisdropped != oldattr->attisdropped)
284 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
285 errmsg(
"cannot drop columns from view")));
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\"",
293 errhint(
"Use ALTER VIEW ... RENAME COLUMN ... to change name of view column instead.")));
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",
309 newattr->atttypmod))));
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\"",
357 int stmt_location,
int stmt_len)
382 elog(
ERROR,
"unexpected parse analysis result");
386 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
387 errmsg(
"views must not contain SELECT INTO")));
389 elog(
ERROR,
"unexpected parse analysis result");
396 if (viewParse->hasModifyingCTE)
398 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
399 errmsg(
"views must not contain data-modifying statements in WITH")));
418 check_option =
false;
420 foreach(cell,
stmt->options)
424 if (strcmp(defel->
defname,
"check_option") == 0)
434 const char *view_updatable_error =
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))));
461 alist_item =
lnext(
stmt->aliases, alist_item);
462 if (alist_item == NULL)
466 if (alist_item != NULL)
468 (
errcode(ERRCODE_SYNTAX_ERROR),
469 errmsg(
"CREATE VIEW specifies more column "
470 "names than columns")));
474 if (
stmt->view->relpersistence == RELPERSISTENCE_UNLOGGED)
476 (
errcode(ERRCODE_SYNTAX_ERROR),
477 errmsg(
"views cannot be unlogged because they do not have storage")));
491 (
errmsg(
"view \"%s\" will be a temporary view",
502 stmt->replace,
stmt->options, viewParse);
#define Assert(condition)
#define OidIsValid(objectId)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
List * lappend(List *list, void *datum)
#define AccessExclusiveLock
char * get_collation_name(Oid colloid)
bool type_is_collatable(Oid typid)
DefElem * makeDefElem(char *name, Node *arg, int location)
ColumnDef * makeColumnDef(const char *colname, Oid typeOid, int32 typmod, Oid collOid)
char * pstrdup(const char *in)
Oid RangeVarGetAndCheckCreationNamespace(RangeVar *relation, LOCKMODE lockmode, Oid *existing_relation_id)
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
Oid exprCollation(const Node *expr)
#define IsA(nodeptr, _type_)
#define ObjectAddressSet(addr, class_id, object_id)
bool isQueryUsingTempRelation(Query *query)
Query * parse_analyze_fixedparams(RawStmt *parseTree, const char *sourceText, const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv)
FormData_pg_attribute * Form_pg_attribute
static const struct exclude_list_item skip[]
void recordDependencyOnCurrentExtension(const ObjectAddress *object, bool isReplace)
#define lfirst_node(type, lc)
static int list_length(const List *l)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
#define RelationGetRelationName(relation)
ObjectAddress DefineQueryRewrite(const char *rulename, Oid event_relid, Node *event_qual, CmdType event_type, bool is_instead, bool replace, List *action)
const char * view_query_is_auto_updatable(Query *viewquery, bool check_cols)
#define ViewSelectRuleName
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
TupleDesc BuildDescForRelation(const List *columns)
void CheckTableNotInUse(Relation rel, const char *stmt)
ObjectAddress DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, ObjectAddress *typaddress, const char *queryString)
void AlterTableInternal(Oid relid, List *cmds, bool recurse)
#define TupleDescAttr(tupdesc, i)
String * makeString(char *str)
static ObjectAddress DefineVirtualRelation(RangeVar *relation, List *tlist, bool replace, List *options, Query *viewParse)
static void checkViewColumns(TupleDesc newdesc, TupleDesc olddesc)
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)
void CommandCounterIncrement(void)