array bad behavior? - Mailing list pgsql-general

From Thalis A. Kalfigopoulos
Subject array bad behavior?
Date
Msg-id Pine.LNX.4.21.0105241511480.317-100000@aluminum.cs.pitt.edu
Whole thread Raw
Responses Re: array bad behavior?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
I create the following table:
create table lala (id int,people varchar(10)[][]);

I insert as follows:
insert into lala values(1000,'{{"1_1","1_2"},{"2_1","2_2"}}');

Works just fine:
  id  |           people
------+----------------------------
 1000 | {{"1_1","1_2"},{"2_1","2_2"}}

Then I insert:
insert into lala values(1002,'{{"1_1"},{"2_1","2_2"}}');

Which behaves well i.e. for the first row it fills in an empty string for the missing element (2D array has to be NxN):
  id  |           people
------+----------------------------
 1000 | {{"1_1","1_2"},{"2_1",""}}
 1002 | {{"1_1",""},{"2_1","2_2"}}

Then I insert:
insert into lala values(1003,'{{"1_1","1_2"},{"2_1"}}');

Which doesn't work exactly as expected, i.e. it doesn't fill in the missing element of the second row with an empty
stringas it did earlier, but instead truncates the first row to match the size of the second: 
  id  |            people
------+-------------------------------
 1000 | {{"1_1","1_2"},{"2_1","2_2"}}
 1002 | {{"1_1",""},{"2_1","2_2"}}
 1003 | {{"1_1"},{"2_1"}}

Is that normal?

thanks in advance,
thalis


pgsql-general by date:

Previous
From: Linh Luong
Date:
Subject: Column name
Next
From: "Steven D. Arnold"
Date:
Subject: strange stored procedure problem