Hi

After I upgraded 7.2.3 to 7.3 I started to get the following errors:
pg_atoi: zero-length string

its seems that i get it when not all field have content:

this is one example that generate the error:
insert into images (section_id, pic_date, image_order) values ('8',
'2002-12-03', '')


Tue, 3 Dec 2002 12:24:33 +0200
"Ben-Nes Michael" <miki@canaan.co.il>
7.3 -> pg_atoi: zero-length string
Hi, one of the changes in 7.3 was to disallow '' being implicitly
converted to 0. In your example below image_order is clearly not a
text/char column, so what are you trying to set it too? If you want it
be 0 then explicitly use 0, if you want it to be undefined then use
NULL.

Lee.

Ben-Nes Michael writes:
 > Hi
 > 
 > After I upgraded 7.2.3 to 7.3 I started to get the following errors:
 > pg_atoi: zero-length string
 > 
 > its seems that i get it when not all field have content:
 > 
 > this is one example that generate the error:
 > insert into images (section_id, pic_date, image_order) values ('8',
 > '2002-12-03', '')
 > 
 > 
 > ---------------------------(end of broadcast)---------------------------
 > TIP 2: you can get off all lists at once with the unregister command
 >     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

Tue, 3 Dec 2002 10:37:48 +0000
Lee Kindness <lkindness@csl.co.uk>
7.3 -> pg_atoi: zero-length string
That's indeed very nice but I don't see the logic in it.

If I want to upgrade I need to go on all my projects and change thousands of
lines.

And that's not all :(
I have other applications like phprojekt that was not developed by me and
became useless now as I cant insert.

Was this step so necessary ?

----- Original Message -----
From: "Lee Kindness" <lkindness@csl.co.uk>
To: "Ben-Nes Michael" <miki@canaan.co.il>
Cc: "postgresql" <pgsql-general@postgresql.org>; "Lee Kindness"
<lkindness@csl.co.uk>
Sent: Tuesday, December 03, 2002 12:37 PM
Subject: [GENERAL] 7.3 -> pg_atoi: zero-length string


> Hi, one of the changes in 7.3 was to disallow '' being implicitly
> converted to 0. In your example below image_order is clearly not a
> text/char column, so what are you trying to set it too? If you want it
> be 0 then explicitly use 0, if you want it to be undefined then use
> NULL.
>
> Lee.
>
> Ben-Nes Michael writes:
>  > Hi
>  >
>  > After I upgraded 7.2.3 to 7.3 I started to get the following errors:
>  > pg_atoi: zero-length string
>  >
>  > its seems that i get it when not all field have content:
>  >
>  > this is one example that generate the error:
>  > insert into images (section_id, pic_date, image_order) values ('8',
>  > '2002-12-03', '')
>  >
>  >
>  > ---------------------------(end of
broadcast)---------------------------
>  > TIP 2: you can get off all lists at once with the unregister command
>  >     (send "unregister YourEmailAddressHere" to
majordomo@postgresql.org)
>


Tue, 3 Dec 2002 12:50:41 +0200
"Ben-Nes Michael" <miki@canaan.co.il>
Re: 7.3 -> pg_atoi: zero-length string
Was it necessary? No idea, you're welcome to search through the
pgsql-hackers archives to determine the reasoning behind the change. I
believe the change was made by Bruce Momjian (going by the release
notes). I only remember reading the discussion in passing.

This is also one of the reasons for beta releases - to allow people to
test against the new version and pick up these sort of things. Either
this gives them/you time to make changes, or to lobby to get the old
behaviour back.

If I were in your situation i'd probably hack back the old behaviour
to 7.3, compile and run that while changes were made. Or stick with
7.2.x until changes were made to your applications, have you got a
'big carrot' for going with 7.3?

Lee.

Ben-Nes Michael writes:
 > That's indeed very nice but I don't see the logic in it.
 > 
 > If I want to upgrade I need to go on all my projects and change thousands of
 > lines.
 > 
 > And that's not all :(
 > I have other applications like phprojekt that was not developed by me and
 > became useless now as I cant insert.
 > 
 > Was this step so necessary ?
 > 
 > ----- Original Message -----
 > From: "Lee Kindness" <lkindness@csl.co.uk>
 > To: "Ben-Nes Michael" <miki@canaan.co.il>
 > Cc: "postgresql" <pgsql-general@postgresql.org>; "Lee Kindness"
 > <lkindness@csl.co.uk>
 > Sent: Tuesday, December 03, 2002 12:37 PM
 > Subject: [GENERAL] 7.3 -> pg_atoi: zero-length string
 > 
 > > Hi, one of the changes in 7.3 was to disallow '' being implicitly
 > > converted to 0. In your example below image_order is clearly not a
 > > text/char column, so what are you trying to set it too? If you want it
 > > be 0 then explicitly use 0, if you want it to be undefined then use
 > > NULL.
 > >
 > > Lee.
 > >
 > > Ben-Nes Michael writes:
 > >  > Hi
 > >  >
 > >  > After I upgraded 7.2.3 to 7.3 I started to get the following errors:
 > >  > pg_atoi: zero-length string
 > >  >
 > >  > its seems that i get it when not all field have content:
 > >  >
 > >  > this is one example that generate the error:
 > >  > insert into images (section_id, pic_date, image_order) values ('8',
 > >  > '2002-12-03', '')

Tue, 3 Dec 2002 11:08:38 +0000
Lee Kindness <lkindness@csl.co.uk>
Re: 7.3 -> pg_atoi: zero-length string

The change was made to tighten up the code to catch errors sooner. 
There isn't much logic to making '' be 0, and no one could make a case
for keeping such a mapping.

---------------------------------------------------------------------------

Lee Kindness wrote:
> Was it necessary? No idea, you're welcome to search through the
> pgsql-hackers archives to determine the reasoning behind the change. I
> believe the change was made by Bruce Momjian (going by the release
> notes). I only remember reading the discussion in passing.
> 
> This is also one of the reasons for beta releases - to allow people to
> test against the new version and pick up these sort of things. Either
> this gives them/you time to make changes, or to lobby to get the old
> behaviour back.
> 
> If I were in your situation i'd probably hack back the old behaviour
> to 7.3, compile and run that while changes were made. Or stick with
> 7.2.x until changes were made to your applications, have you got a
> 'big carrot' for going with 7.3?
> 
> Lee.
> 
> Ben-Nes Michael writes:
>  > That's indeed very nice but I don't see the logic in it.
>  > 
>  > If I want to upgrade I need to go on all my projects and change thousands of
>  > lines.
>  > 
>  > And that's not all :(
>  > I have other applications like phprojekt that was not developed by me and
>  > became useless now as I cant insert.
>  > 
>  > Was this step so necessary ?
>  > 
>  > ----- Original Message -----
>  > From: "Lee Kindness" <lkindness@csl.co.uk>
>  > To: "Ben-Nes Michael" <miki@canaan.co.il>
>  > Cc: "postgresql" <pgsql-general@postgresql.org>; "Lee Kindness"
>  > <lkindness@csl.co.uk>
>  > Sent: Tuesday, December 03, 2002 12:37 PM
>  > Subject: [GENERAL] 7.3 -> pg_atoi: zero-length string
>  > 
>  > > Hi, one of the changes in 7.3 was to disallow '' being implicitly
>  > > converted to 0. In your example below image_order is clearly not a
>  > > text/char column, so what are you trying to set it too? If you want it
>  > > be 0 then explicitly use 0, if you want it to be undefined then use
>  > > NULL.
>  > >
>  > > Lee.
>  > >
>  > > Ben-Nes Michael writes:
>  > >  > Hi
>  > >  >
>  > >  > After I upgraded 7.2.3 to 7.3 I started to get the following errors:
>  > >  > pg_atoi: zero-length string
>  > >  >
>  > >  > its seems that i get it when not all field have content:
>  > >  >
>  > >  > this is one example that generate the error:
>  > >  > insert into images (section_id, pic_date, image_order) values ('8',
>  > >  > '2002-12-03', '')
> 

-- 
  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

Tue, 3 Dec 2002 11:08:50 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: 7.3 -> pg_atoi: zero-length string
Then Why not set it to NULL

Seems logic as there is nothing between ''

What is the solution of other dbs ( oracle, db2 .. ) to:
insert into table (num) value (''); ?

Who knows how many application will suffer becouse of this.

----- Original Message -----
From: "Bruce Momjian" <pgman@candle.pha.pa.us>
To: "Lee Kindness" <lkindness@csl.co.uk>
Cc: "Ben-Nes Michael" <miki@canaan.co.il>; "postgresql"
<pgsql-general@postgresql.org>; <pgsql-hackers@postgresql.org>
Sent: Tuesday, December 03, 2002 6:08 PM
Subject: Re: [GENERAL] 7.3 -> pg_atoi: zero-length string


>
> The change was made to tighten up the code to catch errors sooner.
> There isn't much logic to making '' be 0, and no one could make a case
> for keeping such a mapping.
>
> --------------------------------------------------------------------------
-
>
> Lee Kindness wrote:
> > Was it necessary? No idea, you're welcome to search through the
> > pgsql-hackers archives to determine the reasoning behind the change. I
> > believe the change was made by Bruce Momjian (going by the release
> > notes). I only remember reading the discussion in passing.
> >
> > This is also one of the reasons for beta releases - to allow people to
> > test against the new version and pick up these sort of things. Either
> > this gives them/you time to make changes, or to lobby to get the old
> > behaviour back.
> >
> > If I were in your situation i'd probably hack back the old behaviour
> > to 7.3, compile and run that while changes were made. Or stick with
> > 7.2.x until changes were made to your applications, have you got a
> > 'big carrot' for going with 7.3?
> >
> > Lee.
> >
> > Ben-Nes Michael writes:
> >  > That's indeed very nice but I don't see the logic in it.
> >  >
> >  > If I want to upgrade I need to go on all my projects and change
thousands of
> >  > lines.
> >  >
> >  > And that's not all :(
> >  > I have other applications like phprojekt that was not developed by me
and
> >  > became useless now as I cant insert.
> >  >
> >  > Was this step so necessary ?
> >  >
> >  > ----- Original Message -----
> >  > From: "Lee Kindness" <lkindness@csl.co.uk>
> >  > To: "Ben-Nes Michael" <miki@canaan.co.il>
> >  > Cc: "postgresql" <pgsql-general@postgresql.org>; "Lee Kindness"
> >  > <lkindness@csl.co.uk>
> >  > Sent: Tuesday, December 03, 2002 12:37 PM
> >  > Subject: [GENERAL] 7.3 -> pg_atoi: zero-length string
> >  >
> >  > > Hi, one of the changes in 7.3 was to disallow '' being implicitly
> >  > > converted to 0. In your example below image_order is clearly not a
> >  > > text/char column, so what are you trying to set it too? If you want
it
> >  > > be 0 then explicitly use 0, if you want it to be undefined then use
> >  > > NULL.
> >  > >
> >  > > Lee.
> >  > >
> >  > > Ben-Nes Michael writes:
> >  > >  > Hi
> >  > >  >
> >  > >  > After I upgraded 7.2.3 to 7.3 I started to get the following
errors:
> >  > >  > pg_atoi: zero-length string
> >  > >  >
> >  > >  > its seems that i get it when not all field have content:
> >  > >  >
> >  > >  > this is one example that generate the error:
> >  > >  > insert into images (section_id, pic_date, image_order) values
('8',
> >  > >  > '2002-12-03', '')
> >
>
> --
>   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
>


Tue, 3 Dec 2002 18:14:34 +0200
"Ben-Nes Michael" <miki@canaan.co.il>
Re: 7.3 -> pg_atoi: zero-length string
Ben-Nes Michael wrote:
> Then Why not set it to NULL

Well, it is not NULL, though, it is ''.  They are not the same in
strings (though for some dbms's they are), so I don't see why we would
do that for numerics.

> Seems logic as there is nothing between ''
> 
> What is the solution of other dbs ( oracle, db2 .. ) to:
> insert into table (num) value (''); ?

I assume they would fail too.

> Who knows how many application will suffer becouse of this.

Yours is the first, or perhaps second to bring up this issue.
I am sure it is a pain, but it does tighten up some cases where we were
silently mapping '' to 0, and we don't exactly have a flood of problem
reports.

-- 
  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

Tue, 3 Dec 2002 11:21:04 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: 7.3 -> pg_atoi: zero-length string
I don't think many will be caught-out, since it's an overwhelmingly
daft thing to do anyway!

If you've got a numeric type column then assign numeric values to, not
strings. Or explicitly convert.

I'm sure all occurrences of this "in the wild" are due to sloppy
SQL...

For the record:

 lkind@coulin:~% sql -uingres iidbdb
 INGRES TERMINAL MONITOR Copyright (c) 1981, 1997 Computer Associates Intl, Inc.
 OpenIngres SPARC SOLARIS Version OI 2.0/9712 (su4.us5/00) login
 Tue Dec  3 16:17:27 2002

 continue
 * create table test(f1 int);\g
 Executing . . .

 continue
 * insert into test(f1) values('');\g
 Executing . . .

 E_US0B61 line 1, You cannot assign  a value of type 'varchar' to a column
     of type 'integer'. Explicitly convert the value to the required type.
     (Tue Dec  3 16:18:22 2002)
 continue

 * select int4('');\g
 Executing . . .
  col1
  0
 (1 row)
 continue

Lee.

Ben-Nes Michael writes:
 > Then Why not set it to NULL
 > 
 > Seems logic as there is nothing between ''
 > 
 > What is the solution of other dbs ( oracle, db2 .. ) to:
 > insert into table (num) value (''); ?
 > 
 > Who knows how many application will suffer becouse of this.
 > 
 > ----- Original Message -----
 > From: "Bruce Momjian" <pgman@candle.pha.pa.us>
 > To: "Lee Kindness" <lkindness@csl.co.uk>
 > Cc: "Ben-Nes Michael" <miki@canaan.co.il>; "postgresql"
 > <pgsql-general@postgresql.org>; <pgsql-hackers@postgresql.org>
 > Sent: Tuesday, December 03, 2002 6:08 PM
 > Subject: Re: [GENERAL] 7.3 -> pg_atoi: zero-length string
 > 
 > > The change was made to tighten up the code to catch errors sooner.
 > > There isn't much logic to making '' be 0, and no one could make a case
 > > for keeping such a mapping.
 > >
 > > --------------------------------------------------------------------------
 > -
 > >
 > > Lee Kindness wrote:
 > > > Was it necessary? No idea, you're welcome to search through the
 > > > pgsql-hackers archives to determine the reasoning behind the change. I
 > > > believe the change was made by Bruce Momjian (going by the release
 > > > notes). I only remember reading the discussion in passing.
 > > >
 > > > This is also one of the reasons for beta releases - to allow people to
 > > > test against the new version and pick up these sort of things. Either
 > > > this gives them/you time to make changes, or to lobby to get the old
 > > > behaviour back.
 > > >
 > > > If I were in your situation i'd probably hack back the old behaviour
 > > > to 7.3, compile and run that while changes were made. Or stick with
 > > > 7.2.x until changes were made to your applications, have you got a
 > > > 'big carrot' for going with 7.3?
 > > >
 > > > Lee.
 > > >
 > > > Ben-Nes Michael writes:
 > > >  > That's indeed very nice but I don't see the logic in it.
 > > >  >
 > > >  > If I want to upgrade I need to go on all my projects and change
 > thousands of
 > > >  > lines.
 > > >  >
 > > >  > And that's not all :(
 > > >  > I have other applications like phprojekt that was not developed by me
 > and
 > > >  > became useless now as I cant insert.
 > > >  >
 > > >  > Was this step so necessary ?
 > > >  >
 > > >  > ----- Original Message -----
 > > >  > From: "Lee Kindness" <lkindness@csl.co.uk>
 > > >  > To: "Ben-Nes Michael" <miki@canaan.co.il>
 > > >  > Cc: "postgresql" <pgsql-general@postgresql.org>; "Lee Kindness"
 > > >  > <lkindness@csl.co.uk>
 > > >  > Sent: Tuesday, December 03, 2002 12:37 PM
 > > >  > Subject: [GENERAL] 7.3 -> pg_atoi: zero-length string
 > > >  >
 > > >  > > Hi, one of the changes in 7.3 was to disallow '' being implicitly
 > > >  > > converted to 0. In your example below image_order is clearly not a
 > > >  > > text/char column, so what are you trying to set it too? If you want
 > it
 > > >  > > be 0 then explicitly use 0, if you want it to be undefined then use
 > > >  > > NULL.
 > > >  > >
 > > >  > > Lee.
 > > >  > >
 > > >  > > Ben-Nes Michael writes:
 > > >  > >  > Hi
 > > >  > >  >
 > > >  > >  > After I upgraded 7.2.3 to 7.3 I started to get the following
 > errors:
 > > >  > >  > pg_atoi: zero-length string
 > > >  > >  >
 > > >  > >  > its seems that i get it when not all field have content:
 > > >  > >  >
 > > >  > >  > this is one example that generate the error:
 > > >  > >  > insert into images (section_id, pic_date, image_order) values
 > ('8',
 > > >  > >  > '2002-12-03', '')
 > > >
 > >

Tue, 3 Dec 2002 16:28:24 +0000
Lee Kindness <lkindness@csl.co.uk>
Re: 7.3 -> pg_atoi: zero-length string


--On Tuesday, December 03, 2002 11:21:04 -0500 Bruce Momjian 
<pgman@candle.pha.pa.us> wrote:

> Ben-Nes Michael wrote:
>> Then Why not set it to NULL
>
> Well, it is not NULL, though, it is ''.  They are not the same in
> strings (though for some dbms's they are), so I don't see why we would
> do that for numerics.
>
>> Seems logic as there is nothing between ''
>>
>> What is the solution of other dbs ( oracle, db2 .. ) to:
>> insert into table (num) value (''); ?
>
> I assume they would fail too.
>
>> Who knows how many application will suffer becouse of this.
>
> Yours is the first, or perhaps second to bring up this issue.
> I am sure it is a pain, but it does tighten up some cases where we were
> silently mapping '' to 0, and we don't exactly have a flood of problem
> reports.
He's at least the 2nd.  I have one, that I've complained to the 
PHPGroupware folks (which
BREAKS severely with this change).

LER

>
> --
>   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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>



-- 
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749




Tue, 03 Dec 2002 10:34:19 -0600
Larry Rosenman <ler@lerctr.org>
Re: [HACKERS] 7.3 -> pg_atoi: zero-length string
Bruce Momjian wrote:
> Ben-Nes Michael wrote:
> 
>>Then Why not set it to NULL
> 
> Well, it is not NULL, though, it is ''.  They are not the same in
> strings (though for some dbms's they are), so I don't see why we would
> do that for numerics.
> 
>>Seems logic as there is nothing between ''
>>
>>What is the solution of other dbs ( oracle, db2 .. ) to:
>>insert into table (num) value (''); ?
> 
> I assume they would fail too.

Oracle doesn't fail because it converts an empty string into 
NULL. So the insert succeeds if the column lacked a NOT NULL 
constraint. But Oracle's treatment of empty strings as NULL *is 
insane*. Not sure about DB2...

Mike Mascari
mascarm@mascari.com



Tue, 03 Dec 2002 11:40:09 -0500
Mike Mascari <mascarm@mascari.com>
Re: 7.3 -> pg_atoi: zero-length string

Hi,
 | > What is the solution of other dbs ( oracle, db2 .. ) to:
 | > insert into table (num) value (''); ? | 
 | I assume they would fail too.

The Oracle behaviour is:
---
oracle> create table foonum (x number(5));
oracle> insert into foonum values ('');
oracle> select * from foonum;
--------+
   X    |
--------+
 [NULL] |
--------+
---

so, '' as numeric value is regarded as NULL. But Oracle 
braindeadly interprets the varchar '' as well as NULL in a varchar 
column so is probably not paragon ...

IMHO, if PostgreSQL is to support an empty string for numerics at all, 
then it should be interpreted as not-a-value and as such as NULL. 
Interpreting it as numeric value '0' could lead to subtle bugs since this 
would probably not the expected behaviour (at least not mine).
The number '0' is arbitrary, except that we happend to start counting with 
it. Someone else could argue why not interpret  not-a-value as '1' 
(non-computer guys tend to start counting with '1') or even '42' (since 
this is the answer to everything).

I personally would be prefer to raise an error on an empty string; but 
interpreting it as NULL would be reasonable as well. But interpreting it 
as '0' will yield many unseen programming errors and should be avoided.

my 2cent,
 -hen


Tue, 3 Dec 2002 18:07:52 +0100 (CET)
Henner Zeller <henner@freiheit.com>
Re: [GENERAL] 7.3 -> pg_atoi: zero-length string

If we had received more complaints about the change during beta, we
would have added a mention that the change would be in 7.4.  As we got
few complaints, the change went into 7.3, and it is mentioned in the
porting section of the release notes (last item):

     * An empty string ('') is no longer allowed as the input into an
       integer field. Formerly, it was silently interpreted as 0.

---------------------------------------------------------------------------

Larry Rosenman wrote:
> 
> 
> --On Tuesday, December 03, 2002 11:21:04 -0500 Bruce Momjian 
> <pgman@candle.pha.pa.us> wrote:
> 
> > Ben-Nes Michael wrote:
> >> Then Why not set it to NULL
> >
> > Well, it is not NULL, though, it is ''.  They are not the same in
> > strings (though for some dbms's they are), so I don't see why we would
> > do that for numerics.
> >
> >> Seems logic as there is nothing between ''
> >>
> >> What is the solution of other dbs ( oracle, db2 .. ) to:
> >> insert into table (num) value (''); ?
> >
> > I assume they would fail too.
> >
> >> Who knows how many application will suffer becouse of this.
> >
> > Yours is the first, or perhaps second to bring up this issue.
> > I am sure it is a pain, but it does tighten up some cases where we were
> > silently mapping '' to 0, and we don't exactly have a flood of problem
> > reports.
> He's at least the 2nd.  I have one, that I've complained to the 
> PHPGroupware folks (which
> BREAKS severely with this change).
> 
> LER
> 
> >
> > --
> >   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
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 4: Don't 'kill -9' the postmaster
> >
> 
> 
> 
> -- 
> Larry Rosenman                     http://www.lerctr.org/~ler
> Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
> US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
> 
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
> 

-- 
  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

Tue, 3 Dec 2002 12:12:12 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: [HACKERS] 7.3 -> pg_atoi: zero-length string
Well I already fixed all my application, it was quiet easy though more code
was entered :(

like:

if ( !is_numeric($var) )
    $var = 0;

I hope the other projects will fix compliance fast.

maybe this feature should be enabled when compiling ?


----- Original Message -----
From: "Bruce Momjian" <pgman@candle.pha.pa.us>
To: "Larry Rosenman" <ler@lerctr.org>
Cc: "Ben-Nes Michael" <miki@canaan.co.il>; "Lee Kindness"
<lkindness@csl.co.uk>; "postgresql" <pgsql-general@postgresql.org>;
<pgsql-hackers@postgresql.org>
Sent: Tuesday, December 03, 2002 7:12 PM
Subject: Re: [HACKERS] [GENERAL] 7.3 -> pg_atoi: zero-length string


>
> If we had received more complaints about the change during beta, we
> would have added a mention that the change would be in 7.4.  As we got
> few complaints, the change went into 7.3, and it is mentioned in the
> porting section of the release notes (last item):
>
>      * An empty string ('') is no longer allowed as the input into an
>        integer field. Formerly, it was silently interpreted as 0.
>
> --------------------------------------------------------------------------
-
>
> Larry Rosenman wrote:
> >
> >
> > --On Tuesday, December 03, 2002 11:21:04 -0500 Bruce Momjian
> > <pgman@candle.pha.pa.us> wrote:
> >
> > > Ben-Nes Michael wrote:
> > >> Then Why not set it to NULL
> > >
> > > Well, it is not NULL, though, it is ''.  They are not the same in
> > > strings (though for some dbms's they are), so I don't see why we would
> > > do that for numerics.
> > >
> > >> Seems logic as there is nothing between ''
> > >>
> > >> What is the solution of other dbs ( oracle, db2 .. ) to:
> > >> insert into table (num) value (''); ?
> > >
> > > I assume they would fail too.
> > >
> > >> Who knows how many application will suffer becouse of this.
> > >
> > > Yours is the first, or perhaps second to bring up this issue.
> > > I am sure it is a pain, but it does tighten up some cases where we
were
> > > silently mapping '' to 0, and we don't exactly have a flood of problem
> > > reports.
> > He's at least the 2nd.  I have one, that I've complained to the
> > PHPGroupware folks (which
> > BREAKS severely with this change).
> >
> > LER
> >
> > >
> > > --
> > >   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
> > >
> > > ---------------------------(end of
broadcast)---------------------------
> > > TIP 4: Don't 'kill -9' the postmaster
> > >
> >
> >
> >
> > --
> > Larry Rosenman                     http://www.lerctr.org/~ler
> > Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
> > US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
> >
> >
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 4: Don't 'kill -9' the postmaster
> >
>
> --
>   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
>


Tue, 3 Dec 2002 19:17:08 +0200
"Ben-Nes Michael" <miki@canaan.co.il>
Re: [HACKERS] 7.3 -> pg_atoi: zero-length string
I don't have 7.3 installed, just wondering...

What do the following do in PostgreSQL 7.3?

SELECT int4('');
SELECT CAST('' AS int4);

G.
--
while (!asleep()) sheep++;

---------------------------- cut here ------------------------------
----- Original Message -----
From: "Ben-Nes Michael" <miki@canaan.co.il>
Sent: Tuesday, December 03, 2002 6:17 PM


> Well I already fixed all my application, it was quiet easy though more
code
> was entered :(
>
> like:
>
> if ( !is_numeric($var) )
>     $var = 0;
>
> I hope the other projects will fix compliance fast.
>
> maybe this feature should be enabled when compiling ?



Tue, 3 Dec 2002 19:28:12 +0100
=?iso-8859-1?Q?SZUCS_G=E1bor?= <surrano@mailbox.hu>
Re: 7.3 -> pg_atoi: zero-length string
Same as in the INSERT case:

 iidbdb=# SELECT version();
                           version                          
 -----------------------------------------------------------
  PostgreSQL 7.3 on i686-pc-linux-gnu, compiled by GCC 2.96
 (1 row)
 
 iidbdb=# SELECT int4('');
 ERROR:  pg_atoi: zero-length string
 iidbdb=# SELECT CAST('' AS int4);
 ERROR:  pg_atoi: zero-length string

Lee.

SZUCS Gábor writes:
 > I don't have 7.3 installed, just wondering...
 > 
 > What do the following do in PostgreSQL 7.3?
 > 
 > SELECT int4('');
 > SELECT CAST('' AS int4);
 > 
 > G.
 > --
 > while (!asleep()) sheep++;
 > 
 > ---------------------------- cut here ------------------------------
 > ----- Original Message -----
 > From: "Ben-Nes Michael" <miki@canaan.co.il>
 > Sent: Tuesday, December 03, 2002 6:17 PM
 > 
 > 
 > > Well I already fixed all my application, it was quiet easy though more
 > code
 > > was entered :(
 > >
 > > like:
 > >
 > > if ( !is_numeric($var) )
 > >     $var = 0;
 > >
 > > I hope the other projects will fix compliance fast.
 > >
 > > maybe this feature should be enabled when compiling ?

Tue, 3 Dec 2002 18:31:33 +0000
Lee Kindness <lkindness@csl.co.uk>
Re: 7.3 -> pg_atoi: zero-length string