]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix SELECT INTO and CREATE TABLE AS to create tables in the default
authorBruce Momjian <bruce@momjian.us>
Wed, 26 Apr 2006 23:01:13 +0000 (23:01 +0000)
committerBruce Momjian <bruce@momjian.us>
Wed, 26 Apr 2006 23:01:13 +0000 (23:01 +0000)
tablespace, not the base directory.

Kris Jurka

src/backend/executor/execMain.c

index 3a86d31162969d83c2809beaec027753e91ab9f8..8f753ffe0fbaa21fdc8e3c27b018e97e88e17243 100644 (file)
@@ -26,7 +26,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.241.4.2 2006/01/12 21:49:17 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.241.4.3 2006/04/26 23:01:13 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -36,6 +36,7 @@
 #include "catalog/heap.h"
 #include "catalog/namespace.h"
 #include "commands/tablecmds.h"
+#include "commands/tablespace.h"
 #include "commands/trigger.h"
 #include "executor/execdebug.h"
 #include "executor/execdefs.h"
@@ -731,6 +732,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
        {
                char       *intoName;
                Oid                     namespaceId;
+               Oid                     tablespaceId;
                AclResult       aclresult;
                Oid                     intoRelationId;
                TupleDesc       tupdesc;
@@ -747,6 +749,16 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
                        aclcheck_error(aclresult, ACL_KIND_NAMESPACE,
                                                   get_namespace_name(namespaceId));
 
+               tablespaceId = GetDefaultTablespace();
+               if (OidIsValid(tablespaceId)) {
+                       aclresult = pg_tablespace_aclcheck(tablespaceId, GetUserId(),
+                                                                                          ACL_CREATE);
+
+                       if (aclresult != ACLCHECK_OK)
+                               aclcheck_error(aclresult, ACL_KIND_TABLESPACE,
+                                                          get_tablespace_name(tablespaceId));
+               }
+
                /*
                 * have to copy tupType to get rid of constraints
                 */
@@ -754,7 +766,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
 
                intoRelationId = heap_create_with_catalog(intoName,
                                                                                                  namespaceId,
-                                                                                                 InvalidOid,
+                                                                                                 tablespaceId,
                                                                                                  tupdesc,
                                                                                                  RELKIND_RELATION,
                                                                                                  false,