Here is a variant of the second test case that does not require the manual
disabling of the query flattener:

<blockquote><verbatim>
CREATE TABLE t1 (a); INSERT INTO t1 (a) VALUES (104);
CREATE TABLE t2 (b); INSERT INTO t2 (b) VALUES (104);
CREATE TABLE t3 (c); INSERT INTO t3 (c) VALUES (104);
CREATE TABLE t4 (d); INSERT INTO t4 (d) VALUES (104);
SELECT *
FROM t1 CROSS JOIN t2 ON (t1.a = t2.b) WHERE t2.b IN (
  SELECT t3.c
  FROM t3
  WHERE t3.c IN (
    SELECT d FROM (SELECT DISTINCT d FROM t4) AS x WHERE x.d=104
  )
);