From: | Marko Tiikkaja <marko(at)joh(dot)to> |
---|---|
To: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
Cc: | PostGreSql hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: array_length(anyarray) |
Date: | 2013-12-18 21:38:38 |
Message-ID: | 52B215DE.40409@joh.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2013-12-18 22:32, Andrew Dunstan wrote:
> You're not really free to assume it - you'll need an exception handler
> for the other-than-1 case, or your code might blow up.
>
> This seems to be codifying a bad pattern, which should be using
> array_lower() and array_upper() instead.
That's the entire point -- I *want* my code to blow up. If someone
passes a multi-dimensional array to a function that assumes its input is
one-dimensional and its indexes start from 1, I want it to be obvious
that the caller did something wrong. Now I either copy-paste lines and
lines of codes to always test for the weird cases or my code breaks in
subtle ways.
This is no different from an Assert() somewhere -- if the caller breaks
the documented interface, it's his problem, not mine. And I don't want
to waste my time coding around the fact that this simple thing is so
hard to do in PG.
Regards,
Marko Tiikkaja
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Stark | 2013-12-18 21:54:20 | Re: Extension Templates S03E11 |
Previous Message | Andrew Dunstan | 2013-12-18 21:32:46 | Re: array_length(anyarray) |