SQLite

Check-in [54410f0e77]
Login

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

Overview
Comment:Ensure that an ALWAYS() in the rename logic really is always true, even for faulty inputs.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 54410f0e7710542d5159d0449898598d2b7f7676bfd993644ca47da1bf1fcdac
User & Date: drh 2019-12-04 15:08:58.371
Context
2019-12-04
19:45
Window functions are never constant. (check-in: 35f0b5a8c7 user: drh tags: trunk)
15:08
Ensure that an ALWAYS() in the rename logic really is always true, even for faulty inputs. (check-in: 54410f0e77 user: drh tags: trunk)
14:26
Fix an assert() failure that could occur in ALTER TABLE code when the schema contains a view that uses a CTE. (check-in: 75b04a4b0d user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/alter.c.
753
754
755
756
757
758
759

760
761
762
763
764
765
766

/*
** Walker callback used by sqlite3RenameExprUnmap().
*/
static int renameUnmapSelectCb(Walker *pWalker, Select *p){
  Parse *pParse = pWalker->pParse;
  int i;

  if( ALWAYS(p->pEList) ){
    ExprList *pList = p->pEList;
    for(i=0; i<pList->nExpr; i++){
      if( pList->a[i].zName ){
        sqlite3RenameTokenRemap(pParse, 0, (void*)pList->a[i].zName);
      }
    }







>







753
754
755
756
757
758
759
760
761
762
763
764
765
766
767

/*
** Walker callback used by sqlite3RenameExprUnmap().
*/
static int renameUnmapSelectCb(Walker *pWalker, Select *p){
  Parse *pParse = pWalker->pParse;
  int i;
  if( pParse->nErr ) return WRC_Abort;
  if( ALWAYS(p->pEList) ){
    ExprList *pList = p->pEList;
    for(i=0; i<pList->nExpr; i++){
      if( pList->a[i].zName ){
        sqlite3RenameTokenRemap(pParse, 0, (void*)pList->a[i].zName);
      }
    }
Changes to test/altertab3.test.
461
462
463
464
465
466
467









468
469
  " {}

  do_catchsql_test 19.$tn.2 {
    ALTER TABLE a RENAME TO g;
  } $res
}











finish_test







>
>
>
>
>
>
>
>
>


461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
  " {}

  do_catchsql_test 19.$tn.2 {
    ALTER TABLE a RENAME TO g;
  } $res
}

# Verify that the "if( pParse->nErr ) return WRC_Abort" at the top of the
# renameUnmapSelectCb() routine in alter.c (2019-12-04) is really required.
#
sqlite3 db :memory:
do_catchsql_test 20.10 {
  CREATE TABLE s(a, b, c);
  CREATE INDEX k ON s( (WITH s AS( SELECT * ) VALUES(2) ) IN () );
  ALTER TABLE s RENAME a TO a2;
} {1 {error in index k: no tables specified}}

finish_test