Re: Disallow arrays with non-standard lower bounds

Поиск
Список
Период
Сортировка
От Florian Pflug
Тема Re: Disallow arrays with non-standard lower bounds
Дата
Msg-id 838EE4F9-994E-4107-B4FF-6484E64FC6BE@phlo.org
обсуждение исходный текст
Ответ на Re: Disallow arrays with non-standard lower bounds  (Kevin Grittner <kgrittn@ymail.com>)
Список pgsql-hackers
On Jan14, 2014, at 02:10 , Kevin Grittner <kgrittn@ymail.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




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Capturing EXPLAIN ANALYZE for a query without discarding the normal result set
Следующее
От: Michael Paquier
Дата:
Сообщение: Soften pg_[start|stop]_backup to allow them on a standby?