提交 54a8af05 编写于 作者: T Tom Lane

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.
上级 9f53cfd9
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/backend/libpq/pqformat.c,v 1.37 2004/12/31 21:59:50 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/libpq/pqformat.c,v 1.38 2005/09/24 15:34:07 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -501,8 +501,12 @@ pq_getmsgint64(StringInfo msg) ...@@ -501,8 +501,12 @@ pq_getmsgint64(StringInfo msg)
l32 = ntohl(l32); l32 = ntohl(l32);
#ifdef INT64_IS_BUSTED #ifdef INT64_IS_BUSTED
/* just lose the high half */ /* error out if incoming value is wider than 32 bits */
result = l32; 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 #else
result = h32; result = h32;
result <<= 32; result <<= 32;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册