pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dennis Haney <davh@diku.dk>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgresql.org
Subject: Re: IN joining
Date: Mon, 08 Mar 2004 15:03:40 +0100
Message-ID: <404C7D3C.50908@diku.dk> (raw)
In-Reply-To: <12170.1078528135@sss.pgh.pa.us>
References: <4048B8D6.70401@diku.dk>
	<11205.1078520699@sss.pgh.pa.us>
	<4048F1D3.20405@diku.dk>
	<12170.1078528135@sss.pgh.pa.us>

Tom Lane wrote:

>Dennis Haney <davh@diku.dk> writes:
>  
>
>>>Joining {b,c} to {a} does not meet any of those four allowed cases.
>>>
>>>      
>>>
>>Exactly my point... So why ever bother creating the {b,c} node which is 
>>legal by the above definition?
>>    
>>
>
>We don't, because there is no such join clause.
>
>  
>
No, but we create the equality via the implied equality mechanism...

select * from a, b where a.id = b.id3 and a.id in (select c.id2 from c);

rtable is (after in-optimization):
resno   refname         relid   inFromCl
-----   ---------       -----   --------
1       a     17143           inFromCl
2       b     17151           inFromCl
3       IN_subquery     [subquery]
4       c     17147           inFromCl

in gdb:
break joinrels.c:563
commands
call bms_is_subset(ininfo->lefthand, rel1->relids)
call bms_equal(ininfo->righthand, rel2->relids)
call bms_is_subset(ininfo->lefthand, rel2->relids)
call bms_equal(ininfo->righthand, rel1->relids)
x/t rel1->relids.words
x/t rel2->relids.words
x/t joinrelids.words
p jointype
printf "%s\n", 
pretty_format_node_dump(nodeToString(((RestrictInfo*)((RestrictInfo*)restrictlist)->clause)->clause))
end

then we get this join:

Breakpoint 4, make_join_rel (root=0x8307bc8, rel1=0x8316920, 
rel2=0x8316b10, jointype=JOIN_UNIQUE_INNER)
    at joinrels.c:563
563             switch (jointype)
$92 = 0 '\0'
$93 = 1 '\001'
$94 = 0 '\0'
$95 = 0 '\0'
0x83169ac:      00000000000000000000000000000100
0x8316b9c:      00000000000000000000000000010000
0x832670c:      00000000000000000000000000010100
$96 = JOIN_UNIQUE_INNER
   {OPEXPR
   :opno 96
   :opfuncid 0
   :opresulttype 16
   :opretset false
   :args (
      {VAR
      :varno 4
      :varattno 1
      :vartype 23
      :vartypmod -1
      :varlevelsup 0
      :varnoold 4
      :varoattno 1
      }

      {VAR
      :varno 2
      :varattno 1
      :vartype 23
      :vartypmod -1
      :varlevelsup 0
      :varnoold 2
      :varoattno 1
      }
   )
   }


-- 
Dennis

view thread (7+ messages)  latest in thread

Message-ID: <404C7D3C.50908@diku.dk>
Permalink:  ../404C7D3C.50908@diku.dk/
Also on:    postgresql.org/message-id/404C7D3C.50908@diku.dk

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: davh@diku.dk, tgl@sss.pgh.pa.us
  Subject: Re: IN joining
  In-Reply-To: <404C7D3C.50908@diku.dk>

* 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