Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Have fts5 reject attempts to insert a non-integer, non-null value into a rowid column with SQLITE_MISMATCH. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
4a9483f81e9ca1aa41d6ca33cb317137 |
User & Date: | dan 2019-01-15 15:18:58.151 |
Context
2019-01-15
| ||
16:14 | Fix a buffer overread in fts3 caused by a corrupt record. (check-in: e54efd60c2 user: dan tags: trunk) | |
15:18 | Have fts5 reject attempts to insert a non-integer, non-null value into a rowid column with SQLITE_MISMATCH. (check-in: 4a9483f81e user: dan tags: trunk) | |
14:44 | Fix a harmless memory leak in the Lemon parser generator utility program. (check-in: 1caff0fb0b user: drh tags: trunk) | |
Changes
Changes to ext/fts5/fts5_main.c.
︙ | ︙ | |||
1493 1494 1495 1496 1497 1498 1499 | int rc = SQLITE_OK; /* Return code */ /* A transaction must be open when this is called. */ assert( pTab->ts.eState==1 ); assert( pVtab->zErrMsg==0 ); assert( nArg==1 || nArg==(2+pConfig->nCol+2) ); | < | | | 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 | int rc = SQLITE_OK; /* Return code */ /* A transaction must be open when this is called. */ assert( pTab->ts.eState==1 ); assert( pVtab->zErrMsg==0 ); assert( nArg==1 || nArg==(2+pConfig->nCol+2) ); assert( sqlite3_value_type(apVal[0])==SQLITE_INTEGER || sqlite3_value_type(apVal[0])==SQLITE_NULL ); assert( pTab->pConfig->pzErrmsg==0 ); pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg; /* Put any active cursors into REQUIRE_SEEK state. */ fts5TripCursors(pTab); |
︙ | ︙ | |||
1552 1553 1554 1555 1556 1557 1558 | /* DELETE */ else if( nArg==1 ){ i64 iDel = sqlite3_value_int64(apVal[0]); /* Rowid to delete */ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0); } | | > > > > > > > | | | < < | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 | /* DELETE */ else if( nArg==1 ){ i64 iDel = sqlite3_value_int64(apVal[0]); /* Rowid to delete */ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0); } /* INSERT or UPDATE */ else{ int eType1 = sqlite3_value_numeric_type(apVal[1]); if( eType1!=SQLITE_INTEGER && eType1!=SQLITE_NULL ){ rc = SQLITE_MISMATCH; } else if( eType0!=SQLITE_INTEGER ){ /* If this is a REPLACE, first remove the current entry (if any) */ if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){ i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0); } fts5StorageInsert(&rc, pTab, apVal, pRowid); } /* UPDATE */ else{ i64 iOld = sqlite3_value_int64(apVal[0]); /* Old rowid */ i64 iNew = sqlite3_value_int64(apVal[1]); /* New rowid */ if( eType1==SQLITE_INTEGER && iOld!=iNew ){ if( eConflict==SQLITE_REPLACE ){ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0); if( rc==SQLITE_OK ){ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0); } fts5StorageInsert(&rc, pTab, apVal, pRowid); }else{ rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, pRowid); if( rc==SQLITE_OK ){ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0); } if( rc==SQLITE_OK ){ rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal,*pRowid); } } }else{ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0); fts5StorageInsert(&rc, pTab, apVal, pRowid); } } } } pTab->pConfig->pzErrmsg = 0; return rc; } |
︙ | ︙ |
Changes to ext/fts5/test/fts5update.test.
︙ | ︙ | |||
130 131 132 133 134 135 136 137 138 139 140 141 142 143 | db eval { SELECT * FROM x3('one') } { db eval { INSERT INTO x3(x3) VALUES('optimize'); } } } {} } reset_db do_catchsql_test 4.0 { CREATE VIRTUAL TABLE t1 USING fts5(a,b,c); } {0 {}} do_catchsql_test 4.1 { DELETE FROM t1 WHERE t1 MATCH 'f*'; } {0 {}} finish_test | > > > > > > > > > > > > > > | 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 | db eval { SELECT * FROM x3('one') } { db eval { INSERT INTO x3(x3) VALUES('optimize'); } } } {} do_execsql_test 4.0 { CREATE VIRTUAL TABLE x4 USING fts5(a, detail=%DETAIL%); INSERT INTO x4 VALUES('one two three'); INSERT INTO x4(rowid, a) VALUES('2', 'one two three'); INSERT INTO x4(rowid, a) VALUES('3.0', 'one two three'); } do_catchsql_test 4.1 { INSERT INTO x4(rowid, a) VALUES('four', 'one two three'); } {1 {datatype mismatch}} do_catchsql_test 4.2 { UPDATE x4 SET rowid = 'four' WHERE rowid=1; } {1 {datatype mismatch}} } reset_db do_catchsql_test 4.0 { CREATE VIRTUAL TABLE t1 USING fts5(a,b,c); } {0 {}} do_catchsql_test 4.1 { DELETE FROM t1 WHERE t1 MATCH 'f*'; } {0 {}} finish_test |