Skip site navigation (1) Skip section navigation (2)

Re: Polymorphic functions without a type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Brian Hurt <bhurt(at)janestcapital(dot)com>
Cc: nhrcommu(at)rochester(dot)rr(dot)com, pgsql-novice(at)postgresql(dot)org
Subject: Re: Polymorphic functions without a type
Date: 2006-12-01 15:53:43
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Brian Hurt <bhurt(at)janestcapital(dot)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

In response to

pgsql-novice by date

Next:From: operationsengineer1Date: 2006-12-02 06:31:54
Subject: Re: Benchmarking PostgreSQL against others on Windows?
Previous:From: Tom LaneDate: 2006-12-01 15:35:07
Subject: Re: Messed up Postgresql

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group