Re: [GENERAL] MySQL to PostgreSQL, was ENUM type

From: "Jim C(dot) Nasby" <decibel(at)decibel(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Gregory Youngblood <pgcluster(at)netio(dot)org>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, Chris Travers <chris(at)travelamericas(dot)com>, Merlin Moncure <merlin(dot)moncure(at)rcsonline(dot)com>, PostgreSQL advocacy <pgsql-advocacy(at)postgresql(dot)org>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: [GENERAL] MySQL to PostgreSQL, was ENUM type
Date: 2005-07-29 20:03:48
Message-ID: 20050729200348.GI95931@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-advocacy pgsql-general

On Fri, Jul 29, 2005 at 03:57:48PM -0400, Tom Lane wrote:
> "Jim C. Nasby" <decibel(at)decibel(dot)org> writes:
> > Is there any serious impediment to adding unsigned types to PostgreSQL?
>
> Quick, what's the datatype of 12345? And why?
>
> My guess is that transparent support for such a thing would require some
> tricky and fragile compromises in the numeric hierarchy's promotion
> rules. The handling of smallint is already pretty unsatisfactory
> because "12345" is considered int not smallint; adding three or four
> unsigned types would make that problem many times worse.

ISTM that so long as you don't overflow or lose precision it shouldn't
really matter what datatype is used to represent a number, until you use
it someplace that specifies a datatype to use (such as a function or a
table). I realize that function overloading gums this up a bit, but I
don't think it's unreasonable to require the user to explicitly cast if
they want an explicit function out of the overloaded set to be used
(though throwing a warning if they don't cast might be a good idea).

> > I don't think these would even have to be in core, if that's a
> > concern.
>
> Sure, if you don't need it to work reasonably nicely --- although the
> promotion rules are now embedded in pg_cast and hence modifiable, the
> initial determination of a datatype for a numeric literal is still
> hard-wired in the grammar.

So what would those rules currently do when they find a value that
exceedes a signed int? Or a signed bigint?
--
Jim C. Nasby, Database Consultant decibel(at)decibel(dot)org
Give your computer some brain candy! www.distributed.net Team #1828

Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"

In response to

Browse pgsql-advocacy by date

  From Date Subject
Next Message Chris Browne 2005-07-29 22:50:58 Re: 775,000 downloads plus
Previous Message Tom Lane 2005-07-29 19:57:48 Re: [GENERAL] MySQL to PostgreSQL, was ENUM type

Browse pgsql-general by date

  From Date Subject
Next Message Greg Stark 2005-07-29 20:14:48 Re: Megabytes of stats saved after every connection
Previous Message Tom Lane 2005-07-29 19:57:48 Re: [GENERAL] MySQL to PostgreSQL, was ENUM type