Skip to content

Commit 54a8af0

Browse files
committed
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.
1 parent 9f53cfd commit 54a8af0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/backend/libpq/pqformat.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
2525
* Portions Copyright (c) 1994, Regents of the University of California
2626
*
27-
* $PostgreSQL: pgsql/src/backend/libpq/pqformat.c,v 1.37 2004/12/31 21:59:50 pgsql Exp $
27+
* $PostgreSQL: pgsql/src/backend/libpq/pqformat.c,v 1.38 2005/09/24 15:34:07 tgl Exp $
2828
*
2929
*-------------------------------------------------------------------------
3030
*/
@@ -501,8 +501,12 @@ pq_getmsgint64(StringInfo msg)
501501
l32 = ntohl(l32);
502502

503503
#ifdef INT64_IS_BUSTED
504-
/* just lose the high half */
504+
/* error out if incoming value is wider than 32 bits */
505505
result = l32;
506+
if ((result < 0) ? (h32 != -1) : (h32 != 0))
507+
ereport(ERROR,
508+
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
509+
errmsg("binary value is out of range for type bigint")));
506510
#else
507511
result = h32;
508512
result <<= 32;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy