Skip site navigation (1) Skip section navigation (2)

Backward compatibility patch for numutils.c

From: "Markus Wollny" <Markus(dot)Wollny(at)computec(dot)de>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Backward compatibility patch for numutils.c
Date: 2004-06-30 18:05:17
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general

We're using some "hardwired" apps which try to insert '' in INT-fields when what they really mean is NULL. 7.2 wasn't bothered by this behaviour, but 7.3 was and it broke some apps then. So Bruce had posted a patch for 7.3's /src/backend/utils/adt/numutils.c - I couldn't find the original posting when someone asked some time ago and I cannot find it now, however I have reposted his patch there:

Now the relevant bit has slightly changed in 7.4.x and I wonder what else would be affected when applying the same thing here; I have made the same changes to the source of 7.4.3, resulting in the following diff:

diff numutils.c.patched numutils.c.orig 
<       else if (*s == 0) 
<            {
<               /* 7.4.X workaround for broken apps */
<               elog(WARNING, "pg_atoi: zero-length string");
<               l = (long) 0;
<              }        
>       if (*s == 0)
>               ereport(ERROR,
>                               (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
>                                errmsg("invalid input syntax for integer: \"%s\"",
>                                               s)));

It compiles fine, but I don't know if I'd shoot myself in the foot when actually using and trusting the thus patched 7.4.3 in a production environment. Any thoughts? Or can I put my mind at rest regardless? I know it's breaking the SQL-specs, but I'd rather have that than broken apps...

Kind regards

Markus Wollny

pgsql-general by date

Next:From: Dennis BjorklundDate: 2004-06-30 18:09:32
Subject: psql - list objects in a schema
Previous:From: Dennis GearonDate: 2004-06-30 17:05:30
Subject: Re: backups

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group