Re: typmod is always -1

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: typmod is always -1
Дата
Msg-id 19183.1458261604@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: typmod is always -1  (Chapman Flack <chap@anastigmatix.net>)
Ответы Re: typmod is always -1  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
Список pgsql-hackers
Chapman Flack <chap@anastigmatix.net> writes:
> It seems that a typmod can only be used restrict the set of possible
> values of the unmodified type (as clearly seen in the language "length
> conversion cast", since certainly a typmod allowing { string | length < N }
> is doing nothing but enforcing a subset of { string }. Each element of
> the subset is still a valid element of the whole set (naturally, boring)
> *and has to be represented the same way* (interesting): the representation
> mustn't do clever things that you would need to know the typmod in order to
> interpret, because most uses of a value are without access to the typmod.

You do need to be able to interpret values of the type without having
separate access to the typmod, but I don't think it follows that it's as
restrictive as you say.  One easy way around that is to store the typmod
in the value.

Practical uses might include compressing the data in different ways
depending on typmod.  I'm drawing a blank on other compelling examples
though I'm sure there are some.  Have you looked at PostGIS?  I'm pretty
sure some of their types make use of typmod in nontrivial ways.
        regards, tom lane



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

Предыдущее
От: Mark Dilger
Дата:
Сообщение: Re: Make primnodes.h gender neutral
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Request - repeat value of \pset title during \watch interations