Re: Porting MySQL data types to PostgreSQL

From: ptjm(at)interlog(dot)com (Patrick TJ McPhee)
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Porting MySQL data types to PostgreSQL
Date: 2007-08-01 05:19:33
Message-ID: 13b05v56sftdof3@corp.supernews.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In article <19363(dot)1185892343(at)sss(dot)pgh(dot)pa(dot)us>,
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
% ptjm(at)interlog(dot)com (Patrick TJ McPhee) writes:
% > One problem with this idea is the treatment of implicit casts between
% > numeric types in TypeCategory(). For implicit casts to work, the type's
% > OID has to be listed in that function (i.e., it has to be a built-in type).
%
% That's not the case. There probably are some things that won't work
% nicely if TypeCategory() doesn't recognize the type as numeric category,
% but to claim that implicit casts won't work at all is wrong.

I didn't say they won't work at all, but I do say that they won't work
completely. I had to play around with it before I remembered where things
broke down. Suppose you have a type called unsigned, written in C, with an
implicit cast from int4 to unsigned. Then

SELECT 23::unsigned
UNION
SELECT 0;

will work if unsigned has one of the numeric OIDs known to TypeCategory(),
but not if it was defined normally using CREATE TYPE.

You can characterise this as working, just not nicely, but it's still
a problem for anyone trying to implement unsigned, or any other kind of
numeric value, as a user-defined type.

--

Patrick TJ McPhee
North York Canada
ptjm(at)interlog(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ashish Karalkar 2007-08-01 07:27:43 Problem With gunzip backup
Previous Message Stuart McGraw 2007-08-01 04:46:32 Re: [GENERAL] ascii() for utf8