Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a bad interaction between constant propagation and transitive term handling causing patterns like "WHERE unlikely(t1.x=t1.y) AND t1.y=?" to return non-matching rows. See forum post c38462ab5e. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
2363a14ca723c0343fbe350f6c19787a |
User & Date: | dan 2021-04-15 19:09:19 |
Original Comment: | Fix a bad interaction between constant propagation and transitive term handling causing patterns like "WHERE unlikely(t1.x=t1.y) AND t1.y=?" to return non-matching rows. |
Context
2021-04-16
| ||
01:03 | Do not invoke sqlite3ExprAffinity() if there is a possibility that the Expr is incomplete due to a prior OOM. dbsqlfuzz b8a824706914488bd236da51118eb9174ceb870f (check-in: e8a1515b user: drh tags: trunk) | |
2021-04-15
| ||
23:43 | Merge from (forked) trunk. Handle compile options that differ from default by being 0. (check-in: 6eb83f83 user: larrybr tags: compile_options) | |
19:09 | Fix a bad interaction between constant propagation and transitive term handling causing patterns like "WHERE unlikely(t1.x=t1.y) AND t1.y=?" to return non-matching rows. See forum post c38462ab5e. (check-in: 2363a14c user: dan tags: trunk) | |
13:26 | Add extra test case for OOM handling in where.c. (check-in: 7163de3d user: dan tags: trunk) | |
Changes
Changes to src/where.c.
︙ | ︙ | |||
257 258 259 260 261 262 263 | /* ** If the right-hand branch of the expression is a TK_COLUMN, then return ** a pointer to the right-hand branch. Otherwise, return NULL. */ static Expr *whereRightSubexprIsColumn(Expr *p){ p = sqlite3ExprSkipCollateAndLikely(p->pRight); | | > > | 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | /* ** If the right-hand branch of the expression is a TK_COLUMN, then return ** a pointer to the right-hand branch. Otherwise, return NULL. */ static Expr *whereRightSubexprIsColumn(Expr *p){ p = sqlite3ExprSkipCollateAndLikely(p->pRight); if( ALWAYS(p!=0) && p->op==TK_COLUMN && !ExprHasProperty(p, EP_FixedCol) ){ return p; } return 0; } /* ** Advance to the next WhereTerm that matches according to the criteria ** established when the pScan object was initialized by whereScanInit(). ** Return NULL if there are no more matching WhereTerms. |
︙ | ︙ |
Changes to test/whereG.test.
︙ | ︙ | |||
329 330 331 332 333 334 335 336 337 | reset_db do_execsql_test 10.1 { CREATE TABLE a(b TEXT); INSERT INTO a VALUES(0),(4),(9); CREATE TABLE c(d NUM); CREATE VIEW f(g, h) AS SELECT b, 0 FROM a UNION SELECT d, d FROM c; SELECT g = g FROM f GROUP BY h; } {1} finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | reset_db do_execsql_test 10.1 { CREATE TABLE a(b TEXT); INSERT INTO a VALUES(0),(4),(9); CREATE TABLE c(d NUM); CREATE VIEW f(g, h) AS SELECT b, 0 FROM a UNION SELECT d, d FROM c; SELECT g = g FROM f GROUP BY h; } {1} reset_db do_execsql_test 11.0 { CREATE TABLE t1(x PRIMARY KEY, y); INSERT INTO t1 VALUES('AAA', 'BBB'); CREATE TABLE t2(z); INSERT INTO t2 VALUES('t2'); CREATE TABLE t3(x PRIMARY KEY, y); INSERT INTO t3 VALUES('AAA', 'AAA'); } do_execsql_test 11.1.1 { SELECT * FROM t1 JOIN t2 ON unlikely(x=y) AND y='AAA' } do_execsql_test 11.1.2 { SELECT * FROM t1 JOIN t2 ON likely(x=y) AND y='AAA' } do_execsql_test 11.1.3 { SELECT * FROM t1 JOIN t2 ON x=y AND y='AAA' } do_execsql_test 11.2.1 { SELECT * FROM t3 JOIN t2 ON unlikely(x=y) AND y='AAA' } {AAA AAA t2} do_execsql_test 11.2.2 { SELECT * FROM t3 JOIN t2 ON likely(x=y) AND y='AAA' } {AAA AAA t2} do_execsql_test 11.2.3 { SELECT * FROM t3 JOIN t2 ON x=y AND y='AAA' } {AAA AAA t2} finish_test |