Skip to content

Commit

Permalink
Use PG_INTXX_MAX macros instead of INTXX_MAX
Browse files Browse the repository at this point in the history
  • Loading branch information
svenklemm authored and RobAtticus committed Dec 4, 2018
1 parent cf9e72e commit 37d574d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/dimension.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
#include <utils/timestamp.h>
#include <funcapi.h>
#include <miscadmin.h>
#ifdef _WIN32
#include <stdint.h>
#endif

#include "catalog.h"
#include "compat.h"
Expand Down Expand Up @@ -667,10 +664,10 @@ interval_to_usec(Interval *interval)
}

#define INT_TYPE_MAX(type) \
(int64)(((type) == INT2OID) ? INT16_MAX : (((type) == INT4OID) ? INT32_MAX : INT64_MAX))
(int64)(((type) == INT2OID) ? PG_INT16_MAX : (((type) == INT4OID) ? PG_INT32_MAX : PG_INT64_MAX))

#define IS_VALID_NUM_SLICES(num_slices) \
((num_slices) >= 1 && (num_slices) <= INT16_MAX)
((num_slices) >= 1 && (num_slices) <= PG_INT16_MAX)

static int64
get_validated_integer_interval(Oid coltype, int64 value)
Expand Down Expand Up @@ -866,7 +863,7 @@ ts_dimension_set_num_slices(PG_FUNCTION_ARGS)
if (PG_ARGISNULL(1) || !IS_VALID_NUM_SLICES(num_slices_arg))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid number of partitions: must be between 1 and %d", INT16_MAX)));
errmsg("invalid number of partitions: must be between 1 and %d", PG_INT16_MAX)));

/*
* Our catalog stores num_slices as a smallint (int16). However, function
Expand Down Expand Up @@ -985,7 +982,7 @@ dimension_validate_info(DimensionInfo *info)
if (!IS_VALID_NUM_SLICES(info->num_slices))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid number of partitions: must be between 1 and %d", INT16_MAX)));
errmsg("invalid number of partitions: must be between 1 and %d", PG_INT16_MAX)));
}
else
{
Expand Down

0 comments on commit 37d574d

Please sign in to comment.