Re: Possible to create canonicalized range type without being superuser?

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Possible to create canonicalized range type without being superuser?
Дата
Msg-id CAKFQuwY=t_hQH-G3Bj78X182=u94C7g=itWjJ0Sgv4iHhuUQzA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Possible to create canonicalized range type without being superuser?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Possible to create canonicalized range type without being superuser?  (Paul A Jungwirth <pj@illuminatedcomputing.com>)
Список pgsql-general
On Tue, Jul 5, 2016 at 5:37 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Paul Jungwirth <pj@illuminatedcomputing.com> writes:
> The problem is this (tried on 9.3 and 9.5):
> db=> create type inetrange;
> ERROR:  must be superuser to create a base type
> So I'm wondering whether there is any way around this circle without
> being a superuser?

The only other obvious way to deal with this is to allow the canonical
function to be defined after the range type is created, and then added to
the type via an ALTER TYPE command.  But then you have an interval where
the type is not restricted, in which you might store values that aren't
canonical.

​Can the canonical function be definitionally optional but runtime required?  That is, have it only be an error to use a type lacking a canonical function?  If so I think a usable idiom is that for types that don't want to canonicalize (i.e., presently have a NULL assigned) they would make an explicit declaration by doing something like:

CREATE TYPE int4range AS RANGE (subtype = int4, canonical = int4_identity);

Now you have a window where the type is incompletely defined and when the missing canonical function is encountered the system balks.  At some future point a function can be associated via ALTER TYPE which makes the type completely defined.

CREATE TYPE inetrange AS RANGE (subtype = inet, canonical = NULL);
ALTER TYPE inetrange SET PROPERTY canonical = inet_canonicalizer;
 ​
David J.

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

Предыдущее
От: trafdev
Дата:
Сообщение: Re: pg_dump fundenental question
Следующее
От: Luís Eduardo Oliveira Lizardo
Дата:
Сообщение: Is it possible to use an EVENT TRIGGER to validate a TRIGGER?