Re: On hardcoded type aliases and typmod for user types

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: On hardcoded type aliases and typmod for user types
Дата
Msg-id 20050831175905.GD5489@svana.org
обсуждение исходный текст
Ответ на Re: On hardcoded type aliases and typmod for user types  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: On hardcoded type aliases and typmod for user types  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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@svana.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.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: 8.1 and syntax checking at create time
Следующее
От: Tony Caduto
Дата:
Сообщение: Re: 8.1 and syntax checking at create time