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)

FossilOrigin-Name: 4a9dd5e782a363e93d4705fa3671bc6cf0bb5a33
This commit is contained in:
drh 2008-07-23 21:07:25 +00:00
parent 9a1ec1e3ae
commit 80cc85b3c2
5 changed files with 30 additions and 19 deletions

View File

@ -1,5 +1,5 @@
C Remove\sstray\sbreakpoints\sfrom\stest\sscripts.\s(CVS\s5465)
D 2008-07-23T20:28:14
C Error\smessages\sfrom\svirtual\stables\sstore\son\sthe\ssqlite3_vtab->zErrMsg\sfield\nare\sreported\sback\sup\sto\sthe\sapplication\sinterface\sand\smemory\sis\sreclaimed.\s(CVS\s5466)
D 2008-07-23T21:07:25
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 77ff156061bb870aa0a8b3d545c670d08070f7e6
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -182,10 +182,10 @@ F src/update.c 4e698fcc0c91c241a960304c4236dc3a49603155
F src/utf.c 8d52f620a7153d90b058502124fe51d821fcdf57
F src/util.c f94d11f931775e325b1a9f97b5cd3005bc4328ba
F src/vacuum.c ef342828002debc97514617af3424aea8ef8522c
F src/vdbe.c 2868150723d81acfade5cfb5ecbd1d7075678aed
F src/vdbe.c cc4c19b88d63fa963a4b9260bcae04b82fb59fbb
F src/vdbe.h c46155c221418bea29ee3a749d5950fcf85a70e2
F src/vdbeInt.h 30535c1d30ba1b5fb58d8f0e1d1261af976558aa
F src/vdbeapi.c a7c6b8db324cf7eccff32de871dea36aa305c994
F src/vdbeapi.c 17fa6f432197d759b15d3b37a7d672a34043c078
F src/vdbeaux.c 05330c212c77dfd43300bc31bfa0044e4f7ec956
F src/vdbeblob.c a20fe9345062b1a1b4cc187dc5fad45c9414033b
F src/vdbefifo.c c46dae1194e4277bf007144d7e5b0c0b1c24f136
@ -565,7 +565,7 @@ F test/vacuum3.test 75dee6ffd1baa60308dcad93f2c689126500dcff
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
F test/veryquick.test e265401afefa994cdf2fe4b6f286b1e87c2f9b9d
F test/view.test 5799906511d6c77cfe3516d3d1189224350ef732
F test/vtab1.test 4421276b9010022d623879531a05a58fefaad771
F test/vtab1.test 905a1aedad6e7307aea29f00d87b255b04994777
F test/vtab2.test 1da49b015582965a8fc386aa23d051a5a622b08e
F test/vtab3.test baad99fd27217f5d6db10660522e0b7192446de1
F test/vtab4.test 942f8b8280b3ea8a41dae20e7822d065ca1cb275
@ -611,7 +611,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P a7d64e86e84cf16c9742e6b012a0b96d9c6b2ba1
R f5137591809f31c9ab28dedfd27be8d9
P cb5e75dfa5c7048bd0994afac19846f70bfa7a4d
R da2e59546e4fa7b050269870dc1e776f
U drh
Z ced7f31902a9154ae870cc955d9c540a
Z 3024197f824f60bae53687eb95f7ee5e

View File

@ -1 +1 @@
cb5e75dfa5c7048bd0994afac19846f70bfa7a4d
4a9dd5e782a363e93d4705fa3671bc6cf0bb5a33

View File

@ -43,7 +43,7 @@
** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.762 2008/07/23 18:17:32 drh Exp $
** $Id: vdbe.c,v 1.763 2008/07/23 21:07:25 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -4621,7 +4621,9 @@ case OP_VOpen: {
assert(pVtab && pModule);
if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
rc = pModule->xOpen(pVtab, &pVtabCursor);
sqlite3VtabTransferError(db, rc, pVtab);
sqlite3_free(p->zErrMsg);
p->zErrMsg = pVtab->zErrMsg;
pVtab->zErrMsg = 0;
if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
if( SQLITE_OK==rc ){
/* Initialize sqlite3_vtab_cursor base class */
@ -4851,8 +4853,10 @@ case OP_VRename: {
if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
sqlite3VtabLock(pVtab);
rc = pVtab->pModule->xRename(pVtab, pName->z);
sqlite3_free(p->zErrMsg);
p->zErrMsg = pVtab->zErrMsg;
pVtab->zErrMsg = 0;
sqlite3VtabUnlock(db, pVtab);
sqlite3VtabTransferError(db, rc, pVtab);
if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
break;
@ -4904,8 +4908,10 @@ case OP_VUpdate: {
if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
sqlite3VtabLock(pVtab);
rc = pModule->xUpdate(pVtab, nArg, apArg, &rowid);
sqlite3_free(p->zErrMsg);
p->zErrMsg = pVtab->zErrMsg;
pVtab->zErrMsg = 0;
sqlite3VtabUnlock(db, pVtab);
sqlite3VtabTransferError(db, rc, pVtab);
if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
if( pOp->p1 && rc==SQLITE_OK ){
assert( nArg>1 && apArg[0] && (apArg[0]->flags&MEM_Null) );

View File

@ -13,7 +13,7 @@
** This file contains code use to implement APIs that are part of the
** VDBE.
**
** $Id: vdbeapi.c,v 1.134 2008/06/19 02:52:25 drh Exp $
** $Id: vdbeapi.c,v 1.135 2008/07/23 21:07:25 drh Exp $
*/
#include "sqliteInt.h"
#include "vdbeInt.h"
@ -497,14 +497,16 @@ static int sqlite3Step(Vdbe *p){
}
#endif
sqlite3Error(p->db, rc, 0);
db->errCode = rc;
/*sqlite3Error(p->db, rc, 0);*/
p->rc = sqlite3ApiExit(p->db, p->rc);
end_of_step:
assert( (rc&0xff)==rc );
if( p->zSql && (rc&0xff)<SQLITE_ROW ){
/* This behavior occurs if sqlite3_prepare_v2() was used to build
** the prepared statement. Return error codes directly */
sqlite3Error(p->db, p->rc, 0);
p->db->errCode = p->rc;
/* sqlite3Error(p->db, p->rc, 0); */
return p->rc;
}else{
/* This is for legacy sqlite3_prepare() builds and when the code

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is creating and dropping virtual tables.
#
# $Id: vtab1.test,v 1.54 2008/07/04 10:56:08 danielk1977 Exp $
# $Id: vtab1.test,v 1.55 2008/07/23 21:07:25 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -1007,7 +1007,10 @@ do_test vtab1.12-1 {
# First test outside of a transaction.
do_test vtab1.12-2 {
catchsql { INSERT INTO echo_c SELECT * FROM b; }
} {1 {constraint failed}}
} {1 {echo-vtab-error: column a is not unique}}
do_test vtab1.12-2.1 {
sqlite3_errmsg db
} {echo-vtab-error: column a is not unique}
do_test vtab1.12-3 {
execsql { SELECT * FROM c }
} {3 G H}
@ -1016,7 +1019,7 @@ do_test vtab1.12-3 {
do_test vtab1.12-4 {
execsql {BEGIN}
catchsql { INSERT INTO echo_c SELECT * FROM b; }
} {1 {constraint failed}}
} {1 {echo-vtab-error: column a is not unique}}
do_test vtab1.12-5 {
execsql { SELECT * FROM c }
} {3 G H}