]> granicus.if.org Git - postgresql/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:58 +0000 (23:01 +0000)
committerBruce Momjian <bruce@momjian.us>
Wed, 26 Apr 2006 23:01:58 +0000 (23:01 +0000)
tablespace, not the base directory.

Kris Jurka

src/backend/executor/execMain.c

index 36d031b10ab31e02f4bf406ea8f81279bd7b3347..2a5d39fcea63540126b4df813b486d6c20d6a467 100644 (file)
@@ -26,7 +26,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.256.2.5 2006/01/12 21:49:06 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.256.2.6 2006/04/26 23:01:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -37,6 +37,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"
@@ -737,6 +738,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
        {
                char       *intoName;
                Oid                     namespaceId;
+               Oid                     tablespaceId;
                AclResult       aclresult;
                Oid                     intoRelationId;
                TupleDesc       tupdesc;
@@ -753,6 +755,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
                 */
@@ -760,7 +772,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
 
                intoRelationId = heap_create_with_catalog(intoName,
                                                                                                  namespaceId,
-                                                                                                 InvalidOid,
+                                                                                                 tablespaceId,
                                                                                                  InvalidOid,
                                                                                                  GetUserId(),
                                                                                                  tupdesc,