Re: pg7.3.4: pg_atoi: zero-length string
От | Markus Wollny |
---|---|
Тема | Re: pg7.3.4: pg_atoi: zero-length string |
Дата | |
Msg-id | 2266D0630E43BB4290742247C89105750393D53E@dozer.computec.de обсуждение исходный текст |
Ответ на | pg7.3.4: pg_atoi: zero-length string (Rob Fielding <rob@dsvr.net>) |
Список | pgsql-general |
> -----Ursprüngliche Nachricht----- > Von: Andrew Sullivan [mailto:andrew@libertyrms.info] > Gesendet: Dienstag, 4. November 2003 12:32 > An: pgsql-general@postgresql.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@candle.pha.pa.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 >
В списке pgsql-general по дате отправления: