pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: raf <raf@raf.org>
To: pgsql-general@postgresql.org
Subject: I'm surprised that this worked
Date: Wed, 23 Sep 2020 11:34:02 +1000
Message-ID: <20200923013402.56zpnae4ocdu43cr@raf.org> (raw)

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






view thread (2+ messages)  latest in thread

Message-ID: <20200923013402.56zpnae4ocdu43cr@raf.org>
Permalink:  ../20200923013402.56zpnae4ocdu43cr@raf.org/
Also on:    postgresql.org/message-id/20200923013402.56zpnae4ocdu43cr@raf.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: raf@raf.org
  Subject: Re: I'm surprised that this worked
  In-Reply-To: <20200923013402.56zpnae4ocdu43cr@raf.org>
  References: <20200923013402.56zpnae4ocdu43cr@raf.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox