SQLite

Check-in [c431b3fd]
Login

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

Overview
Comment:Fix a problem with ALTER TABLE for views that have a nested FROM clause. Ticket [f50af3e8a565776b].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c431b3fd8fd0f6a6974bba3e9366b0430ec003d570e7ce70ceefbcff5fe4b6fa
User & Date: drh 2020-02-23 17:34:45
References
2020-02-23
17:38 Fixed ticket [f50af3e8]: OOB memory access on a table rename plus 5 other changes (artifact: 929fcf1d user: drh)
Context
2020-02-24
17:05
If STAT4 determines that a WHERE clause term that is not used by an index has very high probability of being true, then do not use that term to reduce the estimated output row count. (check-in: 40739c79 user: drh tags: trunk)
13:26
Merge bugfix from trunk. (check-in: b542dee9 user: drh tags: stat4-truthprob)
2020-02-23
17:34
Fix a problem with ALTER TABLE for views that have a nested FROM clause. Ticket [f50af3e8a565776b]. (check-in: c431b3fd user: drh tags: trunk)
2020-02-22
13:01
In the OP_Column opcode, if the cursor is marked NullRow (due to being the right table of a LEFT JOIN that does not match) and the cursor is the table cursor for an OR-optimization with a covering index, then do not substitute the covering index cursor, since the covering index cursor does not have the NullRow flag set. Ticket [aa4378693018aa99] (check-in: f02030b3 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/select.c.

5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
              }
            }else{
              pExpr = pRight;
            }
            pNew = sqlite3ExprListAppend(pParse, pNew, pExpr);
            sqlite3TokenInit(&sColname, zColname);
            sqlite3ExprListSetName(pParse, pNew, &sColname, 0);
            if( pNew && (p->selFlags & SF_NestedFrom)!=0 ){
              struct ExprList_item *pX = &pNew->a[pNew->nExpr-1];
              sqlite3DbFree(db, pX->zEName);
              if( pSub ){
                pX->zEName = sqlite3DbStrDup(db, pSub->pEList->a[j].zEName);
                testcase( pX->zEName==0 );
              }else{
                pX->zEName = sqlite3MPrintf(db, "%s.%s.%s",







|







5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
              }
            }else{
              pExpr = pRight;
            }
            pNew = sqlite3ExprListAppend(pParse, pNew, pExpr);
            sqlite3TokenInit(&sColname, zColname);
            sqlite3ExprListSetName(pParse, pNew, &sColname, 0);
            if( pNew && (p->selFlags & SF_NestedFrom)!=0 && !IN_RENAME_OBJECT ){
              struct ExprList_item *pX = &pNew->a[pNew->nExpr-1];
              sqlite3DbFree(db, pX->zEName);
              if( pSub ){
                pX->zEName = sqlite3DbStrDup(db, pSub->pEList->a[j].zEName);
                testcase( pX->zEName==0 );
              }else{
                pX->zEName = sqlite3MPrintf(db, "%s.%s.%s",

Changes to test/altertab.test.

608
609
610
611
612
613
614

















615
616
}
do_execsql_test 18.2.1 {
  ALTER TABLE t0 RENAME COLUMN c0 TO c1;
}
do_execsql_test 18.2.2 {
  SELECT sql FROM sqlite_master;
} {{CREATE TABLE t0 (c1 INTEGER, PRIMARY KEY(c1))}}


















finish_test







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


608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
}
do_execsql_test 18.2.1 {
  ALTER TABLE t0 RENAME COLUMN c0 TO c1;
}
do_execsql_test 18.2.2 {
  SELECT sql FROM sqlite_master;
} {{CREATE TABLE t0 (c1 INTEGER, PRIMARY KEY(c1))}}

# 2020-02-23 ticket f50af3e8a565776b
reset_db
do_execsql_test 19.100 {
  CREATE TABLE t1(x);
  CREATE VIEW t2 AS SELECT 1 FROM t1, (t1 AS a0, t1);
  ALTER TABLE t1 RENAME TO t3;
  SELECT sql FROM sqlite_master;
} {{CREATE TABLE "t3"(x)} {CREATE VIEW t2 AS SELECT 1 FROM "t3", ("t3" AS a0, "t3")}}
do_execsql_test 19.110 {
  INSERT INTO t3(x) VALUES(123);
  SELECT * FROM t2;
} {1}
do_execsql_test 19.120 {
  INSERT INTO t3(x) VALUES('xyz');
  SELECT * FROM t2;
} {1 1 1 1 1 1 1 1}

finish_test