mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Enhance error message handling for the vtshim module.
FossilOrigin-Name: b4a0d5327addd90bef758e6a1403ac69f61b3886
This commit is contained in:
@ -58,6 +58,13 @@ struct vtshim_cursor {
|
||||
vtshim_cursor *pNext; /* Next on list of all cursors */
|
||||
};
|
||||
|
||||
/* Macro used to copy the child vtable error message to outer vtable */
|
||||
#define VTSHIM_COPY_ERRMSG() \
|
||||
do { \
|
||||
sqlite3_free(pVtab->base.zErrMsg); \
|
||||
pVtab->base.zErrMsg = sqlite3_mprintf("%s", pVtab->pChild->zErrMsg); \
|
||||
} while (0)
|
||||
|
||||
/* Methods for the vtshim module */
|
||||
static int vtshimCreate(
|
||||
sqlite3 *db,
|
||||
@ -72,6 +79,13 @@ static int vtshimCreate(
|
||||
int rc;
|
||||
|
||||
assert( db==pAux->db );
|
||||
if( pAux->bDisposed ){
|
||||
if( pzErr ){
|
||||
*pzErr = sqlite3_mprintf("virtual table was disposed: \"%s\"",
|
||||
pAux->zName);
|
||||
}
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
pNew = sqlite3_malloc( sizeof(*pNew) );
|
||||
*ppVtab = (sqlite3_vtab*)pNew;
|
||||
if( pNew==0 ) return SQLITE_NOMEM;
|
||||
@ -103,6 +117,13 @@ static int vtshimConnect(
|
||||
int rc;
|
||||
|
||||
assert( db==pAux->db );
|
||||
if( pAux->bDisposed ){
|
||||
if( pzErr ){
|
||||
*pzErr = sqlite3_mprintf("virtual table was disposed: \"%s\"",
|
||||
pAux->zName);
|
||||
}
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
pNew = sqlite3_malloc( sizeof(*pNew) );
|
||||
*ppVtab = (sqlite3_vtab*)pNew;
|
||||
if( pNew==0 ) return SQLITE_NOMEM;
|
||||
@ -127,11 +148,15 @@ static int vtshimBestIndex(
|
||||
){
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pBase;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
int rc;
|
||||
if( pAux->bDisposed ) return SQLITE_ERROR;
|
||||
return pAux->pMod->xBestIndex(pVtab->pChild, pIdxInfo);
|
||||
rc = pAux->pMod->xBestIndex(pVtab->pChild, pIdxInfo);
|
||||
if( rc!=SQLITE_OK ){
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
static int vtshimDisconnect(sqlite3_vtab *pBase){
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pBase;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
@ -171,6 +196,7 @@ static int vtshimOpen(sqlite3_vtab *pBase, sqlite3_vtab_cursor **ppCursor){
|
||||
rc = pAux->pMod->xOpen(pVtab->pChild, &pCur->pChild);
|
||||
if( rc ){
|
||||
sqlite3_free(pCur);
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
return rc;
|
||||
}
|
||||
pCur->pChild->pVtab = pVtab->pChild;
|
||||
@ -189,6 +215,9 @@ static int vtshimClose(sqlite3_vtab_cursor *pX){
|
||||
int rc = SQLITE_OK;
|
||||
if( !pAux->bDisposed ){
|
||||
rc = pAux->pMod->xClose(pCur->pChild);
|
||||
if( rc!=SQLITE_OK ){
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
}
|
||||
}
|
||||
if( pCur->pNext ) pCur->pNext->ppPrev = pCur->ppPrev;
|
||||
*pCur->ppPrev = pCur->pNext;
|
||||
@ -206,40 +235,63 @@ static int vtshimFilter(
|
||||
vtshim_cursor *pCur = (vtshim_cursor*)pX;
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
int rc;
|
||||
if( pAux->bDisposed ) return SQLITE_ERROR;
|
||||
return pAux->pMod->xFilter(pCur->pChild, idxNum, idxStr, argc, argv);
|
||||
rc = pAux->pMod->xFilter(pCur->pChild, idxNum, idxStr, argc, argv);
|
||||
if( rc!=SQLITE_OK ){
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int vtshimNext(sqlite3_vtab_cursor *pX){
|
||||
vtshim_cursor *pCur = (vtshim_cursor*)pX;
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
int rc;
|
||||
if( pAux->bDisposed ) return SQLITE_ERROR;
|
||||
return pAux->pMod->xNext(pCur->pChild);
|
||||
rc = pAux->pMod->xNext(pCur->pChild);
|
||||
if( rc!=SQLITE_OK ){
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int vtshimEof(sqlite3_vtab_cursor *pX){
|
||||
vtshim_cursor *pCur = (vtshim_cursor*)pX;
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
if( pAux->bDisposed ) return SQLITE_ERROR;
|
||||
return pAux->pMod->xEof(pCur->pChild);
|
||||
int rc;
|
||||
if( pAux->bDisposed ) return 1;
|
||||
rc = pAux->pMod->xEof(pCur->pChild);
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int vtshimColumn(sqlite3_vtab_cursor *pX, sqlite3_context *ctx, int i){
|
||||
vtshim_cursor *pCur = (vtshim_cursor*)pX;
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
int rc;
|
||||
if( pAux->bDisposed ) return SQLITE_ERROR;
|
||||
return pAux->pMod->xColumn(pCur->pChild, ctx, i);
|
||||
rc = pAux->pMod->xColumn(pCur->pChild, ctx, i);
|
||||
if( rc!=SQLITE_OK ){
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int vtshimRowid(sqlite3_vtab_cursor *pX, sqlite3_int64 *pRowid){
|
||||
vtshim_cursor *pCur = (vtshim_cursor*)pX;
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
int rc;
|
||||
if( pAux->bDisposed ) return SQLITE_ERROR;
|
||||
return pAux->pMod->xRowid(pCur->pChild, pRowid);
|
||||
rc = pAux->pMod->xRowid(pCur->pChild, pRowid);
|
||||
if( rc!=SQLITE_OK ){
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int vtshimUpdate(
|
||||
@ -250,36 +302,61 @@ static int vtshimUpdate(
|
||||
){
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pBase;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
int rc;
|
||||
if( pAux->bDisposed ) return SQLITE_ERROR;
|
||||
return pAux->pMod->xUpdate(pVtab->pChild, argc, argv, pRowid);
|
||||
rc = pAux->pMod->xUpdate(pVtab->pChild, argc, argv, pRowid);
|
||||
if( rc!=SQLITE_OK ){
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int vtshimBegin(sqlite3_vtab *pBase){
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pBase;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
int rc;
|
||||
if( pAux->bDisposed ) return SQLITE_ERROR;
|
||||
return pAux->pMod->xBegin(pVtab->pChild);
|
||||
rc = pAux->pMod->xBegin(pVtab->pChild);
|
||||
if( rc!=SQLITE_OK ){
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int vtshimSync(sqlite3_vtab *pBase){
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pBase;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
int rc;
|
||||
if( pAux->bDisposed ) return SQLITE_ERROR;
|
||||
return pAux->pMod->xSync(pVtab->pChild);
|
||||
rc = pAux->pMod->xSync(pVtab->pChild);
|
||||
if( rc!=SQLITE_OK ){
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int vtshimCommit(sqlite3_vtab *pBase){
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pBase;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
int rc;
|
||||
if( pAux->bDisposed ) return SQLITE_ERROR;
|
||||
return pAux->pMod->xCommit(pVtab->pChild);
|
||||
rc = pAux->pMod->xCommit(pVtab->pChild);
|
||||
if( rc!=SQLITE_OK ){
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int vtshimRollback(sqlite3_vtab *pBase){
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pBase;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
int rc;
|
||||
if( pAux->bDisposed ) return SQLITE_ERROR;
|
||||
return pAux->pMod->xRollback(pVtab->pChild);
|
||||
rc = pAux->pMod->xRollback(pVtab->pChild);
|
||||
if( rc!=SQLITE_OK ){
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int vtshimFindFunction(
|
||||
@ -291,36 +368,59 @@ static int vtshimFindFunction(
|
||||
){
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pBase;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
if( pAux->bDisposed ) return SQLITE_ERROR;
|
||||
return pAux->pMod->xFindFunction(pVtab->pChild, nArg, zName, pxFunc, ppArg);
|
||||
int rc;
|
||||
if( pAux->bDisposed ) return 0;
|
||||
rc = pAux->pMod->xFindFunction(pVtab->pChild, nArg, zName, pxFunc, ppArg);
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int vtshimRename(sqlite3_vtab *pBase, const char *zNewName){
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pBase;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
int rc;
|
||||
if( pAux->bDisposed ) return SQLITE_ERROR;
|
||||
return pAux->pMod->xRename(pVtab->pChild, zNewName);
|
||||
rc = pAux->pMod->xRename(pVtab->pChild, zNewName);
|
||||
if( rc!=SQLITE_OK ){
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int vtshimSavepoint(sqlite3_vtab *pBase, int n){
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pBase;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
int rc;
|
||||
if( pAux->bDisposed ) return SQLITE_ERROR;
|
||||
return pAux->pMod->xSavepoint(pVtab->pChild, n);
|
||||
rc = pAux->pMod->xSavepoint(pVtab->pChild, n);
|
||||
if( rc!=SQLITE_OK ){
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int vtshimRelease(sqlite3_vtab *pBase, int n){
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pBase;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
int rc;
|
||||
if( pAux->bDisposed ) return SQLITE_ERROR;
|
||||
return pAux->pMod->xRelease(pVtab->pChild, n);
|
||||
rc = pAux->pMod->xRelease(pVtab->pChild, n);
|
||||
if( rc!=SQLITE_OK ){
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int vtshimRollbackTo(sqlite3_vtab *pBase, int n){
|
||||
vtshim_vtab *pVtab = (vtshim_vtab*)pBase;
|
||||
vtshim_aux *pAux = pVtab->pAux;
|
||||
int rc;
|
||||
if( pAux->bDisposed ) return SQLITE_ERROR;
|
||||
return pAux->pMod->xRollbackTo(pVtab->pChild, n);
|
||||
rc = pAux->pMod->xRollbackTo(pVtab->pChild, n);
|
||||
if( rc!=SQLITE_OK ){
|
||||
VTSHIM_COPY_ERRMSG();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* The destructor function for a disposible module */
|
||||
|
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C The\svtshim\sxCreate\sand\sxConnect\sfunctions\sneed\sto\sstore\sthe\spAux\spointer\sinto\sthe\snewly\screated\svtable\sobject.\s\sStyle\sfixes.
|
||||
D 2013-06-20T01:27:51.651
|
||||
C Enhance\serror\smessage\shandling\sfor\sthe\svtshim\smodule.
|
||||
D 2013-06-21T19:39:51.240
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -115,7 +115,7 @@ F ext/misc/percentile.c 4fb5e46c4312b0be74e8e497ac18f805f0e3e6c5
|
||||
F ext/misc/regexp.c c25c65fe775f5d9801fb8573e36ebe73f2c0c2e0
|
||||
F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a
|
||||
F ext/misc/spellfix.c 6d7ce6105a4b7729f6c44ccdf1ab7e80d9707c02
|
||||
F ext/misc/vtshim.c fe8f6f7d8b83a631b95b3cfb9a04dc985812d9da
|
||||
F ext/misc/vtshim.c 5fb6be7fe37659a8cbd1e16982d74cceacbc4543
|
||||
F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
|
||||
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
|
||||
F ext/rtree/rtree.c 757abea591d4ff67c0ff4e8f9776aeda86b18c14
|
||||
@ -1096,7 +1096,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||
F tool/wherecosttest.c 4d0393bdbe7230adb712e925863744dd2b7ffc5b
|
||||
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
|
||||
P bf2e28ddb292ef0b9a1262ec249aed3243dcfb20
|
||||
R 704132a94aa348b6d1fcd7a610d55eca
|
||||
P 43913c7bd5409791916dfa268258d22f34731273
|
||||
R 2bd29e8c3bcc06d35e440ba04e551d53
|
||||
U mistachkin
|
||||
Z e214b512264b6021b2a0d7dd8f81d237
|
||||
Z 9488ac35d83e50762d870999333aa524
|
||||
|
@ -1 +1 @@
|
||||
43913c7bd5409791916dfa268258d22f34731273
|
||||
b4a0d5327addd90bef758e6a1403ac69f61b3886
|
Reference in New Issue
Block a user