/ Check-in [e41d6217]
Login

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

Overview
Comment:The sqlite3_namelist() routine now works for all name types.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | experimental-namelist
Files: files | file ages | folders
SHA3-256:e41d62175b65428567a05130725ad0547ea3e8095cbad4f71948d2d2d9697a0e
User & Date: drh 2017-07-06 18:25:27
Context
2017-07-06
18:52
Change the sqlite3_namelist() interface to return a pointer to an array of pointers to strings, and to avoid duplicates. check-in: 70291110 user: drh tags: experimental-namelist
18:25
The sqlite3_namelist() routine now works for all name types. check-in: e41d6217 user: drh tags: experimental-namelist
17:36
Initial implementation of a highly experimental interface for listing all keywords and symbolic names for an SQLite database connection. check-in: 04ef6783 user: drh tags: experimental-namelist
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/tokenize.c.

649
650
651
652
653
654
655

656
657
658
659
660
661
662
663































































664
665
**
** Each word is separated from the next by a single 0x00 byte.  The list
** is terminated by two 0x00 bytes in a row.
*/
char *sqlite3_namelist(sqlite3 *db, const char *zPrefix, int typeMask){
  struct NameAccum x;
  int i;

  x.zPrefix = zPrefix;
  x.nPrefix = sqlite3Strlen30(zPrefix);
  sqlite3StrAccumInit(&x.x, 0, 0, 0, 100000000);
  if( typeMask & SQLITE_NAMETYPE_KEYWORD ){
    for(i=0; i<ArraySize(aKWOffset); i++){
      addName(&x, zKWText + aKWOffset[i], aKWLen[i]);
    }
  }































































  return sqlite3StrAccumFinish(&x.x);
}







>








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
**
** Each word is separated from the next by a single 0x00 byte.  The list
** is terminated by two 0x00 bytes in a row.
*/
char *sqlite3_namelist(sqlite3 *db, const char *zPrefix, int typeMask){
  struct NameAccum x;
  int i;
  HashElem *j;
  x.zPrefix = zPrefix;
  x.nPrefix = sqlite3Strlen30(zPrefix);
  sqlite3StrAccumInit(&x.x, 0, 0, 0, 100000000);
  if( typeMask & SQLITE_NAMETYPE_KEYWORD ){
    for(i=0; i<ArraySize(aKWOffset); i++){
      addName(&x, zKWText + aKWOffset[i], aKWLen[i]);
    }
  }
  if( typeMask & SQLITE_NAMETYPE_FUNCTION ){
    for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){
      FuncDef *p;
      for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash){
        addName(&x, p->zName, -1);
      }
    }
    for(j=sqliteHashFirst(&db->aFunc); j; j=sqliteHashNext(j)){
      FuncDef *p = (FuncDef*)sqliteHashData(j);
      addName(&x, p->zName, -1);
    }
  }
  if( typeMask & SQLITE_NAMETYPE_COLLATION ){
    for(j=sqliteHashFirst(&db->aCollSeq); j; j=sqliteHashNext(j)){
      CollSeq *p = (CollSeq*)sqliteHashData(j);
      addName(&x, p->zName, -1);
    }
  }
  if( typeMask & SQLITE_NAMETYPE_MODULE ){
    for(j=sqliteHashFirst(&db->aModule); j; j=sqliteHashNext(j)){
      Module *p = (Module*)sqliteHashData(j);
      addName(&x, p->zName, -1);
    }
  }
  if( typeMask & (SQLITE_NAMETYPE_SCHEMA|
                  SQLITE_NAMETYPE_TABLE|
                  SQLITE_NAMETYPE_INDEX|
                  SQLITE_NAMETYPE_TRIGGER|
                  SQLITE_NAMETYPE_COLUMN) ){
    int iDb;
    for(iDb=0; iDb<db->nDb; iDb++){
      Db *pDb = &db->aDb[iDb];
      if( typeMask & SQLITE_NAMETYPE_SCHEMA ){
         addName(&x, pDb->zDbSName, -1);
      }
      if( typeMask & (SQLITE_NAMETYPE_TABLE|SQLITE_NAMETYPE_COLUMN) ){
        for(j=sqliteHashFirst(&pDb->pSchema->tblHash); j; j=sqliteHashNext(j)){
          Table *p = (Table*)sqliteHashData(j);
          if( typeMask & SQLITE_NAMETYPE_TABLE ){
            addName(&x, p->zName, -1);
          }
          if( typeMask & SQLITE_NAMETYPE_COLUMN ){
            int k;
            for(k=0; k<p->nCol; k++){
              addName(&x, p->aCol[k].zName, -1);
            }
          }
        }
      }
      if( typeMask & SQLITE_NAMETYPE_INDEX ){
        for(j=sqliteHashFirst(&pDb->pSchema->idxHash); j; j=sqliteHashNext(j)){
          Index *p = (Index*)sqliteHashData(j);
          addName(&x, p->zName, -1);
        }
      }
      if( typeMask & SQLITE_NAMETYPE_TRIGGER ){
        for(j=sqliteHashFirst(&pDb->pSchema->trigHash); j; j=sqliteHashNext(j)){
          Trigger *p = (Trigger*)sqliteHashData(j);
          addName(&x, p->zName, -1);
        }
      }
    }
  }
  return sqlite3StrAccumFinish(&x.x);
}