Re: type aliases

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: type aliases
Дата
Msg-id 1392479864641-5792207.post@n5.nabble.com
обсуждение исходный текст
Ответ на Re: type aliases  (James Harper <james.harper@bendigoit.com.au>)
Ответы Re: type aliases  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
James Harper wrote
>>
>> You probably should define your domain like this:
>>
>>    CREATE DOMAIN myvarchar varchar(42);
>>
>
> That's what I thought, so it won't do what I want. I need to be able to
> set the length at the time of declaration.
>
> So suppose I wanted to implement myvarchar in C. In my _in function, how
> do I know how big my column declaration is? Eg if someone tries to insert
> 50 characters into my 42 character field, how do I get the declared length
> and then tell postgres that the data to be inserted is too big?
>
> Thanks
>
> James

IMO. You are abusing the type system to implement things that should be
defined using CHECK constraints.  If indeed you are working with string I
would avoid length-limited type mods and rely on checks/constraints.  There
isn't any viable alternative for numeric scale/precision type modifiers
though :(

There is no current way for a function body to examine the type modifiers of
its input, domain or otherwise.

David J.




--
View this message in context: http://postgresql.1045698.n5.nabble.com/type-aliases-tp5792148p5792207.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


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

Предыдущее
От: Clemens Eisserer
Дата:
Сообщение: Re: Will modifications to unlogged tables also be flused to disk?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: type aliases