I'm surprised that this worked - Mailing list pgsql-general

From raf
Subject I'm surprised that this worked
Date
Msg-id 20200923013402.56zpnae4ocdu43cr@raf.org
Whole thread Raw
Responses Re: I'm surprised that this worked  ("David G. Johnston" <david.g.johnston@gmail.com>)
List 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




pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Can I get some PostgreSQL developer feedback on these five general issues I have with PostgreSQL and its ecosystem?
Next
From: "David G. Johnston"
Date:
Subject: Re: I'm surprised that this worked