SQLite

Check-in [7101ccd533]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a problem that could occur when the RHS of an IN operator was a compound SELECT featuring an ORDER BY on a subquery that was flattened into one of the component SELECTs introduced by [baa83b460c677c21]. Problem reported in forum post 1e17219c88.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7101ccd5331e36fd1a539f540e79ce0ce159be76ec422e1d9436eec6f3908c6e
User & Date: dan 2025-03-18 19:21:04.551
Original Comment: Fix a problem that could occur when the RHS of an IN operator was a compound SELECT featuring an ORDER BY on a subquery that was flattened into one of the component SELECTs introduced by [baa83b460c677c21]. Forum post /forumpost/1e17219c88.
Context
2025-03-18
20:15
Change the generate_series() table-valued function so that its rowid is just an alias for its value. This allows it to be used as the RHS operand of a RIGHT JOIN. This fixes the issue raised by forum post 1e17219c88. (check-in: 77db4d85e7 user: drh tags: trunk)
19:21
Fix a problem that could occur when the RHS of an IN operator was a compound SELECT featuring an ORDER BY on a subquery that was flattened into one of the component SELECTs introduced by [baa83b460c677c21]. Problem reported in forum post 1e17219c88. (check-in: 7101ccd533 user: dan tags: trunk)
13:52
Internal doc touchups in ext/wasm/mkwasmbuilds.c. No functional changes. (check-in: 47d34260e7 user: stephan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/select.c.
3243
3244
3245
3246
3247
3248
3249

3250
3251
3252
3253
3254
3255
3256
    }
    sqlite3KeyInfoUnref(pKeyInfo);
  }

multi_select_end:
  pDest->iSdst = dest.iSdst;
  pDest->nSdst = dest.nSdst;

  if( pDelete ){
    sqlite3ParserAddCleanup(pParse, sqlite3SelectDeleteGeneric, pDelete);
  }
  return rc;
}
#endif /* SQLITE_OMIT_COMPOUND_SELECT */








>







3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
    }
    sqlite3KeyInfoUnref(pKeyInfo);
  }

multi_select_end:
  pDest->iSdst = dest.iSdst;
  pDest->nSdst = dest.nSdst;
  pDest->iSDParm2 = dest.iSDParm2;
  if( pDelete ){
    sqlite3ParserAddCleanup(pParse, sqlite3SelectDeleteGeneric, pDelete);
  }
  return rc;
}
#endif /* SQLITE_OMIT_COMPOUND_SELECT */

Changes to test/bloom1.test.
179
180
181
182
183
184
185









































186
187
188
  INSERT INTO t2 VALUES(7);
  ANALYZE;
  CREATE INDEX t2x ON t2(true IN ());
}
do_execsql_test 4.4 {
  SELECT * FROM t0 LEFT JOIN t1 LEFT JOIN t2 ON (b NOTNULL)==(c IN ()) WHERE c;
} {xyz {} 7.0}









































 

finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
  INSERT INTO t2 VALUES(7);
  ANALYZE;
  CREATE INDEX t2x ON t2(true IN ());
}
do_execsql_test 4.4 {
  SELECT * FROM t0 LEFT JOIN t1 LEFT JOIN t2 ON (b NOTNULL)==(c IN ()) WHERE c;
} {xyz {} 7.0}

reset_db
do_execsql_test 5.0 {
  CREATE TABLE t1 (c1);
  INSERT INTO t1 VALUES (101);
  CREATE TABLE t2 ( x );
  INSERT INTO t2 VALUES(404);
}

do_execsql_test 5.1 {
  SELECT 'val' in (
      select 'val' from ( select 'valueB' from t1 order by 1 ) 
      union all 
      select 'val'
  );
} {1}

do_execsql_test 5.2 {
  select * from t2
    where 'val' in (
        select 'val' from ( select 'valueB' from t1 order by 1 ) 
        union all 
        select 'val'
    );
} {404}

do_execsql_test 5.3 {
  SELECT subq_1.c_0 as c_0 
  FROM ( SELECT 0 as c_0) as subq_1
  WHERE (subq_1.c_0) IN (
    SELECT subq_2.c_0 as c_0
    FROM (
      SELECT 0 as c_0
      FROM t1 as ref_1
      WHERE (ref_1.c1) = (2)
      ORDER BY c_0 desc
    ) as subq_2
    UNION ALL
    SELECT 0 as c_0
  );
} {0}
 

finish_test