Fix SELECT INTO and CREATE TABLE AS to create tables in the default

tablespace, not the base directory.

Kris Jurka
This commit is contained in:
Bruce Momjian 2006-04-26 23:01:13 +00:00
parent 46942e84d9
commit 382825da9d

View File

@ -26,7 +26,7 @@
* *
* *
* IDENTIFICATION * 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/heap.h"
#include "catalog/namespace.h" #include "catalog/namespace.h"
#include "commands/tablecmds.h" #include "commands/tablecmds.h"
#include "commands/tablespace.h"
#include "commands/trigger.h" #include "commands/trigger.h"
#include "executor/execdebug.h" #include "executor/execdebug.h"
#include "executor/execdefs.h" #include "executor/execdefs.h"
@ -731,6 +732,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
{ {
char *intoName; char *intoName;
Oid namespaceId; Oid namespaceId;
Oid tablespaceId;
AclResult aclresult; AclResult aclresult;
Oid intoRelationId; Oid intoRelationId;
TupleDesc tupdesc; TupleDesc tupdesc;
@ -747,6 +749,16 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
aclcheck_error(aclresult, ACL_KIND_NAMESPACE, aclcheck_error(aclresult, ACL_KIND_NAMESPACE,
get_namespace_name(namespaceId)); 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 * have to copy tupType to get rid of constraints
*/ */
@ -754,7 +766,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
intoRelationId = heap_create_with_catalog(intoName, intoRelationId = heap_create_with_catalog(intoName,
namespaceId, namespaceId,
InvalidOid, tablespaceId,
tupdesc, tupdesc,
RELKIND_RELATION, RELKIND_RELATION,
false, false,