Re: On hardcoded type aliases and typmod for user types

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: On hardcoded type aliases and typmod for user types
Date: 2005-08-31 17:59:10
Message-ID: 20050831175905.GD5489@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 31, 2005 at 11:11:04AM -0400, Tom Lane wrote:
> IMHO, ideally the aliasing should *only* apply to the built-in types.
> The current hack only approximates this (IIRC, the translation happens
> for any unqualified type name, independently of one's search path).
>
> One possible approach is to remove the aliasing translation from the
> grammar altogether, and add a notion of "alias" entries in pg_type that
> would be found through normal lookup and then replaced by the underlying
> type by parse analysis rather than by the grammar. We could not do this
> in the existing system because of the need to handle typmods for some of
> the aliases ... but maybe it would work given generalized typmod
> support. There are still a few special cases though, like CHARACTER
> VARYING, which seems like it more or less has to be wired into the
> grammar.

Yeah, I was thinking about alias entries. I was thinking that domains
might already do a lot of the work. But then it's not really aliasing
anymore.

> BTW, the proposed refactoring sounds messier to me than does decreeing
> type and function names equivalent ...

Actually, it's not that bad. The non-terminals relating to types
collapse into about three with only "xxx VARYING" and "DOUBLE
PRECISION" and a few others remaining. The keywords are split into
three sets like I mentioned. Then you make the rules for GenericType
look enough like the expansion of func_expr, that bison can consider
the context after before deciding it's a function or a type.

The changes are not that great. The number of rules (according to the
-v output) goes from 1610 to 1601 and states from 2810 to 2777. OTOH, a
chunk of code moves from gram.y to the adt directory I guess. The
grammar is just the beginning of the work.

Though maybe the point is that we can take the easy way and implement
the slightly more difficult if it turns out the be necessary.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tony Caduto 2005-08-31 18:13:00 Re: 8.1 and syntax checking at create time
Previous Message Tom Lane 2005-08-31 17:51:01 Re: 8.1 and syntax checking at create time