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:58 +00:00
parent abee2cdb1e
commit 96cc1341dd

View 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,