90 is_matview = (into->viewQuery != NULL);
91 relkind = is_matview ? RELKIND_MATVIEW : RELKIND_RELATION;
142 return intoRelationAddr;
181 colname = tle->resname;
197 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
198 errmsg(
"no collation was derived for column \"%s\" with collatable type %s",
201 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
203 attrList =
lappend(attrList, col);
209 (
errcode(ERRCODE_SYNTAX_ERROR),
210 errmsg(
"too many column names were specified")));
228 bool is_matview = (into->viewQuery != NULL);
229 bool do_refresh =
false;
247 (*post_parse_analyze_hook) (pstate, query, jstate);
316 elog(
ERROR,
"unexpected rewrite result for CREATE TABLE AS SELECT");
337 dest, params, queryEnv, 0);
405 (
errcode(ERRCODE_DUPLICATE_TABLE),
406 errmsg(
"relation \"%s\" already exists",
420 (
errcode(ERRCODE_DUPLICATE_TABLE),
421 errmsg(
"relation \"%s\" already exists, skipping",
447 self->into = intoClause;
471 is_matview = (into->viewQuery != NULL);
493 colname =
NameStr(attribute->attname);
497 attribute->atttypmod,
498 attribute->attcollation);
509 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
510 errmsg(
"no collation was derived for column \"%s\" with collatable type %s",
513 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
515 attrList =
lappend(attrList, col);
520 (
errcode(ERRCODE_SYNTAX_ERROR),
521 errmsg(
"too many column names were specified")));
543 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
544 errmsg(
"policies not yet implemented for this command")));
556 myState->
rel = intoRelationDesc;
557 myState->
reladdr = intoRelationAddr;
void ExecuteQuery(ParseState *pstate, ExecuteStmt *stmt, IntoClause *intoClause, ParamListInfo params, DestReceiver *dest, QueryCompletion *qc)
#define InvalidBlockNumber
#define Assert(condition)
#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)
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
BulkInsertState GetBulkInsertState(void)
void FreeBulkInsertState(BulkInsertState bistate)
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)
ObjectAddress RefreshMatViewByOid(Oid matviewOid, bool is_create, bool skipData, bool concurrent, const char *queryString, QueryCompletion *qc)
void pfree(void *pointer)
void * palloc0(Size size)
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
post_parse_analyze_hook_type post_parse_analyze_hook
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)
static bool IsQueryIdEnabled(void)
JumbleState * JumbleQuery(Query *query)
#define RelationGetTargetBlock(relation)
Datum transformRelOptions(Datum oldOptions, List *defList, const char *namspace, const char *const 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)