Re: [PATCH] Add error handling to byteaout.

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Andreas Seltenreich <andreas(dot)seltenreich(at)credativ(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Add error handling to byteaout.
Date: 2015-06-04 00:34:57
Message-ID: CAB7nPqRySWTbXXf2HTyxPM2bEevuXmiGUetkBMSer25qGj2jWg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jun 4, 2015 at 1:32 AM, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
wrote:

> Andreas Seltenreich wrote:
> > Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> >
> > > Andreas Seltenreich <andreas(dot)seltenreich(at)credativ(dot)de> writes:
> > >> The scary one is due to an integer overflow the attached patch also
> > >> fixes.
> > >
> > > s/int/Size/ doesn't fix anything on 32-bit machines.
> >
> > Well, it changes the signedness of the computation on 32-bit, and in
> > combination with the fact that "len" is always smaller than 2^32, but
> > may exceed 2^31-1, the change avoids the dependency on the undefined
> > behavior of signed integer overflows in C on 32-bit as well.
>
> Why not just use an unsigned 64 bit variable? Also, perhaps
> palloc_huge() avoids the whole problem in the first place ... though it
> might only move the issue around, if you cannot ship the longer-than-1GB
> resulting escaped value. (Of course, if you try to allocate 2 GB in a
> 32 bit machine, you're going to be having quite some fun ...)
>

Pure nitpicking: there is no palloc_huge, only repalloc_huge. Though we
could have one.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2015-06-04 02:02:45 Further issues with jsonb semantics, documentation
Previous Message Thomas Munro 2015-06-03 23:08:40 Re: [GENERAL] 9.4.1 -> 9.4.2 problem: could not access status of transaction 1