Re: BUG #2802: Feature request: tinyint and unsigned types

From: Albert Strasheim <fullung(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jim Nasby <decibel(at)decibel(dot)org>, Bruno Wolff III <bruno(at)wolff(dot)to>, Albert Strasheim <fullung(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2802: Feature request: tinyint and unsigned types
Date: 2006-12-09 15:44:51
Message-ID: 20061209154451.GA22535@dogbert.sdsl.sun.ac.za
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello all,

Firstly, thanks for taking the time to evaluate my request.

On Sat, 09 Dec 2006, Tom Lane wrote:

> Jim Nasby <decibel(at)decibel(dot)org> writes:
> > Is there any technical reason why we don't support unsigned ints or
> > tinyint? Just a matter of no one feeling the itch?
>
> The question is whether it's worth complicating the numeric-type
> promotion hierarchy even more. A variant int type probably isn't worth
> much if it doesn't interact naturally with arithmetic & comparisons with
> other int types, but we've found out the hard way that you can't have a
> huge number of possible interpretations, or you get too many "can't
> resolve which operator to use" errors. (See the archives for details.)
>
> My private suspicion is that 90% of the people who say they want tinyint
> are really looking for a enum type, and thus that Tom Dunstan's recent
> patch for enum support might solve their problem. (Did Tom's patch
> allow for the storage size to vary depending on the number of values?
> Those folk won't be satisfied if not, even though we all know that
> alignment issues frequently negate any savings...)

Agreed. Some variables I had wanted to make tinyints could be expressed
as enumerated values. Other variables I wanted to express as unsigned
ints or tinyints or unsigned tinyints to model the possible values
from the problem domain as succinctly as possible.

I wasn't aware of alignment issues negating the savings I was hoping to
achieve. A discussion in the data types section of the user manual
about alignment issues as would have set me straight.

> As for unsigned, you can use OID as uint4 if you must.

Agreed. I could also use chars for 1-byte values, but my data really are
numbers, not characters. Again, I was trying to write a schema that
models the problem domain as accurately as possible, data types and
all. I'm guessing here, but using "incorrect" data types probably runs
you into an interesting set of problems when you start accessing your
database through JDBC or higher level things like an ORM library. Now
you have to explain to this library that, while your schema says char,
you really meant unsigned tinyint.

Thanks for everyone's inputs.

Regards,

Albert Strasheim

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message trinchero 2006-12-09 17:01:00 BUG #2820: "select" faling with "distinct" clause on a subquery
Previous Message Tom Lane 2006-12-09 06:37:48 Re: BUG #2802: Feature request: tinyint and unsigned types