Index: src/select.c ================================================================== --- src/select.c +++ src/select.c @@ -744,11 +744,11 @@ ** part of the result. */ if( hasDistinct ){ switch( pDistinct->eTnctType ){ case WHERE_DISTINCT_ORDERED: { -#if 0 +#if 1 VdbeOp *pOp; /* No longer required OpenEphemeral instr. */ int iJump; /* Jump destination */ int regPrev; /* Previous row content */ /* Allocate space for the previous row */ Index: test/distinct2.test ================================================================== --- test/distinct2.test +++ test/distinct2.test @@ -75,7 +75,14 @@ INSERT INTO t5(a,b) VALUES(0,0),(1,0),(1,1),(0,3); CREATE TEMP TABLE out AS SELECT DISTINCT a+b FROM t5; SELECT * FROM out ORDER BY 1; } {0 1 2 3} +do_execsql_test 600 { + CREATE TABLE t6a(x INTEGER PRIMARY KEY); + INSERT INTO t6a VALUES(1); + CREATE TABLE t6b(y INTEGER PRIMARY KEY); + INSERT INTO t6b VALUES(2),(3); + SELECT DISTINCT x, x FROM t6a, t6b; +} {1 1} finish_test