BulkInsertState bistate; /* bulk insert state */
} DR_intorel;
+/* the OID of the created table, for ExecCreateTableAs consumption */
+static Oid CreateAsRelid = InvalidOid;
+
static void intorel_startup(DestReceiver *self, int operation, TupleDesc typeinfo);
static void intorel_receive(TupleTableSlot *slot, DestReceiver *self);
static void intorel_shutdown(DestReceiver *self);
/*
* ExecCreateTableAs -- execute a CREATE TABLE AS command
*/
-void
+Oid
ExecCreateTableAs(CreateTableAsStmt *stmt, const char *queryString,
ParamListInfo params, char *completionTag)
{
Oid save_userid = InvalidOid;
int save_sec_context = 0;
int save_nestlevel = 0;
+ Oid relOid;
List *rewritten;
PlannedStmt *plan;
QueryDesc *queryDesc;
Assert(!is_matview); /* excluded by syntax */
ExecuteQuery(estmt, into, queryString, params, dest, completionTag);
- return;
+ relOid = CreateAsRelid;
+ CreateAsRelid = InvalidOid;
+ return relOid;
}
Assert(query->commandType == CMD_SELECT);
/* Restore userid and security context */
SetUserIdAndSecContext(save_userid, save_sec_context);
}
+
+ relOid = CreateAsRelid;
+ CreateAsRelid = InvalidOid;
+
+ return relOid;
}
/*
myState->rel = intoRelationDesc;
myState->output_cid = GetCurrentCommandId(true);
+ /* and remember the new relation's OID for ExecCreateTableAs */
+ CreateAsRelid = RelationGetRelid(myState->rel);
+
/*
* We can skip WAL-logging the insertions, unless PITR or streaming
* replication is in use. We can skip the FSM in any case.
* The matview's "populated" state is changed based on whether the contents
* reflect the result set of the materialized view's query.
*/
-void
+Oid
ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
ParamListInfo params, char *completionTag)
{
}
else
refresh_by_heap_swap(matviewOid, OIDNewHeap);
+
+ return matviewOid;
}
/*
#include "tcop/dest.h"
-extern void ExecCreateTableAs(CreateTableAsStmt *stmt, const char *queryString,
+extern Oid ExecCreateTableAs(CreateTableAsStmt *stmt, const char *queryString,
ParamListInfo params, char *completionTag);
extern int GetIntoRelEFlags(IntoClause *intoClause);
extern void SetMatViewPopulatedState(Relation relation, bool newstate);
-extern void ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
+extern Oid ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
ParamListInfo params, char *completionTag);
extern DestReceiver *CreateTransientRelDestReceiver(Oid oid);