PostgreSQL Source Code: src/backend/nodes/copyfuncs.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
17
20
21
22
23
24
25
26
27
28
29
30#define COPY_SCALAR_FIELD(fldname) \
31 (newnode->fldname = from->fldname)
32
33
34#define COPY_NODE_FIELD(fldname) \
35 (newnode->fldname = copyObjectImpl(from->fldname))
36
37
38#define COPY_BITMAPSET_FIELD(fldname) \
39 (newnode->fldname = bms_copy(from->fldname))
40
41
42#define COPY_STRING_FIELD(fldname) \
43 (newnode->fldname = from->fldname ? pstrdup(from->fldname) : NULL)
44
45
46#define COPY_ARRAY_FIELD(fldname) \
47 memcpy(newnode->fldname, from->fldname, sizeof(newnode->fldname))
48
49
50#define COPY_POINTER_FIELD(fldname, sz) \
51 do { \
52 Size _size = (sz); \
53 if (_size > 0) \
54 { \
55 newnode->fldname = palloc(_size); \
56 memcpy(newnode->fldname, from->fldname, _size); \
57 } \
58 } while (0)
59
60
61#define COPY_LOCATION_FIELD(fldname) \
62 (newnode->fldname = from->fldname)
63
64
65#include "copyfuncs.funcs.c"
66
67
68
69
70
71
74{
76
81
82 if (from->constbyval || from->constisnull)
83 {
84
85
86
87
88 newnode->constvalue = from->constvalue;
89 }
90 else
91 {
92
93
94
95 newnode->constvalue = datumCopy(from->constvalue,
96 from->constbyval,
97 from->constlen);
98 }
99
103
104 return newnode;
105}
106
109{
111
114 {
115
118 {
119 case T_Integer:
121 break;
122 case T_Float:
124 break;
125 case T_Boolean:
127 break;
128 case T_String:
130 break;
131 case T_BitString:
133 break;
134 default:
135 elog(ERROR, "unrecognized node type: %d",
137 break;
138 }
139 }
140
142
143 return newnode;
144}
145
148{
151
154 T_ExtensibleNode);
156
157
158 methods->nodeCopy(newnode, from);
159
160 return newnode;
161}
162
165{
167}
168
169
170
171
172
173
174
175
176void *
178{
179 void *retval;
180
181 if (from == NULL)
182 return NULL;
183
184
186
188 {
189#include "copyfuncs.switch.c"
190
191 case T_List:
193 break;
194
195
196
197
198
199 case T_IntList:
200 case T_OidList:
201 case T_XidList:
203 break;
204
205 default:
206 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
207 retval = 0;
208 break;
209 }
210
211 return retval;
212}
Bitmapset * bms_copy(const Bitmapset *a)
static Const * _copyConst(const Const *from)
static ExtensibleNode * _copyExtensibleNode(const ExtensibleNode *from)
#define COPY_LOCATION_FIELD(fldname)
void * copyObjectImpl(const void *from)
static A_Const * _copyA_Const(const A_Const *from)
#define COPY_STRING_FIELD(fldname)
static Bitmapset * _copyBitmapset(const Bitmapset *from)
#define COPY_SCALAR_FIELD(fldname)
Datum datumCopy(Datum value, bool typByVal, int typLen)
const ExtensibleNodeMethods * GetExtensibleNodeMethods(const char *extnodename, bool missing_ok)
List * list_copy_deep(const List *oldlist)
List * list_copy(const List *oldlist)
static Node * newNode(size_t size, NodeTag tag)
void check_stack_depth(void)
void(* nodeCopy)(struct ExtensibleNode *newnode, const struct ExtensibleNode *oldnode)