Re: Damn bug!

From: JanWieck(at)t-online(dot)de (Jan Wieck)
To: Bernie Huang <bernie(dot)huang(at)ec(dot)gc(dot)ca>
Cc: PGSQL-BUGS <pgsql-bugs(at)postgresql(dot)org>, PHP list <php-general(at)lists(dot)php(dot)net>
Subject: Re: Damn bug!
Date: 2000-07-20 21:25:45
Message-ID: 200007202125.XAA06132@hot.jw.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Bernie Huang wrote:
[Charset iso-8859-15 unsupported, filtering to ASCII...]
> Hi,
>
> Sorry for the subject, but it is driving me crazy that I spend my entire
> morning searching for this little bug. =(
>
> Well, I found it.
>
> I have a field using array (eg; col1 text[]) in Postgres, and it's a
> list of attributes. (eg; {"hi","hello","whatever","Empty",...})
>
> When I tried to update elements in the array via PHP script,
>
> $query = "update table
> set col1[1]='$var1',
> col1[2]='$var2',
> ...
> col1[4]='$var4'";
>
> it worked alright; however, when it came to the word 'Empty', it just
> wouldn't update. So, after a lot of struggle... )xp ... I finally
> replaced the word 'Empty' with 'None' or something alike, and it worked!
>
> Although this is a rare case, I thought I would just share this with you
> so you won't get tripped over it. Don't know if it's a PHP bug or a
> Postgres bug!

A Postgres bug:

pgsql=# create table t1 (a text[]);
CREATE
pgsql=# insert into t1 values ('{"foo","bar"}');
INSERT 18872 1
pgsql=# select * from t1;
a
---------------
{"foo","bar"}
(1 row)

pgsql=# update t1 set a[1] = 'new', a[2] = 'Empty';
UPDATE 1
pgsql=# select * from t1;
a
---------------
{"new","bar"}
(1 row)

pgsql=# update t1 set a[1] = 'next', a[2] = 'None';
UPDATE 1
pgsql=# select * from t1;
a
-----------------
{"next","None"}
(1 row)

Don't know where this might happen, but it's interesting that
our ORDBMS treats some "text" literal special. Looks like a
fogotten hack somewhere :-)

Jan

--

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

In response to

  • Damn bug! at 2000-07-20 19:13:52 from Bernie Huang

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2000-07-21 06:03:39 Re: Damn bug!
Previous Message Andrew McMillan 2000-07-20 20:51:45 Re: Damn bug!