Re: Number of dimensions of an array parameter - Mailing list pgsql-hackers

From Thomas Hallgren
Subject Re: Number of dimensions of an array parameter
Date
Msg-id 445F8062.1060206@tada.se
Whole thread Raw
In response to Number of dimensions of an array parameter  (Thomas Hallgren <thomas@tada.se>)
Responses Re: Number of dimensions of an array parameter
Re: Number of dimensions of an array parameter
List pgsql-hackers
Stefan Kaltenbrunner wrote:
> while it would be nice to improve that - it is actually documented quite
> clearly.
>
> http://www.postgresql.org/docs/current/static/arrays.html has:
>
> "However, the current implementation does not enforce the array size
> limits — the behavior is the same as for arrays of unspecified length.
>
> Actually, the current implementation does not enforce the declared
> number of dimensions either. Arrays of a particular element type are all
> considered to be of the same type, regardless of size or number of
> dimensions. So, declaring number of dimensions or sizes in CREATE TABLE
> is simply documentation, it does not affect run-time behavior. "
>
>   
A documented flaw is much better than an undocumented one but it's still 
a flaw, and a pretty bad one at that. It's like having a compiler that 
doesn't complain when you define a C-function that takes an int** and 
then pass an int*.

Would it be hard to enforce a real check? The implementation could use 
GUC settings like 'enforce_array_dimensions' and 'enforce_array_lengths' 
that could be set to false for the legacy implementations that rely on 
the current behavior. I know Tom added the ability to have NULL values 
in the arrays. Perhaps now is the time to improve the type semantics as 
well?

Regards,
Thomas Hallgren




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Number of dimensions of an array parameter
Next
From: "Magnus Hagander"
Date:
Subject: Pragma linking?