postgres.git / summary / log / commit / refs
commit d4a68363aff508a1179cd5e3f45f61a08104a1e1
Author: Robert Haas <rhaas@postgresql.org>
Date: Wed Mar 21 16:38:34 2012 +0000
First released in: 8.3.19, 8.4.12, 9.0.8, 9.1.4
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
src/backend/executor/execMain.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index bcab54397f2..657a778290a 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -38,6 +38,7 @@
#include "access/xact.h"
#include "catalog/heap.h"
#include "catalog/namespace.h"
+#include "catalog/pg_tablespace.h"
#include "catalog/toasting.h"
#include "commands/tablespace.h"
#include "commands/trigger.h"
@@ -2249,6 +2250,12 @@ OpenIntoRel(QueryDesc *queryDesc)
get_tablespace_name(tablespaceId));
}
+ /* In all cases disallow placing user relations in pg_global */
+ if (tablespaceId == GLOBALTABLESPACE_OID)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("only shared relations can be placed in pg_global tablespace")));
+
/* Parse and validate any reloptions */
reloptions = transformRelOptions((Datum) 0,
into->options,
[parent: 4ba41df89605]