Re: Polymorphic functions without a type

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Polymorphic functions without a type
Дата
Msg-id 16301.1164988423@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Polymorphic functions without a type  (Brian Hurt <bhurt@janestcapital.com>)
Список pgsql-novice
Brian Hurt <bhurt@janestcapital.com> writes:
> In addition to providing a text function, explicitly assigning a type
> also works, so:
> select equals(null :: int, null);

This must be so if you think about it: the meaning of equality depends
on what type you are talking about, so equals() cannot work in a vacuum.
You have to give the parser some clue what type you want the inputs to
be understood as.

In most real-world cases you're not going to be passing the thing
literal constants, but expressions involving table columns, which will
have well-defined types already.  So I don't see this as a major problem
in practice.  I'd avoid adding a separate equals(text,text) function,
as that's most likely not going to do much except risk "capturing" cases
you'd rather had not gotten interpreted as text equality.

            regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Messed up Postgresql
Следующее
От:
Дата:
Сообщение: Re: Benchmarking PostgreSQL against others on Windows?