Skip site navigation (1) Skip section navigation (2)

Re: trouble selecting from array

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: brian <brian(at)zijn-digital(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: trouble selecting from array
Date: 2008-03-28 18:19:55
Message-ID: b42b73150803281119v1199cebaxb90328031ca5fee1@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-general
On Thu, Mar 27, 2008 at 8:58 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>  If you want a sub-array you need to use the slice notation, eg
>  tdr_tags[2:2][1:2]

The slice approach is not a general solution...in fact there seems to
be no way to convert an array of N dimensions to N-1 dimensions except
in the special case of N=1.  One side effect of this is that the
_pg_expand_array approaches which I was about to suggest to the OP
only work for one dimensional arrays.

reading the archives, you wrote:
"Because it isn't a slice expression --- you used colon nowhere, so the
result type is going to be text not text[].  (Remember that the parser
must determine the expression's result type at parse time, so whether
there are enough subscripts can't enter into this.)  Our alternatives
here are to throw a subscripting error or return NULL.  I'd personally
have gone with throwing an error, I think, but it seems far too late to
revisit that decision."

is there not enough information available to the parser to reduce the
expression dimensions by one?

merlin

In response to

Responses

pgsql-general by date

Next:From: Alex AdriaanseDate: 2008-03-28 18:38:57
Subject: Out of memory
Previous:From: brianDate: 2008-03-28 18:02:15
Subject: Re: VS: Delete after trigger fixing the key of row numbers

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group