Eneboo - Documentación para desarrolladores
|
00001 /*------------------------------------------------------------------------- 00002 * 00003 * resowner.h 00004 * POSTGRES resource owner definitions. 00005 * 00006 * Query-lifespan resources are tracked by associating them with 00007 * ResourceOwner objects. This provides a simple mechanism for ensuring 00008 * that such resources are freed at the right time. 00009 * See utils/resowner/README for more info. 00010 * 00011 * 00012 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group 00013 * Portions Copyright (c) 1994, Regents of the University of California 00014 * 00015 * $PostgreSQL: pgsql/src/include/utils/resowner.h,v 1.5 2004/12/31 22:03:46 pgsql Exp $ 00016 * 00017 *------------------------------------------------------------------------- 00018 */ 00019 #ifndef RESOWNER_H 00020 #define RESOWNER_H 00021 00022 #include "storage/buf.h" 00023 #include "utils/catcache.h" 00024 #include "utils/rel.h" 00025 00026 00027 /* 00028 * ResourceOwner objects are an opaque data structure known only within 00029 * resowner.c. 00030 */ 00031 typedef struct ResourceOwnerData *ResourceOwner; 00032 00033 00034 /* 00035 * Globally known ResourceOwners 00036 */ 00037 extern DLLIMPORT ResourceOwner CurrentResourceOwner; 00038 extern DLLIMPORT ResourceOwner CurTransactionResourceOwner; 00039 extern DLLIMPORT ResourceOwner TopTransactionResourceOwner; 00040 00041 /* 00042 * Resource releasing is done in three phases: pre-locks, locks, and 00043 * post-locks. The pre-lock phase must release any resources that are 00044 * visible to other backends (such as pinned buffers); this ensures that 00045 * when we release a lock that another backend may be waiting on, it will 00046 * see us as being fully out of our transaction. The post-lock phase 00047 * should be used for backend-internal cleanup. 00048 */ 00049 typedef enum 00050 { 00051 RESOURCE_RELEASE_BEFORE_LOCKS, 00052 RESOURCE_RELEASE_LOCKS, 00053 RESOURCE_RELEASE_AFTER_LOCKS 00054 } ResourceReleasePhase; 00055 00056 /* 00057 * Dynamically loaded modules can get control during ResourceOwnerRelease 00058 * by providing a callback of this form. 00059 */ 00060 typedef void (*ResourceReleaseCallback) (ResourceReleasePhase phase, 00061 bool isCommit, 00062 bool isTopLevel, 00063 void *arg); 00064 00065 00066 /* 00067 * Functions in resowner.c 00068 */ 00069 00070 /* generic routines */ 00071 extern ResourceOwner ResourceOwnerCreate(ResourceOwner parent, 00072 const char *name); 00073 extern void ResourceOwnerRelease(ResourceOwner owner, 00074 ResourceReleasePhase phase, 00075 bool isCommit, 00076 bool isTopLevel); 00077 extern void ResourceOwnerDelete(ResourceOwner owner); 00078 extern ResourceOwner ResourceOwnerGetParent(ResourceOwner owner); 00079 extern void ResourceOwnerNewParent(ResourceOwner owner, 00080 ResourceOwner newparent); 00081 extern void RegisterResourceReleaseCallback(ResourceReleaseCallback callback, 00082 void *arg); 00083 extern void UnregisterResourceReleaseCallback(ResourceReleaseCallback callback, 00084 void *arg); 00085 00086 /* support for buffer refcount management */ 00087 extern void ResourceOwnerEnlargeBuffers(ResourceOwner owner); 00088 extern void ResourceOwnerRememberBuffer(ResourceOwner owner, Buffer buffer); 00089 extern void ResourceOwnerForgetBuffer(ResourceOwner owner, Buffer buffer); 00090 00091 /* support for catcache refcount management */ 00092 extern void ResourceOwnerEnlargeCatCacheRefs(ResourceOwner owner); 00093 extern void ResourceOwnerRememberCatCacheRef(ResourceOwner owner, 00094 HeapTuple tuple); 00095 extern void ResourceOwnerForgetCatCacheRef(ResourceOwner owner, 00096 HeapTuple tuple); 00097 extern void ResourceOwnerEnlargeCatCacheListRefs(ResourceOwner owner); 00098 extern void ResourceOwnerRememberCatCacheListRef(ResourceOwner owner, 00099 CatCList *list); 00100 extern void ResourceOwnerForgetCatCacheListRef(ResourceOwner owner, 00101 CatCList *list); 00102 00103 /* support for relcache refcount management */ 00104 extern void ResourceOwnerEnlargeRelationRefs(ResourceOwner owner); 00105 extern void ResourceOwnerRememberRelationRef(ResourceOwner owner, 00106 Relation rel); 00107 extern void ResourceOwnerForgetRelationRef(ResourceOwner owner, 00108 Relation rel); 00109 00110 #endif /* RESOWNER_H */