mirror of
https://github.com/postgres/postgres.git
synced 2025-05-08 07:21:33 +03:00
Fix unintended assignment of sequences to the containing schema's
default tablespace --- they should always go in the database's default tablespace. Adjust heap_create() API so that it is passed the relkind to make this easier; should simplify any further tweaking of the same sort.
This commit is contained in:
parent
a421b4e850
commit
617d6ea7df
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.72 2004/08/29 04:12:24 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.73 2004/08/31 17:10:36 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -184,8 +184,8 @@ Boot_CreateStmt:
|
|||||||
PG_CATALOG_NAMESPACE,
|
PG_CATALOG_NAMESPACE,
|
||||||
$3 ? GLOBALTABLESPACE_OID : 0,
|
$3 ? GLOBALTABLESPACE_OID : 0,
|
||||||
tupdesc,
|
tupdesc,
|
||||||
|
RELKIND_RELATION,
|
||||||
$3,
|
$3,
|
||||||
true,
|
|
||||||
true);
|
true);
|
||||||
elog(DEBUG4, "bootstrap relation created");
|
elog(DEBUG4, "bootstrap relation created");
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.275 2004/08/29 05:06:41 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.276 2004/08/31 17:10:36 tgl Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
@ -201,12 +201,13 @@ heap_create(const char *relname,
|
|||||||
Oid relnamespace,
|
Oid relnamespace,
|
||||||
Oid reltablespace,
|
Oid reltablespace,
|
||||||
TupleDesc tupDesc,
|
TupleDesc tupDesc,
|
||||||
|
char relkind,
|
||||||
bool shared_relation,
|
bool shared_relation,
|
||||||
bool create_storage,
|
|
||||||
bool allow_system_table_mods)
|
bool allow_system_table_mods)
|
||||||
{
|
{
|
||||||
Oid relid;
|
Oid relid;
|
||||||
bool nailme = false;
|
bool nailme = false;
|
||||||
|
bool create_storage;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -263,6 +264,34 @@ heap_create(const char *relname,
|
|||||||
else
|
else
|
||||||
relid = newoid();
|
relid = newoid();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Decide if we need storage or not, and handle a couple other
|
||||||
|
* special cases for particular relkinds.
|
||||||
|
*/
|
||||||
|
switch (relkind)
|
||||||
|
{
|
||||||
|
case RELKIND_VIEW:
|
||||||
|
case RELKIND_COMPOSITE_TYPE:
|
||||||
|
create_storage = false;
|
||||||
|
/*
|
||||||
|
* Force reltablespace to zero if the relation has no physical
|
||||||
|
* storage. This is mainly just for cleanliness' sake.
|
||||||
|
*/
|
||||||
|
reltablespace = InvalidOid;
|
||||||
|
break;
|
||||||
|
case RELKIND_SEQUENCE:
|
||||||
|
create_storage = true;
|
||||||
|
/*
|
||||||
|
* Force reltablespace to zero for sequences, since we don't
|
||||||
|
* support moving them around into different tablespaces.
|
||||||
|
*/
|
||||||
|
reltablespace = InvalidOid;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
create_storage = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Never allow a pg_class entry to explicitly specify the database's
|
* Never allow a pg_class entry to explicitly specify the database's
|
||||||
* default tablespace in reltablespace; force it to zero instead. This
|
* default tablespace in reltablespace; force it to zero instead. This
|
||||||
@ -275,13 +304,6 @@ heap_create(const char *relname,
|
|||||||
if (reltablespace == MyDatabaseTableSpace)
|
if (reltablespace == MyDatabaseTableSpace)
|
||||||
reltablespace = InvalidOid;
|
reltablespace = InvalidOid;
|
||||||
|
|
||||||
/*
|
|
||||||
* Also, force reltablespace to zero if the relation has no physical
|
|
||||||
* storage. This is mainly just for cleanliness' sake.
|
|
||||||
*/
|
|
||||||
if (!create_storage)
|
|
||||||
reltablespace = InvalidOid;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* build the relcache entry.
|
* build the relcache entry.
|
||||||
*/
|
*/
|
||||||
@ -728,16 +750,13 @@ heap_create_with_catalog(const char *relname,
|
|||||||
* Create the relcache entry (mostly dummy at this point) and the
|
* Create the relcache entry (mostly dummy at this point) and the
|
||||||
* physical disk file. (If we fail further down, it's the smgr's
|
* physical disk file. (If we fail further down, it's the smgr's
|
||||||
* responsibility to remove the disk file again.)
|
* responsibility to remove the disk file again.)
|
||||||
*
|
|
||||||
* NB: create a physical file only if it's not a view or type relation.
|
|
||||||
*/
|
*/
|
||||||
new_rel_desc = heap_create(relname,
|
new_rel_desc = heap_create(relname,
|
||||||
relnamespace,
|
relnamespace,
|
||||||
reltablespace,
|
reltablespace,
|
||||||
tupdesc,
|
tupdesc,
|
||||||
|
relkind,
|
||||||
shared_relation,
|
shared_relation,
|
||||||
(relkind != RELKIND_VIEW &&
|
|
||||||
relkind != RELKIND_COMPOSITE_TYPE),
|
|
||||||
allow_system_table_mods);
|
allow_system_table_mods);
|
||||||
|
|
||||||
/* Fetch the relation OID assigned by heap_create */
|
/* Fetch the relation OID assigned by heap_create */
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.238 2004/08/29 05:06:41 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.239 2004/08/31 17:10:36 tgl Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
@ -543,8 +543,8 @@ index_create(Oid heapRelationId,
|
|||||||
namespaceId,
|
namespaceId,
|
||||||
tableSpaceId,
|
tableSpaceId,
|
||||||
indexTupDesc,
|
indexTupDesc,
|
||||||
|
RELKIND_INDEX,
|
||||||
shared_relation,
|
shared_relation,
|
||||||
true,
|
|
||||||
allow_system_table_mods);
|
allow_system_table_mods);
|
||||||
|
|
||||||
/* Fetch the relation OID assigned by heap_create */
|
/* Fetch the relation OID assigned by heap_create */
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.70 2004/08/29 04:13:04 momjian Exp $
|
* $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.71 2004/08/31 17:10:36 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -39,8 +39,8 @@ extern Relation heap_create(const char *relname,
|
|||||||
Oid relnamespace,
|
Oid relnamespace,
|
||||||
Oid reltablespace,
|
Oid reltablespace,
|
||||||
TupleDesc tupDesc,
|
TupleDesc tupDesc,
|
||||||
|
char relkind,
|
||||||
bool shared_relation,
|
bool shared_relation,
|
||||||
bool create_storage,
|
|
||||||
bool allow_system_table_mods);
|
bool allow_system_table_mods);
|
||||||
|
|
||||||
extern Oid heap_create_with_catalog(const char *relname,
|
extern Oid heap_create_with_catalog(const char *relname,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user