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:
22
manifest
22
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Patches\sto\sget\sthings\sworking\sbetter\sfor\sOS2.\s\sTicket\s#1836.\s(CVS\s3217)
|
C Add\scode\sto\sinvoke\sthe\sxDestroy\smethod\sof\sa\svirtual\stable\swhen\sit\sis\sdropped.\s(CVS\s3218)
|
||||||
D 2006-06-12T12:57:46
|
D 2006-06-12T16:01:22
|
||||||
F Makefile.in 56fd6261e83f60724e6dcd764e06ab68cbd53909
|
F Makefile.in 56fd6261e83f60724e6dcd764e06ab68cbd53909
|
||||||
F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
|
F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
|
||||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||||
@@ -36,7 +36,7 @@ F src/attach.c 27a31d3b89d7ebb5b358847607b1ec795384123c
|
|||||||
F src/auth.c 9ae84d2d94eb96195e04515715e08e85963e96c2
|
F src/auth.c 9ae84d2d94eb96195e04515715e08e85963e96c2
|
||||||
F src/btree.c ed343b3dbcbc7da9ac481ef2b98c4239fe6d9629
|
F src/btree.c ed343b3dbcbc7da9ac481ef2b98c4239fe6d9629
|
||||||
F src/btree.h 40055cfc09defd1146bc5b922399c035f969e56d
|
F src/btree.h 40055cfc09defd1146bc5b922399c035f969e56d
|
||||||
F src/build.c 0781f85451caefe6419eaa8d04b65fd3150cef2c
|
F src/build.c 133a046cef19c8bc80dafb38bb82229caefd6fff
|
||||||
F src/callback.c fd9bb39f7ff6b52bad8365617abc61c720640429
|
F src/callback.c fd9bb39f7ff6b52bad8365617abc61c720640429
|
||||||
F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675
|
F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675
|
||||||
F src/date.c cd2bd5d1ebc6fa12d6312f69789ae5b0a2766f2e
|
F src/date.c cd2bd5d1ebc6fa12d6312f69789ae5b0a2766f2e
|
||||||
@@ -74,7 +74,7 @@ F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
|
|||||||
F src/shell.c 55bf6335dae7146f7a300039f5d6bb35010f1996
|
F src/shell.c 55bf6335dae7146f7a300039f5d6bb35010f1996
|
||||||
F src/sqlite.h.in cad97e59cfad8337f9f43ea9662714a256ca80b2
|
F src/sqlite.h.in cad97e59cfad8337f9f43ea9662714a256ca80b2
|
||||||
F src/sqlite3ext.h 127bd394c8eea481f2ac9b754bf399dbfc818b75
|
F src/sqlite3ext.h 127bd394c8eea481f2ac9b754bf399dbfc818b75
|
||||||
F src/sqliteInt.h b77822681ec59f3ec57b921a1d8c1b47a8c3e18f
|
F src/sqliteInt.h a617f13e11e05f78a8fa55756591eba9a59c9dbc
|
||||||
F src/table.c f64ec4fbfe333f8df925bc6ba494f55e05b0e75e
|
F src/table.c f64ec4fbfe333f8df925bc6ba494f55e05b0e75e
|
||||||
F src/tclsqlite.c 0b2a04cfc1b4298adfbe90a754cfbbe207aca11a
|
F src/tclsqlite.c 0b2a04cfc1b4298adfbe90a754cfbbe207aca11a
|
||||||
F src/test1.c 88291fa6674dcd409b1c9d76d3119151d4b81a50
|
F src/test1.c 88291fa6674dcd409b1c9d76d3119151d4b81a50
|
||||||
@@ -94,14 +94,14 @@ F src/update.c 0186f09414a6578156d40666becc964f85c2a616
|
|||||||
F src/utf.c ab81ac59084ff1c07d421eb1a0a84ec809603b44
|
F src/utf.c ab81ac59084ff1c07d421eb1a0a84ec809603b44
|
||||||
F src/util.c ca6ee72772c0f5dc04d2e0ab1973fd3b6a9bf79d
|
F src/util.c ca6ee72772c0f5dc04d2e0ab1973fd3b6a9bf79d
|
||||||
F src/vacuum.c 5b37d0f436f8e1ffacd17934e44720b38d2247f9
|
F src/vacuum.c 5b37d0f436f8e1ffacd17934e44720b38d2247f9
|
||||||
F src/vdbe.c 5c77e8b57c07e7776ec34df8088749c639bbfe7c
|
F src/vdbe.c 7002df8e881e4a977c57d504287b5a30f84b8d37
|
||||||
F src/vdbe.h 190d85a37658c2397be75a4c70bbc02ebc4ec0ba
|
F src/vdbe.h 190d85a37658c2397be75a4c70bbc02ebc4ec0ba
|
||||||
F src/vdbeInt.h 85cd5f81d38edb1b8f4786f407c77a7a3ba636fb
|
F src/vdbeInt.h 85cd5f81d38edb1b8f4786f407c77a7a3ba636fb
|
||||||
F src/vdbeapi.c 7dc662e7c905ce666bb506dced932e0307115cbf
|
F src/vdbeapi.c 7dc662e7c905ce666bb506dced932e0307115cbf
|
||||||
F src/vdbeaux.c 4002e6b19d7c9719cb81f9797316b9ad118e4370
|
F src/vdbeaux.c 4002e6b19d7c9719cb81f9797316b9ad118e4370
|
||||||
F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
|
F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
|
||||||
F src/vdbemem.c 5f0afe3b92bb2c037f8d5d697f7c151fa50783a3
|
F src/vdbemem.c 5f0afe3b92bb2c037f8d5d697f7c151fa50783a3
|
||||||
F src/vtab.c 430228a2c920138d528e9937b3123bedffeb10b6
|
F src/vtab.c 4ec6ac7e5e4fccb38401285d0e329d018622859f
|
||||||
F src/where.c 3dc5269ba552c0db39247f6bbc98b312ae786863
|
F src/where.c 3dc5269ba552c0db39247f6bbc98b312ae786863
|
||||||
F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
|
F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
|
||||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||||
@@ -287,7 +287,7 @@ F test/vacuum.test 37f998b841cb335397c26d9bbc3457182af2565f
|
|||||||
F test/vacuum2.test 5aea8c88a65cb29f7d175296e7c819c6158d838c
|
F test/vacuum2.test 5aea8c88a65cb29f7d175296e7c819c6158d838c
|
||||||
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
|
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
|
||||||
F test/view.test 16e2774fe35e47a07ac4471b7f0bcc948b1aa6d5
|
F test/view.test 16e2774fe35e47a07ac4471b7f0bcc948b1aa6d5
|
||||||
F test/vtab1.test 79369c49f7607300ce62cf8b10ea56eb604f106f
|
F test/vtab1.test d3d4d38bd6fccb2ecec25357d9696bfea38d61e4
|
||||||
F test/where.test ee7c9a6659b07e1ee61177f6e7ff71565ee2c9df
|
F test/where.test ee7c9a6659b07e1ee61177f6e7ff71565ee2c9df
|
||||||
F test/where2.test a16476a5913e75cf65b38f2daa6157a6b7791394
|
F test/where2.test a16476a5913e75cf65b38f2daa6157a6b7791394
|
||||||
F test/where3.test 3b5ad2c58069e12be2bd86bc5e211a82810521aa
|
F test/where3.test 3b5ad2c58069e12be2bd86bc5e211a82810521aa
|
||||||
@@ -363,7 +363,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
|||||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||||
P 54b30fe1bdf0c9e690e12f07dcce4382e863bf02
|
P 65c6e5e117b9194015e382b1ad9bb9c88704eeb7
|
||||||
R c82c985d39a094d0be35353a73bbb871
|
R 5c6b73fe0e6f68c2a41a34bb9e99f68c
|
||||||
U drh
|
U danielk1977
|
||||||
Z d677de0ba67b5d1d1c7872ed912e52cc
|
Z 4c06df1b2df27b4be5379aebd6a5dbae
|
||||||
|
@@ -1 +1 @@
|
|||||||
65c6e5e117b9194015e382b1ad9bb9c88704eeb7
|
f0c7c8d12c04376e48c6d53a29cfae3fa13b52cf
|
10
src/build.c
10
src/build.c
@@ -22,7 +22,7 @@
|
|||||||
** COMMIT
|
** COMMIT
|
||||||
** ROLLBACK
|
** ROLLBACK
|
||||||
**
|
**
|
||||||
** $Id: build.c,v 1.398 2006/06/12 12:08:45 danielk1977 Exp $
|
** $Id: build.c,v 1.399 2006/06/12 16:01:22 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -1982,13 +1982,11 @@ void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){
|
|||||||
** the schema cookie.
|
** the schema cookie.
|
||||||
*/
|
*/
|
||||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||||
if( pTab->isEphem ){
|
if( pTab->isVirtual ){
|
||||||
sqlite3VdbeOp3(v, OP_VDestroy, iDb, 0, pTab->zName, 0);
|
sqlite3VdbeOp3(v, OP_VDestroy, iDb, 0, pTab->zName, 0);
|
||||||
}else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
sqlite3VdbeOp3(v, OP_DropTable, iDb, 0, pTab->zName, 0);
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
sqlite3VdbeOp3(v, OP_DropTable, iDb, 0, pTab->zName, 0);
|
||||||
sqlite3ChangeCookie(db, v, iDb);
|
sqlite3ChangeCookie(db, v, iDb);
|
||||||
}
|
}
|
||||||
sqliteViewResetAll(db, iDb);
|
sqliteViewResetAll(db, iDb);
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** Internal interface definitions for SQLite.
|
** Internal interface definitions for SQLite.
|
||||||
**
|
**
|
||||||
** @(#) $Id: sqliteInt.h,v 1.500 2006/06/12 12:08:45 danielk1977 Exp $
|
** @(#) $Id: sqliteInt.h,v 1.501 2006/06/12 16:01:22 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _SQLITEINT_H_
|
#ifndef _SQLITEINT_H_
|
||||||
#define _SQLITEINT_H_
|
#define _SQLITEINT_H_
|
||||||
@@ -1801,6 +1801,7 @@ void sqlite3VtabArgInit(Parse*);
|
|||||||
void sqlite3VtabArgExtend(Parse*, Token*);
|
void sqlite3VtabArgExtend(Parse*, Token*);
|
||||||
int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);
|
int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);
|
||||||
int sqlite3VtabCallConnect(Parse*, Table*);
|
int sqlite3VtabCallConnect(Parse*, Table*);
|
||||||
|
int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
|
||||||
|
|
||||||
#ifdef SQLITE_SSE
|
#ifdef SQLITE_SSE
|
||||||
#include "sseInt.h"
|
#include "sseInt.h"
|
||||||
|
@@ -43,7 +43,7 @@
|
|||||||
** in this file for details. If in doubt, do not deviate from existing
|
** in this file for details. If in doubt, do not deviate from existing
|
||||||
** commenting and indentation practices when changing or adding code.
|
** commenting and indentation practices when changing or adding code.
|
||||||
**
|
**
|
||||||
** $Id: vdbe.c,v 1.552 2006/06/12 06:09:19 danielk1977 Exp $
|
** $Id: vdbe.c,v 1.553 2006/06/12 16:01:22 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
@@ -4546,12 +4546,13 @@ case OP_VCreate: {
|
|||||||
#endif /* SQLITE_OMIT_VIRTUALTABLE */
|
#endif /* SQLITE_OMIT_VIRTUALTABLE */
|
||||||
|
|
||||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||||
/* Opcode: VDestroy * * P3
|
/* Opcode: VDestroy P1 * P3
|
||||||
**
|
**
|
||||||
** P3 is the name of a virtual table. Call the xDestroy method for
|
** P3 is the name of a virtual table in database P1. Call the xDestroy method
|
||||||
** that table.
|
** of that table.
|
||||||
*/
|
*/
|
||||||
case OP_VDestroy: {
|
case OP_VDestroy: {
|
||||||
|
rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif /* SQLITE_OMIT_VIRTUALTABLE */
|
#endif /* SQLITE_OMIT_VIRTUALTABLE */
|
||||||
|
31
src/vtab.c
31
src/vtab.c
@@ -11,7 +11,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** This file contains code used to help implement virtual tables.
|
** 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
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
@@ -373,4 +373,33 @@ int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){
|
|||||||
return rc;
|
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 */
|
#endif /* SQLITE_OMIT_VIRTUALTABLE */
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
# This file implements regression tests for SQLite library. The
|
# This file implements regression tests for SQLite library. The
|
||||||
# focus of this file is creating and dropping virtual tables.
|
# focus of this file is creating and dropping virtual tables.
|
||||||
#
|
#
|
||||||
# $Id: vtab1.test,v 1.5 2006/06/12 12:50:23 drh Exp $
|
# $Id: vtab1.test,v 1.6 2006/06/12 16:01:23 danielk1977 Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@@ -99,4 +99,26 @@ do_test vtab1-2.4 {
|
|||||||
2 c {} 0 {} 0 \
|
2 c {} 0 {} 0 \
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Drop the table t2. This should cause the xDestroy (but not xDisconnect)
|
||||||
|
# method to be invoked.
|
||||||
|
do_test vtab1-2.5 {
|
||||||
|
set echo_module [list]
|
||||||
|
execsql {
|
||||||
|
DROP TABLE t2;
|
||||||
|
}
|
||||||
|
set echo_module
|
||||||
|
} [list xDestroy]
|
||||||
|
do_test vtab1-2.6 {
|
||||||
|
execsql {
|
||||||
|
PRAGMA table_info(t2);
|
||||||
|
}
|
||||||
|
} {}
|
||||||
|
do_test vtab1-2.7 {
|
||||||
|
execsql {
|
||||||
|
SELECT sql FROM sqlite_master;
|
||||||
|
}
|
||||||
|
} [list {CREATE VIRTUAL TABLE t1 USING echo} \
|
||||||
|
{CREATE TABLE template(a, b, c)} \
|
||||||
|
]
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
Reference in New Issue
Block a user