mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Add some tests (and fixes) for virtual tables and the authorization callback. Still more to come. (CVS 3260)
FossilOrigin-Name: 9497c66e5533ec143d0efda4a419e4bdf922ae8c
This commit is contained in:
32
src/vtab.c
32
src/vtab.c
@@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** This file contains code used to help implement virtual tables.
|
||||
**
|
||||
** $Id: vtab.c,v 1.13 2006/06/15 07:29:01 danielk1977 Exp $
|
||||
** $Id: vtab.c,v 1.14 2006/06/16 08:01:04 danielk1977 Exp $
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
#include "sqliteInt.h"
|
||||
@@ -89,22 +89,34 @@ void sqlite3VtabBeginParse(
|
||||
Token *pName2, /* Name of new table or NULL */
|
||||
Token *pModuleName /* Name of the module for the virtual table */
|
||||
){
|
||||
int iDb; /* The database the table is being created in */
|
||||
Table *pTable; /* The new virtual table */
|
||||
Token *pDummy; /* Dummy arg for sqlite3TwoPartName() */
|
||||
|
||||
/* TODO: The 5th argument to sqlite3StartTable() - isView - is being
|
||||
** passed a true value at present. This prevents sqlite3StartTable()
|
||||
** from coding OP_CreateTable, which is correct, but causes it
|
||||
** to invoke the authorization function as if a CREATE VIEW statement
|
||||
** were attempted, which is incorrect.
|
||||
*/
|
||||
sqlite3StartTable(pParse, pName1, pName2, 0, 1, 0);
|
||||
|
||||
sqlite3StartTable(pParse, pName1, pName2, 0, 0, 1, 0);
|
||||
pTable = pParse->pNewTable;
|
||||
if( pTable==0 ) return;
|
||||
if( pTable==0 || pParse->nErr ) return;
|
||||
assert( 0==pTable->pIndex );
|
||||
|
||||
pTable->isVirtual = 1;
|
||||
pTable->nModuleArg = 0;
|
||||
addModuleArgument(pTable, sqlite3NameFromToken(pModuleName));
|
||||
pParse->sNameToken.n = pModuleName->z + pModuleName->n - pName1->z;
|
||||
|
||||
#ifndef SQLITE_OMIT_AUTHORIZATION
|
||||
/* Creating a virtual table invokes the authorization callback twice.
|
||||
** The first invocation, to obtain permission to INSERT a row into the
|
||||
** sqlite_master table, has already been made by sqlite3StartTable().
|
||||
** The second call, to obtain permission to create the table, is made now.
|
||||
*/
|
||||
iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pDummy);
|
||||
assert( iDb>=0 );
|
||||
if( sqlite3AuthCheck(pParse, SQLITE_CREATE_VTABLE, pTable->zName,
|
||||
pTable->azModuleArg[0], pParse->db->aDb[iDb].zName)
|
||||
){
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user