mirror of https://github.com/citusdata/citus.git
Simplify CitusNewNode (#7434)
postgres refactored newNode() in PG 17, the main point for doing this is
the original tricks is no longer neccessary for modern compilers[1].
This does the same for Citus.
This should have no backward compatibility issues since it just replaces
palloc0fast with palloc0.
This is good for forward compatibility since palloc0fast no longer
exists in PG 17.
[1]
https://www.postgresql.org/message-id/b51f1fa7-7e6a-4ecc-936d-90a8a1659e7c@iki.fi
(cherry picked from commit 4b295cc857
)
pull/7699/head
parent
6616f1fd88
commit
f6e2d0108e
|
@ -92,38 +92,21 @@ CitusNodeTagI(Node *node)
|
||||||
return ((CitusNode*)(node))->citus_tag;
|
return ((CitusNode*)(node))->citus_tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Postgres's nodes/nodes.h has more information on why we do this.
|
|
||||||
*/
|
|
||||||
#ifdef __GNUC__
|
|
||||||
|
|
||||||
/* Citus variant of newNode(), don't use directly. */
|
/* Citus variant of newNode(), don't use directly. */
|
||||||
#define CitusNewNode(size, tag) \
|
static inline CitusNode *
|
||||||
({ CitusNode *_result; \
|
CitusNewNode(size_t size, CitusNodeTag tag)
|
||||||
AssertMacro((size) >= sizeof(CitusNode)); /* need the tag, at least */ \
|
{
|
||||||
_result = (CitusNode *) palloc0fast(size); \
|
CitusNode *result;
|
||||||
_result->extensible.type = T_ExtensibleNode; \
|
|
||||||
_result->extensible.extnodename = CitusNodeTagNames[tag - CITUS_NODE_TAG_START]; \
|
|
||||||
_result->citus_tag =(int) (tag); \
|
|
||||||
_result; \
|
|
||||||
})
|
|
||||||
|
|
||||||
#else
|
Assert(size >= sizeof(CitusNode)); /* need the ExtensibleNode and the tag, at least */
|
||||||
|
result = (CitusNode *) palloc0(size);
|
||||||
extern CitusNode *newCitusNodeMacroHolder;
|
result->extensible.type = T_ExtensibleNode;
|
||||||
|
result->extensible.extnodename = CitusNodeTagNames[tag - CITUS_NODE_TAG_START];
|
||||||
#define CitusNewNode(size, tag) \
|
result->citus_tag = (int) (tag);
|
||||||
( \
|
|
||||||
AssertMacro((size) >= sizeof(CitusNode)), /* need the tag, at least */ \
|
|
||||||
newCitusNodeMacroHolder = (CitusNode *) palloc0fast(size), \
|
|
||||||
newCitusNodeMacroHolder->extensible.type = T_ExtensibleNode, \
|
|
||||||
newCitusNodeMacroHolder->extensible.extnodename = CitusNodeTagNames[tag - CITUS_NODE_TAG_START], \
|
|
||||||
newCitusNodeMacroHolder->citus_tag =(int) (tag), \
|
|
||||||
newCitusNodeMacroHolder \
|
|
||||||
)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IsA equivalent that compares node tags, including Citus-specific nodes.
|
* IsA equivalent that compares node tags, including Citus-specific nodes.
|
||||||
|
|
Loading…
Reference in New Issue