summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2005-09-24 15:34:07 +0000
committerTom Lane2005-09-24 15:34:07 +0000
commitabbe05e681f7d54190a0902e96cd3917f6806b51 (patch)
tree7908b604902158289df86d07a907609be5327ba7
parent97a9e1fbfe7c4e56da9eee3dd3b49e3cb9df00d9 (diff)
In a machine where INT64_IS_BUSTED, we can only support 32-bit values
for int8 and related types. However we might be talking to a client that has working int64; so pq_getmsgint64 really needs to check the incoming value and throw an overflow error if we can't represent it accurately.
-rw-r--r--src/backend/libpq/pqformat.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/libpq/pqformat.c b/src/backend/libpq/pqformat.c
index 9db0b2d927..fb9db13ef9 100644
--- a/src/backend/libpq/pqformat.c
+++ b/src/backend/libpq/pqformat.c
@@ -501,8 +501,12 @@ pq_getmsgint64(StringInfo msg)
l32 = ntohl(l32);
#ifdef INT64_IS_BUSTED
- /* just lose the high half */
+ /* error out if incoming value is wider than 32 bits */
result = l32;
+ if ((result < 0) ? (h32 != -1) : (h32 != 0))
+ ereport(ERROR,
+ (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
+ errmsg("binary value is out of range for type bigint")));
#else
result = h32;
result <<= 32;