1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Add a new zErrMsg field to the sqlite3_vtab structure to support returning

error messages from virtual table constructors.  This change means that
virtual table implementations compiled as loadable extensions for version
3.3.7 will need to be recompile for version 3.3.8 and will not be usable
by both versions at one.  The virtual table mechanism is still considered
experimental so we feel justified in breaking backwards compatibility
in this way.  Additional interface changes might occurs in the future. (CVS 3401)

FossilOrigin-Name: 36693a5cb72b4363010f9ab0866e1f7865f65275
This commit is contained in:
drh
2006-09-10 17:08:29 +00:00
parent a2a9d18869
commit fe1368ee08
4 changed files with 37 additions and 16 deletions

View File

@@ -11,7 +11,7 @@
*************************************************************************
** This file contains code used to help implement virtual tables.
**
** $Id: vtab.c,v 1.31 2006/09/02 20:57:52 drh Exp $
** $Id: vtab.c,v 1.32 2006/09/10 17:08:30 drh Exp $
*/
#ifndef SQLITE_OMIT_VIRTUALTABLE
#include "sqliteInt.h"
@@ -59,6 +59,8 @@ void sqlite3VtabLock(sqlite3_vtab *pVtab){
void sqlite3VtabUnlock(sqlite3_vtab *pVtab){
pVtab->nRef--;
if( pVtab->nRef==0 ){
sqlite3_free(pVtab->zErrMsg);
pVtab->zErrMsg = 0;
pVtab->pModule->xDisconnect(pVtab);
}
}
@@ -291,6 +293,7 @@ static int vtabCallConstructor(
){
int rc;
int rc2;
sqlite3_vtab *pVtab;
char **azArg = pTab->azModuleArg;
int nArg = pTab->nModuleArg;
char *zErr = sqlite3MPrintf("vtable constructor failed: %s", pTab->zName);
@@ -303,15 +306,22 @@ static int vtabCallConstructor(
assert( rc==SQLITE_OK );
rc = xConstruct(db, pMod->pAux, nArg, azArg, &pTab->pVtab);
rc2 = sqlite3SafetyOn(db);
if( rc==SQLITE_OK && pTab->pVtab ){
pTab->pVtab->pModule = pMod->pModule;
pTab->pVtab->nRef = 1;
pVtab = pTab->pVtab;
if( rc==SQLITE_OK && pVtab ){
pVtab->pModule = pMod->pModule;
pVtab->nRef = 1;
}
if( SQLITE_OK!=rc ){
*pzErr = zErr;
zErr = 0;
} else if( db->pVTab ){
if( pVtab && pVtab->zErrMsg ){
*pzErr = sqlite3MPrintf("%s", pVtab->zErrMsg);
sqlite3_free(pVtab->zErrMsg);
pVtab->zErrMsg = 0;
}else{
*pzErr = zErr;
zErr = 0;
}
}else if( db->pVTab ){
const char *zFormat = "vtable constructor did not declare schema: %s";
*pzErr = sqlite3MPrintf(zFormat, pTab->zName);
rc = SQLITE_ERROR;