/ Check-in [9664e2b6]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Fix a case in where.c where a crash can follow a malloc failure. Also modify test code in test8.c to check a return code that was being dropped (causing a test in vtab_err.test to fail). (CVS 6567)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9664e2b6c69271a7ca55af7812a186773a7c6592
User & Date: danielk1977 2009-04-29 11:50:54
Context
2009-04-29
14:33
Update the documentation on the sqlite3_changes() and sqlite3_total_changes() functions. (CVS 6568) check-in: 58c7bdb2 user: drh tags: trunk
11:50
Fix a case in where.c where a crash can follow a malloc failure. Also modify test code in test8.c to check a return code that was being dropped (causing a test in vtab_err.test to fail). (CVS 6567) check-in: 9664e2b6 user: danielk1977 tags: trunk
11:31
Add a version of cellSizePtr() that is faster than using sqlite3BtreeParseCellPtr(). This speeds up balance_nonroot(). (CVS 6566) check-in: e8f7f7b7 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test8.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing the virtual table interfaces.  This code
    13     13   ** is not included in the SQLite library.  It is used for automated
    14     14   ** testing of the SQLite library.
    15     15   **
    16         -** $Id: test8.c,v 1.77 2009/04/21 09:02:47 danielk1977 Exp $
           16  +** $Id: test8.c,v 1.78 2009/04/29 11:50:54 danielk1977 Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "tcl.h"
    20     20   #include <stdlib.h>
    21     21   #include <string.h>
    22     22   
    23     23   #ifndef SQLITE_OMIT_VIRTUALTABLE
................................................................................
   691    691   
   692    692     /* Prepare the SQL statement created by echoBestIndex and bind the
   693    693     ** runtime parameters passed to this function to it.
   694    694     */
   695    695     rc = sqlite3_prepare(db, idxStr, -1, &pCur->pStmt, 0);
   696    696     assert( pCur->pStmt || rc!=SQLITE_OK );
   697    697     for(i=0; rc==SQLITE_OK && i<argc; i++){
   698         -    sqlite3_bind_value(pCur->pStmt, i+1, argv[i]);
          698  +    rc = sqlite3_bind_value(pCur->pStmt, i+1, argv[i]);
   699    699     }
   700    700   
   701    701     /* If everything was successful, advance to the first row of the scan */
   702    702     if( rc==SQLITE_OK ){
   703    703       rc = echoNext(pVtabCursor);
   704    704     }
   705    705   

Changes to src/where.c.

    12     12   ** This module contains C code that generates VDBE code used to process
    13     13   ** the WHERE clause of SQL statements.  This module is responsible for
    14     14   ** generating the code that loops through a table looking for applicable
    15     15   ** rows.  Indices are selected and used to speed the search when doing
    16     16   ** so is applicable.  Because this module is responsible for selecting
    17     17   ** indices, you might also think of this module as the "query optimizer".
    18     18   **
    19         -** $Id: where.c,v 1.390 2009/04/24 15:46:22 drh Exp $
           19  +** $Id: where.c,v 1.391 2009/04/29 11:50:54 danielk1977 Exp $
    20     20   */
    21     21   #include "sqliteInt.h"
    22     22   
    23     23   /*
    24     24   ** Trace output macros
    25     25   */
    26     26   #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
................................................................................
  1742   1742     Table *pTab = pSrc->pTab;
  1743   1743     sqlite3_index_info *pIdxInfo;
  1744   1744     struct sqlite3_index_constraint *pIdxCons;
  1745   1745     struct sqlite3_index_constraint_usage *pUsage;
  1746   1746     WhereTerm *pTerm;
  1747   1747     int i, j;
  1748   1748     int nOrderBy;
         1749  +
         1750  +  /* Make sure wsFlags is initialized to some sane value. Otherwise, if the 
         1751  +  ** malloc in allocateIndexInfo() fails and this function returns leaving
         1752  +  ** wsFlags in an uninitialized state, the caller may behave unpredictably.
         1753  +  */
         1754  +  pCost->plan.wsFlags = WHERE_VIRTUALTABLE;
  1749   1755   
  1750   1756     /* If the sqlite3_index_info structure has not been previously
  1751   1757     ** allocated and initialized, then allocate and initialize it now.
  1752   1758     */
  1753   1759     pIdxInfo = *ppIdxInfo;
  1754   1760     if( pIdxInfo==0 ){
  1755   1761       *ppIdxInfo = pIdxInfo = allocateIndexInfo(pParse, pWC, pSrc, pOrderBy);
................................................................................
  1826   1832     ** is defined.
  1827   1833     */
  1828   1834     if( (SQLITE_BIG_DBL/((double)2))<pIdxInfo->estimatedCost ){
  1829   1835       pCost->rCost = (SQLITE_BIG_DBL/((double)2));
  1830   1836     }else{
  1831   1837       pCost->rCost = pIdxInfo->estimatedCost;
  1832   1838     }
  1833         -  pCost->plan.wsFlags = WHERE_VIRTUALTABLE;
  1834   1839     pCost->plan.u.pVtabIdx = pIdxInfo;
  1835   1840     if( pIdxInfo && pIdxInfo->orderByConsumed ){
  1836   1841       pCost->plan.wsFlags |= WHERE_ORDERBY;
  1837   1842     }
  1838   1843     pCost->plan.nEq = 0;
  1839   1844     pIdxInfo->nOrderBy = nOrderBy;
  1840   1845