Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 16f42be

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 04e9dc6 commit 16f42be

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
@@ -43,6 +43,7 @@
4343
#include "access/xact.h"
4444
#include "catalog/heap.h"
4545
#include "catalog/namespace.h"
46+
#include "catalog/pg_tablespace.h"
4647
#include "catalog/toasting.h"
4748
#include "commands/tablespace.h"
4849
#include "commands/trigger.h"
@@ -2452,6 +2453,12 @@ OpenIntoRel(QueryDesc *queryDesc)
24522453
get_tablespace_name(tablespaceId));
24532454
}
24542455

2456+
/* In all cases disallow placing user relations in pg_global */
2457+
if (tablespaceId == GLOBALTABLESPACE_OID)
2458+
ereport(ERROR,
2459+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2460+
errmsg("only shared relations can be placed in pg_global tablespace")));
2461+
24552462
/* Parse and validate any reloptions */
24562463
reloptions = transformRelOptions((Datum) 0,
24572464
into->options,

0 commit comments

Comments
 (0)