]> git.8kb.co.uk Git - pgpool-ii/pgpool-ii_2.2.5/blob - parser/memnodes.h
Attempt to send a proper failure message to frontend when authentication
[pgpool-ii/pgpool-ii_2.2.5] / parser / memnodes.h
1 /*-------------------------------------------------------------------------
2  *
3  * memnodes.h
4  *        POSTGRES memory context node definitions.
5  *
6  *
7  * Portions Copyright (c) 2003-2008, PgPool Global Development Group
8  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
9  * Portions Copyright (c) 1994, Regents of the University of California
10  *
11  * $PostgreSQL: pgsql/src/include/nodes/memnodes.h,v 1.30 2004/12/31 22:03:34 pgsql Exp $
12  *
13  *-------------------------------------------------------------------------
14  */
15 #ifndef MEMNODES_H
16 #define MEMNODES_H
17
18 #include "nodes.h"
19
20 /*
21  * MemoryContext
22  *              A logical context in which memory allocations occur.
23  *
24  * MemoryContext itself is an abstract type that can have multiple
25  * implementations, though for now we have only AllocSetContext.
26  * The function pointers in MemoryContextMethods define one specific
27  * implementation of MemoryContext --- they are a virtual function table
28  * in C++ terms.
29  *
30  * Node types that are actual implementations of memory contexts must
31  * begin with the same fields as MemoryContext.
32  *
33  * Note: for largely historical reasons, typedef MemoryContext is a pointer
34  * to the context struct rather than the struct type itself.
35  */
36
37 typedef struct MemoryContextMethods
38 {
39         void       *(*alloc) (MemoryContext context, Size size);
40         /* call this free_p in case someone #define's free() */
41         void            (*free_p) (MemoryContext context, void *pointer);
42         void       *(*realloc) (MemoryContext context, void *pointer, Size size);
43         void            (*init) (MemoryContext context);
44         void            (*reset) (MemoryContext context);
45         void            (*delete) (MemoryContext context);
46         Size            (*get_chunk_space) (MemoryContext context, void *pointer);
47         bool            (*is_empty) (MemoryContext context);
48         void            (*stats) (MemoryContext context);
49 #ifdef MEMORY_CONTEXT_CHECKING
50         void            (*check) (MemoryContext context);
51 #endif
52 } MemoryContextMethods;
53
54
55 typedef struct MemoryContextData
56 {
57         NodeTag         type;                   /* identifies exact kind of context */
58         MemoryContextMethods *methods;          /* virtual function table */
59         MemoryContext parent;           /* NULL if no parent (toplevel context) */
60         MemoryContext firstchild;       /* head of linked list of children */
61         MemoryContext nextchild;        /* next child of same parent */
62         char       *name;                       /* context name (just for debugging) */
63 } MemoryContextData;
64
65 /* utils/palloc.h contains typedef struct MemoryContextData *MemoryContext */
66
67
68 /*
69  * MemoryContextIsValid
70  *              True iff memory context is valid.
71  *
72  * Add new context types to the set accepted by this macro.
73  */
74 #define MemoryContextIsValid(context) \
75         ((context) != NULL && \
76          (IsA((context), AllocSetContext)))
77
78 #endif   /* MEMNODES_H */