Thread: Backward compatibility patch for numutils.c

Backward compatibility patch for numutils.c

From
"Markus Wollny"
Date:
Hi!

We're using some "hardwired" apps which try to insert '' in INT-fields when what they really mean is NULL. 7.2 wasn't
botheredby 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
findit now, however I have reposted his patch there:
http://groups.google.de/groups?hl=de&lr=&ie=UTF-8&selm=2266D0630E43BB4290742247C89105750393D53E%40dozer.computec.de

Now the relevant bit has slightly changed in 7.4.x and I wonder what else would be affected when applying the same
thinghere; 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
69,74c69,74
<       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.3in 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

Re: Backward compatibility patch for numutils.c

From
"Markus Wollny"
Date:
Hi!

Can noone give me any advice on whether to use this backward compatibility patch or not? I'm not a PG-hacker, so some
bettereducated opinions would be very welcome. Thank you! 

Kind regards,

  Markus


-----Original Message-----
From:    pgsql-general-owner@postgresql.org on behalf of Markus Wollny
Sent:    Wed 6/30/2004 20:05
To:    pgsql-general@postgresql.org
Cc:
Subject:    [GENERAL] Backward compatibility patch for numutils.c
Hi!

We're using some "hardwired" apps which try to insert '' in INT-fields when what they really mean is NULL. 7.2 wasn't
botheredby 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
findit now, however I have reposted his patch there:
http://groups.google.de/groups?hl=de&lr=&ie=UTF-8&selm=2266D0630E43BB4290742247C89105750393D53E%40dozer.computec.de

Now the relevant bit has slightly changed in 7.4.x and I wonder what else would be affected when applying the same
thinghere; 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
69,74c69,74
<       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.3in 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

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@postgresql.org so that your
      message can get through to the mailing list cleanly





Re: Backward compatibility patch for numutils.c

From
Jan Wieck
Date:
On 7/4/2004 5:18 PM, Markus Wollny wrote:

> Hi!
>
> Can noone give me any advice on whether to use this backward compatibility patch or not? I'm not a PG-hacker, so some
bettereducated opinions would be very welcome. Thank you! 

7.2 is over 2 years old. 7.3 1.5 years. If you don't have the sourcecode
for those "hardwired" apps, then it seems to me that the vendor must
have lost the sourcecode as well. My advice: think about what happens if
you hit a really serious bug in that application where no workaround by
screwing with the DB system will help any more.


Jan

>
> Kind regards,
>
>   Markus
>
>
> -----Original Message-----
> From:    pgsql-general-owner@postgresql.org on behalf of Markus Wollny
> Sent:    Wed 6/30/2004 20:05
> To:    pgsql-general@postgresql.org
> Cc:
> Subject:    [GENERAL] Backward compatibility patch for numutils.c
> Hi!
>
> We're using some "hardwired" apps which try to insert '' in INT-fields when what they really mean is NULL. 7.2 wasn't
botheredby 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
findit now, however I have reposted his patch there:
http://groups.google.de/groups?hl=de&lr=&ie=UTF-8&selm=2266D0630E43BB4290742247C89105750393D53E%40dozer.computec.de
>
> Now the relevant bit has slightly changed in 7.4.x and I wonder what else would be affected when applying the same
thinghere; 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
> 69,74c69,74
> <       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.3in 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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faqs/FAQ.html


--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #