MCPcopy Create free account
hub / github.com/apache/cloudberry / SetTempTablespaces

Function SetTempTablespaces

src/backend/storage/file/fd.c:2972–2991  ·  view source on GitHub ↗

* SetTempTablespaces * * Define a list (actually an array) of OIDs of tablespaces to use for * temporary files. This list will be used until end of transaction, * unless this function is called again before then. It is caller's * responsibility that the passed-in array has adequate lifespan (typically * it'd be allocated in TopTransactionContext). * * Some entries of the array may be Inv

Source from the content-addressed store, hash-verified

2970 * database's default tablespace should be used.
2971 */
2972void
2973SetTempTablespaces(Oid *tableSpaces, int numSpaces)
2974{
2975 Assert(numSpaces >= 0);
2976 tempTableSpaces = tableSpaces;
2977 numTempTableSpaces = numSpaces;
2978
2979 /*
2980 * Select a random starting point in the list. This is to minimize
2981 * conflicts between backends that are most likely sharing the same list
2982 * of temp tablespaces. Note that if we create multiple temp files in the
2983 * same transaction, we'll advance circularly through the list --- this
2984 * ensures that large temporary sort files are nicely spread across all
2985 * available tablespaces.
2986 */
2987 if (numSpaces > 1)
2988 nextTempTableSpace = random() % numSpaces;
2989 else
2990 nextTempTableSpace = 0;
2991}
2992
2993/*
2994 * TempTablespacesAreSet

Callers 2

assign_temp_tablespacesFunction · 0.85
PrepareTempTablespacesFunction · 0.85

Calls 1

randomFunction · 0.85

Tested by

no test coverage detected