Re: Range Types, constructors, and the type system

Поиск
Список
Период
Сортировка
От Jeff Davis
Тема Re: Range Types, constructors, and the type system
Дата
Msg-id 1309135727.2443.206.camel@jdavis
обсуждение исходный текст
Ответ на Re: Range Types, constructors, and the type system  (Florian Pflug <fgp@phlo.org>)
Ответы Re: Range Types, constructors, and the type system
Список pgsql-hackers
On Mon, 2011-06-27 at 00:56 +0200, Florian Pflug wrote:
> Well, there actually *is* some precedence for that kind of top-down
> (form a syntactic perspective) type inference. We *enforce* the cast
> in 
>   array[]::<arraytype>
> and actually for a very similar reason - without the case, there's no
> way of knowing which type of empty array was meant. I think we also

That's a good point.

Although, I'm not sure whether that's an argument that we can make the
type system work as-is, or if it means that we should add syntax like
ARRAY[].

> special-case
>   'literal'::<type>
> to use the input function of type directly, instead of first creating
> a text value and later casting it to <type>.

That is certainly true. Quoted strings never start out as text, they
start out as "unknown" and wait for the type inference to determine the
type. I'm not entirely sure whether a quoted string followed by a cast
is briefly unknown and then cast, or if it's directly interpreted using
the cast's type input function.

I don't know if that's a good example though because it's near the end
of the line and there's no function call in between the arguments and
the cast. It might get more complex with cases like:
 range(lower(range(1,2)),upper(range(1,2)))::int8range

but maybe that can be done more easily than I think?

Regards,Jeff Davis



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

Предыдущее
От: Florian Pflug
Дата:
Сообщение: Re: Range Types, constructors, and the type system
Следующее
От: Jeff Davis
Дата:
Сообщение: Re: Range Types and length function