Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Merge latest trunk changes. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | changesetfuzz |
Files: | files | file ages | folders |
SHA3-256: |
b6d549c988e765789c4a81d586170451 |
User & Date: | dan 2018-11-10 17:36:55.425 |
Context
2018-11-10
| ||
17:37 | Add the "changesetfuzz" program. For fuzzing changeset blobs. (check-in: 2bae0e7c1c user: dan tags: trunk) | |
17:36 | Merge latest trunk changes. (Closed-Leaf check-in: b6d549c988 user: dan tags: changesetfuzz) | |
2018-11-09
| ||
23:41 | Fix invalid use of unprotected sqlite3_value objects in the sqldiff utility, when using the --changeset option. (check-in: a8d65214a5 user: drh tags: trunk) | |
2018-11-08
| ||
14:59 | Add tests and a fix for program "changesetfuzz". (check-in: 09b90db56c user: dan tags: changesetfuzz) | |
Changes
Changes to src/alter.c.
︙ | ︙ | |||
1440 1441 1442 1443 1444 1445 1446 | sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC); if( sParse.nErr ) rc = sParse.rc; sqlite3WalkSelect(&sWalker, pTab->pSelect); } }else{ /* Modify any FK definitions to point to the new table. */ #ifndef SQLITE_OMIT_FOREIGN_KEY | | | 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 | sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC); if( sParse.nErr ) rc = sParse.rc; sqlite3WalkSelect(&sWalker, pTab->pSelect); } }else{ /* Modify any FK definitions to point to the new table. */ #ifndef SQLITE_OMIT_FOREIGN_KEY if( isLegacy==0 || (db->flags & SQLITE_ForeignKeys) ){ FKey *pFKey; for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){ if( sqlite3_stricmp(pFKey->zTo, zOld)==0 ){ renameTokenFind(&sParse, &sCtx, (void*)pFKey->zTo); } } } |
︙ | ︙ |
Changes to src/sqliteInt.h.
︙ | ︙ | |||
3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 | void *sqlite3TestTextToPtr(const char*); #endif #if defined(SQLITE_DEBUG) void sqlite3TreeViewExpr(TreeView*, const Expr*, u8); void sqlite3TreeViewBareExprList(TreeView*, const ExprList*, const char*); void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*); void sqlite3TreeViewSelect(TreeView*, const Select*, u8); void sqlite3TreeViewWith(TreeView*, const With*, u8); #ifndef SQLITE_OMIT_WINDOWFUNC void sqlite3TreeViewWindow(TreeView*, const Window*, u8); void sqlite3TreeViewWinFunc(TreeView*, const Window*, u8); #endif #endif | > | 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 | void *sqlite3TestTextToPtr(const char*); #endif #if defined(SQLITE_DEBUG) void sqlite3TreeViewExpr(TreeView*, const Expr*, u8); void sqlite3TreeViewBareExprList(TreeView*, const ExprList*, const char*); void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*); void sqlite3TreeViewSrcList(TreeView*, const SrcList*); void sqlite3TreeViewSelect(TreeView*, const Select*, u8); void sqlite3TreeViewWith(TreeView*, const With*, u8); #ifndef SQLITE_OMIT_WINDOWFUNC void sqlite3TreeViewWindow(TreeView*, const Window*, u8); void sqlite3TreeViewWinFunc(TreeView*, const Window*, u8); #endif #endif |
︙ | ︙ |
Changes to src/treeview.c.
︙ | ︙ | |||
117 118 119 120 121 122 123 124 125 126 127 128 129 130 | sqlite3TreeViewSelect(pView, pCte->pSelect, 0); sqlite3TreeViewPop(pView); } sqlite3TreeViewPop(pView); } } /* ** Generate a human-readable description of a Select object. */ void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){ int n = 0; int cnt = 0; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | sqlite3TreeViewSelect(pView, pCte->pSelect, 0); sqlite3TreeViewPop(pView); } sqlite3TreeViewPop(pView); } } /* ** Generate a human-readable description of a SrcList object. */ void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){ int i; for(i=0; i<pSrc->nSrc; i++){ const struct SrcList_item *pItem = &pSrc->a[i]; StrAccum x; char zLine[100]; sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); sqlite3_str_appendf(&x, "{%d,*}", pItem->iCursor); if( pItem->zDatabase ){ sqlite3_str_appendf(&x, " %s.%s", pItem->zDatabase, pItem->zName); }else if( pItem->zName ){ sqlite3_str_appendf(&x, " %s", pItem->zName); } if( pItem->pTab ){ sqlite3_str_appendf(&x, " tabname=%Q", pItem->pTab->zName); } if( pItem->zAlias ){ sqlite3_str_appendf(&x, " (AS %s)", pItem->zAlias); } if( pItem->fg.jointype & JT_LEFT ){ sqlite3_str_appendf(&x, " LEFT-JOIN"); } sqlite3StrAccumFinish(&x); sqlite3TreeViewItem(pView, zLine, i<pSrc->nSrc-1); if( pItem->pSelect ){ sqlite3TreeViewSelect(pView, pItem->pSelect, 0); } if( pItem->fg.isTabFunc ){ sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:"); } sqlite3TreeViewPop(pView); } } /* ** Generate a human-readable description of a Select object. */ void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){ int n = 0; int cnt = 0; |
︙ | ︙ | |||
171 172 173 174 175 176 177 | for(pX=p->pWin; pX; pX=pX->pNextWin){ sqlite3TreeViewWinFunc(pView, pX, pX->pNextWin!=0); } sqlite3TreeViewPop(pView); } #endif if( p->pSrc && p->pSrc->nSrc ){ | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | for(pX=p->pWin; pX; pX=pX->pNextWin){ sqlite3TreeViewWinFunc(pView, pX, pX->pNextWin!=0); } sqlite3TreeViewPop(pView); } #endif if( p->pSrc && p->pSrc->nSrc ){ pView = sqlite3TreeViewPush(pView, (n--)>0); sqlite3TreeViewLine(pView, "FROM"); sqlite3TreeViewSrcList(pView, p->pSrc); sqlite3TreeViewPop(pView); } if( p->pWhere ){ sqlite3TreeViewItem(pView, "WHERE", (n--)>0); sqlite3TreeViewExpr(pView, p->pWhere, 0); sqlite3TreeViewPop(pView); } |
︙ | ︙ |
Changes to src/where.c.
︙ | ︙ | |||
850 851 852 853 854 855 856 | if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue); if( pTabItem->fg.viaCoroutine ){ sqlite3VdbeChangeP2(v, addrCounter, regBase+n); testcase( pParse->db->mallocFailed ); translateColumnToCopy(pParse, addrTop, pLevel->iTabCur, pTabItem->regResult, 1); sqlite3VdbeGoto(v, addrTop); | < | 850 851 852 853 854 855 856 857 858 859 860 861 862 863 | if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue); if( pTabItem->fg.viaCoroutine ){ sqlite3VdbeChangeP2(v, addrCounter, regBase+n); testcase( pParse->db->mallocFailed ); translateColumnToCopy(pParse, addrTop, pLevel->iTabCur, pTabItem->regResult, 1); sqlite3VdbeGoto(v, addrTop); }else{ sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v); } sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX); sqlite3VdbeJumpHere(v, addrTop); sqlite3ReleaseTempReg(pParse, regRecord); |
︙ | ︙ |
Changes to test/altertab2.test.
︙ | ︙ | |||
36 37 38 39 40 41 42 43 44 45 46 | } do_execsql_test 1.2 { INSERT INTO rr VALUES('in', 'tcl'); SELECT * FROM ffff; } {hello world in tcl} } finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | } do_execsql_test 1.2 { INSERT INTO rr VALUES('in', 'tcl'); SELECT * FROM ffff; } {hello world in tcl} } #------------------------------------------------------------------------- # Check that table names that appear in REFERENCES clauses are updated # when a table is renamed unless: # # a) "PRAGMA legacy_alter_table" is true, and # b) "PRAGMA foreign_keys" is false. # do_execsql_test 2.0 { CREATE TABLE p1(a PRIMARY KEY, b); CREATE TABLE c1(x REFERENCES p1); CREATE TABLE c2(x, FOREIGN KEY (x) REFERENCES p1); CREATE TABLE c3(x, FOREIGN KEY (x) REFERENCES p1(a)); } do_execsql_test 2.1 { ALTER TABLE p1 RENAME TO p2; SELECT sql FROM sqlite_master WHERE name LIKE 'c%'; } { {CREATE TABLE c1(x REFERENCES "p2")} {CREATE TABLE c2(x, FOREIGN KEY (x) REFERENCES "p2")} {CREATE TABLE c3(x, FOREIGN KEY (x) REFERENCES "p2"(a))} } do_execsql_test 2.2 { PRAGMA legacy_alter_table = 1; ALTER TABLE p2 RENAME TO p3; SELECT sql FROM sqlite_master WHERE name LIKE 'c%'; } { {CREATE TABLE c1(x REFERENCES "p2")} {CREATE TABLE c2(x, FOREIGN KEY (x) REFERENCES "p2")} {CREATE TABLE c3(x, FOREIGN KEY (x) REFERENCES "p2"(a))} } do_execsql_test 2.3 { ALTER TABLE p3 RENAME TO p2; PRAGMA foreign_keys = 1; ALTER TABLE p2 RENAME TO p3; SELECT sql FROM sqlite_master WHERE name LIKE 'c%'; } { {CREATE TABLE c1(x REFERENCES "p3")} {CREATE TABLE c2(x, FOREIGN KEY (x) REFERENCES "p3")} {CREATE TABLE c3(x, FOREIGN KEY (x) REFERENCES "p3"(a))} } finish_test |
Changes to test/autoindex5.test.
︙ | ︙ | |||
119 120 121 122 123 124 125 126 127 128 | UNION ALL SELECT 0, 0 WHERE 0; SELECT ( SELECT sum(z) FROM vvv WHERE x='aaa' ) FROM one; } {8.0} finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | UNION ALL SELECT 0, 0 WHERE 0; SELECT ( SELECT sum(z) FROM vvv WHERE x='aaa' ) FROM one; } {8.0} # Ticket https://www.sqlite.org/src/info/787fa716be3a7f65 # Segfault due to multiple uses of the same subquery where the # subquery is implemented via coroutine. # sqlite3 db :memory: do_execsql_test 3.0 { -- This is the original test case reported on the mailing list CREATE TABLE artists ( id integer NOT NULL PRIMARY KEY AUTOINCREMENT, name varchar(255) ); CREATE TABLE albums ( id integer NOT NULL PRIMARY KEY AUTOINCREMENT, name varchar(255), artist_id integer REFERENCES artists ); INSERT INTO artists (name) VALUES ('Ar'); INSERT INTO albums (name, artist_id) VALUES ('Al', 1); SELECT artists.* FROM artists INNER JOIN artists AS 'b' ON (b.id = artists.id) WHERE (artists.id IN ( SELECT albums.artist_id FROM albums WHERE ((name = 'Al') AND (albums.artist_id IS NOT NULL) AND (albums.id IN ( SELECT id FROM ( SELECT albums.id, row_number() OVER ( PARTITION BY albums.artist_id ORDER BY name ) AS 'x' FROM albums WHERE (name = 'Al') ) AS 't1' WHERE (x = 1) )) AND (albums.id IN (1, 2))) )); } {1 Ar} # The remaining test cases were discovered (by Dan) during trouble-shooting sqlite3 db :memory: do_execsql_test 3.1 { CREATE TABLE t1 (a); INSERT INTO t1 (a) VALUES (104); CREATE TABLE t2 (b); INSERT INTO t2 (b) VALUES (104); CREATE TABLE t3 (c); INSERT INTO t3 (c) VALUES (104); CREATE TABLE t4 (d); INSERT INTO t4 (d) VALUES (104); SELECT * FROM t1 CROSS JOIN t2 ON (t1.a = t2.b) WHERE t2.b IN ( SELECT t3.c FROM t3 WHERE t3.c IN ( SELECT d FROM (SELECT DISTINCT d FROM t4) AS x WHERE x.d=104 ) ); } {104 104} sqlite3 db :memory: do_execsql_test 3.2 { CREATE TABLE t5(a, b, c, d); CREATE INDEX t5a ON t5(a); CREATE INDEX t5b ON t5(b); CREATE TABLE t6(e); INSERT INTO t6 VALUES(1); INSERT INTO t5 VALUES(1,1,1,1), (2,2,2,2); SELECT * FROM t5 WHERE (a=1 OR b=2) AND c IN ( SELECT e FROM (SELECT DISTINCT e FROM t6) WHERE e=1 ); } {1 1 1 1} sqlite3 db :memory: do_execsql_test 3.3 { CREATE TABLE t1(a1, a2, a3); CREATE INDEX t1a2 ON t1(a2, a1); CREATE INDEX t1a3 ON t1(a3, a1); CREATE TABLE t2(d); INSERT INTO t1 VALUES(3, 1, 1), (3, 2, 2); INSERT INTO t2 VALUES(3); SELECT *, 'x' FROM t1 WHERE (a2=1 OR a3=2) AND a1 = ( SELECT d FROM (SELECT DISTINCT d FROM t2) WHERE d=3 ); } {3 1 1 x 3 2 2 x} finish_test |
Changes to tool/sqldiff.c.
︙ | ︙ | |||
1489 1490 1491 1492 1493 1494 1495 | fwrite(p+n+1, 9-n, 1, out); } } /* ** Write an SQLite value onto out. */ | | | | | | | | | | 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 | fwrite(p+n+1, 9-n, 1, out); } } /* ** Write an SQLite value onto out. */ static void putValue(FILE *out, sqlite3_stmt *pStmt, int k){ int iDType = sqlite3_column_type(pStmt, k); sqlite3_int64 iX; double rX; sqlite3_uint64 uX; int j; putc(iDType, out); switch( iDType ){ case SQLITE_INTEGER: iX = sqlite3_column_int64(pStmt, k); memcpy(&uX, &iX, 8); for(j=56; j>=0; j-=8) putc((uX>>j)&0xff, out); break; case SQLITE_FLOAT: rX = sqlite3_column_double(pStmt, k); memcpy(&uX, &rX, 8); for(j=56; j>=0; j-=8) putc((uX>>j)&0xff, out); break; case SQLITE_TEXT: iX = sqlite3_column_bytes(pStmt, k); putsVarint(out, (sqlite3_uint64)iX); fwrite(sqlite3_column_text(pStmt, k),1,(size_t)iX,out); break; case SQLITE_BLOB: iX = sqlite3_column_bytes(pStmt, k); putsVarint(out, (sqlite3_uint64)iX); fwrite(sqlite3_column_blob(pStmt, k),1,(size_t)iX,out); break; case SQLITE_NULL: break; } } /* |
︙ | ︙ | |||
1646 1647 1648 1649 1650 1651 1652 | int iType = sqlite3_column_int(pStmt,0); putc(iType, out); putc(0, out); switch( sqlite3_column_int(pStmt,0) ){ case SQLITE_UPDATE: { for(k=1, i=0; i<nCol; i++){ if( aiFlg[i] ){ | | | | | | | | | 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 | int iType = sqlite3_column_int(pStmt,0); putc(iType, out); putc(0, out); switch( sqlite3_column_int(pStmt,0) ){ case SQLITE_UPDATE: { for(k=1, i=0; i<nCol; i++){ if( aiFlg[i] ){ putValue(out, pStmt, k); k++; }else if( sqlite3_column_int(pStmt,k) ){ putValue(out, pStmt, k+1); k += 3; }else{ putc(0, out); k += 3; } } for(k=1, i=0; i<nCol; i++){ if( aiFlg[i] ){ putc(0, out); k++; }else if( sqlite3_column_int(pStmt,k) ){ putValue(out, pStmt, k+2); k += 3; }else{ putc(0, out); k += 3; } } break; } case SQLITE_INSERT: { for(k=1, i=0; i<nCol; i++){ if( aiFlg[i] ){ putValue(out, pStmt, k); k++; }else{ putValue(out, pStmt, k+2); k += 3; } } break; } case SQLITE_DELETE: { for(k=1, i=0; i<nCol; i++){ if( aiFlg[i] ){ putValue(out, pStmt, k); k++; }else{ putValue(out, pStmt, k+1); k += 3; } } break; } } } |
︙ | ︙ |