Re: pg7.3.4: pg_atoi: zero-length string

From: "Markus Wollny" <Markus(dot)Wollny(at)computec(dot)de>
To: "Andrew Sullivan" <andrew(at)libertyrms(dot)info>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: pg7.3.4: pg_atoi: zero-length string
Date: 2003-11-04 11:46:44
Message-ID: 2266D0630E43BB4290742247C89105750393D53E@dozer.computec.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Ursprüngliche Nachricht-----
> Von: Andrew Sullivan [mailto:andrew(at)libertyrms(dot)info]
> Gesendet: Dienstag, 4. November 2003 12:32
> An: pgsql-general(at)postgresql(dot)org
> Betreff: Re: [GENERAL] pg7.3.4: pg_atoi: zero-length string
>
>
> On Tue, Nov 04, 2003 at 11:21:35AM +0000, Rob Fielding wrote:
> > We're currently experiencing a problem where SQL statements
> are failing
> > when entring a '' for not not-null integer columns:
>
> Yes. This behaviour was made more compliant in 7.3. It's in the
> release notes.
[snip]
> You could probably put in a rewrite rule to convert '' to NULL and
> allow nulls on the column. It's the only suggestion I can think of,
> short of going back to 7.2.

No, there's actually another option. Bruce posted a patch for reverting
to 7.2-behaviour (well, sort of...); I currently cannot find the
original message, but here's the relevant bit:

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania
19073

--ELM1040320327-20624-0_
Content-Transfer-Encoding: 7bit
Content-Type: text/plain
Content-Disposition: inline; filename="/bjm/diff"

Index: src/backend/utils/adt/numutils.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/adt/numutils.c,v
retrieving revision 1.54
diff -c -c -r1.54 numutils.c
*** src/backend/utils/adt/numutils.c 4 Sep 2002 20:31:28 -0000 1.54
--- src/backend/utils/adt/numutils.c 19 Dec 2002 17:10:56 -0000
***************
*** 70,76 ****
if (s == (char *) NULL)
elog(ERROR, "pg_atoi: NULL pointer");
else if (*s == 0)
! elog(ERROR, "pg_atoi: zero-length string");
else
l = strtol(s, &badp, 10);

--- 70,80 ----
if (s == (char *) NULL)
elog(ERROR, "pg_atoi: NULL pointer");
else if (*s == 0)
! {
! /* 7.3.X workaround for broken apps, bjm 2002-12-19 */
! elog(WARNING, "pg_atoi: zero-length string");
! l = (long) 0;
! }
else
l = strtol(s, &badp, 10);

--ELM1040320327-20624-0_
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0

Note however, that regression tests for 7.3.x will fail, as there are
explicit tests for zero-length strings to cause an error. That need not
worry you, though. We're currently running 7.3.4 with this patch and it
works like a charm.

Regards,

Markus

>

Browse pgsql-general by date

  From Date Subject
Next Message Victor Spång Arthursson 2003-11-04 12:10:16 Very strange selectproblem
Previous Message Andrew Sullivan 2003-11-04 11:32:22 Re: pg7.3.4: pg_atoi: zero-length string