/ Check-in [05a9d129]
Login

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

Overview
Comment:First proposed fix for the ALTER TABLE problem described by ticket [b41031ea2b5372378cb3d2d]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tkt-b41031ea
Files: files | file ages | folders
SHA3-256: 05a9d129254e01a5f6b5e4033c105190eae386575a94b020ef3e0cbd30bbf056
User & Date: drh 2018-09-16 23:27:37
Context
2018-09-17
00:15
Add assert()s to the new code in the previous check-in. check-in: b12f23a5 user: drh tags: tkt-b41031ea
2018-09-16
23:27
First proposed fix for the ALTER TABLE problem described by ticket [b41031ea2b5372378cb3d2d] check-in: 05a9d129 user: drh tags: tkt-b41031ea
18:23
Remove an unreachable branch from the index-on-expression optimization. check-in: 2df2cf4f user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/resolve.c.

236
237
238
239
240
241
242
243


244
245
246
247
248
249
250
    ExprList *pEList;
    SrcList *pSrcList = pNC->pSrcList;

    if( pSrcList ){
      for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){
        pTab = pItem->pTab;
        assert( pTab!=0 && pTab->zName!=0 );
        assert( pTab->nCol>0 );


        if( pItem->pSelect && (pItem->pSelect->selFlags & SF_NestedFrom)!=0 ){
          int hit = 0;
          pEList = pItem->pSelect->pEList;
          for(j=0; j<pEList->nExpr; j++){
            if( sqlite3MatchSpanName(pEList->a[j].zSpan, zCol, zTab, zDb) ){
              cnt++;
              cntTab = 2;







|
>
>







236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
    ExprList *pEList;
    SrcList *pSrcList = pNC->pSrcList;

    if( pSrcList ){
      for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){
        pTab = pItem->pTab;
        assert( pTab!=0 && pTab->zName!=0 );
        if( pTab->nCol==0 ){
          if( sqlite3ViewGetColumnNames(pNC->pParse, pTab) ) return WRC_Abort;
        }
        if( pItem->pSelect && (pItem->pSelect->selFlags & SF_NestedFrom)!=0 ){
          int hit = 0;
          pEList = pItem->pSelect->pEList;
          for(j=0; j<pEList->nExpr; j++){
            if( sqlite3MatchSpanName(pEList->a[j].zSpan, zCol, zTab, zDb) ){
              cnt++;
              cntTab = 2;

Changes to test/alter.test.

871
872
873
874
875
876
877
878
879


















  SELECT * FROM t16a ORDER BY a;
} {abc 1.25 99 xyzzy cba 5.5 98 fizzle}
do_execsql_test alter-16.2 {
  ALTER TABLE t16a RENAME TO t16a_rn;
  SELECT * FROM t16a_rn ORDER BY a;
} {abc 1.25 99 xyzzy cba 5.5 98 fizzle}

finish_test


























|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
  SELECT * FROM t16a ORDER BY a;
} {abc 1.25 99 xyzzy cba 5.5 98 fizzle}
do_execsql_test alter-16.2 {
  ALTER TABLE t16a RENAME TO t16a_rn;
  SELECT * FROM t16a_rn ORDER BY a;
} {abc 1.25 99 xyzzy cba 5.5 98 fizzle}

# 2018-09-16 ticket b41031ea2b5372378cb3d2d43cf9fe2a4a5c2510
#
ifcapable rtree {
  db close
  sqlite3 db :memory:
  do_execsql_test alter-17.100 {
    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
    CREATE VIRTUAL TABLE t2 USING rtree(id,x0,x1);
    INSERT INTO t1 VALUES(1,'apple'),(2,'fig'),(3,'pear');
    INSERT INTO t2 VALUES(1,1.0,2.0),(2,2.0,3.0),(3,1.5,3.5);
    CREATE TRIGGER r1 AFTER UPDATE ON t1 BEGIN
      DELETE FROM t2 WHERE id = OLD.a;
    END;
    ALTER TABLE t1 RENAME TO t3;
    UPDATE t3 SET b='peach' WHERE a=2;
    SELECT * FROM t2 ORDER BY 1;
  } {1 1.0 2.0 3 1.5 3.5}
}

finish_test