I'm surprised that this worked

From: raf <raf(at)raf(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: I'm surprised that this worked
Date: 2020-09-23 01:34:02
Message-ID: 20200923013402.56zpnae4ocdu43cr@raf.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I just wrote a query that I didn't expect to work but I
was pleasantly surprised that it did. It looked
something like this:

select
a.aaa,
c.ccc,
d.ddd1,
d.ddd2
from
tbla a,
tblb b,
tblc c,
funcd(c.id) d
where
a.something = something and
b.something = a.something and
c.something = b.something

How does it know which c.id to use for the function
without going all cartesian product on me? Maybe it
makes no sense for such a parameterised function to be
part of a cartesian product. Actually, that function
returns a setof record but only ever a single record.
That might be relevant.

I was sure I'd done something similar once that
(sensibly) didn't work, and I needed a loop to call the
function in, but I might be thinking of something in an
outer join's "on" clause. Does that make sense?

Even more impressed with Postgresql than usual. :-)

cheers,
raf

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2020-09-23 02:31:37 Re: I'm surprised that this worked
Previous Message Adrian Klaver 2020-09-22 22:47:56 Re: Can I get some PostgreSQL developer feedback on these five general issues I have with PostgreSQL and its ecosystem?