summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2015-04-02 17:43:35 +0200
committerAndres Freund <andres@anarazel.de>2015-04-02 17:43:35 +0200
commit62e2a8dc2c7f6b1351a0385491933af969ed4265 (patch)
tree3fd46136353e1838f871478232935dbba0866392 /src/backend/utils/adt
parente146ca682062ca1f5015f3820571c5359f5f9dba (diff)
downloadpostgresql-62e2a8dc2c7f6b1351a0385491933af969ed4265.tar.gz
Define integer limits independently from the system definitions.
In 83ff1618 we defined integer limits iff they're not provided by the system. That turns out not to be the greatest idea because there's different ways some datatypes can be represented. E.g. on OSX PG's 64bit datatype will be a 'long int', but OSX unconditionally uses 'long long'. That disparity then can lead to warnings, e.g. around printf formats. One way to fix that would be to back int64 using stdint.h's int64_t. While a good idea it's not that easy to implement. We would e.g. need to include stdint.h in our external headers, which we don't today. Also computing the correct int64 printf formats in that case is nontrivial. Instead simply prefix the integer limits with PG_ and define them unconditionally. I've adjusted all the references to them in code, but not the ones in comments; the latter seems unnecessary to me. Discussion: 20150331141423.GK4878@alap3.anarazel.de
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r--src/backend/utils/adt/int8.c2
-rw-r--r--src/backend/utils/adt/numutils.c2
-rw-r--r--src/backend/utils/adt/timestamp.c2
-rw-r--r--src/backend/utils/adt/txid.c2
4 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index b3a1191887..63a4fbb4a3 100644
--- a/src/backend/utils/adt/int8.c
+++ b/src/backend/utils/adt/int8.c
@@ -78,7 +78,7 @@ scanint8(const char *str, bool errorOK, int64 *result)
*/
if (strncmp(ptr, "9223372036854775808", 19) == 0)
{
- tmp = INT64_MIN;
+ tmp = PG_INT64_MIN;
ptr += 19;
goto gotdigits;
}
diff --git a/src/backend/utils/adt/numutils.c b/src/backend/utils/adt/numutils.c
index 585da1e732..1dadbd597a 100644
--- a/src/backend/utils/adt/numutils.c
+++ b/src/backend/utils/adt/numutils.c
@@ -190,7 +190,7 @@ pg_lltoa(int64 value, char *a)
* Avoid problems with the most negative integer not being representable
* as a positive integer.
*/
- if (value == INT64_MIN)
+ if (value == PG_INT64_MIN)
{
memcpy(a, "-9223372036854775808", 21);
return;
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index 33e859d35e..86a014a2bb 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -3309,7 +3309,7 @@ interval_mul(PG_FUNCTION_ARGS)
result->day += (int32) month_remainder_days;
#ifdef HAVE_INT64_TIMESTAMP
result_double = rint(span->time * factor + sec_remainder * USECS_PER_SEC);
- if (result_double > INT64_MAX || result_double < INT64_MIN)
+ if (result_double > PG_INT64_MAX || result_double < PG_INT64_MIN)
ereport(ERROR,
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
errmsg("interval out of range")));
diff --git a/src/backend/utils/adt/txid.c b/src/backend/utils/adt/txid.c
index 31f8033ae4..1d7bb02ca4 100644
--- a/src/backend/utils/adt/txid.c
+++ b/src/backend/utils/adt/txid.c
@@ -34,7 +34,7 @@
/* txid will be signed int8 in database, so must limit to 63 bits */
-#define MAX_TXID ((uint64) INT64_MAX)
+#define MAX_TXID ((uint64) PG_INT64_MAX)
/* Use unsigned variant internally */
typedef uint64 txid;