Re: 2D arrays in 7.3... actually, parser bug?

From: Guy Fraser <guy(at)incentre(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: 2D arrays in 7.3... actually, parser bug?
Date: 2003-02-06 19:10:20
Message-ID: 3E42B31C.90102@incentre.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)postgresql(dot)org)
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2003-02-06 19:24:14 Re: user column name
Previous Message Robert Treat 2003-02-06 19:02:56 Re: how do I get a log of SQL executed by server?