Re: Is there any plan to add unsigned integer types?

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: Is there any plan to add unsigned integer types?
Дата
Msg-id CAHyXU0wuRzTGvagZ=iK3QTWbVEC5MTj7V3cnffSVgr33wj00Fw@mail.gmail.com
обсуждение исходный текст
Ответ на Is there any plan to add unsigned integer types?  (crocket <crockabiscuit@gmail.com>)
Ответы Re: Is there any plan to add unsigned integer types?
Список pgsql-hackers
On Mon, Sep 26, 2011 at 5:41 AM, crocket <crockabiscuit@gmail.com> wrote:
> MySQL already has unsigned INT type, and it has double the range of
> signed INT type.
> It's not just the bigger range that UINT type brings.
> If unsigned INT type exists, I wouldn't have to execute "create domain
> UINT" in every database.
>
> If "INT unsigned" and "SERIAL unsigned" exist, PostgreSQL would bring
> more convenience to users.

This comes up now and then.  The problem is the benefit gained is not
really worth the pain.  In today's 64 bit world, choosing a 64 bit int
nails the cases where you need the extra range and you have the
ability to use constraints (if necessary, through a domain) to enforce
correctness.

On the downside, you have to add a lot of casts, overloads, etc.
Figuring out the casting rules is non trivial and could lead to
surprising behaviors...inferring the type of 'unknown' strings is bad
enough as it is.

TBH, what I'd greatly prefer to see is to have domains be finished up
so that you don't have to carefully consider their use (for example,
you can't make arrays out of them).  Then an unsigned int could simply
be:

create domain uint as bigint check (value >= 0);

merlin


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

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: Inlining comparators as a performance optimisation
Следующее
От: Tom Lane
Дата:
Сообщение: Re: contrib/sepgsql regression tests are a no-go