Skip to content

Commit df3ff5f

Browse files
committed
Correct comments in convert_IN_to_antijoin()
Incorrect example comments: The transformation is to rewrite a query of the form: select c1 from t1 where c1 NOT IN (select c2 from t2); (to) select c1 from t1 left anti semi join (select 0 as zero, c2 from t2) foo ON (c1 = c2) IS NOT FALSE where zero is NULL; Correct it to: The transformation is to rewrite a query of the form: select c1 from t1 where c1 NOT IN (select c2 from t2); (to) select c1 from t1 left anti semi join (select 0 as zero, c2 from t2) foo ON (c1 != c2) IS NOT FALSE where zero is NULL; SQL NOT IN should be converted to Left Anti Semi (not-in) Join with join condition c1 != c2. Any non-null values from t1 don't match values from t2 shoule be kept and IS NOT FALSE will return TRUE. GDB checks after function make_lasj_quals() join_expr->quals: BoolExpr [boolop=NOT_EXPR] OpExpr [opno=518 opfuncid=144 opresulttype=16 opretset=false] Var [varno=1 varattno=1 vartype=23 varnoold=1 varoattno=1] Var [varno=2 varattno=1 vartype=23 varnoold=2 varoattno=1] And oid 518 is a '<>' operator in pg_operator. select oprname from pg_operator where oid = 518; -[ RECORD 1 ] oprname | <> Authored-by: Zhang Mingli avamingli@gmail.com
1 parent 3a89357 commit df3ff5f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/backend/cdb/cdbsubselect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ is_exprs_nullable_internal(Node *exprs, List *nonnullable_vars)
14551455
* select c1 from t1 where c1 NOT IN (select c2 from t2);
14561456
* (to)
14571457
* select c1 from t1 left anti semi join (select 0 as zero, c2 from t2) foo
1458-
* ON (c1 = c2) IS NOT FALSE where zero is NULL;
1458+
* ON (c1 != c2) IS NOT FALSE where zero is NULL;
14591459
*
14601460
* The pseudoconstant column zero is needed to correctly pipe in the NULLs
14611461
* from the subselect upstream.

0 commit comments

Comments
 (0)