Обсуждение: Re: [GENERAL] 7.3 -> pg_atoi: zero-length string

Поиск
Список
Период
Сортировка

Re: [GENERAL] 7.3 -> pg_atoi: zero-length string

От
Bruce Momjian
Дата:
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

Re: [GENERAL] 7.3 -> pg_atoi: zero-length string

От
Larry Rosenman
Дата:

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




Re: [GENERAL] 7.3 -> pg_atoi: zero-length string

От
Henner Zeller
Дата:
Hi,| > What is the solution of other dbs ( oracle, db2 .. ) to:| > insert into table (num) value (''); ? | | I assume
theywould 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



Re: [GENERAL] 7.3 -> pg_atoi: zero-length string

От
Bruce Momjian
Дата:
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