PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
resowner.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * resowner.h
4  * POSTGRES resource owner definitions.
5  *
6  * Query-lifespan resources are tracked by associating them with
7  * ResourceOwner objects. This provides a simple mechanism for ensuring
8  * that such resources are freed at the right time.
9  * See utils/resowner/README for more info.
10  *
11  *
12  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
13  * Portions Copyright (c) 1994, Regents of the University of California
14  *
15  * src/include/utils/resowner.h
16  *
17  *-------------------------------------------------------------------------
18  */
19 #ifndef RESOWNER_H
20 #define RESOWNER_H
21 
22 
23 /*
24  * ResourceOwner objects are an opaque data structure known only within
25  * resowner.c.
26  */
28 
29 
30 /*
31  * Globally known ResourceOwners
32  */
33 extern PGDLLIMPORT ResourceOwner CurrentResourceOwner;
34 extern PGDLLIMPORT ResourceOwner CurTransactionResourceOwner;
35 extern PGDLLIMPORT ResourceOwner TopTransactionResourceOwner;
36 
37 /*
38  * Resource releasing is done in three phases: pre-locks, locks, and
39  * post-locks. The pre-lock phase must release any resources that are
40  * visible to other backends (such as pinned buffers); this ensures that
41  * when we release a lock that another backend may be waiting on, it will
42  * see us as being fully out of our transaction. The post-lock phase
43  * should be used for backend-internal cleanup.
44  */
45 typedef enum
46 {
51 
52 /*
53  * Dynamically loaded modules can get control during ResourceOwnerRelease
54  * by providing a callback of this form.
55  */
57  bool isCommit,
58  bool isTopLevel,
59  void *arg);
60 
61 
62 /*
63  * Functions in resowner.c
64  */
65 
66 /* generic routines */
67 extern ResourceOwner ResourceOwnerCreate(ResourceOwner parent,
68  const char *name);
69 extern void ResourceOwnerRelease(ResourceOwner owner,
71  bool isCommit,
72  bool isTopLevel);
73 extern void ResourceOwnerDelete(ResourceOwner owner);
74 extern ResourceOwner ResourceOwnerGetParent(ResourceOwner owner);
75 extern void ResourceOwnerNewParent(ResourceOwner owner,
76  ResourceOwner newparent);
78  void *arg);
80  void *arg);
81 
82 #endif /* RESOWNER_H */
void ResourceOwnerNewParent(ResourceOwner owner, ResourceOwner newparent)
Definition: resowner.c:745
void RegisterResourceReleaseCallback(ResourceReleaseCallback callback, void *arg)
Definition: resowner.c:793
void UnregisterResourceReleaseCallback(ResourceReleaseCallback callback, void *arg)
Definition: resowner.c:807
void ResourceOwnerRelease(ResourceOwner owner, ResourceReleasePhase phase, bool isCommit, bool isTopLevel)
Definition: resowner.c:471
#define PGDLLIMPORT
Definition: c.h:1064
PGDLLIMPORT ResourceOwner TopTransactionResourceOwner
Definition: resowner.c:140
PGDLLIMPORT ResourceOwner CurrentResourceOwner
Definition: resowner.c:138
struct ResourceOwnerData * ResourceOwner
Definition: resowner.h:27
ResourceOwner ResourceOwnerGetParent(ResourceOwner owner)
Definition: resowner.c:736
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
ResourceReleasePhase
Definition: resowner.h:45
ResourceOwner ResourceOwnerCreate(ResourceOwner parent, const char *name)
Definition: resowner.c:416
ResourceOwner parent
Definition: resowner.c:112
void(* ResourceReleaseCallback)(ResourceReleasePhase phase, bool isCommit, bool isTopLevel, void *arg)
Definition: resowner.h:56
const char * name
Definition: encode.c:521
void * arg
void ResourceOwnerDelete(ResourceOwner owner)
Definition: resowner.c:687
PGDLLIMPORT ResourceOwner CurTransactionResourceOwner
Definition: resowner.c:139