pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Array Madness
5+ messages / 3 participants
[nested] [flat]

* Array Madness
@ 1999-09-14 01:56 Michael Richards <miker@scifair.acadiau.ca>
  1999-09-14 02:19 ` Re: [SQL] Array Madness Bruce Momjian <maillist@candle.pha.pa.us>
  1999-09-14 15:02 ` Re: [SQL] Array Madness Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 5+ messages in thread

From: Michael Richards @ 1999-09-14 01:56 UTC (permalink / raw)
  To: pgsql-sql

Hi.
I've started to fiddle with arrays. Every time I fiddle stuff breaks or
won't work for me :)

It seems that you can't have a NULL value in an array. I think based on
the idea of RDBMSes you should be able to have an array value that is
null... Running an update and setting a single array value to null seems
to nuke the entire array.

create table test(features int4[]);
insert into test values ('{NULL,1}');     
ERROR:  pg_atoi: error in "NULL": can't parse "NULL"
insert into test values ('{0,1}');
insert into test values ('{,1}');
select * from test;
features
--------
{0,1}   
{0,1}   
(2 rows)
update test set features[2]=NULL;
UPDATE 2
select * from test;              
features
--------
        
        
(2 rows)

Positively a bad thing...

-Michael




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [SQL] Array Madness
  1999-09-14 01:56 Array Madness Michael Richards <miker@scifair.acadiau.ca>
@ 1999-09-14 02:19 ` Bruce Momjian <maillist@candle.pha.pa.us>
  1 sibling, 0 replies; 5+ messages in thread

From: Bruce Momjian @ 1999-09-14 02:19 UTC (permalink / raw)
  To: Michael Richards <miker@scifair.acadiau.ca>; +Cc: pgsql-sql

> Hi.
> I've started to fiddle with arrays. Every time I fiddle stuff breaks or
> won't work for me :)
> 
> It seems that you can't have a NULL value in an array. I think based on
> the idea of RDBMSes you should be able to have an array value that is


Added to TODO:

	* Allow nulls in arrays


-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@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



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [SQL] Array Madness
  1999-09-14 01:56 Array Madness Michael Richards <miker@scifair.acadiau.ca>
@ 1999-09-14 15:02 ` Tom Lane <tgl@sss.pgh.pa.us>
  1999-09-14 15:42   ` Re: [SQL] Array Madness Michael Richards <miker@scifair.acadiau.ca>
  1 sibling, 1 reply; 5+ messages in thread

From: Tom Lane @ 1999-09-14 15:02 UTC (permalink / raw)
  To: Michael Richards <miker@scifair.acadiau.ca>; +Cc: pgsql-sql

Michael Richards <miker@scifair.acadiau.ca> writes:
> It seems that you can't have a NULL value in an array.

Seems like a reasonable idea.  Go for it...

> Running an update and setting a single array value to null seems
> to nuke the entire array.

Yeah, it does, see ExecEvalArrayRef() in execQual.c: if the refassgnexpr
yields a null, it just drops out with a null result for the whole expr.
This could be fixed if the array routines had a representation for a
null element in an array, but they don't.

In the meantime, perhaps it would be better for ExecEvalArrayRef() to
raise an error if the assign source is null, rather than dropping the
whole contents of the array.  Comments?

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [SQL] Array Madness
  1999-09-14 01:56 Array Madness Michael Richards <miker@scifair.acadiau.ca>
  1999-09-14 15:02 ` Re: [SQL] Array Madness Tom Lane <tgl@sss.pgh.pa.us>
@ 1999-09-14 15:42   ` Michael Richards <miker@scifair.acadiau.ca>
  1999-09-14 15:45     ` Re: [SQL] Array Madness Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: Michael Richards @ 1999-09-14 15:42 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql

On Tue, 14 Sep 1999, Tom Lane wrote:

> In the meantime, perhaps it would be better for ExecEvalArrayRef() to
> raise an error if the assign source is null, rather than dropping the
> whole contents of the array.  Comments?

This sounds like a hack that avoids the real issue... Bruce has added it
to the todo list. I'm going to re-write the code for ALTER TABLE,
otherwise I'd have time to play with this one. I guess for now I will
design my implementation so a value of '0' is not used as a key.

-Michael




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [SQL] Array Madness
  1999-09-14 01:56 Array Madness Michael Richards <miker@scifair.acadiau.ca>
  1999-09-14 15:02 ` Re: [SQL] Array Madness Tom Lane <tgl@sss.pgh.pa.us>
  1999-09-14 15:42   ` Re: [SQL] Array Madness Michael Richards <miker@scifair.acadiau.ca>
@ 1999-09-14 15:45     ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 1999-09-14 15:45 UTC (permalink / raw)
  To: Michael Richards <miker@scifair.acadiau.ca>; +Cc: pgsql-sql

Michael Richards <miker@scifair.acadiau.ca> writes:
> On Tue, 14 Sep 1999, Tom Lane wrote:
>> In the meantime, perhaps it would be better for ExecEvalArrayRef() to
>> raise an error if the assign source is null, rather than dropping the
>> whole contents of the array.  Comments?

> This sounds like a hack that avoids the real issue...

Well, of course it's not a solution to the real issue, but it seemed
like it might prevent someone from accidentally losing data until
we get around to providing a real solution.  (Which could be a long
time; there's a lot of things on the TODO list...)

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~1999-09-14 15:45 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-09-14 01:56 Array Madness Michael Richards <miker@scifair.acadiau.ca>
1999-09-14 02:19 ` Bruce Momjian <maillist@candle.pha.pa.us>
1999-09-14 15:02 ` Tom Lane <tgl@sss.pgh.pa.us>
1999-09-14 15:42   ` Michael Richards <miker@scifair.acadiau.ca>
1999-09-14 15:45     ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox