mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Add code to invoke the xDestroy method of a virtual table when it is dropped. (CVS 3218)
FossilOrigin-Name: f0c7c8d12c04376e48c6d53a29cfae3fa13b52cf
This commit is contained in:
31
src/vtab.c
31
src/vtab.c
@@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** This file contains code used to help implement virtual tables.
|
||||
**
|
||||
** $Id: vtab.c,v 1.4 2006/06/12 12:08:45 danielk1977 Exp $
|
||||
** $Id: vtab.c,v 1.5 2006/06/12 16:01:22 danielk1977 Exp $
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
#include "sqliteInt.h"
|
||||
@@ -373,4 +373,33 @@ int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** This function is invoked by the vdbe to call the xDestroy method
|
||||
** of the virtual table named zTab in database iDb. This occurs
|
||||
** when a DROP TABLE is mentioned.
|
||||
**
|
||||
** This call is a no-op if zTab is not a virtual table.
|
||||
*/
|
||||
int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab)
|
||||
{
|
||||
int rc = SQLITE_OK;
|
||||
Table *pTab;
|
||||
sqlite3_module *pModule;
|
||||
|
||||
pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
|
||||
pModule = pTab->pModule;
|
||||
assert(pTab);
|
||||
if( pTab->pVtab ){
|
||||
rc = sqlite3SafetyOff(db);
|
||||
assert( rc==SQLITE_OK );
|
||||
rc = pModule->xDestroy(pTab->pVtab);
|
||||
sqlite3SafetyOn(db);
|
||||
if( rc==SQLITE_OK ){
|
||||
pTab->pVtab = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
#endif /* SQLITE_OMIT_VIRTUALTABLE */
|
||||
|
Reference in New Issue
Block a user