Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita7d3f3b

Browse files
committed
Fix temporary tablespaces for shared filesets some more.
Commitecd9e9f fixed the problem in the wrong place, causing unwantedside-effects on the behavior of GetNextTempTableSpace(). Instead,let's make SharedFileSetInit() responsible for subbing in the valueof MyDatabaseTableSpace when the default tablespace is called for.The convention about what is in the tempTableSpaces[] array isevidently insufficiently documented, so try to improve that.It also looks like SharedFileSetInit() is doing the wrong thing in thecase where temp_tablespaces is empty. It was hard-wiring use of thepg_default tablespace, but it seems like using MyDatabaseTableSpaceis more consistent with what happens for other temp files.Back-patch the reversion of PrepareTempTablespaces()'s behavior to9.5, asecd9e9f was. The changes in SharedFileSetInit() go backto v11 where that was introduced. (Note there is net zero code changebefore v11 from these two patch sets, so nothing to release-note.)Magnus Hagander and Tom LaneDiscussion:https://postgr.es/m/CABUevExg5YEsOvqMxrjoNvb3ApVyH+9jggWGKwTDFyFCVWczGQ@mail.gmail.com
1 parent4a1d215 commita7d3f3b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

‎src/backend/commands/tablespace.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,7 @@ GetDefaultTablespace(char relpersistence)
11491149

11501150
typedefstruct
11511151
{
1152+
/* Array of OIDs to be passed to SetTempTablespaces() */
11521153
intnumSpcs;
11531154
OidtblSpcs[FLEXIBLE_ARRAY_MEMBER];
11541155
}temp_tablespaces_extra;
@@ -1198,6 +1199,7 @@ check_temp_tablespaces(char **newval, void **extra, GucSource source)
11981199
/* Allow an empty string (signifying database default) */
11991200
if (curname[0]=='\0')
12001201
{
1202+
/* InvalidOid signifies database's default tablespace */
12011203
tblSpcs[numSpcs++]=InvalidOid;
12021204
continue;
12031205
}
@@ -1224,6 +1226,7 @@ check_temp_tablespaces(char **newval, void **extra, GucSource source)
12241226
*/
12251227
if (curoid==MyDatabaseTableSpace)
12261228
{
1229+
/* InvalidOid signifies database's default tablespace */
12271230
tblSpcs[numSpcs++]=InvalidOid;
12281231
continue;
12291232
}
@@ -1334,6 +1337,7 @@ PrepareTempTablespaces(void)
13341337
/* Allow an empty string (signifying database default) */
13351338
if (curname[0]=='\0')
13361339
{
1340+
/* InvalidOid signifies database's default tablespace */
13371341
tblSpcs[numSpcs++]=InvalidOid;
13381342
continue;
13391343
}
@@ -1352,7 +1356,8 @@ PrepareTempTablespaces(void)
13521356
*/
13531357
if (curoid==MyDatabaseTableSpace)
13541358
{
1355-
tblSpcs[numSpcs++]=curoid;
1359+
/* InvalidOid signifies database's default tablespace */
1360+
tblSpcs[numSpcs++]=InvalidOid;
13561361
continue;
13571362
}
13581363

‎src/backend/storage/file/fd.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,10 @@ static AllocateDesc *allocatedDescs = NULL;
253253
staticlongtempFileCounter=0;
254254

255255
/*
256-
* Array of OIDs of temp tablespaces. When numTempTableSpaces is -1,
257-
* this has not been set in the current transaction.
256+
* Array of OIDs of temp tablespaces. (Some entries may be InvalidOid,
257+
* indicating that the current database's default tablespace should be used.)
258+
* When numTempTableSpaces is -1, this has not been set in the current
259+
* transaction.
258260
*/
259261
staticOid*tempTableSpaces=NULL;
260262
staticintnumTempTableSpaces=-1;
@@ -2576,6 +2578,9 @@ closeAllVfds(void)
25762578
* unless this function is called again before then. It is caller's
25772579
* responsibility that the passed-in array has adequate lifespan (typically
25782580
* it'd be allocated in TopTransactionContext).
2581+
*
2582+
* Some entries of the array may be InvalidOid, indicating that the current
2583+
* database's default tablespace should be used.
25792584
*/
25802585
void
25812586
SetTempTablespaces(Oid*tableSpaces,intnumSpaces)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp