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