Skip to content

Commit d4a6836

Browse files
committed
Don't allow CREATE TABLE AS to put relations in pg_global.
This was never intended to be allowed, and is blocked for an ordinary CREATE TABLE, but CREATE TABLE AS slipped through the cracks. This commit won't do anything to fix existing cases where this has loophole has been exploited, but it still seems prudent to lock it down going forward. Back-branch commit only, as this problem has been refactored away on the master branch. Andres Freund
1 parent 4ba41df commit d4a6836

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/backend/executor/execMain.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "access/xact.h"
3939
#include "catalog/heap.h"
4040
#include "catalog/namespace.h"
41+
#include "catalog/pg_tablespace.h"
4142
#include "catalog/toasting.h"
4243
#include "commands/tablespace.h"
4344
#include "commands/trigger.h"
@@ -2249,6 +2250,12 @@ OpenIntoRel(QueryDesc *queryDesc)
22492250
get_tablespace_name(tablespaceId));
22502251
}
22512252

2253+
/* In all cases disallow placing user relations in pg_global */
2254+
if (tablespaceId == GLOBALTABLESPACE_OID)
2255+
ereport(ERROR,
2256+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2257+
errmsg("only shared relations can be placed in pg_global tablespace")));
2258+
22522259
/* Parse and validate any reloptions */
22532260
reloptions = transformRelOptions((Datum) 0,
22542261
into->options,

0 commit comments

Comments
 (0)