Re: 2D arrays in 7.3... actually, parser bug? - Mailing list pgsql-general

From Guy Fraser
Subject Re: 2D arrays in 7.3... actually, parser bug?
Date
Msg-id 3E42B31C.90102@incentre.net
Whole thread Raw
In response to 2D arrays in 7.3... actually, parser bug?  (Eric B.Ridge <ebr@tcdi.com>)
List pgsql-general
While testing this out I discovered somthing interesting.

Here was my test :

create table foo (bar int8[]);
insert into foo values('{12423}');
insert into foo values('{{1223,4563},{3623}}');
insert into foo values('{{123},{3423}}');
insert into foo values('{{12323,45363},{5443,23}}');
insert into foo values('{{123,456,768},{543,323,235},{234,456,654}}');
select array_dims(bar),bar from foo ;

The result was :

  array_dims |                     bar
------------+---------------------------------------------
  [1:1]      | {12423}
  [1:2][1:1] | {{1223},{3623}}
  [1:2][1:1] | {{123},{3423}}
  [1:2][1:2] | {{12323,45363},{5443,23}}
  [1:3][1:3] | {{123,456,768},{543,323,235},{234,456,654}}
(5 rows)

What happened to the '4563' on the second insert statement?

If you have less dimensions filled out as an array of arrays does postgres
default to the minimum dimension of the array data rather than put a NULL
entry to fill in additional entries?

When I tried to force the data I recieved somewhat expected results :

test=$ insert into foo values('{{1223,4563},{3623,}}');
ERROR:  Bad int8 external representation ""

test=$ insert into foo values('{{1223,4563},{3623,NULL}}');
ERROR:  Bad int8 external representation "NULL"

test=$ insert into foo values('{{1223,4563},{3623,0}}');
INSERT 65261 1


Guy

Eric B.Ridge wrote:
> zzzz=# select version();
>                                             version
> ------------------------------------------------------------------------
> ------------------------
>  PostgreSQL 7.3 on powerpc-apple-darwin6.3, compiled by GCC gcc (GCC)
> 3.1 20020420 (prerelease)
> (1 row)
>
> Being too lazy to RTFM, I decided to discover on my own if postgres
> supported 2D array types:
>
> zzzz=# create table foo (bar int8[][]);
> CREATE TABLE
>
> (Oh cool!  it does!)
>
> zzzz=# \d foo
>       Table "public.foo"
>  Column |   Type   | Modifiers
> --------+----------+-----------
>  bar    | bigint[] |
>
> (hmm, that doesn't look right.  <pause>  *snicker*  Hmm, I wonder...)
>
> zzzz=# create table foo2 (bar int8[][][][][][][][]);
> CREATE TABLE
> zzzz=# \d foo2
>       Table "public.foo2"
>  Column |   Type   | Modifiers
> --------+----------+-----------
>  bar    | bigint[] |
>
> So now my question is, since postgres doesn't support 2D (or N-D)
> arrays, shouldn't the above produce some kind of syntax error?
>
> eric
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
>



pgsql-general by date:

Previous
From: Nick Wellnhofer
Date:
Subject: Index not used with IS NULL
Next
From: damonhart@yahoo.com (Damon Hart)
Date:
Subject: backend process crash - PL/pgSQL functions - parsing problem?