/ Check-in [efa8fb32]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Convert all names to lower case before sending them to the xFindFunction method of a virtual table. In FTS1, use strcmp instead of strcasecmp. Ticket #1981. (CVS 3428)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: efa8fb32a596c7232bb1754b3231e4f2421df75b
User & Date: drh 2006-09-18 20:24:02
Original Comment: Convert all names to lower case before sending them to the xFindFunction method of a virtual table. In FTS1, use strcmp instead of strcasecmp. Ticket #1981. (CVS 3428)
Original User & Date: drh 2006-09-18 20:24:03
Context
2006-09-18
20:24
Convert all names to lower case before sending them to the xFindFunction method of a virtual table. In FTS1, use strcmp instead of strcasecmp. Ticket #1981. (CVS 3429) check-in: cd4e1de8 user: drh tags: trunk
20:24
Convert all names to lower case before sending them to the xFindFunction method of a virtual table. In FTS1, use strcmp instead of strcasecmp. Ticket #1981. (CVS 3428) check-in: efa8fb32 user: drh tags: trunk
02:12
Modify FTS1 so that the "magic" column has the same name as the virtual table. Offsets are retrieved using a special "offsets" function whose first argument is the magic column. Snippets will ultimately be retrieved in the same way. (CVS 3427) check-in: 5e35dc1f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts1/fts1.c.

  2882   2882   static int fulltextFindFunction(
  2883   2883     sqlite3_vtab *pVtab,
  2884   2884     int nArg,
  2885   2885     const char *zName,
  2886   2886     void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
  2887   2887     void **ppArg
  2888   2888   ){
  2889         -  if( strcasecmp(zName,"snippet")==0 ){
         2889  +  if( strcmp(zName,"snippet")==0 ){
  2890   2890       *pxFunc = snippetFunc;
  2891   2891       return 1;
  2892         -  }else if( strcasecmp(zName,"offsets")==0 ){
         2892  +  }else if( strcmp(zName,"offsets")==0 ){
  2893   2893       *pxFunc = snippetOffsetsFunc;
  2894   2894       return 1;
  2895   2895     }
  2896   2896     return 0;
  2897   2897   }
  2898   2898   
  2899   2899   static const sqlite3_module fulltextModule = {

Changes to src/vtab.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to help implement virtual tables.
    13     13   **
    14         -** $Id: vtab.c,v 1.36 2006/09/15 07:28:51 drh Exp $
           14  +** $Id: vtab.c,v 1.37 2006/09/18 20:24:03 drh Exp $
    15     15   */
    16     16   #ifndef SQLITE_OMIT_VIRTUALTABLE
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** External API function used to create a new virtual-table module.
    21     21   */
................................................................................
   644    644   ){
   645    645     Table *pTab;
   646    646     sqlite3_vtab *pVtab;
   647    647     sqlite3_module *pMod;
   648    648     void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
   649    649     void *pArg;
   650    650     FuncDef *pNew;
          651  +  int rc;
          652  +  char *zLowerName;
          653  +  unsigned char *z;
          654  +
   651    655   
   652    656     /* Check to see the left operand is a column in a virtual table */
   653    657     if( pExpr==0 ) return pDef;
   654    658     if( pExpr->op!=TK_COLUMN ) return pDef;
   655    659     pTab = pExpr->pTab;
   656    660     if( pTab==0 ) return pDef;
   657    661     if( !pTab->isVirtual ) return pDef;
................................................................................
   658    662     pVtab = pTab->pVtab;
   659    663     assert( pVtab!=0 );
   660    664     assert( pVtab->pModule!=0 );
   661    665     pMod = (sqlite3_module *)pVtab->pModule;
   662    666     if( pMod->xFindFunction==0 ) return pDef;
   663    667    
   664    668     /* Call the xFuncFunction method on the virtual table implementation
   665         -  ** to see if the implementation wants to overload this function */
   666         -  if( pMod->xFindFunction(pVtab, nArg, pDef->zName, &xFunc, &pArg)==0 ){
          669  +  ** to see if the implementation wants to overload this function 
          670  +  */
          671  +  zLowerName = sqlite3StrDup(pDef->zName);
          672  +  for(z=(unsigned char*)zLowerName; *z; z++){
          673  +    *z = sqlite3UpperToLower[*z];
          674  +  }
          675  +  rc = pMod->xFindFunction(pVtab, nArg, zLowerName, &xFunc, &pArg);
          676  +  sqliteFree(zLowerName);
          677  +  if( rc==0 ){
   667    678       return pDef;
   668    679     }
   669    680   
   670    681     /* Create a new ephemeral function definition for the overloaded
   671    682     ** function */
   672    683     pNew = sqliteMalloc( sizeof(*pNew) + strlen(pDef->zName) );
   673    684     if( pNew==0 ){