mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Allow virtual tables to mark columns as 'hidden'. Hidden columns do not show
up in "*" expansion, the implicit column list of an INSERT statement, or the results of a "PRAGMA table_info" statement. (CVS 4127) FossilOrigin-Name: 7f887a6a00fdd6efc3740bd8a1731bb1abde087c
This commit is contained in:
40
src/vtab.c
40
src/vtab.c
@@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** This file contains code used to help implement virtual tables.
|
||||
**
|
||||
** $Id: vtab.c,v 1.47 2007/06/22 15:21:16 danielk1977 Exp $
|
||||
** $Id: vtab.c,v 1.48 2007/06/26 10:38:55 danielk1977 Exp $
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
#include "sqliteInt.h"
|
||||
@@ -376,6 +376,44 @@ static int vtabCallConstructor(
|
||||
}
|
||||
db->pVTab = 0;
|
||||
sqliteFree(zModuleName);
|
||||
|
||||
/* If everything went according to plan, loop through the columns
|
||||
** of the table to see if any of them contain the token "hidden".
|
||||
** If so, set the Column.isHidden flag and remove the token from
|
||||
** the type string.
|
||||
*/
|
||||
if( rc==SQLITE_OK ){
|
||||
int iCol;
|
||||
for(iCol=0; iCol<pTab->nCol; iCol++){
|
||||
char *zType = pTab->aCol[iCol].zType;
|
||||
int nType;
|
||||
int i = 0;
|
||||
if( !zType ) continue;
|
||||
nType = strlen(zType);
|
||||
if( sqlite3StrNICmp("hidden", zType, 6) || (zType[6] && zType[6]!=' ') ){
|
||||
for(i=0; i<nType; i++){
|
||||
if( (0==sqlite3StrNICmp(" hidden", &zType[i], 7))
|
||||
&& (zType[i+7]=='\0' || zType[i+7]==' ')
|
||||
){
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( i<nType ){
|
||||
int j;
|
||||
int nDel = 6 + (zType[i+6] ? 1 : 0);
|
||||
for(j=i; (j+nDel)<=nType; j++){
|
||||
zType[j] = zType[j+nDel];
|
||||
}
|
||||
if( zType[i]=='\0' && i>0 ){
|
||||
assert(zType[i-1]==' ');
|
||||
zType[i-1] = '\0';
|
||||
}
|
||||
pTab->aCol[iCol].isHidden = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user