diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-07-03 17:01:34 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-07-03 17:01:34 -0400 |
commit | f7b5988cc0d879d6cc9d481ba898e55747a53bbe (patch) | |
tree | 0d6bd8f63441150f6aa9f33feea49eb7b019ee2a /src/backend/storage/file/sharedfileset.c | |
parent | 1f902d499eda862a98e881a2227b8d2cf3565374 (diff) | |
download | postgresql-f7b5988cc0d879d6cc9d481ba898e55747a53bbe.tar.gz postgresql-f7b5988cc0d879d6cc9d481ba898e55747a53bbe.zip |
Fix temporary tablespaces for shared filesets some more.
Commit ecd9e9f0b fixed the problem in the wrong place, causing unwanted
side-effects on the behavior of GetNextTempTableSpace(). Instead,
let's make SharedFileSetInit() responsible for subbing in the value
of MyDatabaseTableSpace when the default tablespace is called for.
The convention about what is in the tempTableSpaces[] array is
evidently insufficiently documented, so try to improve that.
It also looks like SharedFileSetInit() is doing the wrong thing in the
case where temp_tablespaces is empty. It was hard-wiring use of the
pg_default tablespace, but it seems like using MyDatabaseTableSpace
is more consistent with what happens for other temp files.
Back-patch the reversion of PrepareTempTablespaces()'s behavior to
9.5, as ecd9e9f0b was. The changes in SharedFileSetInit() go back
to v11 where that was introduced. (Note there is net zero code change
before v11 from these two patch sets, so nothing to release-note.)
Magnus Hagander and Tom Lane
Discussion: https://postgr.es/m/CABUevExg5YEsOvqMxrjoNvb3ApVyH+9jggWGKwTDFyFCVWczGQ@mail.gmail.com
Diffstat (limited to 'src/backend/storage/file/sharedfileset.c')
-rw-r--r-- | src/backend/storage/file/sharedfileset.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/backend/storage/file/sharedfileset.c b/src/backend/storage/file/sharedfileset.c index f7206c9175f..16b7594756c 100644 --- a/src/backend/storage/file/sharedfileset.c +++ b/src/backend/storage/file/sharedfileset.c @@ -63,9 +63,25 @@ SharedFileSetInit(SharedFileSet *fileset, dsm_segment *seg) lengthof(fileset->tablespaces)); if (fileset->ntablespaces == 0) { - fileset->tablespaces[0] = DEFAULTTABLESPACE_OID; + /* If the GUC is empty, use current database's default tablespace */ + fileset->tablespaces[0] = MyDatabaseTableSpace; fileset->ntablespaces = 1; } + else + { + int i; + + /* + * An entry of InvalidOid means use the default tablespace for the + * current database. Replace that now, to be sure that all users of + * the SharedFileSet agree on what to do. + */ + for (i = 0; i < fileset->ntablespaces; i++) + { + if (fileset->tablespaces[i] == InvalidOid) + fileset->tablespaces[i] = MyDatabaseTableSpace; + } + } /* Register our cleanup callback. */ on_dsm_detach(seg, SharedFileSetOnDetach, PointerGetDatum(fileset)); |