Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a couple of segfaults that could occur after a malloc() failure in the SQL compiler. (CVS 4747) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
6bd8db3839d57a738cae219667981918 |
User & Date: | danielk1977 2008-01-23 15:44:51.000 |
Context
2008-01-23
| ||
17:13 | Fix another segfault that can occur following a malloc failure in the SQL compiler. (CVS 4748) (check-in: 9d98a3f0dd user: danielk1977 tags: trunk) | |
15:44 | Fix a couple of segfaults that could occur after a malloc() failure in the SQL compiler. (CVS 4747) (check-in: 6bd8db3839 user: danielk1977 tags: trunk) | |
14:51 | Testing coverage enhancements to sqlite3_get_table() and to the SELECT code generator. (CVS 4746) (check-in: 45c59802f6 user: drh tags: trunk) | |
Changes
Changes to src/select.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** ** $Id: select.c,v 1.408 2008/01/23 15:44:51 danielk1977 Exp $ */ #include "sqliteInt.h" /* ** Delete all the content of a Select structure but do not deallocate ** the select structure itself. |
︙ | ︙ | |||
1590 1591 1592 1593 1594 1595 1596 | int isOrder, /* 1 for ORDER BY. 0 for GROUP BY */ u8 *pHasAgg /* Set to TRUE if any term contains an aggregate */ ){ int i; sqlite3 *db = pParse->db; ExprList *pEList; | | | 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 | int isOrder, /* 1 for ORDER BY. 0 for GROUP BY */ u8 *pHasAgg /* Set to TRUE if any term contains an aggregate */ ){ int i; sqlite3 *db = pParse->db; ExprList *pEList; if( pOrderBy==0 || pParse->db->mallocFailed ) return 0; if( pOrderBy->nExpr>SQLITE_MAX_COLUMN ){ const char *zType = isOrder ? "ORDER" : "GROUP"; sqlite3ErrorMsg(pParse, "too many terms in %s BY clause", zType); return 1; } pEList = pSelect->pEList; if( pEList==0 ){ |
︙ | ︙ | |||
1620 1621 1622 1623 1624 1625 1626 | } if( iCol>0 ){ CollSeq *pColl = pE->pColl; int flags = pE->flags & EP_ExpCollate; sqlite3ExprDelete(pE); pE = sqlite3ExprDup(db, pEList->a[iCol-1].pExpr); pOrderBy->a[i].pExpr = pE; | | | 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 | } if( iCol>0 ){ CollSeq *pColl = pE->pColl; int flags = pE->flags & EP_ExpCollate; sqlite3ExprDelete(pE); pE = sqlite3ExprDup(db, pEList->a[iCol-1].pExpr); pOrderBy->a[i].pExpr = pE; if( pE && pColl && flags ){ pE->pColl = pColl; pE->flags |= flags; } } } return 0; } |
︙ | ︙ |
Changes to test/malloc.test.
︙ | ︙ | |||
12 13 14 15 16 17 18 | # This file attempts to check the behavior of the SQLite library in # an out-of-memory situation. When compiled with -DSQLITE_DEBUG=1, # the SQLite library accepts a special command (sqlite3_memdebug_fail N C) # which causes the N-th malloc to fail. This special feature is used # to see what happens in the library if a malloc were to really fail # due to an out-of-memory situation. # | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # This file attempts to check the behavior of the SQLite library in # an out-of-memory situation. When compiled with -DSQLITE_DEBUG=1, # the SQLite library accepts a special command (sqlite3_memdebug_fail N C) # which causes the N-th malloc to fail. This special feature is used # to see what happens in the library if a malloc were to really fail # due to an out-of-memory situation. # # $Id: malloc.test,v 1.56 2008/01/23 15:44:51 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Only run these tests if memory debugging is turned on. # ifcapable !memdebug { |
︙ | ︙ | |||
56 57 58 59 60 61 62 63 64 65 66 67 68 69 | CREATE INDEX i1 ON t1(a,b); INSERT INTO t1 VALUES(1,2.3,4.5,'hi',x'746865726500'); INSERT INTO t1 VALUES(6,7.0,0.8,'hello','out yonder'); SELECT * FROM t1; SELECT avg(b) FROM t1 GROUP BY a HAVING b>20.0; DELETE FROM t1 WHERE a IN (SELECT min(a) FROM t1); SELECT count(*), group_concat(e) FROM t1; } } # Ensure that no file descriptors were leaked. do_test malloc-1.X { catch {db close} set sqlite_open_file_count | > | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | CREATE INDEX i1 ON t1(a,b); INSERT INTO t1 VALUES(1,2.3,4.5,'hi',x'746865726500'); INSERT INTO t1 VALUES(6,7.0,0.8,'hello','out yonder'); SELECT * FROM t1; SELECT avg(b) FROM t1 GROUP BY a HAVING b>20.0; DELETE FROM t1 WHERE a IN (SELECT min(a) FROM t1); SELECT count(*), group_concat(e) FROM t1; SELECT b FROM t1 ORDER BY 1 COLLATE nocase; } } # Ensure that no file descriptors were leaked. do_test malloc-1.X { catch {db close} set sqlite_open_file_count |
︙ | ︙ |