Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Run the "PRAGMA optimize" command as the database is closing. This change is intended as a test of "PRAGMA optimize". |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | optimize-pragma |
| Files: | files | file ages | folders |
| SHA1: |
90555227ea0362810b569fff3d4f863a |
| User & Date: | drh 2017-02-23 13:42:30.705 |
Context
|
2017-02-23
| ||
| 14:55 | Add the /repo_stat1 webpage (accessible only to administrators). Enhance the /repo_schema page so that it can optionally show the schema for a single table. Include sqlite_stat1 information on the /repo_schema page. check-in: f9f5702d7a user: drh tags: optimize-pragma | |
| 13:42 | Run the "PRAGMA optimize" command as the database is closing. This change is intended as a test of "PRAGMA optimize". check-in: 90555227ea user: drh tags: optimize-pragma | |
| 07:52 | Add support for document titles to the TH1 docs feature. check-in: 35698c9c43 user: mistachkin tags: trunk | |
Changes
Changes to src/db.c.
| ︙ | ︙ | |||
1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 |
fprintf(stderr, "-- prepared statements %10d\n", db.nPrepare);
}
while( db.pAllStmt ){
db_finalize(db.pAllStmt);
}
db_end_transaction(1);
pStmt = 0;
db_close_config();
/* If the localdb has a lot of unused free space,
** then VACUUM it as we shut down.
*/
if( db_database_slot("localdb")>=0 ){
int nFree = db_int(0, "PRAGMA localdb.freelist_count");
| > | 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 |
fprintf(stderr, "-- prepared statements %10d\n", db.nPrepare);
}
while( db.pAllStmt ){
db_finalize(db.pAllStmt);
}
db_end_transaction(1);
pStmt = 0;
sqlite3_exec(g.db, "PRAGMA optimize", 0, 0, 0);
db_close_config();
/* If the localdb has a lot of unused free space,
** then VACUUM it as we shut down.
*/
if( db_database_slot("localdb")>=0 ){
int nFree = db_int(0, "PRAGMA localdb.freelist_count");
|
| ︙ | ︙ |
Changes to src/sqlite3.c.
1 2 | /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite | | | 1 2 3 4 5 6 7 8 9 10 | /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite ** version 3.18.0. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements ** of 5% or more are commonly seen when SQLite is compiled as a single ** translation unit. ** ** This file is all you need to compile SQLite. To use SQLite in other |
| ︙ | ︙ | |||
394 395 396 397 398 399 400 | ** string contains the date and time of the check-in (UTC) and an SHA1 ** hash of the entire source tree. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ | | | | | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | ** string contains the date and time of the check-in (UTC) and an SHA1 ** hash of the entire source tree. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.18.0" #define SQLITE_VERSION_NUMBER 3018000 #define SQLITE_SOURCE_ID "2017-02-23 02:15:33 7a959f6d1ea038988cdb4c02d6f37abaec2580a0" /* ** CAPI3REF: Run-Time Library Version Numbers ** KEYWORDS: sqlite3_version sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros |
| ︙ | ︙ | |||
12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 | SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*); SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*); SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt); SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*); SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*); SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*); #ifndef SQLITE_OMIT_INCRBLOB SQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor*, u32 offset, u32 amt, void*); SQLITE_PRIVATE int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*); SQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *); #endif SQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *); | > | 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 | SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*); SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*); SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt); SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*); SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*); SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*); SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*); #ifndef SQLITE_OMIT_INCRBLOB SQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor*, u32 offset, u32 amt, void*); SQLITE_PRIVATE int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*); SQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *); #endif SQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *); |
| ︙ | ︙ | |||
12755 12756 12757 12758 12759 12760 12761 | #define OP_Subtract 48 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ #define OP_Multiply 49 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ #define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ #define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ #define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ #define OP_Last 53 #define OP_BitNot 54 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */ | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < > | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 |
#define OP_Subtract 48 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
#define OP_Multiply 49 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
#define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
#define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
#define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
#define OP_Last 53
#define OP_BitNot 54 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
#define OP_IfSmaller 55
#define OP_SorterSort 56
#define OP_Sort 57
#define OP_Rewind 58
#define OP_IdxLE 59 /* synopsis: key=r[P3@P4] */
#define OP_IdxGT 60 /* synopsis: key=r[P3@P4] */
#define OP_IdxLT 61 /* synopsis: key=r[P3@P4] */
#define OP_IdxGE 62 /* synopsis: key=r[P3@P4] */
#define OP_RowSetRead 63 /* synopsis: r[P3]=rowset(P1) */
#define OP_RowSetTest 64 /* synopsis: if r[P3] in rowset(P1) goto P2 */
#define OP_Program 65
#define OP_FkIfZero 66 /* synopsis: if fkctr[P1]==0 goto P2 */
#define OP_IfPos 67 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
#define OP_IfNotZero 68 /* synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
#define OP_DecrJumpZero 69 /* synopsis: if (--r[P1])==0 goto P2 */
#define OP_IncrVacuum 70
#define OP_VNext 71
#define OP_Init 72 /* synopsis: Start at P2 */
#define OP_Return 73
#define OP_EndCoroutine 74
#define OP_HaltIfNull 75 /* synopsis: if r[P3]=null halt */
#define OP_Halt 76
#define OP_Integer 77 /* synopsis: r[P2]=P1 */
#define OP_Int64 78 /* synopsis: r[P2]=P4 */
#define OP_String 79 /* synopsis: r[P2]='P4' (len=P1) */
#define OP_Null 80 /* synopsis: r[P2..P3]=NULL */
#define OP_SoftNull 81 /* synopsis: r[P1]=NULL */
#define OP_Blob 82 /* synopsis: r[P2]=P4 (len=P1) */
#define OP_Variable 83 /* synopsis: r[P2]=parameter(P1,P4) */
#define OP_Move 84 /* synopsis: r[P2@P3]=r[P1@P3] */
#define OP_Copy 85 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
#define OP_SCopy 86 /* synopsis: r[P2]=r[P1] */
#define OP_IntCopy 87 /* synopsis: r[P2]=r[P1] */
#define OP_ResultRow 88 /* synopsis: output=r[P1@P2] */
#define OP_CollSeq 89
#define OP_Function0 90 /* synopsis: r[P3]=func(r[P2@P5]) */
#define OP_Function 91 /* synopsis: r[P3]=func(r[P2@P5]) */
#define OP_AddImm 92 /* synopsis: r[P1]=r[P1]+P2 */
#define OP_RealAffinity 93
#define OP_Cast 94 /* synopsis: affinity(r[P1]) */
#define OP_Permutation 95
#define OP_Compare 96 /* synopsis: r[P1@P3] <-> r[P2@P3] */
#define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */
#define OP_Column 98 /* synopsis: r[P3]=PX */
#define OP_Affinity 99 /* synopsis: affinity(r[P1@P2]) */
#define OP_MakeRecord 100 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
#define OP_Count 101 /* synopsis: r[P2]=count() */
#define OP_ReadCookie 102
#define OP_SetCookie 103
#define OP_ReopenIdx 104 /* synopsis: root=P2 iDb=P3 */
#define OP_OpenRead 105 /* synopsis: root=P2 iDb=P3 */
#define OP_OpenWrite 106 /* synopsis: root=P2 iDb=P3 */
#define OP_OpenAutoindex 107 /* synopsis: nColumn=P2 */
#define OP_OpenEphemeral 108 /* synopsis: nColumn=P2 */
#define OP_SorterOpen 109
#define OP_SequenceTest 110 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
#define OP_OpenPseudo 111 /* synopsis: P3 columns in r[P2] */
#define OP_Close 112
#define OP_ColumnsUsed 113
#define OP_Sequence 114 /* synopsis: r[P2]=cursor[P1].ctr++ */
#define OP_NewRowid 115 /* synopsis: r[P2]=rowid */
#define OP_Insert 116 /* synopsis: intkey=r[P3] data=r[P2] */
#define OP_InsertInt 117 /* synopsis: intkey=P3 data=r[P2] */
#define OP_Delete 118
#define OP_ResetCount 119
#define OP_SorterCompare 120 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
#define OP_SorterData 121 /* synopsis: r[P2]=data */
#define OP_RowData 122 /* synopsis: r[P2]=data */
#define OP_Rowid 123 /* synopsis: r[P2]=rowid */
#define OP_NullRow 124
#define OP_SorterInsert 125 /* synopsis: key=r[P2] */
#define OP_IdxInsert 126 /* synopsis: key=r[P2] */
#define OP_IdxDelete 127 /* synopsis: key=r[P2@P3] */
#define OP_Seek 128 /* synopsis: Move P3 to P1.rowid */
#define OP_IdxRowid 129 /* synopsis: r[P2]=rowid */
#define OP_Destroy 130
#define OP_Clear 131
#define OP_Real 132 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
#define OP_ResetSorter 133
#define OP_CreateIndex 134 /* synopsis: r[P2]=root iDb=P1 */
#define OP_CreateTable 135 /* synopsis: r[P2]=root iDb=P1 */
#define OP_SqlExec 136
#define OP_ParseSchema 137
#define OP_LoadAnalysis 138
#define OP_DropTable 139
#define OP_DropIndex 140
#define OP_DropTrigger 141
#define OP_IntegrityCk 142
#define OP_RowSetAdd 143 /* synopsis: rowset(P1)=r[P2] */
#define OP_Param 144
#define OP_FkCounter 145 /* synopsis: fkctr[P1]+=P2 */
#define OP_MemMax 146 /* synopsis: r[P1]=max(r[P1],r[P2]) */
#define OP_OffsetLimit 147 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
#define OP_AggStep0 148 /* synopsis: accum=r[P3] step(r[P2@P5]) */
#define OP_AggStep 149 /* synopsis: accum=r[P3] step(r[P2@P5]) */
#define OP_AggFinal 150 /* synopsis: accum=r[P1] N=P2 */
#define OP_Expire 151
#define OP_TableLock 152 /* synopsis: iDb=P1 root=P2 write=P3 */
#define OP_VBegin 153
#define OP_VCreate 154
#define OP_VDestroy 155
#define OP_VOpen 156
#define OP_VColumn 157 /* synopsis: r[P3]=vcolumn(P2) */
#define OP_VRename 158
#define OP_Pagecount 159
#define OP_MaxPgcnt 160
#define OP_CursorHint 161
#define OP_Noop 162
#define OP_Explain 163
/* Properties such as "out2" or "jump" that are specified in
** comments following the "case" for each opcode in the vdbe.c
** are encoded into bitvectors as follows:
*/
#define OPFLG_JUMP 0x01 /* jump: P2 holds jmp target */
#define OPFLG_IN1 0x02 /* in1: P1 is an input */
#define OPFLG_IN2 0x04 /* in2: P2 is an input */
#define OPFLG_IN3 0x08 /* in3: P3 is an input */
#define OPFLG_OUT2 0x10 /* out2: P2 is an output */
#define OPFLG_OUT3 0x20 /* out3: P3 is an output */
#define OPFLG_INITIALIZER {\
/* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,\
/* 8 */ 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01,\
/* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x09,\
/* 24 */ 0x09, 0x09, 0x09, 0x26, 0x26, 0x09, 0x09, 0x09,\
/* 32 */ 0x09, 0x09, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
/* 40 */ 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26, 0x26,\
/* 48 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x01, 0x12, 0x01,\
/* 56 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x23,\
/* 64 */ 0x0b, 0x01, 0x01, 0x03, 0x03, 0x03, 0x01, 0x01,\
/* 72 */ 0x01, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10,\
/* 80 */ 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10,\
/* 88 */ 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00,\
/* 96 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
/* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
/* 112 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\
/* 120 */ 0x00, 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00,\
/* 128 */ 0x00, 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10,\
/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,\
/* 144 */ 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00,\
/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
/* 160 */ 0x10, 0x00, 0x00, 0x00,}
/* The sqlite3P2Values() routine is able to run faster if it knows
** the value of the largest JUMP opcode. The smaller the maximum
** JUMP opcode the better, so the mkopcodeh.tcl script that
** generated this include file strives to group all JUMP opcodes
** together near the beginning of the list.
*/
#define SQLITE_MX_JUMP_OPCODE 72 /* Maximum JUMP opcode */
/************** End of opcodes.h *********************************************/
/************** Continuing where we left off in vdbe.h ***********************/
/*
** Prototypes for the VDBE interface. See comments on the implementation
** for a description of what each of these routines does.
|
| ︙ | ︙ | |||
14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 |
u8 dfltLockMode; /* Default locking-mode for attached dbs */
signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */
u8 suppressErr; /* Do not issue error messages if true */
u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */
u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
u8 mTrace; /* zero or more SQLITE_TRACE flags */
u8 skipBtreeMutex; /* True if no shared-cache backends */
int nextPagesize; /* Pagesize after VACUUM if >0 */
u32 magic; /* Magic number for detect library misuse */
int nChange; /* Value returned by sqlite3_changes() */
int nTotalChange; /* Value returned by sqlite3_total_changes() */
int aLimit[SQLITE_N_LIMIT]; /* Limits */
int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */
struct sqlite3InitInfo { /* Information used during initialization */
| > | 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 |
u8 dfltLockMode; /* Default locking-mode for attached dbs */
signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */
u8 suppressErr; /* Do not issue error messages if true */
u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */
u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
u8 mTrace; /* zero or more SQLITE_TRACE flags */
u8 skipBtreeMutex; /* True if no shared-cache backends */
u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */
int nextPagesize; /* Pagesize after VACUUM if >0 */
u32 magic; /* Magic number for detect library misuse */
int nChange; /* Value returned by sqlite3_changes() */
int nTotalChange; /* Value returned by sqlite3_total_changes() */
int aLimit[SQLITE_N_LIMIT]; /* Limits */
int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */
struct sqlite3InitInfo { /* Information used during initialization */
|
| ︙ | ︙ | |||
14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 |
Select *pSelect; /* NULL for tables. Points to definition if a view. */
FKey *pFKey; /* Linked list of all foreign keys in this table */
char *zColAff; /* String defining the affinity of each column */
ExprList *pCheck; /* All CHECK constraints */
/* ... also used as column name list in a VIEW */
int tnum; /* Root BTree page for this table */
u32 nTabRef; /* Number of pointers to this Table */
i16 iPKey; /* If not negative, use aCol[iPKey] as the rowid */
i16 nCol; /* Number of columns in this table */
LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */
LogEst szTabRow; /* Estimated size of each table row in bytes */
#ifdef SQLITE_ENABLE_COSTMULT
LogEst costMult; /* Cost multiplier for using this table */
#endif
| > < | 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 |
Select *pSelect; /* NULL for tables. Points to definition if a view. */
FKey *pFKey; /* Linked list of all foreign keys in this table */
char *zColAff; /* String defining the affinity of each column */
ExprList *pCheck; /* All CHECK constraints */
/* ... also used as column name list in a VIEW */
int tnum; /* Root BTree page for this table */
u32 nTabRef; /* Number of pointers to this Table */
u32 tabFlags; /* Mask of TF_* values */
i16 iPKey; /* If not negative, use aCol[iPKey] as the rowid */
i16 nCol; /* Number of columns in this table */
LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */
LogEst szTabRow; /* Estimated size of each table row in bytes */
#ifdef SQLITE_ENABLE_COSTMULT
LogEst costMult; /* Cost multiplier for using this table */
#endif
u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
#ifndef SQLITE_OMIT_ALTERTABLE
int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
#endif
#ifndef SQLITE_OMIT_VIRTUALTABLE
int nModuleArg; /* Number of arguments to the module */
char **azModuleArg; /* 0: module 1: schema 2: vtab name 3...: args */
|
| ︙ | ︙ | |||
14618 14619 14620 14621 14622 14623 14624 | ** ** TF_OOOHidden applies to tables or view that have hidden columns that are ** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING ** vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden, ** the TF_OOOHidden attribute would apply in this case. Such tables require ** special handling during INSERT processing. */ | | | | | | | | | | > > | | 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 |
**
** TF_OOOHidden applies to tables or view that have hidden columns that are
** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING
** vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden,
** the TF_OOOHidden attribute would apply in this case. Such tables require
** special handling during INSERT processing.
*/
#define TF_Readonly 0x0001 /* Read-only system table */
#define TF_Ephemeral 0x0002 /* An ephemeral table */
#define TF_HasPrimaryKey 0x0004 /* Table has a primary key */
#define TF_Autoincrement 0x0008 /* Integer primary key is autoincrement */
#define TF_HasStat1 0x0010 /* nRowLogEst set from sqlite_stat1 */
#define TF_WithoutRowid 0x0020 /* No rowid. PRIMARY KEY is the key */
#define TF_NoVisibleRowid 0x0040 /* No user-visible "rowid" column */
#define TF_OOOHidden 0x0080 /* Out-of-Order hidden columns */
#define TF_StatsUsed 0x0100 /* Query planner decisions affected by
** Index.aiRowLogEst[] values */
#define TF_HasNotNull 0x0200 /* Contains NOT NULL constraints */
/*
** Test to see whether or not a table is a virtual table. This is
** done as a macro so that it will be optimized out when virtual
** table support is omitted from the build.
*/
#ifndef SQLITE_OMIT_VIRTUALTABLE
# define IsVirtual(X) ((X)->nModuleArg)
#else
# define IsVirtual(X) 0
#endif
/*
** Macros to determine if a column is hidden. IsOrdinaryHiddenColumn()
** only works for non-virtual tables (ordinary tables and views) and is
|
| ︙ | ︙ | |||
14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 | u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ unsigned idxType:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */ unsigned bUnordered:1; /* Use this index for == or IN queries only */ unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */ unsigned isResized:1; /* True if resizeIndexObject() has been called */ unsigned isCovering:1; /* True if this is a covering index */ unsigned noSkipScan:1; /* Do not try to use skip-scan if true */ #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 int nSample; /* Number of elements in aSample[] */ int nSampleCol; /* Size of IndexSample.anEq[] and so on */ tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */ IndexSample *aSample; /* Samples of the left-most key */ tRowcnt *aiRowEst; /* Non-logarithmic stat1 data for this index */ tRowcnt nRowEst0; /* Non-logarithmic number of rows in the index */ | > | 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 | u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ unsigned idxType:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */ unsigned bUnordered:1; /* Use this index for == or IN queries only */ unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */ unsigned isResized:1; /* True if resizeIndexObject() has been called */ unsigned isCovering:1; /* True if this is a covering index */ unsigned noSkipScan:1; /* Do not try to use skip-scan if true */ unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */ #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 int nSample; /* Number of elements in aSample[] */ int nSampleCol; /* Size of IndexSample.anEq[] and so on */ tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */ IndexSample *aSample; /* Samples of the left-most key */ tRowcnt *aiRowEst; /* Non-logarithmic stat1 data for this index */ tRowcnt nRowEst0; /* Non-logarithmic number of rows in the index */ |
| ︙ | ︙ | |||
15179 15180 15181 15182 15183 15184 15185 |
** the bSpanIsTab flag is set, then zSpan is overloaded to mean the name
** of the result column in the form: DATABASE.TABLE.COLUMN. This later
** form is used for name resolution with nested FROM clauses.
*/
struct ExprList {
int nExpr; /* Number of expressions on the list */
struct ExprList_item { /* For each expression in the list */
| | | 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 |
** the bSpanIsTab flag is set, then zSpan is overloaded to mean the name
** of the result column in the form: DATABASE.TABLE.COLUMN. This later
** form is used for name resolution with nested FROM clauses.
*/
struct ExprList {
int nExpr; /* Number of expressions on the list */
struct ExprList_item { /* For each expression in the list */
Expr *pExpr; /* The parse tree for this expression */
char *zName; /* Token associated with this expression */
char *zSpan; /* Original text of the expression */
u8 sortOrder; /* 1 for DESC or 0 for ASC */
unsigned done :1; /* A flag to indicate when processing is finished */
unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */
unsigned reusable :1; /* Constant expression is reusable */
union {
|
| ︙ | ︙ | |||
16502 16503 16504 16505 16506 16507 16508 16509 16510 16511 16512 16513 16514 16515 | SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*); SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*); SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*); SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int); SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*); SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int); SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int); SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int); SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*); SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx); SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*); SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*); | > | 16509 16510 16511 16512 16513 16514 16515 16516 16517 16518 16519 16520 16521 16522 16523 | SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*); SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*); SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*); SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int); SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*); SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int); SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*, Expr*, int); SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int); SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int); SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*); SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx); SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*); SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*); |
| ︙ | ︙ | |||
17448 17449 17450 17451 17452 17453 17454 | "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER), #elif defined(__GNUC__) && defined(__VERSION__) "COMPILER=gcc-" __VERSION__, #endif #if SQLITE_COVERAGE_TEST "COVERAGE_TEST", #endif | | | 17456 17457 17458 17459 17460 17461 17462 17463 17464 17465 17466 17467 17468 17469 17470 | "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER), #elif defined(__GNUC__) && defined(__VERSION__) "COMPILER=gcc-" __VERSION__, #endif #if SQLITE_COVERAGE_TEST "COVERAGE_TEST", #endif #ifdef SQLITE_DEBUG "DEBUG", #endif #if SQLITE_DEFAULT_LOCKING_MODE "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE), #endif #if defined(SQLITE_DEFAULT_MMAP_SIZE) && !defined(SQLITE_DEFAULT_MMAP_SIZE_xc) "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE), |
| ︙ | ︙ | |||
24048 24049 24050 24051 24052 24053 24054 |
assert( winMutex_isInit==1 );
EnterCriticalSection(&p->mutex);
#ifdef SQLITE_DEBUG
assert( p->nRef>0 || p->owner==0 );
p->owner = tid;
p->nRef++;
if( p->trace ){
| | | | 24056 24057 24058 24059 24060 24061 24062 24063 24064 24065 24066 24067 24068 24069 24070 24071 |
assert( winMutex_isInit==1 );
EnterCriticalSection(&p->mutex);
#ifdef SQLITE_DEBUG
assert( p->nRef>0 || p->owner==0 );
p->owner = tid;
p->nRef++;
if( p->trace ){
OSTRACE(("ENTER-MUTEX tid=%lu, mutex(%d)=%p (%d), nRef=%d\n",
tid, p->id, p, p->trace, p->nRef));
}
#endif
}
static int winMutexTry(sqlite3_mutex *p){
#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
DWORD tid = GetCurrentThreadId();
|
| ︙ | ︙ | |||
24091 24092 24093 24094 24095 24096 24097 |
rc = SQLITE_OK;
}
#else
UNUSED_PARAMETER(p);
#endif
#ifdef SQLITE_DEBUG
if( p->trace ){
| | | | 24099 24100 24101 24102 24103 24104 24105 24106 24107 24108 24109 24110 24111 24112 24113 24114 |
rc = SQLITE_OK;
}
#else
UNUSED_PARAMETER(p);
#endif
#ifdef SQLITE_DEBUG
if( p->trace ){
OSTRACE(("TRY-MUTEX tid=%lu, mutex(%d)=%p (%d), owner=%lu, nRef=%d, rc=%s\n",
tid, p->id, p, p->trace, p->owner, p->nRef, sqlite3ErrName(rc)));
}
#endif
return rc;
}
/*
** The sqlite3_mutex_leave() routine exits a mutex that was
|
| ︙ | ︙ | |||
24120 24121 24122 24123 24124 24125 24126 |
if( p->nRef==0 ) p->owner = 0;
assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );
#endif
assert( winMutex_isInit==1 );
LeaveCriticalSection(&p->mutex);
#ifdef SQLITE_DEBUG
if( p->trace ){
| | | | 24128 24129 24130 24131 24132 24133 24134 24135 24136 24137 24138 24139 24140 24141 24142 24143 |
if( p->nRef==0 ) p->owner = 0;
assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );
#endif
assert( winMutex_isInit==1 );
LeaveCriticalSection(&p->mutex);
#ifdef SQLITE_DEBUG
if( p->trace ){
OSTRACE(("LEAVE-MUTEX tid=%lu, mutex(%d)=%p (%d), nRef=%d\n",
tid, p->id, p, p->trace, p->nRef));
}
#endif
}
SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
static const sqlite3_mutex_methods sMutex = {
winMutexInit,
|
| ︙ | ︙ | |||
24570 24571 24572 24573 24574 24575 24576 |
SQLITE_PRIVATE int sqlite3MallocSize(void *p){
assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
return sqlite3GlobalConfig.m.xSize(p);
}
SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){
assert( p!=0 );
if( db==0 || !isLookaside(db,p) ){
| | | 24578 24579 24580 24581 24582 24583 24584 24585 24586 24587 24588 24589 24590 24591 24592 |
SQLITE_PRIVATE int sqlite3MallocSize(void *p){
assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
return sqlite3GlobalConfig.m.xSize(p);
}
SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){
assert( p!=0 );
if( db==0 || !isLookaside(db,p) ){
#ifdef SQLITE_DEBUG
if( db==0 ){
assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
}else{
assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
}
|
| ︙ | ︙ | |||
24631 24632 24633 24634 24635 24636 24637 |
if( db ){
if( db->pnBytesFreed ){
measureAllocationSize(db, p);
return;
}
if( isLookaside(db, p) ){
LookasideSlot *pBuf = (LookasideSlot*)p;
| | | 24639 24640 24641 24642 24643 24644 24645 24646 24647 24648 24649 24650 24651 24652 24653 |
if( db ){
if( db->pnBytesFreed ){
measureAllocationSize(db, p);
return;
}
if( isLookaside(db, p) ){
LookasideSlot *pBuf = (LookasideSlot*)p;
#ifdef SQLITE_DEBUG
/* Trash all content in the buffer being freed */
memset(p, 0xaa, db->lookaside.sz);
#endif
pBuf->pNext = db->lookaside.pFree;
db->lookaside.pFree = pBuf;
db->lookaside.nOut--;
return;
|
| ︙ | ︙ | |||
25000 25001 25002 25003 25004 25005 25006 | */ /* #include "sqliteInt.h" */ /* ** Conversion types fall into various categories as defined by the ** following enumeration. */ | | > | | 25008 25009 25010 25011 25012 25013 25014 25015 25016 25017 25018 25019 25020 25021 25022 25023 25024 25025 25026 25027 25028 25029 25030 25031 25032 25033 25034 25035 25036 25037 25038 25039 25040 25041 25042 |
*/
/* #include "sqliteInt.h" */
/*
** Conversion types fall into various categories as defined by the
** following enumeration.
*/
#define etRADIX 0 /* non-decimal integer types. %x %o */
#define etFLOAT 1 /* Floating point. %f */
#define etEXP 2 /* Exponentional notation. %e and %E */
#define etGENERIC 3 /* Floating or exponential, depending on exponent. %g */
#define etSIZE 4 /* Return number of characters processed so far. %n */
#define etSTRING 5 /* Strings. %s */
#define etDYNSTRING 6 /* Dynamically allocated strings. %z */
#define etPERCENT 7 /* Percent symbol. %% */
#define etCHARX 8 /* Characters. %c */
/* The rest are extensions, not normally found in printf() */
#define etSQLESCAPE 9 /* Strings with '\'' doubled. %q */
#define etSQLESCAPE2 10 /* Strings with '\'' doubled and enclosed in '',
NULL pointers replaced by SQL NULL. %Q */
#define etTOKEN 11 /* a pointer to a Token structure */
#define etSRCLIST 12 /* a pointer to a SrcList */
#define etPOINTER 13 /* The %p conversion */
#define etSQLESCAPE3 14 /* %w -> Strings with '\"' doubled */
#define etORDINAL 15 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */
#define etDECIMAL 16 /* %d or %u, but not %x, %o */
#define etINVALID 17 /* Any unrecognized conversion type */
/*
** An "etByte" is an 8-bit unsigned value.
*/
typedef unsigned char etByte;
|
| ︙ | ︙ | |||
25043 25044 25045 25046 25047 25048 25049 | etByte charset; /* Offset into aDigits[] of the digits string */ etByte prefix; /* Offset into aPrefix[] of the prefix string */ } et_info; /* ** Allowed values for et_info.flags */ | | | | | | | 25052 25053 25054 25055 25056 25057 25058 25059 25060 25061 25062 25063 25064 25065 25066 25067 25068 25069 25070 25071 25072 25073 25074 25075 25076 25077 25078 25079 25080 25081 25082 25083 25084 25085 25086 25087 25088 25089 25090 25091 25092 25093 25094 25095 |
etByte charset; /* Offset into aDigits[] of the digits string */
etByte prefix; /* Offset into aPrefix[] of the prefix string */
} et_info;
/*
** Allowed values for et_info.flags
*/
#define FLAG_SIGNED 1 /* True if the value to convert is signed */
#define FLAG_STRING 4 /* Allow infinite precision */
/*
** The following table is searched linearly, so it is good to put the
** most frequently used conversion types first.
*/
static const char aDigits[] = "0123456789ABCDEF0123456789abcdef";
static const char aPrefix[] = "-x0\000X0";
static const et_info fmtinfo[] = {
{ 'd', 10, 1, etDECIMAL, 0, 0 },
{ 's', 0, 4, etSTRING, 0, 0 },
{ 'g', 0, 1, etGENERIC, 30, 0 },
{ 'z', 0, 4, etDYNSTRING, 0, 0 },
{ 'q', 0, 4, etSQLESCAPE, 0, 0 },
{ 'Q', 0, 4, etSQLESCAPE2, 0, 0 },
{ 'w', 0, 4, etSQLESCAPE3, 0, 0 },
{ 'c', 0, 0, etCHARX, 0, 0 },
{ 'o', 8, 0, etRADIX, 0, 2 },
{ 'u', 10, 0, etDECIMAL, 0, 0 },
{ 'x', 16, 0, etRADIX, 16, 1 },
{ 'X', 16, 0, etRADIX, 0, 4 },
#ifndef SQLITE_OMIT_FLOATING_POINT
{ 'f', 0, 1, etFLOAT, 0, 0 },
{ 'e', 0, 1, etEXP, 30, 0 },
{ 'E', 0, 1, etEXP, 14, 0 },
{ 'G', 0, 1, etGENERIC, 14, 0 },
#endif
{ 'i', 10, 1, etDECIMAL, 0, 0 },
{ 'n', 0, 0, etSIZE, 0, 0 },
{ '%', 0, 0, etPERCENT, 0, 0 },
{ 'p', 16, 0, etPOINTER, 0, 1 },
/* All the rest are undocumented and are for internal use only */
{ 'T', 0, 0, etTOKEN, 0, 0 },
{ 'S', 0, 0, etSRCLIST, 0, 0 },
|
| ︙ | ︙ | |||
25164 25165 25166 25167 25168 25169 25170 | int c; /* Next character in the format string */ char *bufpt; /* Pointer to the conversion buffer */ int precision; /* Precision of the current field */ int length; /* Length of the field */ int idx; /* A general purpose loop counter */ int width; /* Width of the current field */ etByte flag_leftjustify; /* True if "-" flag is present */ | | < | < > | 25173 25174 25175 25176 25177 25178 25179 25180 25181 25182 25183 25184 25185 25186 25187 25188 25189 25190 25191 25192 25193 | int c; /* Next character in the format string */ char *bufpt; /* Pointer to the conversion buffer */ int precision; /* Precision of the current field */ int length; /* Length of the field */ int idx; /* A general purpose loop counter */ int width; /* Width of the current field */ etByte flag_leftjustify; /* True if "-" flag is present */ etByte flag_prefix; /* '+' or ' ' or 0 for prefix */ etByte flag_alternateform; /* True if "#" flag is present */ etByte flag_altform2; /* True if "!" flag is present */ etByte flag_zeropad; /* True if field width constant starts with zero */ etByte flag_long; /* 1 for the "l" flag, 2 for "ll", 0 by default */ etByte done; /* Loop termination flag */ etByte cThousand; /* Thousands separator for %d and %u */ etByte xtype = etINVALID; /* Conversion paradigm */ u8 bArgList; /* True for SQLITE_PRINTF_SQLFUNC */ char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ sqlite_uint64 longvalue; /* Value for integer types */ LONGDOUBLE_TYPE realvalue; /* Value for real types */ const et_info *infop; /* Pointer to the appropriate info structure */ char *zOut; /* Rendering buffer */ |
| ︙ | ︙ | |||
25214 25215 25216 25217 25218 25219 25220 |
if( *fmt==0 ) break;
}
if( (c=(*++fmt))==0 ){
sqlite3StrAccumAppend(pAccum, "%", 1);
break;
}
/* Find out what flags are present */
| | | | > | 25222 25223 25224 25225 25226 25227 25228 25229 25230 25231 25232 25233 25234 25235 25236 25237 25238 25239 25240 25241 25242 25243 25244 25245 25246 25247 |
if( *fmt==0 ) break;
}
if( (c=(*++fmt))==0 ){
sqlite3StrAccumAppend(pAccum, "%", 1);
break;
}
/* Find out what flags are present */
flag_leftjustify = flag_prefix = cThousand =
flag_alternateform = flag_altform2 = flag_zeropad = 0;
done = 0;
do{
switch( c ){
case '-': flag_leftjustify = 1; break;
case '+': flag_prefix = '+'; break;
case ' ': flag_prefix = ' '; break;
case '#': flag_alternateform = 1; break;
case '!': flag_altform2 = 1; break;
case '0': flag_zeropad = 1; break;
case ',': cThousand = ','; break;
default: done = 1; break;
}
}while( !done && (c=(*++fmt))!=0 );
/* Get the field width */
if( c=='*' ){
if( bArgList ){
width = (int)getIntArg(pArgList);
|
| ︙ | ︙ | |||
25294 25295 25296 25297 25298 25299 25300 |
/* Get the conversion type modifier */
if( c=='l' ){
flag_long = 1;
c = *++fmt;
if( c=='l' ){
| | < < | | | < < < < | | | > > > | > | | | > < < | | > | | | > | | | 25303 25304 25305 25306 25307 25308 25309 25310 25311 25312 25313 25314 25315 25316 25317 25318 25319 25320 25321 25322 25323 25324 25325 25326 25327 25328 25329 25330 25331 25332 25333 25334 25335 25336 25337 25338 25339 25340 25341 25342 25343 25344 25345 25346 25347 25348 25349 25350 25351 25352 25353 25354 25355 25356 25357 25358 25359 25360 25361 25362 25363 25364 25365 25366 25367 25368 25369 25370 25371 25372 25373 25374 25375 25376 25377 25378 25379 25380 25381 25382 25383 25384 25385 25386 25387 25388 25389 25390 25391 25392 25393 25394 25395 25396 25397 25398 25399 25400 25401 25402 25403 25404 25405 25406 25407 |
/* Get the conversion type modifier */
if( c=='l' ){
flag_long = 1;
c = *++fmt;
if( c=='l' ){
flag_long = 2;
c = *++fmt;
}
}else{
flag_long = 0;
}
/* Fetch the info entry for the field */
infop = &fmtinfo[0];
xtype = etINVALID;
for(idx=0; idx<ArraySize(fmtinfo); idx++){
if( c==fmtinfo[idx].fmttype ){
infop = &fmtinfo[idx];
xtype = infop->type;
break;
}
}
/*
** At this point, variables are initialized as follows:
**
** flag_alternateform TRUE if a '#' is present.
** flag_altform2 TRUE if a '!' is present.
** flag_prefix '+' or ' ' or zero
** flag_leftjustify TRUE if a '-' is present or if the
** field width was negative.
** flag_zeropad TRUE if the width began with 0.
** flag_long 1 for "l", 2 for "ll"
** width The specified field width. This is
** always non-negative. Zero is the default.
** precision The specified precision. The default
** is -1.
** xtype The class of the conversion.
** infop Pointer to the appropriate info struct.
*/
switch( xtype ){
case etPOINTER:
flag_long = sizeof(char*)==sizeof(i64) ? 2 :
sizeof(char*)==sizeof(long int) ? 1 : 0;
/* Fall through into the next case */
case etORDINAL:
case etRADIX:
cThousand = 0;
/* Fall through into the next case */
case etDECIMAL:
if( infop->flags & FLAG_SIGNED ){
i64 v;
if( bArgList ){
v = getIntArg(pArgList);
}else if( flag_long ){
if( flag_long==2 ){
v = va_arg(ap,i64) ;
}else{
v = va_arg(ap,long int);
}
}else{
v = va_arg(ap,int);
}
if( v<0 ){
if( v==SMALLEST_INT64 ){
longvalue = ((u64)1)<<63;
}else{
longvalue = -v;
}
prefix = '-';
}else{
longvalue = v;
prefix = flag_prefix;
}
}else{
if( bArgList ){
longvalue = (u64)getIntArg(pArgList);
}else if( flag_long ){
if( flag_long==2 ){
longvalue = va_arg(ap,u64);
}else{
longvalue = va_arg(ap,unsigned long int);
}
}else{
longvalue = va_arg(ap,unsigned int);
}
prefix = 0;
}
if( longvalue==0 ) flag_alternateform = 0;
if( flag_zeropad && precision<width-(prefix!=0) ){
precision = width-(prefix!=0);
}
if( precision<etBUFSIZE-10-etBUFSIZE/3 ){
nOut = etBUFSIZE;
zOut = buf;
}else{
nOut = precision + 10 + precision/3;
zOut = zExtra = sqlite3Malloc( nOut );
if( zOut==0 ){
setStrAccumError(pAccum, STRACCUM_NOMEM);
return;
}
}
bufpt = &zOut[nOut-1];
|
| ︙ | ︙ | |||
25411 25412 25413 25414 25415 25416 25417 |
u8 base = infop->base;
do{ /* Convert to ascii */
*(--bufpt) = cset[longvalue%base];
longvalue = longvalue/base;
}while( longvalue>0 );
}
length = (int)(&zOut[nOut-1]-bufpt);
| | > > > > > > > > > > > > > > > | 25419 25420 25421 25422 25423 25424 25425 25426 25427 25428 25429 25430 25431 25432 25433 25434 25435 25436 25437 25438 25439 25440 25441 25442 25443 25444 25445 25446 25447 25448 25449 |
u8 base = infop->base;
do{ /* Convert to ascii */
*(--bufpt) = cset[longvalue%base];
longvalue = longvalue/base;
}while( longvalue>0 );
}
length = (int)(&zOut[nOut-1]-bufpt);
while( precision>length ){
*(--bufpt) = '0'; /* Zero pad */
length++;
}
if( cThousand ){
int nn = (length - 1)/3; /* Number of "," to insert */
int ix = (length - 1)%3 + 1;
bufpt -= nn;
for(idx=0; nn>0; idx++){
bufpt[idx] = bufpt[idx+nn];
ix--;
if( ix==0 ){
bufpt[++idx] = cThousand;
nn--;
ix = 3;
}
}
}
if( prefix ) *(--bufpt) = prefix; /* Add sign */
if( flag_alternateform && infop->prefix ){ /* Add "0" or "0x" */
const char *pre;
char x;
pre = &aPrefix[infop->prefix];
for(; (x=(*pre))!=0; pre++) *(--bufpt) = x;
|
| ︙ | ︙ | |||
25439 25440 25441 25442 25443 25444 25445 |
length = 0;
#else
if( precision<0 ) precision = 6; /* Set default precision */
if( realvalue<0.0 ){
realvalue = -realvalue;
prefix = '-';
}else{
| < < | | 25462 25463 25464 25465 25466 25467 25468 25469 25470 25471 25472 25473 25474 25475 25476 |
length = 0;
#else
if( precision<0 ) precision = 6; /* Set default precision */
if( realvalue<0.0 ){
realvalue = -realvalue;
prefix = '-';
}else{
prefix = flag_prefix;
}
if( xtype==etGENERIC && precision>0 ) precision--;
testcase( precision>0xfff );
for(idx=precision&0xfff, rounder=0.5; idx>0; idx--, rounder*=0.1){}
if( xtype==etFLOAT ) realvalue += rounder;
/* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
exp = 0;
|
| ︙ | ︙ | |||
29462 29463 29464 29465 29466 29467 29468 |
/* 48 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
/* 49 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
/* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
/* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
/* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
/* 53 */ "Last" OpHelp(""),
/* 54 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
| > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < > | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | 29483 29484 29485 29486 29487 29488 29489 29490 29491 29492 29493 29494 29495 29496 29497 29498 29499 29500 29501 29502 29503 29504 29505 29506 29507 29508 29509 29510 29511 29512 29513 29514 29515 29516 29517 29518 29519 29520 29521 29522 29523 29524 29525 29526 29527 29528 29529 29530 29531 29532 29533 29534 29535 29536 29537 29538 29539 29540 29541 29542 29543 29544 29545 29546 29547 29548 29549 29550 29551 29552 29553 29554 29555 29556 29557 29558 29559 29560 29561 29562 29563 29564 29565 29566 29567 29568 29569 29570 29571 29572 29573 29574 29575 29576 29577 29578 29579 29580 29581 29582 29583 29584 29585 29586 29587 29588 29589 29590 29591 29592 29593 29594 29595 29596 29597 29598 29599 29600 29601 29602 29603 29604 29605 |
/* 48 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
/* 49 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
/* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
/* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
/* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
/* 53 */ "Last" OpHelp(""),
/* 54 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
/* 55 */ "IfSmaller" OpHelp(""),
/* 56 */ "SorterSort" OpHelp(""),
/* 57 */ "Sort" OpHelp(""),
/* 58 */ "Rewind" OpHelp(""),
/* 59 */ "IdxLE" OpHelp("key=r[P3@P4]"),
/* 60 */ "IdxGT" OpHelp("key=r[P3@P4]"),
/* 61 */ "IdxLT" OpHelp("key=r[P3@P4]"),
/* 62 */ "IdxGE" OpHelp("key=r[P3@P4]"),
/* 63 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
/* 64 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
/* 65 */ "Program" OpHelp(""),
/* 66 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
/* 67 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
/* 68 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
/* 69 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
/* 70 */ "IncrVacuum" OpHelp(""),
/* 71 */ "VNext" OpHelp(""),
/* 72 */ "Init" OpHelp("Start at P2"),
/* 73 */ "Return" OpHelp(""),
/* 74 */ "EndCoroutine" OpHelp(""),
/* 75 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
/* 76 */ "Halt" OpHelp(""),
/* 77 */ "Integer" OpHelp("r[P2]=P1"),
/* 78 */ "Int64" OpHelp("r[P2]=P4"),
/* 79 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
/* 80 */ "Null" OpHelp("r[P2..P3]=NULL"),
/* 81 */ "SoftNull" OpHelp("r[P1]=NULL"),
/* 82 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
/* 83 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
/* 84 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
/* 85 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
/* 86 */ "SCopy" OpHelp("r[P2]=r[P1]"),
/* 87 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
/* 88 */ "ResultRow" OpHelp("output=r[P1@P2]"),
/* 89 */ "CollSeq" OpHelp(""),
/* 90 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
/* 91 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
/* 92 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
/* 93 */ "RealAffinity" OpHelp(""),
/* 94 */ "Cast" OpHelp("affinity(r[P1])"),
/* 95 */ "Permutation" OpHelp(""),
/* 96 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
/* 97 */ "String8" OpHelp("r[P2]='P4'"),
/* 98 */ "Column" OpHelp("r[P3]=PX"),
/* 99 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
/* 100 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
/* 101 */ "Count" OpHelp("r[P2]=count()"),
/* 102 */ "ReadCookie" OpHelp(""),
/* 103 */ "SetCookie" OpHelp(""),
/* 104 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
/* 105 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
/* 106 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
/* 107 */ "OpenAutoindex" OpHelp("nColumn=P2"),
/* 108 */ "OpenEphemeral" OpHelp("nColumn=P2"),
/* 109 */ "SorterOpen" OpHelp(""),
/* 110 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
/* 111 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
/* 112 */ "Close" OpHelp(""),
/* 113 */ "ColumnsUsed" OpHelp(""),
/* 114 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
/* 115 */ "NewRowid" OpHelp("r[P2]=rowid"),
/* 116 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
/* 117 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
/* 118 */ "Delete" OpHelp(""),
/* 119 */ "ResetCount" OpHelp(""),
/* 120 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
/* 121 */ "SorterData" OpHelp("r[P2]=data"),
/* 122 */ "RowData" OpHelp("r[P2]=data"),
/* 123 */ "Rowid" OpHelp("r[P2]=rowid"),
/* 124 */ "NullRow" OpHelp(""),
/* 125 */ "SorterInsert" OpHelp("key=r[P2]"),
/* 126 */ "IdxInsert" OpHelp("key=r[P2]"),
/* 127 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
/* 128 */ "Seek" OpHelp("Move P3 to P1.rowid"),
/* 129 */ "IdxRowid" OpHelp("r[P2]=rowid"),
/* 130 */ "Destroy" OpHelp(""),
/* 131 */ "Clear" OpHelp(""),
/* 132 */ "Real" OpHelp("r[P2]=P4"),
/* 133 */ "ResetSorter" OpHelp(""),
/* 134 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"),
/* 135 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"),
/* 136 */ "SqlExec" OpHelp(""),
/* 137 */ "ParseSchema" OpHelp(""),
/* 138 */ "LoadAnalysis" OpHelp(""),
/* 139 */ "DropTable" OpHelp(""),
/* 140 */ "DropIndex" OpHelp(""),
/* 141 */ "DropTrigger" OpHelp(""),
/* 142 */ "IntegrityCk" OpHelp(""),
/* 143 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
/* 144 */ "Param" OpHelp(""),
/* 145 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
/* 146 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
/* 147 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
/* 148 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
/* 149 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
/* 150 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
/* 151 */ "Expire" OpHelp(""),
/* 152 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
/* 153 */ "VBegin" OpHelp(""),
/* 154 */ "VCreate" OpHelp(""),
/* 155 */ "VDestroy" OpHelp(""),
/* 156 */ "VOpen" OpHelp(""),
/* 157 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
/* 158 */ "VRename" OpHelp(""),
/* 159 */ "Pagecount" OpHelp(""),
/* 160 */ "MaxPgcnt" OpHelp(""),
/* 161 */ "CursorHint" OpHelp(""),
/* 162 */ "Noop" OpHelp(""),
/* 163 */ "Explain" OpHelp(""),
};
return azName[i];
}
#endif
/************** End of opcodes.c *********************************************/
/************** Begin file os_unix.c *****************************************/
|
| ︙ | ︙ | |||
37950 37951 37952 37953 37954 37955 37956 | * winMemShutdown function is called (e.g. by the sqlite3_shutdown * function), all data that was allocated using the isolated heap will * be freed immediately and any attempt to access any of that freed * data will almost certainly result in an immediate access violation. ****************************************************************************** */ #ifndef SQLITE_WIN32_HEAP_CREATE | | > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > | | > | | | 37973 37974 37975 37976 37977 37978 37979 37980 37981 37982 37983 37984 37985 37986 37987 37988 37989 37990 37991 37992 37993 37994 37995 37996 37997 37998 37999 38000 38001 38002 38003 38004 38005 38006 38007 38008 38009 38010 38011 38012 38013 38014 38015 38016 38017 38018 38019 38020 38021 38022 38023 38024 38025 38026 38027 38028 38029 38030 38031 38032 38033 38034 38035 38036 38037 38038 38039 38040 38041 38042 38043 38044 38045 38046 38047 38048 38049 38050 38051 38052 38053 38054 38055 38056 38057 38058 38059 38060 |
* winMemShutdown function is called (e.g. by the sqlite3_shutdown
* function), all data that was allocated using the isolated heap will
* be freed immediately and any attempt to access any of that freed
* data will almost certainly result in an immediate access violation.
******************************************************************************
*/
#ifndef SQLITE_WIN32_HEAP_CREATE
# define SQLITE_WIN32_HEAP_CREATE (TRUE)
#endif
/*
* This is the maximum possible initial size of the Win32-specific heap, in
* bytes.
*/
#ifndef SQLITE_WIN32_HEAP_MAX_INIT_SIZE
# define SQLITE_WIN32_HEAP_MAX_INIT_SIZE (4294967295U)
#endif
/*
* This is the extra space for the initial size of the Win32-specific heap,
* in bytes. This value may be zero.
*/
#ifndef SQLITE_WIN32_HEAP_INIT_EXTRA
# define SQLITE_WIN32_HEAP_INIT_EXTRA (4194304)
#endif
/*
* Calculate the maximum legal cache size, in pages, based on the maximum
* possible initial heap size and the default page size, setting aside the
* needed extra space.
*/
#ifndef SQLITE_WIN32_MAX_CACHE_SIZE
# define SQLITE_WIN32_MAX_CACHE_SIZE (((SQLITE_WIN32_HEAP_MAX_INIT_SIZE) - \
(SQLITE_WIN32_HEAP_INIT_EXTRA)) / \
(SQLITE_DEFAULT_PAGE_SIZE))
#endif
/*
* This is cache size used in the calculation of the initial size of the
* Win32-specific heap. It cannot be negative.
*/
#ifndef SQLITE_WIN32_CACHE_SIZE
# if SQLITE_DEFAULT_CACHE_SIZE>=0
# define SQLITE_WIN32_CACHE_SIZE (SQLITE_DEFAULT_CACHE_SIZE)
# else
# define SQLITE_WIN32_CACHE_SIZE (-(SQLITE_DEFAULT_CACHE_SIZE))
# endif
#endif
/*
* Make sure that the calculated cache size, in pages, cannot cause the
* initial size of the Win32-specific heap to exceed the maximum amount
* of memory that can be specified in the call to HeapCreate.
*/
#if SQLITE_WIN32_CACHE_SIZE>SQLITE_WIN32_MAX_CACHE_SIZE
# undef SQLITE_WIN32_CACHE_SIZE
# define SQLITE_WIN32_CACHE_SIZE (2000)
#endif
/*
* The initial size of the Win32-specific heap. This value may be zero.
*/
#ifndef SQLITE_WIN32_HEAP_INIT_SIZE
# define SQLITE_WIN32_HEAP_INIT_SIZE ((SQLITE_WIN32_CACHE_SIZE) * \
(SQLITE_DEFAULT_PAGE_SIZE) + \
(SQLITE_WIN32_HEAP_INIT_EXTRA))
#endif
/*
* The maximum size of the Win32-specific heap. This value may be zero.
*/
#ifndef SQLITE_WIN32_HEAP_MAX_SIZE
# define SQLITE_WIN32_HEAP_MAX_SIZE (0)
#endif
/*
* The extra flags to use in calls to the Win32 heap APIs. This value may be
* zero for the default behavior.
*/
#ifndef SQLITE_WIN32_HEAP_FLAGS
# define SQLITE_WIN32_HEAP_FLAGS (0)
#endif
/*
** The winMemData structure stores information required by the Win32-specific
** sqlite3_mem_methods implementation.
*/
|
| ︙ | ︙ | |||
44082 44083 44084 44085 44086 44087 44088 | ** Return false if any invariant is violated. ** ** This routine is for use inside of assert() statements only. For ** example: ** ** assert( sqlite3PcachePageSanity(pPg) ); */ | | | 44143 44144 44145 44146 44147 44148 44149 44150 44151 44152 44153 44154 44155 44156 44157 |
** Return false if any invariant is violated.
**
** This routine is for use inside of assert() statements only. For
** example:
**
** assert( sqlite3PcachePageSanity(pPg) );
*/
#ifdef SQLITE_DEBUG
SQLITE_PRIVATE int sqlite3PcachePageSanity(PgHdr *pPg){
PCache *pCache;
assert( pPg!=0 );
assert( pPg->pgno>0 || pPg->pPager==0 ); /* Page number is 1 or more */
pCache = pPg->pCache;
assert( pCache!=0 ); /* Every page has an associated PCache */
if( pPg->flags & PGHDR_CLEAN ){
|
| ︙ | ︙ | |||
63634 63635 63636 63637 63638 63639 63640 |
pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);
pCur->iPage++;
pCur->aiIdx[pCur->iPage] = 0;
return getAndInitPage(pBt, newPgno, &pCur->apPage[pCur->iPage],
pCur, pCur->curPagerFlags);
}
| | | 63695 63696 63697 63698 63699 63700 63701 63702 63703 63704 63705 63706 63707 63708 63709 |
pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);
pCur->iPage++;
pCur->aiIdx[pCur->iPage] = 0;
return getAndInitPage(pBt, newPgno, &pCur->apPage[pCur->iPage],
pCur, pCur->curPagerFlags);
}
#ifdef SQLITE_DEBUG
/*
** Page pParent is an internal (non-leaf) tree page. This function
** asserts that page number iChild is the left-child if the iIdx'th
** cell in page pParent. Or, if iIdx is equal to the total number of
** cells in pParent, that page number iChild is the right-child of
** the page.
*/
|
| ︙ | ︙ | |||
64176 64177 64178 64179 64180 64181 64182 64183 64184 64185 64186 64187 64188 64189 |
SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor *pCur){
/* TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries
** have been deleted? This API will need to change to return an error code
** as well as the boolean result value.
*/
return (CURSOR_VALID!=pCur->eState);
}
/*
** Advance the cursor to the next entry in the database. If
** successful then set *pRes=0. If the cursor
** was already pointing to the last entry in the database before
** this routine was called, then set *pRes=1.
**
| > > > > > > > > > > > > > > > > > > > > > > > > | 64237 64238 64239 64240 64241 64242 64243 64244 64245 64246 64247 64248 64249 64250 64251 64252 64253 64254 64255 64256 64257 64258 64259 64260 64261 64262 64263 64264 64265 64266 64267 64268 64269 64270 64271 64272 64273 64274 |
SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor *pCur){
/* TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries
** have been deleted? This API will need to change to return an error code
** as well as the boolean result value.
*/
return (CURSOR_VALID!=pCur->eState);
}
/*
** Return an estimate for the number of rows in the table that pCur is
** pointing to. Return a negative number if no estimate is currently
** available.
*/
SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor *pCur){
i64 n;
u8 i;
assert( cursorOwnsBtShared(pCur) );
assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
/* Currently this interface is only called by the OP_IfSmaller
** opcode, and it that case the cursor will always be valid and
** will always point to a leaf node. */
if( NEVER(pCur->eState!=CURSOR_VALID) ) return -1;
if( NEVER(pCur->apPage[pCur->iPage]->leaf==0) ) return -1;
for(n=1, i=0; i<=pCur->iPage; i++){
n *= pCur->apPage[i]->nCell;
}
return n;
}
/*
** Advance the cursor to the next entry in the database. If
** successful then set *pRes=0. If the cursor
** was already pointing to the last entry in the database before
** this routine was called, then set *pRes=1.
**
|
| ︙ | ︙ | |||
65021 65022 65023 65024 65025 65026 65027 | ** that means content must spill into overflow pages. ** *pnSize Size of the local cell (not counting overflow pages) ** pPrior Where to write the pgno of the first overflow page ** ** Use a call to btreeParseCellPtr() to verify that the values above ** were computed correctly. */ | | | 65106 65107 65108 65109 65110 65111 65112 65113 65114 65115 65116 65117 65118 65119 65120 |
** that means content must spill into overflow pages.
** *pnSize Size of the local cell (not counting overflow pages)
** pPrior Where to write the pgno of the first overflow page
**
** Use a call to btreeParseCellPtr() to verify that the values above
** were computed correctly.
*/
#ifdef SQLITE_DEBUG
{
CellInfo info;
pPage->xParseCell(pPage, pCell, &info);
assert( nHeader==(int)(info.pPayload - pCell) );
assert( info.nKey==pX->nKey );
assert( *pnSize == info.nSize );
assert( spaceLeft == info.nLocal );
|
| ︙ | ︙ | |||
73751 73752 73753 73754 73755 73756 73757 73758 73759 73760 73761 |
** SQLITE_INTERRUPT
**
** Then the internal cache might have been left in an inconsistent
** state. We need to rollback the statement transaction, if there is
** one, or the complete transaction if there is no statement transaction.
*/
if( db->mallocFailed ){
p->rc = SQLITE_NOMEM_BKPT;
}
closeAllCursors(p);
| > > > < < < | 73836 73837 73838 73839 73840 73841 73842 73843 73844 73845 73846 73847 73848 73849 73850 73851 73852 73853 73854 73855 73856 |
** SQLITE_INTERRUPT
**
** Then the internal cache might have been left in an inconsistent
** state. We need to rollback the statement transaction, if there is
** one, or the complete transaction if there is no statement transaction.
*/
if( p->magic!=VDBE_MAGIC_RUN ){
return SQLITE_OK;
}
if( db->mallocFailed ){
p->rc = SQLITE_NOMEM_BKPT;
}
closeAllCursors(p);
checkActiveVdbeCnt(db);
/* No commit or rollback needed if the program never started or if the
** SQL statement does not read or write a database file. */
if( p->pc>=0 && p->bIsReader ){
int mrc; /* Primary error code from p->rc */
int eStatementOp = 0;
|
| ︙ | ︙ | |||
74704 74705 74706 74707 74708 74709 74710 |
pMem++;
if( (++u)>=p->nField ) break;
}
assert( u<=pKeyInfo->nField + 1 );
p->nField = u;
}
| | | 74789 74790 74791 74792 74793 74794 74795 74796 74797 74798 74799 74800 74801 74802 74803 |
pMem++;
if( (++u)>=p->nField ) break;
}
assert( u<=pKeyInfo->nField + 1 );
p->nField = u;
}
#ifdef SQLITE_DEBUG
/*
** This function compares two index or table record keys in the same way
** as the sqlite3VdbeRecordCompare() routine. Unlike VdbeRecordCompare(),
** this function deserializes and compares values using the
** sqlite3VdbeSerialGet() and sqlite3MemCompare() functions. It is used
** in assert() statements to ensure that the optimized code in
** sqlite3VdbeRecordCompare() returns results with these two primitives.
|
| ︙ | ︙ | |||
74809 74810 74811 74812 74813 74814 74815 | if( desiredResult>0 && rc>0 ) return 1; if( CORRUPT_DB ) return 1; if( pKeyInfo->db->mallocFailed ) return 1; return 0; } #endif | | | 74894 74895 74896 74897 74898 74899 74900 74901 74902 74903 74904 74905 74906 74907 74908 | if( desiredResult>0 && rc>0 ) return 1; if( CORRUPT_DB ) return 1; if( pKeyInfo->db->mallocFailed ) return 1; return 0; } #endif #ifdef SQLITE_DEBUG /* ** Count the number of fields (a.k.a. columns) in the record given by ** pKey,nKey. The verify that this count is less than or equal to the ** limit given by pKeyInfo->nField + pKeyInfo->nXField. ** ** If this constraint is not satisfied, it means that the high-speed ** vdbeRecordCompareInt() and vdbeRecordCompareString() routines will |
| ︙ | ︙ | |||
79656 79657 79658 79659 79660 79661 79662 |
** reinitializes the relavant parts of the sqlite3_context object */
pOut = &aMem[pOp->p3];
if( pCtx->pOut != pOut ){
pCtx->pOut = pOut;
for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i];
}
| | | | | | | | | 79741 79742 79743 79744 79745 79746 79747 79748 79749 79750 79751 79752 79753 79754 79755 79756 79757 79758 79759 79760 79761 79762 79763 79764 79765 79766 79767 79768 79769 79770 79771 79772 79773 79774 79775 79776 79777 79778 79779 79780 79781 79782 79783 |
** reinitializes the relavant parts of the sqlite3_context object */
pOut = &aMem[pOp->p3];
if( pCtx->pOut != pOut ){
pCtx->pOut = pOut;
for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i];
}
memAboutToChange(p, pOut);
#ifdef SQLITE_DEBUG
for(i=0; i<pCtx->argc; i++){
assert( memIsValid(pCtx->argv[i]) );
REGISTER_TRACE(pOp->p2+i, pCtx->argv[i]);
}
#endif
MemSetTypeFlag(pOut, MEM_Null);
pCtx->fErrorOrAux = 0;
(*pCtx->pFunc->xSFunc)(pCtx, pCtx->argc, pCtx->argv);/* IMP: R-24505-23230 */
/* If the function returned an error, throw an exception */
if( pCtx->fErrorOrAux ){
if( pCtx->isError ){
sqlite3VdbeError(p, "%s", sqlite3_value_text(pOut));
rc = pCtx->isError;
}
sqlite3VdbeDeleteAuxData(db, &p->pAuxData, pCtx->iOp, pOp->p1);
if( rc ) goto abort_due_to_error;
}
/* Copy the result of the function into register P3 */
if( pOut->flags & (MEM_Str|MEM_Blob) ){
sqlite3VdbeChangeEncoding(pOut, encoding);
if( sqlite3VdbeMemTooBig(pOut) ) goto too_big;
}
REGISTER_TRACE(pOp->p3, pOut);
UPDATE_MAX_BLOBSIZE(pOut);
break;
}
/* Opcode: BitAnd P1 P2 P3 * *
** Synopsis: r[P3]=r[P1]&r[P2]
**
** Take the bit-wise AND of the values in register P1 and P2 and
|
| ︙ | ︙ | |||
80185 80186 80187 80188 80189 80190 80191 | } n = pOp->p3; pKeyInfo = pOp->p4.pKeyInfo; assert( n>0 ); assert( pKeyInfo!=0 ); p1 = pOp->p1; p2 = pOp->p2; | | | 80270 80271 80272 80273 80274 80275 80276 80277 80278 80279 80280 80281 80282 80283 80284 |
}
n = pOp->p3;
pKeyInfo = pOp->p4.pKeyInfo;
assert( n>0 );
assert( pKeyInfo!=0 );
p1 = pOp->p1;
p2 = pOp->p2;
#ifdef SQLITE_DEBUG
if( aPermute ){
int k, mx = 0;
for(k=0; k<n; k++) if( aPermute[k]>mx ) mx = aPermute[k];
assert( p1>0 && p1+mx<=(p->nMem+1 - p->nCursor)+1 );
assert( p2>0 && p2+mx<=(p->nMem+1 - p->nCursor)+1 );
}else{
assert( p1>0 && p1+n<=(p->nMem+1 - p->nCursor)+1 );
|
| ︙ | ︙ | |||
82834 82835 82836 82837 82838 82839 82840 82841 82842 82843 82844 82845 82846 82847 |
}
}else{
assert( pOp->p2==0 );
}
break;
}
/* Opcode: SorterSort P1 P2 * * *
**
** After all records have been inserted into the Sorter object
** identified by P1, invoke this opcode to actually do the sorting.
** Jump to P2 if there are no records to be sorted.
**
| > > > > > > > > > > > > > > > > > > > > > > > > > > > | 82919 82920 82921 82922 82923 82924 82925 82926 82927 82928 82929 82930 82931 82932 82933 82934 82935 82936 82937 82938 82939 82940 82941 82942 82943 82944 82945 82946 82947 82948 82949 82950 82951 82952 82953 82954 82955 82956 82957 82958 82959 |
}
}else{
assert( pOp->p2==0 );
}
break;
}
/* Opcode: IfSmaller P1 P2 P3 * *
**
** Estimate the number of rows in the table P1. Jump to P2 if that
** estimate is less than approximately 2**(0.1*P3).
*/
case OP_IfSmaller: { /* jump */
VdbeCursor *pC;
BtCursor *pCrsr;
int res;
i64 sz;
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
pC = p->apCsr[pOp->p1];
assert( pC!=0 );
pCrsr = pC->uc.pCursor;
assert( pCrsr );
rc = sqlite3BtreeFirst(pCrsr, &res);
if( rc ) goto abort_due_to_error;
if( res==0 ){
sz = sqlite3BtreeRowCountEst(pCrsr);
if( ALWAYS(sz>=0) && sqlite3LogEst((u64)sz)<pOp->p3 ) res = 1;
}
VdbeBranchTaken(res!=0,2);
if( res ) goto jump_to_p2;
break;
}
/* Opcode: SorterSort P1 P2 * * *
**
** After all records have been inserted into the Sorter object
** identified by P1, invoke this opcode to actually do the sorting.
** Jump to P2 if there are no records to be sorted.
**
|
| ︙ | ︙ | |||
83477 83478 83479 83480 83481 83482 83483 83484 83485 83486 83487 83488 83489 83490 |
flags = BTREE_BLOBKEY;
}
rc = sqlite3BtreeCreateTable(pDb->pBt, &pgno, flags);
if( rc ) goto abort_due_to_error;
pOut->u.i = pgno;
break;
}
/* Opcode: ParseSchema P1 * * P4 *
**
** Read and parse all entries from the SQLITE_MASTER table of database P1
** that match the WHERE clause P4.
**
** This opcode invokes the parser to create a new virtual machine,
| > > > > > > > > > > > > | 83589 83590 83591 83592 83593 83594 83595 83596 83597 83598 83599 83600 83601 83602 83603 83604 83605 83606 83607 83608 83609 83610 83611 83612 83613 83614 |
flags = BTREE_BLOBKEY;
}
rc = sqlite3BtreeCreateTable(pDb->pBt, &pgno, flags);
if( rc ) goto abort_due_to_error;
pOut->u.i = pgno;
break;
}
/* Opcode: SqlExec * * * P4 *
**
** Run the SQL statement or statements specified in the P4 string.
*/
case OP_SqlExec: {
db->nSqlExec++;
rc = sqlite3_exec(db, pOp->p4.z, 0, 0, 0);
db->nSqlExec--;
if( rc ) goto abort_due_to_error;
break;
}
/* Opcode: ParseSchema P1 * * P4 *
**
** Read and parse all entries from the SQLITE_MASTER table of database P1
** that match the WHERE clause P4.
**
** This opcode invokes the parser to create a new virtual machine,
|
| ︙ | ︙ | |||
83598 83599 83600 83601 83602 83603 83604 | #ifndef SQLITE_OMIT_INTEGRITY_CHECK /* Opcode: IntegrityCk P1 P2 P3 P4 P5 ** ** Do an analysis of the currently open database. Store in ** register P1 the text of an error message describing any problems. ** If no problems are found, store a NULL in register P1. ** | | | 83722 83723 83724 83725 83726 83727 83728 83729 83730 83731 83732 83733 83734 83735 83736 | #ifndef SQLITE_OMIT_INTEGRITY_CHECK /* Opcode: IntegrityCk P1 P2 P3 P4 P5 ** ** Do an analysis of the currently open database. Store in ** register P1 the text of an error message describing any problems. ** If no problems are found, store a NULL in register P1. ** ** The register P3 contains one less than the maximum number of allowed errors. ** At most reg(P3) errors will be reported. ** In other words, the analysis stops as soon as reg(P1) errors are ** seen. Reg(P1) is updated with the number of errors remaining. ** ** The root page numbers of all tables in the database are integers ** stored in P4_INTARRAY argument. ** |
| ︙ | ︙ | |||
83631 83632 83633 83634 83635 83636 83637 | pnErr = &aMem[pOp->p3]; assert( (pnErr->flags & MEM_Int)!=0 ); assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 ); pIn1 = &aMem[pOp->p1]; assert( pOp->p5<db->nDb ); assert( DbMaskTest(p->btreeMask, pOp->p5) ); z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, aRoot, nRoot, | | < > | 83755 83756 83757 83758 83759 83760 83761 83762 83763 83764 83765 83766 83767 83768 83769 83770 83771 83772 83773 83774 83775 83776 |
pnErr = &aMem[pOp->p3];
assert( (pnErr->flags & MEM_Int)!=0 );
assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 );
pIn1 = &aMem[pOp->p1];
assert( pOp->p5<db->nDb );
assert( DbMaskTest(p->btreeMask, pOp->p5) );
z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, aRoot, nRoot,
(int)pnErr->u.i+1, &nErr);
sqlite3VdbeMemSetNull(pIn1);
if( nErr==0 ){
assert( z==0 );
}else if( z==0 ){
goto no_mem;
}else{
pnErr->u.i -= nErr-1;
sqlite3VdbeMemSetStr(pIn1, z, -1, SQLITE_UTF8, sqlite3_free);
}
UPDATE_MAX_BLOBSIZE(pIn1);
sqlite3VdbeChangeEncoding(pIn1, encoding);
break;
}
#endif /* SQLITE_OMIT_INTEGRITY_CHECK */
|
| ︙ | ︙ | |||
92831 92832 92833 92834 92835 92836 92837 |
static char *exprINAffinity(Parse *pParse, Expr *pExpr){
Expr *pLeft = pExpr->pLeft;
int nVal = sqlite3ExprVectorSize(pLeft);
Select *pSelect = (pExpr->flags & EP_xIsSelect) ? pExpr->x.pSelect : 0;
char *zRet;
assert( pExpr->op==TK_IN );
| | | 92955 92956 92957 92958 92959 92960 92961 92962 92963 92964 92965 92966 92967 92968 92969 |
static char *exprINAffinity(Parse *pParse, Expr *pExpr){
Expr *pLeft = pExpr->pLeft;
int nVal = sqlite3ExprVectorSize(pLeft);
Select *pSelect = (pExpr->flags & EP_xIsSelect) ? pExpr->x.pSelect : 0;
char *zRet;
assert( pExpr->op==TK_IN );
zRet = sqlite3DbMallocRaw(pParse->db, nVal+1);
if( zRet ){
int i;
for(i=0; i<nVal; i++){
Expr *pA = sqlite3VectorFieldSubexpr(pLeft, i);
char a = sqlite3ExprAffinity(pA);
if( pSelect ){
zRet[i] = sqlite3CompareAffinity(pSelect->pEList->a[i].pExpr, a);
|
| ︙ | ︙ | |||
93736 93737 93738 93739 93740 93741 93742 |
/*
** Clear all column cache entries.
*/
SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse *pParse){
int i;
| | | 93860 93861 93862 93863 93864 93865 93866 93867 93868 93869 93870 93871 93872 93873 93874 |
/*
** Clear all column cache entries.
*/
SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse *pParse){
int i;
#ifdef SQLITE_DEBUG
if( pParse->db->flags & SQLITE_VdbeAddopTrace ){
printf("CLEAR\n");
}
#endif
for(i=0; i<pParse->nColCache; i++){
if( pParse->aColCache[i].tempReg
&& pParse->nTempReg<ArraySize(pParse->aTempReg)
|
| ︙ | ︙ | |||
95143 95144 95145 95146 95147 95148 95149 95150 95151 95152 95153 95154 95155 95156 |
Expr *pExprA = pA->a[i].pExpr;
Expr *pExprB = pB->a[i].pExpr;
if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1;
}
return 0;
}
/*
** Return true if we can prove the pE2 will always be true if pE1 is
** true. Return false if we cannot complete the proof or if pE2 might
** be false. Examples:
**
** pE1: x==5 pE2: x==5 Result: true
| > > > > > > > > > > > | 95267 95268 95269 95270 95271 95272 95273 95274 95275 95276 95277 95278 95279 95280 95281 95282 95283 95284 95285 95286 95287 95288 95289 95290 95291 |
Expr *pExprA = pA->a[i].pExpr;
Expr *pExprB = pB->a[i].pExpr;
if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1;
}
return 0;
}
/*
** Like sqlite3ExprCompare() except COLLATE operators at the top-level
** are ignored.
*/
SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){
return sqlite3ExprCompare(
sqlite3ExprSkipCollate(pA),
sqlite3ExprSkipCollate(pB),
iTab);
}
/*
** Return true if we can prove the pE2 will always be true if pE1 is
** true. Return false if we cannot complete the proof or if pE2 might
** be false. Examples:
**
** pE1: x==5 pE2: x==5 Result: true
|
| ︙ | ︙ | |||
96696 96697 96698 96699 96700 96701 96702 96703 96704 96705 96706 96707 96708 96709 | int nKeyCol; /* Number of index columns w/o the pk/rowid */ int mxSample; /* Maximum number of samples to accumulate */ Stat4Sample current; /* Current row as a Stat4Sample */ u32 iPrn; /* Pseudo-random number used for sampling */ Stat4Sample *aBest; /* Array of nCol best samples */ int iMin; /* Index in a[] of entry with minimum score */ int nSample; /* Current number of samples */ int iGet; /* Index of current sample accessed by stat_get() */ Stat4Sample *a; /* Array of mxSample Stat4Sample objects */ sqlite3 *db; /* Database connection, for malloc() */ }; /* Reclaim memory used by a Stat4Sample */ | > | 96831 96832 96833 96834 96835 96836 96837 96838 96839 96840 96841 96842 96843 96844 96845 | int nKeyCol; /* Number of index columns w/o the pk/rowid */ int mxSample; /* Maximum number of samples to accumulate */ Stat4Sample current; /* Current row as a Stat4Sample */ u32 iPrn; /* Pseudo-random number used for sampling */ Stat4Sample *aBest; /* Array of nCol best samples */ int iMin; /* Index in a[] of entry with minimum score */ int nSample; /* Current number of samples */ int nMaxEqZero; /* Max leading 0 in anEq[] for any a[] entry */ int iGet; /* Index of current sample accessed by stat_get() */ Stat4Sample *a; /* Array of mxSample Stat4Sample objects */ sqlite3 *db; /* Database connection, for malloc() */ }; /* Reclaim memory used by a Stat4Sample */ |
| ︙ | ︙ | |||
96960 96961 96962 96963 96964 96965 96966 96967 96968 96969 96970 96971 96972 96973 |
static void sampleInsert(Stat4Accum *p, Stat4Sample *pNew, int nEqZero){
Stat4Sample *pSample = 0;
int i;
assert( IsStat4 || nEqZero==0 );
#ifdef SQLITE_ENABLE_STAT4
if( pNew->isPSample==0 ){
Stat4Sample *pUpgrade = 0;
assert( pNew->anEq[pNew->iCol]>0 );
/* This sample is being added because the prefix that ends in column
** iCol occurs many times in the table. However, if we have already
** added a sample that shares this prefix, there is no need to add
| > > > > > > > | 97096 97097 97098 97099 97100 97101 97102 97103 97104 97105 97106 97107 97108 97109 97110 97111 97112 97113 97114 97115 97116 |
static void sampleInsert(Stat4Accum *p, Stat4Sample *pNew, int nEqZero){
Stat4Sample *pSample = 0;
int i;
assert( IsStat4 || nEqZero==0 );
#ifdef SQLITE_ENABLE_STAT4
/* Stat4Accum.nMaxEqZero is set to the maximum number of leading 0
** values in the anEq[] array of any sample in Stat4Accum.a[]. In
** other words, if nMaxEqZero is n, then it is guaranteed that there
** are no samples with Stat4Sample.anEq[m]==0 for (m>=n). */
if( nEqZero>p->nMaxEqZero ){
p->nMaxEqZero = nEqZero;
}
if( pNew->isPSample==0 ){
Stat4Sample *pUpgrade = 0;
assert( pNew->anEq[pNew->iCol]>0 );
/* This sample is being added because the prefix that ends in column
** iCol occurs many times in the table. However, if we have already
** added a sample that shares this prefix, there is no need to add
|
| ︙ | ︙ | |||
97057 97058 97059 97060 97061 97062 97063 97064 |
Stat4Sample *pBest = &p->aBest[i];
pBest->anEq[i] = p->current.anEq[i];
if( p->nSample<p->mxSample || sampleIsBetter(p, pBest, &p->a[p->iMin]) ){
sampleInsert(p, pBest, i);
}
}
/* Update the anEq[] fields of any samples already collected. */
| > > > > > > > > | | | | | > > | 97200 97201 97202 97203 97204 97205 97206 97207 97208 97209 97210 97211 97212 97213 97214 97215 97216 97217 97218 97219 97220 97221 97222 97223 97224 97225 97226 97227 97228 97229 |
Stat4Sample *pBest = &p->aBest[i];
pBest->anEq[i] = p->current.anEq[i];
if( p->nSample<p->mxSample || sampleIsBetter(p, pBest, &p->a[p->iMin]) ){
sampleInsert(p, pBest, i);
}
}
/* Check that no sample contains an anEq[] entry with an index of
** p->nMaxEqZero or greater set to zero. */
for(i=p->nSample-1; i>=0; i--){
int j;
for(j=p->nMaxEqZero; j<p->nCol; j++) assert( p->a[i].anEq[j]>0 );
}
/* Update the anEq[] fields of any samples already collected. */
if( iChng<p->nMaxEqZero ){
for(i=p->nSample-1; i>=0; i--){
int j;
for(j=iChng; j<p->nCol; j++){
if( p->a[i].anEq[j]==0 ) p->a[i].anEq[j] = p->current.anEq[j];
}
}
p->nMaxEqZero = iChng;
}
#endif
#if defined(SQLITE_ENABLE_STAT3) && !defined(SQLITE_ENABLE_STAT4)
if( iChng==0 ){
tRowcnt nLt = p->current.anLt[0];
tRowcnt nEq = p->current.anEq[0];
|
| ︙ | ︙ | |||
97776 97777 97778 97779 97780 97781 97782 |
assert( pName2!=0 || pName1==0 );
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);
}
| | | < < | | < < < < < < < < < < < | | | | | > | 97929 97930 97931 97932 97933 97934 97935 97936 97937 97938 97939 97940 97941 97942 97943 97944 97945 97946 97947 97948 97949 97950 97951 97952 97953 97954 97955 97956 97957 97958 97959 97960 97961 97962 97963 97964 |
assert( pName2!=0 || pName1==0 );
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->n==0 && (iDb = sqlite3FindDb(db, pName1))>=0 ){
/* Analyze the schema named as the argument */
analyzeDatabase(pParse, iDb);
}else{
/* Form 3: Analyze the table or index named as an argument */
iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pTableName);
if( iDb>=0 ){
zDb = pName2->n ? db->aDb[iDb].zDbSName : 0;
z = sqlite3NameFromToken(db, pTableName);
if( z ){
if( (pIdx = sqlite3FindIndex(db, z, zDb))!=0 ){
analyzeTable(pParse, pIdx->pTable, pIdx);
}else if( (pTab = sqlite3LocateTable(pParse, 0, z, zDb))!=0 ){
analyzeTable(pParse, pTab, 0);
}
sqlite3DbFree(db, z);
}
}
}
if( db->nSqlExec==0 && (v = sqlite3GetVdbe(pParse))!=0 ){
sqlite3VdbeAddOp0(v, OP_Expire);
}
}
/*
** Used to pass information from the analyzer reader through to the
** callback routine.
*/
typedef struct analysisInfo analysisInfo;
|
| ︙ | ︙ | |||
97938 97939 97940 97941 97942 97943 97944 |
pIndex->aiRowEst = (tRowcnt*)sqlite3MallocZero(sizeof(tRowcnt) * nCol);
if( pIndex->aiRowEst==0 ) sqlite3OomFault(pInfo->db);
}
aiRowEst = pIndex->aiRowEst;
#endif
pIndex->bUnordered = 0;
decodeIntArray((char*)z, nCol, aiRowEst, pIndex->aiRowLogEst, pIndex);
| > | > > > > | 98079 98080 98081 98082 98083 98084 98085 98086 98087 98088 98089 98090 98091 98092 98093 98094 98095 98096 98097 98098 98099 98100 98101 98102 98103 98104 98105 98106 |
pIndex->aiRowEst = (tRowcnt*)sqlite3MallocZero(sizeof(tRowcnt) * nCol);
if( pIndex->aiRowEst==0 ) sqlite3OomFault(pInfo->db);
}
aiRowEst = pIndex->aiRowEst;
#endif
pIndex->bUnordered = 0;
decodeIntArray((char*)z, nCol, aiRowEst, pIndex->aiRowLogEst, pIndex);
pIndex->hasStat1 = 1;
if( pIndex->pPartIdxWhere==0 ){
pTable->nRowLogEst = pIndex->aiRowLogEst[0];
pTable->tabFlags |= TF_HasStat1;
}
}else{
Index fakeIdx;
fakeIdx.szIdxRow = pTable->szTabRow;
#ifdef SQLITE_ENABLE_COSTMULT
fakeIdx.pTable = pTable;
#endif
decodeIntArray((char*)z, 1, 0, &pTable->nRowLogEst, &fakeIdx);
pTable->szTabRow = fakeIdx.szIdxRow;
pTable->tabFlags |= TF_HasStat1;
}
return 0;
}
/*
** If the Index.aSample variable is not NULL, delete the aSample[] array
|
| ︙ | ︙ | |||
98241 98242 98243 98244 98245 98246 98247 98248 98249 98250 98251 98252 98253 |
** code may be ignored.
*/
SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
analysisInfo sInfo;
HashElem *i;
char *zSql;
int rc = SQLITE_OK;
assert( iDb>=0 && iDb<db->nDb );
assert( db->aDb[iDb].pBt!=0 );
/* Clear any prior statistics */
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
| > | > > > > | | 98387 98388 98389 98390 98391 98392 98393 98394 98395 98396 98397 98398 98399 98400 98401 98402 98403 98404 98405 98406 98407 98408 98409 98410 98411 98412 98413 98414 |
** code may be ignored.
*/
SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
analysisInfo sInfo;
HashElem *i;
char *zSql;
int rc = SQLITE_OK;
Schema *pSchema = db->aDb[iDb].pSchema;
assert( iDb>=0 && iDb<db->nDb );
assert( db->aDb[iDb].pBt!=0 );
/* Clear any prior statistics */
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
for(i=sqliteHashFirst(&pSchema->tblHash); i; i=sqliteHashNext(i)){
Table *pTab = sqliteHashData(i);
pTab->tabFlags &= ~TF_HasStat1;
}
for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
Index *pIdx = sqliteHashData(i);
pIdx->hasStat1 = 0;
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
sqlite3DeleteIndexSamples(db, pIdx);
pIdx->aSample = 0;
#endif
}
/* Load new statistics out of the sqlite_stat1 table */
|
| ︙ | ︙ | |||
98272 98273 98274 98275 98276 98277 98278 |
rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);
sqlite3DbFree(db, zSql);
}
}
/* Set appropriate defaults on all indexes not in the sqlite_stat1 table */
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
| | | | | 98423 98424 98425 98426 98427 98428 98429 98430 98431 98432 98433 98434 98435 98436 98437 98438 98439 98440 98441 98442 98443 98444 98445 98446 98447 98448 98449 |
rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);
sqlite3DbFree(db, zSql);
}
}
/* Set appropriate defaults on all indexes not in the sqlite_stat1 table */
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
Index *pIdx = sqliteHashData(i);
if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx);
}
/* Load the statistics from the sqlite_stat4 table. */
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
if( rc==SQLITE_OK && OptimizationEnabled(db, SQLITE_Stat34) ){
db->lookaside.bDisable++;
rc = loadStat4(db, sInfo.zDatabase);
db->lookaside.bDisable--;
}
for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
Index *pIdx = sqliteHashData(i);
sqlite3_free(pIdx->aiRowEst);
pIdx->aiRowEst = 0;
}
#endif
if( rc==SQLITE_NOMEM ){
|
| ︙ | ︙ | |||
100269 100270 100271 100272 100273 100274 100275 100276 100277 100278 100279 100280 100281 100282 |
** the column currently under construction.
*/
SQLITE_PRIVATE void sqlite3AddNotNull(Parse *pParse, int onError){
Table *p;
p = pParse->pNewTable;
if( p==0 || NEVER(p->nCol<1) ) return;
p->aCol[p->nCol-1].notNull = (u8)onError;
}
/*
** Scan the column type name zType (length nType) and return the
** associated affinity type.
**
** This routine does a case-independent search of zType for the
| > | 100420 100421 100422 100423 100424 100425 100426 100427 100428 100429 100430 100431 100432 100433 100434 |
** the column currently under construction.
*/
SQLITE_PRIVATE void sqlite3AddNotNull(Parse *pParse, int onError){
Table *p;
p = pParse->pNewTable;
if( p==0 || NEVER(p->nCol<1) ) return;
p->aCol[p->nCol-1].notNull = (u8)onError;
p->tabFlags |= TF_HasNotNull;
}
/*
** Scan the column type name zType (length nType) and return the
** associated affinity type.
**
** This routine does a case-independent search of zType for the
|
| ︙ | ︙ | |||
102607 102608 102609 102610 102611 102612 102613 102614 102615 102616 102617 102618 102619 102620 |
*/
SQLITE_PRIVATE void sqlite3DefaultRowEst(Index *pIdx){
/* 10, 9, 8, 7, 6 */
LogEst aVal[] = { 33, 32, 30, 28, 26 };
LogEst *a = pIdx->aiRowLogEst;
int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);
int i;
/* Set the first entry (number of rows in the index) to the estimated
** number of rows in the table, or half the number of rows in the table
** for a partial index. But do not let the estimate drop below 10. */
a[0] = pIdx->pTable->nRowLogEst;
if( pIdx->pPartIdxWhere!=0 ) a[0] -= 10; assert( 10==sqlite3LogEst(2) );
if( a[0]<33 ) a[0] = 33; assert( 33==sqlite3LogEst(10) );
| > > > | 102759 102760 102761 102762 102763 102764 102765 102766 102767 102768 102769 102770 102771 102772 102773 102774 102775 |
*/
SQLITE_PRIVATE void sqlite3DefaultRowEst(Index *pIdx){
/* 10, 9, 8, 7, 6 */
LogEst aVal[] = { 33, 32, 30, 28, 26 };
LogEst *a = pIdx->aiRowLogEst;
int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);
int i;
/* Indexes with default row estimates should not have stat1 data */
assert( !pIdx->hasStat1 );
/* Set the first entry (number of rows in the index) to the estimated
** number of rows in the table, or half the number of rows in the table
** for a partial index. But do not let the estimate drop below 10. */
a[0] = pIdx->pTable->nRowLogEst;
if( pIdx->pPartIdxWhere!=0 ) a[0] -= 10; assert( 10==sqlite3LogEst(2) );
if( a[0]<33 ) a[0] = 33; assert( 33==sqlite3LogEst(10) );
|
| ︙ | ︙ | |||
109796 109797 109798 109799 109800 109801 109802 109803 109804 109805 109806 109807 109808 109809 |
}
sqlite3VdbeAddOp2(v, iField<0 ? OP_IntCopy : OP_SCopy, x, regIdx+i);
VdbeComment((v, "%s", iField<0 ? "rowid" : pTab->aCol[iField].zName));
}
}
sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);
VdbeComment((v, "for %s", pIdx->zName));
/* In an UPDATE operation, if this index is the PRIMARY KEY index
** of a WITHOUT ROWID table and there has been no change the
** primary key, then no collision is possible. The collision detection
** logic below can all be skipped. */
if( isUpdate && pPk==pIdx && pkChng==0 ){
sqlite3VdbeResolveLabel(v, addrUniqueOk);
| > > > | 109951 109952 109953 109954 109955 109956 109957 109958 109959 109960 109961 109962 109963 109964 109965 109966 109967 |
}
sqlite3VdbeAddOp2(v, iField<0 ? OP_IntCopy : OP_SCopy, x, regIdx+i);
VdbeComment((v, "%s", iField<0 ? "rowid" : pTab->aCol[iField].zName));
}
}
sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);
VdbeComment((v, "for %s", pIdx->zName));
#ifdef SQLITE_ENABLE_NULL_TRIM
if( pIdx->idxType==2 ) sqlite3SetMakeRecordP5(v, pIdx->pTable);
#endif
/* In an UPDATE operation, if this index is the PRIMARY KEY index
** of a WITHOUT ROWID table and there has been no change the
** primary key, then no collision is possible. The collision detection
** logic below can all be skipped. */
if( isUpdate && pPk==pIdx && pkChng==0 ){
sqlite3VdbeResolveLabel(v, addrUniqueOk);
|
| ︙ | ︙ | |||
109951 109952 109953 109954 109955 109956 109957 |
SQLITE_PRIVATE void sqlite3SetMakeRecordP5(Vdbe *v, Table *pTab){
u16 i;
/* Records with omitted columns are only allowed for schema format
** version 2 and later (SQLite version 3.1.4, 2005-02-20). */
if( pTab->pSchema->file_format<2 ) return;
| | > > > | | 110109 110110 110111 110112 110113 110114 110115 110116 110117 110118 110119 110120 110121 110122 110123 110124 110125 110126 110127 |
SQLITE_PRIVATE void sqlite3SetMakeRecordP5(Vdbe *v, Table *pTab){
u16 i;
/* Records with omitted columns are only allowed for schema format
** version 2 and later (SQLite version 3.1.4, 2005-02-20). */
if( pTab->pSchema->file_format<2 ) return;
for(i=pTab->nCol-1; i>0; i--){
if( pTab->aCol[i].pDflt!=0 ) break;
if( pTab->aCol[i].colFlags & COLFLAG_PRIMKEY ) break;
}
sqlite3VdbeChangeP5(v, i+1);
}
#endif
/*
** This routine generates code to finish the INSERT or UPDATE operation
** that was started by a prior call to sqlite3GenerateConstraintChecks.
** A consecutive range of registers starting at regNewData contains the
|
| ︙ | ︙ | |||
110242 110243 110244 110245 110246 110247 110248 |
** error if pSelect reads from a CTE named "xxx". */
return 0;
}
if( sqlite3TriggerList(pParse, pDest) ){
return 0; /* tab1 must not have triggers */
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
| | | 110403 110404 110405 110406 110407 110408 110409 110410 110411 110412 110413 110414 110415 110416 110417 |
** error if pSelect reads from a CTE named "xxx". */
return 0;
}
if( sqlite3TriggerList(pParse, pDest) ){
return 0; /* tab1 must not have triggers */
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
if( IsVirtual(pDest) ){
return 0; /* tab1 must not be a virtual table */
}
#endif
if( onError==OE_Default ){
if( pDest->iPKey>=0 ) onError = pDest->keyConf;
if( onError==OE_Default ) onError = OE_Abort;
}
|
| ︙ | ︙ | |||
110304 110305 110306 110307 110308 110309 110310 |
if( pSrc==pDest ){
return 0; /* tab1 and tab2 may not be the same table */
}
if( HasRowid(pDest)!=HasRowid(pSrc) ){
return 0; /* source and destination must both be WITHOUT ROWID or not */
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
| | | 110465 110466 110467 110468 110469 110470 110471 110472 110473 110474 110475 110476 110477 110478 110479 |
if( pSrc==pDest ){
return 0; /* tab1 and tab2 may not be the same table */
}
if( HasRowid(pDest)!=HasRowid(pSrc) ){
return 0; /* source and destination must both be WITHOUT ROWID or not */
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
if( IsVirtual(pSrc) ){
return 0; /* tab2 must not be a virtual table */
}
#endif
if( pSrc->pSelect ){
return 0; /* tab2 may not be a view */
}
if( pDest->nCol!=pSrc->nCol ){
|
| ︙ | ︙ | |||
110601 110602 110603 110604 110605 110606 110607 |
rc = sqlite3_step(pStmt);
/* Invoke the callback function if required */
if( xCallback && (SQLITE_ROW==rc ||
(SQLITE_DONE==rc && !callbackIsInit
&& db->flags&SQLITE_NullCallback)) ){
if( !callbackIsInit ){
| | > | 110762 110763 110764 110765 110766 110767 110768 110769 110770 110771 110772 110773 110774 110775 110776 110777 110778 110779 110780 110781 110782 110783 110784 110785 110786 110787 110788 110789 110790 110791 110792 110793 110794 110795 110796 110797 |
rc = sqlite3_step(pStmt);
/* Invoke the callback function if required */
if( xCallback && (SQLITE_ROW==rc ||
(SQLITE_DONE==rc && !callbackIsInit
&& db->flags&SQLITE_NullCallback)) ){
if( !callbackIsInit ){
azCols = sqlite3DbMallocRaw(db, (2*nCol+1)*sizeof(const char*));
if( azCols==0 ){
goto exec_out;
}
for(i=0; i<nCol; i++){
azCols[i] = (char *)sqlite3_column_name(pStmt, i);
/* sqlite3VdbeSetColName() installs column names as UTF8
** strings so there is no way for sqlite3_column_name() to fail. */
assert( azCols[i]!=0 );
}
callbackIsInit = 1;
}
if( rc==SQLITE_ROW ){
azVals = &azCols[nCol];
for(i=0; i<nCol; i++){
azVals[i] = (char *)sqlite3_column_text(pStmt, i);
if( !azVals[i] && sqlite3_column_type(pStmt, i)!=SQLITE_NULL ){
sqlite3OomFault(db);
goto exec_out;
}
}
azVals[i] = 0;
}
if( xCallback(pArg, nCol, azVals, azCols) ){
/* EVIDENCE-OF: R-38229-40159 If the callback function to
** sqlite3_exec() returns non-zero, then sqlite3_exec() will
** return SQLITE_ABORT. */
rc = SQLITE_ABORT;
sqlite3VdbeFinalize((Vdbe *)pStmt);
|
| ︙ | ︙ | |||
112092 112093 112094 112095 112096 112097 112098 | #define PragTyp_INTEGRITY_CHECK 18 #define PragTyp_JOURNAL_MODE 19 #define PragTyp_JOURNAL_SIZE_LIMIT 20 #define PragTyp_LOCK_PROXY_FILE 21 #define PragTyp_LOCKING_MODE 22 #define PragTyp_PAGE_COUNT 23 #define PragTyp_MMAP_SIZE 24 | > | | | | < > | 112254 112255 112256 112257 112258 112259 112260 112261 112262 112263 112264 112265 112266 112267 112268 112269 112270 112271 112272 112273 112274 112275 112276 112277 112278 112279 112280 112281 112282 112283 112284 112285 112286 | #define PragTyp_INTEGRITY_CHECK 18 #define PragTyp_JOURNAL_MODE 19 #define PragTyp_JOURNAL_SIZE_LIMIT 20 #define PragTyp_LOCK_PROXY_FILE 21 #define PragTyp_LOCKING_MODE 22 #define PragTyp_PAGE_COUNT 23 #define PragTyp_MMAP_SIZE 24 #define PragTyp_OPTIMIZE 25 #define PragTyp_PAGE_SIZE 26 #define PragTyp_SECURE_DELETE 27 #define PragTyp_SHRINK_MEMORY 28 #define PragTyp_SOFT_HEAP_LIMIT 29 #define PragTyp_SYNCHRONOUS 30 #define PragTyp_TABLE_INFO 31 #define PragTyp_TEMP_STORE 32 #define PragTyp_TEMP_STORE_DIRECTORY 33 #define PragTyp_THREADS 34 #define PragTyp_WAL_AUTOCHECKPOINT 35 #define PragTyp_WAL_CHECKPOINT 36 #define PragTyp_ACTIVATE_EXTENSIONS 37 #define PragTyp_HEXKEY 38 #define PragTyp_KEY 39 #define PragTyp_REKEY 40 #define PragTyp_LOCK_STATUS 41 #define PragTyp_PARSER_TRACE 42 #define PragTyp_STATS 43 /* Property flags associated with various pragma. */ #define PragFlg_NeedSchema 0x01 /* Force schema load before running */ #define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */ #define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */ #define PragFlg_ReadOnly 0x08 /* Read-only HEADER_VALUE */ #define PragFlg_Result0 0x10 /* Acts as query when no argument */ |
| ︙ | ︙ | |||
112133 112134 112135 112136 112137 112138 112139 | /* 0 */ "cache_size", /* Used by: default_cache_size */ /* 1 */ "cid", /* Used by: table_info */ /* 2 */ "name", /* 3 */ "type", /* 4 */ "notnull", /* 5 */ "dflt_value", /* 6 */ "pk", | | | | | | | | | | | | | | | | | | | | | | > | | | < | | | | | | | | | | > | | | | | | | 112296 112297 112298 112299 112300 112301 112302 112303 112304 112305 112306 112307 112308 112309 112310 112311 112312 112313 112314 112315 112316 112317 112318 112319 112320 112321 112322 112323 112324 112325 112326 112327 112328 112329 112330 112331 112332 112333 112334 112335 112336 112337 112338 112339 112340 112341 112342 112343 112344 112345 112346 112347 112348 112349 112350 112351 |
/* 0 */ "cache_size", /* Used by: default_cache_size */
/* 1 */ "cid", /* Used by: table_info */
/* 2 */ "name",
/* 3 */ "type",
/* 4 */ "notnull",
/* 5 */ "dflt_value",
/* 6 */ "pk",
/* 7 */ "tbl", /* Used by: stats */
/* 8 */ "idx",
/* 9 */ "wdth",
/* 10 */ "hght",
/* 11 */ "flgs",
/* 12 */ "seqno", /* Used by: index_info */
/* 13 */ "cid",
/* 14 */ "name",
/* 15 */ "seqno", /* Used by: index_xinfo */
/* 16 */ "cid",
/* 17 */ "name",
/* 18 */ "desc",
/* 19 */ "coll",
/* 20 */ "key",
/* 21 */ "seq", /* Used by: index_list */
/* 22 */ "name",
/* 23 */ "unique",
/* 24 */ "origin",
/* 25 */ "partial",
/* 26 */ "seq", /* Used by: database_list */
/* 27 */ "name",
/* 28 */ "file",
/* 29 */ "seq", /* Used by: collation_list */
/* 30 */ "name",
/* 31 */ "id", /* Used by: foreign_key_list */
/* 32 */ "seq",
/* 33 */ "table",
/* 34 */ "from",
/* 35 */ "to",
/* 36 */ "on_update",
/* 37 */ "on_delete",
/* 38 */ "match",
/* 39 */ "table", /* Used by: foreign_key_check */
/* 40 */ "rowid",
/* 41 */ "parent",
/* 42 */ "fkid",
/* 43 */ "busy", /* Used by: wal_checkpoint */
/* 44 */ "log",
/* 45 */ "checkpointed",
/* 46 */ "timeout", /* Used by: busy_timeout */
/* 47 */ "database", /* Used by: lock_status */
/* 48 */ "status",
};
/* Definitions of all built-in pragmas */
typedef struct PragmaName {
const char *const zName; /* Name of pragma */
u8 ePragTyp; /* PragTyp_XXX value */
u8 mPragFlg; /* Zero or more PragFlg_XXX values */
|
| ︙ | ︙ | |||
112219 112220 112221 112222 112223 112224 112225 |
/* ColNames: */ 0, 0,
/* iArg: */ SQLITE_AutoIndex },
#endif
#endif
{/* zName: */ "busy_timeout",
/* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
/* ePragFlg: */ PragFlg_Result0,
| | | 112383 112384 112385 112386 112387 112388 112389 112390 112391 112392 112393 112394 112395 112396 112397 |
/* ColNames: */ 0, 0,
/* iArg: */ SQLITE_AutoIndex },
#endif
#endif
{/* zName: */ "busy_timeout",
/* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
/* ePragFlg: */ PragFlg_Result0,
/* ColNames: */ 46, 1,
/* iArg: */ 0 },
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
{/* zName: */ "cache_size",
/* ePragTyp: */ PragTyp_CACHE_SIZE,
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
|
| ︙ | ︙ | |||
112256 112257 112258 112259 112260 112261 112262 |
/* ColNames: */ 0, 0,
/* iArg: */ SQLITE_CkptFullFSync },
#endif
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
{/* zName: */ "collation_list",
/* ePragTyp: */ PragTyp_COLLATION_LIST,
/* ePragFlg: */ PragFlg_Result0,
| | | 112420 112421 112422 112423 112424 112425 112426 112427 112428 112429 112430 112431 112432 112433 112434 |
/* ColNames: */ 0, 0,
/* iArg: */ SQLITE_CkptFullFSync },
#endif
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
{/* zName: */ "collation_list",
/* ePragTyp: */ PragTyp_COLLATION_LIST,
/* ePragFlg: */ PragFlg_Result0,
/* ColNames: */ 29, 2,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
{/* zName: */ "compile_options",
/* ePragTyp: */ PragTyp_COMPILE_OPTIONS,
/* ePragFlg: */ PragFlg_Result0,
/* ColNames: */ 0, 0,
|
| ︙ | ︙ | |||
112291 112292 112293 112294 112295 112296 112297 |
/* ColNames: */ 0, 0,
/* iArg: */ BTREE_DATA_VERSION },
#endif
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
{/* zName: */ "database_list",
/* ePragTyp: */ PragTyp_DATABASE_LIST,
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
| | | 112455 112456 112457 112458 112459 112460 112461 112462 112463 112464 112465 112466 112467 112468 112469 |
/* ColNames: */ 0, 0,
/* iArg: */ BTREE_DATA_VERSION },
#endif
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
{/* zName: */ "database_list",
/* ePragTyp: */ PragTyp_DATABASE_LIST,
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
/* ColNames: */ 26, 3,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
{/* zName: */ "default_cache_size",
/* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE,
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
/* ColNames: */ 0, 1,
|
| ︙ | ︙ | |||
112328 112329 112330 112331 112332 112333 112334 |
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
{/* zName: */ "foreign_key_check",
/* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
/* ePragFlg: */ PragFlg_NeedSchema,
| | | | 112492 112493 112494 112495 112496 112497 112498 112499 112500 112501 112502 112503 112504 112505 112506 112507 112508 112509 112510 112511 112512 112513 |
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
{/* zName: */ "foreign_key_check",
/* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
/* ePragFlg: */ PragFlg_NeedSchema,
/* ColNames: */ 39, 4,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_FOREIGN_KEY)
{/* zName: */ "foreign_key_list",
/* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST,
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
/* ColNames: */ 31, 8,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
{/* zName: */ "foreign_keys",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
| ︙ | ︙ | |||
112398 112399 112400 112401 112402 112403 112404 |
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
{/* zName: */ "index_info",
/* ePragTyp: */ PragTyp_INDEX_INFO,
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
| | | | | 112562 112563 112564 112565 112566 112567 112568 112569 112570 112571 112572 112573 112574 112575 112576 112577 112578 112579 112580 112581 112582 112583 112584 112585 112586 |
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
{/* zName: */ "index_info",
/* ePragTyp: */ PragTyp_INDEX_INFO,
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
/* ColNames: */ 12, 3,
/* iArg: */ 0 },
{/* zName: */ "index_list",
/* ePragTyp: */ PragTyp_INDEX_LIST,
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
/* ColNames: */ 21, 5,
/* iArg: */ 0 },
{/* zName: */ "index_xinfo",
/* ePragTyp: */ PragTyp_INDEX_INFO,
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
/* ColNames: */ 15, 6,
/* iArg: */ 1 },
#endif
#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
{/* zName: */ "integrity_check",
/* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
/* ePragFlg: */ PragFlg_NeedSchema,
/* ColNames: */ 0, 0,
|
| ︙ | ︙ | |||
112455 112456 112457 112458 112459 112460 112461 |
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
#endif
#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
{/* zName: */ "lock_status",
/* ePragTyp: */ PragTyp_LOCK_STATUS,
/* ePragFlg: */ PragFlg_Result0,
| | > > > > > > > | 112619 112620 112621 112622 112623 112624 112625 112626 112627 112628 112629 112630 112631 112632 112633 112634 112635 112636 112637 112638 112639 112640 112641 112642 112643 112644 112645 112646 112647 112648 112649 112650 112651 112652 112653 112654 112655 112656 112657 112658 |
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
#endif
#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
{/* zName: */ "lock_status",
/* ePragTyp: */ PragTyp_LOCK_STATUS,
/* ePragFlg: */ PragFlg_Result0,
/* ColNames: */ 47, 2,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
{/* zName: */ "locking_mode",
/* ePragTyp: */ PragTyp_LOCKING_MODE,
/* ePragFlg: */ PragFlg_Result0|PragFlg_SchemaReq,
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
{/* zName: */ "max_page_count",
/* ePragTyp: */ PragTyp_PAGE_COUNT,
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
{/* zName: */ "mmap_size",
/* ePragTyp: */ PragTyp_MMAP_SIZE,
/* ePragFlg: */ 0,
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
#endif
{/* zName: */ "optimize",
/* ePragTyp: */ PragTyp_OPTIMIZE,
/* ePragFlg: */ PragFlg_NoColumns,
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
{/* zName: */ "page_count",
/* ePragTyp: */ PragTyp_PAGE_COUNT,
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
{/* zName: */ "page_size",
/* ePragTyp: */ PragTyp_PAGE_SIZE,
|
| ︙ | ︙ | |||
112572 112573 112574 112575 112576 112577 112578 |
{/* zName: */ "sql_trace",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
/* ColNames: */ 0, 0,
/* iArg: */ SQLITE_SqlTrace },
#endif
#endif
| | | | 112743 112744 112745 112746 112747 112748 112749 112750 112751 112752 112753 112754 112755 112756 112757 112758 112759 112760 112761 |
{/* zName: */ "sql_trace",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
/* ColNames: */ 0, 0,
/* iArg: */ SQLITE_SqlTrace },
#endif
#endif
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) && defined(SQLITE_DEBUG)
{/* zName: */ "stats",
/* ePragTyp: */ PragTyp_STATS,
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
/* ColNames: */ 7, 5,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
{/* zName: */ "synchronous",
/* ePragTyp: */ PragTyp_SYNCHRONOUS,
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
/* ColNames: */ 0, 0,
|
| ︙ | ︙ | |||
112655 112656 112657 112658 112659 112660 112661 |
/* ePragTyp: */ PragTyp_WAL_AUTOCHECKPOINT,
/* ePragFlg: */ 0,
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
{/* zName: */ "wal_checkpoint",
/* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
/* ePragFlg: */ PragFlg_NeedSchema,
| | | | 112826 112827 112828 112829 112830 112831 112832 112833 112834 112835 112836 112837 112838 112839 112840 112841 112842 112843 112844 112845 112846 112847 112848 112849 112850 112851 |
/* ePragTyp: */ PragTyp_WAL_AUTOCHECKPOINT,
/* ePragFlg: */ 0,
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
{/* zName: */ "wal_checkpoint",
/* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
/* ePragFlg: */ PragFlg_NeedSchema,
/* ColNames: */ 43, 3,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
{/* zName: */ "writable_schema",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
/* ColNames: */ 0, 0,
/* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
#endif
};
/* Number of pragmas: 60 on by default, 74 total. */
/************** End of pragma.h **********************************************/
/************** Continuing where we left off in pragma.c *********************/
/*
** Interpret the given string as a safety level. Return 0 for OFF,
** 1 for ON or NORMAL, 2 for FULL, and 3 for EXTRA. Return 1 for an empty or
|
| ︙ | ︙ | |||
112935 112936 112937 112938 112939 112940 112941 112942 112943 112944 112945 112946 112947 112948 |
upr = mid - 1;
}else{
lwr = mid + 1;
}
}
return lwr>upr ? 0 : &aPragmaName[mid];
}
/*
** Process a pragma statement.
**
** Pragmas are of this form:
**
** PRAGMA [schema.]id [= value]
| > > > > > > > > > > > > > > > > | 113106 113107 113108 113109 113110 113111 113112 113113 113114 113115 113116 113117 113118 113119 113120 113121 113122 113123 113124 113125 113126 113127 113128 113129 113130 113131 113132 113133 113134 113135 |
upr = mid - 1;
}else{
lwr = mid + 1;
}
}
return lwr>upr ? 0 : &aPragmaName[mid];
}
/*
** Helper subroutine for PRAGMA integrity_check:
**
** Generate code to output a single-column result row with the result
** held in register regResult. Decrement the result count and halt if
** the maximum number of result rows have been issued.
*/
static int integrityCheckResultRow(Vdbe *v, int regResult){
int addr;
sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 1);
addr = sqlite3VdbeAddOp3(v, OP_IfPos, 1, sqlite3VdbeCurrentAddr(v)+2, 1);
VdbeCoverage(v);
sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
return addr;
}
/*
** Process a pragma statement.
**
** Pragmas are of this form:
**
** PRAGMA [schema.]id [= value]
|
| ︙ | ︙ | |||
113739 113740 113741 113742 113743 113744 113745 113746 113747 113748 |
k);
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
}
}
}
break;
case PragTyp_STATS: {
Index *pIdx;
HashElem *i;
| > | | | > | | | > | > | 113926 113927 113928 113929 113930 113931 113932 113933 113934 113935 113936 113937 113938 113939 113940 113941 113942 113943 113944 113945 113946 113947 113948 113949 113950 113951 113952 113953 113954 113955 113956 113957 113958 113959 113960 113961 113962 113963 113964 113965 113966 |
k);
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
}
}
}
break;
#ifdef SQLITE_DEBUG
case PragTyp_STATS: {
Index *pIdx;
HashElem *i;
pParse->nMem = 5;
sqlite3CodeVerifySchema(pParse, iDb);
for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){
Table *pTab = sqliteHashData(i);
sqlite3VdbeMultiLoad(v, 1, "ssiii",
pTab->zName,
0,
pTab->szTabRow,
pTab->nRowLogEst,
pTab->tabFlags);
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
sqlite3VdbeMultiLoad(v, 2, "siii",
pIdx->zName,
pIdx->szIdxRow,
pIdx->aiRowLogEst[0],
pIdx->hasStat1);
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
}
}
}
break;
#endif
case PragTyp_INDEX_INFO: if( zRight ){
Index *pIdx;
Table *pTab;
pIdx = sqlite3FindIndex(db, zRight, zDb);
if( pIdx ){
int i;
|
| ︙ | ︙ | |||
114018 114019 114020 114021 114022 114023 114024 | break; #ifndef SQLITE_INTEGRITY_CHECK_ERROR_MAX # define SQLITE_INTEGRITY_CHECK_ERROR_MAX 100 #endif #ifndef SQLITE_OMIT_INTEGRITY_CHECK | > > > > > > > | | > | 114209 114210 114211 114212 114213 114214 114215 114216 114217 114218 114219 114220 114221 114222 114223 114224 114225 114226 114227 114228 114229 114230 114231 114232 114233 |
break;
#ifndef SQLITE_INTEGRITY_CHECK_ERROR_MAX
# define SQLITE_INTEGRITY_CHECK_ERROR_MAX 100
#endif
#ifndef SQLITE_OMIT_INTEGRITY_CHECK
/* PRAGMA integrity_check
** PRAGMA integrity_check(N)
** PRAGMA quick_check
** PRAGMA quick_check(N)
**
** Verify the integrity of the database.
**
** The "quick_check" is reduced version of
** integrity_check designed to detect most database corruption
** without the overhead of cross-checking indexes. Quick_check
** is linear time wherease integrity_check is O(NlogN).
*/
case PragTyp_INTEGRITY_CHECK: {
int i, j, addr, mxErr;
int isQuick = (sqlite3Tolower(zLeft[0])=='q');
/* If the PRAGMA command was of the form "PRAGMA <db>.integrity_check",
|
| ︙ | ︙ | |||
114051 114052 114053 114054 114055 114056 114057 |
mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
if( zRight ){
sqlite3GetInt32(zRight, &mxErr);
if( mxErr<=0 ){
mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
}
}
| | < < < < | 114250 114251 114252 114253 114254 114255 114256 114257 114258 114259 114260 114261 114262 114263 114264 114265 114266 114267 114268 114269 114270 114271 114272 114273 114274 114275 114276 114277 114278 |
mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
if( zRight ){
sqlite3GetInt32(zRight, &mxErr);
if( mxErr<=0 ){
mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
}
}
sqlite3VdbeAddOp2(v, OP_Integer, mxErr-1, 1); /* reg[1] holds errors left */
/* Do an integrity check on each database file */
for(i=0; i<db->nDb; i++){
HashElem *x;
Hash *pTbls;
int *aRoot;
int cnt = 0;
int mxIdx = 0;
int nIdx;
if( OMIT_TEMPDB && i==1 ) continue;
if( iDb>=0 && i!=iDb ) continue;
sqlite3CodeVerifySchema(pParse, i);
/* Do an integrity check of the B-Tree
**
** Begin by finding the root pages numbers
** for all tables and indices in the database.
*/
assert( sqlite3SchemaMutexHeld(db, i, 0) );
|
| ︙ | ︙ | |||
114109 114110 114111 114112 114113 114114 114115 |
sqlite3VdbeChangeP5(v, (u8)i);
addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zDbSName),
P4_DYNAMIC);
sqlite3VdbeAddOp3(v, OP_Move, 2, 4, 1);
sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 2);
| | | | > > > > > < < < < | < > | > > > > | > > > > > > > > > > > > > | > | | | < | < < < > | | | < < < | | | < | | > | > | | | 114304 114305 114306 114307 114308 114309 114310 114311 114312 114313 114314 114315 114316 114317 114318 114319 114320 114321 114322 114323 114324 114325 114326 114327 114328 114329 114330 114331 114332 114333 114334 114335 114336 114337 114338 114339 114340 114341 114342 114343 114344 114345 114346 114347 114348 114349 114350 114351 114352 114353 114354 114355 114356 114357 114358 114359 114360 114361 114362 114363 114364 114365 114366 114367 114368 114369 114370 114371 114372 114373 114374 114375 114376 114377 114378 114379 114380 114381 114382 114383 114384 114385 114386 114387 114388 114389 114390 114391 114392 114393 114394 114395 114396 114397 114398 114399 114400 114401 114402 114403 114404 114405 114406 114407 114408 114409 114410 114411 114412 114413 114414 114415 114416 114417 114418 114419 114420 114421 114422 114423 114424 114425 114426 114427 114428 114429 114430 114431 114432 114433 114434 114435 114436 114437 114438 114439 114440 114441 114442 114443 114444 114445 114446 114447 114448 114449 114450 114451 114452 114453 114454 114455 114456 114457 114458 114459 114460 114461 114462 114463 |
sqlite3VdbeChangeP5(v, (u8)i);
addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zDbSName),
P4_DYNAMIC);
sqlite3VdbeAddOp3(v, OP_Move, 2, 4, 1);
sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 2);
integrityCheckResultRow(v, 2);
sqlite3VdbeJumpHere(v, addr);
/* Make sure all the indices are constructed correctly.
*/
for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
Table *pTab = sqliteHashData(x);
Index *pIdx, *pPk;
Index *pPrior = 0;
int loopTop;
int iDataCur, iIdxCur;
int r1 = -1;
if( pTab->pCheck==0
&& (pTab->tabFlags & TF_HasNotNull)==0
&& (pTab->pIndex==0 || isQuick)
){
continue; /* No additional checks needed for this table */
}
pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);
sqlite3ExprCacheClear(pParse);
sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenRead, 0,
1, 0, &iDataCur, &iIdxCur);
sqlite3VdbeAddOp2(v, OP_Integer, 0, 7);
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
sqlite3VdbeAddOp2(v, OP_Integer, 0, 8+j); /* index entries counter */
}
assert( pParse->nMem>=8+j );
assert( sqlite3NoTempsInRange(pParse,1,7+j) );
sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); VdbeCoverage(v);
loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);
/* Verify that all NOT NULL columns really are NOT NULL */
for(j=0; j<pTab->nCol; j++){
char *zErr;
int jmp2;
if( j==pTab->iPKey ) continue;
if( pTab->aCol[j].notNull==0 ) continue;
sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3);
sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v);
zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName,
pTab->aCol[j].zName);
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
integrityCheckResultRow(v, 3);
sqlite3VdbeJumpHere(v, jmp2);
}
/* Verify CHECK constraints */
if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
int addrCkFault = sqlite3VdbeMakeLabel(v);
int addrCkOk = sqlite3VdbeMakeLabel(v);
ExprList *pCheck = pTab->pCheck;
char *zErr;
int k;
pParse->iSelfTab = iDataCur;
sqlite3ExprCachePush(pParse);
for(k=pCheck->nExpr-1; k>0; k--){
sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0);
}
sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk,
SQLITE_JUMPIFNULL);
sqlite3VdbeResolveLabel(v, addrCkFault);
zErr = sqlite3MPrintf(db, "CHECK constraint failed in %s",
pTab->zName);
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
integrityCheckResultRow(v, 3);
sqlite3VdbeResolveLabel(v, addrCkOk);
sqlite3ExprCachePop(pParse);
}
/* Validate index entries for the current row */
for(j=0, pIdx=pTab->pIndex; pIdx && !isQuick; pIdx=pIdx->pNext, j++){
int jmp2, jmp3, jmp4, jmp5;
int ckUniq = sqlite3VdbeMakeLabel(v);
if( pPk==pIdx ) continue;
r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,
pPrior, r1);
pPrior = pIdx;
sqlite3VdbeAddOp2(v, OP_AddImm, 8+j, 1); /* increment entry count */
/* Verify that an index entry exists for the current table row */
jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, ckUniq, r1,
pIdx->nColumn); VdbeCoverage(v);
sqlite3VdbeLoadString(v, 3, "row ");
sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);
sqlite3VdbeLoadString(v, 4, " missing from index ");
sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);
jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName);
sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);
jmp4 = integrityCheckResultRow(v, 3);
sqlite3VdbeJumpHere(v, jmp2);
/* For UNIQUE indexes, verify that only one entry exists with the
** current key. The entry is unique if (1) any column is NULL
** or (2) the next entry has a different key */
if( IsUniqueIndex(pIdx) ){
int uniqOk = sqlite3VdbeMakeLabel(v);
int jmp6;
int kk;
for(kk=0; kk<pIdx->nKeyCol; kk++){
int iCol = pIdx->aiColumn[kk];
assert( iCol!=XN_ROWID && iCol<pTab->nCol );
if( iCol>=0 && pTab->aCol[iCol].notNull ) continue;
sqlite3VdbeAddOp2(v, OP_IsNull, r1+kk, uniqOk);
VdbeCoverage(v);
}
jmp6 = sqlite3VdbeAddOp1(v, OP_Next, iIdxCur+j); VdbeCoverage(v);
sqlite3VdbeGoto(v, uniqOk);
sqlite3VdbeJumpHere(v, jmp6);
sqlite3VdbeAddOp4Int(v, OP_IdxGT, iIdxCur+j, uniqOk, r1,
pIdx->nKeyCol); VdbeCoverage(v);
sqlite3VdbeLoadString(v, 3, "non-unique entry in index ");
sqlite3VdbeGoto(v, jmp5);
sqlite3VdbeResolveLabel(v, uniqOk);
}
sqlite3VdbeJumpHere(v, jmp4);
sqlite3ResolvePartIdxLabel(pParse, jmp3);
}
sqlite3VdbeAddOp2(v, OP_Next, iDataCur, loopTop); VdbeCoverage(v);
sqlite3VdbeJumpHere(v, loopTop-1);
#ifndef SQLITE_OMIT_BTREECOUNT
if( !isQuick ){
sqlite3VdbeLoadString(v, 2, "wrong # of entries in index ");
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
if( pPk==pIdx ) continue;
sqlite3VdbeAddOp2(v, OP_Count, iIdxCur+j, 3);
addr = sqlite3VdbeAddOp3(v, OP_Eq, 8+j, 0, 3); VdbeCoverage(v);
sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
sqlite3VdbeLoadString(v, 3, pIdx->zName);
sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7);
integrityCheckResultRow(v, 7);
sqlite3VdbeJumpHere(v, addr);
}
}
#endif /* SQLITE_OMIT_BTREECOUNT */
}
}
{
static const int iLn = VDBE_OFFSET_LINENO(2);
static const VdbeOpList endCode[] = {
{ OP_AddImm, 1, 0, 0}, /* 0 */
{ OP_IfNotZero, 1, 4, 0}, /* 1 */
{ OP_String8, 0, 3, 0}, /* 2 */
{ OP_ResultRow, 3, 1, 0}, /* 3 */
};
VdbeOp *aOp;
aOp = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode, iLn);
if( aOp ){
aOp[0].p2 = 1-mxErr;
aOp[2].p4type = P4_STATIC;
aOp[2].p4.z = "ok";
}
}
}
break;
#endif /* SQLITE_OMIT_INTEGRITY_CHECK */
|
| ︙ | ︙ | |||
114464 114465 114466 114467 114468 114469 114470 114471 114472 114473 114474 114475 114476 114477 |
** connection on which it is invoked to free up as much memory as it
** can, by calling sqlite3_db_release_memory().
*/
case PragTyp_SHRINK_MEMORY: {
sqlite3_db_release_memory(db);
break;
}
/*
** PRAGMA busy_timeout
** PRAGMA busy_timeout = N
**
** Call sqlite3_busy_timeout(db, N). Return the current timeout value
** if one is set. If no busy handler or a different busy handler is set
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 114673 114674 114675 114676 114677 114678 114679 114680 114681 114682 114683 114684 114685 114686 114687 114688 114689 114690 114691 114692 114693 114694 114695 114696 114697 114698 114699 114700 114701 114702 114703 114704 114705 114706 114707 114708 114709 114710 114711 114712 114713 114714 114715 114716 114717 114718 114719 114720 114721 114722 114723 114724 114725 114726 114727 114728 114729 114730 114731 114732 114733 114734 114735 114736 114737 114738 114739 114740 114741 114742 114743 114744 114745 114746 114747 114748 114749 114750 114751 114752 114753 114754 114755 114756 114757 114758 114759 114760 114761 114762 114763 114764 114765 114766 114767 114768 |
** connection on which it is invoked to free up as much memory as it
** can, by calling sqlite3_db_release_memory().
*/
case PragTyp_SHRINK_MEMORY: {
sqlite3_db_release_memory(db);
break;
}
/*
** PRAGMA optimize
** PRAGMA schema.optimize
**
** Attempt to optimize the database. All schemas are optimized in the first
** form, and only the specified schema is optimized in the second form.
**
** The details of optimizations performed by this pragma does are expected
** to change and improve over time. Applications should anticipate that
** this pragma will perform new optimizations in future releases.
**
** Argments to this pragma are currently ignored, but future enhancements
** might make use of arguments to control which optimizations are allowed
** or to suggest limits on how much CPU time and I/O should be expended
** in the optimization effort.
**
** The current implementation runs ANALYZE on any tables which might have
** benefitted from having recent statistics at some point since the start
** of the current connection. Only tables in "schema" are analyzed in the
** second form. In the first form, all tables except TEMP tables are
** checked.
**
** In the current implementation, a table is analyzed only if both of
** the following are true:
**
** (1) The query planner used sqlite_stat1-style statistics for one or
** more indexes of the table at some point during the lifetime of
** the current connection.
**
** (2) One or more indexes of the table are currently unanalyzed OR
** the number of rows in the table has increased by 25 times or more
** since the last time ANALYZE was run.
**
** The rules for when tables are analyzed are likely to change in
** future releases.
*/
case PragTyp_OPTIMIZE: {
int iDbLast; /* Loop termination point for the schema loop */
int iTabCur; /* Cursor for a table whose size needs checking */
HashElem *k; /* Loop over tables of a schema */
Schema *pSchema; /* The current schema */
Table *pTab; /* A table in the schema */
Index *pIdx; /* An index of the table */
LogEst szThreshold; /* Size threshold above which reanalysis is needd */
char *zSubSql; /* SQL statement for the OP_SqlExec opcode */
iTabCur = pParse->nTab++;
for(iDbLast = zDb?iDb:db->nDb-1; iDb<=iDbLast; iDb++){
if( iDb==1 ) continue;
sqlite3CodeVerifySchema(pParse, iDb);
pSchema = db->aDb[iDb].pSchema;
for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){
pTab = (Table*)sqliteHashData(k);
/* If table pTab has not been used in a way that would benefit from
** having analysis statistics during the current session, then skip it.
** This also has the effect of skipping virtual tables and views */
if( (pTab->tabFlags & TF_StatsUsed)==0 ) continue;
/* Reanalyze if the table is 25 times larger than the last analysis */
szThreshold = pTab->nRowLogEst + 46; assert( sqlite3LogEst(25)==46 );
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
if( !pIdx->hasStat1 ){
szThreshold = 0; /* Always analyze if any index lacks statistics */
break;
}
}
if( szThreshold ){
sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead);
sqlite3VdbeAddOp3(v, OP_IfSmaller, iTabCur,
sqlite3VdbeCurrentAddr(v)+2, szThreshold);
VdbeCoverage(v);
}
zSubSql = sqlite3MPrintf(db, "ANALYZE \"%w\".\"%w\"",
db->aDb[iDb].zDbSName, pTab->zName);
sqlite3VdbeAddOp4(v, OP_SqlExec, 0, 0, 0, zSubSql, P4_DYNAMIC);
}
}
sqlite3VdbeAddOp0(v, OP_Expire);
break;
}
/*
** PRAGMA busy_timeout
** PRAGMA busy_timeout = N
**
** Call sqlite3_busy_timeout(db, N). Return the current timeout value
** if one is set. If no busy handler or a different busy handler is set
|
| ︙ | ︙ | |||
123780 123781 123782 123783 123784 123785 123786 |
** not work if other processes are attached to the original database.
** And a power loss in between deleting the original and renaming the
** transient would cause the database file to appear to be deleted
** following reboot.
*/
SQLITE_PRIVATE void sqlite3Vacuum(Parse *pParse, Token *pNm){
Vdbe *v = sqlite3GetVdbe(pParse);
| > > > > > > | > > > > > > > > > > > | | 124071 124072 124073 124074 124075 124076 124077 124078 124079 124080 124081 124082 124083 124084 124085 124086 124087 124088 124089 124090 124091 124092 124093 124094 124095 124096 124097 124098 124099 124100 124101 124102 124103 |
** not work if other processes are attached to the original database.
** And a power loss in between deleting the original and renaming the
** transient would cause the database file to appear to be deleted
** following reboot.
*/
SQLITE_PRIVATE void sqlite3Vacuum(Parse *pParse, Token *pNm){
Vdbe *v = sqlite3GetVdbe(pParse);
int iDb = 0;
if( v==0 ) return;
if( pNm ){
#ifndef SQLITE_BUG_COMPATIBLE_20160819
/* Default behavior: Report an error if the argument to VACUUM is
** not recognized */
iDb = sqlite3TwoPartName(pParse, pNm, pNm, &pNm);
if( iDb<0 ) return;
#else
/* When SQLITE_BUG_COMPATIBLE_20160819 is defined, unrecognized arguments
** to VACUUM are silently ignored. This is a back-out of a bug fix that
** occurred on 2016-08-19 (https://www.sqlite.org/src/info/083f9e6270).
** The buggy behavior is required for binary compatibility with some
** legacy applications. */
iDb = sqlite3FindDb(pParse->db, pNm);
if( iDb<0 ) iDb = 0;
#endif
}
if( iDb!=1 ){
sqlite3VdbeAddOp1(v, OP_Vacuum, iDb);
sqlite3VdbeUsesBtree(v, iDb);
}
return;
}
/*
|
| ︙ | ︙ | |||
124375 124376 124377 124378 124379 124380 124381 | if( pTable==0 ) return; assert( 0==pTable->pIndex ); db = pParse->db; iDb = sqlite3SchemaToIndex(db, pTable->pSchema); assert( iDb>=0 ); | < | | 124683 124684 124685 124686 124687 124688 124689 124690 124691 124692 124693 124694 124695 124696 124697 |
if( pTable==0 ) return;
assert( 0==pTable->pIndex );
db = pParse->db;
iDb = sqlite3SchemaToIndex(db, pTable->pSchema);
assert( iDb>=0 );
assert( pTable->nModuleArg==0 );
addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName));
addModuleArgument(db, pTable, 0);
addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName));
assert( (pParse->sNameToken.z==pName2->z && pName2->z!=0)
|| (pParse->sNameToken.z==pName1->z && pName2->z==0)
);
pParse->sNameToken.n = (int)(
|
| ︙ | ︙ | |||
124664 124665 124666 124667 124668 124669 124670 |
SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){
sqlite3 *db = pParse->db;
const char *zMod;
Module *pMod;
int rc;
assert( pTab );
| | | 124971 124972 124973 124974 124975 124976 124977 124978 124979 124980 124981 124982 124983 124984 124985 |
SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){
sqlite3 *db = pParse->db;
const char *zMod;
Module *pMod;
int rc;
assert( pTab );
if( !IsVirtual(pTab) || sqlite3GetVTable(db, pTab) ){
return SQLITE_OK;
}
/* Locate the required virtual table module */
zMod = pTab->azModuleArg[0];
pMod = (Module*)sqlite3HashFind(&db->aModule, zMod);
|
| ︙ | ︙ | |||
124734 124735 124736 124737 124738 124739 124740 |
SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){
int rc = SQLITE_OK;
Table *pTab;
Module *pMod;
const char *zMod;
pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName);
| | | 125041 125042 125043 125044 125045 125046 125047 125048 125049 125050 125051 125052 125053 125054 125055 |
SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){
int rc = SQLITE_OK;
Table *pTab;
Module *pMod;
const char *zMod;
pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName);
assert( pTab && IsVirtual(pTab) && !pTab->pVTable );
/* Locate the required virtual table module */
zMod = pTab->azModuleArg[0];
pMod = (Module*)sqlite3HashFind(&db->aModule, zMod);
/* If the module has been registered and includes a Create method,
** invoke it now. If the module has not been registered, return an
|
| ︙ | ︙ | |||
124788 124789 124790 124791 124792 124793 124794 |
pCtx = db->pVtabCtx;
if( !pCtx || pCtx->bDeclared ){
sqlite3Error(db, SQLITE_MISUSE);
sqlite3_mutex_leave(db->mutex);
return SQLITE_MISUSE_BKPT;
}
pTab = pCtx->pTab;
| | | | 125095 125096 125097 125098 125099 125100 125101 125102 125103 125104 125105 125106 125107 125108 125109 125110 125111 125112 125113 125114 125115 125116 125117 125118 125119 125120 125121 125122 125123 |
pCtx = db->pVtabCtx;
if( !pCtx || pCtx->bDeclared ){
sqlite3Error(db, SQLITE_MISUSE);
sqlite3_mutex_leave(db->mutex);
return SQLITE_MISUSE_BKPT;
}
pTab = pCtx->pTab;
assert( IsVirtual(pTab) );
pParse = sqlite3StackAllocZero(db, sizeof(*pParse));
if( pParse==0 ){
rc = SQLITE_NOMEM_BKPT;
}else{
pParse->declareVtab = 1;
pParse->db = db;
pParse->nQueryLoop = 1;
if( SQLITE_OK==sqlite3RunParser(pParse, zCreateTable, &zErr)
&& pParse->pNewTable
&& !db->mallocFailed
&& !pParse->pNewTable->pSelect
&& !IsVirtual(pParse->pNewTable)
){
if( !pTab->aCol ){
Table *pNew = pParse->pNewTable;
Index *pIdx;
pTab->aCol = pNew->aCol;
pTab->nCol = pNew->nCol;
pTab->tabFlags |= pNew->tabFlags & (TF_WithoutRowid|TF_NoVisibleRowid);
|
| ︙ | ︙ | |||
125091 125092 125093 125094 125095 125096 125097 | /* Check to see the left operand is a column in a virtual table */ if( NEVER(pExpr==0) ) return pDef; if( pExpr->op!=TK_COLUMN ) return pDef; pTab = pExpr->pTab; if( NEVER(pTab==0) ) return pDef; | | | 125398 125399 125400 125401 125402 125403 125404 125405 125406 125407 125408 125409 125410 125411 125412 | /* Check to see the left operand is a column in a virtual table */ if( NEVER(pExpr==0) ) return pDef; if( pExpr->op!=TK_COLUMN ) return pDef; pTab = pExpr->pTab; if( NEVER(pTab==0) ) return pDef; if( !IsVirtual(pTab) ) return pDef; pVtab = sqlite3GetVTable(db, pTab)->pVtab; assert( pVtab!=0 ); assert( pVtab->pModule!=0 ); pMod = (sqlite3_module *)pVtab->pModule; if( pMod->xFindFunction==0 ) return pDef; /* Call the xFindFunction method on the virtual table implementation |
| ︙ | ︙ | |||
125186 125187 125188 125189 125190 125191 125192 |
if( pTab->zName==0 ){
sqlite3DbFree(db, pTab);
return 0;
}
pMod->pEpoTab = pTab;
pTab->nTabRef = 1;
pTab->pSchema = db->aDb[0].pSchema;
| < | | 125493 125494 125495 125496 125497 125498 125499 125500 125501 125502 125503 125504 125505 125506 125507 |
if( pTab->zName==0 ){
sqlite3DbFree(db, pTab);
return 0;
}
pMod->pEpoTab = pTab;
pTab->nTabRef = 1;
pTab->pSchema = db->aDb[0].pSchema;
assert( pTab->nModuleArg==0 );
pTab->iPKey = -1;
addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName));
addModuleArgument(db, pTab, 0);
addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName));
rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr);
if( rc ){
sqlite3ErrorMsg(pParse, "%s", zErr);
|
| ︙ | ︙ | |||
125258 125259 125260 125261 125262 125263 125264 |
va_start(ap, op);
switch( op ){
case SQLITE_VTAB_CONSTRAINT_SUPPORT: {
VtabCtx *p = db->pVtabCtx;
if( !p ){
rc = SQLITE_MISUSE_BKPT;
}else{
| | | 125564 125565 125566 125567 125568 125569 125570 125571 125572 125573 125574 125575 125576 125577 125578 |
va_start(ap, op);
switch( op ){
case SQLITE_VTAB_CONSTRAINT_SUPPORT: {
VtabCtx *p = db->pVtabCtx;
if( !p ){
rc = SQLITE_MISUSE_BKPT;
}else{
assert( p->pTab==0 || IsVirtual(p->pTab) );
p->pVTable->bConstraint = (u8)va_arg(ap, int);
}
break;
}
default:
rc = SQLITE_MISUSE_BKPT;
break;
|
| ︙ | ︙ | |||
125697 125698 125699 125700 125701 125702 125703 125704 125705 125706 125707 125708 125709 125710 125711 125712 125713 125714 125715 125716 125717 125718 125719 |
ExprList *pOrderBy; /* ORDER BY clause */
WhereLoop *pNew; /* Template WhereLoop */
WhereOrSet *pOrSet; /* Record best loops here, if not NULL */
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
UnpackedRecord *pRec; /* Probe for stat4 (if required) */
int nRecValid; /* Number of valid fields currently in pRec */
#endif
};
/*
** The WHERE clause processing routine has two halves. The
** first part does the start of the WHERE loop and the second
** half does the tail of the WHERE loop. An instance of
** this structure is returned by the first half and passed
** into the second half to give some continuity.
**
** An instance of this object holds the complete state of the query
** planner.
*/
struct WhereInfo {
Parse *pParse; /* Parsing and code generating context */
SrcList *pTabList; /* List of tables in the join */
ExprList *pOrderBy; /* The ORDER BY clause or NULL */
| > > > > > | | 126003 126004 126005 126006 126007 126008 126009 126010 126011 126012 126013 126014 126015 126016 126017 126018 126019 126020 126021 126022 126023 126024 126025 126026 126027 126028 126029 126030 126031 126032 126033 126034 126035 126036 126037 126038 |
ExprList *pOrderBy; /* ORDER BY clause */
WhereLoop *pNew; /* Template WhereLoop */
WhereOrSet *pOrSet; /* Record best loops here, if not NULL */
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
UnpackedRecord *pRec; /* Probe for stat4 (if required) */
int nRecValid; /* Number of valid fields currently in pRec */
#endif
unsigned int bldFlags; /* SQLITE_BLDF_* flags */
};
/* Allowed values for WhereLoopBuider.bldFlags */
#define SQLITE_BLDF_INDEXED 0x0001 /* An index is used */
#define SQLITE_BLDF_UNIQUE 0x0002 /* All keys of a UNIQUE index used */
/*
** The WHERE clause processing routine has two halves. The
** first part does the start of the WHERE loop and the second
** half does the tail of the WHERE loop. An instance of
** this structure is returned by the first half and passed
** into the second half to give some continuity.
**
** An instance of this object holds the complete state of the query
** planner.
*/
struct WhereInfo {
Parse *pParse; /* Parsing and code generating context */
SrcList *pTabList; /* List of tables in the join */
ExprList *pOrderBy; /* The ORDER BY clause or NULL */
ExprList *pResultSet; /* Result set of the query */
LogEst iLimit; /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */
int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */
int iContinue; /* Jump here to continue with next record */
int iBreak; /* Jump here to break out of the loop */
int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */
u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */
u8 nLevel; /* Number of nested loop */
|
| ︙ | ︙ | |||
126897 126898 126899 126900 126901 126902 126903 126904 126905 126906 126907 126908 126909 126910 | WhereClause *pWC; /* Decomposition of the entire WHERE clause */ WhereTerm *pTerm; /* A WHERE clause term */ Parse *pParse; /* Parsing context */ sqlite3 *db; /* Database connection */ Vdbe *v; /* The prepared stmt under constructions */ struct SrcList_item *pTabItem; /* FROM clause term being coded */ int addrBrk; /* Jump here to break out of the loop */ int addrCont; /* Jump here to continue with next cycle */ int iRowidReg = 0; /* Rowid is stored in this register, if not zero */ int iReleaseReg = 0; /* Temp register to free before returning */ pParse = pWInfo->pParse; v = pParse->pVdbe; pWC = &pWInfo->sWC; | > | 127208 127209 127210 127211 127212 127213 127214 127215 127216 127217 127218 127219 127220 127221 127222 | WhereClause *pWC; /* Decomposition of the entire WHERE clause */ WhereTerm *pTerm; /* A WHERE clause term */ Parse *pParse; /* Parsing context */ sqlite3 *db; /* Database connection */ Vdbe *v; /* The prepared stmt under constructions */ struct SrcList_item *pTabItem; /* FROM clause term being coded */ int addrBrk; /* Jump here to break out of the loop */ int addrHalt; /* addrBrk for the outermost loop */ int addrCont; /* Jump here to continue with next cycle */ int iRowidReg = 0; /* Rowid is stored in this register, if not zero */ int iReleaseReg = 0; /* Temp register to free before returning */ pParse = pWInfo->pParse; v = pParse->pVdbe; pWC = &pWInfo->sWC; |
| ︙ | ︙ | |||
126937 126938 126939 126940 126941 126942 126943 126944 126945 126946 126947 126948 126949 126950 |
** row of the left table of the join.
*/
if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){
pLevel->iLeftJoin = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);
VdbeComment((v, "init LEFT JOIN no-match flag"));
}
/* Special case of a FROM clause subquery implemented as a co-routine */
if( pTabItem->fg.viaCoroutine ){
int regYield = pTabItem->regReturn;
sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
pLevel->p2 = sqlite3VdbeAddOp2(v, OP_Yield, regYield, addrBrk);
VdbeCoverage(v);
| > > > > > | 127249 127250 127251 127252 127253 127254 127255 127256 127257 127258 127259 127260 127261 127262 127263 127264 127265 127266 127267 |
** row of the left table of the join.
*/
if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){
pLevel->iLeftJoin = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);
VdbeComment((v, "init LEFT JOIN no-match flag"));
}
/* Compute a safe address to jump to if we discover that the table for
** this loop is empty and can never contribute content. */
for(j=iLevel; j>0 && pWInfo->a[j].iLeftJoin==0; j--){}
addrHalt = pWInfo->a[j].addrBrk;
/* Special case of a FROM clause subquery implemented as a co-routine */
if( pTabItem->fg.viaCoroutine ){
int regYield = pTabItem->regReturn;
sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
pLevel->p2 = sqlite3VdbeAddOp2(v, OP_Yield, regYield, addrBrk);
VdbeCoverage(v);
|
| ︙ | ︙ | |||
127122 127123 127124 127125 127126 127127 127128 |
VdbeCoverageIf(v, pX->op==TK_GT);
VdbeCoverageIf(v, pX->op==TK_LE);
VdbeCoverageIf(v, pX->op==TK_LT);
VdbeCoverageIf(v, pX->op==TK_GE);
sqlite3ExprCacheAffinityChange(pParse, r1, 1);
sqlite3ReleaseTempReg(pParse, rTemp);
}else{
| | | 127439 127440 127441 127442 127443 127444 127445 127446 127447 127448 127449 127450 127451 127452 127453 |
VdbeCoverageIf(v, pX->op==TK_GT);
VdbeCoverageIf(v, pX->op==TK_LE);
VdbeCoverageIf(v, pX->op==TK_LT);
VdbeCoverageIf(v, pX->op==TK_GE);
sqlite3ExprCacheAffinityChange(pParse, r1, 1);
sqlite3ReleaseTempReg(pParse, rTemp);
}else{
sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrHalt);
VdbeCoverageIf(v, bRev==0);
VdbeCoverageIf(v, bRev!=0);
}
if( pEnd ){
Expr *pX;
pX = pEnd->pExpr;
assert( pX!=0 );
|
| ︙ | ︙ | |||
127768 127769 127770 127771 127772 127773 127774 |
/* Tables marked isRecursive have only a single row that is stored in
** a pseudo-cursor. No need to Rewind or Next such cursors. */
pLevel->op = OP_Noop;
}else{
codeCursorHint(pTabItem, pWInfo, pLevel, 0);
pLevel->op = aStep[bRev];
pLevel->p1 = iCur;
| | | 128085 128086 128087 128088 128089 128090 128091 128092 128093 128094 128095 128096 128097 128098 128099 |
/* Tables marked isRecursive have only a single row that is stored in
** a pseudo-cursor. No need to Rewind or Next such cursors. */
pLevel->op = OP_Noop;
}else{
codeCursorHint(pTabItem, pWInfo, pLevel, 0);
pLevel->op = aStep[bRev];
pLevel->p1 = iCur;
pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrHalt);
VdbeCoverageIf(v, bRev==0);
VdbeCoverageIf(v, bRev!=0);
pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;
}
}
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
|
| ︙ | ︙ | |||
128093 128094 128095 128096 128097 128098 128099 |
return 0;
}
#ifdef SQLITE_EBCDIC
if( *pnoCase ) return 0;
#endif
pList = pExpr->x.pList;
pLeft = pList->a[1].pExpr;
| < < < < < < < < < > > > > > > > > > > > > > > > > > | 128410 128411 128412 128413 128414 128415 128416 128417 128418 128419 128420 128421 128422 128423 128424 128425 128426 128427 128428 128429 128430 128431 128432 128433 128434 128435 128436 128437 128438 128439 128440 128441 128442 128443 128444 128445 128446 128447 128448 128449 128450 128451 128452 128453 128454 128455 128456 |
return 0;
}
#ifdef SQLITE_EBCDIC
if( *pnoCase ) return 0;
#endif
pList = pExpr->x.pList;
pLeft = pList->a[1].pExpr;
pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr);
op = pRight->op;
if( op==TK_VARIABLE ){
Vdbe *pReprepare = pParse->pReprepare;
int iCol = pRight->iColumn;
pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_BLOB);
if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
z = (char *)sqlite3_value_text(pVal);
}
sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);
assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
}else if( op==TK_STRING ){
z = pRight->u.zToken;
}
if( z ){
/* If the RHS begins with a digit or a minus sign, then the LHS must
** be an ordinary column (not a virtual table column) with TEXT affinity.
** Otherwise the LHS might be numeric and "lhs >= rhs" would be false
** even though "lhs LIKE rhs" is true. But if the RHS does not start
** with a digit or '-', then "lhs LIKE rhs" will always be false if
** the LHS is numeric and so the optimization still works.
*/
if( sqlite3Isdigit(z[0]) || z[0]=='-' ){
if( pLeft->op!=TK_COLUMN
|| sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
|| IsVirtual(pLeft->pTab) /* Value might be numeric */
){
sqlite3ValueFree(pVal);
return 0;
}
}
cnt = 0;
while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
cnt++;
}
if( cnt!=0 && 255!=(u8)z[cnt-1] ){
Expr *pPrefix;
*pisComplete = c==wc[0] && z[cnt+1]==0;
|
| ︙ | ︙ | |||
128746 128747 128748 128749 128750 128751 128752 |
if( (mPrereq&(mPrereq-1))!=0 ) return 0; /* Refs more than one table */
for(i=0; mPrereq>1; i++, mPrereq>>=1){}
iCur = pFrom->a[i].iCursor;
for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){
if( pIdx->aColExpr==0 ) continue;
for(i=0; i<pIdx->nKeyCol; i++){
if( pIdx->aiColumn[i]!=XN_EXPR ) continue;
| | | 129071 129072 129073 129074 129075 129076 129077 129078 129079 129080 129081 129082 129083 129084 129085 |
if( (mPrereq&(mPrereq-1))!=0 ) return 0; /* Refs more than one table */
for(i=0; mPrereq>1; i++, mPrereq>>=1){}
iCur = pFrom->a[i].iCursor;
for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){
if( pIdx->aColExpr==0 ) continue;
for(i=0; i<pIdx->nKeyCol; i++){
if( pIdx->aiColumn[i]!=XN_EXPR ) continue;
if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){
*piCur = iCur;
*piColumn = XN_EXPR;
return 1;
}
}
}
return 0;
|
| ︙ | ︙ | |||
129537 129538 129539 129540 129541 129542 129543 |
iCur = pScan->aiCur[pScan->iEquiv-1];
assert( pWC!=0 );
do{
for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
if( pTerm->leftCursor==iCur
&& pTerm->u.leftColumn==iColumn
&& (iColumn!=XN_EXPR
| > | | 129862 129863 129864 129865 129866 129867 129868 129869 129870 129871 129872 129873 129874 129875 129876 129877 |
iCur = pScan->aiCur[pScan->iEquiv-1];
assert( pWC!=0 );
do{
for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
if( pTerm->leftCursor==iCur
&& pTerm->u.leftColumn==iColumn
&& (iColumn!=XN_EXPR
|| sqlite3ExprCompareSkip(pTerm->pExpr->pLeft,
pScan->pIdxExpr,iCur)==0)
&& (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))
){
if( (pTerm->eOperator & WO_EQUIV)!=0
&& pScan->nEquiv<ArraySize(pScan->aiCur)
&& (pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight))->op==TK_COLUMN
){
int j;
|
| ︙ | ︙ | |||
131714 131715 131716 131717 131718 131719 131720 131721 131722 131723 131724 131725 131726 131727 |
&& (eOp & (WO_IS|WO_ISNULL))!=0
){
testcase( eOp & WO_IS );
testcase( eOp & WO_ISNULL );
continue;
}
pNew->wsFlags = saved_wsFlags;
pNew->u.btree.nEq = saved_nEq;
pNew->u.btree.nBtm = saved_nBtm;
pNew->u.btree.nTop = saved_nTop;
pNew->nLTerm = saved_nLTerm;
if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
pNew->aLTerm[pNew->nLTerm++] = pTerm;
| > > > > > | 132040 132041 132042 132043 132044 132045 132046 132047 132048 132049 132050 132051 132052 132053 132054 132055 132056 132057 132058 |
&& (eOp & (WO_IS|WO_ISNULL))!=0
){
testcase( eOp & WO_IS );
testcase( eOp & WO_ISNULL );
continue;
}
if( IsUniqueIndex(pProbe) && saved_nEq==pProbe->nKeyCol-1 ){
pBuilder->bldFlags |= SQLITE_BLDF_UNIQUE;
}else{
pBuilder->bldFlags |= SQLITE_BLDF_INDEXED;
}
pNew->wsFlags = saved_wsFlags;
pNew->u.btree.nEq = saved_nEq;
pNew->u.btree.nBtm = saved_nBtm;
pNew->u.btree.nTop = saved_nTop;
pNew->nLTerm = saved_nLTerm;
if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
pNew->aLTerm[pNew->nLTerm++] = pTerm;
|
| ︙ | ︙ | |||
132261 132262 132263 132264 132265 132266 132267 132268 132269 132270 132271 132272 132273 132274 132275 |
whereLoopOutputAdjust(pWC, pNew, rSize);
rc = whereLoopInsert(pBuilder, pNew);
pNew->nOut = rSize;
if( rc ) break;
}
}
rc = whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, 0);
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
sqlite3Stat4ProbeFree(pBuilder->pRec);
pBuilder->nRecValid = 0;
pBuilder->pRec = 0;
#endif
/* If there was an INDEXED BY clause, then only that one index is
| > > > > > > > > | 132592 132593 132594 132595 132596 132597 132598 132599 132600 132601 132602 132603 132604 132605 132606 132607 132608 132609 132610 132611 132612 132613 132614 |
whereLoopOutputAdjust(pWC, pNew, rSize);
rc = whereLoopInsert(pBuilder, pNew);
pNew->nOut = rSize;
if( rc ) break;
}
}
pBuilder->bldFlags = 0;
rc = whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, 0);
if( pBuilder->bldFlags==SQLITE_BLDF_INDEXED ){
/* If a non-unique index is used, or if a prefix of the key for
** unique index is used (making the index functionally non-unique)
** then the sqlite_stat1 data becomes important for scoring the
** plan */
pTab->tabFlags |= TF_StatsUsed;
}
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
sqlite3Stat4ProbeFree(pBuilder->pRec);
pBuilder->nRecValid = 0;
pBuilder->pRec = 0;
#endif
/* If there was an INDEXED BY clause, then only that one index is
|
| ︙ | ︙ | |||
133441 133442 133443 133444 133445 133446 133447 |
}
if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)!=0
&& (pWInfo->wctrlFlags & WHERE_DISTINCTBY)==0
&& pWInfo->eDistinct==WHERE_DISTINCT_NOOP
&& nRowEst
){
Bitmask notUsed;
| | | | 133780 133781 133782 133783 133784 133785 133786 133787 133788 133789 133790 133791 133792 133793 133794 133795 133796 |
}
if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)!=0
&& (pWInfo->wctrlFlags & WHERE_DISTINCTBY)==0
&& pWInfo->eDistinct==WHERE_DISTINCT_NOOP
&& nRowEst
){
Bitmask notUsed;
int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pResultSet, pFrom,
WHERE_DISTINCTBY, nLoop-1, pFrom->aLoop[nLoop-1], ¬Used);
if( rc==pWInfo->pResultSet->nExpr ){
pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
}
}
if( pWInfo->pOrderBy ){
if( pWInfo->wctrlFlags & WHERE_DISTINCTBY ){
if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){
pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
|
| ︙ | ︙ | |||
133680 133681 133682 133683 133684 133685 133686 | ** used. */ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( Parse *pParse, /* The parser context */ SrcList *pTabList, /* FROM clause: A list of all tables to be scanned */ Expr *pWhere, /* The WHERE clause */ ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */ | | | 134019 134020 134021 134022 134023 134024 134025 134026 134027 134028 134029 134030 134031 134032 134033 |
** used.
*/
SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
Parse *pParse, /* The parser context */
SrcList *pTabList, /* FROM clause: A list of all tables to be scanned */
Expr *pWhere, /* The WHERE clause */
ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */
ExprList *pResultSet, /* Query result set. Req'd for DISTINCT */
u16 wctrlFlags, /* The WHERE_* flags defined in sqliteInt.h */
int iAuxArg /* If WHERE_OR_SUBCLAUSE is set, index cursor number
** If WHERE_USE_LIMIT, then the limit amount */
){
int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */
int nTabList; /* Number of elements in pTabList */
WhereInfo *pWInfo; /* Will become the return value of this function */
|
| ︙ | ︙ | |||
133756 133757 133758 133759 133760 133761 133762 |
sqlite3DbFree(db, pWInfo);
pWInfo = 0;
goto whereBeginError;
}
pWInfo->pParse = pParse;
pWInfo->pTabList = pTabList;
pWInfo->pOrderBy = pOrderBy;
| | | 134095 134096 134097 134098 134099 134100 134101 134102 134103 134104 134105 134106 134107 134108 134109 |
sqlite3DbFree(db, pWInfo);
pWInfo = 0;
goto whereBeginError;
}
pWInfo->pParse = pParse;
pWInfo->pTabList = pTabList;
pWInfo->pOrderBy = pOrderBy;
pWInfo->pResultSet = pResultSet;
pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1;
pWInfo->nLevel = nTabList;
pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(v);
pWInfo->wctrlFlags = wctrlFlags;
pWInfo->iLimit = iAuxArg;
pWInfo->savedNQueryLoop = pParse->nQueryLoop;
memset(&pWInfo->nOBSat, 0,
|
| ︙ | ︙ | |||
133834 133835 133836 133837 133838 133839 133840 |
#endif
/* Analyze all of the subexpressions. */
sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);
if( db->mallocFailed ) goto whereBeginError;
if( wctrlFlags & WHERE_WANT_DISTINCT ){
| | | | 134173 134174 134175 134176 134177 134178 134179 134180 134181 134182 134183 134184 134185 134186 134187 134188 134189 134190 134191 134192 134193 |
#endif
/* Analyze all of the subexpressions. */
sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);
if( db->mallocFailed ) goto whereBeginError;
if( wctrlFlags & WHERE_WANT_DISTINCT ){
if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){
/* The DISTINCT marking is pointless. Ignore it. */
pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
}else if( pOrderBy==0 ){
/* Try to ORDER BY the result set to make distinct processing easier */
pWInfo->wctrlFlags |= WHERE_DISTINCTBY;
pWInfo->pOrderBy = pResultSet;
}
}
/* Construct the WhereLoop objects */
#if defined(WHERETRACE_ENABLED)
if( sqlite3WhereTrace & 0xffff ){
sqlite3DebugPrintf("*** Optimizer Start *** (wctrlFlags: 0x%x",wctrlFlags);
|
| ︙ | ︙ | |||
133916 133917 133918 133919 133920 133921 133922 |
for(ii=0; ii<pWInfo->nLevel; ii++){
whereLoopPrint(pWInfo->a[ii].pWLoop, sWLB.pWC);
}
}
#endif
/* Attempt to omit tables from the join that do not effect the result */
if( pWInfo->nLevel>=2
| | | | 134255 134256 134257 134258 134259 134260 134261 134262 134263 134264 134265 134266 134267 134268 134269 134270 134271 134272 |
for(ii=0; ii<pWInfo->nLevel; ii++){
whereLoopPrint(pWInfo->a[ii].pWLoop, sWLB.pWC);
}
}
#endif
/* Attempt to omit tables from the join that do not effect the result */
if( pWInfo->nLevel>=2
&& pResultSet!=0
&& OptimizationEnabled(db, SQLITE_OmitNoopJoin)
){
Bitmask tabUsed = sqlite3WhereExprListUsage(pMaskSet, pResultSet);
if( sWLB.pOrderBy ){
tabUsed |= sqlite3WhereExprListUsage(pMaskSet, sWLB.pOrderBy);
}
while( pWInfo->nLevel>=2 ){
WhereTerm *pTerm, *pEnd;
pLoop = pWInfo->a[pWInfo->nLevel-1].pWLoop;
if( (pWInfo->pTabList->a[pLoop->iTab].fg.jointype & JT_LEFT)==0 ) break;
|
| ︙ | ︙ | |||
134702 134703 134704 134705 134706 134707 134708 |
** shifting non-terminals after a reduce.
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (1567)
static const YYACTIONTYPE yy_action[] = {
/* 0 */ 325, 832, 351, 825, 5, 203, 203, 819, 99, 100,
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 135041 135042 135043 135044 135045 135046 135047 135048 135049 135050 135051 135052 135053 135054 135055 135056 135057 135058 135059 135060 135061 135062 135063 135064 135065 135066 135067 135068 135069 135070 135071 135072 135073 135074 135075 135076 135077 135078 135079 135080 135081 135082 135083 135084 135085 135086 135087 135088 135089 135090 135091 135092 135093 135094 135095 135096 135097 135098 135099 135100 135101 135102 135103 135104 135105 135106 135107 135108 135109 135110 135111 135112 135113 135114 135115 135116 135117 135118 135119 135120 135121 135122 135123 135124 135125 135126 135127 135128 135129 135130 135131 135132 135133 135134 135135 135136 135137 135138 135139 135140 135141 135142 135143 135144 135145 135146 135147 135148 135149 135150 135151 135152 135153 135154 135155 135156 135157 135158 135159 135160 135161 135162 135163 135164 135165 135166 135167 135168 135169 135170 135171 135172 135173 135174 135175 135176 135177 135178 135179 135180 135181 135182 135183 135184 135185 135186 135187 135188 135189 135190 135191 135192 135193 135194 135195 135196 135197 135198 135199 135200 135201 135202 135203 135204 135205 135206 135207 135208 135209 135210 |
** shifting non-terminals after a reduce.
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (1567)
static const YYACTIONTYPE yy_action[] = {
/* 0 */ 325, 832, 351, 825, 5, 203, 203, 819, 99, 100,
/* 10 */ 90, 978, 978, 853, 856, 845, 845, 97, 97, 98,
/* 20 */ 98, 98, 98, 301, 96, 96, 96, 96, 95, 95,
/* 30 */ 94, 94, 94, 93, 351, 325, 976, 976, 824, 824,
/* 40 */ 826, 946, 354, 99, 100, 90, 978, 978, 853, 856,
/* 50 */ 845, 845, 97, 97, 98, 98, 98, 98, 338, 96,
/* 60 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
/* 70 */ 95, 95, 94, 94, 94, 93, 351, 791, 976, 976,
/* 80 */ 325, 94, 94, 94, 93, 351, 792, 75, 99, 100,
/* 90 */ 90, 978, 978, 853, 856, 845, 845, 97, 97, 98,
/* 100 */ 98, 98, 98, 450, 96, 96, 96, 96, 95, 95,
/* 110 */ 94, 94, 94, 93, 351, 1333, 155, 155, 2, 325,
/* 120 */ 275, 146, 132, 52, 52, 93, 351, 99, 100, 90,
/* 130 */ 978, 978, 853, 856, 845, 845, 97, 97, 98, 98,
/* 140 */ 98, 98, 101, 96, 96, 96, 96, 95, 95, 94,
/* 150 */ 94, 94, 93, 351, 957, 957, 325, 268, 428, 413,
/* 160 */ 411, 61, 752, 752, 99, 100, 90, 978, 978, 853,
/* 170 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 60,
/* 180 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
/* 190 */ 351, 325, 270, 329, 273, 277, 958, 959, 250, 99,
/* 200 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97,
/* 210 */ 98, 98, 98, 98, 301, 96, 96, 96, 96, 95,
/* 220 */ 95, 94, 94, 94, 93, 351, 325, 937, 1326, 698,
/* 230 */ 706, 1326, 242, 412, 99, 100, 90, 978, 978, 853,
/* 240 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 347,
/* 250 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
/* 260 */ 351, 325, 937, 1327, 384, 699, 1327, 381, 379, 99,
/* 270 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97,
/* 280 */ 98, 98, 98, 98, 701, 96, 96, 96, 96, 95,
/* 290 */ 95, 94, 94, 94, 93, 351, 325, 92, 89, 178,
/* 300 */ 833, 935, 373, 700, 99, 100, 90, 978, 978, 853,
/* 310 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 375,
/* 320 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
/* 330 */ 351, 325, 1275, 946, 354, 818, 935, 739, 739, 99,
/* 340 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97,
/* 350 */ 98, 98, 98, 98, 230, 96, 96, 96, 96, 95,
/* 360 */ 95, 94, 94, 94, 93, 351, 325, 968, 227, 92,
/* 370 */ 89, 178, 373, 300, 99, 100, 90, 978, 978, 853,
/* 380 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 920,
/* 390 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
/* 400 */ 351, 325, 449, 447, 447, 447, 147, 737, 737, 99,
/* 410 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97,
/* 420 */ 98, 98, 98, 98, 296, 96, 96, 96, 96, 95,
/* 430 */ 95, 94, 94, 94, 93, 351, 325, 419, 231, 957,
/* 440 */ 957, 158, 25, 422, 99, 100, 90, 978, 978, 853,
/* 450 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 450,
/* 460 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
/* 470 */ 351, 443, 224, 224, 420, 957, 957, 961, 325, 52,
/* 480 */ 52, 958, 959, 176, 415, 78, 99, 100, 90, 978,
/* 490 */ 978, 853, 856, 845, 845, 97, 97, 98, 98, 98,
/* 500 */ 98, 379, 96, 96, 96, 96, 95, 95, 94, 94,
/* 510 */ 94, 93, 351, 325, 428, 418, 298, 958, 959, 961,
/* 520 */ 81, 99, 88, 90, 978, 978, 853, 856, 845, 845,
/* 530 */ 97, 97, 98, 98, 98, 98, 717, 96, 96, 96,
/* 540 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 842,
/* 550 */ 842, 854, 857, 996, 318, 343, 379, 100, 90, 978,
/* 560 */ 978, 853, 856, 845, 845, 97, 97, 98, 98, 98,
/* 570 */ 98, 450, 96, 96, 96, 96, 95, 95, 94, 94,
/* 580 */ 94, 93, 351, 325, 350, 350, 350, 260, 377, 340,
/* 590 */ 928, 52, 52, 90, 978, 978, 853, 856, 845, 845,
/* 600 */ 97, 97, 98, 98, 98, 98, 361, 96, 96, 96,
/* 610 */ 96, 95, 95, 94, 94, 94, 93, 351, 86, 445,
/* 620 */ 846, 3, 1202, 361, 360, 378, 344, 813, 957, 957,
/* 630 */ 1299, 86, 445, 729, 3, 212, 169, 287, 405, 282,
/* 640 */ 404, 199, 232, 450, 300, 760, 83, 84, 280, 245,
/* 650 */ 262, 365, 251, 85, 352, 352, 92, 89, 178, 83,
/* 660 */ 84, 242, 412, 52, 52, 448, 85, 352, 352, 246,
/* 670 */ 958, 959, 194, 455, 670, 402, 399, 398, 448, 243,
/* 680 */ 221, 114, 434, 776, 361, 450, 397, 268, 747, 224,
/* 690 */ 224, 132, 132, 198, 832, 434, 452, 451, 428, 427,
/* 700 */ 819, 415, 734, 713, 132, 52, 52, 832, 268, 452,
/* 710 */ 451, 734, 194, 819, 363, 402, 399, 398, 450, 1270,
/* 720 */ 1270, 23, 957, 957, 86, 445, 397, 3, 228, 429,
/* 730 */ 894, 824, 824, 826, 827, 19, 203, 720, 52, 52,
/* 740 */ 428, 408, 439, 249, 824, 824, 826, 827, 19, 229,
/* 750 */ 403, 153, 83, 84, 761, 177, 241, 450, 721, 85,
/* 760 */ 352, 352, 120, 157, 958, 959, 58, 976, 409, 355,
/* 770 */ 330, 448, 268, 428, 430, 320, 790, 32, 32, 86,
/* 780 */ 445, 776, 3, 341, 98, 98, 98, 98, 434, 96,
/* 790 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
/* 800 */ 832, 120, 452, 451, 813, 886, 819, 83, 84, 976,
/* 810 */ 813, 132, 410, 919, 85, 352, 352, 132, 407, 789,
/* 820 */ 957, 957, 92, 89, 178, 916, 448, 262, 370, 261,
/* 830 */ 82, 913, 80, 262, 370, 261, 776, 824, 824, 826,
/* 840 */ 827, 19, 933, 434, 96, 96, 96, 96, 95, 95,
/* 850 */ 94, 94, 94, 93, 351, 832, 74, 452, 451, 957,
/* 860 */ 957, 819, 958, 959, 120, 92, 89, 178, 944, 2,
/* 870 */ 917, 964, 268, 1, 975, 76, 445, 762, 3, 708,
/* 880 */ 900, 900, 387, 957, 957, 757, 918, 371, 740, 778,
/* 890 */ 756, 257, 824, 824, 826, 827, 19, 417, 741, 450,
/* 900 */ 24, 958, 959, 83, 84, 369, 957, 957, 177, 226,
/* 910 */ 85, 352, 352, 884, 315, 314, 313, 215, 311, 10,
/* 920 */ 10, 683, 448, 349, 348, 958, 959, 908, 777, 157,
/* 930 */ 120, 957, 957, 337, 776, 416, 711, 310, 450, 434,
/* 940 */ 450, 321, 450, 791, 103, 200, 175, 450, 958, 959,
/* 950 */ 907, 832, 792, 452, 451, 9, 9, 819, 10, 10,
/* 960 */ 52, 52, 51, 51, 180, 716, 248, 10, 10, 171,
/* 970 */ 170, 167, 339, 958, 959, 247, 984, 702, 702, 450,
/* 980 */ 715, 233, 686, 982, 888, 983, 182, 913, 824, 824,
/* 990 */ 826, 827, 19, 183, 256, 423, 132, 181, 394, 10,
/* 1000 */ 10, 888, 890, 749, 957, 957, 916, 268, 985, 198,
/* 1010 */ 985, 349, 348, 425, 415, 299, 817, 832, 326, 825,
/* 1020 */ 120, 332, 133, 819, 268, 98, 98, 98, 98, 91,
/* 1030 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
/* 1040 */ 351, 157, 810, 371, 382, 359, 958, 959, 358, 268,
/* 1050 */ 450, 917, 368, 324, 824, 824, 826, 450, 709, 450,
/* 1060 */ 264, 380, 888, 450, 876, 746, 253, 918, 255, 433,
/* 1070 */ 36, 36, 234, 450, 234, 120, 269, 37, 37, 12,
/* 1080 */ 12, 334, 272, 27, 27, 450, 330, 118, 450, 162,
/* 1090 */ 742, 280, 450, 38, 38, 450, 985, 356, 985, 450,
/* 1100 */ 709, 1209, 450, 132, 450, 39, 39, 450, 40, 40,
/* 1110 */ 450, 362, 41, 41, 450, 42, 42, 450, 254, 28,
/* 1120 */ 28, 450, 29, 29, 31, 31, 450, 43, 43, 450,
/* 1130 */ 44, 44, 450, 714, 45, 45, 450, 11, 11, 767,
/* 1140 */ 450, 46, 46, 450, 268, 450, 105, 105, 450, 47,
/* 1150 */ 47, 450, 48, 48, 450, 237, 33, 33, 450, 172,
/* 1160 */ 49, 49, 450, 50, 50, 34, 34, 274, 122, 122,
/* 1170 */ 450, 123, 123, 450, 124, 124, 450, 897, 56, 56,
/* 1180 */ 450, 896, 35, 35, 450, 267, 450, 817, 450, 817,
/* 1190 */ 106, 106, 450, 53, 53, 385, 107, 107, 450, 817,
/* 1200 */ 108, 108, 817, 450, 104, 104, 121, 121, 119, 119,
/* 1210 */ 450, 117, 112, 112, 450, 276, 450, 225, 111, 111,
/* 1220 */ 450, 730, 450, 109, 109, 450, 673, 674, 675, 911,
/* 1230 */ 110, 110, 317, 998, 55, 55, 57, 57, 692, 331,
/* 1240 */ 54, 54, 26, 26, 696, 30, 30, 317, 936, 197,
/* 1250 */ 196, 195, 335, 281, 336, 446, 331, 745, 689, 436,
/* 1260 */ 440, 444, 120, 72, 386, 223, 175, 345, 757, 932,
/* 1270 */ 20, 286, 319, 756, 815, 372, 374, 202, 202, 202,
/* 1280 */ 263, 395, 285, 74, 208, 21, 696, 719, 718, 883,
/* 1290 */ 120, 120, 120, 120, 120, 754, 278, 828, 77, 74,
/* 1300 */ 726, 727, 785, 783, 879, 202, 999, 208, 893, 892,
/* 1310 */ 893, 892, 694, 816, 763, 116, 774, 1289, 431, 432,
/* 1320 */ 302, 999, 390, 303, 823, 697, 691, 680, 159, 289,
/* 1330 */ 679, 883, 681, 951, 291, 218, 293, 7, 316, 828,
/* 1340 */ 173, 805, 259, 364, 252, 910, 376, 713, 295, 435,
/* 1350 */ 308, 168, 954, 993, 135, 400, 990, 284, 881, 880,
/* 1360 */ 205, 927, 925, 59, 333, 62, 144, 156, 130, 72,
/* 1370 */ 802, 366, 367, 393, 137, 185, 189, 160, 139, 383,
/* 1380 */ 67, 895, 140, 141, 142, 148, 389, 812, 775, 266,
/* 1390 */ 219, 190, 154, 391, 912, 875, 271, 406, 191, 322,
/* 1400 */ 682, 733, 192, 342, 732, 724, 731, 711, 723, 421,
/* 1410 */ 705, 71, 323, 6, 204, 771, 288, 79, 297, 346,
/* 1420 */ 772, 704, 290, 283, 703, 770, 292, 294, 966, 239,
/* 1430 */ 769, 102, 861, 438, 426, 240, 424, 442, 73, 213,
/* 1440 */ 688, 238, 22, 453, 952, 214, 217, 216, 454, 677,
/* 1450 */ 676, 671, 753, 125, 115, 235, 126, 669, 353, 166,
/* 1460 */ 127, 244, 179, 357, 306, 304, 305, 307, 113, 891,
/* 1470 */ 327, 889, 811, 328, 134, 128, 136, 138, 743, 258,
/* 1480 */ 906, 184, 143, 129, 909, 186, 63, 64, 145, 187,
/* 1490 */ 905, 65, 8, 66, 13, 188, 202, 898, 265, 149,
/* 1500 */ 987, 388, 150, 685, 161, 392, 285, 193, 279, 396,
/* 1510 */ 151, 401, 68, 14, 15, 722, 69, 236, 831, 131,
/* 1520 */ 830, 859, 70, 751, 16, 414, 755, 4, 174, 220,
/* 1530 */ 222, 784, 201, 152, 779, 77, 74, 17, 18, 874,
/* 1540 */ 860, 858, 915, 863, 914, 207, 206, 941, 163, 437,
/* 1550 */ 947, 942, 164, 209, 1002, 441, 862, 165, 210, 829,
/* 1560 */ 695, 87, 312, 211, 1291, 1290, 309,
};
static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28,
/* 10 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
/* 20 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
/* 30 */ 49, 50, 51, 52, 53, 19, 55, 55, 132, 133,
/* 40 */ 134, 1, 2, 27, 28, 29, 30, 31, 32, 33,
|
| ︙ | ︙ | |||
135110 135111 135112 135113 135114 135115 135116 |
/* 280 */ 1223, 1235, 1236, 1245, 1249, 1226, 1250, 1254, 1199, 1201,
/* 290 */ 1204, 1207, 1209, 1211, 1214, 1212, 1255, 1208, 1259, 1215,
/* 300 */ 1256, 1200, 1206, 1260, 1247, 1261, 1263, 1262, 1266, 1278,
/* 310 */ 1282, 1292, 1294, 1297, 1298, 1299, 1300, 1221, 1224, 1228,
/* 320 */ 1288, 1291, 1276, 1277, 1295,
};
static const YYACTIONTYPE yy_default[] = {
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 135449 135450 135451 135452 135453 135454 135455 135456 135457 135458 135459 135460 135461 135462 135463 135464 135465 135466 135467 135468 135469 135470 135471 135472 135473 135474 135475 135476 135477 135478 135479 135480 135481 135482 135483 135484 135485 135486 135487 135488 135489 135490 135491 135492 135493 135494 135495 135496 135497 135498 135499 135500 135501 135502 135503 135504 135505 135506 135507 |
/* 280 */ 1223, 1235, 1236, 1245, 1249, 1226, 1250, 1254, 1199, 1201,
/* 290 */ 1204, 1207, 1209, 1211, 1214, 1212, 1255, 1208, 1259, 1215,
/* 300 */ 1256, 1200, 1206, 1260, 1247, 1261, 1263, 1262, 1266, 1278,
/* 310 */ 1282, 1292, 1294, 1297, 1298, 1299, 1300, 1221, 1224, 1228,
/* 320 */ 1288, 1291, 1276, 1277, 1295,
};
static const YYACTIONTYPE yy_default[] = {
/* 0 */ 1280, 1270, 1270, 1270, 1202, 1202, 1202, 1202, 1270, 1096,
/* 10 */ 1125, 1125, 1254, 1332, 1332, 1332, 1332, 1332, 1332, 1201,
/* 20 */ 1332, 1332, 1332, 1332, 1270, 1100, 1131, 1332, 1332, 1332,
/* 30 */ 1332, 1203, 1204, 1332, 1332, 1332, 1253, 1255, 1141, 1140,
/* 40 */ 1139, 1138, 1236, 1112, 1136, 1129, 1133, 1203, 1197, 1198,
/* 50 */ 1196, 1200, 1204, 1332, 1132, 1167, 1181, 1166, 1332, 1332,
/* 60 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
/* 70 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
/* 80 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
/* 90 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
/* 100 */ 1332, 1332, 1332, 1332, 1175, 1180, 1187, 1179, 1176, 1169,
/* 110 */ 1168, 1170, 1171, 1332, 1019, 1067, 1332, 1332, 1332, 1172,
/* 120 */ 1332, 1173, 1184, 1183, 1182, 1261, 1288, 1287, 1332, 1332,
/* 130 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
/* 140 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
/* 150 */ 1332, 1332, 1332, 1332, 1332, 1280, 1270, 1025, 1025, 1332,
/* 160 */ 1270, 1270, 1270, 1270, 1270, 1270, 1266, 1100, 1091, 1332,
/* 170 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
/* 180 */ 1258, 1256, 1332, 1217, 1332, 1332, 1332, 1332, 1332, 1332,
/* 190 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
/* 200 */ 1332, 1332, 1332, 1332, 1096, 1332, 1332, 1332, 1332, 1332,
/* 210 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1282, 1332, 1231,
/* 220 */ 1096, 1096, 1096, 1098, 1080, 1090, 1004, 1135, 1114, 1114,
/* 230 */ 1321, 1135, 1321, 1042, 1302, 1039, 1125, 1114, 1199, 1125,
/* 240 */ 1125, 1097, 1090, 1332, 1324, 1105, 1105, 1323, 1323, 1105,
/* 250 */ 1146, 1070, 1135, 1076, 1076, 1076, 1076, 1105, 1016, 1135,
/* 260 */ 1146, 1070, 1070, 1135, 1105, 1016, 1235, 1318, 1105, 1105,
/* 270 */ 1016, 1210, 1105, 1016, 1105, 1016, 1210, 1068, 1068, 1068,
/* 280 */ 1057, 1210, 1068, 1042, 1068, 1057, 1068, 1068, 1118, 1113,
/* 290 */ 1118, 1113, 1118, 1113, 1118, 1113, 1105, 1205, 1105, 1332,
/* 300 */ 1210, 1214, 1214, 1210, 1130, 1119, 1128, 1126, 1135, 1022,
/* 310 */ 1060, 1285, 1285, 1281, 1281, 1281, 1281, 1329, 1329, 1266,
/* 320 */ 1297, 1297, 1044, 1044, 1297, 1332, 1332, 1332, 1332, 1332,
/* 330 */ 1332, 1292, 1332, 1219, 1332, 1332, 1332, 1332, 1332, 1332,
/* 340 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
/* 350 */ 1332, 1332, 1152, 1332, 1000, 1263, 1332, 1332, 1262, 1332,
/* 360 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
/* 370 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1320,
/* 380 */ 1332, 1332, 1332, 1332, 1332, 1332, 1234, 1233, 1332, 1332,
/* 390 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
/* 400 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
/* 410 */ 1332, 1082, 1332, 1332, 1332, 1306, 1332, 1332, 1332, 1332,
/* 420 */ 1332, 1332, 1332, 1127, 1332, 1120, 1332, 1332, 1311, 1332,
/* 430 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1272,
/* 440 */ 1332, 1332, 1332, 1271, 1332, 1332, 1332, 1332, 1332, 1154,
/* 450 */ 1332, 1153, 1157, 1332, 1010, 1332,
};
/********** End of lemon-generated parsing tables *****************************/
/* The next table maps tokens (terminal symbols) into fallback tokens.
** If a construct like the following:
**
|
| ︙ | ︙ | |||
135600 135601 135602 135603 135604 135605 135606 | /* 167 */ "expr ::= expr OR expr", /* 168 */ "expr ::= expr LT|GT|GE|LE expr", /* 169 */ "expr ::= expr EQ|NE expr", /* 170 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", /* 171 */ "expr ::= expr PLUS|MINUS expr", /* 172 */ "expr ::= expr STAR|SLASH|REM expr", /* 173 */ "expr ::= expr CONCAT expr", | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | < | | | | > | | | | | | < | | | | | | | | | | | | | | | | | | | > | | | | | < | | | | | | > | | | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 135939 135940 135941 135942 135943 135944 135945 135946 135947 135948 135949 135950 135951 135952 135953 135954 135955 135956 135957 135958 135959 135960 135961 135962 135963 135964 135965 135966 135967 135968 135969 135970 135971 135972 135973 135974 135975 135976 135977 135978 135979 135980 135981 135982 135983 135984 135985 135986 135987 135988 135989 135990 135991 135992 135993 135994 135995 135996 135997 135998 135999 136000 136001 136002 136003 136004 136005 136006 136007 136008 136009 136010 136011 136012 136013 136014 136015 136016 136017 136018 136019 136020 136021 136022 136023 136024 136025 136026 136027 136028 136029 136030 136031 136032 136033 136034 136035 136036 136037 136038 136039 136040 136041 136042 136043 136044 136045 136046 136047 136048 136049 136050 136051 136052 136053 136054 136055 136056 136057 136058 136059 136060 136061 136062 136063 136064 136065 136066 136067 136068 136069 136070 136071 136072 136073 136074 136075 136076 136077 136078 136079 136080 136081 136082 136083 136084 136085 136086 136087 136088 136089 | /* 167 */ "expr ::= expr OR expr", /* 168 */ "expr ::= expr LT|GT|GE|LE expr", /* 169 */ "expr ::= expr EQ|NE expr", /* 170 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", /* 171 */ "expr ::= expr PLUS|MINUS expr", /* 172 */ "expr ::= expr STAR|SLASH|REM expr", /* 173 */ "expr ::= expr CONCAT expr", /* 174 */ "likeop ::= NOT LIKE_KW|MATCH", /* 175 */ "expr ::= expr likeop expr", /* 176 */ "expr ::= expr likeop expr ESCAPE expr", /* 177 */ "expr ::= expr ISNULL|NOTNULL", /* 178 */ "expr ::= expr NOT NULL", /* 179 */ "expr ::= expr IS expr", /* 180 */ "expr ::= expr IS NOT expr", /* 181 */ "expr ::= NOT expr", /* 182 */ "expr ::= BITNOT expr", /* 183 */ "expr ::= MINUS expr", /* 184 */ "expr ::= PLUS expr", /* 185 */ "between_op ::= BETWEEN", /* 186 */ "between_op ::= NOT BETWEEN", /* 187 */ "expr ::= expr between_op expr AND expr", /* 188 */ "in_op ::= IN", /* 189 */ "in_op ::= NOT IN", /* 190 */ "expr ::= expr in_op LP exprlist RP", /* 191 */ "expr ::= LP select RP", /* 192 */ "expr ::= expr in_op LP select RP", /* 193 */ "expr ::= expr in_op nm dbnm paren_exprlist", /* 194 */ "expr ::= EXISTS LP select RP", /* 195 */ "expr ::= CASE case_operand case_exprlist case_else END", /* 196 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", /* 197 */ "case_exprlist ::= WHEN expr THEN expr", /* 198 */ "case_else ::= ELSE expr", /* 199 */ "case_else ::=", /* 200 */ "case_operand ::= expr", /* 201 */ "case_operand ::=", /* 202 */ "exprlist ::=", /* 203 */ "nexprlist ::= nexprlist COMMA expr", /* 204 */ "nexprlist ::= expr", /* 205 */ "paren_exprlist ::=", /* 206 */ "paren_exprlist ::= LP exprlist RP", /* 207 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", /* 208 */ "uniqueflag ::= UNIQUE", /* 209 */ "uniqueflag ::=", /* 210 */ "eidlist_opt ::=", /* 211 */ "eidlist_opt ::= LP eidlist RP", /* 212 */ "eidlist ::= eidlist COMMA nm collate sortorder", /* 213 */ "eidlist ::= nm collate sortorder", /* 214 */ "collate ::=", /* 215 */ "collate ::= COLLATE ID|STRING", /* 216 */ "cmd ::= DROP INDEX ifexists fullname", /* 217 */ "cmd ::= VACUUM", /* 218 */ "cmd ::= VACUUM nm", /* 219 */ "cmd ::= PRAGMA nm dbnm", /* 220 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", /* 221 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", /* 222 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", /* 223 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", /* 224 */ "plus_num ::= PLUS INTEGER|FLOAT", /* 225 */ "minus_num ::= MINUS INTEGER|FLOAT", /* 226 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", /* 227 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", /* 228 */ "trigger_time ::= BEFORE", /* 229 */ "trigger_time ::= AFTER", /* 230 */ "trigger_time ::= INSTEAD OF", /* 231 */ "trigger_time ::=", /* 232 */ "trigger_event ::= DELETE|INSERT", /* 233 */ "trigger_event ::= UPDATE", /* 234 */ "trigger_event ::= UPDATE OF idlist", /* 235 */ "when_clause ::=", /* 236 */ "when_clause ::= WHEN expr", /* 237 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", /* 238 */ "trigger_cmd_list ::= trigger_cmd SEMI", /* 239 */ "trnm ::= nm DOT nm", /* 240 */ "tridxby ::= INDEXED BY nm", /* 241 */ "tridxby ::= NOT INDEXED", /* 242 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt", /* 243 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select", /* 244 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt", /* 245 */ "trigger_cmd ::= select", /* 246 */ "expr ::= RAISE LP IGNORE RP", /* 247 */ "expr ::= RAISE LP raisetype COMMA nm RP", /* 248 */ "raisetype ::= ROLLBACK", /* 249 */ "raisetype ::= ABORT", /* 250 */ "raisetype ::= FAIL", /* 251 */ "cmd ::= DROP TRIGGER ifexists fullname", /* 252 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", /* 253 */ "cmd ::= DETACH database_kw_opt expr", /* 254 */ "key_opt ::=", /* 255 */ "key_opt ::= KEY expr", /* 256 */ "cmd ::= REINDEX", /* 257 */ "cmd ::= REINDEX nm dbnm", /* 258 */ "cmd ::= ANALYZE", /* 259 */ "cmd ::= ANALYZE nm dbnm", /* 260 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", /* 261 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", /* 262 */ "add_column_fullname ::= fullname", /* 263 */ "cmd ::= create_vtab", /* 264 */ "cmd ::= create_vtab LP vtabarglist RP", /* 265 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", /* 266 */ "vtabarg ::=", /* 267 */ "vtabargtoken ::= ANY", /* 268 */ "vtabargtoken ::= lp anylist RP", /* 269 */ "lp ::= LP", /* 270 */ "with ::=", /* 271 */ "with ::= WITH wqlist", /* 272 */ "with ::= WITH RECURSIVE wqlist", /* 273 */ "wqlist ::= nm eidlist_opt AS LP select RP", /* 274 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP", /* 275 */ "input ::= cmdlist", /* 276 */ "cmdlist ::= cmdlist ecmd", /* 277 */ "cmdlist ::= ecmd", /* 278 */ "ecmd ::= SEMI", /* 279 */ "ecmd ::= explain cmdx SEMI", /* 280 */ "explain ::=", /* 281 */ "trans_opt ::=", /* 282 */ "trans_opt ::= TRANSACTION", /* 283 */ "trans_opt ::= TRANSACTION nm", /* 284 */ "savepoint_opt ::= SAVEPOINT", /* 285 */ "savepoint_opt ::=", /* 286 */ "cmd ::= create_table create_table_args", /* 287 */ "columnlist ::= columnlist COMMA columnname carglist", /* 288 */ "columnlist ::= columnname carglist", /* 289 */ "nm ::= ID|INDEXED", /* 290 */ "nm ::= STRING", /* 291 */ "nm ::= JOIN_KW", /* 292 */ "typetoken ::= typename", /* 293 */ "typename ::= ID|STRING", /* 294 */ "signed ::= plus_num", /* 295 */ "signed ::= minus_num", /* 296 */ "carglist ::= carglist ccons", /* 297 */ "carglist ::=", /* 298 */ "ccons ::= NULL onconf", /* 299 */ "conslist_opt ::= COMMA conslist", /* 300 */ "conslist ::= conslist tconscomma tcons", /* 301 */ "conslist ::= tcons", /* 302 */ "tconscomma ::=", /* 303 */ "defer_subclause_opt ::= defer_subclause", /* 304 */ "resolvetype ::= raisetype", /* 305 */ "selectnowith ::= oneselect", /* 306 */ "oneselect ::= values", /* 307 */ "sclp ::= selcollist COMMA", /* 308 */ "as ::= ID|STRING", /* 309 */ "expr ::= term", /* 310 */ "likeop ::= LIKE_KW|MATCH", /* 311 */ "exprlist ::= nexprlist", /* 312 */ "nmnum ::= plus_num", /* 313 */ "nmnum ::= nm", /* 314 */ "nmnum ::= ON", /* 315 */ "nmnum ::= DELETE", /* 316 */ "nmnum ::= DEFAULT", /* 317 */ "plus_num ::= INTEGER|FLOAT", |
| ︙ | ︙ | |||
136373 136374 136375 136376 136377 136378 136379 |
{ 173, 3 },
{ 173, 3 },
{ 173, 3 },
{ 173, 3 },
{ 173, 3 },
{ 173, 3 },
{ 173, 3 },
| < | 136712 136713 136714 136715 136716 136717 136718 136719 136720 136721 136722 136723 136724 136725 |
{ 173, 3 },
{ 173, 3 },
{ 173, 3 },
{ 173, 3 },
{ 173, 3 },
{ 173, 3 },
{ 173, 3 },
{ 221, 2 },
{ 173, 3 },
{ 173, 5 },
{ 173, 2 },
{ 173, 3 },
{ 173, 3 },
{ 173, 4 },
|
| ︙ | ︙ | |||
136510 136511 136512 136513 136514 136515 136516 136517 136518 136519 136520 136521 136522 136523 |
{ 188, 1 },
{ 190, 1 },
{ 194, 1 },
{ 195, 1 },
{ 209, 2 },
{ 210, 1 },
{ 173, 1 },
{ 208, 1 },
{ 230, 1 },
{ 230, 1 },
{ 230, 1 },
{ 230, 1 },
{ 230, 1 },
{ 169, 1 },
| > | 136848 136849 136850 136851 136852 136853 136854 136855 136856 136857 136858 136859 136860 136861 136862 |
{ 188, 1 },
{ 190, 1 },
{ 194, 1 },
{ 195, 1 },
{ 209, 2 },
{ 210, 1 },
{ 173, 1 },
{ 221, 1 },
{ 208, 1 },
{ 230, 1 },
{ 230, 1 },
{ 230, 1 },
{ 230, 1 },
{ 230, 1 },
{ 169, 1 },
|
| ︙ | ︙ | |||
136652 136653 136654 136655 136656 136657 136658 |
case 19: /* temp ::= */ yytestcase(yyruleno==19);
case 22: /* table_options ::= */ yytestcase(yyruleno==22);
case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
case 90: /* distinct ::= */ yytestcase(yyruleno==90);
| | | 136991 136992 136993 136994 136995 136996 136997 136998 136999 137000 137001 137002 137003 137004 137005 |
case 19: /* temp ::= */ yytestcase(yyruleno==19);
case 22: /* table_options ::= */ yytestcase(yyruleno==22);
case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
case 90: /* distinct ::= */ yytestcase(yyruleno==90);
case 214: /* collate ::= */ yytestcase(yyruleno==214);
{yymsp[1].minor.yy194 = 0;}
break;
case 17: /* ifnotexists ::= IF NOT EXISTS */
{yymsp[-2].minor.yy194 = 1;}
break;
case 18: /* temp ::= TEMP */
case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
|
| ︙ | ︙ | |||
136796 136797 136798 136799 136800 136801 136802 |
case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
case 144: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==144);
{yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;}
break;
case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
| | | | | 137135 137136 137137 137138 137139 137140 137141 137142 137143 137144 137145 137146 137147 137148 137149 137150 137151 |
case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
case 144: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==144);
{yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;}
break;
case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
case 186: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==186);
case 189: /* in_op ::= NOT IN */ yytestcase(yyruleno==189);
case 215: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==215);
{yymsp[-1].minor.yy194 = 1;}
break;
case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
{yymsp[-1].minor.yy194 = 0;}
break;
case 61: /* tconscomma ::= COMMA */
{pParse->constraintName.n = 0;}
|
| ︙ | ︙ | |||
136962 136963 136964 136965 136966 136967 136968 |
break;
case 89: /* distinct ::= ALL */
{yymsp[0].minor.yy194 = SF_All;}
break;
case 91: /* sclp ::= */
case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119);
case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126);
| | | | | 137301 137302 137303 137304 137305 137306 137307 137308 137309 137310 137311 137312 137313 137314 137315 137316 137317 |
break;
case 89: /* distinct ::= ALL */
{yymsp[0].minor.yy194 = SF_All;}
break;
case 91: /* sclp ::= */
case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119);
case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126);
case 202: /* exprlist ::= */ yytestcase(yyruleno==202);
case 205: /* paren_exprlist ::= */ yytestcase(yyruleno==205);
case 210: /* eidlist_opt ::= */ yytestcase(yyruleno==210);
{yymsp[1].minor.yy148 = 0;}
break;
case 92: /* selcollist ::= sclp expr as */
{
yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr);
if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-2].minor.yy148, &yymsp[0].minor.yy0, 1);
sqlite3ExprListSetSpan(pParse,yymsp[-2].minor.yy148,&yymsp[-1].minor.yy190);
|
| ︙ | ︙ | |||
136990 136991 136992 136993 136994 136995 136996 |
Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot);
}
break;
case 95: /* as ::= AS nm */
case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
| | | | 137329 137330 137331 137332 137333 137334 137335 137336 137337 137338 137339 137340 137341 137342 137343 137344 |
Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot);
}
break;
case 95: /* as ::= AS nm */
case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
case 224: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==224);
case 225: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==225);
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
break;
case 97: /* from ::= */
{yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));}
break;
case 98: /* from ::= FROM seltablist */
{
|
| ︙ | ︙ | |||
137074 137075 137076 137077 137078 137079 137080 |
break;
case 111: /* joinop ::= JOIN_KW nm nm JOIN */
{yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
break;
case 112: /* on_opt ::= ON expr */
case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129);
case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136);
| | | | | 137413 137414 137415 137416 137417 137418 137419 137420 137421 137422 137423 137424 137425 137426 137427 137428 137429 137430 137431 137432 137433 137434 |
break;
case 111: /* joinop ::= JOIN_KW nm nm JOIN */
{yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
break;
case 112: /* on_opt ::= ON expr */
case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129);
case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136);
case 198: /* case_else ::= ELSE expr */ yytestcase(yyruleno==198);
{yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;}
break;
case 113: /* on_opt ::= */
case 128: /* having_opt ::= */ yytestcase(yyruleno==128);
case 135: /* where_opt ::= */ yytestcase(yyruleno==135);
case 199: /* case_else ::= */ yytestcase(yyruleno==199);
case 201: /* case_operand ::= */ yytestcase(yyruleno==201);
{yymsp[1].minor.yy72 = 0;}
break;
case 115: /* indexed_opt ::= INDEXED BY nm */
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
break;
case 116: /* indexed_opt ::= NOT INDEXED */
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
|
| ︙ | ︙ | |||
137318 137319 137320 137321 137322 137323 137324 |
case 169: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==169);
case 170: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==170);
case 171: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==171);
case 172: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==172);
case 173: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==173);
{spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);}
break;
| | < < < | | | | | | | | | | | | | | | 137657 137658 137659 137660 137661 137662 137663 137664 137665 137666 137667 137668 137669 137670 137671 137672 137673 137674 137675 137676 137677 137678 137679 137680 137681 137682 137683 137684 137685 137686 137687 137688 137689 137690 137691 137692 137693 137694 137695 137696 137697 137698 137699 137700 137701 137702 137703 137704 137705 137706 137707 137708 137709 137710 137711 137712 137713 137714 137715 137716 137717 137718 137719 137720 137721 137722 137723 137724 137725 137726 137727 137728 137729 137730 137731 137732 137733 137734 137735 137736 137737 137738 137739 137740 137741 137742 137743 137744 137745 137746 137747 |
case 169: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==169);
case 170: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==170);
case 171: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==171);
case 172: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==172);
case 173: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==173);
{spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);}
break;
case 174: /* likeop ::= NOT LIKE_KW|MATCH */
{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
break;
case 175: /* expr ::= expr likeop expr */
{
ExprList *pList;
int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
yymsp[-1].minor.yy0.n &= 0x7fffffff;
pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr);
pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy190.pExpr);
yymsp[-2].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0);
exprNot(pParse, bNot, &yymsp[-2].minor.yy190);
yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc;
}
break;
case 176: /* expr ::= expr likeop expr ESCAPE expr */
{
ExprList *pList;
int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
yymsp[-3].minor.yy0.n &= 0x7fffffff;
pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy190.pExpr);
pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
yymsp[-4].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0);
exprNot(pParse, bNot, &yymsp[-4].minor.yy190);
yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc;
}
break;
case 177: /* expr ::= expr ISNULL|NOTNULL */
{spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);}
break;
case 178: /* expr ::= expr NOT NULL */
{spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);}
break;
case 179: /* expr ::= expr IS expr */
{
spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);
binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL);
}
break;
case 180: /* expr ::= expr IS NOT expr */
{
spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190);
binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL);
}
break;
case 181: /* expr ::= NOT expr */
case 182: /* expr ::= BITNOT expr */ yytestcase(yyruleno==182);
{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
break;
case 183: /* expr ::= MINUS expr */
{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
break;
case 184: /* expr ::= PLUS expr */
{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
break;
case 185: /* between_op ::= BETWEEN */
case 188: /* in_op ::= IN */ yytestcase(yyruleno==188);
{yymsp[0].minor.yy194 = 0;}
break;
case 187: /* expr ::= expr between_op expr AND expr */
{
ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0);
if( yymsp[-4].minor.yy190.pExpr ){
yymsp[-4].minor.yy190.pExpr->x.pList = pList;
}else{
sqlite3ExprListDelete(pParse->db, pList);
}
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
}
break;
case 190: /* expr ::= expr in_op LP exprlist RP */
{
if( yymsp[-1].minor.yy148==0 ){
/* Expressions of the form
**
** expr1 IN ()
** expr1 NOT IN ()
**
|
| ︙ | ︙ | |||
137450 137451 137452 137453 137454 137455 137456 |
sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy148);
}
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
}
yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
}
break;
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 137786 137787 137788 137789 137790 137791 137792 137793 137794 137795 137796 137797 137798 137799 137800 137801 137802 137803 137804 137805 137806 137807 137808 137809 137810 137811 137812 137813 137814 137815 137816 137817 137818 137819 137820 137821 137822 137823 137824 137825 137826 137827 137828 137829 137830 137831 137832 137833 137834 137835 137836 137837 137838 137839 137840 137841 137842 137843 137844 137845 137846 137847 137848 137849 137850 137851 137852 137853 137854 137855 137856 137857 137858 137859 137860 137861 137862 137863 137864 137865 137866 137867 137868 137869 137870 137871 137872 137873 137874 137875 137876 137877 137878 137879 137880 137881 137882 137883 137884 137885 137886 137887 137888 137889 137890 137891 137892 137893 137894 137895 137896 137897 137898 137899 137900 137901 137902 137903 137904 137905 137906 137907 137908 137909 137910 137911 137912 137913 137914 137915 137916 137917 137918 137919 137920 137921 137922 137923 137924 137925 137926 137927 137928 137929 137930 137931 137932 137933 137934 137935 137936 137937 137938 137939 137940 137941 137942 137943 137944 137945 137946 137947 137948 137949 137950 137951 137952 137953 137954 137955 137956 137957 137958 137959 137960 137961 137962 137963 137964 137965 137966 137967 137968 137969 137970 137971 137972 137973 137974 137975 137976 137977 137978 137979 137980 137981 137982 137983 137984 137985 137986 137987 137988 137989 137990 137991 137992 137993 137994 137995 137996 137997 137998 137999 138000 138001 138002 138003 138004 138005 138006 138007 138008 138009 138010 138011 138012 138013 138014 138015 138016 138017 138018 138019 138020 138021 138022 138023 138024 138025 138026 138027 138028 138029 138030 138031 138032 138033 138034 138035 138036 138037 138038 138039 138040 138041 138042 138043 138044 138045 138046 138047 138048 138049 138050 138051 138052 138053 138054 138055 138056 138057 138058 138059 138060 138061 138062 138063 138064 138065 138066 138067 138068 138069 138070 138071 138072 138073 138074 138075 138076 138077 138078 138079 138080 138081 138082 138083 138084 138085 138086 138087 138088 138089 138090 138091 138092 138093 138094 138095 138096 138097 138098 138099 138100 138101 138102 138103 138104 138105 138106 138107 138108 138109 138110 138111 138112 138113 138114 138115 138116 138117 138118 138119 138120 138121 138122 138123 138124 138125 138126 138127 138128 138129 138130 138131 138132 138133 138134 138135 138136 138137 138138 138139 138140 138141 138142 138143 138144 138145 138146 138147 138148 138149 138150 |
sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy148);
}
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
}
yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
}
break;
case 191: /* expr ::= LP select RP */
{
spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243);
}
break;
case 192: /* expr ::= expr in_op LP select RP */
{
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243);
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
}
break;
case 193: /* expr ::= expr in_op nm dbnm paren_exprlist */
{
SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
if( yymsp[0].minor.yy148 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148);
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect);
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
yymsp[-4].minor.yy190.zEnd = yymsp[-1].minor.yy0.z ? &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n] : &yymsp[-2].minor.yy0.z[yymsp[-2].minor.yy0.n];
}
break;
case 194: /* expr ::= EXISTS LP select RP */
{
Expr *p;
spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243);
}
break;
case 195: /* expr ::= CASE case_operand case_exprlist case_else END */
{
spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0);
if( yymsp[-4].minor.yy190.pExpr ){
yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148;
sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy190.pExpr);
}else{
sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148);
sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72);
}
}
break;
case 196: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
{
yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr);
yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
}
break;
case 197: /* case_exprlist ::= WHEN expr THEN expr */
{
yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr);
}
break;
case 200: /* case_operand ::= expr */
{yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/}
break;
case 203: /* nexprlist ::= nexprlist COMMA expr */
{yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);}
break;
case 204: /* nexprlist ::= expr */
{yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/}
break;
case 206: /* paren_exprlist ::= LP exprlist RP */
case 211: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==211);
{yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;}
break;
case 207: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
{
sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
&yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
}
break;
case 208: /* uniqueflag ::= UNIQUE */
case 249: /* raisetype ::= ABORT */ yytestcase(yyruleno==249);
{yymsp[0].minor.yy194 = OE_Abort;}
break;
case 209: /* uniqueflag ::= */
{yymsp[1].minor.yy194 = OE_None;}
break;
case 212: /* eidlist ::= eidlist COMMA nm collate sortorder */
{
yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194);
}
break;
case 213: /* eidlist ::= nm collate sortorder */
{
yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/
}
break;
case 216: /* cmd ::= DROP INDEX ifexists fullname */
{sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);}
break;
case 217: /* cmd ::= VACUUM */
{sqlite3Vacuum(pParse,0);}
break;
case 218: /* cmd ::= VACUUM nm */
{sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
break;
case 219: /* cmd ::= PRAGMA nm dbnm */
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
break;
case 220: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
break;
case 221: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
break;
case 222: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
break;
case 223: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
break;
case 226: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
{
Token all;
all.z = yymsp[-3].minor.yy0.z;
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
}
break;
case 227: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
{
sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
}
break;
case 228: /* trigger_time ::= BEFORE */
{ yymsp[0].minor.yy194 = TK_BEFORE; }
break;
case 229: /* trigger_time ::= AFTER */
{ yymsp[0].minor.yy194 = TK_AFTER; }
break;
case 230: /* trigger_time ::= INSTEAD OF */
{ yymsp[-1].minor.yy194 = TK_INSTEAD;}
break;
case 231: /* trigger_time ::= */
{ yymsp[1].minor.yy194 = TK_BEFORE; }
break;
case 232: /* trigger_event ::= DELETE|INSERT */
case 233: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==233);
{yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
break;
case 234: /* trigger_event ::= UPDATE OF idlist */
{yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
break;
case 235: /* when_clause ::= */
case 254: /* key_opt ::= */ yytestcase(yyruleno==254);
{ yymsp[1].minor.yy72 = 0; }
break;
case 236: /* when_clause ::= WHEN expr */
case 255: /* key_opt ::= KEY expr */ yytestcase(yyruleno==255);
{ yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
break;
case 237: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
{
assert( yymsp[-2].minor.yy145!=0 );
yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
}
break;
case 238: /* trigger_cmd_list ::= trigger_cmd SEMI */
{
assert( yymsp[-1].minor.yy145!=0 );
yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
}
break;
case 239: /* trnm ::= nm DOT nm */
{
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
sqlite3ErrorMsg(pParse,
"qualified table names are not allowed on INSERT, UPDATE, and DELETE "
"statements within triggers");
}
break;
case 240: /* tridxby ::= INDEXED BY nm */
{
sqlite3ErrorMsg(pParse,
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
"within triggers");
}
break;
case 241: /* tridxby ::= NOT INDEXED */
{
sqlite3ErrorMsg(pParse,
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
"within triggers");
}
break;
case 242: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
{yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
break;
case 243: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
{yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}
break;
case 244: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
{yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
break;
case 245: /* trigger_cmd ::= select */
{yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
break;
case 246: /* expr ::= RAISE LP IGNORE RP */
{
spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
if( yymsp[-3].minor.yy190.pExpr ){
yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
}
}
break;
case 247: /* expr ::= RAISE LP raisetype COMMA nm RP */
{
spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
if( yymsp[-5].minor.yy190.pExpr ) {
yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
}
}
break;
case 248: /* raisetype ::= ROLLBACK */
{yymsp[0].minor.yy194 = OE_Rollback;}
break;
case 250: /* raisetype ::= FAIL */
{yymsp[0].minor.yy194 = OE_Fail;}
break;
case 251: /* cmd ::= DROP TRIGGER ifexists fullname */
{
sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
}
break;
case 252: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
{
sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
}
break;
case 253: /* cmd ::= DETACH database_kw_opt expr */
{
sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
}
break;
case 256: /* cmd ::= REINDEX */
{sqlite3Reindex(pParse, 0, 0);}
break;
case 257: /* cmd ::= REINDEX nm dbnm */
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
break;
case 258: /* cmd ::= ANALYZE */
{sqlite3Analyze(pParse, 0, 0);}
break;
case 259: /* cmd ::= ANALYZE nm dbnm */
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
break;
case 260: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
{
sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
}
break;
case 261: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
{
yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
}
break;
case 262: /* add_column_fullname ::= fullname */
{
disableLookaside(pParse);
sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
}
break;
case 263: /* cmd ::= create_vtab */
{sqlite3VtabFinishParse(pParse,0);}
break;
case 264: /* cmd ::= create_vtab LP vtabarglist RP */
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
break;
case 265: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
{
sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
}
break;
case 266: /* vtabarg ::= */
{sqlite3VtabArgInit(pParse);}
break;
case 267: /* vtabargtoken ::= ANY */
case 268: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==268);
case 269: /* lp ::= LP */ yytestcase(yyruleno==269);
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
break;
case 270: /* with ::= */
{yymsp[1].minor.yy285 = 0;}
break;
case 271: /* with ::= WITH wqlist */
{ yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
break;
case 272: /* with ::= WITH RECURSIVE wqlist */
{ yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
break;
case 273: /* wqlist ::= nm eidlist_opt AS LP select RP */
{
yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
}
break;
case 274: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
{
yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
}
break;
default:
/* (275) input ::= cmdlist */ yytestcase(yyruleno==275);
/* (276) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==276);
/* (277) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=277);
/* (278) ecmd ::= SEMI */ yytestcase(yyruleno==278);
/* (279) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==279);
/* (280) explain ::= */ yytestcase(yyruleno==280);
/* (281) trans_opt ::= */ yytestcase(yyruleno==281);
/* (282) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==282);
/* (283) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==283);
/* (284) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==284);
/* (285) savepoint_opt ::= */ yytestcase(yyruleno==285);
/* (286) cmd ::= create_table create_table_args */ yytestcase(yyruleno==286);
/* (287) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==287);
/* (288) columnlist ::= columnname carglist */ yytestcase(yyruleno==288);
/* (289) nm ::= ID|INDEXED */ yytestcase(yyruleno==289);
/* (290) nm ::= STRING */ yytestcase(yyruleno==290);
/* (291) nm ::= JOIN_KW */ yytestcase(yyruleno==291);
/* (292) typetoken ::= typename */ yytestcase(yyruleno==292);
/* (293) typename ::= ID|STRING */ yytestcase(yyruleno==293);
/* (294) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
/* (295) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=295);
/* (296) carglist ::= carglist ccons */ yytestcase(yyruleno==296);
/* (297) carglist ::= */ yytestcase(yyruleno==297);
/* (298) ccons ::= NULL onconf */ yytestcase(yyruleno==298);
/* (299) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==299);
/* (300) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==300);
/* (301) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=301);
/* (302) tconscomma ::= */ yytestcase(yyruleno==302);
/* (303) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=303);
/* (304) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=304);
/* (305) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=305);
/* (306) oneselect ::= values */ yytestcase(yyruleno==306);
/* (307) sclp ::= selcollist COMMA */ yytestcase(yyruleno==307);
/* (308) as ::= ID|STRING */ yytestcase(yyruleno==308);
/* (309) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=309);
/* (310) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==310);
/* (311) exprlist ::= nexprlist */ yytestcase(yyruleno==311);
/* (312) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=312);
/* (313) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=313);
/* (314) nmnum ::= ON */ yytestcase(yyruleno==314);
/* (315) nmnum ::= DELETE */ yytestcase(yyruleno==315);
/* (316) nmnum ::= DEFAULT */ yytestcase(yyruleno==316);
/* (317) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==317);
|
| ︙ | ︙ | |||
181077 181078 181079 181080 181081 181082 181083 | typedef unsigned char u8; typedef unsigned int u32; typedef unsigned short u16; typedef short i16; typedef sqlite3_int64 i64; typedef sqlite3_uint64 u64; | > | > | 181414 181415 181416 181417 181418 181419 181420 181421 181422 181423 181424 181425 181426 181427 181428 181429 181430 | typedef unsigned char u8; typedef unsigned int u32; typedef unsigned short u16; typedef short i16; typedef sqlite3_int64 i64; typedef sqlite3_uint64 u64; #ifndef ArraySize # define ArraySize(x) ((int)(sizeof(x) / sizeof(x[0]))) #endif #define testcase(x) #define ALWAYS(x) 1 #define NEVER(x) 0 #define MIN(x,y) (((x) < (y)) ? (x) : (y)) #define MAX(x,y) (((x) > (y)) ? (x) : (y)) |
| ︙ | ︙ | |||
186300 186301 186302 186303 186304 186305 186306 |
Fts5ExprNode *p1 = pNode->apChild[i];
assert( p1->bEof || fts5RowidCmp(pExpr, p1->iRowid, iLast)>=0 );
if( p1->bEof==0 ){
if( (p1->iRowid==iLast)
|| (bFromValid && fts5RowidCmp(pExpr, p1->iRowid, iFrom)<0)
){
int rc = fts5ExprNodeNext(pExpr, p1, bFromValid, iFrom);
| | > > > | 186639 186640 186641 186642 186643 186644 186645 186646 186647 186648 186649 186650 186651 186652 186653 186654 186655 186656 |
Fts5ExprNode *p1 = pNode->apChild[i];
assert( p1->bEof || fts5RowidCmp(pExpr, p1->iRowid, iLast)>=0 );
if( p1->bEof==0 ){
if( (p1->iRowid==iLast)
|| (bFromValid && fts5RowidCmp(pExpr, p1->iRowid, iFrom)<0)
){
int rc = fts5ExprNodeNext(pExpr, p1, bFromValid, iFrom);
if( rc!=SQLITE_OK ){
pNode->bNomatch = 0;
return rc;
}
}
}
}
fts5ExprNodeTest_OR(pExpr, pNode);
return SQLITE_OK;
}
|
| ︙ | ︙ | |||
186331 186332 186333 186334 186335 186336 186337 |
bMatch = 1;
for(iChild=0; iChild<pAnd->nChild; iChild++){
Fts5ExprNode *pChild = pAnd->apChild[iChild];
int cmp = fts5RowidCmp(pExpr, iLast, pChild->iRowid);
if( cmp>0 ){
/* Advance pChild until it points to iLast or laster */
rc = fts5ExprNodeNext(pExpr, pChild, 1, iLast);
| | > > > | 186673 186674 186675 186676 186677 186678 186679 186680 186681 186682 186683 186684 186685 186686 186687 186688 186689 186690 |
bMatch = 1;
for(iChild=0; iChild<pAnd->nChild; iChild++){
Fts5ExprNode *pChild = pAnd->apChild[iChild];
int cmp = fts5RowidCmp(pExpr, iLast, pChild->iRowid);
if( cmp>0 ){
/* Advance pChild until it points to iLast or laster */
rc = fts5ExprNodeNext(pExpr, pChild, 1, iLast);
if( rc!=SQLITE_OK ){
pAnd->bNomatch = 0;
return rc;
}
}
/* If the child node is now at EOF, so is the parent AND node. Otherwise,
** the child node is guaranteed to have advanced at least as far as
** rowid iLast. So if it is not at exactly iLast, pChild->iRowid is the
** new lastest rowid seen so far. */
assert( pChild->bEof || fts5RowidCmp(pExpr, iLast, pChild->iRowid)<=0 );
|
| ︙ | ︙ | |||
186370 186371 186372 186373 186374 186375 186376 186377 186378 186379 186380 186381 186382 186383 |
Fts5ExprNode *pNode,
int bFromValid,
i64 iFrom
){
int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);
if( rc==SQLITE_OK ){
rc = fts5ExprNodeTest_AND(pExpr, pNode);
}
return rc;
}
static int fts5ExprNodeTest_NOT(
Fts5Expr *pExpr, /* Expression pPhrase belongs to */
Fts5ExprNode *pNode /* FTS5_NOT node to advance */
| > > | 186715 186716 186717 186718 186719 186720 186721 186722 186723 186724 186725 186726 186727 186728 186729 186730 |
Fts5ExprNode *pNode,
int bFromValid,
i64 iFrom
){
int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);
if( rc==SQLITE_OK ){
rc = fts5ExprNodeTest_AND(pExpr, pNode);
}else{
pNode->bNomatch = 0;
}
return rc;
}
static int fts5ExprNodeTest_NOT(
Fts5Expr *pExpr, /* Expression pPhrase belongs to */
Fts5ExprNode *pNode /* FTS5_NOT node to advance */
|
| ︙ | ︙ | |||
186412 186413 186414 186415 186416 186417 186418 186419 186420 186421 186422 186423 186424 186425 |
int bFromValid,
i64 iFrom
){
int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);
if( rc==SQLITE_OK ){
rc = fts5ExprNodeTest_NOT(pExpr, pNode);
}
return rc;
}
/*
** If pNode currently points to a match, this function returns SQLITE_OK
** without modifying it. Otherwise, pNode is advanced until it does point
** to a match or EOF is reached.
| > > > | 186759 186760 186761 186762 186763 186764 186765 186766 186767 186768 186769 186770 186771 186772 186773 186774 186775 |
int bFromValid,
i64 iFrom
){
int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);
if( rc==SQLITE_OK ){
rc = fts5ExprNodeTest_NOT(pExpr, pNode);
}
if( rc!=SQLITE_OK ){
pNode->bNomatch = 0;
}
return rc;
}
/*
** If pNode currently points to a match, this function returns SQLITE_OK
** without modifying it. Otherwise, pNode is advanced until it does point
** to a match or EOF is reached.
|
| ︙ | ︙ | |||
197532 197533 197534 197535 197536 197537 197538 |
static void fts5SourceIdFunc(
sqlite3_context *pCtx, /* Function call context */
int nArg, /* Number of args */
sqlite3_value **apUnused /* Function arguments */
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
| | | 197882 197883 197884 197885 197886 197887 197888 197889 197890 197891 197892 197893 197894 197895 197896 |
static void fts5SourceIdFunc(
sqlite3_context *pCtx, /* Function call context */
int nArg, /* Number of args */
sqlite3_value **apUnused /* Function arguments */
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
sqlite3_result_text(pCtx, "fts5: 2017-02-20 13:11:07 ff213f2ef5bf96754a2264685d25546d8b5ccf0a", -1, SQLITE_TRANSIENT);
}
static int fts5Init(sqlite3 *db){
static const sqlite3_module fts5Mod = {
/* iVersion */ 2,
/* xCreate */ fts5CreateMethod,
/* xConnect */ fts5ConnectMethod,
|
| ︙ | ︙ |
Changes to src/sqlite3.h.
| ︙ | ︙ | |||
117 118 119 120 121 122 123 | ** string contains the date and time of the check-in (UTC) and an SHA1 ** hash of the entire source tree. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ | | | | | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | ** string contains the date and time of the check-in (UTC) and an SHA1 ** hash of the entire source tree. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.18.0" #define SQLITE_VERSION_NUMBER 3018000 #define SQLITE_SOURCE_ID "2017-02-23 02:15:33 7a959f6d1ea038988cdb4c02d6f37abaec2580a0" /* ** CAPI3REF: Run-Time Library Version Numbers ** KEYWORDS: sqlite3_version sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros |
| ︙ | ︙ |