/ Check-in [4a9dd5e7]
Login

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

Overview
Comment:Error messages from virtual tables store on the sqlite3_vtab->zErrMsg field are reported back up to the application interface and memory is reclaimed. (CVS 5466)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4a9dd5e782a363e93d4705fa3671bc6cf0bb5a33
User & Date: drh 2008-07-23 21:07:25
Context
2008-07-24
08:20
Add mem6.c, a new allocator. More to come. (CVS 5467) check-in: 192bc192 user: danielk1977 tags: trunk
2008-07-23
21:07
Error messages from virtual tables store on the sqlite3_vtab->zErrMsg field are reported back up to the application interface and memory is reclaimed. (CVS 5466) check-in: 4a9dd5e7 user: drh tags: trunk
20:28
Remove stray breakpoints from test scripts. (CVS 5465) check-in: cb5e75df user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

    39     39   **
    40     40   ** Various scripts scan this source file in order to generate HTML
    41     41   ** documentation, headers files, or other derived files.  The formatting
    42     42   ** of the code in this file is, therefore, important.  See other comments
    43     43   ** in this file for details.  If in doubt, do not deviate from existing
    44     44   ** commenting and indentation practices when changing or adding code.
    45     45   **
    46         -** $Id: vdbe.c,v 1.762 2008/07/23 18:17:32 drh Exp $
           46  +** $Id: vdbe.c,v 1.763 2008/07/23 21:07:25 drh Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #include <ctype.h>
    50     50   #include "vdbeInt.h"
    51     51   
    52     52   /*
    53     53   ** The following global variable is incremented every time a cursor
................................................................................
  4617   4617   
  4618   4618     sqlite3_vtab *pVtab = pOp->p4.pVtab;
  4619   4619     sqlite3_module *pModule = (sqlite3_module *)pVtab->pModule;
  4620   4620   
  4621   4621     assert(pVtab && pModule);
  4622   4622     if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
  4623   4623     rc = pModule->xOpen(pVtab, &pVtabCursor);
  4624         -  sqlite3VtabTransferError(db, rc, pVtab);
         4624  +  sqlite3_free(p->zErrMsg);
         4625  +  p->zErrMsg = pVtab->zErrMsg;
         4626  +  pVtab->zErrMsg = 0;
  4625   4627     if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
  4626   4628     if( SQLITE_OK==rc ){
  4627   4629       /* Initialize sqlite3_vtab_cursor base class */
  4628   4630       pVtabCursor->pVtab = pVtab;
  4629   4631   
  4630   4632       /* Initialise vdbe cursor object */
  4631   4633       pCur = allocateCursor(p, pOp->p1, &pOp[-1], -1, 0);
................................................................................
  4847   4849     REGISTER_TRACE(pOp->p1, pName);
  4848   4850   
  4849   4851     Stringify(pName, encoding);
  4850   4852   
  4851   4853     if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
  4852   4854     sqlite3VtabLock(pVtab);
  4853   4855     rc = pVtab->pModule->xRename(pVtab, pName->z);
         4856  +  sqlite3_free(p->zErrMsg);
         4857  +  p->zErrMsg = pVtab->zErrMsg;
         4858  +  pVtab->zErrMsg = 0;
  4854   4859     sqlite3VtabUnlock(db, pVtab);
  4855         -  sqlite3VtabTransferError(db, rc, pVtab);
  4856   4860     if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
  4857   4861   
  4858   4862     break;
  4859   4863   }
  4860   4864   #endif
  4861   4865   
  4862   4866   #ifndef SQLITE_OMIT_VIRTUALTABLE
................................................................................
  4900   4904         storeTypeInfo(pX, 0);
  4901   4905         apArg[i] = pX;
  4902   4906         pX++;
  4903   4907       }
  4904   4908       if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
  4905   4909       sqlite3VtabLock(pVtab);
  4906   4910       rc = pModule->xUpdate(pVtab, nArg, apArg, &rowid);
         4911  +    sqlite3_free(p->zErrMsg);
         4912  +    p->zErrMsg = pVtab->zErrMsg;
         4913  +    pVtab->zErrMsg = 0;
  4907   4914       sqlite3VtabUnlock(db, pVtab);
  4908         -    sqlite3VtabTransferError(db, rc, pVtab);
  4909   4915       if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
  4910   4916       if( pOp->p1 && rc==SQLITE_OK ){
  4911   4917         assert( nArg>1 && apArg[0] && (apArg[0]->flags&MEM_Null) );
  4912   4918         db->lastRowid = rowid;
  4913   4919       }
  4914   4920       p->nChange++;
  4915   4921     }

Changes to src/vdbeapi.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   **
    13     13   ** This file contains code use to implement APIs that are part of the
    14     14   ** VDBE.
    15     15   **
    16         -** $Id: vdbeapi.c,v 1.134 2008/06/19 02:52:25 drh Exp $
           16  +** $Id: vdbeapi.c,v 1.135 2008/07/23 21:07:25 drh Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "vdbeInt.h"
    20     20   
    21     21   #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
    22     22   /*
    23     23   ** The following structure contains pointers to the end points of a
................................................................................
   493    493   
   494    494       sqlite3OsCurrentTime(db->pVfs, &rNow);
   495    495       elapseTime = (rNow - (int)rNow)*3600.0*24.0*1000000000.0 - p->startTime;
   496    496       db->xProfile(db->pProfileArg, p->aOp[0].p4.z, elapseTime);
   497    497     }
   498    498   #endif
   499    499   
   500         -  sqlite3Error(p->db, rc, 0);
          500  +  db->errCode = rc;
          501  +  /*sqlite3Error(p->db, rc, 0);*/
   501    502     p->rc = sqlite3ApiExit(p->db, p->rc);
   502    503   end_of_step:
   503    504     assert( (rc&0xff)==rc );
   504    505     if( p->zSql && (rc&0xff)<SQLITE_ROW ){
   505    506       /* This behavior occurs if sqlite3_prepare_v2() was used to build
   506    507       ** the prepared statement.  Return error codes directly */
   507         -    sqlite3Error(p->db, p->rc, 0);
          508  +    p->db->errCode = p->rc;
          509  +    /* sqlite3Error(p->db, p->rc, 0); */
   508    510       return p->rc;
   509    511     }else{
   510    512       /* This is for legacy sqlite3_prepare() builds and when the code
   511    513       ** is SQLITE_ROW or SQLITE_DONE */
   512    514       return rc;
   513    515     }
   514    516   }

Changes to test/vtab1.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is creating and dropping virtual tables.
    13     13   #
    14         -# $Id: vtab1.test,v 1.54 2008/07/04 10:56:08 danielk1977 Exp $
           14  +# $Id: vtab1.test,v 1.55 2008/07/23 21:07:25 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   ifcapable !vtab||!schema_pragmas {
    20     20     finish_test
    21     21     return
................................................................................
  1003   1003       CREATE VIRTUAL TABLE echo_c USING echo(c);
  1004   1004     }
  1005   1005   } {}
  1006   1006   
  1007   1007   # First test outside of a transaction.
  1008   1008   do_test vtab1.12-2 {
  1009   1009     catchsql { INSERT INTO echo_c SELECT * FROM b; }
  1010         -} {1 {constraint failed}}
         1010  +} {1 {echo-vtab-error: column a is not unique}}
         1011  +do_test vtab1.12-2.1 {
         1012  +  sqlite3_errmsg db
         1013  +} {echo-vtab-error: column a is not unique}
  1011   1014   do_test vtab1.12-3 {
  1012   1015     execsql { SELECT * FROM c }
  1013   1016   } {3 G H}
  1014   1017   
  1015   1018   # Now the real test - wrapped in a transaction.
  1016   1019   do_test vtab1.12-4 {
  1017   1020     execsql  {BEGIN}
  1018   1021     catchsql { INSERT INTO echo_c SELECT * FROM b; }
  1019         -} {1 {constraint failed}}
         1022  +} {1 {echo-vtab-error: column a is not unique}}
  1020   1023   do_test vtab1.12-5 {
  1021   1024     execsql { SELECT * FROM c }
  1022   1025   } {3 G H}
  1023   1026   do_test vtab1.12-6 {
  1024   1027     execsql { COMMIT }
  1025   1028     execsql { SELECT * FROM c }
  1026   1029   } {3 G H}