Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
main.c File Reference
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

Go to the source code of this file.

Functions

const char * sqlite3_libversion (void)
int sqlite3_libversion_number (void)
static int binCollFunc (void *NotUsed, int nKey1, const void *pKey1, int nKey2, const void *pKey2)
static int nocaseCollatingFunc (void *NotUsed, int nKey1, const void *pKey1, int nKey2, const void *pKey2)
sqlite_int64 sqlite3_last_insert_rowid (sqlite3 *db)
int sqlite3_changes (sqlite3 *db)
int sqlite3_total_changes (sqlite3 *db)
int sqlite3_close (sqlite3 *db)
void sqlite3RollbackAll (sqlite3 *db)
const char * sqlite3ErrStr (int rc)
static int sqliteDefaultBusyCallback (void *ptr, int count)
int sqlite3InvokeBusyHandler (BusyHandler *p)
int sqlite3_busy_handler (sqlite3 *db, int(*xBusy)(void *, int), void *pArg)
void sqlite3_progress_handler (sqlite3 *db, int nOps, int(*xProgress)(void *), void *pArg)
int sqlite3_busy_timeout (sqlite3 *db, int ms)
void sqlite3_interrupt (sqlite3 *db)
void sqlite3_free (char *p)
int sqlite3CreateFunc (sqlite3 *db, const char *zFunctionName, int nArg, int enc, void *pUserData, void(*xFunc)(sqlite3_context *, int, sqlite3_value **), void(*xStep)(sqlite3_context *, int, sqlite3_value **), void(*xFinal)(sqlite3_context *))
int sqlite3_create_function (sqlite3 *db, const char *zFunctionName, int nArg, int enc, void *p, void(*xFunc)(sqlite3_context *, int, sqlite3_value **), void(*xStep)(sqlite3_context *, int, sqlite3_value **), void(*xFinal)(sqlite3_context *))
int sqlite3_create_function16 (sqlite3 *db, const void *zFunctionName, int nArg, int eTextRep, void *p, void(*xFunc)(sqlite3_context *, int, sqlite3_value **), void(*xStep)(sqlite3_context *, int, sqlite3_value **), void(*xFinal)(sqlite3_context *))
voidsqlite3_trace (sqlite3 *db, void(*xTrace)(void *, const char *), void *pArg)
voidsqlite3_profile (sqlite3 *db, void(*xProfile)(void *, const char *, sqlite_uint64), void *pArg)
voidsqlite3_commit_hook (sqlite3 *db, int(*xCallback)(void *), void *pArg)
voidsqlite3_update_hook (sqlite3 *db, void(*xCallback)(void *, int, char const *, char const *, sqlite_int64), void *pArg)
voidsqlite3_rollback_hook (sqlite3 *db, void(*xCallback)(void *), void *pArg)
int sqlite3BtreeFactory (const sqlite3 *db, const char *zFilename, int omitJournal, int nCache, Btree **ppBtree)
const char * sqlite3_errmsg (sqlite3 *db)
const voidsqlite3_errmsg16 (sqlite3 *db)
int sqlite3_errcode (sqlite3 *db)
static int createCollation (sqlite3 *db, const char *zName, int enc, void *pCtx, int(*xCompare)(void *, int, const void *, int, const void *))
static int openDatabase (const char *zFilename, sqlite3 **ppDb)
int sqlite3_open (const char *zFilename, sqlite3 **ppDb)
int sqlite3_open16 (const void *zFilename, sqlite3 **ppDb)
int sqlite3_finalize (sqlite3_stmt *pStmt)
int sqlite3_reset (sqlite3_stmt *pStmt)
int sqlite3_create_collation (sqlite3 *db, const char *zName, int enc, void *pCtx, int(*xCompare)(void *, int, const void *, int, const void *))
int sqlite3_create_collation16 (sqlite3 *db, const char *zName, int enc, void *pCtx, int(*xCompare)(void *, int, const void *, int, const void *))
int sqlite3_collation_needed (sqlite3 *db, void *pCollNeededArg, void(*xCollNeeded)(void *, sqlite3 *, int eTextRep, const char *))
int sqlite3_collation_needed16 (sqlite3 *db, void *pCollNeededArg, void(*xCollNeeded16)(void *, sqlite3 *, int eTextRep, const void *))
int sqlite3_global_recover ()
int sqlite3_get_autocommit (sqlite3 *db)
int sqlite3_enable_shared_cache (int enable)
void sqlite3_thread_cleanup (void)

Variables

const int sqlite3one = 1
const char sqlite3_version [] = SQLITE_VERSION

Function Documentation

static int binCollFunc ( void NotUsed,
int  nKey1,
const void pKey1,
int  nKey2,
const void pKey2 
) [static]

Definition at line 40 of file main.c.

 {
  int rc, n;
  n = nKey1<nKey2 ? nKey1 : nKey2;
  rc = memcmp(pKey1, pKey2, n);
  if( rc==0 ){
    rc = nKey1 - nKey2;
  }
  return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int createCollation ( sqlite3 db,
const char *  zName,
int  enc,
void pCtx,
int(*)(void *, int, const void *, int, const void *)  xCompare 
) [static]

Definition at line 741 of file main.c.

 {
  CollSeq *pColl;
  int enc2;
  
  if( sqlite3SafetyCheck(db) ){
    return SQLITE_MISUSE;
  }

  /* If SQLITE_UTF16 is specified as the encoding type, transform this
  ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the
  ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.
  */
  enc2 = enc & ~SQLITE_UTF16_ALIGNED;
  if( enc2==SQLITE_UTF16 ){
    enc2 = SQLITE_UTF16NATIVE;
  }

  if( (enc2&~3)!=0 ){
    sqlite3Error(db, SQLITE_ERROR, "unknown encoding");
    return SQLITE_ERROR;
  }

  /* Check if this call is removing or replacing an existing collation 
  ** sequence. If so, and there are active VMs, return busy. If there
  ** are no active VMs, invalidate any pre-compiled statements.
  */
  pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, strlen(zName), 0);
  if( pColl && pColl->xCmp ){
    if( db->activeVdbeCnt ){
      sqlite3Error(db, SQLITE_BUSY, 
        "Unable to delete/modify collation sequence due to active statements");
      return SQLITE_BUSY;
    }
    sqlite3ExpirePreparedStatements(db);
  }

  pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, strlen(zName), 1);
  if( pColl ){
    pColl->xCmp = xCompare;
    pColl->pUser = pCtx;
    pColl->enc = enc2 | (enc & SQLITE_UTF16_ALIGNED);
  }
  sqlite3Error(db, SQLITE_OK, 0);
  return SQLITE_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int nocaseCollatingFunc ( void NotUsed,
int  nKey1,
const void pKey1,
int  nKey2,
const void pKey2 
) [static]

Definition at line 63 of file main.c.

 {
  int r = sqlite3StrNICmp(
      (const char *)pKey1, (const char *)pKey2, (nKey1<nKey2)?nKey1:nKey2);
  if( 0==r ){
    r = nKey1-nKey2;
  }
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int openDatabase ( const char *  zFilename,
sqlite3 **  ppDb 
) [static]

Definition at line 799 of file main.c.

 {
  sqlite3 *db;
  int rc;
  CollSeq *pColl;

  assert( !sqlite3MallocFailed() );

  /* Allocate the sqlite data structure */
  db = sqliteMalloc( sizeof(sqlite3) );
  if( db==0 ) goto opendb_out;
  db->priorNewRowid = 0;
  db->magic = SQLITE_MAGIC_BUSY;
  db->nDb = 2;
  db->aDb = db->aDbStatic;
  db->autoCommit = 1;
  db->flags |= SQLITE_ShortColNames;
  sqlite3HashInit(&db->aFunc, SQLITE_HASH_STRING, 0);
  sqlite3HashInit(&db->aCollSeq, SQLITE_HASH_STRING, 0);

  /* Add the default collation sequence BINARY. BINARY works for both UTF-8
  ** and UTF-16, so add a version for each to avoid any unnecessary
  ** conversions. The only error that can occur here is a malloc() failure.
  */
  if( createCollation(db, "BINARY", SQLITE_UTF8, 0, binCollFunc) ||
      createCollation(db, "BINARY", SQLITE_UTF16BE, 0, binCollFunc) ||
      createCollation(db, "BINARY", SQLITE_UTF16LE, 0, binCollFunc) ||
      (db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 6, 0))==0 
  ){
    assert( sqlite3MallocFailed() );
    db->magic = SQLITE_MAGIC_CLOSED;
    goto opendb_out;
  }

  /* Also add a UTF-8 case-insensitive collation sequence. */
  createCollation(db, "NOCASE", SQLITE_UTF8, 0, nocaseCollatingFunc);

  /* Set flags on the built-in collating sequences */
  db->pDfltColl->type = SQLITE_COLL_BINARY;
  pColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "NOCASE", 6, 0);
  if( pColl ){
    pColl->type = SQLITE_COLL_NOCASE;
  }

  /* Open the backend database driver */
  rc = sqlite3BtreeFactory(db, zFilename, 0, MAX_PAGES, &db->aDb[0].pBt);
  if( rc!=SQLITE_OK ){
    sqlite3Error(db, rc, 0);
    db->magic = SQLITE_MAGIC_CLOSED;
    goto opendb_out;
  }
  db->aDb[0].pSchema = sqlite3SchemaGet(db->aDb[0].pBt);
  db->aDb[1].pSchema = sqlite3SchemaGet(0);
  if( db->aDb[0].pSchema ){
    ENC(db) = SQLITE_UTF8;
  }


  /* The default safety_level for the main database is 'full'; for the temp
  ** database it is 'NONE'. This matches the pager layer defaults.  
  */
  db->aDb[0].zName = "main";
  db->aDb[0].safety_level = 3;
#ifndef SQLITE_OMIT_TEMPDB
  db->aDb[1].zName = "temp";
  db->aDb[1].safety_level = 1;
#endif

  /* Register all built-in functions, but do not attempt to read the
  ** database schema yet. This is delayed until the first time the database
  ** is accessed.
  */
  if( !sqlite3MallocFailed() ){
    sqlite3RegisterBuiltinFunctions(db);
    sqlite3Error(db, SQLITE_OK, 0);
  }
  db->magic = SQLITE_MAGIC_OPEN;

opendb_out:
  if( SQLITE_NOMEM==(rc = sqlite3_errcode(db)) ){
    sqlite3_close(db);
    db = 0;
  }
  *ppDb = db;
  return sqlite3ApiExit(0, rc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3_busy_handler ( sqlite3 db,
int(*)(void *, int xBusy,
void pArg 
)

Definition at line 312 of file main.c.

 {
  if( sqlite3SafetyCheck(db) ){
    return SQLITE_MISUSE;
  }
  db->busyHandler.xFunc = xBusy;
  db->busyHandler.pArg = pArg;
  db->busyHandler.nBusy = 0;
  return SQLITE_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3_busy_timeout ( sqlite3 db,
int  ms 
)

Definition at line 357 of file main.c.

                                             {
  if( ms>0 ){
    db->busyTimeout = ms;
    sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void*)db);
  }else{
    sqlite3_busy_handler(db, 0, 0);
  }
  return SQLITE_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 86 of file main.c.

                                {
  return db->nChange;
}

Here is the caller graph for this function:

Definition at line 100 of file main.c.

                              {
  HashElem *i;
  int j;

  if( !db ){
    return SQLITE_OK;
  }
  if( sqlite3SafetyCheck(db) ){
    return SQLITE_MISUSE;
  }

#ifdef SQLITE_SSE
  {
    extern void sqlite3SseCleanup(sqlite3*);
    sqlite3SseCleanup(db);
  }
#endif 

  /* If there are any outstanding VMs, return SQLITE_BUSY. */
  if( db->pVdbe ){
    sqlite3Error(db, SQLITE_BUSY, 
        "Unable to close due to unfinalised statements");
    return SQLITE_BUSY;
  }
  assert( !sqlite3SafetyCheck(db) );

  /* FIX ME: db->magic may be set to SQLITE_MAGIC_CLOSED if the database
  ** cannot be opened for some reason. So this routine needs to run in
  ** that case. But maybe there should be an extra magic value for the
  ** "failed to open" state.
  */
  if( db->magic!=SQLITE_MAGIC_CLOSED && sqlite3SafetyOn(db) ){
    /* printf("DID NOT CLOSE\n"); fflush(stdout); */
    return SQLITE_ERROR;
  }

  for(j=0; j<db->nDb; j++){
    struct Db *pDb = &db->aDb[j];
    if( pDb->pBt ){
      sqlite3BtreeClose(pDb->pBt);
      pDb->pBt = 0;
      if( j!=1 ){
        pDb->pSchema = 0;
      }
    }
  }
  sqlite3ResetInternalSchema(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);
    }
  }

  for(i=sqliteHashFirst(&db->aCollSeq); i; i=sqliteHashNext(i)){
    CollSeq *pColl = (CollSeq *)sqliteHashData(i);
    sqliteFree(pColl);
  }
  sqlite3HashClear(&db->aCollSeq);

  sqlite3HashClear(&db->aFunc);
  sqlite3Error(db, SQLITE_OK, 0); /* Deallocates any cached error strings. */
  if( db->pErr ){
    sqlite3ValueFree(db->pErr);
  }

  db->magic = SQLITE_MAGIC_ERROR;

  /* The temp-database schema is allocated differently from the other schema
  ** objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()).
  ** So it needs to be freed here. Todo: Why not roll the temp schema into
  ** the same sqliteMalloc() as the one that allocates the database 
  ** structure?
  */
  sqliteFree(db->aDb[1].pSchema);
  sqliteFree(db);
  sqlite3ReleaseThreadData();
  return SQLITE_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3_collation_needed ( sqlite3 db,
void pCollNeededArg,
void(*)(void *, sqlite3 *, int eTextRep, const char *)  xCollNeeded 
)

Definition at line 1013 of file main.c.

 {
  if( sqlite3SafetyCheck(db) ){
    return SQLITE_MISUSE;
  }
  db->xCollNeeded = xCollNeeded;
  db->xCollNeeded16 = 0;
  db->pCollNeededArg = pCollNeededArg;
  return SQLITE_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3_collation_needed16 ( sqlite3 db,
void pCollNeededArg,
void(*)(void *, sqlite3 *, int eTextRep, const void *)  xCollNeeded16 
)

Definition at line 1032 of file main.c.

 {
  if( sqlite3SafetyCheck(db) ){
    return SQLITE_MISUSE;
  }
  db->xCollNeeded = 0;
  db->xCollNeeded16 = xCollNeeded16;
  db->pCollNeededArg = pCollNeededArg;
  return SQLITE_OK;
}

Here is the call graph for this function:

void* sqlite3_commit_hook ( sqlite3 db,
int(*)(void *)  xCallback,
void pArg 
)

Definition at line 553 of file main.c.

 {
  void *pOld = db->pCommitArg;
  db->xCommitCallback = xCallback;
  db->pCommitArg = pArg;
  return pOld;
}

Here is the caller graph for this function:

int sqlite3_create_collation ( sqlite3 db,
const char *  zName,
int  enc,
void pCtx,
int(*)(void *, int, const void *, int, const void *)  xCompare 
)

Definition at line 973 of file main.c.

 {
  int rc;
  assert( !sqlite3MallocFailed() );
  rc = createCollation(db, zName, enc, pCtx, xCompare);
  return sqlite3ApiExit(db, rc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3_create_collation16 ( sqlite3 db,
const char *  zName,
int  enc,
void pCtx,
int(*)(void *, int, const void *, int, const void *)  xCompare 
)

Definition at line 990 of file main.c.

 {
  int rc = SQLITE_OK;
  char *zName8; 
  assert( !sqlite3MallocFailed() );
  zName8 = sqlite3utf16to8(zName, -1);
  if( zName8 ){
    rc = createCollation(db, zName8, enc, pCtx, xCompare);
    sqliteFree(zName8);
  }
  return sqlite3ApiExit(db, rc);
}

Here is the call graph for this function:

int sqlite3_create_function ( sqlite3 db,
const char *  zFunctionName,
int  nArg,
int  enc,
void p,
void(*)(sqlite3_context *, int, sqlite3_value **)  xFunc,
void(*)(sqlite3_context *, int, sqlite3_value **)  xStep,
void(*)(sqlite3_context *)  xFinal 
)

Definition at line 472 of file main.c.

 {
  int rc;
  assert( !sqlite3MallocFailed() );
  rc = sqlite3CreateFunc(db, zFunctionName, nArg, enc, p, xFunc, xStep, xFinal);

  return sqlite3ApiExit(db, rc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3_create_function16 ( sqlite3 db,
const void zFunctionName,
int  nArg,
int  eTextRep,
void p,
void(*)(sqlite3_context *, int, sqlite3_value **)  xFunc,
void(*)(sqlite3_context *, int, sqlite3_value **)  xStep,
void(*)(sqlite3_context *)  xFinal 
)

Definition at line 490 of file main.c.

 {
  int rc;
  char *zFunc8;
  assert( !sqlite3MallocFailed() );

  zFunc8 = sqlite3utf16to8(zFunctionName, -1);
  rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xFunc, xStep, xFinal);
  sqliteFree(zFunc8);

  return sqlite3ApiExit(db, rc);
}

Here is the call graph for this function:

Definition at line 1089 of file main.c.

                                           {
  ThreadData *pTd = sqlite3ThreadData();
  if( pTd ){
    /* It is only legal to call sqlite3_enable_shared_cache() when there
    ** are no currently open b-trees that were opened by the calling thread.
    ** This condition is only easy to detect if the shared-cache were 
    ** previously enabled (and is being disabled). 
    */
    if( pTd->pBtree && !enable ){
      assert( pTd->useSharedData );
      return SQLITE_MISUSE;
    }

    pTd->useSharedData = enable;
    sqlite3ReleaseThreadData();
  }
  return sqlite3ApiExit(0, SQLITE_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 727 of file main.c.

                                {
  if( !db || sqlite3MallocFailed() ){
    return SQLITE_NOMEM;
  }
  if( sqlite3SafetyCheck(db) ){
    return SQLITE_MISUSE;
  }
  return db->errCode;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* sqlite3_errmsg ( sqlite3 db)

Definition at line 665 of file main.c.

                                       {
  const char *z;
  if( !db || sqlite3MallocFailed() ){
    return sqlite3ErrStr(SQLITE_NOMEM);
  }
  if( sqlite3SafetyCheck(db) || db->errCode==SQLITE_MISUSE ){
    return sqlite3ErrStr(SQLITE_MISUSE);
  }
  z = (char*)sqlite3_value_text(db->pErr);
  if( z==0 ){
    z = sqlite3ErrStr(db->errCode);
  }
  return z;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 685 of file main.c.

                                         {
  /* Because all the characters in the string are in the unicode
  ** range 0x00-0xFF, if we pad the big-endian string with a 
  ** zero byte, we can obtain the little-endian string with
  ** &big_endian[1].
  */
  static const char outOfMemBe[] = {
    0, 'o', 0, 'u', 0, 't', 0, ' ', 
    0, 'o', 0, 'f', 0, ' ', 
    0, 'm', 0, 'e', 0, 'm', 0, 'o', 0, 'r', 0, 'y', 0, 0, 0
  };
  static const char misuseBe [] = {
    0, 'l', 0, 'i', 0, 'b', 0, 'r', 0, 'a', 0, 'r', 0, 'y', 0, ' ', 
    0, 'r', 0, 'o', 0, 'u', 0, 't', 0, 'i', 0, 'n', 0, 'e', 0, ' ', 
    0, 'c', 0, 'a', 0, 'l', 0, 'l', 0, 'e', 0, 'd', 0, ' ', 
    0, 'o', 0, 'u', 0, 't', 0, ' ', 
    0, 'o', 0, 'f', 0, ' ', 
    0, 's', 0, 'e', 0, 'q', 0, 'u', 0, 'e', 0, 'n', 0, 'c', 0, 'e', 0, 0, 0
  };

  const void *z;
  if( sqlite3MallocFailed() ){
    return (void *)(&outOfMemBe[SQLITE_UTF16NATIVE==SQLITE_UTF16LE?1:0]);
  }
  if( sqlite3SafetyCheck(db) || db->errCode==SQLITE_MISUSE ){
    return (void *)(&misuseBe[SQLITE_UTF16NATIVE==SQLITE_UTF16LE?1:0]);
  }
  z = sqlite3_value_text16(db->pErr);
  if( z==0 ){
    sqlite3ValueSetStr(db->pErr, -1, sqlite3ErrStr(db->errCode),
         SQLITE_UTF8, SQLITE_STATIC);
    z = sqlite3_value_text16(db->pErr);
  }
  sqlite3ApiExit(0, 0);
  return z;
}

Here is the call graph for this function:

Definition at line 941 of file main.c.

                                         {
  int rc;
  if( pStmt==0 ){
    rc = SQLITE_OK;
  }else{
    rc = sqlite3VdbeFinalize((Vdbe*)pStmt);
  }
  return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite3_free ( char *  p)

Definition at line 384 of file main.c.

{ free(p); }

Here is the caller graph for this function:

Definition at line 1065 of file main.c.

                                       {
  return db->autoCommit;
}

Here is the caller graph for this function:

Definition at line 1052 of file main.c.

                            {
  return SQLITE_OK;
}

Definition at line 370 of file main.c.

                                   {
  if( !sqlite3SafetyCheck(db) ){
    db->flags |= SQLITE_Interrupt;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 79 of file main.c.

                                                   {
  return db->lastRowid;
}

Here is the caller graph for this function:

Definition at line 33 of file main.c.

{ return sqlite3_version; }

Here is the caller graph for this function:

Definition at line 34 of file main.c.

int sqlite3_open ( const char *  zFilename,
sqlite3 **  ppDb 
)

Definition at line 891 of file main.c.

 {
  return openDatabase(zFilename, ppDb);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3_open16 ( const void zFilename,
sqlite3 **  ppDb 
)

Definition at line 902 of file main.c.

 {
  char const *zFilename8;   /* zFilename encoded in UTF-8 instead of UTF-16 */
  int rc = SQLITE_OK;
  sqlite3_value *pVal;

  assert( zFilename );
  assert( ppDb );
  *ppDb = 0;
  pVal = sqlite3ValueNew();
  sqlite3ValueSetStr(pVal, -1, zFilename, SQLITE_UTF16NATIVE, SQLITE_STATIC);
  zFilename8 = sqlite3ValueText(pVal, SQLITE_UTF8);
  if( zFilename8 ){
    rc = openDatabase(zFilename8, ppDb);
    if( rc==SQLITE_OK && *ppDb ){
      rc = sqlite3_exec(*ppDb, "PRAGMA encoding = 'UTF-16'", 0, 0, 0);
      if( rc!=SQLITE_OK ){
        sqlite3_close(*ppDb);
        *ppDb = 0;
      }
    }
  }
  sqlite3ValueFree(pVal);

  return sqlite3ApiExit(0, rc);
}

Here is the call graph for this function:

void* sqlite3_profile ( sqlite3 db,
void(*)(void *, const char *, sqlite_uint64 xProfile,
void pArg 
)

Definition at line 535 of file main.c.

 {
  void *pOld = db->pProfileArg;
  db->xProfile = xProfile;
  db->pProfileArg = pArg;
  return pOld;
}

Here is the caller graph for this function:

void sqlite3_progress_handler ( sqlite3 db,
int  nOps,
int(*)(void *)  xProgress,
void pArg 
)

Definition at line 332 of file main.c.

 {
  if( !sqlite3SafetyCheck(db) ){
    if( nOps>0 ){
      db->xProgress = xProgress;
      db->nProgressOps = nOps;
      db->pProgressArg = pArg;
    }else{
      db->xProgress = 0;
      db->nProgressOps = 0;
      db->pProgressArg = 0;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 959 of file main.c.

                                      {
  int rc;
  if( pStmt==0 ){
    rc = SQLITE_OK;
  }else{
    rc = sqlite3VdbeReset((Vdbe*)pStmt);
    sqlite3VdbeMakeReady((Vdbe*)pStmt, -1, 0, 0, 0);
  }
  return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* sqlite3_rollback_hook ( sqlite3 db,
void(*)(void *)  xCallback,
void pArg 
)

Definition at line 583 of file main.c.

 {
  void *pRet = db->pRollbackArg;
  db->xRollbackCallback = xCallback;
  db->pRollbackArg = pArg;
  return pRet;
}

Here is the caller graph for this function:

Definition at line 1113 of file main.c.

                                 {
  ThreadData *pTd = sqlite3OsThreadSpecificData(0);
  if( pTd ){
    memset(pTd, 0, sizeof(*pTd));
    sqlite3OsThreadSpecificData(-1);
  }
}

Here is the call graph for this function:

Definition at line 93 of file main.c.

                                      {
  return db->nTotalChange;
}

Here is the caller graph for this function:

void* sqlite3_trace ( sqlite3 db,
void(*)(void *, const char *)  xTrace,
void pArg 
)

Definition at line 521 of file main.c.

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

Here is the caller graph for this function:

void* sqlite3_update_hook ( sqlite3 db,
void(*)(void *, int, char const *, char const *, sqlite_int64 xCallback,
void pArg 
)

Definition at line 568 of file main.c.

 {
  void *pRet = db->pUpdateArg;
  db->xUpdateCallback = xCallback;
  db->pUpdateArg = pArg;
  return pRet;
}

Here is the caller graph for this function:

int sqlite3BtreeFactory ( const sqlite3 db,
const char *  zFilename,
int  omitJournal,
int  nCache,
Btree **  ppBtree 
)

Definition at line 619 of file main.c.

 {
  int btree_flags = 0;
  int rc;
  
  assert( ppBtree != 0);
  if( omitJournal ){
    btree_flags |= BTREE_OMIT_JOURNAL;
  }
  if( db->flags & SQLITE_NoReadlock ){
    btree_flags |= BTREE_NO_READLOCK;
  }
  if( zFilename==0 ){
#if TEMP_STORE==0
    /* Do nothing */
#endif
#ifndef SQLITE_OMIT_MEMORYDB
#if TEMP_STORE==1
    if( db->temp_store==2 ) zFilename = ":memory:";
#endif
#if TEMP_STORE==2
    if( db->temp_store!=1 ) zFilename = ":memory:";
#endif
#if TEMP_STORE==3
    zFilename = ":memory:";
#endif
#endif /* SQLITE_OMIT_MEMORYDB */
  }

  rc = sqlite3BtreeOpen(zFilename, (sqlite3 *)db, ppBtree, btree_flags);
  if( rc==SQLITE_OK ){
    sqlite3BtreeSetBusyHandler(*ppBtree, (void*)&db->busyHandler);
    sqlite3BtreeSetCacheSize(*ppBtree, nCache);
  }
  return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3CreateFunc ( sqlite3 db,
const char *  zFunctionName,
int  nArg,
int  enc,
void pUserData,
void(*)(sqlite3_context *, int, sqlite3_value **)  xFunc,
void(*)(sqlite3_context *, int, sqlite3_value **)  xStep,
void(*)(sqlite3_context *)  xFinal 
)

Definition at line 392 of file main.c.

 {
  FuncDef *p;
  int nName;

  if( sqlite3SafetyCheck(db) ){
    return SQLITE_MISUSE;
  }
  if( zFunctionName==0 ||
      (xFunc && (xFinal || xStep)) || 
      (!xFunc && (xFinal && !xStep)) ||
      (!xFunc && (!xFinal && xStep)) ||
      (nArg<-1 || nArg>127) ||
      (255<(nName = strlen(zFunctionName))) ){
    return SQLITE_ERROR;
  }
  
#ifndef SQLITE_OMIT_UTF16
  /* If SQLITE_UTF16 is specified as the encoding type, transform this
  ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the
  ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.
  **
  ** If SQLITE_ANY is specified, add three versions of the function
  ** to the hash table.
  */
  if( enc==SQLITE_UTF16 ){
    enc = SQLITE_UTF16NATIVE;
  }else if( enc==SQLITE_ANY ){
    int rc;
    rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8,
         pUserData, xFunc, xStep, xFinal);
    if( rc!=SQLITE_OK ) return rc;
    rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE,
        pUserData, xFunc, xStep, xFinal);
    if( rc!=SQLITE_OK ) return rc;
    enc = SQLITE_UTF16BE;
  }
#else
  enc = SQLITE_UTF8;
#endif
  
  /* Check if an existing function is being overridden or deleted. If so,
  ** and there are active VMs, then return SQLITE_BUSY. If a function
  ** is being overridden/deleted but there are no active VMs, allow the
  ** operation to continue but invalidate all precompiled statements.
  */
  p = sqlite3FindFunction(db, zFunctionName, nName, nArg, enc, 0);
  if( p && p->iPrefEnc==enc && p->nArg==nArg ){
    if( db->activeVdbeCnt ){
      sqlite3Error(db, SQLITE_BUSY, 
        "Unable to delete/modify user-function due to active statements");
      assert( !sqlite3MallocFailed() );
      return SQLITE_BUSY;
    }else{
      sqlite3ExpirePreparedStatements(db);
    }
  }

  p = sqlite3FindFunction(db, zFunctionName, nName, nArg, enc, 1);
  if( p ){
    p->flags = 0;
    p->xFunc = xFunc;
    p->xStep = xStep;
    p->xFinalize = xFinal;
    p->pUserData = pUserData;
  }
  return SQLITE_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* sqlite3ErrStr ( int  rc)

Definition at line 212 of file main.c.

                                 {
  const char *z;
  switch( rc ){
    case SQLITE_ROW:
    case SQLITE_DONE:
    case SQLITE_OK:         z = "not an error";                          break;
    case SQLITE_ERROR:      z = "SQL logic error or missing database";   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_FULL:       z = "database or disk 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_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 or column 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:

Definition at line 296 of file main.c.

                                            {
  int rc;
  if( p==0 || p->xFunc==0 || p->nBusy<0 ) return 0;
  rc = p->xFunc(p->pArg, p->nBusy);
  if( rc==0 ){
    p->nBusy = -1;
  }else{
    p->nBusy++;
  }
  return rc; 
}

Here is the caller graph for this function:

Definition at line 186 of file main.c.

                                    {
  int i;
  int inTrans = 0;
  for(i=0; i<db->nDb; i++){
    if( db->aDb[i].pBt ){
      if( sqlite3BtreeIsInTrans(db->aDb[i].pBt) ){
        inTrans = 1;
      }
      sqlite3BtreeRollback(db->aDb[i].pBt);
      db->aDb[i].inTrans = 0;
    }
  }
  if( db->flags&SQLITE_InternChanges ){
    sqlite3ResetInternalSchema(db, 0);
  }

  /* If one has been configured, invoke the rollback-hook callback */
  if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){
    db->xRollbackCallback(db->pRollbackArg);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int sqliteDefaultBusyCallback ( void ptr,
int  count 
) [static]

Definition at line 252 of file main.c.

 {
#if OS_WIN || (defined(HAVE_USLEEP) && HAVE_USLEEP)
  static const u8 delays[] =
     { 1, 2, 5, 10, 15, 20, 25, 25,  25,  50,  50, 100 };
  static const u8 totals[] =
     { 0, 1, 3,  8, 18, 33, 53, 78, 103, 128, 178, 228 };
# define NDELAY (sizeof(delays)/sizeof(delays[0]))
  int timeout = ((sqlite3 *)ptr)->busyTimeout;
  int delay, prior;

  assert( count>=0 );
  if( count < NDELAY ){
    delay = delays[count];
    prior = totals[count];
  }else{
    delay = delays[NDELAY-1];
    prior = totals[NDELAY-1] + delay*(count-(NDELAY-1));
  }
  if( prior + delay > timeout ){
    delay = timeout - prior;
    if( delay<=0 ) return 0;
  }
  sqlite3OsSleep(delay);
  return 1;
#else
  int timeout = ((sqlite3 *)ptr)->busyTimeout;
  if( (count+1)*1000 > timeout ){
    return 0;
  }
  sqlite3OsSleep(1000);
  return 1;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 32 of file main.c.

Definition at line 27 of file main.c.