Re: Missing array support - Mailing list pgsql-hackers

From Joe Conway
Subject Re: Missing array support
Date
Msg-id 3EFD1931.1090204@joeconway.com
Whole thread Raw
In response to Re: Missing array support  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:
> Joe Conway <mail@joeconway.com> writes:
>>So array[] should produce '{}' of (an array) type determined by the 
>>context? OK -- seems easy enough.

> Is it?  I think we'd decided that this could only reasonably be handled
> by creating a datatype representing array-of-UNKNOWN.  I'm afraid to do
> that because I think it might allow the parser's type resolution
> algorithms to follow paths we will not like.  Perhaps it can be made to
> work, but I think it will require some careful study.
> 

But see the spec wording:
1) The declared type DT of an <empty specification> ES is ET ARRAY[0], 
where the element type ET is determined by the context in which ES 
appears. ES is effectively replaced by CAST ( ES AS DT ).
NOTE 69 – In every such context, ES is uniquely associated with some 
expression or site of declared type DT, which thereby becomes the 
declared type of ES.

I took that to mean that this sould only work in contexts where the data 
type is known.

Come to think of it, I guess in most cases of ARRAY[elem1,elem2,elem3] 
we derive the data type using the elements in the array expression, so 
in practice there may be few places where this would work. We should be 
able to come up with a data type for inserts and updates though, 
shouldn't we?

Joe



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Missing array support
Next
From: Tom Lane
Date:
Subject: Re: Assembler error