Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions | Variables
sqliteInt.h File Reference
#include "sqlite3.h"
#include "hash.h"
#include "parse.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stddef.h>
#include "vdbe.h"
#include "btree.h"
#include "pager.h"

Go to the source code of this file.

Classes

struct  BusyHandler
struct  ThreadData
struct  Db
struct  Schema
struct  sqlite3
struct  sqlite3::sqlite3InitInfo
struct  FuncDef
struct  Column
struct  CollSeq
struct  Table
struct  FKey
struct  FKey::sColMap
struct  KeyInfo
struct  Index
struct  Token
 A Token class for the ExprLexer. More...
struct  AggInfo
struct  AggInfo::AggInfo_col
struct  AggInfo::AggInfo_func
class  Expr
 A Base Class for all XSL Expressions. More...
struct  ExprList
struct  ExprList::ExprList_item
struct  IdList
struct  IdList::IdList_item
struct  SrcList
struct  SrcList::SrcList_item
struct  WhereLevel
struct  WhereInfo
struct  NameContext
struct  Select
struct  Parse
struct  AuthContext
struct  Trigger
struct  TriggerStep
struct  TriggerStack
struct  DbFixer
struct  InitData

Defines

#define NDEBUG   1
#define _LARGE_FILE   1
#define _FILE_OFFSET_BITS   64
#define _LARGEFILE_SOURCE   1
#define SQLITE_BIG_DBL   (1e99)
#define MAX_PAGES   2000
#define TEMP_PAGES   500
#define OMIT_TEMPDB   0
#define NULL_DISTINCT_FOR_UNIQUE   1
#define MAX_ATTACHED   10
#define SQLITE_MAX_VARIABLE_NUMBER   999
#define SQLITE_MAX_FILE_FORMAT   4
#define SQLITE_DEFAULT_FILE_FORMAT   4
#define TEMP_STORE   1
#define offsetof(STRUCTURE, FIELD)   ((int)((char*)&((STRUCTURE*)0)->FIELD))
#define SQLITE_ASCII   1
#define UINT32_TYPE   unsigned int
#define UINT16_TYPE   unsigned short int
#define INT16_TYPE   short int
#define UINT8_TYPE   unsigned char
#define INT8_TYPE   signed char
#define LONGDOUBLE_TYPE   long double
#define SQLITE_BIGENDIAN   (*(char *)(&sqlite3one)==0)
#define SQLITE_LITTLEENDIAN   (*(char *)(&sqlite3one)==1)
#define ENTER_MALLOC   0
#define sqliteMalloc(x)   sqlite3Malloc(x,1)
#define sqliteMallocRaw(x)   sqlite3MallocRaw(x,1)
#define sqliteRealloc(x, y)   sqlite3Realloc(x,y)
#define sqliteStrDup(x)   sqlite3StrDup(x)
#define sqliteStrNDup(x, y)   sqlite3StrNDup(x,y)
#define sqliteReallocOrFree(x, y)   sqlite3ReallocOrFree(x,y)
#define sqliteFree(x)   sqlite3FreeX(x)
#define sqliteAllocSize(x)   sqlite3AllocSize(x)
#define MASTER_NAME   "sqlite_master"
#define TEMP_MASTER_NAME   "sqlite_temp_master"
#define MASTER_ROOT   1
#define SCHEMA_TABLE(x)   ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME)
#define ArraySize(X)   (sizeof(X)/sizeof(X[0]))
#define DbHasProperty(D, I, P)   (((D)->aDb[I].pSchema->flags&(P))==(P))
#define DbHasAnyProperty(D, I, P)   (((D)->aDb[I].pSchema->flags&(P))!=0)
#define DbSetProperty(D, I, P)   (D)->aDb[I].pSchema->flags|=(P)
#define DbClearProperty(D, I, P)   (D)->aDb[I].pSchema->flags&=~(P)
#define DB_SchemaLoaded   0x0001 /* The schema has been loaded */
#define DB_UnresetViews   0x0002 /* Some views have defined column names */
#define DB_Empty   0x0004 /* The file is empty (length 0 bytes) */
#define SQLITE_UTF16NATIVE   (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)
#define ENC(db)   ((db)->aDb[0].pSchema->enc)
#define SQLITE_VdbeTrace   0x00000001 /* True to trace VDBE execution */
#define SQLITE_Interrupt   0x00000004 /* Cancel current operation */
#define SQLITE_InTrans   0x00000008 /* True if in a transaction */
#define SQLITE_InternChanges   0x00000010 /* Uncommitted Hash table changes */
#define SQLITE_FullColNames   0x00000020 /* Show full column names on SELECT */
#define SQLITE_ShortColNames   0x00000040 /* Show short columns names */
#define SQLITE_CountRows   0x00000080 /* Count rows changed by INSERT, */
#define SQLITE_NullCallback   0x00000100 /* Invoke the callback once if the */
#define SQLITE_SqlTrace   0x00000200 /* Debug print SQL as it executes */
#define SQLITE_VdbeListing   0x00000400 /* Debug listings of VDBE programs */
#define SQLITE_WriteSchema   0x00000800 /* OK to update SQLITE_MASTER */
#define SQLITE_NoReadlock
#define SQLITE_IgnoreChecks   0x00002000 /* Do not enforce check constraints */
#define SQLITE_ReadUncommitted   0x00004000 /* For shared-cache mode */
#define SQLITE_LegacyFileFmt   0x00008000 /* Create new databases in format 1 */
#define SQLITE_FullFSync   0x00010000 /* Use full fsync on the backend */
#define SQLITE_MAGIC_OPEN   0xa029a697 /* Database is open */
#define SQLITE_MAGIC_CLOSED   0x9f3c2d33 /* Database is closed */
#define SQLITE_MAGIC_BUSY   0xf03b7906 /* Database currently in use */
#define SQLITE_MAGIC_ERROR   0xb5357930 /* An SQLITE_MISUSE error occurred */
#define SQLITE_FUNC_LIKE   0x01 /* Candidate for the LIKE optimization */
#define SQLITE_FUNC_CASE   0x02 /* Case-sensitive LIKE-type function */
#define SQLITE_COLL_BINARY   1 /* The default memcmp() collating sequence */
#define SQLITE_COLL_NOCASE   2 /* The built-in NOCASE collating sequence */
#define SQLITE_COLL_REVERSE   3 /* The built-in REVERSE collating sequence */
#define SQLITE_COLL_USER   0 /* Any other user-defined collating sequence */
#define SQLITE_SO_ASC   0 /* Sort in ascending order */
#define SQLITE_SO_DESC   1 /* Sort in ascending order */
#define SQLITE_AFF_TEXT   'a'
#define SQLITE_AFF_NONE   'b'
#define SQLITE_AFF_NUMERIC   'c'
#define SQLITE_AFF_INTEGER   'd'
#define SQLITE_AFF_REAL   'e'
#define sqlite3IsNumericAffinity(X)   ((X)>=SQLITE_AFF_NUMERIC)
#define OE_None   0 /* There is no constraint to check */
#define OE_Rollback   1 /* Fail the operation and rollback the transaction */
#define OE_Abort   2 /* Back out changes but do no rollback transaction */
#define OE_Fail   3 /* Stop the operation but leave all prior changes */
#define OE_Ignore   4 /* Ignore the error. Do not do the INSERT or UPDATE */
#define OE_Replace   5 /* Delete existing record, then do INSERT or UPDATE */
#define OE_Restrict   6 /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */
#define OE_SetNull   7 /* Set the foreign key value to NULL */
#define OE_SetDflt   8 /* Set the foreign key value to its default */
#define OE_Cascade   9 /* Cascade the changes */
#define OE_Default   99 /* Do whatever the default action is */
#define EP_FromJoin   0x01 /* Originated in ON or USING clause of a join */
#define EP_Agg   0x02 /* Contains one or more aggregate functions */
#define EP_Resolved   0x04 /* IDs have been resolved to COLUMNs */
#define EP_Error   0x08 /* Expression contains one or more errors */
#define EP_Distinct   0x10 /* Aggregate function with DISTINCT keyword */
#define EP_VarSelect   0x20 /* pSelect is correlated, not constant */
#define EP_Dequoted   0x40 /* True if the string has been dequoted */
#define ExprHasProperty(E, P)   (((E)->flags&(P))==(P))
#define ExprHasAnyProperty(E, P)   (((E)->flags&(P))!=0)
#define ExprSetProperty(E, P)   (E)->flags|=(P)
#define ExprClearProperty(E, P)   (E)->flags&=~(P)
#define JT_INNER   0x0001 /* Any kind of inner or cross join */
#define JT_CROSS   0x0002 /* Explicit use of the CROSS keyword */
#define JT_NATURAL   0x0004 /* True for a "natural" join */
#define JT_LEFT   0x0008 /* Left outer join */
#define JT_RIGHT   0x0010 /* Right outer join */
#define JT_OUTER   0x0020 /* The "OUTER" keyword is present */
#define JT_ERROR   0x0040 /* unknown or unsupported join type */
#define SRT_Union   1 /* Store result as keys in an index */
#define SRT_Except   2 /* Remove result from a UNION index */
#define SRT_Discard   3 /* Do not save the results anywhere */
#define IgnorableOrderby(X)   (X<=SRT_Discard)
#define SRT_Callback   4 /* Invoke a callback with each row of result */
#define SRT_Mem   5 /* Store result in a memory cell */
#define SRT_Set   6 /* Store non-null results as keys in an index */
#define SRT_Table   7 /* Store result as data with an automatic rowid */
#define SRT_VirtualTab   8 /* Create virtual table and store like SRT_Table */
#define SRT_Subroutine   9 /* Call a subroutine to handle results */
#define SRT_Exists   10 /* Store 1 if the result is not empty */
#define OPFLAG_NCHANGE   1 /* Set to update db->nChange */
#define OPFLAG_LASTROWID   2 /* Set to update db->lastRowid */
#define OPFLAG_ISUPDATE   4 /* This OP_Insert is an sql UPDATE */
#define TRIGGER_BEFORE   1
#define TRIGGER_AFTER   2
#define SQLITE_CORRUPT_BKPT   SQLITE_CORRUPT
#define sqlite3CheckMemory(a, b)
#define sqlite3TestMallocFail()   0
#define sqlite3MallocDisallow()
#define sqlite3MallocAllow()
#define sqlite3ThreadSafeMalloc   sqlite3MallocX
#define sqlite3ThreadSafeFree   sqlite3FreeX

Typedefs

typedef sqlite_int64 i64
typedef sqlite_uint64 u64
typedef UINT32_TYPE u32
typedef UINT16_TYPE u16
typedef INT16_TYPE i16
typedef UINT8_TYPE u8
typedef UINT8_TYPE i8
typedef struct BusyHandler
typedef struct AggInfo
typedef struct AuthContext
typedef struct CollSeq
typedef struct Column
typedef struct Db
typedef struct Schema
typedef struct Expr
typedef struct ExprList
typedef struct FKey
typedef struct FuncDef
typedef struct IdList
typedef struct Index
typedef struct KeyClass
typedef struct KeyInfo
typedef struct NameContext
typedef struct Parse
typedef struct Select
typedef struct SrcList
typedef struct ThreadData
typedef struct Table
typedef struct TableLock
typedef struct Token
typedef struct TriggerStack
typedef struct TriggerStep
typedef struct Trigger
typedef struct WhereInfo
typedef struct WhereLevel
typedef unsigned int Bitmask
typedef struct DbFixer

Functions

int sqlite3StrICmp (const char *, const char *)
int sqlite3StrNICmp (const char *, const char *, int)
int sqlite3HashNoCase (const char *, int)
int sqlite3IsNumber (const char *, int *, u8)
int sqlite3Compare (const char *, const char *)
int sqlite3SortCompare (const char *, const char *)
void sqlite3RealToSortable (double r, char *)
voidsqlite3Malloc (int, int)
voidsqlite3MallocRaw (int, int)
void sqlite3Free (void *)
voidsqlite3Realloc (void *, int)
char * sqlite3StrDup (const char *)
char * sqlite3StrNDup (const char *, int)
void sqlite3ReallocOrFree (void **, int)
void sqlite3FreeX (void *)
voidsqlite3MallocX (int)
int sqlite3AllocSize (void *)
char * sqlite3MPrintf (const char *,...)
char * sqlite3VMPrintf (const char *, va_list)
void sqlite3DebugPrintf (const char *,...)
voidsqlite3TextToPtr (const char *)
void sqlite3SetString (char **,...)
void sqlite3ErrorMsg (Parse *, const char *,...)
void sqlite3ErrorClear (Parse *)
void sqlite3Dequote (char *)
void sqlite3DequoteExpr (Expr *)
int sqlite3KeywordCode (const unsigned char *, int)
int sqlite3RunParser (Parse *, const char *, char **)
void sqlite3FinishCoding (Parse *)
Exprsqlite3Expr (int, Expr *, Expr *, const Token *)
Exprsqlite3RegisterExpr (Parse *, Token *)
Exprsqlite3ExprAnd (Expr *, Expr *)
void sqlite3ExprSpan (Expr *, Token *, Token *)
Exprsqlite3ExprFunction (ExprList *, Token *)
void sqlite3ExprAssignVarNumber (Parse *, Expr *)
void sqlite3ExprDelete (Expr *)
ExprListsqlite3ExprListAppend (ExprList *, Expr *, Token *)
void sqlite3ExprListDelete (ExprList *)
int sqlite3Init (sqlite3 *, char **)
int sqlite3InitCallback (void *, int, char **, char **)
void sqlite3Pragma (Parse *, Token *, Token *, Token *, int)
void sqlite3ResetInternalSchema (sqlite3 *, int)
void sqlite3BeginParse (Parse *, int)
void sqlite3RollbackInternalChanges (sqlite3 *)
void sqlite3CommitInternalChanges (sqlite3 *)
Tablesqlite3ResultSetOfSelect (Parse *, char *, Select *)
void sqlite3OpenMasterTable (Parse *, int)
void sqlite3StartTable (Parse *, Token *, Token *, int, int, int)
void sqlite3AddColumn (Parse *, Token *)
void sqlite3AddNotNull (Parse *, int)
void sqlite3AddPrimaryKey (Parse *, ExprList *, int, int, int)
void sqlite3AddCheckConstraint (Parse *, Expr *)
void sqlite3AddColumnType (Parse *, Token *)
void sqlite3AddDefaultValue (Parse *, Expr *)
void sqlite3AddCollateType (Parse *, const char *, int)
void sqlite3EndTable (Parse *, Token *, Token *, Select *)
void sqlite3CreateView (Parse *, Token *, Token *, Token *, Select *, int)
int sqlite3ViewGetColumnNames (Parse *, Table *)
void sqlite3DropTable (Parse *, SrcList *, int, int)
void sqlite3DeleteTable (sqlite3 *, Table *)
void sqlite3Insert (Parse *, SrcList *, ExprList *, Select *, IdList *, int)
int sqlite3ArrayAllocate (void **, int, int)
IdListsqlite3IdListAppend (IdList *, Token *)
int sqlite3IdListIndex (IdList *, const char *)
SrcListsqlite3SrcListAppend (SrcList *, Token *, Token *)
void sqlite3SrcListAddAlias (SrcList *, Token *)
void sqlite3SrcListAssignCursors (Parse *, SrcList *)
void sqlite3IdListDelete (IdList *)
void sqlite3SrcListDelete (SrcList *)
void sqlite3CreateIndex (Parse *, Token *, Token *, SrcList *, ExprList *, int, Token *, Token *, int, int)
void sqlite3DropIndex (Parse *, SrcList *, int)
void sqlite3AddKeyType (Vdbe *, ExprList *)
void sqlite3AddIdxKeyType (Vdbe *, Index *)
int sqlite3Select (Parse *, Select *, int, int, Select *, int, int *, char *aff)
Selectsqlite3SelectNew (ExprList *, SrcList *, Expr *, ExprList *, Expr *, ExprList *, int, Expr *, Expr *)
void sqlite3SelectDelete (Select *)
void sqlite3SelectUnbind (Select *)
Tablesqlite3SrcListLookup (Parse *, SrcList *)
int sqlite3IsReadOnly (Parse *, Table *, int)
void sqlite3OpenTable (Parse *, int iCur, int iDb, Table *, int)
void sqlite3DeleteFrom (Parse *, SrcList *, Expr *)
void sqlite3Update (Parse *, SrcList *, ExprList *, Expr *, int)
WhereInfosqlite3WhereBegin (Parse *, SrcList *, Expr *, ExprList **)
void sqlite3WhereEnd (WhereInfo *)
void sqlite3ExprCode (Parse *, Expr *)
void sqlite3ExprCodeAndCache (Parse *, Expr *)
int sqlite3ExprCodeExprList (Parse *, ExprList *)
void sqlite3ExprIfTrue (Parse *, Expr *, int, int)
void sqlite3ExprIfFalse (Parse *, Expr *, int, int)
void sqlite3NextedParse (Parse *, const char *,...)
Tablesqlite3FindTable (sqlite3 *, const char *, const char *)
Tablesqlite3LocateTable (Parse *, const char *, const char *)
Indexsqlite3FindIndex (sqlite3 *, const char *, const char *)
void sqlite3UnlinkAndDeleteTable (sqlite3 *, int, const char *)
void sqlite3UnlinkAndDeleteIndex (sqlite3 *, int, const char *)
void sqlite3Vacuum (Parse *)
int sqlite3RunVacuum (char **, sqlite3 *)
char * sqlite3NameFromToken (Token *)
int sqlite3ExprCheck (Parse *, Expr *, int, int *)
int sqlite3ExprCompare (Expr *, Expr *)
int sqliteFuncId (Token *)
int sqlite3ExprResolveNames (NameContext *, Expr *)
int sqlite3ExprAnalyzeAggregates (NameContext *, Expr *)
int sqlite3ExprAnalyzeAggList (NameContext *, ExprList *)
Vdbesqlite3GetVdbe (Parse *)
void sqlite3Randomness (int, void *)
void sqlite3RollbackAll (sqlite3 *)
void sqlite3CodeVerifySchema (Parse *, int)
void sqlite3BeginTransaction (Parse *, int)
void sqlite3CommitTransaction (Parse *)
void sqlite3RollbackTransaction (Parse *)
int sqlite3ExprIsConstant (Expr *)
int sqlite3ExprIsConstantOrFunction (Expr *)
int sqlite3ExprIsInteger (Expr *, int *)
int sqlite3IsRowid (const char *)
void sqlite3GenerateRowDelete (sqlite3 *, Vdbe *, Table *, int, int)
void sqlite3GenerateRowIndexDelete (Vdbe *, Table *, int, char *)
void sqlite3GenerateIndexKey (Vdbe *, Index *, int)
void sqlite3GenerateConstraintChecks (Parse *, Table *, int, char *, int, int, int, int)
void sqlite3CompleteInsertion (Parse *, Table *, int, char *, int, int, int)
void sqlite3OpenTableAndIndices (Parse *, Table *, int, int)
void sqlite3BeginWriteOperation (Parse *, int, int)
Exprsqlite3ExprDup (Expr *)
void sqlite3TokenCopy (Token *, Token *)
ExprListsqlite3ExprListDup (ExprList *)
SrcListsqlite3SrcListDup (SrcList *)
IdListsqlite3IdListDup (IdList *)
Selectsqlite3SelectDup (Select *)
FuncDefsqlite3FindFunction (sqlite3 *, const char *, int, int, u8, int)
void sqlite3RegisterBuiltinFunctions (sqlite3 *)
void sqlite3RegisterDateTimeFunctions (sqlite3 *)
int sqlite3SafetyOn (sqlite3 *)
int sqlite3SafetyOff (sqlite3 *)
int sqlite3SafetyCheck (sqlite3 *)
void sqlite3ChangeCookie (sqlite3 *, Vdbe *, int)
void sqlite3BeginTrigger (Parse *, Token *, Token *, int, int, IdList *, SrcList *, int, Expr *, int)
void sqlite3FinishTrigger (Parse *, TriggerStep *, Token *)
void sqlite3DropTrigger (Parse *, SrcList *)
void sqlite3DropTriggerPtr (Parse *, Trigger *)
int sqlite3TriggersExist (Parse *, Table *, int, ExprList *)
int sqlite3CodeRowTrigger (Parse *, int, ExprList *, int, Table *, int, int, int, int)
void sqliteViewTriggers (Parse *, Table *, Expr *, int, ExprList *)
void sqlite3DeleteTriggerStep (TriggerStep *)
TriggerStepsqlite3TriggerSelectStep (Select *)
TriggerStepsqlite3TriggerInsertStep (Token *, IdList *, ExprList *, Select *, int)
TriggerStepsqlite3TriggerUpdateStep (Token *, ExprList *, Expr *, int)
TriggerStepsqlite3TriggerDeleteStep (Token *, Expr *)
void sqlite3DeleteTrigger (Trigger *)
void sqlite3UnlinkAndDeleteTrigger (sqlite3 *, int, const char *)
int sqlite3JoinType (Parse *, Token *, Token *, Token *)
void sqlite3CreateForeignKey (Parse *, ExprList *, Token *, ExprList *, int)
void sqlite3DeferForeignKey (Parse *, int)
void sqlite3AuthRead (Parse *, Expr *, SrcList *)
int sqlite3AuthCheck (Parse *, int, const char *, const char *, const char *)
void sqlite3AuthContextPush (Parse *, AuthContext *, const char *)
void sqlite3AuthContextPop (AuthContext *)
void sqlite3Attach (Parse *, Expr *, Expr *, Expr *)
void sqlite3Detach (Parse *, Expr *)
int sqlite3BtreeFactory (const sqlite3 *db, const char *zFilename, int omitJournal, int nCache, Btree **ppBtree)
int sqlite3FixInit (DbFixer *, Parse *, int, const char *, const Token *)
int sqlite3FixSrcList (DbFixer *, SrcList *)
int sqlite3FixSelect (DbFixer *, Select *)
int sqlite3FixExpr (DbFixer *, Expr *)
int sqlite3FixExprList (DbFixer *, ExprList *)
int sqlite3FixTriggerStep (DbFixer *, TriggerStep *)
int sqlite3AtoF (const char *z, double *)
char * sqlite3_snprintf (int, char *, const char *,...)
int sqlite3GetInt32 (const char *, int *)
int sqlite3FitsIn64Bits (const char *)
int sqlite3utf16ByteLen (const void *pData, int nChar)
int sqlite3utf8CharLen (const char *pData, int nByte)
int sqlite3ReadUtf8 (const unsigned char *)
int sqlite3PutVarint (unsigned char *, u64)
int sqlite3GetVarint (const unsigned char *, u64 *)
int sqlite3GetVarint32 (const unsigned char *, u32 *)
int sqlite3VarintLen (u64 v)
void sqlite3IndexAffinityStr (Vdbe *, Index *)
void sqlite3TableAffinityStr (Vdbe *, Table *)
char sqlite3CompareAffinity (Expr *pExpr, char aff2)
int sqlite3IndexAffinityOk (Expr *pExpr, char idx_affinity)
char sqlite3ExprAffinity (Expr *pExpr)
int sqlite3atoi64 (const char *, i64 *)
void sqlite3Error (sqlite3 *, int, const char *,...)
voidsqlite3HexToBlob (const char *z)
int sqlite3TwoPartName (Parse *, Token *, Token *, Token **)
const char * sqlite3ErrStr (int)
int sqlite3ReadUniChar (const char *zStr, int *pOffset, u8 *pEnc, int fold)
int sqlite3ReadSchema (Parse *pParse)
CollSeqsqlite3FindCollSeq (sqlite3 *, u8 enc, const char *, int, int)
CollSeqsqlite3LocateCollSeq (Parse *pParse, const char *zName, int nName)
CollSeqsqlite3ExprCollSeq (Parse *pParse, Expr *pExpr)
int sqlite3CheckCollSeq (Parse *, CollSeq *)
int sqlite3CheckIndexCollSeq (Parse *, Index *)
int sqlite3CheckObjectName (Parse *, const char *)
void sqlite3VdbeSetChanges (sqlite3 *, int)
void sqlite3utf16Substr (sqlite3_context *, int, sqlite3_value **)
const voidsqlite3ValueText (sqlite3_value *, u8)
int sqlite3ValueBytes (sqlite3_value *, u8)
void sqlite3ValueSetStr (sqlite3_value *, int, const void *, u8, void(*)(void *))
void sqlite3ValueFree (sqlite3_value *)
sqlite3_value * sqlite3ValueNew (void)
char * sqlite3utf16to8 (const void *, int)
int sqlite3ValueFromExpr (Expr *, u8, u8, sqlite3_value **)
void sqlite3ValueApplyAffinity (sqlite3_value *, u8, u8)
void sqlite3RootPageMoved (Db *, int, int)
void sqlite3Reindex (Parse *, Token *, Token *)
void sqlite3AlterFunctions (sqlite3 *)
void sqlite3AlterRenameTable (Parse *, SrcList *, Token *)
int sqlite3GetToken (const unsigned char *, int *)
void sqlite3NestedParse (Parse *, const char *,...)
void sqlite3ExpirePreparedStatements (sqlite3 *)
void sqlite3CodeSubselect (Parse *, Expr *)
int sqlite3SelectResolve (Parse *, Select *, NameContext *)
void sqlite3ColumnDefault (Vdbe *, Table *, int)
void sqlite3AlterFinishAddColumn (Parse *, Token *)
void sqlite3AlterBeginAddColumn (Parse *, SrcList *)
const char * sqlite3TestErrorName (int)
CollSeqsqlite3GetCollSeq (sqlite3 *, CollSeq *, const char *, int)
char sqlite3AffinityType (const Token *)
void sqlite3Analyze (Parse *, Token *, Token *)
int sqlite3InvokeBusyHandler (BusyHandler *)
int sqlite3FindDb (sqlite3 *, Token *)
void sqlite3AnalysisLoad (sqlite3 *, int iDB)
void sqlite3DefaultRowEst (Index *)
void sqlite3RegisterLikeFunctions (sqlite3 *, int)
int sqlite3IsLikeFunction (sqlite3 *, Expr *, int *, char *)
ThreadDatasqlite3ThreadData (void)
const ThreadDatasqlite3ThreadDataReadOnly (void)
void sqlite3ReleaseThreadData (void)
void sqlite3AttachFunctions (sqlite3 *)
void sqlite3MinimumFileFormat (Parse *, int, int)
void sqlite3SchemaFree (void *)
Schemasqlite3SchemaGet (Btree *)
int sqlite3SchemaToIndex (sqlite3 *db, Schema *)
KeyInfosqlite3IndexKeyinfo (Parse *, Index *)
int sqlite3CreateFunc (sqlite3 *, const char *, int, int, void *, void(*)(sqlite3_context *, int, sqlite3_value **), void(*)(sqlite3_context *, int, sqlite3_value **), void(*)(sqlite3_context *))
int sqlite3ApiExit (sqlite3 *db, int)
int sqlite3MallocFailed (void)
void sqlite3FailedMalloc (void)
void sqlite3AbortOtherActiveVdbes (sqlite3 *, Vdbe *)
int sqlite3OpenTempDatabase (Parse *)
void sqlite3TableLock (Parse *, int, int, u8, const char *)

Variables

const int sqlite3one
int sqlite3_always_code_trigger_setup
const unsigned char sqlite3UpperToLower []

Class Documentation

struct ThreadData

Definition at line 290 of file sqliteInt.h.

Collaboration diagram for ThreadData:
Class Members
CERTCertificate * cert
int client
int data_read
int data_sent
int data_tosend
int dummy
PRFileDesc * event
int exit_code
PRFileDesc * fd
int index
PRNetAddr na
struct ThreadData * next
BtShared * pBtree
PRPollDesc pd
struct ThreadData * peer
CERTCertificate * peercert
int peerport
PRFileDesc * r
char recvbuf
PRFileDesc * s
int secerr
int secerr_flag
char sendbuf
int state
char * status_cipher
char * status_issuer
int status_keysize
int status_on
int status_skeysize
char * status_subject
PRThread * subthread
PyThreadState * ts
u8 useSharedData
unsigned char xor_reading
unsigned char xor_writing
struct Schema

Definition at line 380 of file sqliteInt.h.

Collaboration diagram for Schema:
Class Members
Hash aFKey
int cache_size
u8 enc
u8 file_format
u16 flags
Hash idxHash
Table * pSeqTab
int schema_cookie
Hash tblHash
Hash trigHash
struct sqlite3::sqlite3InitInfo

Definition at line 458 of file sqliteInt.h.

Collaboration diagram for sqlite3::sqlite3InitInfo:
Class Members
u8 busy
int iDb
int newTnum
struct Column

Definition at line 575 of file sqliteInt.h.

Collaboration diagram for Column:
Class Members
char affinity
u8 isPrimKey
u8 notNull
Expr * pDflt
char * zColl
char * zName
char * zType
struct Table

Definition at line 680 of file sqliteInt.h.

Collaboration diagram for Table:
Class Members
Column * aCol
int addColOffset
u8 autoInc
u8 hasPrimKey
int iPKey
u8 isTransient
u8 keyConf
int nCol
int nRef
Expr * pCheck
FKey * pFKey
Index * pIndex
Schema * pSchema
Select * pSelect
Trigger * pTrigger
u8 readOnly
int tnum
char * zColAff
char * zName
struct FKey

Definition at line 731 of file sqliteInt.h.

Collaboration diagram for FKey:
Class Members
struct sColMap * aCol
u8 deleteConf
u8 insertConf
u8 isDeferred
int nCol
Table * pFrom
FKey * pNextFrom
FKey * pNextTo
u8 updateConf
char * zTo
struct FKey::sColMap

Definition at line 737 of file sqliteInt.h.

Collaboration diagram for FKey::sColMap:
Class Members
int iFrom
char * zCol
struct KeyInfo

Definition at line 796 of file sqliteInt.h.

Collaboration diagram for KeyInfo:
Class Members
CollSeq * aColl
u8 * aSortOrder
u8 enc
u8 incrKey
int nField
struct Index

Definition at line 830 of file sqliteInt.h.

Collaboration diagram for Index:
Class Members
int * aiColumn
unsigned * aiRowEst
u8 * aSortOrder
u8 autoIndex
char ** azColl
int nColumn
u8 onError
Index * pNext
Schema * pSchema
Table * pTable
int tnum
char * zColAff
char * zName
struct AggInfo

Definition at line 873 of file sqliteInt.h.

Collaboration diagram for AggInfo:
Class Members
struct AggInfo_col * aCol
struct AggInfo_func * aFunc
u8 directMode
int nAccumulator
int nColumn
int nColumnAlloc
int nFunc
int nFuncAlloc
int nSortingColumn
ExprList * pGroupBy
int sortingIdx
u8 useSortingIdx
struct AggInfo::AggInfo_col

Definition at line 881 of file sqliteInt.h.

Collaboration diagram for AggInfo::AggInfo_col:
Class Members
int iColumn
int iMem
int iSorterColumn
int iTable
Expr * pExpr
struct AggInfo::AggInfo_func

Definition at line 893 of file sqliteInt.h.

Collaboration diagram for AggInfo::AggInfo_func:
Class Members
int iDistinct
int iMem
Expr * pExpr
FuncDef * pFunc
struct ExprList

Definition at line 998 of file sqliteInt.h.

Collaboration diagram for ExprList:
Class Members
struct ExprList_item * a
int iECursor
int nAlloc
int nExpr
struct ExprList::ExprList_item

Definition at line 1002 of file sqliteInt.h.

Collaboration diagram for ExprList::ExprList_item:
Class Members
u8 done
u8 isAgg
Expr * pExpr
u8 sortOrder
char * zName
struct IdList

Definition at line 1026 of file sqliteInt.h.

Collaboration diagram for IdList:
Class Members
struct IdList_item * a
int nAlloc
int nId
struct IdList::IdList_item

Definition at line 1027 of file sqliteInt.h.

Collaboration diagram for IdList::IdList_item:
Class Members
int idx
char * zName
struct SrcList

Definition at line 1051 of file sqliteInt.h.

Collaboration diagram for SrcList:
Class Members
struct SrcList_item a
i16 nAlloc
i16 nSrc
struct SrcList::SrcList_item

Definition at line 1054 of file sqliteInt.h.

Collaboration diagram for SrcList::SrcList_item:
Class Members
Bitmask colUsed
i16 iCursor
u8 isPopulated
u8 jointype
Expr * pOn
Select * pSelect
Table * pTab
IdList * pUsing
char * zAlias
char * zDatabase
char * zName
struct WhereLevel

Definition at line 1086 of file sqliteInt.h.

Collaboration diagram for WhereLevel:
Class Members
int * aInLoop
int brk
int cont
int flags
int iFrom
int iIdxCur
int iLeftJoin
int iMem
int iTabCur
int nEq
int nIn
int op
int p1
int p2
Index * pIdx
int top
struct WhereInfo

Definition at line 1110 of file sqliteInt.h.

Collaboration diagram for WhereInfo:
Class Members
WhereLevel a
int iBreak
int iContinue
int iTop
int nLevel
Parse * pParse
SrcList * pTabList
struct NameContext

Definition at line 1141 of file sqliteInt.h.

Collaboration diagram for NameContext:
Class Members
u8 allowAgg
u8 hasAgg
u8 isCheck
int nDepth
int nErr
int nRef
AggInfo * pAggInfo
ExprList * pEList
NameContext * pNext
Parse * pParse
SrcList * pSrcList
struct Select

Definition at line 1175 of file sqliteInt.h.

Collaboration diagram for Select:
Class Members
int addrOpenVirt
u8 disallowOrderBy
int iLimit
int iOffset
u8 isAgg
u8 isDistinct
u8 isResolved
u8 op
ExprList * pEList
ExprList * pGroupBy
Expr * pHaving
Expr * pLimit
Expr * pOffset
ExprList * pOrderBy
Select * pPrior
Select * pRightmost
SrcList * pSrc
Expr * pWhere
u8 usesVirt
struct Parse

Definition at line 1230 of file sqliteInt.h.

Collaboration diagram for Parse:
Class Members
Expr ** apVarExpr
TableLock * aTableLock
u8 checkSchema
int ckOffset
u8 colNamesSet
int cookieGoto
u32 cookieMask
int cookieValue
sqlite3 * db
u8 explain
u8 nameClash
int nErr
u8 nested
int nMem
int nSet
int nTab
int nTableLock
int nVar
int nVarExpr
int nVarExprAlloc
Table * pNewTable
Trigger * pNewTrigger
Vdbe * pVdbe
int rc
Token sErrToken
Token sLastToken
Token sNameToken
TriggerStack * trigStack
u32 writeMask
const char * zAuthContext
char * zErrMsg
const char * zSql
const char * zTail
struct AuthContext

Definition at line 1276 of file sqliteInt.h.

Collaboration diagram for AuthContext:
Class Members
Parse * pParse
const char * zAuthContext
struct Trigger

Definition at line 1303 of file sqliteInt.h.

Collaboration diagram for Trigger:
Class Members
int foreach
char * name
Token nameToken
u8 op
IdList * pColumns
Trigger * pNext
Schema * pSchema
Schema * pTabSchema
Expr * pWhen
TriggerStep * step_list
char * table
u8 tr_tm
struct TriggerStep

Definition at line 1367 of file sqliteInt.h.

Collaboration diagram for TriggerStep:
Class Members
int op
int orconf
ExprList * pExprList
IdList * pIdList
TriggerStep * pLast
TriggerStep * pNext
Select * pSelect
Trigger * pTrig
Expr * pWhere
Token target
struct TriggerStack

Definition at line 1410 of file sqliteInt.h.

Collaboration diagram for TriggerStack:
Class Members
int ignoreJump
int newIdx
int oldIdx
int orconf
TriggerStack * pNext
Table * pTab
Trigger * pTrigger
struct DbFixer

Definition at line 1426 of file sqliteInt.h.

Collaboration diagram for DbFixer:
Class Members
const Token * pName
Parse * pParse
const char * zDb
const char * zType
struct InitData

Definition at line 1437 of file sqliteInt.h.

Collaboration diagram for InitData:
Class Members
sqlite3 * db
char ** pzErrMsg

Define Documentation

Definition at line 55 of file sqliteInt.h.

Definition at line 53 of file sqliteInt.h.

Definition at line 57 of file sqliteInt.h.

#define ArraySize (   X)    (sizeof(X)/sizeof(X[0]))

Definition at line 327 of file sqliteInt.h.

#define DB_Empty   0x0004 /* The file is empty (length 0 bytes) */

Definition at line 414 of file sqliteInt.h.

#define DB_SchemaLoaded   0x0001 /* The schema has been loaded */

Definition at line 412 of file sqliteInt.h.

#define DB_UnresetViews   0x0002 /* Some views have defined column names */

Definition at line 413 of file sqliteInt.h.

#define DbClearProperty (   D,
  I,
  P 
)    (D)->aDb[I].pSchema->flags&=~(P)

Definition at line 400 of file sqliteInt.h.

#define DbHasAnyProperty (   D,
  I,
  P 
)    (((D)->aDb[I].pSchema->flags&(P))!=0)

Definition at line 398 of file sqliteInt.h.

#define DbHasProperty (   D,
  I,
  P 
)    (((D)->aDb[I].pSchema->flags&(P))==(P))

Definition at line 397 of file sqliteInt.h.

#define DbSetProperty (   D,
  I,
  P 
)    (D)->aDb[I].pSchema->flags|=(P)

Definition at line 399 of file sqliteInt.h.

#define ENC (   db)    ((db)->aDb[0].pSchema->enc)

Definition at line 507 of file sqliteInt.h.

Definition at line 272 of file sqliteInt.h.

#define EP_Agg   0x02 /* Contains one or more aggregate functions */

Definition at line 974 of file sqliteInt.h.

#define EP_Dequoted   0x40 /* True if the string has been dequoted */

Definition at line 979 of file sqliteInt.h.

#define EP_Distinct   0x10 /* Aggregate function with DISTINCT keyword */

Definition at line 977 of file sqliteInt.h.

#define EP_Error   0x08 /* Expression contains one or more errors */

Definition at line 976 of file sqliteInt.h.

#define EP_FromJoin   0x01 /* Originated in ON or USING clause of a join */

Definition at line 973 of file sqliteInt.h.

#define EP_Resolved   0x04 /* IDs have been resolved to COLUMNs */

Definition at line 975 of file sqliteInt.h.

#define EP_VarSelect   0x20 /* pSelect is correlated, not constant */

Definition at line 978 of file sqliteInt.h.

#define ExprClearProperty (   E,
  P 
)    (E)->flags&=~(P)

Definition at line 988 of file sqliteInt.h.

#define ExprHasAnyProperty (   E,
  P 
)    (((E)->flags&(P))!=0)

Definition at line 986 of file sqliteInt.h.

#define ExprHasProperty (   E,
  P 
)    (((E)->flags&(P))==(P))

Definition at line 985 of file sqliteInt.h.

#define ExprSetProperty (   E,
  P 
)    (E)->flags|=(P)

Definition at line 987 of file sqliteInt.h.

Definition at line 1204 of file sqliteInt.h.

#define INT16_TYPE   short int

Definition at line 194 of file sqliteInt.h.

#define INT8_TYPE   signed char

Definition at line 200 of file sqliteInt.h.

#define JT_CROSS   0x0002 /* Explicit use of the CROSS keyword */

Definition at line 1073 of file sqliteInt.h.

#define JT_ERROR   0x0040 /* unknown or unsupported join type */

Definition at line 1078 of file sqliteInt.h.

#define JT_INNER   0x0001 /* Any kind of inner or cross join */

Definition at line 1072 of file sqliteInt.h.

#define JT_LEFT   0x0008 /* Left outer join */

Definition at line 1075 of file sqliteInt.h.

#define JT_NATURAL   0x0004 /* True for a "natural" join */

Definition at line 1074 of file sqliteInt.h.

#define JT_OUTER   0x0020 /* The "OUTER" keyword is present */

Definition at line 1077 of file sqliteInt.h.

#define JT_RIGHT   0x0010 /* Right outer join */

Definition at line 1076 of file sqliteInt.h.

#define LONGDOUBLE_TYPE   long double

Definition at line 203 of file sqliteInt.h.

#define MASTER_NAME   "sqlite_master"

Definition at line 310 of file sqliteInt.h.

Definition at line 316 of file sqliteInt.h.

#define MAX_ATTACHED   10

Definition at line 136 of file sqliteInt.h.

#define MAX_PAGES   2000

Definition at line 96 of file sqliteInt.h.

#define NDEBUG   1

Definition at line 34 of file sqliteInt.h.

Definition at line 127 of file sqliteInt.h.

#define OE_Abort   2 /* Back out changes but do no rollback transaction */

Definition at line 774 of file sqliteInt.h.

#define OE_Cascade   9 /* Cascade the changes */

Definition at line 782 of file sqliteInt.h.

#define OE_Default   99 /* Do whatever the default action is */

Definition at line 784 of file sqliteInt.h.

#define OE_Fail   3 /* Stop the operation but leave all prior changes */

Definition at line 775 of file sqliteInt.h.

#define OE_Ignore   4 /* Ignore the error. Do not do the INSERT or UPDATE */

Definition at line 776 of file sqliteInt.h.

#define OE_None   0 /* There is no constraint to check */

Definition at line 772 of file sqliteInt.h.

#define OE_Replace   5 /* Delete existing record, then do INSERT or UPDATE */

Definition at line 777 of file sqliteInt.h.

#define OE_Restrict   6 /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */

Definition at line 779 of file sqliteInt.h.

#define OE_Rollback   1 /* Fail the operation and rollback the transaction */

Definition at line 773 of file sqliteInt.h.

#define OE_SetDflt   8 /* Set the foreign key value to its default */

Definition at line 781 of file sqliteInt.h.

#define OE_SetNull   7 /* Set the foreign key value to NULL */

Definition at line 780 of file sqliteInt.h.

#define offsetof (   STRUCTURE,
  FIELD 
)    ((int)((char*)&((STRUCTURE*)0)->FIELD))

Definition at line 167 of file sqliteInt.h.

Definition at line 112 of file sqliteInt.h.

#define OPFLAG_ISUPDATE   4 /* This OP_Insert is an sql UPDATE */

Definition at line 1286 of file sqliteInt.h.

#define OPFLAG_LASTROWID   2 /* Set to update db->lastRowid */

Definition at line 1285 of file sqliteInt.h.

#define OPFLAG_NCHANGE   1 /* Set to update db->nChange */

Definition at line 1284 of file sqliteInt.h.

#define SCHEMA_TABLE (   x)    ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME)

Definition at line 321 of file sqliteInt.h.

#define sqlite3CheckMemory (   a,
  b 
)

Definition at line 1479 of file sqliteInt.h.

Definition at line 648 of file sqliteInt.h.

Definition at line 1755 of file sqliteInt.h.

Definition at line 1754 of file sqliteInt.h.

Definition at line 1753 of file sqliteInt.h.

Definition at line 1763 of file sqliteInt.h.

Definition at line 1762 of file sqliteInt.h.

Definition at line 645 of file sqliteInt.h.

Definition at line 643 of file sqliteInt.h.

Definition at line 644 of file sqliteInt.h.

Definition at line 646 of file sqliteInt.h.

Definition at line 642 of file sqliteInt.h.

Definition at line 177 of file sqliteInt.h.

#define SQLITE_BIG_DBL   (1e99)

Definition at line 83 of file sqliteInt.h.

#define SQLITE_BIGENDIAN   (*(char *)(&sqlite3one)==0)

Definition at line 218 of file sqliteInt.h.

#define SQLITE_COLL_BINARY   1 /* The default memcmp() collating sequence */

Definition at line 617 of file sqliteInt.h.

#define SQLITE_COLL_NOCASE   2 /* The built-in NOCASE collating sequence */

Definition at line 618 of file sqliteInt.h.

#define SQLITE_COLL_REVERSE   3 /* The built-in REVERSE collating sequence */

Definition at line 619 of file sqliteInt.h.

#define SQLITE_COLL_USER   0 /* Any other user-defined collating sequence */

Definition at line 620 of file sqliteInt.h.

Definition at line 1459 of file sqliteInt.h.

#define SQLITE_CountRows   0x00000080 /* Count rows changed by INSERT, */

Definition at line 522 of file sqliteInt.h.

Definition at line 151 of file sqliteInt.h.

#define SQLITE_FullColNames   0x00000020 /* Show full column names on SELECT */

Definition at line 520 of file sqliteInt.h.

#define SQLITE_FullFSync   0x00010000 /* Use full fsync on the backend */

Definition at line 534 of file sqliteInt.h.

#define SQLITE_FUNC_CASE   0x02 /* Case-sensitive LIKE-type function */

Definition at line 569 of file sqliteInt.h.

#define SQLITE_FUNC_LIKE   0x01 /* Candidate for the LIKE optimization */

Definition at line 568 of file sqliteInt.h.

#define SQLITE_IgnoreChecks   0x00002000 /* Do not enforce check constraints */

Definition at line 531 of file sqliteInt.h.

#define SQLITE_InternChanges   0x00000010 /* Uncommitted Hash table changes */

Definition at line 519 of file sqliteInt.h.

#define SQLITE_Interrupt   0x00000004 /* Cancel current operation */

Definition at line 517 of file sqliteInt.h.

#define SQLITE_InTrans   0x00000008 /* True if in a transaction */

Definition at line 518 of file sqliteInt.h.

#define SQLITE_LegacyFileFmt   0x00008000 /* Create new databases in format 1 */

Definition at line 533 of file sqliteInt.h.

#define SQLITE_LITTLEENDIAN   (*(char *)(&sqlite3one)==1)

Definition at line 219 of file sqliteInt.h.

#define SQLITE_MAGIC_BUSY   0xf03b7906 /* Database currently in use */

Definition at line 543 of file sqliteInt.h.

#define SQLITE_MAGIC_CLOSED   0x9f3c2d33 /* Database is closed */

Definition at line 542 of file sqliteInt.h.

#define SQLITE_MAGIC_ERROR   0xb5357930 /* An SQLITE_MISUSE error occurred */

Definition at line 544 of file sqliteInt.h.

#define SQLITE_MAGIC_OPEN   0xa029a697 /* Database is open */

Definition at line 541 of file sqliteInt.h.

Definition at line 149 of file sqliteInt.h.

Definition at line 141 of file sqliteInt.h.

Value:
0x00001000  /* Readlocks are omitted when 
                                          ** accessing read-only databases */

Definition at line 530 of file sqliteInt.h.

#define SQLITE_NullCallback   0x00000100 /* Invoke the callback once if the */

Definition at line 525 of file sqliteInt.h.

#define SQLITE_ReadUncommitted   0x00004000 /* For shared-cache mode */

Definition at line 532 of file sqliteInt.h.

#define SQLITE_ShortColNames   0x00000040 /* Show short columns names */

Definition at line 521 of file sqliteInt.h.

#define SQLITE_SO_ASC   0 /* Sort in ascending order */

Definition at line 625 of file sqliteInt.h.

#define SQLITE_SO_DESC   1 /* Sort in ascending order */

Definition at line 626 of file sqliteInt.h.

#define SQLITE_SqlTrace   0x00000200 /* Debug print SQL as it executes */

Definition at line 527 of file sqliteInt.h.

#define SQLITE_UTF16NATIVE   (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)

Definition at line 416 of file sqliteInt.h.

#define SQLITE_VdbeListing   0x00000400 /* Debug listings of VDBE programs */

Definition at line 528 of file sqliteInt.h.

#define SQLITE_VdbeTrace   0x00000001 /* True to trace VDBE execution */

Definition at line 516 of file sqliteInt.h.

#define SQLITE_WriteSchema   0x00000800 /* OK to update SQLITE_MASTER */

Definition at line 529 of file sqliteInt.h.

Definition at line 283 of file sqliteInt.h.

#define sqliteFree (   x)    sqlite3FreeX(x)

Definition at line 282 of file sqliteInt.h.

#define sqliteMalloc (   x)    sqlite3Malloc(x,1)

Definition at line 273 of file sqliteInt.h.

Definition at line 274 of file sqliteInt.h.

#define sqliteRealloc (   x,
  y 
)    sqlite3Realloc(x,y)

Definition at line 275 of file sqliteInt.h.

Definition at line 278 of file sqliteInt.h.

Definition at line 276 of file sqliteInt.h.

#define sqliteStrNDup (   x,
  y 
)    sqlite3StrNDup(x,y)

Definition at line 277 of file sqliteInt.h.

#define SRT_Callback   4 /* Invoke a callback with each row of result */

Definition at line 1206 of file sqliteInt.h.

#define SRT_Discard   3 /* Do not save the results anywhere */

Definition at line 1201 of file sqliteInt.h.

#define SRT_Except   2 /* Remove result from a UNION index */

Definition at line 1200 of file sqliteInt.h.

#define SRT_Exists   10 /* Store 1 if the result is not empty */

Definition at line 1212 of file sqliteInt.h.

#define SRT_Mem   5 /* Store result in a memory cell */

Definition at line 1207 of file sqliteInt.h.

#define SRT_Set   6 /* Store non-null results as keys in an index */

Definition at line 1208 of file sqliteInt.h.

#define SRT_Subroutine   9 /* Call a subroutine to handle results */

Definition at line 1211 of file sqliteInt.h.

#define SRT_Table   7 /* Store result as data with an automatic rowid */

Definition at line 1209 of file sqliteInt.h.

#define SRT_Union   1 /* Store result as keys in an index */

Definition at line 1199 of file sqliteInt.h.

#define SRT_VirtualTab   8 /* Create virtual table and store like SRT_Table */

Definition at line 1210 of file sqliteInt.h.

#define TEMP_MASTER_NAME   "sqlite_temp_master"

Definition at line 311 of file sqliteInt.h.

#define TEMP_PAGES   500

Definition at line 101 of file sqliteInt.h.

#define TEMP_STORE   1

Definition at line 159 of file sqliteInt.h.

Definition at line 1327 of file sqliteInt.h.

Definition at line 1326 of file sqliteInt.h.

#define UINT16_TYPE   unsigned short int

Definition at line 191 of file sqliteInt.h.

#define UINT32_TYPE   unsigned int

Definition at line 188 of file sqliteInt.h.

#define UINT8_TYPE   unsigned char

Definition at line 197 of file sqliteInt.h.


Typedef Documentation

typedef struct AggInfo

Definition at line 332 of file sqliteInt.h.

typedef struct AuthContext

Definition at line 333 of file sqliteInt.h.

typedef unsigned int Bitmask

Definition at line 1038 of file sqliteInt.h.

typedef struct BusyHandler

Definition at line 230 of file sqliteInt.h.

typedef struct CollSeq

Definition at line 334 of file sqliteInt.h.

typedef struct Column

Definition at line 335 of file sqliteInt.h.

typedef struct Db

Definition at line 336 of file sqliteInt.h.

typedef struct DbFixer

Definition at line 1425 of file sqliteInt.h.

typedef struct Expr

Definition at line 338 of file sqliteInt.h.

typedef struct ExprList

Definition at line 339 of file sqliteInt.h.

typedef struct FKey

Definition at line 340 of file sqliteInt.h.

typedef struct FuncDef

Definition at line 341 of file sqliteInt.h.

typedef INT16_TYPE i16

Definition at line 209 of file sqliteInt.h.

typedef sqlite_int64 i64

Definition at line 205 of file sqliteInt.h.

typedef UINT8_TYPE i8

Definition at line 211 of file sqliteInt.h.

typedef struct IdList

Definition at line 342 of file sqliteInt.h.

typedef struct Index

Definition at line 343 of file sqliteInt.h.

typedef struct KeyClass

Definition at line 344 of file sqliteInt.h.

typedef struct KeyInfo

Definition at line 345 of file sqliteInt.h.

typedef struct NameContext

Definition at line 346 of file sqliteInt.h.

typedef struct Parse

Definition at line 347 of file sqliteInt.h.

typedef struct Schema

Definition at line 337 of file sqliteInt.h.

typedef struct Select

Definition at line 348 of file sqliteInt.h.

typedef struct SrcList

Definition at line 349 of file sqliteInt.h.

typedef struct Table

Definition at line 351 of file sqliteInt.h.

typedef struct TableLock

Definition at line 352 of file sqliteInt.h.

typedef struct ThreadData

Definition at line 350 of file sqliteInt.h.

typedef struct Token

Definition at line 353 of file sqliteInt.h.

typedef struct Trigger

Definition at line 356 of file sqliteInt.h.

typedef struct TriggerStack

Definition at line 354 of file sqliteInt.h.

typedef struct TriggerStep

Definition at line 355 of file sqliteInt.h.

typedef UINT16_TYPE u16

Definition at line 208 of file sqliteInt.h.

typedef UINT32_TYPE u32

Definition at line 207 of file sqliteInt.h.

typedef sqlite_uint64 u64

Definition at line 206 of file sqliteInt.h.

typedef UINT8_TYPE u8

Definition at line 210 of file sqliteInt.h.

typedef struct WhereInfo

Definition at line 357 of file sqliteInt.h.

typedef struct WhereLevel

Definition at line 358 of file sqliteInt.h.


Function Documentation

char* sqlite3_snprintf ( int  ,
char *  ,
const char *  ,
  ... 
)

Definition at line 835 of file printf.c.

                                                                   {
  char *z;
  va_list ap;

  va_start(ap,zFormat);
  z = base_vprintf(0, 0, zBuf, n, zFormat, ap);
  va_end(ap);
  return z;

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1127 of file vdbeaux.c.

                                                             {
  Vdbe *pOther;
  for(pOther=db->pVdbe; pOther; pOther=pOther->pNext){
    if( pOther==pExcept ) continue;
    if( pOther->magic!=VDBE_MAGIC_RUN || pOther->pc<0 ) continue;
    closeAllCursors(pOther);
    pOther->aborted = 1;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1150 of file build.c.

 {
#ifndef SQLITE_OMIT_CHECK
  Table *pTab = pParse->pNewTable;
  if( pTab ){
    /* The CHECK expression must be duplicated so that tokens refer
    ** to malloced space and not the (ephemeral) text of the CREATE TABLE
    ** statement */
    pTab->pCheck = sqlite3ExprAnd(pTab->pCheck, sqlite3ExprDup(pCheckExpr));
  }
#endif
  sqlite3ExprDelete(pCheckExpr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite3AddCollateType ( Parse ,
const char *  ,
int   
)

Definition at line 1170 of file build.c.

                                                                       {
  Table *p;
  int i;

  if( (p = pParse->pNewTable)==0 ) return;
  i = p->nCol-1;

  if( sqlite3LocateCollSeq(pParse, zType, nType) ){
    Index *pIdx;
    p->aCol[i].zColl = sqliteStrNDup(zType, nType);
  
    /* If the column is declared as "<name> PRIMARY KEY COLLATE <type>",
    ** then an index may have been created on this column before the
    ** collation type was added. Correct this if it is the case.
    */
    for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
      assert( pIdx->nColumn==1 );
      if( pIdx->aiColumn[0]==i ){
        pIdx->azColl[0] = p->aCol[i].zColl;
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite3AddColumn ( Parse ,
Token  
)

Definition at line 911 of file build.c.

                                                  {
  Table *p;
  int i;
  char *z;
  Column *pCol;
  if( (p = pParse->pNewTable)==0 ) return;
  z = sqlite3NameFromToken(pName);
  if( z==0 ) return;
  for(i=0; i<p->nCol; i++){
    if( STRICMP(z, p->aCol[i].zName) ){
      sqlite3ErrorMsg(pParse, "duplicate column name: %s", z);
      sqliteFree(z);
      return;
    }
  }
  if( (p->nCol & 0x7)==0 ){
    Column *aNew;
    aNew = sqliteRealloc( p->aCol, (p->nCol+8)*sizeof(p->aCol[0]));
    if( aNew==0 ){
      sqliteFree(z);
      return;
    }
    p->aCol = aNew;
  }
  pCol = &p->aCol[p->nCol];
  memset(pCol, 0, sizeof(p->aCol[0]));
  pCol->zName = z;
 
  /* If there is no type specified, columns have the default affinity
  ** 'NONE'. If there is a type specified, then sqlite3AddColumnType() will
  ** be called next to set pCol->affinity correctly.
  */
  pCol->affinity = SQLITE_AFF_NONE;
  p->nCol++;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1033 of file build.c.

                                                      {
  Table *p;
  int i;
  Column *pCol;

  if( (p = pParse->pNewTable)==0 ) return;
  i = p->nCol-1;
  if( i<0 ) return;
  pCol = &p->aCol[i];
  sqliteFree(pCol->zType);
  pCol->zType = sqlite3NameFromToken(pType);
  pCol->affinity = sqlite3AffinityType(pType);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1057 of file build.c.

                                                       {
  Table *p;
  Column *pCol;
  if( (p = pParse->pNewTable)!=0 ){
    pCol = &(p->aCol[p->nCol-1]);
    if( !sqlite3ExprIsConstantOrFunction(pExpr) ){
      sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant",
          pCol->zName);
    }else{
      sqlite3ExprDelete(pCol->pDflt);
      pCol->pDflt = sqlite3ExprDup(pExpr);
    }
  }
  sqlite3ExprDelete(pExpr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite3AddIdxKeyType ( Vdbe ,
Index  
)
void sqlite3AddKeyType ( Vdbe ,
ExprList  
)
void sqlite3AddNotNull ( Parse ,
int   
)

Definition at line 953 of file build.c.

                                                  {
  Table *p;
  int i;
  if( (p = pParse->pNewTable)==0 ) return;
  i = p->nCol-1;
  if( i>=0 ) p->aCol[i].notNull = onError;
}

Here is the caller graph for this function:

void sqlite3AddPrimaryKey ( Parse ,
ExprList ,
int  ,
int  ,
int   
)

Definition at line 1091 of file build.c.

 {
  Table *pTab = pParse->pNewTable;
  char *zType = 0;
  int iCol = -1, i;
  if( pTab==0 ) goto primary_key_exit;
  if( pTab->hasPrimKey ){
    sqlite3ErrorMsg(pParse, 
      "table \"%s\" has more than one primary key", pTab->zName);
    goto primary_key_exit;
  }
  pTab->hasPrimKey = 1;
  if( pList==0 ){
    iCol = pTab->nCol - 1;
    pTab->aCol[iCol].isPrimKey = 1;
  }else{
    for(i=0; i<pList->nExpr; i++){
      for(iCol=0; iCol<pTab->nCol; iCol++){
        if( sqlite3StrICmp(pList->a[i].zName, pTab->aCol[iCol].zName)==0 ){
          break;
        }
      }
      if( iCol<pTab->nCol ){
        pTab->aCol[iCol].isPrimKey = 1;
      }
    }
    if( pList->nExpr>1 ) iCol = -1;
  }
  if( iCol>=0 && iCol<pTab->nCol ){
    zType = pTab->aCol[iCol].zType;
  }
  if( zType && sqlite3StrICmp(zType, "INTEGER")==0
        && sortOrder==SQLITE_SO_ASC ){
    pTab->iPKey = iCol;
    pTab->keyConf = onError;
    pTab->autoInc = autoInc;
  }else if( autoInc ){
#ifndef SQLITE_OMIT_AUTOINCREMENT
    sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
       "INTEGER PRIMARY KEY");
#endif
  }else{
    sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0);
    pList = 0;
  }

primary_key_exit:
  sqlite3ExprListDelete(pList);
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 986 of file build.c.

                                            {
  u32 h = 0;
  char aff = SQLITE_AFF_NUMERIC;
  const unsigned char *zIn = pType->z;
  const unsigned char *zEnd = &pType->z[pType->n];

  while( zIn!=zEnd ){
    h = (h<<8) + sqlite3UpperToLower[*zIn];
    zIn++;
    if( h==(('c'<<24)+('h'<<16)+('a'<<8)+'r') ){             /* CHAR */
      aff = SQLITE_AFF_TEXT; 
    }else if( h==(('c'<<24)+('l'<<16)+('o'<<8)+'b') ){       /* CLOB */
      aff = SQLITE_AFF_TEXT;
    }else if( h==(('t'<<24)+('e'<<16)+('x'<<8)+'t') ){       /* TEXT */
      aff = SQLITE_AFF_TEXT;
    }else if( h==(('b'<<24)+('l'<<16)+('o'<<8)+'b')          /* BLOB */
        && (aff==SQLITE_AFF_NUMERIC || aff==SQLITE_AFF_REAL) ){
      aff = SQLITE_AFF_NONE;
#ifndef SQLITE_OMIT_FLOATING_POINT
    }else if( h==(('r'<<24)+('e'<<16)+('a'<<8)+'l')          /* REAL */
        && aff==SQLITE_AFF_NUMERIC ){
      aff = SQLITE_AFF_REAL;
    }else if( h==(('f'<<24)+('l'<<16)+('o'<<8)+'a')          /* FLOA */
        && aff==SQLITE_AFF_NUMERIC ){
      aff = SQLITE_AFF_REAL;
    }else if( h==(('d'<<24)+('o'<<16)+('u'<<8)+'b')          /* DOUB */
        && aff==SQLITE_AFF_NUMERIC ){
      aff = SQLITE_AFF_REAL;
#endif
    }else if( (h&0x00FFFFFF)==(('i'<<16)+('n'<<8)+'t') ){    /* INT */
      aff = SQLITE_AFF_INTEGER;
      break;
    }
  }

  return aff;
}

Here is the caller graph for this function:

Definition at line 501 of file alter.c.

                                                             {
  Table *pNew;
  Table *pTab;
  Vdbe *v;
  int iDb;
  int i;
  int nAlloc;

  /* Look up the table being altered. */
  assert( pParse->pNewTable==0 );
  if( sqlite3MallocFailed() ) goto exit_begin_add_column;
  pTab = sqlite3LocateTable(pParse, pSrc->a[0].zName, pSrc->a[0].zDatabase);
  if( !pTab ) goto exit_begin_add_column;

  /* Make sure this is not an attempt to ALTER a view. */
  if( pTab->pSelect ){
    sqlite3ErrorMsg(pParse, "Cannot add a column to a view");
    goto exit_begin_add_column;
  }

  assert( pTab->addColOffset>0 );
  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);

  /* Put a copy of the Table struct in Parse.pNewTable for the
  ** sqlite3AddColumn() function and friends to modify.
  */
  pNew = (Table *)sqliteMalloc(sizeof(Table));
  if( !pNew ) goto exit_begin_add_column;
  pParse->pNewTable = pNew;
  pNew->nRef = 1;
  pNew->nCol = pTab->nCol;
  assert( pNew->nCol>0 );
  nAlloc = (((pNew->nCol-1)/8)*8)+8;
  assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );
  pNew->aCol = (Column *)sqliteMalloc(sizeof(Column)*nAlloc);
  pNew->zName = sqliteStrDup(pTab->zName);
  if( !pNew->aCol || !pNew->zName ){
    goto exit_begin_add_column;
  }
  memcpy(pNew->aCol, pTab->aCol, sizeof(Column)*pNew->nCol);
  for(i=0; i<pNew->nCol; i++){
    Column *pCol = &pNew->aCol[i];
    pCol->zName = sqliteStrDup(pCol->zName);
    pCol->zColl = 0;
    pCol->zType = 0;
    pCol->pDflt = 0;
  }
  pNew->pSchema = pParse->db->aDb[iDb].pSchema;
  pNew->addColOffset = pTab->addColOffset;
  pNew->nRef = 1;

  /* Begin a transaction and increment the schema cookie.  */
  sqlite3BeginWriteOperation(pParse, 0, iDb);
  v = sqlite3GetVdbe(pParse);
  if( !v ) goto exit_begin_add_column;
  sqlite3ChangeCookie(pParse->db, v, iDb);

exit_begin_add_column:
  sqlite3SrcListDelete(pSrc);
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 388 of file alter.c.

                                                               {
  Table *pNew;              /* Copy of pParse->pNewTable */
  Table *pTab;              /* Table being altered */
  int iDb;                  /* Database number */
  const char *zDb;          /* Database name */
  const char *zTab;         /* Table name */
  char *zCol;               /* Null-terminated column definition */
  Column *pCol;             /* The new column */
  Expr *pDflt;              /* Default value for the new column */

  if( pParse->nErr ) return;
  pNew = pParse->pNewTable;
  assert( pNew );

  iDb = sqlite3SchemaToIndex(pParse->db, pNew->pSchema);
  zDb = pParse->db->aDb[iDb].zName;
  zTab = pNew->zName;
  pCol = &pNew->aCol[pNew->nCol-1];
  pDflt = pCol->pDflt;
  pTab = sqlite3FindTable(pParse->db, zTab, zDb);
  assert( pTab );

#ifndef SQLITE_OMIT_AUTHORIZATION
  /* Invoke the authorization callback. */
  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){
    return;
  }
#endif

  /* If the default value for the new column was specified with a 
  ** literal NULL, then set pDflt to 0. This simplifies checking
  ** for an SQL NULL default below.
  */
  if( pDflt && pDflt->op==TK_NULL ){
    pDflt = 0;
  }

  /* Check that the new column is not specified as PRIMARY KEY or UNIQUE.
  ** If there is a NOT NULL constraint, then the default value for the
  ** column must not be NULL.
  */
  if( pCol->isPrimKey ){
    sqlite3ErrorMsg(pParse, "Cannot add a PRIMARY KEY column");
    return;
  }
  if( pNew->pIndex ){
    sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column");
    return;
  }
  if( pCol->notNull && !pDflt ){
    sqlite3ErrorMsg(pParse, 
        "Cannot add a NOT NULL column with default value NULL");
    return;
  }

  /* Ensure the default expression is something that sqlite3ValueFromExpr()
  ** can handle (i.e. not CURRENT_TIME etc.)
  */
  if( pDflt ){
    sqlite3_value *pVal;
    if( sqlite3ValueFromExpr(pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal) ){
      /* malloc() has failed */
      return;
    }
    if( !pVal ){
      sqlite3ErrorMsg(pParse, "Cannot add a column with non-constant default");
      return;
    }
    sqlite3ValueFree(pVal);
  }

  /* Modify the CREATE TABLE statement. */
  zCol = sqliteStrNDup((char*)pColDef->z, pColDef->n);
  if( zCol ){
    char *zEnd = &zCol[pColDef->n-1];
    while( (zEnd>zCol && *zEnd==';') || isspace(*(unsigned char *)zEnd) ){
      *zEnd-- = '\0';
    }
    sqlite3NestedParse(pParse, 
        "UPDATE %Q.%s SET "
          "sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d,length(sql)) "
        "WHERE type = 'table' AND name = %Q", 
      zDb, SCHEMA_TABLE(iDb), pNew->addColOffset, zCol, pNew->addColOffset+1,
      zTab
    );
    sqliteFree(zCol);
  }

  /* If the default value of the new column is NULL, then set the file
  ** format to 2. If the default value of the new column is not NULL,
  ** the file format becomes 3.
  */
  sqlite3MinimumFileFormat(pParse, iDb, pDflt ? 3 : 2);

  /* Reload the schema of the modified table. */
  reloadTableSchema(pParse, pTab, pTab->zName);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 151 of file alter.c.

                                       {
  static const struct {
     char *zName;
     signed char nArg;
     void (*xFunc)(sqlite3_context*,int,sqlite3_value **);
  } aFuncs[] = {
    { "sqlite_rename_table",    2, renameTableFunc},
#ifndef SQLITE_OMIT_TRIGGER
    { "sqlite_rename_trigger",  2, renameTriggerFunc},
#endif
  };
  int i;

  for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){
    sqlite3CreateFunc(db, aFuncs[i].zName, aFuncs[i].nArg,
        SQLITE_UTF8, 0, aFuncs[i].xFunc, 0, 0);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 255 of file alter.c.

 {
  int iDb;                  /* Database that contains the table */
  char *zDb;                /* Name of database iDb */
  Table *pTab;              /* Table being renamed */
  char *zName = 0;          /* NULL-terminated version of pName */ 
  sqlite3 *db = pParse->db; /* Database connection */
  Vdbe *v;
#ifndef SQLITE_OMIT_TRIGGER
  char *zWhere = 0;         /* Where clause to locate temp triggers */
#endif
  
  if( sqlite3MallocFailed() ) goto exit_rename_table;
  assert( pSrc->nSrc==1 );

  pTab = sqlite3LocateTable(pParse, pSrc->a[0].zName, pSrc->a[0].zDatabase);
  if( !pTab ) goto exit_rename_table;
  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
  zDb = db->aDb[iDb].zName;

  /* Get a NULL terminated version of the new table name. */
  zName = sqlite3NameFromToken(pName);
  if( !zName ) goto exit_rename_table;

  /* Check that a table or index named 'zName' does not already exist
  ** in database iDb. If so, this is an error.
  */
  if( sqlite3FindTable(db, zName, zDb) || sqlite3FindIndex(db, zName, zDb) ){
    sqlite3ErrorMsg(pParse, 
        "there is already another table or index with this name: %s", zName);
    goto exit_rename_table;
  }

  /* Make sure it is not a system table being altered, or a reserved name
  ** that the table is being renamed to.
  */
  if( strlen(pTab->zName)>6 && 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ){
    sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);
    goto exit_rename_table;
  }
  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
    goto exit_rename_table;
  }

#ifndef SQLITE_OMIT_AUTHORIZATION
  /* Invoke the authorization callback. */
  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){
    goto exit_rename_table;
  }
#endif

  /* Begin a transaction and code the VerifyCookie for database iDb. 
  ** Then modify the schema cookie (since the ALTER TABLE modifies the
  ** schema).
  */
  v = sqlite3GetVdbe(pParse);
  if( v==0 ){
    goto exit_rename_table;
  }
  sqlite3BeginWriteOperation(pParse, 0, iDb);
  sqlite3ChangeCookie(db, v, iDb);

  /* Modify the sqlite_master table to use the new table name. */
  sqlite3NestedParse(pParse,
      "UPDATE %Q.%s SET "
#ifdef SQLITE_OMIT_TRIGGER
          "sql = sqlite_rename_table(sql, %Q), "
#else
          "sql = CASE "
            "WHEN type = 'trigger' THEN sqlite_rename_trigger(sql, %Q)"
            "ELSE sqlite_rename_table(sql, %Q) END, "
#endif
          "tbl_name = %Q, "
          "name = CASE "
            "WHEN type='table' THEN %Q "
            "WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN "
              "'sqlite_autoindex_' || %Q || substr(name, %d+18,10) "
            "ELSE name END "
      "WHERE tbl_name=%Q AND "
          "(type='table' OR type='index' OR type='trigger');", 
      zDb, SCHEMA_TABLE(iDb), zName, zName, zName, 
#ifndef SQLITE_OMIT_TRIGGER
      zName,
#endif
      zName, strlen(pTab->zName), pTab->zName
  );

#ifndef SQLITE_OMIT_AUTOINCREMENT
  /* If the sqlite_sequence table exists in this database, then update 
  ** it with the new table name.
  */
  if( sqlite3FindTable(db, "sqlite_sequence", zDb) ){
    sqlite3NestedParse(pParse,
        "UPDATE %Q.sqlite_sequence set name = %Q WHERE name = %Q",
        zDb, zName, pTab->zName);
  }
#endif

#ifndef SQLITE_OMIT_TRIGGER
  /* If there are TEMP triggers on this table, modify the sqlite_temp_master
  ** table. Don't do this if the table being ALTERed is itself located in
  ** the temp database.
  */
  if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){
    sqlite3NestedParse(pParse, 
        "UPDATE sqlite_temp_master SET "
            "sql = sqlite_rename_trigger(sql, %Q), "
            "tbl_name = %Q "
            "WHERE %s;", zName, zName, zWhere);
    sqliteFree(zWhere);
  }
#endif

  /* Drop and reload the internal table schema. */
  reloadTableSchema(pParse, pTab, zName);

exit_rename_table:
  sqlite3SrcListDelete(pSrc);
  sqliteFree(zName);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite3AnalysisLoad ( sqlite3 ,
int  iDB 
)

Definition at line 374 of file analyze.c.

                                              {
  analysisInfo sInfo;
  HashElem *i;
  char *zSql;

  /* Clear any prior statistics */
  for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){
    Index *pIdx = sqliteHashData(i);
    sqlite3DefaultRowEst(pIdx);
  }

  /* Check to make sure the sqlite_stat1 table existss */
  sInfo.db = db;
  sInfo.zDatabase = db->aDb[iDb].zName;
  if( sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase)==0 ){
     return;
  }


  /* Load new statistics out of the sqlite_stat1 table */
  zSql = sqlite3MPrintf("SELECT idx, stat FROM %Q.sqlite_stat1",
                        sInfo.zDatabase);
  sqlite3SafetyOff(db);
  sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);
  sqlite3SafetyOn(db);
  sqliteFree(zSql);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite3Analyze ( Parse ,
Token ,
Token  
)

Definition at line 278 of file analyze.c.

                                                                {
  sqlite3 *db = pParse->db;
  int iDb;
  int i;
  char *z, *zDb;
  Table *pTab;
  Token *pTableName;

  /* Read the database schema. If an error occurs, leave an error message
  ** and code in pParse and return NULL. */
  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
    return;
  }

  if( pName1==0 ){
    /* Form 1:  Analyze everything */
    for(i=0; i<db->nDb; i++){
      if( i==1 ) continue;  /* Do not analyze the TEMP database */
      analyzeDatabase(pParse, i);
    }
  }else if( pName2==0 || pName2->n==0 ){
    /* Form 2:  Analyze the database or table named */
    iDb = sqlite3FindDb(db, pName1);
    if( iDb>=0 ){
      analyzeDatabase(pParse, iDb);
    }else{
      z = sqlite3NameFromToken(pName1);
      pTab = sqlite3LocateTable(pParse, z, 0);
      sqliteFree(z);
      if( pTab ){
        analyzeTable(pParse, pTab);
      }
    }
  }else{
    /* Form 3: Analyze the fully qualified table name */
    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pTableName);
    if( iDb>=0 ){
      zDb = db->aDb[iDb].zName;
      z = sqlite3NameFromToken(pTableName);
      pTab = sqlite3LocateTable(pParse, z, zDb);
      sqliteFree(z);
      if( pTab ){
        analyzeTable(pParse, pTab);
      }
    }   
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3ApiExit ( sqlite3 db,
int   
)

Definition at line 1440 of file util.c.

Here is the call graph for this function:

int sqlite3ArrayAllocate ( void **  ,
int  ,
int   
)

Definition at line 2742 of file build.c.

                                                                   {
  char *p;
  int *an = (int*)&ppArray[1];
  if( an[0]>=an[1] ){
    void *pNew;
    int newSize;
    newSize = an[1]*2 + initSize;
    pNew = sqliteRealloc(*ppArray, newSize*szEntry);
    if( pNew==0 ){
      return -1;
    }
    an[1] = newSize;
    *ppArray = pNew;
  }
  p = *ppArray;
  memset(&p[an[0]*szEntry], 0, szEntry);
  return an[0]++;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3AtoF ( const char *  z,
double *   
)

Definition at line 990 of file util.c.

                                               {
#ifndef SQLITE_OMIT_FLOATING_POINT
  int sign = 1;
  const char *zBegin = z;
  LONGDOUBLE_TYPE v1 = 0.0;
  while( isspace(*z) ) z++;
  if( *z=='-' ){
    sign = -1;
    z++;
  }else if( *z=='+' ){
    z++;
  }
  while( isdigit(*(u8*)z) ){
    v1 = v1*10.0 + (*z - '0');
    z++;
  }
  if( *z=='.' ){
    LONGDOUBLE_TYPE divisor = 1.0;
    z++;
    while( isdigit(*(u8*)z) ){
      v1 = v1*10.0 + (*z - '0');
      divisor *= 10.0;
      z++;
    }
    v1 /= divisor;
  }
  if( *z=='e' || *z=='E' ){
    int esign = 1;
    int eval = 0;
    LONGDOUBLE_TYPE scale = 1.0;
    z++;
    if( *z=='-' ){
      esign = -1;
      z++;
    }else if( *z=='+' ){
      z++;
    }
    while( isdigit(*(u8*)z) ){
      eval = eval*10 + *z - '0';
      z++;
    }
    while( eval>=64 ){ scale *= 1.0e+64; eval -= 64; }
    while( eval>=16 ){ scale *= 1.0e+16; eval -= 16; }
    while( eval>=4 ){ scale *= 1.0e+4; eval -= 4; }
    while( eval>=1 ){ scale *= 1.0e+1; eval -= 1; }
    if( esign<0 ){
      v1 /= scale;
    }else{
      v1 *= scale;
    }
  }
  *pResult = sign<0 ? -v1 : v1;
  return z - zBegin;
#else
  return sqlite3atoi64(z, pResult);
#endif /* SQLITE_OMIT_FLOATING_POINT */
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3atoi64 ( const char *  ,
i64  
)

Definition at line 1059 of file util.c.

                                              {
  i64 v = 0;
  int neg;
  int i, c;
  while( isspace(*zNum) ) zNum++;
  if( *zNum=='-' ){
    neg = 1;
    zNum++;
  }else if( *zNum=='+' ){
    neg = 0;
    zNum++;
  }else{
    neg = 0;
  }
  for(i=0; (c=zNum[i])>='0' && c<='9'; i++){
    v = v*10 + c - '0';
  }
  *pNum = neg ? -v : v;
  return c==0 && i>0 && 
      (i<19 || (i==19 && memcmp(zNum,"9223372036854775807",19)<=0));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite3Attach ( Parse ,
Expr ,
Expr ,
Expr  
)

Definition at line 344 of file attach.c.

                                                                     {
  codeAttach(pParse, SQLITE_ATTACH, "sqlite_attach", 3, p, p, pDbname, pKey);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 351 of file attach.c.

                                        {
  static const int enc = SQLITE_UTF8;
  sqlite3CreateFunc(db, "sqlite_attach", 3, enc, db, attachFunc, 0, 0);
  sqlite3CreateFunc(db, "sqlite_detach", 1, enc, db, detachFunc, 0, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3AuthCheck ( Parse ,
int  ,
const char *  ,
const char *  ,
const char *   
)

Definition at line 175 of file auth.c.

 {
  sqlite3 *db = pParse->db;
  int rc;

  /* Don't do any authorization checks if the database is initialising. */
  if( db->init.busy ){
    return SQLITE_OK;
  }

  if( db->xAuth==0 ){
    return SQLITE_OK;
  }
  rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext);
  if( rc==SQLITE_DENY ){
    sqlite3ErrorMsg(pParse, "not authorized");
    pParse->rc = SQLITE_AUTH;
  }else if( rc!=SQLITE_OK && rc!=SQLITE_IGNORE ){
    rc = SQLITE_DENY;
    sqliteAuthBadReturnCode(pParse, rc);
  }
  return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 225 of file auth.c.

                                                 {
  if( pContext->pParse ){
    pContext->pParse->zAuthContext = pContext->zAuthContext;
    pContext->pParse = 0;
  }
}

Here is the caller graph for this function:

void sqlite3AuthContextPush ( Parse ,
AuthContext ,
const char *   
)

Definition at line 209 of file auth.c.

 {
  pContext->pParse = pParse;
  if( pParse ){
    pContext->zAuthContext = pParse->zAuthContext;
    pParse->zAuthContext = zContext;
  }
}

Here is the caller graph for this function:

void sqlite3AuthRead ( Parse ,
Expr ,
SrcList  
)

Definition at line 103 of file auth.c.

 {
  sqlite3 *db = pParse->db;
  int rc;
  Table *pTab;          /* The table being read */
  const char *zCol;     /* Name of the column of the table */
  int iSrc;             /* Index in pTabList->a[] of table being read */
  const char *zDBase;   /* Name of database being accessed */
  TriggerStack *pStack; /* The stack of current triggers */
  int iDb;              /* The index of the database the expression refers to */

  if( db->xAuth==0 ) return;
  if( pExpr->op==TK_AS ) return;
  assert( pExpr->op==TK_COLUMN );
  iDb = sqlite3SchemaToIndex(pParse->db, pExpr->pSchema);
  if( iDb<0 ){
    /* An attempt to read a column out of a subquery or other
    ** temporary table. */
    return;
  }
  for(iSrc=0; pTabList && iSrc<pTabList->nSrc; iSrc++){
    if( pExpr->iTable==pTabList->a[iSrc].iCursor ) break;
  }
  if( iSrc>=0 && pTabList && iSrc<pTabList->nSrc ){
    pTab = pTabList->a[iSrc].pTab;
  }else if( (pStack = pParse->trigStack)!=0 ){
    /* This must be an attempt to read the NEW or OLD pseudo-tables
    ** of a trigger.
    */
    assert( pExpr->iTable==pStack->newIdx || pExpr->iTable==pStack->oldIdx );
    pTab = pStack->pTab;
  }else{
    return;
  }
  if( pTab==0 ) return;
  if( pExpr->iColumn>=0 ){
    assert( pExpr->iColumn<pTab->nCol );
    zCol = pTab->aCol[pExpr->iColumn].zName;
  }else if( pTab->iPKey>=0 ){
    assert( pTab->iPKey<pTab->nCol );
    zCol = pTab->aCol[pTab->iPKey].zName;
  }else{
    zCol = "ROWID";
  }
  assert( iDb>=0 && iDb<db->nDb );
  zDBase = db->aDb[iDb].zName;
  rc = db->xAuth(db->pAuthArg, SQLITE_READ, pTab->zName, zCol, zDBase, 
                 pParse->zAuthContext);
  if( rc==SQLITE_IGNORE ){
    pExpr->op = TK_NULL;
  }else if( rc==SQLITE_DENY ){
    if( db->nDb>2 || iDb!=0 ){
      sqlite3ErrorMsg(pParse, "access to %s.%s.%s is prohibited", 
         zDBase, pTab->zName, zCol);
    }else{
      sqlite3ErrorMsg(pParse, "access to %s.%s is prohibited",pTab->zName,zCol);
    }
    pParse->rc = SQLITE_AUTH;
  }else if( rc!=SQLITE_OK ){
    sqliteAuthBadReturnCode(pParse, rc);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite3BeginParse ( Parse ,
int   
)

Definition at line 37 of file build.c.

                                                      {
  pParse->explain = explainFlag;
  pParse->nVar = 0;
}

Here is the caller graph for this function:

Definition at line 2919 of file build.c.

                                                     {
  sqlite3 *db;
  Vdbe *v;
  int i;

  if( pParse==0 || (db=pParse->db)==0 || db->aDb[0].pBt==0 ) return;
  if( pParse->nErr || sqlite3MallocFailed() ) return;
  if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "BEGIN", 0, 0) ) return;

  v = sqlite3GetVdbe(pParse);
  if( !v ) return;
  if( type!=TK_DEFERRED ){
    for(i=0; i<db->nDb; i++){
      sqlite3VdbeAddOp(v, OP_Transaction, i, (type==TK_EXCLUSIVE)+1);
    }
  }
  sqlite3VdbeAddOp(v, OP_AutoCommit, 0, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite3BeginTrigger ( Parse ,
Token ,
Token ,
int  ,
int  ,
IdList ,
SrcList ,
int  ,
Expr ,
int   
)

Definition at line 42 of file trigger.c.

 {
  Trigger *pTrigger = 0;
  Table *pTab;
  char *zName = 0;        /* Name of the trigger */
  sqlite3 *db = pParse->db;
  int iDb;                /* The database to store the trigger in */
  Token *pName;           /* The unqualified db name */
  DbFixer sFix;
  int iTabDb;

  assert( pName1!=0 );   /* pName1->z might be NULL, but not pName1 itself */
  assert( pName2!=0 );
  if( isTemp ){
    /* If TEMP was specified, then the trigger name may not be qualified. */
    if( pName2->n>0 ){
      sqlite3ErrorMsg(pParse, "temporary trigger may not have qualified name");
      goto trigger_cleanup;
    }
    iDb = 1;
    pName = pName1;
  }else{
    /* Figure out the db that the the trigger will be created in */
    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);
    if( iDb<0 ){
      goto trigger_cleanup;
    }
  }

  /* If the trigger name was unqualified, and the table is a temp table,
  ** then set iDb to 1 to create the trigger in the temporary database.
  ** If sqlite3SrcListLookup() returns 0, indicating the table does not
  ** exist, the error is caught by the block below.
  */
  if( !pTableName || sqlite3MallocFailed() ){
    goto trigger_cleanup;
  }
  pTab = sqlite3SrcListLookup(pParse, pTableName);
  if( pName2->n==0 && pTab && pTab->pSchema==db->aDb[1].pSchema ){
    iDb = 1;
  }

  /* Ensure the table name matches database name and that the table exists */
  if( sqlite3MallocFailed() ) goto trigger_cleanup;
  assert( pTableName->nSrc==1 );
  if( sqlite3FixInit(&sFix, pParse, iDb, "trigger", pName) && 
      sqlite3FixSrcList(&sFix, pTableName) ){
    goto trigger_cleanup;
  }
  pTab = sqlite3SrcListLookup(pParse, pTableName);
  if( !pTab ){
    /* The table does not exist. */
    goto trigger_cleanup;
  }

  /* Check that the trigger name is not reserved and that no trigger of the
  ** specified name exists */
  zName = sqlite3NameFromToken(pName);
  if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
    goto trigger_cleanup;
  }
  if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash), zName,strlen(zName)) ){
    sqlite3ErrorMsg(pParse, "trigger %T already exists", pName);
    goto trigger_cleanup;
  }

  /* Do not create a trigger on a system table */
  if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){
    sqlite3ErrorMsg(pParse, "cannot create trigger on system table");
    pParse->nErr++;
    goto trigger_cleanup;
  }

  /* INSTEAD of triggers are only for views and views only support INSTEAD
  ** of triggers.
  */
  if( pTab->pSelect && tr_tm!=TK_INSTEAD ){
    sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S", 
        (tr_tm == TK_BEFORE)?"BEFORE":"AFTER", pTableName, 0);
    goto trigger_cleanup;
  }
  if( !pTab->pSelect && tr_tm==TK_INSTEAD ){
    sqlite3ErrorMsg(pParse, "cannot create INSTEAD OF"
        " trigger on table: %S", pTableName, 0);
    goto trigger_cleanup;
  }
  iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);

#ifndef SQLITE_OMIT_AUTHORIZATION
  {
    int code = SQLITE_CREATE_TRIGGER;
    const char *zDb = db->aDb[iTabDb].zName;
    const char *zDbTrig = isTemp ? db->aDb[1].zName : zDb;
    if( iTabDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER;
    if( sqlite3AuthCheck(pParse, code, zName, pTab->zName, zDbTrig) ){
      goto trigger_cleanup;
    }
    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iTabDb),0,zDb)){
      goto trigger_cleanup;
    }
  }
#endif

  /* INSTEAD OF triggers can only appear on views and BEFORE triggers
  ** cannot appear on views.  So we might as well translate every
  ** INSTEAD OF trigger into a BEFORE trigger.  It simplifies code
  ** elsewhere.
  */
  if (tr_tm == TK_INSTEAD){
    tr_tm = TK_BEFORE;
  }

  /* Build the Trigger object */
  pTrigger = (Trigger*)sqliteMalloc(sizeof(Trigger));
  if( pTrigger==0 ) goto trigger_cleanup;
  pTrigger->name = zName;
  zName = 0;
  pTrigger->table = sqliteStrDup(pTableName->a[0].zName);
  pTrigger->pSchema = db->aDb[iDb].pSchema;
  pTrigger->pTabSchema = pTab->pSchema;
  pTrigger->op = op;
  pTrigger->tr_tm = tr_tm==TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER;
  pTrigger->pWhen = sqlite3ExprDup(pWhen);
  pTrigger->pColumns = sqlite3IdListDup(pColumns);
  pTrigger->foreach = foreach;
  sqlite3TokenCopy(&pTrigger->nameToken,pName);
  assert( pParse->pNewTrigger==0 );
  pParse->pNewTrigger = pTrigger;

trigger_cleanup:
  sqliteFree(zName);
  sqlite3SrcListDelete(pTableName);
  sqlite3IdListDelete(pColumns);
  sqlite3ExprDelete(pWhen);
  if( !pParse->pNewTrigger ){
    sqlite3DeleteTrigger(pTrigger);
  }else{
    assert( pParse->pNewTrigger==pTrigger );
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3066 of file build.c.

                                                                         {
  Vdbe *v = sqlite3GetVdbe(pParse);
  if( v==0 ) return;
  sqlite3CodeVerifySchema(pParse, iDb);
  pParse->writeMask |= 1<<iDb;
  if( setStatement && pParse->nested==0 ){
    sqlite3VdbeAddOp(v, OP_Statement, iDb, 0);
  }
  if( (OMIT_TEMPDB || iDb!=1) && pParse->db->aDb[1].pBt!=0 ){
    sqlite3BeginWriteOperation(pParse, setStatement, 1);
  }
}

Here is the call graph for this function:

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:

void sqlite3ChangeCookie ( sqlite3 ,
Vdbe ,
int   
)

Definition at line 1246 of file build.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 122 of file callback.c.

                                                      {
  if( pColl ){
    const char *zName = pColl->zName;
    CollSeq *p = sqlite3GetCollSeq(pParse->db, pColl, zName, -1);
    if( !p ){
      if( pParse->nErr==0 ){
        sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
      }
      pParse->nErr++;
      return SQLITE_ERROR;
    }
    assert( p==pColl );
  }
  return SQLITE_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3CheckObjectName ( Parse ,
const char *   
)

Definition at line 684 of file build.c.

                                                            {
  if( !pParse->db->init.busy && pParse->nested==0 
          && (pParse->db->flags & SQLITE_WriteSchema)==0
          && 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
    sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s", zName);
    return SQLITE_ERROR;
  }
  return SQLITE_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3CodeRowTrigger ( Parse ,
int  ,
ExprList ,
int  ,
Table ,
int  ,
int  ,
int  ,
int   
)

Definition at line 729 of file trigger.c.

 {
  Trigger *p;
  TriggerStack trigStackEntry;

  assert(op == TK_UPDATE || op == TK_INSERT || op == TK_DELETE);
  assert(tr_tm == TRIGGER_BEFORE || tr_tm == TRIGGER_AFTER );

  assert(newIdx != -1 || oldIdx != -1);

  for(p=pTab->pTrigger; p; p=p->pNext){
    int fire_this = 0;

    /* Determine whether we should code this trigger */
    if( 
      p->op==op && 
      p->tr_tm==tr_tm && 
      (p->pSchema==p->pTabSchema || p->pSchema==pParse->db->aDb[1].pSchema) &&
      (op!=TK_UPDATE||!p->pColumns||checkColumnOverLap(p->pColumns,pChanges))
    ){
      TriggerStack *pS;      /* Pointer to trigger-stack entry */
      for(pS=pParse->trigStack; pS && p!=pS->pTrigger; pS=pS->pNext){}
      if( !pS ){
        fire_this = 1;
      }
#if 0    /* Give no warning for recursive triggers.  Just do not do them */
      else{
        sqlite3ErrorMsg(pParse, "recursive triggers not supported (%s)",
            p->name);
        return SQLITE_ERROR;
      }
#endif
    }
 
    if( fire_this ){
      int endTrigger;
      Expr * whenExpr;
      AuthContext sContext;
      NameContext sNC;

      memset(&sNC, 0, sizeof(sNC));
      sNC.pParse = pParse;

      /* Push an entry on to the trigger stack */
      trigStackEntry.pTrigger = p;
      trigStackEntry.newIdx = newIdx;
      trigStackEntry.oldIdx = oldIdx;
      trigStackEntry.pTab = pTab;
      trigStackEntry.pNext = pParse->trigStack;
      trigStackEntry.ignoreJump = ignoreJump;
      pParse->trigStack = &trigStackEntry;
      sqlite3AuthContextPush(pParse, &sContext, p->name);

      /* code the WHEN clause */
      endTrigger = sqlite3VdbeMakeLabel(pParse->pVdbe);
      whenExpr = sqlite3ExprDup(p->pWhen);
      if( sqlite3ExprResolveNames(&sNC, whenExpr) ){
        pParse->trigStack = trigStackEntry.pNext;
        sqlite3ExprDelete(whenExpr);
        return 1;
      }
      sqlite3ExprIfFalse(pParse, whenExpr, endTrigger, 1);
      sqlite3ExprDelete(whenExpr);

      codeTriggerProgram(pParse, p->step_list, orconf); 

      /* Pop the entry off the trigger stack */
      pParse->trigStack = trigStackEntry.pNext;
      sqlite3AuthContextPop(&sContext);

      sqlite3VdbeResolveLabel(pParse->pVdbe, endTrigger);
    }
  }
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite3CodeSubselect ( Parse ,
Expr  
)

Definition at line 1292 of file expr.c.

                                                     {
  int testAddr = 0;                       /* One-time test address */
  Vdbe *v = sqlite3GetVdbe(pParse);
  if( v==0 ) return;

  /* This code must be run in its entirety every time it is encountered
  ** if any of the following is true:
  **
  **    *  The right-hand side is a correlated subquery
  **    *  The right-hand side is an expression list containing variables
  **    *  We are inside a trigger
  **
  ** If all of the above are false, then we can run this code just once
  ** save the results, and reuse the same result on subsequent invocations.
  */
  if( !ExprHasAnyProperty(pExpr, EP_VarSelect) && !pParse->trigStack ){
    int mem = pParse->nMem++;
    sqlite3VdbeAddOp(v, OP_MemLoad, mem, 0);
    testAddr = sqlite3VdbeAddOp(v, OP_If, 0, 0);
    assert( testAddr>0 || sqlite3MallocFailed() );
    sqlite3VdbeAddOp(v, OP_MemInt, 1, mem);
  }

  switch( pExpr->op ){
    case TK_IN: {
      char affinity;
      KeyInfo keyInfo;
      int addr;        /* Address of OP_OpenVirtual instruction */

      affinity = sqlite3ExprAffinity(pExpr->pLeft);

      /* Whether this is an 'x IN(SELECT...)' or an 'x IN(<exprlist>)'
      ** expression it is handled the same way. A virtual table is 
      ** filled with single-field index keys representing the results
      ** from the SELECT or the <exprlist>.
      **
      ** If the 'x' expression is a column value, or the SELECT...
      ** statement returns a column value, then the affinity of that
      ** column is used to build the index keys. If both 'x' and the
      ** SELECT... statement are columns, then numeric affinity is used
      ** if either column has NUMERIC or INTEGER affinity. If neither
      ** 'x' nor the SELECT... statement are columns, then numeric affinity
      ** is used.
      */
      pExpr->iTable = pParse->nTab++;
      addr = sqlite3VdbeAddOp(v, OP_OpenVirtual, pExpr->iTable, 0);
      memset(&keyInfo, 0, sizeof(keyInfo));
      keyInfo.nField = 1;
      sqlite3VdbeAddOp(v, OP_SetNumColumns, pExpr->iTable, 1);

      if( pExpr->pSelect ){
        /* Case 1:     expr IN (SELECT ...)
        **
        ** Generate code to write the results of the select into the temporary
        ** table allocated and opened above.
        */
        int iParm = pExpr->iTable +  (((int)affinity)<<16);
        ExprList *pEList;
        assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
        sqlite3Select(pParse, pExpr->pSelect, SRT_Set, iParm, 0, 0, 0, 0);
        pEList = pExpr->pSelect->pEList;
        if( pEList && pEList->nExpr>0 ){ 
          keyInfo.aColl[0] = binaryCompareCollSeq(pParse, pExpr->pLeft,
              pEList->a[0].pExpr);
        }
      }else if( pExpr->pList ){
        /* Case 2:     expr IN (exprlist)
        **
       ** For each expression, build an index key from the evaluation and
        ** store it in the temporary table. If <expr> is a column, then use
        ** that columns affinity when building index keys. If <expr> is not
        ** a column, use numeric affinity.
        */
        int i;
        ExprList *pList = pExpr->pList;
        struct ExprList_item *pItem;

        if( !affinity ){
          affinity = SQLITE_AFF_NUMERIC;
        }
        keyInfo.aColl[0] = pExpr->pLeft->pColl;

        /* Loop through each expression in <exprlist>. */
        for(i=pList->nExpr, pItem=pList->a; i>0; i--, pItem++){
          Expr *pE2 = pItem->pExpr;

          /* If the expression is not constant then we will need to
          ** disable the test that was generated above that makes sure
          ** this code only executes once.  Because for a non-constant
          ** expression we need to rerun this code each time.
          */
          if( testAddr>0 && !sqlite3ExprIsConstant(pE2) ){
            sqlite3VdbeChangeToNoop(v, testAddr-1, 3);
            testAddr = 0;
          }

          /* Evaluate the expression and insert it into the temp table */
          sqlite3ExprCode(pParse, pE2);
          sqlite3VdbeOp3(v, OP_MakeRecord, 1, 0, &affinity, 1);
          sqlite3VdbeAddOp(v, OP_IdxInsert, pExpr->iTable, 0);
        }
      }
      sqlite3VdbeChangeP3(v, addr, (void *)&keyInfo, P3_KEYINFO);
      break;
    }

    case TK_EXISTS:
    case TK_SELECT: {
      /* This has to be a scalar SELECT.  Generate code to put the
      ** value of this select in a memory cell and record the number
      ** of the memory cell in iColumn.
      */
      static const Token one = { (u8*)"1", 0, 1 };
      Select *pSel;
      int iMem;
      int sop;

      pExpr->iColumn = iMem = pParse->nMem++;
      pSel = pExpr->pSelect;
      if( pExpr->op==TK_SELECT ){
        sop = SRT_Mem;
        sqlite3VdbeAddOp(v, OP_MemNull, iMem, 0);
        VdbeComment((v, "# Init subquery result"));
      }else{
        sop = SRT_Exists;
        sqlite3VdbeAddOp(v, OP_MemInt, 0, iMem);
        VdbeComment((v, "# Init EXISTS result"));
      }
      sqlite3ExprDelete(pSel->pLimit);
      pSel->pLimit = sqlite3Expr(TK_INTEGER, 0, 0, &one);
      sqlite3Select(pParse, pSel, sop, iMem, 0, 0, 0, 0);
      break;
    }
  }

  if( testAddr ){
    sqlite3VdbeJumpHere(v, testAddr);
  }
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3022 of file build.c.

                                                    {
  sqlite3 *db;
  Vdbe *v;
  int mask;

  v = sqlite3GetVdbe(pParse);
  if( v==0 ) return;  /* This only happens if there was a prior error */
  db = pParse->db;
  if( pParse->cookieGoto==0 ){
    pParse->cookieGoto = sqlite3VdbeAddOp(v, OP_Goto, 0, 0)+1;
  }
  if( iDb>=0 ){
    assert( iDb<db->nDb );
    assert( db->aDb[iDb].pBt!=0 || iDb==1 );
    assert( iDb<MAX_ATTACHED+2 );
    mask = 1<<iDb;
    if( (pParse->cookieMask & mask)==0 ){
      pParse->cookieMask |= mask;
      pParse->cookieValue[iDb] = db->aDb[iDb].pSchema->schema_cookie;
      if( !OMIT_TEMPDB && iDb==1 ){
        sqlite3OpenTempDatabase(pParse);
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite3ColumnDefault ( Vdbe ,
Table ,
int   
)

Definition at line 44 of file update.c.

                                                      {
  if( pTab && !pTab->pSelect ){
    sqlite3_value *pValue;
    u8 enc = ENC(sqlite3VdbeDb(v));
    Column *pCol = &pTab->aCol[i];
    sqlite3ValueFromExpr(pCol->pDflt, enc, pCol->affinity, &pValue);
    if( pValue ){
      sqlite3VdbeChangeP3(v, -1, (const char *)pValue, P3_MEM);
    }else{
      VdbeComment((v, "# %s.%s", pTab->zName, pCol->zName));
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 456 of file build.c.

Here is the caller graph for this function:

Definition at line 2941 of file build.c.

                                            {
  sqlite3 *db;
  Vdbe *v;

  if( pParse==0 || (db=pParse->db)==0 || db->aDb[0].pBt==0 ) return;
  if( pParse->nErr || sqlite3MallocFailed() ) return;
  if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "COMMIT", 0, 0) ) return;

  v = sqlite3GetVdbe(pParse);
  if( v ){
    sqlite3VdbeAddOp(v, OP_AutoCommit, 1, 0);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3Compare ( const char *  ,
const char *   
)
char sqlite3CompareAffinity ( Expr pExpr,
char  aff2 
)

Definition at line 75 of file expr.c.

                                                   {
  char aff1 = sqlite3ExprAffinity(pExpr);
  if( aff1 && aff2 ){
    /* Both sides of the comparison are columns. If one has numeric
    ** affinity, use that. Otherwise use no affinity.
    */
    if( sqlite3IsNumericAffinity(aff1) || sqlite3IsNumericAffinity(aff2) ){
      return SQLITE_AFF_NUMERIC;
    }else{
      return SQLITE_AFF_NONE;
    }
  }else if( !aff1 && !aff2 ){
    /* Neither side of the comparison is a column.  Compare the
    ** results directly.
    */
    return SQLITE_AFF_NONE;
  }else{
    /* One side is a column, the other is not. Use the columns affinity. */
    assert( aff1==0 || aff2==0 );
    return (aff1 + aff2);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite3CompleteInsertion ( Parse ,
Table ,
int  ,
char *  ,
int  ,
int  ,
int   
)

Definition at line 1048 of file insert.c.

 {
  int i;
  Vdbe *v;
  int nIdx;
  Index *pIdx;
  int pik_flags;

  v = sqlite3GetVdbe(pParse);
  assert( v!=0 );
  assert( pTab->pSelect==0 );  /* This table is not a VIEW */
  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}
  for(i=nIdx-1; i>=0; i--){
    if( aIdxUsed && aIdxUsed[i]==0 ) continue;
    sqlite3VdbeAddOp(v, OP_IdxInsert, base+i+1, 0);
  }
  sqlite3VdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0);
  sqlite3TableAffinityStr(v, pTab);
#ifndef SQLITE_OMIT_TRIGGER
  if( newIdx>=0 ){
    sqlite3VdbeAddOp(v, OP_Dup, 1, 0);
    sqlite3VdbeAddOp(v, OP_Dup, 1, 0);
    sqlite3VdbeAddOp(v, OP_Insert, newIdx, 0);
  }
#endif
  if( pParse->nested ){
    pik_flags = 0;
  }else{
    pik_flags = OPFLAG_NCHANGE;
    pik_flags |= (isUpdate?OPFLAG_ISUPDATE:OPFLAG_LASTROWID);
  }
  sqlite3VdbeAddOp(v, OP_Insert, base, pik_flags);
  if( !pParse->nested ){
    sqlite3VdbeChangeP3(v, -1, pTab->zName, P3_STATIC);
  }
  
  if( isUpdate && rowidChng ){
    sqlite3VdbeAddOp(v, OP_Pop, 1, 0);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite3CreateForeignKey ( Parse ,
ExprList ,
Token ,
ExprList ,
int   
)

Definition at line 2001 of file build.c.

 {
#ifndef SQLITE_OMIT_FOREIGN_KEY
  FKey *pFKey = 0;
  Table *p = pParse->pNewTable;
  int nByte;
  int i;
  int nCol;
  char *z;

  assert( pTo!=0 );
  if( p==0 || pParse->nErr ) goto fk_end;
  if( pFromCol==0 ){
    int iCol = p->nCol-1;
    if( iCol<0 ) goto fk_end;
    if( pToCol && pToCol->nExpr!=1 ){
      sqlite3ErrorMsg(pParse, "foreign key on %s"
         " should reference only one column of table %T",
         p->aCol[iCol].zName, pTo);
      goto fk_end;
    }
    nCol = 1;
  }else if( pToCol && pToCol->nExpr!=pFromCol->nExpr ){
    sqlite3ErrorMsg(pParse,
        "number of columns in foreign key does not match the number of "
        "columns in the referenced table");
    goto fk_end;
  }else{
    nCol = pFromCol->nExpr;
  }
  nByte = sizeof(*pFKey) + nCol*sizeof(pFKey->aCol[0]) + pTo->n + 1;
  if( pToCol ){
    for(i=0; i<pToCol->nExpr; i++){
      nByte += strlen(pToCol->a[i].zName) + 1;
    }
  }
  pFKey = sqliteMalloc( nByte );
  if( pFKey==0 ) goto fk_end;
  pFKey->pFrom = p;
  pFKey->pNextFrom = p->pFKey;
  z = (char*)&pFKey[1];
  pFKey->aCol = (struct sColMap*)z;
  z += sizeof(struct sColMap)*nCol;
  pFKey->zTo = z;
  memcpy(z, pTo->z, pTo->n);
  z[pTo->n] = 0;
  z += pTo->n+1;
  pFKey->pNextTo = 0;
  pFKey->nCol = nCol;
  if( pFromCol==0 ){
    pFKey->aCol[0].iFrom = p->nCol-1;
  }else{
    for(i=0; i<nCol; i++){
      int j;
      for(j=0; j<p->nCol; j++){
        if( sqlite3StrICmp(p->aCol[j].zName, pFromCol->a[i].zName)==0 ){
          pFKey->aCol[i].iFrom = j;
          break;
        }
      }
      if( j>=p->nCol ){
        sqlite3ErrorMsg(pParse, 
          "unknown column \"%s\" in foreign key definition", 
          pFromCol->a[i].zName);
        goto fk_end;
      }
    }
  }
  if( pToCol ){
    for(i=0; i<nCol; i++){
      int n = strlen(pToCol->a[i].zName);
      pFKey->aCol[i].zCol = z;
      memcpy(z, pToCol->a[i].zName, n);
      z[n] = 0;
      z += n+1;
    }
  }
  pFKey->isDeferred = 0;
  pFKey->deleteConf = flags & 0xff;
  pFKey->updateConf = (flags >> 8 ) & 0xff;
  pFKey->insertConf = (flags >> 16 ) & 0xff;

  /* Link the foreign key to the table as the last step.
  */
  p->pFKey = pFKey;
  pFKey = 0;

fk_end:
  sqliteFree(pFKey);
#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */
  sqlite3ExprListDelete(pFromCol);
  sqlite3ExprListDelete(pToCol);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3CreateFunc ( sqlite3 ,
const char *  ,
int  ,
int  ,
void ,
void(*)(sqlite3_context *, int, sqlite3_value **)  ,
void(*)(sqlite3_context *, int, sqlite3_value **)  ,
void(*)(sqlite3_context *)   
)

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:

void sqlite3CreateIndex ( Parse ,
Token ,
Token ,
SrcList ,
ExprList ,
int  ,
Token ,
Token ,
int  ,
int   
)

Definition at line 2192 of file build.c.

 {
  Table *pTab = 0;     /* Table to be indexed */
  Index *pIndex = 0;   /* The index to be created */
  char *zName = 0;     /* Name of the index */
  int nName;           /* Number of characters in zName */
  int i, j;
  Token nullId;        /* Fake token for an empty ID list */
  DbFixer sFix;        /* For assigning database names to pTable */
  int sortOrderMask;   /* 1 to honor DESC in index.  0 to ignore. */
  sqlite3 *db = pParse->db;
  Db *pDb;             /* The specific table containing the indexed database */
  int iDb;             /* Index of the database that is being written */
  Token *pName = 0;    /* Unqualified name of the index to create */
  struct ExprList_item *pListItem; /* For looping over pList */
  int nCol;
  int nExtra = 0;
  char *zExtra;

  if( pParse->nErr || sqlite3MallocFailed() ){
    goto exit_create_index;
  }

  /*
  ** Find the table that is to be indexed.  Return early if not found.
  */
  if( pTblName!=0 ){

    /* Use the two-part index name to determine the database 
    ** to search for the table. 'Fix' the table name to this db
    ** before looking up the table.
    */
    assert( pName1 && pName2 );
    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);
    if( iDb<0 ) goto exit_create_index;

#ifndef SQLITE_OMIT_TEMPDB
    /* If the index name was unqualified, check if the the table
    ** is a temp table. If so, set the database to 1.
    */
    pTab = sqlite3SrcListLookup(pParse, pTblName);
    if( pName2 && pName2->n==0 && pTab && pTab->pSchema==db->aDb[1].pSchema ){
      iDb = 1;
    }
#endif

    if( sqlite3FixInit(&sFix, pParse, iDb, "index", pName) &&
        sqlite3FixSrcList(&sFix, pTblName)
    ){
      /* Because the parser constructs pTblName from a single identifier,
      ** sqlite3FixSrcList can never fail. */
      assert(0);
    }
    pTab = sqlite3LocateTable(pParse, pTblName->a[0].zName, 
        pTblName->a[0].zDatabase);
    if( !pTab ) goto exit_create_index;
    assert( db->aDb[iDb].pSchema==pTab->pSchema );
  }else{
    assert( pName==0 );
    pTab = pParse->pNewTable;
    if( !pTab ) goto exit_create_index;
    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
  }
  pDb = &db->aDb[iDb];

  if( pTab==0 || pParse->nErr ) goto exit_create_index;
  if( pTab->readOnly ){
    sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
    goto exit_create_index;
  }
#ifndef SQLITE_OMIT_VIEW
  if( pTab->pSelect ){
    sqlite3ErrorMsg(pParse, "views may not be indexed");
    goto exit_create_index;
  }
#endif

  /*
  ** Find the name of the index.  Make sure there is not already another
  ** index or table with the same name.  
  **
  ** Exception:  If we are reading the names of permanent indices from the
  ** sqlite_master table (because some other process changed the schema) and
  ** one of the index names collides with the name of a temporary table or
  ** index, then we will continue to process this index.
  **
  ** If pName==0 it means that we are
  ** dealing with a primary key or UNIQUE constraint.  We have to invent our
  ** own name.
  */
  if( pName ){
    zName = sqlite3NameFromToken(pName);
    if( SQLITE_OK!=sqlite3ReadSchema(pParse) ) goto exit_create_index;
    if( zName==0 ) goto exit_create_index;
    if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
      goto exit_create_index;
    }
    if( !db->init.busy ){
      if( SQLITE_OK!=sqlite3ReadSchema(pParse) ) goto exit_create_index;
      if( sqlite3FindIndex(db, zName, pDb->zName)!=0 ){
        if( !ifNotExist ){
          sqlite3ErrorMsg(pParse, "index %s already exists", zName);
        }
        goto exit_create_index;
      }
      if( sqlite3FindTable(db, zName, 0)!=0 ){
        sqlite3ErrorMsg(pParse, "there is already a table named %s", zName);
        goto exit_create_index;
      }
    }
  }else{
    char zBuf[30];
    int n;
    Index *pLoop;
    for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){}
    sprintf(zBuf,"_%d",n);
    zName = 0;
    sqlite3SetString(&zName, "sqlite_autoindex_", pTab->zName, zBuf, (char*)0);
    if( zName==0 ) goto exit_create_index;
  }

  /* Check for authorization to create an index.
  */
#ifndef SQLITE_OMIT_AUTHORIZATION
  {
    const char *zDb = pDb->zName;
    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iDb), 0, zDb) ){
      goto exit_create_index;
    }
    i = SQLITE_CREATE_INDEX;
    if( !OMIT_TEMPDB && iDb==1 ) i = SQLITE_CREATE_TEMP_INDEX;
    if( sqlite3AuthCheck(pParse, i, zName, pTab->zName, zDb) ){
      goto exit_create_index;
    }
  }
#endif

  /* If pList==0, it means this routine was called to make a primary
  ** key out of the last column added to the table under construction.
  ** So create a fake list to simulate this.
  */
  if( pList==0 ){
    nullId.z = (u8*)pTab->aCol[pTab->nCol-1].zName;
    nullId.n = strlen((char*)nullId.z);
    pList = sqlite3ExprListAppend(0, 0, &nullId);
    if( pList==0 ) goto exit_create_index;
    pList->a[0].sortOrder = sortOrder;
  }

  /* Figure out how many bytes of space are required to store explicitly
  ** specified collation sequence names.
  */
  for(i=0; i<pList->nExpr; i++){
    Expr *pExpr = pList->a[i].pExpr;
    if( pExpr ){
      nExtra += (1 + strlen(pExpr->pColl->zName));
    }
  }

  /* 
  ** Allocate the index structure. 
  */
  nName = strlen(zName);
  nCol = pList->nExpr;
  pIndex = sqliteMalloc( 
      sizeof(Index) +              /* Index structure  */
      sizeof(int)*nCol +           /* Index.aiColumn   */
      sizeof(int)*(nCol+1) +       /* Index.aiRowEst   */
      sizeof(char *)*nCol +        /* Index.azColl     */
      sizeof(u8)*nCol +            /* Index.aSortOrder */
      nName + 1 +                  /* Index.zName      */
      nExtra                       /* Collation sequence names */
  );
  if( sqlite3MallocFailed() ) goto exit_create_index;
  pIndex->azColl = (char**)(&pIndex[1]);
  pIndex->aiColumn = (int *)(&pIndex->azColl[nCol]);
  pIndex->aiRowEst = (unsigned *)(&pIndex->aiColumn[nCol]);
  pIndex->aSortOrder = (u8 *)(&pIndex->aiRowEst[nCol+1]);
  pIndex->zName = (char *)(&pIndex->aSortOrder[nCol]);
  zExtra = (char *)(&pIndex->zName[nName+1]);
  strcpy(pIndex->zName, zName);
  pIndex->pTable = pTab;
  pIndex->nColumn = pList->nExpr;
  pIndex->onError = onError;
  pIndex->autoIndex = pName==0;
  pIndex->pSchema = db->aDb[iDb].pSchema;

  /* Check to see if we should honor DESC requests on index columns
  */
  if( pDb->pSchema->file_format>=4 ){
    sortOrderMask = -1;   /* Honor DESC */
  }else{
    sortOrderMask = 0;    /* Ignore DESC */
  }

  /* Scan the names of the columns of the table to be indexed and
  ** load the column indices into the Index structure.  Report an error
  ** if any column is not found.
  */
  for(i=0, pListItem=pList->a; i<pList->nExpr; i++, pListItem++){
    const char *zColName = pListItem->zName;
    Column *pTabCol;
    int requestedSortOrder;
    char *zColl;                   /* Collation sequence */

    for(j=0, pTabCol=pTab->aCol; j<pTab->nCol; j++, pTabCol++){
      if( sqlite3StrICmp(zColName, pTabCol->zName)==0 ) break;
    }
    if( j>=pTab->nCol ){
      sqlite3ErrorMsg(pParse, "table %s has no column named %s",
        pTab->zName, zColName);
      goto exit_create_index;
    }
    pIndex->aiColumn[i] = j;
    if( pListItem->pExpr ){
      assert( pListItem->pExpr->pColl );
      zColl = zExtra;
      strcpy(zExtra, pListItem->pExpr->pColl->zName);
      zExtra += (strlen(zColl) + 1);
    }else{
      zColl = pTab->aCol[j].zColl;
      if( !zColl ){
        zColl = db->pDfltColl->zName;
      }
    }
    if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl, -1) ){
      goto exit_create_index;
    }
    pIndex->azColl[i] = zColl;
    requestedSortOrder = pListItem->sortOrder & sortOrderMask;
    pIndex->aSortOrder[i] = requestedSortOrder;
  }
  sqlite3DefaultRowEst(pIndex);

  if( pTab==pParse->pNewTable ){
    /* This routine has been called to create an automatic index as a
    ** result of a PRIMARY KEY or UNIQUE clause on a column definition, or
    ** a PRIMARY KEY or UNIQUE clause following the column definitions.
    ** i.e. one of:
    **
    ** CREATE TABLE t(x PRIMARY KEY, y);
    ** CREATE TABLE t(x, y, UNIQUE(x, y));
    **
    ** Either way, check to see if the table already has such an index. If
    ** so, don't bother creating this one. This only applies to
    ** automatically created indices. Users can do as they wish with
    ** explicit indices.
    */
    Index *pIdx;
    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
      int k;
      assert( pIdx->onError!=OE_None );
      assert( pIdx->autoIndex );
      assert( pIndex->onError!=OE_None );

      if( pIdx->nColumn!=pIndex->nColumn ) continue;
      for(k=0; k<pIdx->nColumn; k++){
        const char *z1 = pIdx->azColl[k];
        const char *z2 = pIndex->azColl[k];
        if( pIdx->aiColumn[k]!=pIndex->aiColumn[k] ) break;
        if( pIdx->aSortOrder[k]!=pIndex->aSortOrder[k] ) break;
        if( z1!=z2 && sqlite3StrICmp(z1, z2) ) break;
      }
      if( k==pIdx->nColumn ){
        if( pIdx->onError!=pIndex->onError ){
          /* This constraint creates the same index as a previous
          ** constraint specified somewhere in the CREATE TABLE statement.
          ** However the ON CONFLICT clauses are different. If both this 
          ** constraint and the previous equivalent constraint have explicit
          ** ON CONFLICT clauses this is an error. Otherwise, use the
          ** explicitly specified behaviour for the index.
          */
          if( !(pIdx->onError==OE_Default || pIndex->onError==OE_Default) ){
            sqlite3ErrorMsg(pParse, 
                "conflicting ON CONFLICT clauses specified", 0);
          }
          if( pIdx->onError==OE_Default ){
            pIdx->onError = pIndex->onError;
          }
        }
        goto exit_create_index;
      }
    }
  }

  /* Link the new Index structure to its table and to the other
  ** in-memory database structures. 
  */
  if( db->init.busy ){
    Index *p;
    p = sqlite3HashInsert(&pIndex->pSchema->idxHash, 
                         pIndex->zName, strlen(pIndex->zName)+1, pIndex);
    if( p ){
      assert( p==pIndex );  /* Malloc must have failed */
      goto exit_create_index;
    }
    db->flags |= SQLITE_InternChanges;
    if( pTblName!=0 ){
      pIndex->tnum = db->init.newTnum;
    }
  }

  /* If the db->init.busy is 0 then create the index on disk.  This
  ** involves writing the index into the master table and filling in the
  ** index with the current table contents.
  **
  ** The db->init.busy is 0 when the user first enters a CREATE INDEX 
  ** command.  db->init.busy is 1 when a database is opened and 
  ** CREATE INDEX statements are read out of the master table.  In
  ** the latter case the index already exists on disk, which is why
  ** we don't want to recreate it.
  **
  ** If pTblName==0 it means this index is generated as a primary key
  ** or UNIQUE constraint of a CREATE TABLE statement.  Since the table
  ** has just been created, it contains no data and the index initialization
  ** step can be skipped.
  */
  else if( db->init.busy==0 ){
    Vdbe *v;
    char *zStmt;
    int iMem = pParse->nMem++;

    v = sqlite3GetVdbe(pParse);
    if( v==0 ) goto exit_create_index;


    /* Create the rootpage for the index
    */
    sqlite3BeginWriteOperation(pParse, 1, iDb);
    sqlite3VdbeAddOp(v, OP_CreateIndex, iDb, 0);
    sqlite3VdbeAddOp(v, OP_MemStore, iMem, 0);

    /* Gather the complete text of the CREATE INDEX statement into
    ** the zStmt variable
    */
    if( pStart && pEnd ){
      /* A named index with an explicit CREATE INDEX statement */
      zStmt = sqlite3MPrintf("CREATE%s INDEX %.*s",
        onError==OE_None ? "" : " UNIQUE",
        pEnd->z - pName->z + 1,
        pName->z);
    }else{
      /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
      /* zStmt = sqlite3MPrintf(""); */
      zStmt = 0;
    }

    /* Add an entry in sqlite_master for this index
    */
    sqlite3NestedParse(pParse, 
        "INSERT INTO %Q.%s VALUES('index',%Q,%Q,#0,%Q);",
        db->aDb[iDb].zName, SCHEMA_TABLE(iDb),
        pIndex->zName,
        pTab->zName,
        zStmt
    );
    sqlite3VdbeAddOp(v, OP_Pop, 1, 0);
    sqliteFree(zStmt);

    /* Fill the index with data and reparse the schema. Code an OP_Expire
    ** to invalidate all pre-compiled statements.
    */
    if( pTblName ){
      sqlite3RefillIndex(pParse, pIndex, iMem);
      sqlite3ChangeCookie(db, v, iDb);
      sqlite3VdbeOp3(v, OP_ParseSchema, iDb, 0,
         sqlite3MPrintf("name='%q'", pIndex->zName), P3_DYNAMIC);
      sqlite3VdbeAddOp(v, OP_Expire, 0, 0);
    }
  }

  /* When adding an index to the list of indices for a table, make
  ** sure all indices labeled OE_Replace come after all those labeled
  ** OE_Ignore.  This is necessary for the correct operation of UPDATE
  ** and INSERT.
  */
  if( db->init.busy || pTblName==0 ){
    if( onError!=OE_Replace || pTab->pIndex==0
         || pTab->pIndex->onError==OE_Replace){
      pIndex->pNext = pTab->pIndex;
      pTab->pIndex = pIndex;
    }else{
      Index *pOther = pTab->pIndex;
      while( pOther->pNext && pOther->pNext->onError!=OE_Replace ){
        pOther = pOther->pNext;
      }
      pIndex->pNext = pOther->pNext;
      pOther->pNext = pIndex;
    }
    pIndex = 0;
  }

  /* Clean up before exiting */
exit_create_index:
  if( pIndex ){
    freeIndex(pIndex);
  }
  sqlite3ExprListDelete(pList);
  sqlite3SrcListDelete(pTblName);
  sqliteFree(zName);
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite3CreateView ( Parse ,
Token ,
Token ,
Token ,
Select ,
int   
)

Definition at line 1569 of file build.c.

 {
  Table *p;
  int n;
  const unsigned char *z;
  Token sEnd;
  DbFixer sFix;
  Token *pName;
  int iDb;

  if( pParse->nVar>0 ){
    sqlite3ErrorMsg(pParse, "parameters are not allowed in views");
    sqlite3SelectDelete(pSelect);
    return;
  }
  sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0);
  p = pParse->pNewTable;
  if( p==0 || pParse->nErr ){
    sqlite3SelectDelete(pSelect);
    return;
  }
  sqlite3TwoPartName(pParse, pName1, pName2, &pName);
  iDb = sqlite3SchemaToIndex(pParse->db, p->pSchema);
  if( sqlite3FixInit(&sFix, pParse, iDb, "view", pName)
    && sqlite3FixSelect(&sFix, pSelect)
  ){
    sqlite3SelectDelete(pSelect);
    return;
  }

  /* Make a copy of the entire SELECT statement that defines the view.
  ** This will force all the Expr.token.z values to be dynamically
  ** allocated rather than point to the input string - which means that
  ** they will persist after the current sqlite3_exec() call returns.
  */
  p->pSelect = sqlite3SelectDup(pSelect);
  sqlite3SelectDelete(pSelect);
  if( sqlite3MallocFailed() ){
    return;
  }
  if( !pParse->db->init.busy ){
    sqlite3ViewGetColumnNames(pParse, p);
  }

  /* Locate the end of the CREATE VIEW statement.  Make sEnd point to
  ** the end.
  */
  sEnd = pParse->sLastToken;
  if( sEnd.z[0]!=0 && sEnd.z[0]!=';' ){
    sEnd.z += sEnd.n;
  }
  sEnd.n = 0;
  n = sEnd.z - pBegin->z;
  z = (const unsigned char*)pBegin->z;
  while( n>0 && (z[n-1]==';' || isspace(z[n-1])) ){ n--; }
  sEnd.z = &z[n-1];
  sEnd.n = 1;

  /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */
  sqlite3EndTable(pParse, 0, &sEnd, 0);
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite3DebugPrintf ( const char *  ,
  ... 
)

Here is the caller graph for this function:

Definition at line 2639 of file build.c.

                                      {
  unsigned *a = pIdx->aiRowEst;
  int i;
  assert( a!=0 );
  a[0] = 1000000;
  for(i=pIdx->nColumn; i>=5; i--){
    a[i] = 5;
  }
  while( i>=1 ){
    a[i] = 11 - i;
    i--;
  }
  if( pIdx->onError!=OE_None ){
    a[pIdx->nColumn] = 1;
  }
}

Here is the caller graph for this function:

Definition at line 2107 of file build.c.

                                                          {
#ifndef SQLITE_OMIT_FOREIGN_KEY
  Table *pTab;
  FKey *pFKey;
  if( (pTab = pParse->pNewTable)==0 || (pFKey = pTab->pFKey)==0 ) return;
  pFKey->isDeferred = isDeferred;
#endif
}

Here is the caller graph for this function:

void sqlite3DeleteFrom ( Parse ,
SrcList ,
Expr  
)

Definition at line 86 of file delete.c.

 {
  Vdbe *v;               /* The virtual database engine */
  Table *pTab;           /* The table from which records will be deleted */
  const char *zDb;       /* Name of database holding pTab */
  int end, addr = 0;     /* A couple addresses of generated code */
  int i;                 /* Loop counter */
  WhereInfo *pWInfo;     /* Information about the WHERE clause */
  Index *pIdx;           /* For looping over indices of the table */
  int iCur;              /* VDBE Cursor number for pTab */
  sqlite3 *db;           /* Main database structure */
  AuthContext sContext;  /* Authorization context */
  int oldIdx = -1;       /* Cursor for the OLD table of AFTER triggers */
  NameContext sNC;       /* Name context to resolve expressions in */
  int iDb;

#ifndef SQLITE_OMIT_TRIGGER
  int isView;                  /* True if attempting to delete from a view */
  int triggers_exist = 0;      /* True if any triggers exist */
#endif

  sContext.pParse = 0;
  if( pParse->nErr || sqlite3MallocFailed() ){
    goto delete_from_cleanup;
  }
  db = pParse->db;
  assert( pTabList->nSrc==1 );

  /* Locate the table which we want to delete.  This table has to be
  ** put in an SrcList structure because some of the subroutines we
  ** will be calling are designed to work with multiple tables and expect
  ** an SrcList* parameter instead of just a Table* parameter.
  */
  pTab = sqlite3SrcListLookup(pParse, pTabList);
  if( pTab==0 )  goto delete_from_cleanup;

  /* Figure out if we have any triggers and if the table being
  ** deleted from is a view
  */
#ifndef SQLITE_OMIT_TRIGGER
  triggers_exist = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0);
  isView = pTab->pSelect!=0;
#else
# define triggers_exist 0
# define isView 0
#endif
#ifdef SQLITE_OMIT_VIEW
# undef isView
# define isView 0
#endif

  if( sqlite3IsReadOnly(pParse, pTab, triggers_exist) ){
    goto delete_from_cleanup;
  }
  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
  assert( iDb<db->nDb );
  zDb = db->aDb[iDb].zName;
  if( sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb) ){
    goto delete_from_cleanup;
  }

  /* If pTab is really a view, make sure it has been initialized.
  */
  if( isView && sqlite3ViewGetColumnNames(pParse, pTab) ){
    goto delete_from_cleanup;
  }

  /* Allocate a cursor used to store the old.* data for a trigger.
  */
  if( triggers_exist ){ 
    oldIdx = pParse->nTab++;
  }

  /* Resolve the column names in the WHERE clause.
  */
  assert( pTabList->nSrc==1 );
  iCur = pTabList->a[0].iCursor = pParse->nTab++;
  memset(&sNC, 0, sizeof(sNC));
  sNC.pParse = pParse;
  sNC.pSrcList = pTabList;
  if( sqlite3ExprResolveNames(&sNC, pWhere) ){
    goto delete_from_cleanup;
  }

  /* Start the view context
  */
  if( isView ){
    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);
  }

  /* Begin generating code.
  */
  v = sqlite3GetVdbe(pParse);
  if( v==0 ){
    goto delete_from_cleanup;
  }
  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
  sqlite3BeginWriteOperation(pParse, triggers_exist, iDb);

  /* If we are trying to delete from a view, realize that view into
  ** a ephemeral table.
  */
  if( isView ){
    Select *pView = sqlite3SelectDup(pTab->pSelect);
    sqlite3Select(pParse, pView, SRT_VirtualTab, iCur, 0, 0, 0, 0);
    sqlite3SelectDelete(pView);
  }

  /* Initialize the counter of the number of rows deleted, if
  ** we are counting rows.
  */
  if( db->flags & SQLITE_CountRows ){
    sqlite3VdbeAddOp(v, OP_Integer, 0, 0);
  }

  /* Special case: A DELETE without a WHERE clause deletes everything.
  ** It is easier just to erase the whole table.  Note, however, that
  ** this means that the row change count will be incorrect.
  */
  if( pWhere==0 && !triggers_exist ){
    if( db->flags & SQLITE_CountRows ){
      /* If counting rows deleted, just count the total number of
      ** entries in the table. */
      int endOfLoop = sqlite3VdbeMakeLabel(v);
      int addr2;
      if( !isView ){
        sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead);
      }
      sqlite3VdbeAddOp(v, OP_Rewind, iCur, sqlite3VdbeCurrentAddr(v)+2);
      addr2 = sqlite3VdbeAddOp(v, OP_AddImm, 1, 0);
      sqlite3VdbeAddOp(v, OP_Next, iCur, addr2);
      sqlite3VdbeResolveLabel(v, endOfLoop);
      sqlite3VdbeAddOp(v, OP_Close, iCur, 0);
    }
    if( !isView ){
      sqlite3VdbeAddOp(v, OP_Clear, pTab->tnum, iDb);
      if( !pParse->nested ){
        sqlite3VdbeChangeP3(v, -1, pTab->zName, P3_STATIC);
      }
      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
        assert( pIdx->pSchema==pTab->pSchema );
        sqlite3VdbeAddOp(v, OP_Clear, pIdx->tnum, iDb);
      }
    }
  }

  /* The usual case: There is a WHERE clause so we have to scan through
  ** the table and pick which records to delete.
  */
  else{
    /* Begin the database scan
    */
    pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0);
    if( pWInfo==0 ) goto delete_from_cleanup;

    /* Remember the rowid of every item to be deleted.
    */
    sqlite3VdbeAddOp(v, OP_Rowid, iCur, 0);
    sqlite3VdbeAddOp(v, OP_FifoWrite, 0, 0);
    if( db->flags & SQLITE_CountRows ){
      sqlite3VdbeAddOp(v, OP_AddImm, 1, 0);
    }

    /* End the database scan loop.
    */
    sqlite3WhereEnd(pWInfo);

    /* Open the pseudo-table used to store OLD if there are triggers.
    */
    if( triggers_exist ){
      sqlite3VdbeAddOp(v, OP_OpenPseudo, oldIdx, 0);
      sqlite3VdbeAddOp(v, OP_SetNumColumns, oldIdx, pTab->nCol);
    }

    /* Delete every item whose key was written to the list during the
    ** database scan.  We have to delete items after the scan is complete
    ** because deleting an item can change the scan order.
    */
    end = sqlite3VdbeMakeLabel(v);

    /* This is the beginning of the delete loop when there are
    ** row triggers.
    */
    if( triggers_exist ){
      addr = sqlite3VdbeAddOp(v, OP_FifoRead, 0, end);
      if( !isView ){
        sqlite3VdbeAddOp(v, OP_Dup, 0, 0);
        sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead);
      }
      sqlite3VdbeAddOp(v, OP_MoveGe, iCur, 0);
      sqlite3VdbeAddOp(v, OP_Rowid, iCur, 0);
      sqlite3VdbeAddOp(v, OP_RowData, iCur, 0);
      sqlite3VdbeAddOp(v, OP_Insert, oldIdx, 0);
      if( !isView ){
        sqlite3VdbeAddOp(v, OP_Close, iCur, 0);
      }

      (void)sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TRIGGER_BEFORE, pTab,
          -1, oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default,
          addr);
    }

    if( !isView ){
      /* Open cursors for the table we are deleting from and all its
      ** indices.  If there are row triggers, this happens inside the
      ** OP_FifoRead loop because the cursor have to all be closed
      ** before the trigger fires.  If there are no row triggers, the
      ** cursors are opened only once on the outside the loop.
      */
      sqlite3OpenTableAndIndices(pParse, pTab, iCur, OP_OpenWrite);

      /* This is the beginning of the delete loop when there are no
      ** row triggers */
      if( !triggers_exist ){ 
        addr = sqlite3VdbeAddOp(v, OP_FifoRead, 0, end);
      }

      /* Delete the row */
      sqlite3GenerateRowDelete(db, v, pTab, iCur, pParse->nested==0);
    }

    /* If there are row triggers, close all cursors then invoke
    ** the AFTER triggers
    */
    if( triggers_exist ){
      if( !isView ){
        for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
          sqlite3VdbeAddOp(v, OP_Close, iCur + i, pIdx->tnum);
        }
        sqlite3VdbeAddOp(v, OP_Close, iCur, 0);
      }
      (void)sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TRIGGER_AFTER, pTab, -1,
          oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default,
          addr);
    }

    /* End of the delete loop */
    sqlite3VdbeAddOp(v, OP_Goto, 0, addr);
    sqlite3VdbeResolveLabel(v, end);

    /* Close the cursors after the loop if there are no row triggers */
    if( !triggers_exist ){
      for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
        sqlite3VdbeAddOp(v, OP_Close, iCur + i, pIdx->tnum);
      }
      sqlite3VdbeAddOp(v, OP_Close, iCur, 0);
    }
  }

  /*
  ** Return the number of rows that were deleted. If this routine is 
  ** generating code because of a call to sqlite3NestedParse(), do not
  ** invoke the callback function.
  */
  if( db->flags & SQLITE_CountRows && pParse->nested==0 && !pParse->trigStack ){
    sqlite3VdbeAddOp(v, OP_Callback, 1, 0);
    sqlite3VdbeSetNumCols(v, 1);
    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", P3_STATIC);
  }

delete_from_cleanup:
  sqlite3AuthContextPop(&sContext);
  sqlite3SrcListDelete(pTabList);
  sqlite3ExprDelete(pWhere);
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 495 of file build.c.

                                                   {
  Index *pIndex, *pNext;
  FKey *pFKey, *pNextFKey;

  db = 0;

  if( pTable==0 ) return;

  /* Do not delete the table until the reference count reaches zero. */
  pTable->nRef--;
  if( pTable->nRef>0 ){
    return;
  }
  assert( pTable->nRef==0 );

  /* Delete all indices associated with this table
  */
  for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){
    pNext = pIndex->pNext;
    assert( pIndex->pSchema==pTable->pSchema );
    sqliteDeleteIndex(pIndex);
  }

#ifndef SQLITE_OMIT_FOREIGN_KEY
  /* Delete all foreign keys associated with this table.  The keys
  ** should have already been unlinked from the db->aFKey hash table 
  */
  for(pFKey=pTable->pFKey; pFKey; pFKey=pNextFKey){
    pNextFKey = pFKey->pNextFrom;
    assert( sqlite3HashFind(&pTable->pSchema->aFKey,
                           pFKey->zTo, strlen(pFKey->zTo)+1)!=pFKey );
    sqliteFree(pFKey);
  }
#endif

  /* Delete the Table structure itself.
  */
  sqliteResetColumnNames(pTable);
  sqliteFree(pTable->zName);
  sqliteFree(pTable->zColAff);
  sqlite3SelectDelete(pTable->pSelect);
#ifndef SQLITE_OMIT_CHECK
  sqlite3ExprDelete(pTable->pCheck);
#endif
  sqliteFree(pTable);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 419 of file trigger.c.

                                            {
  if( pTrigger==0 ) return;
  sqlite3DeleteTriggerStep(pTrigger->step_list);
  sqliteFree(pTrigger->name);
  sqliteFree(pTrigger->table);
  sqlite3ExprDelete(pTrigger->pWhen);
  sqlite3IdListDelete(pTrigger->pColumns);
  if( pTrigger->nameToken.dyn ) sqliteFree((char*)pTrigger->nameToken.z);
  sqliteFree(pTrigger);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 19 of file trigger.c.

                                                        {
  while( pTriggerStep ){
    TriggerStep * pTmp = pTriggerStep;
    pTriggerStep = pTriggerStep->pNext;

    if( pTmp->target.dyn ) sqliteFree((char*)pTmp->target.z);
    sqlite3ExprDelete(pTmp->pWhere);
    sqlite3ExprListDelete(pTmp->pExprList);
    sqlite3SelectDelete(pTmp->pSelect);
    sqlite3IdListDelete(pTmp->pIdList);

    sqliteFree(pTmp);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqlite3Dequote ( char *  )

Definition at line 856 of file util.c.

                            {
  int quote;
  int i, j;
  if( z==0 ) return;
  quote = z[0];
  switch( quote ){
    case '\'':  break;
    case '"':   break;
    case '`':   break;                /* For MySQL compatibility */
    case '[':   quote = ']';  break;  /* For MS SqlServer compatibility */
    default:    return;
  }
  for(i=1, j=0; z[i]; i++){
    if( z[i]==quote ){
      if( z[i+1]==quote ){
        z[j++] = quote;
        i++;
      }else{
        z[j++] = 0;
        break;
      }
    }else{
      z[j++] = z[i];
    }
  }
}

Here is the caller graph for this function:

Definition at line 384 of file expr.c.

                                {
  if( ExprHasAnyProperty(p, EP_Dequoted) ){
    return;
  }
  ExprSetProperty(p, EP_Dequoted);
  if( p->token.dyn==0 ){
    sqlite3TokenCopy(&p->token, &p->token);
  }
  sqlite3Dequote((char*)p->token.z);
}

Here is the call graph for this function:

Here is the caller graph for this function: