* 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
| 2970 | * database's default tablespace should be used. |
| 2971 | */ |
| 2972 | void |
| 2973 | SetTempTablespaces(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 |
no test coverage detected