Re: trouble caused by change in 7.3 handling of '' in integer
От | Bruce Momjian |
---|---|
Тема | Re: trouble caused by change in 7.3 handling of '' in integer |
Дата | |
Msg-id | 200212191752.gBJHq7Y26864@candle.pha.pa.us обсуждение исходный текст |
Ответ на | Re: trouble caused by change in 7.3 handling of '' in integer (Vivek Khera <khera@kcilink.com>) |
Список | pgsql-general |
Vivek Khera wrote: > >>>>> "BM" == Bruce Momjian <pgman@candle.pha.pa.us> writes: > > BM> How about if I give you a patch against 7.3 that allows '' as 0, and you > BM> ask if the author can distribute it and get his code changed for 7.4? > > That would be great. Actually what would be best is if the code could > log a warning (with the full query) every time it happened, then it > would be easy to run the app for a while and find all the places it > happens. RT dynamically creates its queries so this would be the > easiest way to fix it up. Then RT could be fixed up and not need any > patches to PG. OK, patch attached and tested: test=> CREATE TABLE test(x int); CREATE TABLE test=> INSERT INTO test VALUES (''); WARNING: pg_atoi: zero-length string INSERT 140191 1 test=> SELECT x FROM test; x --- 0 (1 row) However, the regression tests will fail now because we explicitly test for '' to generate an error. I added my name, date, and purpose as a comment in the patched code. -- 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 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);
В списке pgsql-general по дате отправления: