From: | Florian Pflug <fgp(at)phlo(dot)org> |
---|---|
To: | Kevin Grittner <kgrittn(at)ymail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, David Fetter <david(at)fetter(dot)org>, Jim Nasby <jim(at)nasby(dot)net>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Disallow arrays with non-standard lower bounds |
Date: | 2014-01-14 03:17:17 |
Message-ID: | 838EE4F9-994E-4107-B4FF-6484E64FC6BE@phlo.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Jan14, 2014, at 02:10 , Kevin Grittner <kgrittn(at)ymail(dot)com> wrote:
> The fact that some
> day some new programmer might not be aware of all business rules,
> or might choose to try to ignore them is the reason you add
> constraints to columns and domains.
Well, for columns and domains that seems easy. We could have
array_has_shape(value anyarray, variadic bounds int4range[])
and
array_has_shape(value anyarray, variadic bounds int4[])
The first returns true if the value has length(bounds) dimensions
and each dimension's bounds match the corresponding range's bound,
where NULL means "arbitrary". The second one requires all lower
bounds to be 1, and checks the upper bounds against the bounds array.
Checking that an array is one-dimensional with lower bound 1 is then
accomplished by
array_has_shape(myarray, int4range(1, NULL))
or simply
array_has_shape(myarray, NULL);
best regards,
Florian Pflug
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2014-01-14 03:31:09 | Soften pg_[start|stop]_backup to allow them on a standby? |
Previous Message | Tom Lane | 2014-01-14 03:14:20 | Re: Capturing EXPLAIN ANALYZE for a query without discarding the normal result set |