Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit301fcf3

Browse files
committed
Have CREATE TABLE AS and REFRESH return an OID
Other DDL commands are already returning the OID, which is required forfuture additional event trigger work. This is merely making thesecommands in line with the rest of utility command support.
1 parentd6d6020 commit301fcf3

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

‎src/backend/commands/createas.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ typedef struct
5555
BulkInsertStatebistate;/* bulk insert state */
5656
}DR_intorel;
5757

58+
/* the OID of the created table, for ExecCreateTableAs consumption */
59+
staticOidCreateAsRelid=InvalidOid;
60+
5861
staticvoidintorel_startup(DestReceiver*self,intoperation,TupleDesctypeinfo);
5962
staticvoidintorel_receive(TupleTableSlot*slot,DestReceiver*self);
6063
staticvoidintorel_shutdown(DestReceiver*self);
@@ -64,7 +67,7 @@ static void intorel_destroy(DestReceiver *self);
6467
/*
6568
* ExecCreateTableAs -- execute a CREATE TABLE AS command
6669
*/
67-
void
70+
Oid
6871
ExecCreateTableAs(CreateTableAsStmt*stmt,constchar*queryString,
6972
ParamListInfoparams,char*completionTag)
7073
{
@@ -75,6 +78,7 @@ ExecCreateTableAs(CreateTableAsStmt *stmt, const char *queryString,
7578
Oidsave_userid=InvalidOid;
7679
intsave_sec_context=0;
7780
intsave_nestlevel=0;
81+
OidrelOid;
7882
List*rewritten;
7983
PlannedStmt*plan;
8084
QueryDesc*queryDesc;
@@ -98,7 +102,9 @@ ExecCreateTableAs(CreateTableAsStmt *stmt, const char *queryString,
98102
Assert(!is_matview);/* excluded by syntax */
99103
ExecuteQuery(estmt,into,queryString,params,dest,completionTag);
100104

101-
return;
105+
relOid=CreateAsRelid;
106+
CreateAsRelid=InvalidOid;
107+
returnrelOid;
102108
}
103109
Assert(query->commandType==CMD_SELECT);
104110

@@ -190,6 +196,11 @@ ExecCreateTableAs(CreateTableAsStmt *stmt, const char *queryString,
190196
/* Restore userid and security context */
191197
SetUserIdAndSecContext(save_userid,save_sec_context);
192198
}
199+
200+
relOid=CreateAsRelid;
201+
CreateAsRelid=InvalidOid;
202+
203+
returnrelOid;
193204
}
194205

195206
/*
@@ -421,6 +432,9 @@ intorel_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
421432
myState->rel=intoRelationDesc;
422433
myState->output_cid=GetCurrentCommandId(true);
423434

435+
/* and remember the new relation's OID for ExecCreateTableAs */
436+
CreateAsRelid=RelationGetRelid(myState->rel);
437+
424438
/*
425439
* We can skip WAL-logging the insertions, unless PITR or streaming
426440
* replication is in use. We can skip the FSM in any case.

‎src/backend/commands/matview.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ SetMatViewPopulatedState(Relation relation, bool newstate)
132132
* The matview's "populated" state is changed based on whether the contents
133133
* reflect the result set of the materialized view's query.
134134
*/
135-
void
135+
Oid
136136
ExecRefreshMatView(RefreshMatViewStmt*stmt,constchar*queryString,
137137
ParamListInfoparams,char*completionTag)
138138
{
@@ -281,6 +281,8 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
281281
}
282282
else
283283
refresh_by_heap_swap(matviewOid,OIDNewHeap);
284+
285+
returnmatviewOid;
284286
}
285287

286288
/*

‎src/include/commands/createas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include"tcop/dest.h"
2020

2121

22-
externvoidExecCreateTableAs(CreateTableAsStmt*stmt,constchar*queryString,
22+
externOidExecCreateTableAs(CreateTableAsStmt*stmt,constchar*queryString,
2323
ParamListInfoparams,char*completionTag);
2424

2525
externintGetIntoRelEFlags(IntoClause*intoClause);

‎src/include/commands/matview.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
externvoidSetMatViewPopulatedState(Relationrelation,boolnewstate);
2424

25-
externvoidExecRefreshMatView(RefreshMatViewStmt*stmt,constchar*queryString,
25+
externOidExecRefreshMatView(RefreshMatViewStmt*stmt,constchar*queryString,
2626
ParamListInfoparams,char*completionTag);
2727

2828
externDestReceiver*CreateTransientRelDestReceiver(Oidoid);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp