95 is_matview = (into->viewQuery != NULL);
96 relkind = is_matview ? RELKIND_MATVIEW : RELKIND_RELATION;
147 return intoRelationAddr;
186 colname = tle->resname;
202 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
203 errmsg(
"no collation was derived for column \"%s\" with collatable type %s",
206 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
208 attrList =
lappend(attrList, col);
214 (
errcode(ERRCODE_SYNTAX_ERROR),
215 errmsg(
"too many column names were specified")));
232 bool is_matview = (into->viewQuery != NULL);
235 int save_sec_context = 0;
236 int save_nestlevel = 0;
307 elog(
ERROR,
"unexpected rewrite result for %s",
308 is_matview ?
"CREATE MATERIALIZED VIEW" :
309 "CREATE TABLE AS SELECT");
330 dest, params, queryEnv, 0);
407 (
errcode(ERRCODE_DUPLICATE_TABLE),
408 errmsg(
"relation \"%s\" already exists",
422 (
errcode(ERRCODE_DUPLICATE_TABLE),
423 errmsg(
"relation \"%s\" already exists, skipping",
449 self->into = intoClause;
473 is_matview = (into->viewQuery != NULL);
495 colname =
NameStr(attribute->attname);
499 attribute->atttypmod,
500 attribute->attcollation);
511 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
512 errmsg(
"no collation was derived for column \"%s\" with collatable type %s",
515 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
517 attrList =
lappend(attrList, col);
522 (
errcode(ERRCODE_SYNTAX_ERROR),
523 errmsg(
"too many column names were specified")));
545 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
546 errmsg(
"policies not yet implemented for this command")));
558 myState->
rel = intoRelationDesc;
559 myState->
reladdr = intoRelationAddr;
void ExecuteQuery(ParseState *pstate, ExecuteStmt *stmt, IntoClause *intoClause, ParamListInfo params, DestReceiver *dest, QueryCompletion *qc)
#define InvalidBlockNumber
#define OidIsValid(objectId)
static void SetQueryCompletion(QueryCompletion *qc, CommandTag commandTag, uint64 nprocessed)
static void intorel_shutdown(DestReceiver *self)
static ObjectAddress create_ctas_internal(List *attrList, IntoClause *into)
bool CreateTableAsRelExists(CreateTableAsStmt *ctas)
DestReceiver * CreateIntoRelDestReceiver(IntoClause *intoClause)
static ObjectAddress create_ctas_nodata(List *tlist, IntoClause *into)
int GetIntoRelEFlags(IntoClause *intoClause)
static bool intorel_receive(TupleTableSlot *slot, DestReceiver *self)
static void intorel_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
ObjectAddress ExecCreateTableAs(ParseState *pstate, CreateTableAsStmt *stmt, ParamListInfo params, QueryEnvironment *queryEnv, QueryCompletion *qc)
static void intorel_destroy(DestReceiver *self)
elog(ERROR, "%s: %s", p2, msg)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void ExecutorEnd(QueryDesc *queryDesc)
void ExecutorFinish(QueryDesc *queryDesc)
void ExecutorStart(QueryDesc *queryDesc, int eflags)
void ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count, bool execute_once)
#define EXEC_FLAG_WITH_NO_DATA
int NewGUCNestLevel(void)
void AtEOXact_GUC(bool isCommit, int nestLevel)
BulkInsertState GetBulkInsertState(void)
void FreeBulkInsertState(BulkInsertState bistate)
Assert(fmt[strlen(fmt) - 1] !='\n')
List * lappend(List *list, void *datum)
#define AccessExclusiveLock
bool type_is_collatable(Oid typid)
Oid get_relname_relid(const char *relname, Oid relnamespace)
ColumnDef * makeColumnDef(const char *colname, Oid typeOid, int32 typmod, Oid collOid)
void SetMatViewPopulatedState(Relation relation, bool newstate)
void pfree(void *pointer)
void * palloc0(Size size)
#define SECURITY_RESTRICTED_OPERATION
void GetUserIdAndSecContext(Oid *userid, int *sec_context)
void SetUserIdAndSecContext(Oid userid, int sec_context)
Oid RangeVarGetCreationNamespace(const RangeVar *newRelation)
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
Oid exprCollation(const Node *expr)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
const ObjectAddress InvalidObjectAddress
#define ObjectAddressSet(addr, class_id, object_id)
#define CURSOR_OPT_PARALLEL_OK
FormData_pg_attribute * Form_pg_attribute
void checkMembershipInCurrentExtension(const ObjectAddress *object)
static int list_length(const List *l)
#define linitial_node(type, l)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
PlannedStmt * pg_plan_query(Query *querytree, const char *query_string, int cursorOptions, ParamListInfo boundParams)
void FreeQueryDesc(QueryDesc *qdesc)
QueryDesc * CreateQueryDesc(PlannedStmt *plannedstmt, const char *sourceText, Snapshot snapshot, Snapshot crosscheck_snapshot, DestReceiver *dest, ParamListInfo params, QueryEnvironment *queryEnv, int instrument_options)
#define RelationGetTargetBlock(relation)
Datum transformRelOptions(Datum oldOptions, List *defList, const char *namspace, char *validnsps[], bool acceptOidsOff, bool isReset)
bytea * heap_reloptions(char relkind, Datum reloptions, bool validate)
#define HEAP_RELOPT_NAMESPACES
List * QueryRewrite(Query *parsetree)
int check_enable_rls(Oid relid, Oid checkAsUser, bool noError)
void UpdateActiveSnapshotCommandId(void)
void PopActiveSnapshot(void)
void PushCopiedSnapshot(Snapshot snapshot)
Snapshot GetActiveSnapshot(void)
const char * p_sourcetext
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
#define TABLE_INSERT_SKIP_FSM
static void table_finish_bulk_insert(Relation rel, int options)
static void table_tuple_insert(Relation rel, TupleTableSlot *slot, CommandId cid, int options, struct BulkInsertStateData *bistate)
ObjectAddress DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, ObjectAddress *typaddress, const char *queryString)
void NewRelationCreateToastTable(Oid relOid, Datum reloptions)
#define TupleDescAttr(tupdesc, i)
void StoreViewQuery(Oid viewOid, Query *viewParse, bool replace)
void CommandCounterIncrement(void)
CommandId GetCurrentCommandId(bool used)