PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
resowner_private.h File Reference
#include "storage/dsm.h"
#include "storage/fd.h"
#include "storage/lock.h"
#include "utils/catcache.h"
#include "utils/plancache.h"
#include "utils/resowner.h"
#include "utils/snapshot.h"
Include dependency graph for resowner_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void ResourceOwnerEnlargeBuffers (ResourceOwner owner)
 
void ResourceOwnerRememberBuffer (ResourceOwner owner, Buffer buffer)
 
void ResourceOwnerForgetBuffer (ResourceOwner owner, Buffer buffer)
 
void ResourceOwnerRememberLock (ResourceOwner owner, LOCALLOCK *locallock)
 
void ResourceOwnerForgetLock (ResourceOwner owner, LOCALLOCK *locallock)
 
void ResourceOwnerEnlargeCatCacheRefs (ResourceOwner owner)
 
void ResourceOwnerRememberCatCacheRef (ResourceOwner owner, HeapTuple tuple)
 
void ResourceOwnerForgetCatCacheRef (ResourceOwner owner, HeapTuple tuple)
 
void ResourceOwnerEnlargeCatCacheListRefs (ResourceOwner owner)
 
void ResourceOwnerRememberCatCacheListRef (ResourceOwner owner, CatCList *list)
 
void ResourceOwnerForgetCatCacheListRef (ResourceOwner owner, CatCList *list)
 
void ResourceOwnerEnlargeRelationRefs (ResourceOwner owner)
 
void ResourceOwnerRememberRelationRef (ResourceOwner owner, Relation rel)
 
void ResourceOwnerForgetRelationRef (ResourceOwner owner, Relation rel)
 
void ResourceOwnerEnlargePlanCacheRefs (ResourceOwner owner)
 
void ResourceOwnerRememberPlanCacheRef (ResourceOwner owner, CachedPlan *plan)
 
void ResourceOwnerForgetPlanCacheRef (ResourceOwner owner, CachedPlan *plan)
 
void ResourceOwnerEnlargeTupleDescs (ResourceOwner owner)
 
void ResourceOwnerRememberTupleDesc (ResourceOwner owner, TupleDesc tupdesc)
 
void ResourceOwnerForgetTupleDesc (ResourceOwner owner, TupleDesc tupdesc)
 
void ResourceOwnerEnlargeSnapshots (ResourceOwner owner)
 
void ResourceOwnerRememberSnapshot (ResourceOwner owner, Snapshot snapshot)
 
void ResourceOwnerForgetSnapshot (ResourceOwner owner, Snapshot snapshot)
 
void ResourceOwnerEnlargeFiles (ResourceOwner owner)
 
void ResourceOwnerRememberFile (ResourceOwner owner, File file)
 
void ResourceOwnerForgetFile (ResourceOwner owner, File file)
 
void ResourceOwnerEnlargeDSMs (ResourceOwner owner)
 
void ResourceOwnerRememberDSM (ResourceOwner owner, dsm_segment *)
 
void ResourceOwnerForgetDSM (ResourceOwner owner, dsm_segment *)
 

Function Documentation

void ResourceOwnerEnlargeBuffers ( ResourceOwner  owner)

Definition at line 839 of file resowner.c.

References ResourceOwnerData::bufferarr, NULL, and ResourceArrayEnlarge().

Referenced by BgBufferSync(), BufferSync(), FlushDatabaseBuffers(), FlushRelationBuffers(), IncrBufferRefCount(), and ReadBuffer_common().

840 {
841  if (owner == NULL)
842  return;
843  ResourceArrayEnlarge(&(owner->bufferarr));
844 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:202
ResourceArray bufferarr
Definition: resowner.c:118
#define NULL
Definition: c.h:229
void ResourceOwnerEnlargeCatCacheListRefs ( ResourceOwner  owner)

Definition at line 973 of file resowner.c.

References ResourceOwnerData::catlistrefarr, and ResourceArrayEnlarge().

Referenced by SearchCatCacheList().

974 {
976 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:202
ResourceArray catlistrefarr
Definition: resowner.c:120
void ResourceOwnerEnlargeCatCacheRefs ( ResourceOwner  owner)

Definition at line 938 of file resowner.c.

References ResourceOwnerData::catrefarr, and ResourceArrayEnlarge().

Referenced by SearchCatCache().

939 {
940  ResourceArrayEnlarge(&(owner->catrefarr));
941 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:202
ResourceArray catrefarr
Definition: resowner.c:119
void ResourceOwnerEnlargeDSMs ( ResourceOwner  owner)

Definition at line 1234 of file resowner.c.

References ResourceOwnerData::dsmarr, and ResourceArrayEnlarge().

Referenced by dsm_create_descriptor(), and dsm_unpin_mapping().

1235 {
1236  ResourceArrayEnlarge(&(owner->dsmarr));
1237 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:202
ResourceArray dsmarr
Definition: resowner.c:126
void ResourceOwnerEnlargeFiles ( ResourceOwner  owner)

Definition at line 1189 of file resowner.c.

References ResourceOwnerData::filearr, and ResourceArrayEnlarge().

Referenced by OpenTemporaryFile().

1190 {
1191  ResourceArrayEnlarge(&(owner->filearr));
1192 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:202
ResourceArray filearr
Definition: resowner.c:125
void ResourceOwnerEnlargePlanCacheRefs ( ResourceOwner  owner)

Definition at line 1053 of file resowner.c.

References ResourceOwnerData::planrefarr, and ResourceArrayEnlarge().

Referenced by GetCachedPlan().

1054 {
1055  ResourceArrayEnlarge(&(owner->planrefarr));
1056 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:202
ResourceArray planrefarr
Definition: resowner.c:122
void ResourceOwnerEnlargeRelationRefs ( ResourceOwner  owner)

Definition at line 1008 of file resowner.c.

References ResourceOwnerData::relrefarr, and ResourceArrayEnlarge().

Referenced by RelationIncrementReferenceCount().

1009 {
1010  ResourceArrayEnlarge(&(owner->relrefarr));
1011 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:202
ResourceArray relrefarr
Definition: resowner.c:121
void ResourceOwnerEnlargeSnapshots ( ResourceOwner  owner)

Definition at line 1143 of file resowner.c.

References ResourceArrayEnlarge(), and ResourceOwnerData::snapshotarr.

Referenced by RegisterSnapshotOnOwner().

1144 {
1145  ResourceArrayEnlarge(&(owner->snapshotarr));
1146 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:202
ResourceArray snapshotarr
Definition: resowner.c:124
void ResourceOwnerEnlargeTupleDescs ( ResourceOwner  owner)

Definition at line 1097 of file resowner.c.

References ResourceArrayEnlarge(), and ResourceOwnerData::tupdescarr.

Referenced by IncrTupleDescRefCount().

1098 {
1099  ResourceArrayEnlarge(&(owner->tupdescarr));
1100 }
static void ResourceArrayEnlarge(ResourceArray *resarr)
Definition: resowner.c:202
ResourceArray tupdescarr
Definition: resowner.c:123
void ResourceOwnerForgetBuffer ( ResourceOwner  owner,
Buffer  buffer 
)

Definition at line 869 of file resowner.c.

References ResourceOwnerData::bufferarr, BufferGetDatum, elog, ERROR, ResourceOwnerData::name, NULL, and ResourceArrayRemove().

Referenced by ReleaseAndReadBuffer(), ReleaseBuffer(), and UnpinBuffer().

870 {
871  if (owner == NULL)
872  return;
874  elog(ERROR, "buffer %d is not owned by resource owner %s",
875  buffer, owner->name);
876 }
ResourceArray bufferarr
Definition: resowner.c:118
const char * name
Definition: resowner.c:115
#define ERROR
Definition: elog.h:43
#define BufferGetDatum(buffer)
Definition: resowner.c:41
#define NULL
Definition: c.h:229
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:214
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:295
#define elog
Definition: elog.h:219
void ResourceOwnerForgetCatCacheListRef ( ResourceOwner  owner,
CatCList list 
)

Definition at line 993 of file resowner.c.

References ResourceOwnerData::catlistrefarr, elog, ERROR, ResourceOwnerData::name, PointerGetDatum, and ResourceArrayRemove().

Referenced by ReleaseCatCacheList().

994 {
995  if (!ResourceArrayRemove(&(owner->catlistrefarr), PointerGetDatum(list)))
996  elog(ERROR, "catcache list reference %p is not owned by resource owner %s",
997  list, owner->name);
998 }
#define PointerGetDatum(X)
Definition: postgres.h:562
const char * name
Definition: resowner.c:115
#define ERROR
Definition: elog.h:43
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:295
ResourceArray catlistrefarr
Definition: resowner.c:120
#define elog
Definition: elog.h:219
void ResourceOwnerForgetCatCacheRef ( ResourceOwner  owner,
HeapTuple  tuple 
)

Definition at line 958 of file resowner.c.

References ResourceOwnerData::catrefarr, elog, ERROR, ResourceOwnerData::name, PointerGetDatum, and ResourceArrayRemove().

Referenced by ReleaseCatCache().

959 {
960  if (!ResourceArrayRemove(&(owner->catrefarr), PointerGetDatum(tuple)))
961  elog(ERROR, "catcache reference %p is not owned by resource owner %s",
962  tuple, owner->name);
963 }
ResourceArray catrefarr
Definition: resowner.c:119
#define PointerGetDatum(X)
Definition: postgres.h:562
const char * name
Definition: resowner.c:115
#define ERROR
Definition: elog.h:43
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:295
#define elog
Definition: elog.h:219
void ResourceOwnerForgetDSM ( ResourceOwner  owner,
dsm_segment  
)

Definition at line 1254 of file resowner.c.

References dsm_segment_handle(), ResourceOwnerData::dsmarr, elog, ERROR, ResourceOwnerData::name, PointerGetDatum, and ResourceArrayRemove().

Referenced by dsm_create(), dsm_detach(), and dsm_pin_mapping().

1255 {
1256  if (!ResourceArrayRemove(&(owner->dsmarr), PointerGetDatum(seg)))
1257  elog(ERROR, "dynamic shared memory segment %u is not owned by resource owner %s",
1258  dsm_segment_handle(seg), owner->name);
1259 }
#define PointerGetDatum(X)
Definition: postgres.h:562
dsm_handle dsm_segment_handle(dsm_segment *seg)
Definition: dsm.c:1028
const char * name
Definition: resowner.c:115
#define ERROR
Definition: elog.h:43
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:295
ResourceArray dsmarr
Definition: resowner.c:126
#define elog
Definition: elog.h:219
void ResourceOwnerForgetFile ( ResourceOwner  owner,
File  file 
)

Definition at line 1209 of file resowner.c.

References elog, ERROR, ResourceOwnerData::filearr, FileGetDatum, ResourceOwnerData::name, and ResourceArrayRemove().

Referenced by FileClose().

1210 {
1211  if (!ResourceArrayRemove(&(owner->filearr), FileGetDatum(file)))
1212  elog(ERROR, "temporary file %d is not owned by resource owner %s",
1213  file, owner->name);
1214 }
const char * name
Definition: resowner.c:115
#define ERROR
Definition: elog.h:43
#define FileGetDatum(file)
Definition: resowner.c:39
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:295
#define elog
Definition: elog.h:219
ResourceArray filearr
Definition: resowner.c:125
void ResourceOwnerForgetLock ( ResourceOwner  owner,
LOCALLOCK locallock 
)

Definition at line 909 of file resowner.c.

References Assert, elog, ERROR, i, ResourceOwnerData::locks, MAX_RESOWNER_LOCKS, ResourceOwnerData::name, and ResourceOwnerData::nlocks.

Referenced by LockReassignOwner(), LockRelease(), LockReleaseAll(), ReleaseLockIfHeld(), and RemoveLocalLock().

910 {
911  int i;
912 
913  if (owner->nlocks > MAX_RESOWNER_LOCKS)
914  return; /* we have overflowed */
915 
916  Assert(owner->nlocks > 0);
917  for (i = owner->nlocks - 1; i >= 0; i--)
918  {
919  if (locallock == owner->locks[i])
920  {
921  owner->locks[i] = owner->locks[owner->nlocks - 1];
922  owner->nlocks--;
923  return;
924  }
925  }
926  elog(ERROR, "lock reference %p is not owned by resource owner %s",
927  locallock, owner->name);
928 }
#define MAX_RESOWNER_LOCKS
Definition: resowner.c:105
const char * name
Definition: resowner.c:115
#define ERROR
Definition: elog.h:43
#define Assert(condition)
Definition: c.h:675
LOCALLOCK * locks[MAX_RESOWNER_LOCKS]
Definition: resowner.c:130
int i
#define elog
Definition: elog.h:219
void ResourceOwnerForgetPlanCacheRef ( ResourceOwner  owner,
CachedPlan plan 
)

Definition at line 1073 of file resowner.c.

References elog, ERROR, ResourceOwnerData::name, ResourceOwnerData::planrefarr, PointerGetDatum, and ResourceArrayRemove().

Referenced by ReleaseCachedPlan().

1074 {
1075  if (!ResourceArrayRemove(&(owner->planrefarr), PointerGetDatum(plan)))
1076  elog(ERROR, "plancache reference %p is not owned by resource owner %s",
1077  plan, owner->name);
1078 }
#define PointerGetDatum(X)
Definition: postgres.h:562
const char * name
Definition: resowner.c:115
#define ERROR
Definition: elog.h:43
ResourceArray planrefarr
Definition: resowner.c:122
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:295
#define elog
Definition: elog.h:219
void ResourceOwnerForgetRelationRef ( ResourceOwner  owner,
Relation  rel 
)

Definition at line 1028 of file resowner.c.

References elog, ERROR, ResourceOwnerData::name, PointerGetDatum, RelationGetRelationName, ResourceOwnerData::relrefarr, and ResourceArrayRemove().

Referenced by RelationDecrementReferenceCount().

1029 {
1030  if (!ResourceArrayRemove(&(owner->relrefarr), PointerGetDatum(rel)))
1031  elog(ERROR, "relcache reference %s is not owned by resource owner %s",
1032  RelationGetRelationName(rel), owner->name);
1033 }
ResourceArray relrefarr
Definition: resowner.c:121
#define PointerGetDatum(X)
Definition: postgres.h:562
const char * name
Definition: resowner.c:115
#define ERROR
Definition: elog.h:43
#define RelationGetRelationName(relation)
Definition: rel.h:436
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:295
#define elog
Definition: elog.h:219
void ResourceOwnerForgetSnapshot ( ResourceOwner  owner,
Snapshot  snapshot 
)

Definition at line 1163 of file resowner.c.

References elog, ERROR, ResourceOwnerData::name, PointerGetDatum, ResourceArrayRemove(), and ResourceOwnerData::snapshotarr.

Referenced by UnregisterSnapshotFromOwner().

1164 {
1165  if (!ResourceArrayRemove(&(owner->snapshotarr), PointerGetDatum(snapshot)))
1166  elog(ERROR, "snapshot reference %p is not owned by resource owner %s",
1167  snapshot, owner->name);
1168 }
#define PointerGetDatum(X)
Definition: postgres.h:562
ResourceArray snapshotarr
Definition: resowner.c:124
const char * name
Definition: resowner.c:115
#define ERROR
Definition: elog.h:43
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:295
#define elog
Definition: elog.h:219
void ResourceOwnerForgetTupleDesc ( ResourceOwner  owner,
TupleDesc  tupdesc 
)

Definition at line 1117 of file resowner.c.

References elog, ERROR, ResourceOwnerData::name, PointerGetDatum, ResourceArrayRemove(), and ResourceOwnerData::tupdescarr.

Referenced by DecrTupleDescRefCount().

1118 {
1119  if (!ResourceArrayRemove(&(owner->tupdescarr), PointerGetDatum(tupdesc)))
1120  elog(ERROR, "tupdesc reference %p is not owned by resource owner %s",
1121  tupdesc, owner->name);
1122 }
#define PointerGetDatum(X)
Definition: postgres.h:562
const char * name
Definition: resowner.c:115
#define ERROR
Definition: elog.h:43
ResourceArray tupdescarr
Definition: resowner.c:123
static bool ResourceArrayRemove(ResourceArray *resarr, Datum value)
Definition: resowner.c:295
#define elog
Definition: elog.h:219
void ResourceOwnerRememberBuffer ( ResourceOwner  owner,
Buffer  buffer 
)

Definition at line 855 of file resowner.c.

References ResourceOwnerData::bufferarr, BufferGetDatum, NULL, and ResourceArrayAdd().

Referenced by IncrBufferRefCount(), LocalBufferAlloc(), PinBuffer(), and PinBuffer_Locked().

856 {
857  if (owner == NULL)
858  return;
860 }
ResourceArray bufferarr
Definition: resowner.c:118
#define BufferGetDatum(buffer)
Definition: resowner.c:41
#define NULL
Definition: c.h:229
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:214
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:257
void ResourceOwnerRememberCatCacheListRef ( ResourceOwner  owner,
CatCList list 
)

Definition at line 984 of file resowner.c.

References ResourceOwnerData::catlistrefarr, PointerGetDatum, and ResourceArrayAdd().

Referenced by SearchCatCacheList().

985 {
987 }
#define PointerGetDatum(X)
Definition: postgres.h:562
ResourceArray catlistrefarr
Definition: resowner.c:120
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:257
void ResourceOwnerRememberCatCacheRef ( ResourceOwner  owner,
HeapTuple  tuple 
)

Definition at line 949 of file resowner.c.

References ResourceOwnerData::catrefarr, PointerGetDatum, and ResourceArrayAdd().

Referenced by SearchCatCache().

950 {
951  ResourceArrayAdd(&(owner->catrefarr), PointerGetDatum(tuple));
952 }
ResourceArray catrefarr
Definition: resowner.c:119
#define PointerGetDatum(X)
Definition: postgres.h:562
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:257
void ResourceOwnerRememberDSM ( ResourceOwner  owner,
dsm_segment  
)

Definition at line 1245 of file resowner.c.

References ResourceOwnerData::dsmarr, PointerGetDatum, and ResourceArrayAdd().

Referenced by dsm_create_descriptor(), and dsm_unpin_mapping().

1246 {
1247  ResourceArrayAdd(&(owner->dsmarr), PointerGetDatum(seg));
1248 }
#define PointerGetDatum(X)
Definition: postgres.h:562
ResourceArray dsmarr
Definition: resowner.c:126
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:257
void ResourceOwnerRememberFile ( ResourceOwner  owner,
File  file 
)

Definition at line 1200 of file resowner.c.

References ResourceOwnerData::filearr, FileGetDatum, and ResourceArrayAdd().

Referenced by OpenTemporaryFile().

1201 {
1202  ResourceArrayAdd(&(owner->filearr), FileGetDatum(file));
1203 }
#define FileGetDatum(file)
Definition: resowner.c:39
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:257
ResourceArray filearr
Definition: resowner.c:125
void ResourceOwnerRememberLock ( ResourceOwner  owner,
LOCALLOCK locallock 
)

Definition at line 889 of file resowner.c.

References Assert, ResourceOwnerData::locks, MAX_RESOWNER_LOCKS, ResourceOwnerData::nlocks, and NULL.

Referenced by GrantLockLocal(), and LockReassignOwner().

890 {
891  Assert(locallock != NULL);
892 
893  if (owner->nlocks > MAX_RESOWNER_LOCKS)
894  return; /* we have already overflowed */
895 
896  if (owner->nlocks < MAX_RESOWNER_LOCKS)
897  owner->locks[owner->nlocks] = locallock;
898  else
899  {
900  /* overflowed */
901  }
902  owner->nlocks++;
903 }
#define MAX_RESOWNER_LOCKS
Definition: resowner.c:105
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
LOCALLOCK * locks[MAX_RESOWNER_LOCKS]
Definition: resowner.c:130
void ResourceOwnerRememberPlanCacheRef ( ResourceOwner  owner,
CachedPlan plan 
)

Definition at line 1064 of file resowner.c.

References ResourceOwnerData::planrefarr, PointerGetDatum, and ResourceArrayAdd().

Referenced by GetCachedPlan().

1065 {
1066  ResourceArrayAdd(&(owner->planrefarr), PointerGetDatum(plan));
1067 }
#define PointerGetDatum(X)
Definition: postgres.h:562
ResourceArray planrefarr
Definition: resowner.c:122
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:257
void ResourceOwnerRememberRelationRef ( ResourceOwner  owner,
Relation  rel 
)

Definition at line 1019 of file resowner.c.

References PointerGetDatum, ResourceOwnerData::relrefarr, and ResourceArrayAdd().

Referenced by RelationIncrementReferenceCount().

1020 {
1021  ResourceArrayAdd(&(owner->relrefarr), PointerGetDatum(rel));
1022 }
ResourceArray relrefarr
Definition: resowner.c:121
#define PointerGetDatum(X)
Definition: postgres.h:562
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:257
void ResourceOwnerRememberSnapshot ( ResourceOwner  owner,
Snapshot  snapshot 
)

Definition at line 1154 of file resowner.c.

References PointerGetDatum, ResourceArrayAdd(), and ResourceOwnerData::snapshotarr.

Referenced by RegisterSnapshotOnOwner().

1155 {
1156  ResourceArrayAdd(&(owner->snapshotarr), PointerGetDatum(snapshot));
1157 }
#define PointerGetDatum(X)
Definition: postgres.h:562
ResourceArray snapshotarr
Definition: resowner.c:124
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:257
void ResourceOwnerRememberTupleDesc ( ResourceOwner  owner,
TupleDesc  tupdesc 
)

Definition at line 1108 of file resowner.c.

References PointerGetDatum, ResourceArrayAdd(), and ResourceOwnerData::tupdescarr.

Referenced by IncrTupleDescRefCount().

1109 {
1110  ResourceArrayAdd(&(owner->tupdescarr), PointerGetDatum(tupdesc));
1111 }
#define PointerGetDatum(X)
Definition: postgres.h:562
ResourceArray tupdescarr
Definition: resowner.c:123
static void ResourceArrayAdd(ResourceArray *resarr, Datum value)
Definition: resowner.c:257