Problems with char array set to NULL

Started by Nonameover 25 years ago6 messages
#1Noname
jlapham@gandalf.bioqmed.ufrj.br

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 abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.

-**-*-*---*-*---*-*---*-----*-*-----*---*-*---*-----*-----*-*-----*---
Jon Lapham, PhD
Centro Nacional de Ressonancia Magnetica Nuclear de Macromoleculas
Universidade Federal do Rio de Janeiro (UFRJ) - Brasil
email: jlapham@gandalf.bioqmed.ufrj.br
***-*--*----*-------*------------*--------------------*---------------

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Noname (#1)
Re: Problems with char array set to NULL

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

#3Hannu Krosing
hannu@tm.ee
In reply to: Noname (#1)
Re: Problems with char array set to NULL

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

#4Zeugswetter Andreas SB
ZeugswetterA@wien.spardat.at
In reply to: Hannu Krosing (#3)
AW: Problems with char array set to NULL

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

Do those lists really exist ? They do not show up on the Mailing Lists
section of www.postgresql.org and thus those lists are somewhat
closed. Is this intentional ?

I think the separation was a bad idea.

Andreas

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Hannu Krosing (#3)
Re: Problems with char array set to NULL

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

#6Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Tom Lane (#5)
Re: Problems with char array set to NULL

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, Pennsylvania 19026