PostgreSQL Source Code  git master
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 62 of file sharedfileset.c.

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().

63 {
64  bool success;
65 
66  SpinLockAcquire(&fileset->mutex);
67  if (fileset->refcnt == 0)
68  success = false;
69  else
70  {
71  ++fileset->refcnt;
72  success = true;
73  }
74  SpinLockRelease(&fileset->mutex);
75 
76  if (!success)
77  ereport(ERROR,
78  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
79  errmsg("could not attach to a SharedFileSet that is already destroyed")));
80 
81  /* Register our cleanup callback. */
83 }
#define PointerGetDatum(X)
Definition: postgres.h:600
int errcode(int sqlerrcode)
Definition: elog.c:698
void on_dsm_detach(dsm_segment *seg, on_dsm_detach_callback function, Datum arg)
Definition: dsm.c:1096
#define SpinLockAcquire(lock)
Definition: spin.h:62
#define ERROR
Definition: elog.h:46
#define SpinLockRelease(lock)
Definition: spin.h:64
#define ereport(elevel,...)
Definition: elog.h:157
int errmsg(const char *fmt,...)
Definition: elog.c:909
static bool success
Definition: initdb.c:165
static void SharedFileSetOnDetach(dsm_segment *segment, Datum datum)

◆ SharedFileSetDeleteAll()

void SharedFileSetDeleteAll ( SharedFileSet fileset)

Definition at line 89 of file sharedfileset.c.

References FileSetDeleteAll(), and SharedFileSet::fs.

Referenced by ExecHashJoinReInitializeDSM().

90 {
91  FileSetDeleteAll(&fileset->fs);
92 }
void FileSetDeleteAll(FileSet *fileset)
Definition: fileset.c:152

◆ SharedFileSetInit()

void SharedFileSetInit ( SharedFileSet fileset,
dsm_segment seg 
)

Definition at line 44 of file sharedfileset.c.

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

Referenced by ExecHashJoinInitializeDSM(), and tuplesort_initialize_shared().

45 {
46  /* Initialize the shared fileset specific members. */
47  SpinLockInit(&fileset->mutex);
48  fileset->refcnt = 1;
49 
50  /* Initialize the fileset. */
51  FileSetInit(&fileset->fs);
52 
53  /* Register our cleanup callback. */
54  if (seg)
56 }
#define PointerGetDatum(X)
Definition: postgres.h:600
#define SpinLockInit(lock)
Definition: spin.h:60
void FileSetInit(FileSet *fileset)
Definition: fileset.c:54
void on_dsm_detach(dsm_segment *seg, on_dsm_detach_callback function, Datum arg)
Definition: dsm.c:1096
static void SharedFileSetOnDetach(dsm_segment *segment, Datum datum)