PostgreSQL Source Code  git master
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-2019, 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 extern PGDLLIMPORT ResourceOwner AuxProcessResourceOwner;
37 
38 /*
39  * Resource releasing is done in three phases: pre-locks, locks, and
40  * post-locks. The pre-lock phase must release any resources that are
41  * visible to other backends (such as pinned buffers); this ensures that
42  * when we release a lock that another backend may be waiting on, it will
43  * see us as being fully out of our transaction. The post-lock phase
44  * should be used for backend-internal cleanup.
45  */
46 typedef enum
47 {
52 
53 /*
54  * Dynamically loaded modules can get control during ResourceOwnerRelease
55  * by providing a callback of this form.
56  */
58  bool isCommit,
59  bool isTopLevel,
60  void *arg);
61 
62 
63 /*
64  * Functions in resowner.c
65  */
66 
67 /* generic routines */
68 extern ResourceOwner ResourceOwnerCreate(ResourceOwner parent,
69  const char *name);
70 extern void ResourceOwnerRelease(ResourceOwner owner,
72  bool isCommit,
73  bool isTopLevel);
74 extern void ResourceOwnerDelete(ResourceOwner owner);
75 extern ResourceOwner ResourceOwnerGetParent(ResourceOwner owner);
76 extern void ResourceOwnerNewParent(ResourceOwner owner,
77  ResourceOwner newparent);
79  void *arg);
81  void *arg);
82 extern void CreateAuxProcessResourceOwner(void);
83 extern void ReleaseAuxProcessResources(bool isCommit);
84 
85 #endif /* RESOWNER_H */
PGDLLIMPORT ResourceOwner AuxProcessResourceOwner
Definition: resowner.c:145
void ResourceOwnerNewParent(ResourceOwner owner, ResourceOwner newparent)
Definition: resowner.c:748
void RegisterResourceReleaseCallback(ResourceReleaseCallback callback, void *arg)
Definition: resowner.c:796
void UnregisterResourceReleaseCallback(ResourceReleaseCallback callback, void *arg)
Definition: resowner.c:810
void ResourceOwnerRelease(ResourceOwner owner, ResourceReleasePhase phase, bool isCommit, bool isTopLevel)
Definition: resowner.c:478
#define PGDLLIMPORT
Definition: c.h:1266
PGDLLIMPORT ResourceOwner TopTransactionResourceOwner
Definition: resowner.c:144
PGDLLIMPORT ResourceOwner CurrentResourceOwner
Definition: resowner.c:142
struct ResourceOwnerData * ResourceOwner
Definition: resowner.h:27
ResourceOwner ResourceOwnerGetParent(ResourceOwner owner)
Definition: resowner.c:739
void ReleaseAuxProcessResources(bool isCommit)
Definition: resowner.c:855
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
void CreateAuxProcessResourceOwner(void)
Definition: resowner.c:834
ResourceReleasePhase
Definition: resowner.h:46
ResourceOwner ResourceOwnerCreate(ResourceOwner parent, const char *name)
Definition: resowner.c:422
ResourceOwner parent
Definition: resowner.c:115
const char * name
Definition: encode.c:521
void(* ResourceReleaseCallback)(ResourceReleasePhase phase, bool isCommit, bool isTopLevel, void *arg)
Definition: resowner.h:57
void * arg
void ResourceOwnerDelete(ResourceOwner owner)
Definition: resowner.c:688
PGDLLIMPORT ResourceOwner CurTransactionResourceOwner
Definition: resowner.c:143