PostgreSQL Source Code: src/backend/nodes/copyfuncs.c File Reference (original) (raw)
#include "[postgres.h](postgres%5F8h%5Fsource.html)"
#include "[miscadmin.h](miscadmin%5F8h%5Fsource.html)"
#include "[utils/datum.h](datum%5F8h%5Fsource.html)"
#include "copyfuncs.funcs.c"
#include "copyfuncs.switch.c"
Go to the source code of this file.
Macros | |
---|---|
#define | COPY_SCALAR_FIELD(fldname) (newnode->fldname = from->fldname) |
#define | COPY_NODE_FIELD(fldname) (newnode->fldname = copyObjectImpl(from->fldname)) |
#define | COPY_BITMAPSET_FIELD(fldname) (newnode->fldname = bms_copy(from->fldname)) |
#define | COPY_STRING_FIELD(fldname) (newnode->fldname = from->fldname ? pstrdup(from->fldname) : NULL) |
#define | COPY_ARRAY_FIELD(fldname) memcpy(newnode->fldname, from->fldname, sizeof(newnode->fldname)) |
#define | COPY_POINTER_FIELD(fldname, sz) |
#define | COPY_LOCATION_FIELD(fldname) (newnode->fldname = from->fldname) |
Functions | |
---|---|
static Const * | _copyConst (const Const *from) |
static A_Const * | _copyA_Const (const A_Const *from) |
static ExtensibleNode * | _copyExtensibleNode (const ExtensibleNode *from) |
static Bitmapset * | _copyBitmapset (const Bitmapset *from) |
void * | copyObjectImpl (const void *from) |
◆ COPY_ARRAY_FIELD
| #define COPY_ARRAY_FIELD | ( | | fldname | ) | memcpy(newnode->fldname, from->fldname, sizeof(newnode->fldname)) | | -------------------------- | - | | ------- | - | ----------------------------------------------------------------- |
◆ COPY_BITMAPSET_FIELD
| #define COPY_BITMAPSET_FIELD | ( | | fldname | ) | (newnode->fldname = bms_copy(from->fldname)) | | ------------------------------ | - | | ------- | - | ------------------------------------------------------------------------------------------------------ |
◆ COPY_LOCATION_FIELD
| #define COPY_LOCATION_FIELD | ( | | fldname | ) | (newnode->fldname = from->fldname) | | ----------------------------- | - | | ------- | - | ---------------------------------- |
◆ COPY_NODE_FIELD
| #define COPY_NODE_FIELD | ( | | fldname | ) | (newnode->fldname = copyObjectImpl(from->fldname)) | | ------------------------- | - | | ------- | - | ------------------------------------------------------------------------------------------------------- |
◆ COPY_POINTER_FIELD
| #define COPY_POINTER_FIELD | ( | | fldname, | | ---------------------------- | - | | -------- | | | sz | | | | | ) | | | |
Value:
do { \
Size _size = (sz); \
if (_size > 0) \
{ \
newnode->fldname = palloc(_size); \
memcpy(newnode->fldname, from->fldname, _size); \
} \
} while (0)
Definition at line 50 of file copyfuncs.c.
◆ COPY_SCALAR_FIELD
| #define COPY_SCALAR_FIELD | ( | | fldname | ) | (newnode->fldname = from->fldname) | | --------------------------- | - | | ------- | - | ---------------------------------- |
◆ COPY_STRING_FIELD
| #define COPY_STRING_FIELD | ( | | fldname | ) | (newnode->fldname = from->fldname ? pstrdup(from->fldname) : NULL) | | --------------------------- | - | | ------- | - | ------------------------------------------------------------------------------------------------------------------------ |
◆ _copyA_Const()
Definition at line 108 of file copyfuncs.c.
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}
#define COPY_LOCATION_FIELD(fldname)
#define COPY_STRING_FIELD(fldname)
#define COPY_SCALAR_FIELD(fldname)
References COPY_LOCATION_FIELD, COPY_SCALAR_FIELD, COPY_STRING_FIELD, elog, ERROR, A_Const::isnull, makeNode, nodeTag, A_Const::val, and val.
◆ _copyBitmapset()
◆ _copyConst()
static Const * _copyConst ( const Const * from) | static |
---|
Definition at line 73 of file copyfuncs.c.
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}
Datum datumCopy(Datum value, bool typByVal, int typLen)
References COPY_LOCATION_FIELD, COPY_SCALAR_FIELD, datumCopy(), and makeNode.
◆ _copyExtensibleNode()
◆ copyObjectImpl()
void * copyObjectImpl | ( | const void * | from | ) |
---|
Definition at line 177 of file copyfuncs.c.
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}
List * list_copy_deep(const List *oldlist)
List * list_copy(const List *oldlist)
void check_stack_depth(void)
References check_stack_depth(), elog, ERROR, list_copy(), list_copy_deep(), and nodeTag.
Referenced by list_copy_deep().