Back to index

php5  5.3.10
Defines | Typedefs | Functions | Variables
sqlite.w32.h File Reference
#include <stdarg.h>

Go to the source code of this file.

Defines

#define SQLITE_VERSION   "2.8.17"
#define SQLITE_ISO8859   1
#define SQLITE_OK   0 /* Successful result */
#define SQLITE_ERROR   1 /* SQL error or missing database */
#define SQLITE_INTERNAL   2 /* An internal logic error in SQLite */
#define SQLITE_PERM   3 /* Access permission denied */
#define SQLITE_ABORT   4 /* Callback routine requested an abort */
#define SQLITE_BUSY   5 /* The database file is locked */
#define SQLITE_LOCKED   6 /* A table in the database is locked */
#define SQLITE_NOMEM   7 /* A malloc() failed */
#define SQLITE_READONLY   8 /* Attempt to write a readonly database */
#define SQLITE_INTERRUPT   9 /* Operation terminated by sqlite_interrupt() */
#define SQLITE_IOERR   10 /* Some kind of disk I/O error occurred */
#define SQLITE_CORRUPT   11 /* The database disk image is malformed */
#define SQLITE_NOTFOUND   12 /* (Internal Only) Table or record not found */
#define SQLITE_FULL   13 /* Insertion failed because database is full */
#define SQLITE_CANTOPEN   14 /* Unable to open the database file */
#define SQLITE_PROTOCOL   15 /* Database lock protocol error */
#define SQLITE_EMPTY   16 /* (Internal Only) Database table is empty */
#define SQLITE_SCHEMA   17 /* The database schema changed */
#define SQLITE_TOOBIG   18 /* Too much data for one row of a table */
#define SQLITE_CONSTRAINT   19 /* Abort due to contraint violation */
#define SQLITE_MISMATCH   20 /* Data type mismatch */
#define SQLITE_MISUSE   21 /* Library used incorrectly */
#define SQLITE_NOLFS   22 /* Uses OS features not supported on host */
#define SQLITE_AUTH   23 /* Authorization denied */
#define SQLITE_FORMAT   24 /* Auxiliary database format error */
#define SQLITE_RANGE   25 /* 2nd parameter to sqlite_bind out of range */
#define SQLITE_NOTADB   26 /* File opened that is not a database file */
#define SQLITE_ROW   100 /* sqlite_step() has another row ready */
#define SQLITE_DONE   101 /* sqlite_step() has finished executing */
#define sqliteErrStr   sqlite_error_string /* Legacy. Do not use in new code. */
#define SQLITE_NUMERIC   (-1)
#define SQLITE_TEXT   (-2)
#define SQLITE_ARGS   (-3)
#define SQLITE_COPY   0 /* Table Name File Name */
#define SQLITE_CREATE_INDEX   1 /* Index Name Table Name */
#define SQLITE_CREATE_TABLE   2 /* Table Name NULL */
#define SQLITE_CREATE_TEMP_INDEX   3 /* Index Name Table Name */
#define SQLITE_CREATE_TEMP_TABLE   4 /* Table Name NULL */
#define SQLITE_CREATE_TEMP_TRIGGER   5 /* Trigger Name Table Name */
#define SQLITE_CREATE_TEMP_VIEW   6 /* View Name NULL */
#define SQLITE_CREATE_TRIGGER   7 /* Trigger Name Table Name */
#define SQLITE_CREATE_VIEW   8 /* View Name NULL */
#define SQLITE_DELETE   9 /* Table Name NULL */
#define SQLITE_DROP_INDEX   10 /* Index Name Table Name */
#define SQLITE_DROP_TABLE   11 /* Table Name NULL */
#define SQLITE_DROP_TEMP_INDEX   12 /* Index Name Table Name */
#define SQLITE_DROP_TEMP_TABLE   13 /* Table Name NULL */
#define SQLITE_DROP_TEMP_TRIGGER   14 /* Trigger Name Table Name */
#define SQLITE_DROP_TEMP_VIEW   15 /* View Name NULL */
#define SQLITE_DROP_TRIGGER   16 /* Trigger Name Table Name */
#define SQLITE_DROP_VIEW   17 /* View Name NULL */
#define SQLITE_INSERT   18 /* Table Name NULL */
#define SQLITE_PRAGMA   19 /* Pragma Name 1st arg or NULL */
#define SQLITE_READ   20 /* Table Name Column Name */
#define SQLITE_SELECT   21 /* NULL NULL */
#define SQLITE_TRANSACTION   22 /* NULL NULL */
#define SQLITE_UPDATE   23 /* Table Name Column Name */
#define SQLITE_ATTACH   24 /* Filename NULL */
#define SQLITE_DETACH   25 /* Database Name NULL */
#define SQLITE_DENY   1 /* Abort the SQL statement with an error */
#define SQLITE_IGNORE   2 /* Don't allow access, but don't generate an error */

Typedefs

typedef struct sqlite
typedef int(* sqlite_callback )(void *, int, char **, char **)
typedef struct sqlite_func
typedef struct sqlite_vm

Functions

sqlitesqlite_open (const char *filename, int mode, char **errmsg)
void sqlite_close (sqlite *)
int sqlite_exec (sqlite *, const char *sql, sqlite_callback, void *, char **errmsg)
int sqlite_last_insert_rowid (sqlite *)
int sqlite_changes (sqlite *)
const char * sqlite_error_string (int)
void sqlite_interrupt (sqlite *)
int sqlite_complete (const char *sql)
void sqlite_busy_handler (sqlite *, int(*)(void *, const char *, int), void *)
void sqlite_busy_timeout (sqlite *, int ms)
int sqlite_get_table (sqlite *, const char *sql, char ***resultp, int *nrow, int *ncolumn, char **errmsg)
void sqlite_free_table (char **result)
int sqlite_exec_printf (sqlite *, const char *sqlFormat, sqlite_callback, void *, char **errmsg,...)
int sqlite_exec_vprintf (sqlite *, const char *sqlFormat, sqlite_callback, void *, char **errmsg, va_list ap)
int sqlite_get_table_printf (sqlite *, const char *sqlFormat, char ***resultp, int *nrow, int *ncolumn, char **errmsg,...)
int sqlite_get_table_vprintf (sqlite *, const char *sqlFormat, char ***resultp, int *nrow, int *ncolumn, char **errmsg, va_list ap)
char * sqlite_mprintf (const char *,...)
char * sqlite_vmprintf (const char *, va_list)
void sqlite_freemem (void *p)
const char * sqlite_libversion (void)
const char * sqlite_libencoding (void)
int sqlite_create_function (sqlite *, const char *zName, int nArg, void(*xFunc)(sqlite_func *, int, const char **), void *pUserData)
int sqlite_create_aggregate (sqlite *, const char *zName, int nArg, void(*xStep)(sqlite_func *, int, const char **), void(*xFinalize)(sqlite_func *), void *pUserData)
int sqlite_function_type (sqlite *db, const char *zName, int datatype)
char * sqlite_set_result_string (sqlite_func *, const char *, int)
void sqlite_set_result_int (sqlite_func *, int)
void sqlite_set_result_double (sqlite_func *, double)
void sqlite_set_result_error (sqlite_func *, const char *, int)
void * sqlite_user_data (sqlite_func *)
void * sqlite_aggregate_context (sqlite_func *, int nBytes)
int sqlite_aggregate_count (sqlite_func *)
int sqlite_set_authorizer (sqlite *, int(*xAuth)(void *, int, const char *, const char *, const char *, const char *), void *pUserData)
void * sqlite_trace (sqlite *, void(*xTrace)(void *, const char *), void *)
int sqlite_compile (sqlite *db, const char *zSql, const char **pzTail, sqlite_vm **ppVm, char **pzErrmsg)
int sqlite_step (sqlite_vm *pVm, int *pN, const char ***pazValue, const char ***pazColName)
int sqlite_finalize (sqlite_vm *, char **pzErrMsg)
int sqlite_reset (sqlite_vm *, char **pzErrMsg)
int sqlite_bind (sqlite_vm *, int idx, const char *value, int len, int copy)
void sqlite_progress_handler (sqlite *, int, int(*)(void *), void *)

Variables

const char sqlite_version []
const char sqlite_encoding []

Define Documentation

#define SQLITE_ABORT   4 /* Callback routine requested an abort */

Definition at line 148 of file sqlite.w32.h.

#define SQLITE_ARGS   (-3)

Definition at line 458 of file sqlite.w32.h.

#define SQLITE_ATTACH   24 /* Filename NULL */

Definition at line 560 of file sqlite.w32.h.

#define SQLITE_AUTH   23 /* Authorization denied */

Definition at line 167 of file sqlite.w32.h.

#define SQLITE_BUSY   5 /* The database file is locked */

Definition at line 149 of file sqlite.w32.h.

#define SQLITE_CANTOPEN   14 /* Unable to open the database file */

Definition at line 158 of file sqlite.w32.h.

#define SQLITE_CONSTRAINT   19 /* Abort due to contraint violation */

Definition at line 163 of file sqlite.w32.h.

#define SQLITE_COPY   0 /* Table Name File Name */

Definition at line 536 of file sqlite.w32.h.

#define SQLITE_CORRUPT   11 /* The database disk image is malformed */

Definition at line 155 of file sqlite.w32.h.

#define SQLITE_CREATE_INDEX   1 /* Index Name Table Name */

Definition at line 537 of file sqlite.w32.h.

#define SQLITE_CREATE_TABLE   2 /* Table Name NULL */

Definition at line 538 of file sqlite.w32.h.

#define SQLITE_CREATE_TEMP_INDEX   3 /* Index Name Table Name */

Definition at line 539 of file sqlite.w32.h.

#define SQLITE_CREATE_TEMP_TABLE   4 /* Table Name NULL */

Definition at line 540 of file sqlite.w32.h.

#define SQLITE_CREATE_TEMP_TRIGGER   5 /* Trigger Name Table Name */

Definition at line 541 of file sqlite.w32.h.

#define SQLITE_CREATE_TEMP_VIEW   6 /* View Name NULL */

Definition at line 542 of file sqlite.w32.h.

#define SQLITE_CREATE_TRIGGER   7 /* Trigger Name Table Name */

Definition at line 543 of file sqlite.w32.h.

#define SQLITE_CREATE_VIEW   8 /* View Name NULL */

Definition at line 544 of file sqlite.w32.h.

#define SQLITE_DELETE   9 /* Table Name NULL */

Definition at line 545 of file sqlite.w32.h.

#define SQLITE_DENY   1 /* Abort the SQL statement with an error */

Definition at line 569 of file sqlite.w32.h.

#define SQLITE_DETACH   25 /* Database Name NULL */

Definition at line 561 of file sqlite.w32.h.

#define SQLITE_DONE   101 /* sqlite_step() has finished executing */

Definition at line 172 of file sqlite.w32.h.

#define SQLITE_DROP_INDEX   10 /* Index Name Table Name */

Definition at line 546 of file sqlite.w32.h.

#define SQLITE_DROP_TABLE   11 /* Table Name NULL */

Definition at line 547 of file sqlite.w32.h.

#define SQLITE_DROP_TEMP_INDEX   12 /* Index Name Table Name */

Definition at line 548 of file sqlite.w32.h.

#define SQLITE_DROP_TEMP_TABLE   13 /* Table Name NULL */

Definition at line 549 of file sqlite.w32.h.

#define SQLITE_DROP_TEMP_TRIGGER   14 /* Trigger Name Table Name */

Definition at line 550 of file sqlite.w32.h.

#define SQLITE_DROP_TEMP_VIEW   15 /* View Name NULL */

Definition at line 551 of file sqlite.w32.h.

#define SQLITE_DROP_TRIGGER   16 /* Trigger Name Table Name */

Definition at line 552 of file sqlite.w32.h.

#define SQLITE_DROP_VIEW   17 /* View Name NULL */

Definition at line 553 of file sqlite.w32.h.

#define SQLITE_EMPTY   16 /* (Internal Only) Database table is empty */

Definition at line 160 of file sqlite.w32.h.

#define SQLITE_ERROR   1 /* SQL error or missing database */

Definition at line 145 of file sqlite.w32.h.

#define SQLITE_FORMAT   24 /* Auxiliary database format error */

Definition at line 168 of file sqlite.w32.h.

#define SQLITE_FULL   13 /* Insertion failed because database is full */

Definition at line 157 of file sqlite.w32.h.

#define SQLITE_IGNORE   2 /* Don't allow access, but don't generate an error */

Definition at line 570 of file sqlite.w32.h.

#define SQLITE_INSERT   18 /* Table Name NULL */

Definition at line 554 of file sqlite.w32.h.

#define SQLITE_INTERNAL   2 /* An internal logic error in SQLite */

Definition at line 146 of file sqlite.w32.h.

#define SQLITE_INTERRUPT   9 /* Operation terminated by sqlite_interrupt() */

Definition at line 153 of file sqlite.w32.h.

#define SQLITE_IOERR   10 /* Some kind of disk I/O error occurred */

Definition at line 154 of file sqlite.w32.h.

#define SQLITE_ISO8859   1

Definition at line 45 of file sqlite.w32.h.

#define SQLITE_LOCKED   6 /* A table in the database is locked */

Definition at line 150 of file sqlite.w32.h.

#define SQLITE_MISMATCH   20 /* Data type mismatch */

Definition at line 164 of file sqlite.w32.h.

#define SQLITE_MISUSE   21 /* Library used incorrectly */

Definition at line 165 of file sqlite.w32.h.

#define SQLITE_NOLFS   22 /* Uses OS features not supported on host */

Definition at line 166 of file sqlite.w32.h.

#define SQLITE_NOMEM   7 /* A malloc() failed */

Definition at line 151 of file sqlite.w32.h.

#define SQLITE_NOTADB   26 /* File opened that is not a database file */

Definition at line 170 of file sqlite.w32.h.

#define SQLITE_NOTFOUND   12 /* (Internal Only) Table or record not found */

Definition at line 156 of file sqlite.w32.h.

#define SQLITE_NUMERIC   (-1)

Definition at line 456 of file sqlite.w32.h.

#define SQLITE_OK   0 /* Successful result */

Definition at line 144 of file sqlite.w32.h.

#define SQLITE_PERM   3 /* Access permission denied */

Definition at line 147 of file sqlite.w32.h.

#define SQLITE_PRAGMA   19 /* Pragma Name 1st arg or NULL */

Definition at line 555 of file sqlite.w32.h.

#define SQLITE_PROTOCOL   15 /* Database lock protocol error */

Definition at line 159 of file sqlite.w32.h.

#define SQLITE_RANGE   25 /* 2nd parameter to sqlite_bind out of range */

Definition at line 169 of file sqlite.w32.h.

#define SQLITE_READ   20 /* Table Name Column Name */

Definition at line 556 of file sqlite.w32.h.

#define SQLITE_READONLY   8 /* Attempt to write a readonly database */

Definition at line 152 of file sqlite.w32.h.

#define SQLITE_ROW   100 /* sqlite_step() has another row ready */

Definition at line 171 of file sqlite.w32.h.

#define SQLITE_SCHEMA   17 /* The database schema changed */

Definition at line 161 of file sqlite.w32.h.

#define SQLITE_SELECT   21 /* NULL NULL */

Definition at line 557 of file sqlite.w32.h.

#define SQLITE_TEXT   (-2)

Definition at line 457 of file sqlite.w32.h.

#define SQLITE_TOOBIG   18 /* Too much data for one row of a table */

Definition at line 162 of file sqlite.w32.h.

#define SQLITE_TRANSACTION   22 /* NULL NULL */

Definition at line 558 of file sqlite.w32.h.

#define SQLITE_UPDATE   23 /* Table Name Column Name */

Definition at line 559 of file sqlite.w32.h.

#define SQLITE_VERSION   "2.8.17"

Definition at line 31 of file sqlite.w32.h.

#define sqliteErrStr   sqlite_error_string /* Legacy. Do not use in new code. */

Definition at line 212 of file sqlite.w32.h.


Typedef Documentation

typedef struct sqlite

Definition at line 59 of file sqlite.w32.h.

typedef int(* sqlite_callback)(void *, int, char **, char **)

Definition at line 91 of file sqlite.w32.h.

typedef struct sqlite_func

Definition at line 417 of file sqlite.w32.h.

typedef struct sqlite_vm

Definition at line 587 of file sqlite.w32.h.


Function Documentation

void* sqlite_aggregate_context ( sqlite_func ,
int  nBytes 
)

Definition at line 480 of file vdbeaux.c.

                                                         {
  assert( p && p->pFunc && p->pFunc->xStep );
  if( p->pAgg==0 ){
    if( nByte<=NBFS ){
      p->pAgg = (void*)p->s.z;
      memset(p->pAgg, 0, nByte);
    }else{
      p->pAgg = sqliteMalloc( nByte );
    }
  }
  return p->pAgg;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 501 of file vdbeaux.c.

                                          {
  assert( p && p->pFunc && p->pFunc->xStep );
  return p->cnt;
}
int sqlite_bind ( sqlite_vm ,
int  idx,
const char *  value,
int  len,
int  copy 
)

Definition at line 948 of file vdbeaux.c.

                                                                           {
  Vdbe *p = (Vdbe*)pVm;
  if( p->magic!=VDBE_MAGIC_RUN || p->pc!=0 ){
    return SQLITE_MISUSE;
  }
  if( i<1 || i>p->nVar ){
    return SQLITE_RANGE;
  }
  i--;
  if( p->abVar[i] ){
    sqliteFree(p->azVar[i]);
  }
  if( zVal==0 ){
    copy = 0;
    len = 0;
  }
  if( len<0 ){
    len = strlen(zVal)+1;
  }
  if( copy ){
    p->azVar[i] = sqliteMalloc( len );
    if( p->azVar[i] ) memcpy(p->azVar[i], zVal, len);
  }else{
    p->azVar[i] = (char*)zVal;
  }
  p->abVar[i] = copy;
  p->anVar[i] = len;
  return SQLITE_OK;
}

Here is the call graph for this function:

void sqlite_busy_handler ( sqlite ,
int(*)(void *, const char *, int ,
void *   
)

Definition at line 906 of file main.c.

 {
  db->xBusyCallback = xBusy;
  db->pBusyArg = pArg;
}

Here is the caller graph for this function:

void sqlite_busy_timeout ( sqlite ,
int  ms 
)

Definition at line 944 of file main.c.

                                            {
  if( ms>0 ){
    sqlite_busy_handler(db, sqliteDefaultBusyCallback, (void*)(long)ms);
  }else{
    sqlite_busy_handler(db, 0, 0);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 551 of file main.c.

                              {
  return db->nChange;
}

Here is the caller graph for this function:

void sqlite_close ( sqlite )

Definition at line 568 of file main.c.

                             {
  HashElem *i;
  int j;
  db->want_to_close = 1;
  if( sqliteSafetyCheck(db) || sqliteSafetyOn(db) ){
    /* printf("DID NOT CLOSE\n"); fflush(stdout); */
    return;
  }
  db->magic = SQLITE_MAGIC_CLOSED;
  for(j=0; j<db->nDb; j++){
    struct Db *pDb = &db->aDb[j];
    if( pDb->pBt ){
      sqliteBtreeClose(pDb->pBt);
      pDb->pBt = 0;
    }
  }
  sqliteResetInternalSchema(db, 0);
  assert( db->nDb<=2 );
  assert( db->aDb==db->aDbStatic );
  for(i=sqliteHashFirst(&db->aFunc); i; i=sqliteHashNext(i)){
    FuncDef *pFunc, *pNext;
    for(pFunc = (FuncDef*)sqliteHashData(i); pFunc; pFunc=pNext){
      pNext = pFunc->pNext;
      sqliteFree(pFunc);
    }
  }
  sqliteHashClear(&db->aFunc);
  sqliteFree(db);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite_compile ( sqlite db,
const char *  zSql,
const char **  pzTail,
sqlite_vm **  ppVm,
char **  pzErrmsg 
)

Definition at line 691 of file main.c.

 {
  Parse sParse;

  if( pzErrMsg ) *pzErrMsg = 0;
  if( sqliteSafetyOn(db) ) goto exec_misuse;
  if( !db->init.busy ){
    if( (db->flags & SQLITE_Initialized)==0 ){
      int rc, cnt = 1;
      while( (rc = sqliteInit(db, pzErrMsg))==SQLITE_BUSY
         && db->xBusyCallback
         && db->xBusyCallback(db->pBusyArg, "", cnt++)!=0 ){}
      if( rc!=SQLITE_OK ){
        sqliteStrRealloc(pzErrMsg);
        sqliteSafetyOff(db);
        return rc;
      }
      if( pzErrMsg ){
        sqliteFree(*pzErrMsg);
        *pzErrMsg = 0;
      }
    }
    if( db->file_format<3 ){
      sqliteSafetyOff(db);
      sqliteSetString(pzErrMsg, "obsolete database file format", (char*)0);
      return SQLITE_ERROR;
    }
  }
  assert( (db->flags & SQLITE_Initialized)!=0 || db->init.busy );
  if( db->pVdbe==0 ){ db->nChange = 0; }
  memset(&sParse, 0, sizeof(sParse));
  sParse.db = db;
  sqliteRunParser(&sParse, zSql, pzErrMsg);
  if( db->xTrace && !db->init.busy ){
    /* Trace only the statment that was compiled.
    ** Make a copy of that part of the SQL string since zSQL is const
    ** and we must pass a zero terminated string to the trace function
    ** The copy is unnecessary if the tail pointer is pointing at the
    ** beginnig or end of the SQL string.
    */
    if( sParse.zTail && sParse.zTail!=zSql && *sParse.zTail ){
      char *tmpSql = sqliteStrNDup(zSql, sParse.zTail - zSql);
      if( tmpSql ){
        db->xTrace(db->pTraceArg, tmpSql);
        free(tmpSql);
      }else{
        /* If a memory error occurred during the copy,
        ** trace entire SQL string and fall through to the
        ** sqlite_malloc_failed test to report the error.
        */
        db->xTrace(db->pTraceArg, zSql); 
      }
    }else{
      db->xTrace(db->pTraceArg, zSql); 
    }
  }
  if( sqlite_malloc_failed ){
    sqliteSetString(pzErrMsg, "out of memory", (char*)0);
    sParse.rc = SQLITE_NOMEM;
    sqliteRollbackAll(db);
    sqliteResetInternalSchema(db, 0);
    db->flags &= ~SQLITE_InTrans;
  }
  if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK;
  if( sParse.rc!=SQLITE_OK && pzErrMsg && *pzErrMsg==0 ){
    sqliteSetString(pzErrMsg, sqlite_error_string(sParse.rc), (char*)0);
  }
  sqliteStrRealloc(pzErrMsg);
  if( sParse.rc==SQLITE_SCHEMA ){
    sqliteResetInternalSchema(db, 0);
  }
  assert( ppVm );
  *ppVm = (sqlite_vm*)sParse.pVdbe;
  if( pzTail ) *pzTail = sParse.zTail;
  if( sqliteSafetyOff(db) ) goto exec_misuse;
  return sParse.rc;

exec_misuse:
  if( pzErrMsg ){
    *pzErrMsg = 0;
    sqliteSetString(pzErrMsg, sqlite_error_string(SQLITE_MISUSE), (char*)0);
    sqliteStrRealloc(pzErrMsg);
  }
  return SQLITE_MISUSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite_complete ( const char *  sql)

Definition at line 554 of file tokenize.c.

                                     {
  u8 state = 0;   /* Current state, using numbers defined in header comment */
  u8 token;       /* Value of the next token */

  /* The following matrix defines the transition from one state to another
  ** according to what token is seen.  trans[state][token] returns the
  ** next state.
  */
  static const u8 trans[7][8] = {
                     /* Token:                                                */
     /* State:       **  EXPLAIN  CREATE  TEMP  TRIGGER  END  SEMI  WS  OTHER */
     /* 0   START: */ {       1,      2,    3,       3,   3,    0,  0,     3, },
     /* 1 EXPLAIN: */ {       3,      2,    3,       3,   3,    0,  1,     3, },
     /* 2  CREATE: */ {       3,      3,    2,       4,   3,    0,  2,     3, },
     /* 3  NORMAL: */ {       3,      3,    3,       3,   3,    0,  3,     3, },
     /* 4 TRIGGER: */ {       4,      4,    4,       4,   4,    5,  4,     4, },
     /* 5    SEMI: */ {       4,      4,    4,       4,   6,    5,  5,     4, },
     /* 6     END: */ {       4,      4,    4,       4,   4,    0,  6,     4, },
  };

  while( *zSql ){
    switch( *zSql ){
      case ';': {  /* A semicolon */
        token = tkSEMI;
        break;
      }
      case ' ':
      case '\r':
      case '\t':
      case '\n':
      case '\f': {  /* White space is ignored */
        token = tkWS;
        break;
      }
      case '/': {   /* C-style comments */
        if( zSql[1]!='*' ){
          token = tkOTHER;
          break;
        }
        zSql += 2;
        while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; }
        if( zSql[0]==0 ) return 0;
        zSql++;
        token = tkWS;
        break;
      }
      case '-': {   /* SQL-style comments from "--" to end of line */
        if( zSql[1]!='-' ){
          token = tkOTHER;
          break;
        }
        while( *zSql && *zSql!='\n' ){ zSql++; }
        if( *zSql==0 ) return state==0;
        token = tkWS;
        break;
      }
      case '[': {   /* Microsoft-style identifiers in [...] */
        zSql++;
        while( *zSql && *zSql!=']' ){ zSql++; }
        if( *zSql==0 ) return 0;
        token = tkOTHER;
        break;
      }
      case '"':     /* single- and double-quoted strings */
      case '\'': {
        int c = *zSql;
        zSql++;
        while( *zSql && *zSql!=c ){ zSql++; }
        if( *zSql==0 ) return 0;
        token = tkOTHER;
        break;
      }
      default: {
        if( isIdChar[(u8)*zSql] ){
          /* Keywords and unquoted identifiers */
          int nId;
          for(nId=1; isIdChar[(u8)zSql[nId]]; nId++){}
          switch( *zSql ){
            case 'c': case 'C': {
              if( nId==6 && sqliteStrNICmp(zSql, "create", 6)==0 ){
                token = tkCREATE;
              }else{
                token = tkOTHER;
              }
              break;
            }
            case 't': case 'T': {
              if( nId==7 && sqliteStrNICmp(zSql, "trigger", 7)==0 ){
                token = tkTRIGGER;
              }else if( nId==4 && sqliteStrNICmp(zSql, "temp", 4)==0 ){
                token = tkTEMP;
              }else if( nId==9 && sqliteStrNICmp(zSql, "temporary", 9)==0 ){
                token = tkTEMP;
              }else{
                token = tkOTHER;
              }
              break;
            }
            case 'e':  case 'E': {
              if( nId==3 && sqliteStrNICmp(zSql, "end", 3)==0 ){
                token = tkEND;
              }else if( nId==7 && sqliteStrNICmp(zSql, "explain", 7)==0 ){
                token = tkEXPLAIN;
              }else{
                token = tkOTHER;
              }
              break;
            }
            default: {
              token = tkOTHER;
              break;
            }
          }
          zSql += nId-1;
        }else{
          /* Operators and special symbols */
          token = tkOTHER;
        }
        break;
      }
    }
    state = trans[state][token];
    zSql++;
  }
  return state==0;
}

Here is the call graph for this function:

int sqlite_create_aggregate ( sqlite ,
const char *  zName,
int  nArg,
void(*)(sqlite_func *, int, const char **)  xStep,
void(*)(sqlite_func *)  xFinalize,
void *  pUserData 
)

Definition at line 1014 of file main.c.

 {
  FuncDef *p;
  int nName;
  if( db==0 || zName==0 || sqliteSafetyCheck(db) ) return 1;
  if( nArg<-1 || nArg>127 ) return 1;
  nName = strlen(zName);
  if( nName>255 ) return 1;
  p = sqliteFindFunction(db, zName, nName, nArg, 1);
  if( p==0 ) return 1;
  p->xFunc = 0;
  p->xStep = xStep;
  p->xFinalize = xFinalize;
  p->pUserData = pUserData;
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite_create_function ( sqlite ,
const char *  zName,
int  nArg,
void(*)(sqlite_func *, int, const char **)  xFunc,
void *  pUserData 
)

Definition at line 993 of file main.c.

 {
  FuncDef *p;
  int nName;
  if( db==0 || zName==0 || sqliteSafetyCheck(db) ) return 1;
  if( nArg<-1 || nArg>127 ) return 1;
  nName = strlen(zName);
  if( nName>255 ) return 1;
  p = sqliteFindFunction(db, zName, nName, nArg, 1);
  if( p==0 ) return 1;
  p->xFunc = xFunc;
  p->xStep = 0;
  p->xFinalize = 0;
  p->pUserData = pUserData;
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* sqlite_error_string ( int  )

Definition at line 824 of file main.c.

                                       {
  const char *z;
  switch( rc ){
    case SQLITE_OK:         z = "not an error";                          break;
    case SQLITE_ERROR:      z = "SQL logic error or missing database";   break;
    case SQLITE_INTERNAL:   z = "internal SQLite implementation flaw";   break;
    case SQLITE_PERM:       z = "access permission denied";              break;
    case SQLITE_ABORT:      z = "callback requested query abort";        break;
    case SQLITE_BUSY:       z = "database is locked";                    break;
    case SQLITE_LOCKED:     z = "database table is locked";              break;
    case SQLITE_NOMEM:      z = "out of memory";                         break;
    case SQLITE_READONLY:   z = "attempt to write a readonly database";  break;
    case SQLITE_INTERRUPT:  z = "interrupted";                           break;
    case SQLITE_IOERR:      z = "disk I/O error";                        break;
    case SQLITE_CORRUPT:    z = "database disk image is malformed";      break;
    case SQLITE_NOTFOUND:   z = "table or record not found";             break;
    case SQLITE_FULL:       z = "database is full";                      break;
    case SQLITE_CANTOPEN:   z = "unable to open database file";          break;
    case SQLITE_PROTOCOL:   z = "database locking protocol failure";     break;
    case SQLITE_EMPTY:      z = "table contains no data";                break;
    case SQLITE_SCHEMA:     z = "database schema has changed";           break;
    case SQLITE_TOOBIG:     z = "too much data for one table row";       break;
    case SQLITE_CONSTRAINT: z = "constraint failed";                     break;
    case SQLITE_MISMATCH:   z = "datatype mismatch";                     break;
    case SQLITE_MISUSE:     z = "library routine called out of sequence";break;
    case SQLITE_NOLFS:      z = "kernel lacks large file support";       break;
    case SQLITE_AUTH:       z = "authorization denied";                  break;
    case SQLITE_FORMAT:     z = "auxiliary database format error";       break;
    case SQLITE_RANGE:      z = "bind index out of range";               break;
    case SQLITE_NOTADB:     z = "file is encrypted or is not a database";break;
    default:                z = "unknown error";                         break;
  }
  return z;
}

Here is the caller graph for this function:

int sqlite_exec ( sqlite ,
const char *  sql,
sqlite_callback  ,
void *  ,
char **  errmsg 
)

Definition at line 623 of file main.c.

 {
  int rc = SQLITE_OK;
  const char *zLeftover;
  sqlite_vm *pVm;
  int nRetry = 0;
  int nChange = 0;
  int nCallback;

  if( zSql==0 ) return SQLITE_OK;
  while( rc==SQLITE_OK && zSql[0] ){
    pVm = 0;
    rc = sqlite_compile(db, zSql, &zLeftover, &pVm, pzErrMsg);
    if( rc!=SQLITE_OK ){
      assert( pVm==0 || sqlite_malloc_failed );
      return rc;
    }
    if( pVm==0 ){
      /* This happens if the zSql input contained only whitespace */
      break;
    }
    db->nChange += nChange;
    nCallback = 0;
    while(1){
      int nArg;
      char **azArg, **azCol;
      rc = sqlite_step(pVm, &nArg, (const char***)&azArg,(const char***)&azCol);
      if( rc==SQLITE_ROW ){
        if( xCallback!=0 && xCallback(pArg, nArg, azArg, azCol) ){
          sqlite_finalize(pVm, 0);
          return SQLITE_ABORT;
        }
        nCallback++;
      }else{
        if( rc==SQLITE_DONE && nCallback==0
          && (db->flags & SQLITE_NullCallback)!=0 && xCallback!=0 ){
          xCallback(pArg, nArg, azArg, azCol);
        }
        rc = sqlite_finalize(pVm, pzErrMsg);
        if( rc==SQLITE_SCHEMA && nRetry<2 ){
          nRetry++;
          rc = SQLITE_OK;
          break;
        }
        if( db->pVdbe==0 ){
          nChange = db->nChange;
        }
        nRetry = 0;
        zSql = zLeftover;
        while( isspace(zSql[0]) ) zSql++;
        break;
      }
    }
  }
  return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite_exec_printf ( sqlite ,
const char *  sqlFormat,
sqlite_callback  ,
void *  ,
char **  errmsg,
  ... 
)

Definition at line 792 of file printf.c.

 {
  va_list ap;
  int rc;

  va_start(ap, errmsg);
  rc = sqlite_exec_vprintf(db, sqlFormat, xCallback, pArg, errmsg, ap);
  va_end(ap);
  return rc;

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite_exec_vprintf ( sqlite ,
const char *  sqlFormat,
sqlite_callback  ,
void *  ,
char **  errmsg,
va_list  ap 
)

Definition at line 808 of file printf.c.

 {
  char *zSql;
  int rc;

  zSql = sqlite_vmprintf(sqlFormat, ap);
  rc = sqlite_exec(db, zSql, xCallback, pArg, errmsg);
  free(zSql);
  return rc;

Here is the caller graph for this function:

int sqlite_finalize ( sqlite_vm ,
char **  pzErrMsg 
)

Definition at line 794 of file main.c.

 {
  int rc = sqliteVdbeFinalize((Vdbe*)pVm, pzErrMsg);
  sqliteStrRealloc(pzErrMsg);
  return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite_free_table ( char **  result)

Definition at line 192 of file table.c.

 {
  if( azResult ){
    int i, n;
    azResult--;
    if( azResult==0 ) return;
    n = (int)(long)azResult[0];
    for(i=1; i<n; i++){ if( azResult[i] ) free(azResult[i]); }
    free(azResult);
  }
}

Here is the caller graph for this function:

void sqlite_freemem ( void *  p)

Definition at line 969 of file main.c.

{ free(p); }

Here is the caller graph for this function:

int sqlite_function_type ( sqlite db,
const char *  zName,
int  datatype 
)

Definition at line 1042 of file main.c.

                                                                     {
  FuncDef *p = (FuncDef*)sqliteHashFind(&db->aFunc, zName, strlen(zName));
  while( p ){
    p->dataType = dataType; 
    p = p->pNext;
  }
  return SQLITE_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite_get_table ( sqlite ,
const char *  sql,
char ***  resultp,
int nrow,
int ncolumn,
char **  errmsg 
)

Definition at line 125 of file table.c.

 {
  int rc;
  TabResult res;
  if( pazResult==0 ){ return SQLITE_ERROR; }
  *pazResult = 0;
  if( pnColumn ) *pnColumn = 0;
  if( pnRow ) *pnRow = 0;
  res.zErrMsg = 0;
  res.nResult = 0;
  res.nRow = 0;
  res.nColumn = 0;
  res.nData = 1;
  res.nAlloc = 20;
  res.rc = SQLITE_OK;
  res.azResult = malloc( sizeof(char*)*res.nAlloc );
  if( res.azResult==0 ){
    return SQLITE_NOMEM;
  }
  res.azResult[0] = 0;
  rc = sqlite_exec(db, zSql, sqlite_get_table_cb, &res, pzErrMsg);
  if( res.azResult ){
    res.azResult[0] = (char*)res.nData;
  }
  if( rc==SQLITE_ABORT ){
    sqlite_free_table(&res.azResult[1]);
    if( res.zErrMsg ){
      if( pzErrMsg ){
        free(*pzErrMsg);
        *pzErrMsg = res.zErrMsg;
        sqliteStrRealloc(pzErrMsg);
      }else{
        sqliteFree(res.zErrMsg);
      }
    }
    return res.rc;
  }
  sqliteFree(res.zErrMsg);
  if( rc!=SQLITE_OK ){
    sqlite_free_table(&res.azResult[1]);
    return rc;
  }
  if( res.nAlloc>res.nData ){
    char **azNew;
    azNew = realloc( res.azResult, sizeof(char*)*(res.nData+1) );
    if( azNew==0 ){
      sqlite_free_table(&res.azResult[1]);
      return SQLITE_NOMEM;
    }
    res.nAlloc = res.nData+1;
    res.azResult = azNew;
  }
  *pazResult = &res.azResult[1];
  if( pnColumn ) *pnColumn = res.nColumn;
  if( pnRow ) *pnRow = res.nRow;
  return rc;
}

Here is the call graph for this function:

int sqlite_get_table_printf ( sqlite ,
const char *  sqlFormat,
char ***  resultp,
int nrow,
int ncolumn,
char **  errmsg,
  ... 
)

Definition at line 824 of file printf.c.

 {
  va_list ap;
  int rc;

  va_start(ap, errmsg);
  rc = sqlite_get_table_vprintf(db, sqlFormat, resultp, nrow, ncol, errmsg, ap);
  va_end(ap);
  return rc;
int sqlite_get_table_vprintf ( sqlite ,
const char *  sqlFormat,
char ***  resultp,
int nrow,
int ncolumn,
char **  errmsg,
va_list  ap 
)

Definition at line 841 of file printf.c.

 {
  char *zSql;
  int rc;

  zSql = sqlite_vmprintf(sqlFormat, ap);
  rc = sqlite_get_table(db, zSql, resultp, nrow, ncolumn, errmsg);
  free(zSql);
  return rc;
void sqlite_interrupt ( sqlite )

Definition at line 955 of file main.c.

                                 {
  db->flags |= SQLITE_Interrupt;
}

Here is the caller graph for this function:

Definition at line 544 of file main.c.

                                        {
  return db->lastRowid;
}

Here is the caller graph for this function:

const char* sqlite_libencoding ( void  )

Definition at line 977 of file main.c.

{ return sqlite_encoding; }

Here is the caller graph for this function:

const char* sqlite_libversion ( void  )

Definition at line 976 of file main.c.

{ return sqlite_version; }

Here is the caller graph for this function:

char* sqlite_mprintf ( const char *  ,
  ... 
)

Definition at line 748 of file printf.c.

                                              {
  va_list ap;
  char *z;
  char zBuf[200];

  va_start(ap,zFormat);
  z = base_vprintf((void*(*)(void*,int))realloc, 0, 
                   zBuf, sizeof(zBuf), zFormat, ap);
  va_end(ap);
  return z;

Here is the call graph for this function:

Here is the caller graph for this function:

sqlite* sqlite_open ( const char *  filename,
int  mode,
char **  errmsg 
)

Definition at line 475 of file main.c.

                                                                     {
  sqlite *db;
  int rc, i;

  /* Allocate the sqlite data structure */
  db = sqliteMalloc( sizeof(sqlite) );
  if( pzErrMsg ) *pzErrMsg = 0;
  if( db==0 ) goto no_mem_on_open;
  db->onError = OE_Default;
  db->priorNewRowid = 0;
  db->magic = SQLITE_MAGIC_BUSY;
  db->nDb = 2;
  db->aDb = db->aDbStatic;
  /* db->flags |= SQLITE_ShortColNames; */
  sqliteHashInit(&db->aFunc, SQLITE_HASH_STRING, 1);
  for(i=0; i<db->nDb; i++){
    sqliteHashInit(&db->aDb[i].tblHash, SQLITE_HASH_STRING, 0);
    sqliteHashInit(&db->aDb[i].idxHash, SQLITE_HASH_STRING, 0);
    sqliteHashInit(&db->aDb[i].trigHash, SQLITE_HASH_STRING, 0);
    sqliteHashInit(&db->aDb[i].aFKey, SQLITE_HASH_STRING, 1);
  }
  
  /* Open the backend database driver */
  if( zFilename[0]==':' && strcmp(zFilename,":memory:")==0 ){
    db->temp_store = 2;
  }
  rc = sqliteBtreeFactory(db, zFilename, 0, MAX_PAGES, &db->aDb[0].pBt);
  if( rc!=SQLITE_OK ){
    switch( rc ){
      default: {
        sqliteSetString(pzErrMsg, "unable to open database: ",
           zFilename, (char*)0);
      }
    }
    sqliteFree(db);
    sqliteStrRealloc(pzErrMsg);
    return 0;
  }
  db->aDb[0].zName = "main";
  db->aDb[1].zName = "temp";

  /* Attempt to read the schema */
  sqliteRegisterBuiltinFunctions(db);
  rc = sqliteInit(db, pzErrMsg);
  db->magic = SQLITE_MAGIC_OPEN;
  if( sqlite_malloc_failed ){
    sqlite_close(db);
    goto no_mem_on_open;
  }else if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){
    sqlite_close(db);
    sqliteStrRealloc(pzErrMsg);
    return 0;
  }else if( pzErrMsg ){
    sqliteFree(*pzErrMsg);
    *pzErrMsg = 0;
  }

  /* Return a pointer to the newly opened database structure */
  return db;

no_mem_on_open:
  sqliteSetString(pzErrMsg, "out of memory", (char*)0);
  sqliteStrRealloc(pzErrMsg);
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite_progress_handler ( sqlite ,
int  ,
int(*)(void *)  ,
void *   
)

Definition at line 921 of file main.c.

 {
  if( nOps>0 ){
    db->xProgress = xProgress;
    db->nProgressOps = nOps;
    db->pProgressArg = pArg;
  }else{
    db->xProgress = 0;
    db->nProgressOps = 0;
    db->pProgressArg = 0;
  }
}
int sqlite_reset ( sqlite_vm ,
char **  pzErrMsg 
)

Definition at line 810 of file main.c.

 {
  int rc = sqliteVdbeReset((Vdbe*)pVm, pzErrMsg);
  sqliteVdbeMakeReady((Vdbe*)pVm, -1, 0);
  sqliteStrRealloc(pzErrMsg);
  return rc;
}

Here is the call graph for this function:

int sqlite_set_authorizer ( sqlite ,
int(*)(void *, int, const char *, const char *, const char *, const char *)  xAuth,
void *  pUserData 
)

Definition at line 73 of file auth.c.

 {
  db->xAuth = xAuth;
  db->pAuthArg = pArg;
  return SQLITE_OK;
}

Here is the caller graph for this function:

void sqlite_set_result_double ( sqlite_func ,
double   
)

Definition at line 448 of file vdbeaux.c.

                                                             {
  assert( !p->isStep );
  if( p->s.flags & MEM_Dyn ){
    sqliteFree(p->s.z);
  }
  p->s.r = rResult;
  p->s.flags = MEM_Real;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite_set_result_error ( sqlite_func ,
const char *  ,
int   
)

Definition at line 456 of file vdbeaux.c.

                                                                     {
  assert( !p->isStep );
  sqlite_set_result_string(p, zMsg, n);
  p->isError = 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite_set_result_int ( sqlite_func ,
int   
)

Definition at line 440 of file vdbeaux.c.

                                                       {
  assert( !p->isStep );
  if( p->s.flags & MEM_Dyn ){
    sqliteFree(p->s.z);
  }
  p->s.i = iResult;
  p->s.flags = MEM_Int;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* sqlite_set_result_string ( sqlite_func ,
const char *  ,
int   
)

Definition at line 411 of file vdbeaux.c.

                                                                          {
  assert( !p->isStep );
  if( p->s.flags & MEM_Dyn ){
    sqliteFree(p->s.z);
  }
  if( zResult==0 ){
    p->s.flags = MEM_Null;
    n = 0;
    p->s.z = 0;
    p->s.n = 0;
  }else{
    if( n<0 ) n = strlen(zResult);
    if( n<NBFS-1 ){
      memcpy(p->s.zShort, zResult, n);
      p->s.zShort[n] = 0;
      p->s.flags = MEM_Str | MEM_Short;
      p->s.z = p->s.zShort;
    }else{
      p->s.z = sqliteMallocRaw( n+1 );
      if( p->s.z ){
        memcpy(p->s.z, zResult, n);
        p->s.z[n] = 0;
      }
      p->s.flags = MEM_Str | MEM_Dyn;
    }
    p->s.n = n+1;
  }
  return p->s.z;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite_step ( sqlite_vm pVm,
int pN,
const char ***  pazValue,
const char ***  pazColName 
)

Definition at line 107 of file vdbe.c.

 {
  Vdbe *p = (Vdbe*)pVm;
  sqlite *db;
  int rc;

  if( !p || p->magic!=VDBE_MAGIC_RUN ){
    return SQLITE_MISUSE;
  }
  db = p->db;
  if( sqliteSafetyOn(db) ){
    p->rc = SQLITE_MISUSE;
    return SQLITE_MISUSE;
  }
  if( p->explain ){
    rc = sqliteVdbeList(p);
  }else{
    rc = sqliteVdbeExec(p);
  }
  if( rc==SQLITE_DONE || rc==SQLITE_ROW ){
    if( pazColName ) *pazColName = (const char**)p->azColName;
    if( pN ) *pN = p->nResColumn;
  }else{
    if( pazColName) *pazColName = 0;
    if( pN ) *pN = 0;
  }
  if( pazValue ){
    if( rc==SQLITE_ROW ){
      *pazValue = (const char**)p->azResColumn;
    }else{
      *pazValue = 0;
    }
  }
  if( sqliteSafetyOff(db) ){
    return SQLITE_MISUSE;
  }
  return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* sqlite_trace ( sqlite ,
void(*)(void *, const char *)  xTrace,
void *   
)

Definition at line 1059 of file main.c.

                                                                             {
  void *pOld = db->pTraceArg;
  db->xTrace = xTrace;
  db->pTraceArg = pArg;
  return pOld;
}

Definition at line 466 of file vdbeaux.c.

                                      {
  assert( p && p->pFunc );
  return p->pFunc->pUserData;
}

Here is the caller graph for this function:

char* sqlite_vmprintf ( const char *  ,
va_list   
)

Definition at line 762 of file printf.c.

                                                      {
  char zBuf[200];
  return base_vprintf((void*(*)(void*,int))realloc, 0,
                      zBuf, sizeof(zBuf), zFormat, ap);

Here is the call graph for this function:


Variable Documentation

const char sqlite_encoding[]

Definition at line 463 of file main.c.

const char sqlite_version[]

Definition at line 454 of file main.c.