diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-07-11 19:52:52 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-07-11 19:52:52 +0000 |
| commit | 8801110b20c6bffe4724e7b27de1c5e519af1b04 (patch) | |
| tree | 387b7b294734422a531f1e759ee013d6996778c2 /src/backend/storage | |
| parent | 94d4d240bb5c75124a270d1b5fecab1822cd4728 (diff) | |
| download | postgresql-8801110b20c6bffe4724e7b27de1c5e519af1b04.tar.gz | |
Move TablespaceCreateDbspace() call into smgrcreate(), which is where it
probably should have been to begin with; this is to cover cases like
needing to recreate the per-db directory during WAL replay.
Also, fix heap_create to force pg_class.reltablespace to be zero instead
of the database's default tablespace; this makes the world safe for
CREATE DATABASE to handle all tables in the default tablespace alike,
as per previous discussion. And force pg_class.reltablespace to zero
when creating a relation without physical storage (eg, a view); this
avoids possibly having dangling references in this column after a
subsequent DROP TABLESPACE.
Diffstat (limited to 'src/backend/storage')
| -rw-r--r-- | src/backend/storage/smgr/smgr.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c index 5c53d48f83..5ad43955e4 100644 --- a/src/backend/storage/smgr/smgr.c +++ b/src/backend/storage/smgr/smgr.c @@ -11,12 +11,13 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.75 2004/07/01 00:51:07 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.76 2004/07/11 19:52:51 tgl Exp $ * *------------------------------------------------------------------------- */ #include "postgres.h" +#include "commands/tablespace.h" #include "storage/bufmgr.h" #include "storage/freespace.h" #include "storage/ipc.h" @@ -309,6 +310,19 @@ smgrcreate(SMgrRelation reln, bool isTemp, bool isRedo) PendingRelDelete *pending; MemoryContext old_cxt; + /* + * We may be using the target table space for the first time in this + * database, so create a per-database subdirectory if needed. + * + * XXX this is a fairly ugly violation of module layering, but this seems + * to be the best place to put the check. Maybe TablespaceCreateDbspace + * should be here and not in commands/tablespace.c? But that would imply + * importing a lot of stuff that smgr.c oughtn't know, either. + */ + TablespaceCreateDbspace(reln->smgr_rnode.spcNode, + reln->smgr_rnode.dbNode, + isRedo); + if (! (*(smgrsw[reln->smgr_which].smgr_create)) (reln, isRedo)) ereport(ERROR, (errcode_for_file_access(), |
