PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
sharedfileset.h File Reference
#include "storage/dsm.h"
#include "storage/fd.h"
#include "storage/fileset.h"
#include "storage/spin.h"
Include dependency graph for sharedfileset.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SharedFileSet
 

Typedefs

typedef struct SharedFileSet SharedFileSet
 

Functions

void SharedFileSetInit (SharedFileSet *fileset, dsm_segment *seg)
 
void SharedFileSetAttach (SharedFileSet *fileset, dsm_segment *seg)
 
void SharedFileSetDeleteAll (SharedFileSet *fileset)
 

Typedef Documentation

◆ SharedFileSet

typedef struct SharedFileSet SharedFileSet

Function Documentation

◆ SharedFileSetAttach()

void SharedFileSetAttach ( SharedFileSet fileset,
dsm_segment seg 
)

Definition at line 56 of file sharedfileset.c.

57{
58 bool success;
59
60 SpinLockAcquire(&fileset->mutex);
61 if (fileset->refcnt == 0)
62 success = false;
63 else
64 {
65 ++fileset->refcnt;
66 success = true;
67 }
68 SpinLockRelease(&fileset->mutex);
69
70 if (!success)
72 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
73 errmsg("could not attach to a SharedFileSet that is already destroyed")));
74
75 /* Register our cleanup callback. */
77}
void on_dsm_detach(dsm_segment *seg, on_dsm_detach_callback function, Datum arg)
Definition: dsm.c:1132
int errcode(int sqlerrcode)
Definition: elog.c:853
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
static bool success
Definition: initdb.c:186
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:322
static void SharedFileSetOnDetach(dsm_segment *segment, Datum datum)
Definition: sharedfileset.c:96
#define SpinLockRelease(lock)
Definition: spin.h:61
#define SpinLockAcquire(lock)
Definition: spin.h:59

References ereport, errcode(), errmsg(), ERROR, SharedFileSet::mutex, on_dsm_detach(), PointerGetDatum(), SharedFileSet::refcnt, SharedFileSetOnDetach(), SpinLockAcquire, SpinLockRelease, and success.

Referenced by ExecHashJoinInitializeWorker(), and tuplesort_attach_shared().

◆ SharedFileSetDeleteAll()

void SharedFileSetDeleteAll ( SharedFileSet fileset)

Definition at line 83 of file sharedfileset.c.

84{
85 FileSetDeleteAll(&fileset->fs);
86}
void FileSetDeleteAll(FileSet *fileset)
Definition: fileset.c:150

References FileSetDeleteAll(), and SharedFileSet::fs.

Referenced by ExecHashJoinReInitializeDSM().

◆ SharedFileSetInit()

void SharedFileSetInit ( SharedFileSet fileset,
dsm_segment seg 
)

Definition at line 38 of file sharedfileset.c.

39{
40 /* Initialize the shared fileset specific members. */
41 SpinLockInit(&fileset->mutex);
42 fileset->refcnt = 1;
43
44 /* Initialize the fileset. */
45 FileSetInit(&fileset->fs);
46
47 /* Register our cleanup callback. */
48 if (seg)
50}
void FileSetInit(FileSet *fileset)
Definition: fileset.c:52
#define SpinLockInit(lock)
Definition: spin.h:57

References FileSetInit(), SharedFileSet::fs, SharedFileSet::mutex, on_dsm_detach(), PointerGetDatum(), SharedFileSet::refcnt, SharedFileSetOnDetach(), and SpinLockInit.

Referenced by ExecHashJoinInitializeDSM(), and tuplesort_initialize_shared().