* Create a BufFile for a new temporary file (which will expand to become * multiple temporary files if more than MAX_PHYSICAL_FILESIZE bytes are * written to it). * * If interXact is true, the temp file will not be automatically deleted * at end of transaction. * * Note: if interXact is true, the caller had better be calling us in a * memory context, and with a resource owner, that will su
| 264 | * transaction boundaries. |
| 265 | */ |
| 266 | BufFile * |
| 267 | BufFileCreateTempInSet(char *operation_name, bool interXact, workfile_set *work_set) |
| 268 | { |
| 269 | BufFile *file; |
| 270 | File pfile; |
| 271 | |
| 272 | /* |
| 273 | * Ensure that temp tablespaces are set up for OpenTemporaryFile to use. |
| 274 | * Possibly the caller will have done this already, but it seems useful to |
| 275 | * double-check here. Failure to do this at all would result in the temp |
| 276 | * files always getting placed in the default tablespace, which is a |
| 277 | * pretty hard-to-detect bug. Callers may prefer to do it earlier if they |
| 278 | * want to be sure that any required catalog access is done in some other |
| 279 | * resource context. |
| 280 | */ |
| 281 | PrepareTempTablespaces(); |
| 282 | |
| 283 | pfile = OpenTemporaryFile(interXact, operation_name); |
| 284 | Assert(pfile >= 0); |
| 285 | |
| 286 | file = makeBufFile(pfile, operation_name); |
| 287 | file->isInterXact = interXact; |
| 288 | |
| 289 | /* |
| 290 | * Register the file as a "work file", so that the Cloudberry workfile |
| 291 | * limits apply to it. |
| 292 | */ |
| 293 | file->work_set = work_set; |
| 294 | FileSetIsWorkfile(pfile); |
| 295 | RegisterFileWithSet(pfile, work_set); |
| 296 | |
| 297 | SIMPLE_FAULT_INJECTOR("workfile_creation_failure"); |
| 298 | |
| 299 | return file; |
| 300 | } |
| 301 | |
| 302 | BufFile * |
| 303 | BufFileCreateTemp(char *operation_name, bool interXact) |