/ Check-in [203f07c5]
Login

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

Overview
Comment:Fix a segfault that could occur if a query that used a vector comparison contained certain types of syntax errors.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rowvalue
Files: files | file ages | folders
SHA1:203f07c5e140e74cf91d0c1e20135c21236f0fc1
User & Date: dan 2016-08-20 15:01:24
Context
2016-08-20
17:00
Do not duplicate the Expr.pLeft subtree of a TK_SELECT_COLUMN node. check-in: 8384c77e user: drh tags: rowvalue
15:01
Fix a segfault that could occur if a query that used a vector comparison contained certain types of syntax errors. check-in: 203f07c5 user: dan tags: rowvalue
12:00
Improvements to the vector comparison splitter in exprAnalyze(). check-in: a3ffd283 user: drh tags: rowvalue
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/expr.c.

458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
  Expr *pVector,                  /* Vector to extract element from */
  int iField,                     /* Field to extract from pVector */
  int regSelect,                  /* First in array of registers */
  Expr **ppExpr,                  /* OUT: Expression element */
  int *pRegFree                   /* OUT: Temp register to free */
){
  assert( pVector->op==TK_VECTOR || pVector->op==TK_SELECT );
  assert( (pVector->op==TK_VECTOR)==(regSelect==0) );
  if( regSelect ){
    *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr;
     return regSelect+iField;
  }
  *ppExpr = pVector->x.pList->a[iField].pExpr;
  return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree);
}








|
|







458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
  Expr *pVector,                  /* Vector to extract element from */
  int iField,                     /* Field to extract from pVector */
  int regSelect,                  /* First in array of registers */
  Expr **ppExpr,                  /* OUT: Expression element */
  int *pRegFree                   /* OUT: Temp register to free */
){
  assert( pVector->op==TK_VECTOR || pVector->op==TK_SELECT );
  assert( pParse->nErr || (pVector->op==TK_VECTOR)==(regSelect==0) );
  if( pVector->op==TK_SELECT ){
    *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr;
     return regSelect+iField;
  }
  *ppExpr = pVector->x.pList->a[iField].pExpr;
  return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree);
}

Changes to test/rowvalue4.test.

287
288
289
290
291
292
293
















294
295
296
do_catchsql_test 7.3 {
  SELECT (a COLLATE nose, b) IN (SELECT a, b FROM f1) FROM f1;
} {1 {no such collation sequence: nose}}

do_catchsql_test 7.4 {
  SELECT * FROM f1 WHERE (?, ? COLLATE nose) > (a, b);
} {1 {no such collation sequence: nose}}

















finish_test








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



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
do_catchsql_test 7.3 {
  SELECT (a COLLATE nose, b) IN (SELECT a, b FROM f1) FROM f1;
} {1 {no such collation sequence: nose}}

do_catchsql_test 7.4 {
  SELECT * FROM f1 WHERE (?, ? COLLATE nose) > (a, b);
} {1 {no such collation sequence: nose}}

#-------------------------------------------------------------------------
drop_all_tables
do_execsql_test 8.1 {
  CREATE TABLE c1(x, y);
  CREATE TABLE c2(a, b, c);
  CREATE INDEX c2ab ON c2(a, b);
  CREATE INDEX c2c ON c2(c);

  CREATE TABLE c3(d);
}
do_catchsql_test 8.2 {
  SELECT * FROM c2 CROSS JOIN c3 WHERE 
    ( (a, b) == (SELECT x, y FROM c1) AND c3.d = c ) OR
    ( c == (SELECT x, y FROM c1) AND c3.d = c )
} {1 {sub-select returns 2 columns - expected 1}}

finish_test