pg12 revised layout of FunctionCallInfoData

See a9c35cf85c

clang raises a warning due to FunctionCall2InfoData technically being variable sized
This is fine, as the struct is the size we want it to be. So silence the warning
pull/2844/head
Philip Dubé 2019-08-08 22:05:16 +00:00
parent bee779e7d4
commit e5cd298a98
6 changed files with 121 additions and 60 deletions

35
configure vendored
View File

@ -3832,6 +3832,41 @@ if test x"$citusac_cv_prog_cc_cflags__Wno_clobbered" = x"yes"; then
CITUS_CFLAGS="$CITUS_CFLAGS -Wno-clobbered"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-gnu-variable-sized-type-not-at-end" >&5
$as_echo_n "checking whether $CC supports -Wno-gnu-variable-sized-type-not-at-end... " >&6; }
if ${citusac_cv_prog_cc_cflags__Wno_gnu_variable_sized_type_not_at_end+:} false; then :
$as_echo_n "(cached) " >&6
else
citusac_save_CFLAGS=$CFLAGS
CFLAGS="$citusac_save_CFLAGS -Wno-gnu-variable-sized-type-not-at-end"
ac_save_c_werror_flag=$ac_c_werror_flag
ac_c_werror_flag=yes
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
citusac_cv_prog_cc_cflags__Wno_gnu_variable_sized_type_not_at_end=yes
else
citusac_cv_prog_cc_cflags__Wno_gnu_variable_sized_type_not_at_end=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_c_werror_flag=$ac_save_c_werror_flag
CFLAGS="$citusac_save_CFLAGS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $citusac_cv_prog_cc_cflags__Wno_gnu_variable_sized_type_not_at_end" >&5
$as_echo "$citusac_cv_prog_cc_cflags__Wno_gnu_variable_sized_type_not_at_end" >&6; }
if test x"$citusac_cv_prog_cc_cflags__Wno_gnu_variable_sized_type_not_at_end" = x"yes"; then
CITUS_CFLAGS="$CITUS_CFLAGS -Wno-gnu-variable-sized-type-not-at-end"
fi
# And add a few extra warnings
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wdeclaration-after-statement" >&5
$as_echo_n "checking whether $CC supports -Wdeclaration-after-statement... " >&6; }

View File

@ -157,6 +157,7 @@ CITUSAC_PROG_CC_CFLAGS_OPT([-Wno-unused-parameter])
CITUSAC_PROG_CC_CFLAGS_OPT([-Wno-sign-compare])
CITUSAC_PROG_CC_CFLAGS_OPT([-Wno-missing-field-initializers])
CITUSAC_PROG_CC_CFLAGS_OPT([-Wno-clobbered])
CITUSAC_PROG_CC_CFLAGS_OPT([-Wno-gnu-variable-sized-type-not-at-end])
# And add a few extra warnings
CITUSAC_PROG_CC_CFLAGS_OPT([-Wdeclaration-after-statement])
CITUSAC_PROG_CC_CFLAGS_OPT([-Wendif-labels])

View File

@ -59,6 +59,7 @@
#include "distributed/multi_physical_planner.h"
#include "distributed/shardinterval_utils.h"
#include "distributed/pg_dist_partition.h"
#include "distributed/version_compat.h"
#include "distributed/worker_protocol.h"
#include "nodes/nodeFuncs.h"
#include "nodes/makefuncs.h"
@ -138,6 +139,17 @@ typedef struct PendingPruningInstance
Node *continueAt;
} PendingPruningInstance;
#if PG_VERSION_NUM >= 120000
typedef union \
{ \
FunctionCallInfoBaseData fcinfo; \
/* ensure enough space for nargs args is available */ \
char fcinfo_data[SizeForFunctionCallInfo(2)]; \
} FunctionCall2InfoData;
#else
typedef FunctionCallInfoData FunctionCall2InfoData;
typedef FunctionCallInfoData *FunctionCallInfo;
#endif
/*
* Data necessary to perform a single PruneShards().
@ -161,11 +173,11 @@ typedef struct ClauseWalkerContext
/*
* Information about function calls we need to perform. Re-using the same
* FunctionCallInfoData, instead of using FunctionCall2Coll, is often
* FunctionCall2InfoData, instead of using FunctionCall2Coll, is often
* cheaper.
*/
FunctionCallInfoData compareValueFunctionCall;
FunctionCallInfoData compareIntervalFunctionCall;
FunctionCall2InfoData compareValueFunctionCall;
FunctionCall2InfoData compareIntervalFunctionCall;
} ClauseWalkerContext;
static void PrunableExpressions(Node *originalNode, ClauseWalkerContext *context);
@ -184,9 +196,9 @@ static void AddNewConjuction(ClauseWalkerContext *context, OpExpr *op);
static PruningInstance * CopyPartialPruningInstance(PruningInstance *sourceInstance);
static List * ShardArrayToList(ShardInterval **shardArray, int length);
static List * DeepCopyShardIntervalList(List *originalShardIntervalList);
static int PerformValueCompare(FunctionCallInfoData *compareFunctionCall, Datum a,
static int PerformValueCompare(FunctionCallInfo compareFunctionCall, Datum a,
Datum b);
static int PerformCompare(FunctionCallInfoData *compareFunctionCall);
static int PerformCompare(FunctionCallInfo compareFunctionCall);
static List * PruneOne(DistTableCacheEntry *cacheEntry, ClauseWalkerContext *context,
PruningInstance *prune);
@ -201,11 +213,11 @@ static bool ExhaustivePruneOne(ShardInterval *curInterval,
PruningInstance *prune);
static int UpperShardBoundary(Datum partitionColumnValue,
ShardInterval **shardIntervalCache,
int shardCount, FunctionCallInfoData *compareFunction,
int shardCount, FunctionCallInfo compareFunction,
bool includeMin);
static int LowerShardBoundary(Datum partitionColumnValue,
ShardInterval **shardIntervalCache,
int shardCount, FunctionCallInfoData *compareFunction,
int shardCount, FunctionCallInfo compareFunction,
bool includeMax);
@ -261,7 +273,8 @@ PruneShards(Oid relationId, Index rangeTableId, List *whereClauseList,
if (cacheEntry->shardIntervalCompareFunction)
{
/* initiate function call info once (allows comparators to cache metadata) */
InitFunctionCallInfoData(context.compareIntervalFunctionCall,
InitFunctionCallInfoData(*(FunctionCallInfo) &
context.compareIntervalFunctionCall,
cacheEntry->shardIntervalCompareFunction,
2, DEFAULT_COLLATION_OID, NULL, NULL);
}
@ -274,7 +287,8 @@ PruneShards(Oid relationId, Index rangeTableId, List *whereClauseList,
if (cacheEntry->shardColumnCompareFunction)
{
/* initiate function call info once (allows comparators to cache metadata) */
InitFunctionCallInfoData(context.compareValueFunctionCall,
InitFunctionCallInfoData(*(FunctionCallInfo) &
context.compareValueFunctionCall,
cacheEntry->shardColumnCompareFunction,
2, DEFAULT_COLLATION_OID, NULL, NULL);
}
@ -753,7 +767,8 @@ AddPartitionKeyRestrictionToInstance(ClauseWalkerContext *context, OpExpr *opCla
case BTLessStrategyNumber:
{
if (!prune->lessConsts ||
PerformValueCompare(&context->compareValueFunctionCall,
PerformValueCompare((FunctionCallInfo) &
context->compareValueFunctionCall,
constantClause->constvalue,
prune->lessConsts->constvalue) < 0)
{
@ -766,7 +781,8 @@ AddPartitionKeyRestrictionToInstance(ClauseWalkerContext *context, OpExpr *opCla
case BTLessEqualStrategyNumber:
{
if (!prune->lessEqualConsts ||
PerformValueCompare(&context->compareValueFunctionCall,
PerformValueCompare((FunctionCallInfo) &
context->compareValueFunctionCall,
constantClause->constvalue,
prune->lessEqualConsts->constvalue) < 0)
{
@ -782,7 +798,8 @@ AddPartitionKeyRestrictionToInstance(ClauseWalkerContext *context, OpExpr *opCla
{
prune->equalConsts = constantClause;
}
else if (PerformValueCompare(&context->compareValueFunctionCall,
else if (PerformValueCompare((FunctionCallInfo) &
context->compareValueFunctionCall,
constantClause->constvalue,
prune->equalConsts->constvalue) != 0)
{
@ -796,7 +813,8 @@ AddPartitionKeyRestrictionToInstance(ClauseWalkerContext *context, OpExpr *opCla
case BTGreaterEqualStrategyNumber:
{
if (!prune->greaterEqualConsts ||
PerformValueCompare(&context->compareValueFunctionCall,
PerformValueCompare((FunctionCallInfo) &
context->compareValueFunctionCall,
constantClause->constvalue,
prune->greaterEqualConsts->constvalue) > 0
)
@ -810,7 +828,8 @@ AddPartitionKeyRestrictionToInstance(ClauseWalkerContext *context, OpExpr *opCla
case BTGreaterStrategyNumber:
{
if (!prune->greaterConsts ||
PerformValueCompare(&context->compareValueFunctionCall,
PerformValueCompare((FunctionCallInfo) &
context->compareValueFunctionCall,
constantClause->constvalue,
prune->greaterConsts->constvalue) > 0)
{
@ -1133,7 +1152,7 @@ PruneOne(DistTableCacheEntry *cacheEntry, ClauseWalkerContext *context,
* unexpected NULL returns.
*/
static int
PerformCompare(FunctionCallInfoData *compareFunctionCall)
PerformCompare(FunctionCallInfo compareFunctionCall)
{
Datum result = FunctionCallInvoke(compareFunctionCall);
@ -1151,12 +1170,10 @@ PerformCompare(FunctionCallInfoData *compareFunctionCall)
* NULL returns.
*/
static int
PerformValueCompare(FunctionCallInfoData *compareFunctionCall, Datum a, Datum b)
PerformValueCompare(FunctionCallInfo compareFunctionCall, Datum a, Datum b)
{
compareFunctionCall->arg[0] = a;
compareFunctionCall->argnull[0] = false;
compareFunctionCall->arg[1] = b;
compareFunctionCall->argnull[1] = false;
fcSetArg(compareFunctionCall, 0, a);
fcSetArg(compareFunctionCall, 1, b);
return PerformCompare(compareFunctionCall);
}
@ -1168,7 +1185,7 @@ PerformValueCompare(FunctionCallInfoData *compareFunctionCall, Datum a, Datum b)
*/
static int
LowerShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCache,
int shardCount, FunctionCallInfoData *compareFunction, bool includeMax)
int shardCount, FunctionCallInfo compareFunction, bool includeMax)
{
int lowerBoundIndex = 0;
int upperBoundIndex = shardCount;
@ -1176,8 +1193,7 @@ LowerShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCach
Assert(shardCount != 0);
/* setup partitionColumnValue argument once */
compareFunction->arg[0] = partitionColumnValue;
compareFunction->argnull[0] = false;
fcSetArg(compareFunction, 0, partitionColumnValue);
while (lowerBoundIndex < upperBoundIndex)
{
@ -1186,8 +1202,7 @@ LowerShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCach
int minValueComparison = 0;
/* setup minValue as argument */
compareFunction->arg[1] = shardIntervalCache[middleIndex]->minValue;
compareFunction->argnull[1] = false;
fcSetArg(compareFunction, 1, shardIntervalCache[middleIndex]->minValue);
/* execute cmp(partitionValue, lowerBound) */
minValueComparison = PerformCompare(compareFunction);
@ -1201,8 +1216,7 @@ LowerShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCach
}
/* setup maxValue as argument */
compareFunction->arg[1] = shardIntervalCache[middleIndex]->maxValue;
compareFunction->argnull[1] = false;
fcSetArg(compareFunction, 1, shardIntervalCache[middleIndex]->maxValue);
/* execute cmp(partitionValue, upperBound) */
maxValueComparison = PerformCompare(compareFunction);
@ -1249,7 +1263,7 @@ LowerShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCach
*/
static int
UpperShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCache,
int shardCount, FunctionCallInfoData *compareFunction, bool includeMin)
int shardCount, FunctionCallInfo compareFunction, bool includeMin)
{
int lowerBoundIndex = 0;
int upperBoundIndex = shardCount;
@ -1257,8 +1271,7 @@ UpperShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCach
Assert(shardCount != 0);
/* setup partitionColumnValue argument once */
compareFunction->arg[0] = partitionColumnValue;
compareFunction->argnull[0] = false;
fcSetArg(compareFunction, 0, partitionColumnValue);
while (lowerBoundIndex < upperBoundIndex)
{
@ -1267,8 +1280,7 @@ UpperShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCach
int minValueComparison = 0;
/* setup minValue as argument */
compareFunction->arg[1] = shardIntervalCache[middleIndex]->minValue;
compareFunction->argnull[1] = false;
fcSetArg(compareFunction, 1, shardIntervalCache[middleIndex]->minValue);
/* execute cmp(partitionValue, lowerBound) */
minValueComparison = PerformCompare(compareFunction);
@ -1283,8 +1295,7 @@ UpperShardBoundary(Datum partitionColumnValue, ShardInterval **shardIntervalCach
}
/* setup maxValue as argument */
compareFunction->arg[1] = shardIntervalCache[middleIndex]->maxValue;
compareFunction->argnull[1] = false;
fcSetArg(compareFunction, 1, shardIntervalCache[middleIndex]->maxValue);
/* execute cmp(partitionValue, upperBound) */
maxValueComparison = PerformCompare(compareFunction);
@ -1345,7 +1356,8 @@ PruneWithBoundaries(DistTableCacheEntry *cacheEntry, ClauseWalkerContext *contex
int lowerBoundIdx = -1;
int upperBoundIdx = -1;
int curIdx = 0;
FunctionCallInfo compareFunctionCall = &context->compareIntervalFunctionCall;
FunctionCallInfo compareFunctionCall = (FunctionCallInfo) &
context->compareIntervalFunctionCall;
if (prune->greaterEqualConsts)
{
@ -1476,7 +1488,8 @@ ExhaustivePruneOne(ShardInterval *curInterval,
ClauseWalkerContext *context,
PruningInstance *prune)
{
FunctionCallInfo compareFunctionCall = &context->compareIntervalFunctionCall;
FunctionCallInfo compareFunctionCall = (FunctionCallInfo) &
context->compareIntervalFunctionCall;
Datum compareWith = 0;
/* NULL boundaries can't be compared to */

View File

@ -11,11 +11,10 @@
#include "catalog/namespace.h"
#include "distributed/function_utils.h"
#include "distributed/version_compat.h"
#include "executor/executor.h"
#include "utils/builtins.h"
#if (PG_VERSION_NUM >= 100000)
#include "utils/regproc.h"
#endif
/*
* FunctionOid searches for a function that has the given name and the given
@ -83,7 +82,7 @@ FunctionOidExtended(const char *schemaName, const char *functionName, int argume
ReturnSetInfo *
FunctionCallGetTupleStore1(PGFunction function, Oid functionId, Datum argument)
{
FunctionCallInfoData fcinfo;
LOCAL_FCINFO(fcinfo, 1);
FmgrInfo flinfo;
ReturnSetInfo *rsinfo = makeNode(ReturnSetInfo);
EState *estate = CreateExecutorState();
@ -91,12 +90,11 @@ FunctionCallGetTupleStore1(PGFunction function, Oid functionId, Datum argument)
rsinfo->allowedModes = SFRM_Materialize;
fmgr_info(functionId, &flinfo);
InitFunctionCallInfoData(fcinfo, &flinfo, 1, InvalidOid, NULL, (Node *) rsinfo);
InitFunctionCallInfoData(*fcinfo, &flinfo, 1, InvalidOid, NULL, (Node *) rsinfo);
fcinfo.arg[0] = argument;
fcinfo.argnull[0] = false;
fcSetArg(fcinfo, 0, argument);
(*function)(&fcinfo);
(*function)(fcinfo);
return rsinfo;
}

View File

@ -20,6 +20,7 @@
#include "access/sysattr.h"
#include "catalog/indexing.h"
#include "catalog/pg_am.h"
#include "catalog/pg_enum.h"
#include "catalog/pg_extension.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_type.h"
@ -43,6 +44,7 @@
#include "distributed/pg_dist_placement.h"
#include "distributed/shared_library_init.h"
#include "distributed/shardinterval_utils.h"
#include "distributed/version_compat.h"
#include "distributed/worker_manager.h"
#include "distributed/worker_protocol.h"
#include "executor/executor.h"
@ -1259,8 +1261,6 @@ static ShardInterval **
SortShardIntervalArray(ShardInterval **shardIntervalArray, int shardCount,
FmgrInfo *shardIntervalSortCompareFunction)
{
ShardInterval **sortedShardIntervalArray = NULL;
/* short cut if there are no shard intervals in the array */
if (shardCount == 0)
{
@ -1272,9 +1272,7 @@ SortShardIntervalArray(ShardInterval **shardIntervalArray, int shardCount,
(qsort_arg_comparator) CompareShardIntervals,
(void *) shardIntervalSortCompareFunction);
sortedShardIntervalArray = shardIntervalArray;
return sortedShardIntervalArray;
return shardIntervalArray;
}
@ -1624,9 +1622,8 @@ AvailableExtensionVersion(void)
{
ReturnSetInfo *extensionsResultSet = NULL;
TupleTableSlot *tupleTableSlot = NULL;
FunctionCallInfoData *fcinfo = NULL;
FmgrInfo *flinfo = NULL;
int argumentCount = 0;
LOCAL_FCINFO(fcinfo, 0);
FmgrInfo flinfo;
EState *estate = NULL;
bool hasTuple = false;
@ -1641,17 +1638,15 @@ AvailableExtensionVersion(void)
extensionsResultSet->econtext = GetPerTupleExprContext(estate);
extensionsResultSet->allowedModes = SFRM_Materialize;
fcinfo = palloc0(sizeof(FunctionCallInfoData));
flinfo = palloc0(sizeof(FmgrInfo));
fmgr_info(F_PG_AVAILABLE_EXTENSIONS, flinfo);
InitFunctionCallInfoData(*fcinfo, flinfo, argumentCount, InvalidOid, NULL,
fmgr_info(F_PG_AVAILABLE_EXTENSIONS, &flinfo);
InitFunctionCallInfoData(*fcinfo, &flinfo, 0, InvalidOid, NULL,
(Node *) extensionsResultSet);
/* pg_available_extensions returns result set containing all available extensions */
(*pg_available_extensions)(fcinfo);
tupleTableSlot = MakeSingleTupleTableSlot(extensionsResultSet->setDesc);
tupleTableSlot = MakeSingleTupleTableSlotCompat(extensionsResultSet->setDesc,
&TTSOpsMinimalTuple);
hasTuple = tuplestore_gettupleslot(extensionsResultSet->setResult, goForward, doCopy,
tupleTableSlot);
while (hasTuple)
@ -1992,7 +1987,8 @@ CitusCopyFormatTypeId(void)
if (MetadataCache.copyFormatTypeId == InvalidOid)
{
char *typeName = "citus_copy_format";
MetadataCache.copyFormatTypeId = GetSysCacheOid2(TYPENAMENSP,
MetadataCache.copyFormatTypeId = GetSysCacheOid2Compat(TYPENAMENSP,
Anum_pg_enum_oid,
PointerGetDatum(typeName),
PG_CATALOG_NAMESPACE);
}
@ -2256,7 +2252,11 @@ LookupNodeRoleTypeOid()
return InvalidOid;
}
#if PG_VERSION_NUM >= 120000
nodeRoleTypId = ((Form_pg_type) GETSTRUCT(tup))->oid;
#else
nodeRoleTypId = HeapTupleGetOid(tup);
#endif
ReleaseSysCache(tup);
return nodeRoleTypId;

View File

@ -257,6 +257,11 @@ RangeVarGetRelidInternal(const RangeVar *relation, LOCKMODE lockmode, uint32 fla
#define GetSysCacheOid3Compat GetSysCacheOid3
#define GetSysCacheOid4Compat GetSysCacheOid4
#define fcSetArg(fc, n, argval) \
(((fc)->args[n].isnull = false), ((fc)->args[n].value = (argval)))
#define fcSetArgNull(fc, n) \
(((fc)->args[n].isnull = true), ((fc)->args[n].value = (Datum) 0))
typedef struct
{
File fd;
@ -319,6 +324,15 @@ FileCompatFromFileStart(File fileDesc)
#define GetSysCacheOid4Compat(cacheId, oidcol, key1, key2, key3, key4) \
GetSysCacheOid4(cacheId, key1, key2, key3, key4)
#define LOCAL_FCINFO(name, nargs) \
FunctionCallInfoData name ## data; \
FunctionCallInfoData *name = &name ## data
#define fcSetArg(fc, n, value) \
(((fc)->argnull[n] = false), ((fc)->arg[n] = (value)))
#define fcSetArgNull(fc, n) \
(((fc)->argnull[n] = true), ((fc)->arg[n] = (Datum) 0))
typedef struct
{
File fd;