Thread: Problems with char array set to NULL

Problems with char array set to NULL

From
jlapham@gandalf.bioqmed.ufrj.br
Date:
Hello-

I've noticed a difference in the behavior between how v6.5.3 and v7.0.0
handle NULL assignments for char arrays (see below for the simple
example).  Maybe I should be using '{}' to nullify a char array instead of
NULL?  Either way, it would seem to me that the behavior with v7.0.0
should be the same as v6.5.3.  And, as you can see below, the response
from v7.0.0 is to terminate the connection to the db backend... which
seems severe.

I am running a variety of i686 linux systems (RedHat 6.2 with home rolled
v2.2.15 kernels), using src compiled Pg.  I have been able to duplicate
this behavior on a number of machines.

-Jon

PS: This is a re-send of a message I posted 5 days ago (~1 June) which
appears to not have made it to the list, probably due to something I
did.  If you received this message before, my apologies.

------------------------
v6.5.3:
template1=> create table a (id char[2]);
CREATE
template1=> insert into a (id) values (NULL);
INSERT 112733 1

------------------------
v7.0.0:
template1=# create table a (id char[2]);
CREATE
template1=# insert into a (id) values (NULL);
pqReadData() -- backend closed the channel unexpectedly.This probably means the backend terminated abnormallybefore or
whileprocessing the request.
 
The connection to the server was lost. Attempting reset: Failed.


-**-*-*---*-*---*-*---*-----*-*-----*---*-*---*-----*-----*-*-----*---Jon Lapham, PhDCentro Nacional de Ressonancia
MagneticaNuclear de MacromoleculasUniversidade Federal do Rio de Janeiro (UFRJ) - Brasilemail:
jlapham@gandalf.bioqmed.ufrj.br 
 
***-*--*----*-------*------------*--------------------*---------------


Re: Problems with char array set to NULL

From
Tom Lane
Date:
jlapham@gandalf.bioqmed.ufrj.br writes:
> v7.0.0:
> template1=# create table a (id char[2]);
> CREATE
> template1=# insert into a (id) values (NULL);
> pqReadData() -- backend closed the channel unexpectedly.

This is fixed in 7.0.1.
        regards, tom lane


Re: Problems with char array set to NULL

From
Hannu Krosing
Date:
Tom Lane wrote:
> 
> jlapham@gandalf.bioqmed.ufrj.br writes:
> > v7.0.0:
> > template1=# create table a (id char[2]);
> > CREATE
> > template1=# insert into a (id) values (NULL);
> > pqReadData() -- backend closed the channel unexpectedly.
>

Just curious, but does postgreSQL support array _elements_ set to NULL.


hannu=# insert into arr values ('{1,2,3}');
INSERT 310985 1
hannu=# insert into arr values ('{1,NULL,3}');
ERROR:  pg_atoi: error in "NULL": can't parse "NULL"

If not, should it ?

From my little knowledge on structure of storage I'd suppose it does 
not and that it would require changing the array machinery to do so.

Maybe this question is more aproppriate for  pgsql-hackers-oo@postgresql.org
but for some strange reason my subscription confirmation was rejected to
all new pgsql-hackers-xxx lists with a message like this

-----8<-------------------8<-------------------8<-------------------8<--------------

>>>> accept
Token for command:   subscribe=request@postgresql.org pgsql-hackers-smgr Hannu Krosing
<hannu@tm.ee>
issued at: Wed May 24 15:04:23 2000 GMT
from sessionid: b9ac0349622ef0032295b46f5510bad9
was accepted with these results:

**** The following was not successfully added to pgsql-hackers-smgr: Hannu Krosing <hannu@tm.ee>

1 valid command processed; its status is indeterminate.

-----8<-------------------8<-------------------8<-------------------8<--------------

Hannu


Re: Problems with char array set to NULL

From
Tom Lane
Date:
Hannu Krosing <hannu@tm.ee> writes:
> Just curious, but does postgreSQL support array _elements_ set to NULL.

No.  This is (or should be) on the TODO list.
        regards, tom lane


Re: Problems with char array set to NULL

From
Bruce Momjian
Date:
> Hannu Krosing <hannu@tm.ee> writes:
> > Just curious, but does postgreSQL support array _elements_ set to NULL.
> 
> No.  This is (or should be) on the TODO list.

Added.

--  Bruce Momjian                        |  http://www.op.net/~candle pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026