Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch remove-btree Excluding Merge-Ins
This is equivalent to a diff from 29c1ec8e6b to 6838c8a3a7
2012-02-21
| ||
20:03 | Only the bare basics work. But we might as well go ahead and call this the trunk since we are unlikely to ever need to bisect back into this massive rewrite effort. check-in: a101b3e1c4 user: drh tags: trunk | |
20:01 | Inserting multiple rows into a table and querying via full-table scan is now working. Leaf check-in: 6838c8a3a7 user: drh tags: remove-btree | |
19:57 | Improved storage tracing output. check-in: d4c10f88ad user: drh tags: remove-btree | |
2012-02-08
| ||
21:47 | This is an incremental check-in for the massive change that removes the old b-tree layer and substitutes a uniform key-value namespace. Nothing works at this point. This check-in is just a checkpoint. check-in: 87d659d624 user: drh tags: remove-btree | |
2012-01-26
| ||
22:11 | Always call OP_MakeKey before OP_MakeRecord prior to adding content to an index. check-in: 29c1ec8e6b user: drh tags: trunk | |
20:53 | Fix the data codec so that it handles Inf and NaN. Make sure OP_MakeKey is only called with an index cursor. check-in: bfa05539ea user: drh tags: trunk | |
Changes to ext/fts3/fts3.c.
︙ | ︙ | |||
303 304 305 306 307 308 309 | #include <stdlib.h> #include <stddef.h> #include <stdio.h> #include <string.h> #include <stdarg.h> #include "fts3.h" | < < < < | 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | #include <stdlib.h> #include <stddef.h> #include <stdio.h> #include <string.h> #include <stdarg.h> #include "fts3.h" static int fts3EvalNext(Fts3Cursor *pCsr); static int fts3EvalStart(Fts3Cursor *pCsr); static int fts3TermSegReaderCursor( Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **); /* |
︙ | ︙ |
Changes to ext/fts3/fts3Int.h.
︙ | ︙ | |||
25 26 27 28 29 30 31 | */ #if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3) # define SQLITE_ENABLE_FTS3 #endif #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) | < < < < < < | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | */ #if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3) # define SQLITE_ENABLE_FTS3 #endif #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) #include "sqlite4.h" #include "fts3_tokenizer.h" #include "fts3_hash.h" /* ** This constant controls how often segments are merged. Once there are ** FTS3_MERGE_COUNT segments of level N, they are merged into a single |
︙ | ︙ |
Changes to main.mk.
︙ | ︙ | |||
47 48 49 50 51 52 53 | TCCX = $(TCC) $(OPTS) -I. -I$(TOP)/src -I$(TOP) TCCX += -I$(TOP)/ext/rtree -I$(TOP)/ext/icu -I$(TOP)/ext/fts3 TCCX += -I$(TOP)/ext/async # Object files for the SQLite library. # LIBOBJ+= alter.o analyze.o attach.o auth.o \ | | | < | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | TCCX = $(TCC) $(OPTS) -I. -I$(TOP)/src -I$(TOP) TCCX += -I$(TOP)/ext/rtree -I$(TOP)/ext/icu -I$(TOP)/ext/fts3 TCCX += -I$(TOP)/ext/async # Object files for the SQLite library. # LIBOBJ+= alter.o analyze.o attach.o auth.o \ bitvec.o build.o \ callback.o complete.o ctime.o date.o delete.o expr.o fault.o fkey.o \ fts3.o fts3_aux.o fts3_expr.o fts3_hash.o fts3_icu.o fts3_porter.o \ fts3_snippet.o fts3_tokenizer.o fts3_tokenizer1.o \ fts3_write.o func.o global.o hash.o \ icu.o insert.o kvmem.o legacy.o \ main.o malloc.o math.o mem0.o mem1.o mem2.o mem3.o mem5.o \ mutex.o mutex_noop.o mutex_os2.o mutex_unix.o mutex_w32.o \ opcodes.o os.o os_os2.o os_unix.o os_win.o \ parse.o pragma.o prepare.o printf.o \ random.o resolve.o rowset.o rtree.o select.o status.o storage.o \ table.o tokenize.o trigger.o \ update.o util.o varint.o \ vdbe.o vdbeapi.o vdbeaux.o vdbecodec.o vdbecursor.o \ vdbemem.o vdbesort.o vdbetrace.o \ walker.o where.o utf.o vtab.o # All of the source code files. # SRC = \ $(TOP)/src/alter.c \ $(TOP)/src/analyze.c \ $(TOP)/src/attach.c \ $(TOP)/src/auth.c \ $(TOP)/src/bitvec.c \ $(TOP)/src/build.c \ $(TOP)/src/callback.c \ $(TOP)/src/complete.c \ $(TOP)/src/ctime.c \ $(TOP)/src/date.c \ $(TOP)/src/delete.c \ $(TOP)/src/expr.c \ $(TOP)/src/fault.c \ $(TOP)/src/fkey.c \ $(TOP)/src/func.c \ $(TOP)/src/global.c \ $(TOP)/src/hash.c \ $(TOP)/src/hash.h \ $(TOP)/src/hwtime.h \ $(TOP)/src/insert.c \ $(TOP)/src/kvmem.c \ $(TOP)/src/legacy.c \ $(TOP)/src/main.c \ $(TOP)/src/malloc.c \ $(TOP)/src/math.c \ $(TOP)/src/mem0.c \ $(TOP)/src/mem1.c \ $(TOP)/src/mem2.c \ $(TOP)/src/mem3.c \ $(TOP)/src/mem5.c \ $(TOP)/src/mutex.c \ $(TOP)/src/mutex.h \ $(TOP)/src/mutex_noop.c \ $(TOP)/src/mutex_os2.c \ $(TOP)/src/mutex_unix.c \ $(TOP)/src/mutex_w32.c \ $(TOP)/src/os.c \ $(TOP)/src/os.h \ $(TOP)/src/os_common.h \ $(TOP)/src/os_os2.c \ $(TOP)/src/os_unix.c \ $(TOP)/src/os_win.c \ $(TOP)/src/parse.y \ $(TOP)/src/pragma.c \ $(TOP)/src/prepare.c \ $(TOP)/src/printf.c \ $(TOP)/src/random.c \ $(TOP)/src/resolve.c \ $(TOP)/src/rowset.c \ $(TOP)/src/select.c \ $(TOP)/src/shell.c \ $(TOP)/src/sqlite.h.in \ $(TOP)/src/sqliteInt.h \ $(TOP)/src/sqliteLimit.h \ $(TOP)/src/status.c \ $(TOP)/src/storage.c \ $(TOP)/src/storage.h \ $(TOP)/src/table.c \ $(TOP)/src/tclsqlite.c \ $(TOP)/src/tokenize.c \ $(TOP)/src/trigger.c \ $(TOP)/src/utf.c \ $(TOP)/src/update.c \ $(TOP)/src/util.c \ $(TOP)/src/varint.c \ $(TOP)/src/vdbe.c \ $(TOP)/src/vdbe.h \ $(TOP)/src/vdbeapi.c \ $(TOP)/src/vdbeaux.c \ $(TOP)/src/vdbemem.c \ $(TOP)/src/vdbesort.c \ $(TOP)/src/vdbetrace.c \ $(TOP)/src/vdbeInt.h \ $(TOP)/src/vtab.c \ $(TOP)/src/walker.c \ $(TOP)/src/where.c # Source code for extensions # SRC += \ $(TOP)/ext/fts3/fts3.c \ $(TOP)/ext/fts3/fts3.h \ $(TOP)/ext/fts3/fts3Int.h \ $(TOP)/ext/fts3/fts3_aux.c \ $(TOP)/ext/fts3/fts3_expr.c \ $(TOP)/ext/fts3/fts3_hash.c \ $(TOP)/ext/fts3/fts3_hash.h \ |
︙ | ︙ | |||
223 224 225 226 227 228 229 | # Source code to the test files. # TESTSRC = \ $(TOP)/ext/fts3/fts3_term.c \ $(TOP)/ext/fts3/fts3_test.c \ $(TOP)/src/test1.c \ | < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | # Source code to the test files. # TESTSRC = \ $(TOP)/ext/fts3/fts3_term.c \ $(TOP)/ext/fts3/fts3_test.c \ $(TOP)/src/test1.c \ $(TOP)/src/test4.c \ $(TOP)/src/test5.c \ $(TOP)/src/test6.c \ $(TOP)/src/test7.c \ $(TOP)/src/test8.c \ $(TOP)/src/test9.c \ $(TOP)/src/test_config.c \ $(TOP)/src/test_demovfs.c \ $(TOP)/src/test_devsym.c \ $(TOP)/src/test_fuzzer.c \ $(TOP)/src/test_hexio.c \ $(TOP)/src/test_init.c \ $(TOP)/src/test_intarray.c \ $(TOP)/src/test_journal.c \ $(TOP)/src/test_malloc.c \ $(TOP)/src/test_mutex.c \ $(TOP)/src/test_onefile.c \ $(TOP)/src/test_osinst.c \ $(TOP)/src/test_rtree.c \ $(TOP)/src/test_schema.c \ $(TOP)/src/test_storage.c \ $(TOP)/src/test_tclvar.c \ $(TOP)/src/test_thread.c \ $(TOP)/src/test_vfs.c \ $(TOP)/src/test_wholenumber.c \ $(TOP)/src/test_wsd.c #TESTSRC += $(TOP)/ext/fts2/fts2_tokenizer.c #TESTSRC += $(TOP)/ext/fts3/fts3_tokenizer.c TESTSRC2 = \ $(TOP)/src/attach.c \ $(TOP)/src/build.c \ $(TOP)/src/date.c \ $(TOP)/src/expr.c \ $(TOP)/src/func.c \ $(TOP)/src/insert.c \ $(TOP)/src/mem5.c \ $(TOP)/src/os.c \ $(TOP)/src/os_os2.c \ $(TOP)/src/os_unix.c \ $(TOP)/src/os_win.c \ $(TOP)/src/pragma.c \ $(TOP)/src/prepare.c \ $(TOP)/src/printf.c \ $(TOP)/src/random.c \ $(TOP)/src/select.c \ $(TOP)/src/tokenize.c \ $(TOP)/src/utf.c \ $(TOP)/src/util.c \ $(TOP)/src/vdbeapi.c \ $(TOP)/src/vdbeaux.c \ $(TOP)/src/vdbe.c \ $(TOP)/src/vdbemem.c \ $(TOP)/src/where.c \ parse.c \ $(TOP)/ext/fts3/fts3.c \ $(TOP)/ext/fts3/fts3_aux.c \ $(TOP)/ext/fts3/fts3_expr.c \ $(TOP)/ext/fts3/fts3_tokenizer.c \ $(TOP)/ext/fts3/fts3_write.c # Header files used by all library source files. # HDR = \ $(TOP)/src/hash.h \ $(TOP)/src/hwtime.h \ keywordhash.h \ $(TOP)/src/mutex.h \ opcodes.h \ $(TOP)/src/os.h \ $(TOP)/src/os_common.h \ parse.h \ sqlite4.h \ $(TOP)/src/sqliteInt.h \ $(TOP)/src/sqliteLimit.h \ $(TOP)/src/storage.h \ $(TOP)/src/vdbe.h \ $(TOP)/src/vdbeInt.h EXTHDR = \ $(TOP)/ext/fts3/fts3.h \ $(TOP)/ext/fts3/fts3Int.h \ $(TOP)/ext/fts3/fts3_hash.h \ $(TOP)/ext/fts3/fts3_tokenizer.h EXTHDR += \ $(TOP)/ext/rtree/rtree.h EXTHDR += \ |
︙ | ︙ |
Changes to notes/key_encoding.txt.
︙ | ︙ | |||
88 89 90 91 92 93 94 | and 0x0c. Finite non-zero values are classified as either large, or small. Small values have an absolute value less than 1. Large values have an absolute value of 1 or more. The value 1.0 is considered large. For both large and small values, we compute a mantissa M and an | | | | < | < < | < | | < | | | | > > > > > | > > > > > > > > > > > > | > > | > | | > > > | | | > | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | and 0x0c. Finite non-zero values are classified as either large, or small. Small values have an absolute value less than 1. Large values have an absolute value of 1 or more. The value 1.0 is considered large. For both large and small values, we compute a mantissa M and an exponent E. The mantissa is a base-100 representation of the value. The exponent E determines where to put the decimal point. Each centimal digit of the mantissa is stored in a byte. If the value of the centimal digit is X (hence X>=0 and X<=99) then the byte value will be 2*X+1 for every byte of the mantissa, except for the last byte which will be 2*X+0. If we assume all digits of the mantissa occur to the right of the decimal point, then the exponent E is the power of one hundred by which one must multiply the mantissa to recover the original value. Examples: Value Exponent E Significand M (in hex) -------- ---------- ---------------------- 1.0 1 02 10.0 1 14 99.0 1 b4 99.01 1 b5 02 99.0001 1 b5 01 02 100.0 2 03 00 100.1 2 03 02 100.01 2 03 01 02 1234 2 19 44 9999 2 c7 c6 9999.000001 2 c7 c7 01 01 02 9999.000009 2 c7 c7 01 01 12 9999.00001 2 c7 c7 01 01 14 9999.00009 2 c7 c7 01 01 b4 9999.000099 2 c7 c7 01 01 c6 9999.0001 2 c7 c7 01 02 9999.001 2 c7 c7 01 14 9999.01 2 c7 c7 02 9999.1 2 c7 c7 14 10000 3 02 10001 3 03 00 02 12345 3 03 2f 5a 123450 4 19 45 64 1234.5 3 19 45 64 12.345 2 19 45 64 0.123 0 19 3c 0.0123 0 03 2e 0.00123 -1 19 3c 9223372036854775807 10 13 2d 43 91 07 89 6d 9b 75 0e The E value is stored in the encoding as an unsigned varint. And since E can be negative, that means we need separate cases for positive and negative E value. That is why large and small numbers are treated differently. Large numbers have a positive E and small numbers have a zero or negative E. Large negative numbers have an initial byte of 0x08 followed by the ones-complement of the varint of E followed by the ones-complement of M. Small negative numbers have an initial byte of 0x09 followed by the varint of -E followed by the ones-complement of M. Small positive numbers have an initial byte of 0x0b followed by the ones-complement of the varint of -E followed by M. Finally, large positive nubmers have an initial byte of 0x0c followed by the varint of E followed by M. SUMMARY Each SQL value is encoded as one or more bytes. The first byte of the encoding, its meaning, and a terse description of the bytes that follow is given by the following table: 0x05 NULL 0x06 NaN 0x07 negative infinity 0x08 negative-large ~E ~M 0x09 negative-small -E ~M 0x0a zero |
︙ | ︙ |
Changes to src/alter.c.
︙ | ︙ | |||
335 336 337 338 339 340 341 | int iDb; /* Index of database containing pTab */ #ifndef SQLITE_OMIT_TRIGGER Trigger *pTrig; #endif v = sqlite4GetVdbe(pParse); if( NEVER(v==0) ) return; | < | 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | int iDb; /* Index of database containing pTab */ #ifndef SQLITE_OMIT_TRIGGER Trigger *pTrig; #endif v = sqlite4GetVdbe(pParse); if( NEVER(v==0) ) return; iDb = sqlite4SchemaToIndex(pParse->db, pTab->pSchema); assert( iDb>=0 ); #ifndef SQLITE_OMIT_TRIGGER /* Drop any table triggers from the internal schema. */ for(pTrig=sqlite4TriggerList(pParse, pTab); pTrig; pTrig=pTrig->pNext){ int iTrigDb = sqlite4SchemaToIndex(pParse->db, pTrig->pSchema); |
︙ | ︙ | |||
408 409 410 411 412 413 414 | #endif VTable *pVTab = 0; /* Non-zero if this is a v-tab with an xRename() */ int savedDbFlags; /* Saved value of db->flags */ savedDbFlags = db->flags; if( NEVER(db->mallocFailed) ) goto exit_rename_table; assert( pSrc->nSrc==1 ); | < | 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | #endif VTable *pVTab = 0; /* Non-zero if this is a v-tab with an xRename() */ int savedDbFlags; /* Saved value of db->flags */ savedDbFlags = db->flags; if( NEVER(db->mallocFailed) ) goto exit_rename_table; assert( pSrc->nSrc==1 ); pTab = sqlite4LocateTable(pParse, 0, pSrc->a[0].zName, pSrc->a[0].zDatabase); if( !pTab ) goto exit_rename_table; iDb = sqlite4SchemaToIndex(pParse->db, pTab->pSchema); zDb = db->aDb[iDb].zName; db->flags |= SQLITE_PreferBuiltin; |
︙ | ︙ | |||
583 584 585 586 587 588 589 | exit_rename_table: sqlite4SrcListDelete(db, pSrc); sqlite4DbFree(db, zName); db->flags = savedDbFlags; } | < < < < < < < < < < < < < < < < < < < < < < < < < | 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | exit_rename_table: sqlite4SrcListDelete(db, pSrc); sqlite4DbFree(db, zName); db->flags = savedDbFlags; } /* ** This function is called after an "ALTER TABLE ... ADD" statement ** has been parsed. Argument pColDef contains the text of the new ** column definition. ** ** The Table structure pParse->pNewTable was extended to include ** the new column during parsing. |
︙ | ︙ | |||
632 633 634 635 636 637 638 | sqlite4 *db; /* The database connection; */ db = pParse->db; if( pParse->nErr || db->mallocFailed ) return; pNew = pParse->pNewTable; assert( pNew ); | < | 605 606 607 608 609 610 611 612 613 614 615 616 617 618 | sqlite4 *db; /* The database connection; */ db = pParse->db; if( pParse->nErr || db->mallocFailed ) return; pNew = pParse->pNewTable; assert( pNew ); iDb = sqlite4SchemaToIndex(db, pNew->pSchema); zDb = db->aDb[iDb].zName; zTab = &pNew->zName[16]; /* Skip the "sqlite_altertab_" prefix on the name */ pCol = &pNew->aCol[pNew->nCol-1]; pDflt = pCol->pDflt; pTab = sqlite4FindTable(db, zTab, zDb); assert( pTab ); |
︙ | ︙ | |||
715 716 717 718 719 720 721 | zDb, SCHEMA_TABLE(iDb), pNew->addColOffset, zCol, pNew->addColOffset+1, zTab ); sqlite4DbFree(db, zCol); db->flags = savedDbFlags; } | < < < < < < | 687 688 689 690 691 692 693 694 695 696 697 698 699 700 | zDb, SCHEMA_TABLE(iDb), pNew->addColOffset, zCol, pNew->addColOffset+1, zTab ); sqlite4DbFree(db, zCol); db->flags = savedDbFlags; } /* Reload the schema of the modified table. */ reloadTableSchema(pParse, pTab, pTab->zName); } /* ** This function is called by the parser after the table-name in ** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument |
︙ | ︙ | |||
751 752 753 754 755 756 757 | int iDb; int i; int nAlloc; sqlite4 *db = pParse->db; /* Look up the table being altered. */ assert( pParse->pNewTable==0 ); | < | 717 718 719 720 721 722 723 724 725 726 727 728 729 730 | int iDb; int i; int nAlloc; sqlite4 *db = pParse->db; /* Look up the table being altered. */ assert( pParse->pNewTable==0 ); if( db->mallocFailed ) goto exit_begin_add_column; pTab = sqlite4LocateTable(pParse, 0, pSrc->a[0].zName, pSrc->a[0].zDatabase); if( !pTab ) goto exit_begin_add_column; #ifndef SQLITE_OMIT_VIRTUALTABLE if( IsVirtual(pTab) ){ sqlite4ErrorMsg(pParse, "virtual tables may not be altered"); |
︙ | ︙ |
Changes to src/analyze.c.
︙ | ︙ | |||
153 154 155 156 157 158 159 | u8 aCreateTbl[] = {0, 0}; int i; sqlite4 *db = pParse->db; Db *pDb; Vdbe *v = sqlite4GetVdbe(pParse); if( v==0 ) return; | < | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | u8 aCreateTbl[] = {0, 0}; int i; sqlite4 *db = pParse->db; Db *pDb; Vdbe *v = sqlite4GetVdbe(pParse); if( v==0 ) return; assert( sqlite4VdbeDb(v)==db ); pDb = &db->aDb[iDb]; /* Create new statistic tables if they do not exist, or clear them ** if they do already exist. */ for(i=0; i<ArraySize(aTable); i++){ |
︙ | ︙ | |||
474 475 476 477 478 479 480 | /* Do not gather statistics on views or virtual tables */ return; } if( memcmp(pTab->zName, "sqlite_", 7)==0 ){ /* Do not gather statistics on system tables */ return; } | < < | 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | /* Do not gather statistics on views or virtual tables */ return; } if( memcmp(pTab->zName, "sqlite_", 7)==0 ){ /* Do not gather statistics on system tables */ return; } iDb = sqlite4SchemaToIndex(db, pTab->pSchema); assert( iDb>=0 ); #ifndef SQLITE_OMIT_AUTHORIZATION if( sqlite4AuthCheck(pParse, SQLITE_ANALYZE, pTab->zName, 0, db->aDb[iDb].zName ) ){ return; } #endif |
︙ | ︙ | |||
723 724 725 726 727 728 729 | int iMem; sqlite4BeginWriteOperation(pParse, 0, iDb); iStatCur = pParse->nTab; pParse->nTab += 3; openStatTable(pParse, iDb, iStatCur, 0, 0); iMem = pParse->nMem+1; | < < | 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 | int iMem; sqlite4BeginWriteOperation(pParse, 0, iDb); iStatCur = pParse->nTab; pParse->nTab += 3; openStatTable(pParse, iDb, iStatCur, 0, 0); iMem = pParse->nMem+1; for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){ Table *pTab = (Table*)sqliteHashData(k); analyzeOneTable(pParse, pTab, 0, iStatCur, iMem); } loadAnalysis(pParse, iDb); } /* ** Generate code that will do an analysis of a single table in ** a database. If pOnlyIdx is not NULL then it is a single index ** in pTab that should be analyzed. */ static void analyzeTable(Parse *pParse, Table *pTab, Index *pOnlyIdx){ int iDb; int iStatCur; assert( pTab!=0 ); iDb = sqlite4SchemaToIndex(pParse->db, pTab->pSchema); sqlite4BeginWriteOperation(pParse, 0, iDb); iStatCur = pParse->nTab; pParse->nTab += 3; if( pOnlyIdx ){ openStatTable(pParse, iDb, iStatCur, pOnlyIdx->zName, "idx"); }else{ |
︙ | ︙ | |||
778 779 780 781 782 783 784 | char *z, *zDb; Table *pTab; Index *pIdx; Token *pTableName; /* Read the database schema. If an error occurs, leave an error message ** and code in pParse and return NULL. */ | < | 773 774 775 776 777 778 779 780 781 782 783 784 785 786 | char *z, *zDb; Table *pTab; Index *pIdx; Token *pTableName; /* Read the database schema. If an error occurs, leave an error message ** and code in pParse and return NULL. */ if( SQLITE_OK!=sqlite4ReadSchema(pParse) ){ return; } assert( pName2!=0 || pName1==0 ); if( pName1==0 ){ /* Form 1: Analyze everything */ |
︙ | ︙ | |||
1069 1070 1071 1072 1073 1074 1075 | int sqlite4AnalysisLoad(sqlite4 *db, int iDb){ analysisInfo sInfo; HashElem *i; char *zSql; int rc; assert( iDb>=0 && iDb<db->nDb ); | | < | 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | int sqlite4AnalysisLoad(sqlite4 *db, int iDb){ analysisInfo sInfo; HashElem *i; char *zSql; int rc; assert( iDb>=0 && iDb<db->nDb ); assert( db->aDb[iDb].pKV!=0 ); /* Clear any prior statistics */ for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){ Index *pIdx = sqliteHashData(i); sqlite4DefaultRowEst(pIdx); #ifdef SQLITE_ENABLE_STAT3 sqlite4DeleteIndexSamples(db, pIdx); pIdx->aSample = 0; #endif |
︙ | ︙ |
Changes to src/attach.c.
︙ | ︙ | |||
134 135 136 137 138 139 140 | if( rc==SQLITE_NOMEM ) db->mallocFailed = 1; sqlite4_result_error(context, zErr, -1); sqlite4_free(zErr); return; } assert( pVfs ); flags |= SQLITE_OPEN_MAIN_DB; | < | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | if( rc==SQLITE_NOMEM ) db->mallocFailed = 1; sqlite4_result_error(context, zErr, -1); sqlite4_free(zErr); return; } assert( pVfs ); flags |= SQLITE_OPEN_MAIN_DB; rc = sqlite4KVStoreOpen(db, zName, zPath, &aNew->pKV, 0); sqlite4_free( zPath ); db->nDb++; if( rc==SQLITE_CONSTRAINT ){ rc = SQLITE_ERROR; zErrDyn = sqlite4MPrintf(db, "database is already attached"); }else if( rc==SQLITE_OK ){ aNew->pSchema = sqlite4SchemaGet(db); if( !aNew->pSchema ){ rc = SQLITE_NOMEM; }else if( aNew->pSchema->file_format && aNew->pSchema->enc!=ENC(db) ){ zErrDyn = sqlite4MPrintf(db, "attached databases must use the same text encoding as main database"); rc = SQLITE_ERROR; } } aNew->zName = sqlite4DbStrDup(db, zName); if( rc==SQLITE_OK && aNew->zName==0 ){ rc = SQLITE_NOMEM; } /* If the file was opened successfully, read the schema for the new database. ** If this fails, or if opening the file failed, then close the file and ** remove the entry from the db->aDb[] array. i.e. put everything back the way ** we found it. */ if( rc==SQLITE_OK ){ rc = sqlite4Init(db, &zErrDyn); } if( rc ){ int iDb = db->nDb - 1; assert( iDb>=2 ); if( db->aDb[iDb].pKV ){ sqlite4KVStoreClose(db->aDb[iDb].pKV); db->aDb[iDb].pKV = 0; db->aDb[iDb].pSchema = 0; } sqlite4ResetInternalSchema(db, -1); db->nDb = iDb; if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){ |
︙ | ︙ | |||
262 263 264 265 266 267 268 | char zErr[128]; UNUSED_PARAMETER(NotUsed); if( zName==0 ) zName = ""; for(i=0; i<db->nDb; i++){ pDb = &db->aDb[i]; | | | < < | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | char zErr[128]; UNUSED_PARAMETER(NotUsed); if( zName==0 ) zName = ""; for(i=0; i<db->nDb; i++){ pDb = &db->aDb[i]; if( pDb->pKV==0 ) continue; if( sqlite4StrICmp(pDb->zName, zName)==0 ) break; } if( i>=db->nDb ){ sqlite4_snprintf(sizeof(zErr),zErr, "no such database: %s", zName); goto detach_error; } if( i<2 ){ sqlite4_snprintf(sizeof(zErr),zErr, "cannot detach database %s", zName); goto detach_error; } if( !db->autoCommit ){ sqlite4_snprintf(sizeof(zErr), zErr, "cannot DETACH database within transaction"); goto detach_error; } if( pDb->pKV->iTransLevel ){ sqlite4_snprintf(sizeof(zErr),zErr, "database %s is locked", zName); goto detach_error; } sqlite4KVStoreClose(pDb->pKV); pDb->pKV = 0; pDb->pSchema = 0; sqlite4ResetInternalSchema(db, -1); return; detach_error: |
︙ | ︙ |
Deleted src/backup.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/btmutex.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/btree.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/btree.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/btreeInt.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/build.c.
︙ | ︙ | |||
149 150 151 152 153 154 155 | */ if( pParse->cookieGoto>0 ){ yDbMask mask; int iDb; sqlite4VdbeJumpHere(v, pParse->cookieGoto-1); for(iDb=0, mask=1; iDb<db->nDb; mask<<=1, iDb++){ if( (mask & pParse->cookieMask)==0 ) continue; | < < | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | */ if( pParse->cookieGoto>0 ){ yDbMask mask; int iDb; sqlite4VdbeJumpHere(v, pParse->cookieGoto-1); for(iDb=0, mask=1; iDb<db->nDb; mask<<=1, iDb++){ if( (mask & pParse->cookieMask)==0 ) continue; sqlite4VdbeAddOp2(v,OP_Transaction, iDb, (mask & pParse->writeMask)!=0); if( db->init.busy==0 ){ sqlite4VdbeAddOp3(v, OP_VerifyCookie, iDb, pParse->cookieValue[iDb], db->aDb[iDb].pSchema->iGeneration); } } #ifndef SQLITE_OMIT_VIRTUALTABLE { |
︙ | ︙ | |||
267 268 269 270 271 272 273 | Table *sqlite4FindTable(sqlite4 *db, const char *zName, const char *zDatabase){ Table *p = 0; int i; int nName; assert( zName!=0 ); nName = sqlite4Strlen30(zName); /* All mutexes are required for schema access. Make sure we hold them. */ | < < | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | Table *sqlite4FindTable(sqlite4 *db, const char *zName, const char *zDatabase){ Table *p = 0; int i; int nName; assert( zName!=0 ); nName = sqlite4Strlen30(zName); /* All mutexes are required for schema access. Make sure we hold them. */ for(i=OMIT_TEMPDB; i<db->nDb; i++){ int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */ if( zDatabase!=0 && sqlite4StrICmp(zDatabase, db->aDb[j].zName) ) continue; p = sqlite4HashFind(&db->aDb[j].pSchema->tblHash, zName, nName); if( p ) break; } return p; } /* |
︙ | ︙ | |||
332 333 334 335 336 337 338 | ** using the ATTACH command. */ Index *sqlite4FindIndex(sqlite4 *db, const char *zName, const char *zDb){ Index *p = 0; int i; int nName = sqlite4Strlen30(zName); /* All mutexes are required for schema access. Make sure we hold them. */ | < < | 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | ** using the ATTACH command. */ Index *sqlite4FindIndex(sqlite4 *db, const char *zName, const char *zDb){ Index *p = 0; int i; int nName = sqlite4Strlen30(zName); /* All mutexes are required for schema access. Make sure we hold them. */ for(i=OMIT_TEMPDB; i<db->nDb; i++){ int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */ Schema *pSchema = db->aDb[j].pSchema; assert( pSchema ); if( zDb && sqlite4StrICmp(zDb, db->aDb[j].zName) ) continue; p = sqlite4HashFind(&pSchema->idxHash, zName, nName); if( p ) break; } return p; } /* |
︙ | ︙ | |||
367 368 369 370 371 372 373 | ** with the index. */ void sqlite4UnlinkAndDeleteIndex(sqlite4 *db, int iDb, const char *zIdxName){ Index *pIndex; int len; Hash *pHash; | < | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | ** with the index. */ void sqlite4UnlinkAndDeleteIndex(sqlite4 *db, int iDb, const char *zIdxName){ Index *pIndex; int len; Hash *pHash; pHash = &db->aDb[iDb].pSchema->idxHash; len = sqlite4Strlen30(zIdxName); pIndex = sqlite4HashInsert(pHash, zIdxName, len, 0); if( ALWAYS(pIndex) ){ if( pIndex->pTable->pIndex==pIndex ){ pIndex->pTable->pIndex = pIndex->pNext; }else{ |
︙ | ︙ | |||
407 408 409 410 411 412 413 | void sqlite4ResetInternalSchema(sqlite4 *db, int iDb){ int i, j; assert( iDb<db->nDb ); if( iDb>=0 ){ /* Case 1: Reset the single schema identified by iDb */ Db *pDb = &db->aDb[iDb]; | < < < | | 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | void sqlite4ResetInternalSchema(sqlite4 *db, int iDb){ int i, j; assert( iDb<db->nDb ); if( iDb>=0 ){ /* Case 1: Reset the single schema identified by iDb */ Db *pDb = &db->aDb[iDb]; assert( pDb->pSchema!=0 ); sqlite4SchemaClear(pDb->pSchema); /* If any database other than TEMP is reset, then also reset TEMP ** since TEMP might be holding triggers that reference tables in the ** other database. */ if( iDb!=1 ){ pDb = &db->aDb[1]; assert( pDb->pSchema!=0 ); sqlite4SchemaClear(pDb->pSchema); } return; } /* Case 2 (from here to the end): Reset all schemas for all attached ** databases. */ assert( iDb<0 ); for(i=0; i<db->nDb; i++){ Db *pDb = &db->aDb[i]; if( pDb->pSchema ){ sqlite4SchemaClear(pDb->pSchema); } } db->flags &= ~SQLITE_InternChanges; sqlite4VtabUnlockList(db); /* If one or more of the auxiliary database files has been closed, ** then remove them from the auxiliary database list. We take the ** opportunity to do this here since we have just deleted all of the ** schema hash tables and therefore do not have to make any changes ** to any of those tables. */ for(i=j=2; i<db->nDb; i++){ struct Db *pDb = &db->aDb[i]; if( pDb->pKV==0 ){ sqlite4DbFree(db, pDb->zName); pDb->zName = 0; continue; } if( j<i ){ db->aDb[j] = db->aDb[i]; } |
︙ | ︙ | |||
517 518 519 520 521 522 523 | pNext = pIndex->pNext; assert( pIndex->pSchema==pTable->pSchema ); if( !db || db->pnBytesFreed==0 ){ char *zName = pIndex->zName; TESTONLY ( Index *pOld = ) sqlite4HashInsert( &pIndex->pSchema->idxHash, zName, sqlite4Strlen30(zName), 0 ); | < | 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | pNext = pIndex->pNext; assert( pIndex->pSchema==pTable->pSchema ); if( !db || db->pnBytesFreed==0 ){ char *zName = pIndex->zName; TESTONLY ( Index *pOld = ) sqlite4HashInsert( &pIndex->pSchema->idxHash, zName, sqlite4Strlen30(zName), 0 ); assert( pOld==pIndex || pOld==0 ); } freeIndex(db, pIndex); } /* Delete any foreign keys attached to this table. */ sqlite4FkDelete(db, pTable); |
︙ | ︙ | |||
552 553 554 555 556 557 558 | void sqlite4UnlinkAndDeleteTable(sqlite4 *db, int iDb, const char *zTabName){ Table *p; Db *pDb; assert( db!=0 ); assert( iDb>=0 && iDb<db->nDb ); assert( zTabName ); | < | 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | void sqlite4UnlinkAndDeleteTable(sqlite4 *db, int iDb, const char *zTabName){ Table *p; Db *pDb; assert( db!=0 ); assert( iDb>=0 && iDb<db->nDb ); assert( zTabName ); testcase( zTabName[0]==0 ); /* Zero-length table names are allowed */ pDb = &db->aDb[iDb]; p = sqlite4HashInsert(&pDb->pSchema->tblHash, zTabName, sqlite4Strlen30(zTabName),0); sqlite4DeleteTable(db, p); db->flags |= SQLITE_InternChanges; } |
︙ | ︙ | |||
840 841 842 843 844 845 846 | /* If this is the magic sqlite_sequence table used by autoincrement, ** then record a pointer to this table in the main database structure ** so that INSERT can find the table easily. */ #ifndef SQLITE_OMIT_AUTOINCREMENT if( !pParse->nested && strcmp(zName, "sqlite_sequence")==0 ){ | < < < < < < < < < < < < < < < < < < < > > > | 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 | /* If this is the magic sqlite_sequence table used by autoincrement, ** then record a pointer to this table in the main database structure ** so that INSERT can find the table easily. */ #ifndef SQLITE_OMIT_AUTOINCREMENT if( !pParse->nested && strcmp(zName, "sqlite_sequence")==0 ){ pTable->pSchema->pSeqTab = pTable; } #endif /* Begin generating the code that will insert the table record into ** the SQLITE_MASTER table. Note in particular that we must go ahead ** and allocate the record number for the table entry now. Before any ** PRIMARY KEY or UNIQUE keywords are parsed. Those keywords will cause ** indices to be created and the table record must come before the ** indices. Hence, the record number for the table must be allocated ** now. */ if( !db->init.busy && (v = sqlite4GetVdbe(pParse))!=0 ){ int reg1, reg2, reg3; sqlite4BeginWriteOperation(pParse, 0, iDb); #ifndef SQLITE_OMIT_VIRTUALTABLE if( isVirtual ){ sqlite4VdbeAddOp0(v, OP_VBegin); } #endif /* This just creates a place-holder record in the sqlite_master table. ** The record created does not contain anything yet. It will be replaced ** by the real entry in code generated at sqlite4EndTable(). ** ** The rowid for the new entry is left in register pParse->regRowid. ** The root page number of the new table is left in reg pParse->regRoot. ** The rowid and root page number values are needed by the code that ** sqlite4EndTable will generate. */ reg1 = pParse->regRowid = ++pParse->nMem; reg2 = pParse->regRoot = ++pParse->nMem; reg3 = ++pParse->nMem; #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) if( isView || isVirtual ){ sqlite4VdbeAddOp2(v, OP_Integer, 0, reg2); }else #endif { sqlite4VdbeAddOp2(v, OP_CreateTable, iDb, reg2); |
︙ | ︙ | |||
1301 1302 1303 1304 1305 1306 1307 | ** and the probability of hitting the same cookie value is only ** 1 chance in 2^32. So we're safe enough. */ void sqlite4ChangeCookie(Parse *pParse, int iDb){ int r1 = sqlite4GetTempReg(pParse); sqlite4 *db = pParse->db; Vdbe *v = pParse->pVdbe; | < | | 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 | ** and the probability of hitting the same cookie value is only ** 1 chance in 2^32. So we're safe enough. */ void sqlite4ChangeCookie(Parse *pParse, int iDb){ int r1 = sqlite4GetTempReg(pParse); sqlite4 *db = pParse->db; Vdbe *v = pParse->pVdbe; sqlite4VdbeAddOp2(v, OP_Integer, db->aDb[iDb].pSchema->schema_cookie+1, r1); sqlite4VdbeAddOp3(v, OP_SetCookie, iDb, 0, r1); sqlite4ReleaseTempReg(pParse, r1); } /* ** Measure the number of characters needed to output the given ** identifier. The number returned includes any quotes used ** but does not include the null terminator. |
︙ | ︙ | |||
1604 1605 1606 1607 1608 1609 1610 | #ifndef SQLITE_OMIT_AUTOINCREMENT /* Check to see if we need to create an sqlite_sequence table for ** keeping track of autoincrement keys. */ if( p->tabFlags & TF_Autoincrement ){ Db *pDb = &db->aDb[iDb]; | < < | 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 | #ifndef SQLITE_OMIT_AUTOINCREMENT /* Check to see if we need to create an sqlite_sequence table for ** keeping track of autoincrement keys. */ if( p->tabFlags & TF_Autoincrement ){ Db *pDb = &db->aDb[iDb]; if( pDb->pSchema->pSeqTab==0 ){ sqlite4NestedParse(pParse, "CREATE TABLE %Q.sqlite_sequence(name,seq)", pDb->zName ); } } #endif /* Reparse everything to update our internal data structures */ sqlite4VdbeAddParseSchemaOp(v, iDb, sqlite4MPrintf(db, "tbl_name='%q'", p->zName)); } /* Add the table to the in-memory representation of the database. */ if( db->init.busy ){ Table *pOld; Schema *pSchema = p->pSchema; pOld = sqlite4HashInsert(&pSchema->tblHash, p->zName, sqlite4Strlen30(p->zName),p); if( pOld ){ assert( p==pOld ); /* Malloc must have failed inside HashInsert() */ db->mallocFailed = 1; return; } |
︙ | ︙ | |||
1810 1811 1812 1813 1814 1815 1816 | if( pSelTab ){ assert( pTable->aCol==0 ); pTable->nCol = pSelTab->nCol; pTable->aCol = pSelTab->aCol; pSelTab->nCol = 0; pSelTab->aCol = 0; sqlite4DeleteTable(db, pSelTab); | < < | 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 | if( pSelTab ){ assert( pTable->aCol==0 ); pTable->nCol = pSelTab->nCol; pTable->aCol = pSelTab->aCol; pSelTab->nCol = 0; pSelTab->aCol = 0; sqlite4DeleteTable(db, pSelTab); pTable->pSchema->flags |= DB_UnresetViews; }else{ pTable->nCol = 0; nErr++; } sqlite4SelectDelete(db, pSel); } else { nErr++; } #endif /* SQLITE_OMIT_VIEW */ return nErr; } #endif /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */ #ifndef SQLITE_OMIT_VIEW /* ** Clear the column names from every VIEW in database idx. */ static void sqliteViewResetAll(sqlite4 *db, int idx){ HashElem *i; if( !DbHasProperty(db, idx, DB_UnresetViews) ) return; for(i=sqliteHashFirst(&db->aDb[idx].pSchema->tblHash); i;i=sqliteHashNext(i)){ Table *pTab = sqliteHashData(i); if( pTab->pSelect ){ sqliteDeleteColumnNames(db, pTab); pTab->aCol = 0; pTab->nCol = 0; |
︙ | ︙ | |||
2178 2179 2180 2181 2182 2183 2184 | z += n+1; } } pFKey->isDeferred = 0; pFKey->aAction[0] = (u8)(flags & 0xff); /* ON DELETE action */ pFKey->aAction[1] = (u8)((flags >> 8 ) & 0xff); /* ON UPDATE action */ | < | 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 | z += n+1; } } pFKey->isDeferred = 0; pFKey->aAction[0] = (u8)(flags & 0xff); /* ON DELETE action */ pFKey->aAction[1] = (u8)((flags >> 8 ) & 0xff); /* ON UPDATE action */ pNextTo = (FKey *)sqlite4HashInsert(&p->pSchema->fkeyHash, pFKey->zTo, sqlite4Strlen30(pFKey->zTo), (void *)pFKey ); if( pNextTo==pFKey ){ db->mallocFailed = 1; goto fk_end; } |
︙ | ︙ | |||
2234 2235 2236 2237 2238 2239 2240 | ** created. The register specified by memRootPage contains the ** root page number of the index. If memRootPage is negative, then ** the index already exists and must be cleared before being refilled and ** the root page number of the index is taken from pIndex->tnum. */ static void sqlite4RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){ Table *pTab = pIndex->pTable; /* The table that is indexed */ | | | | 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 | ** created. The register specified by memRootPage contains the ** root page number of the index. If memRootPage is negative, then ** the index already exists and must be cleared before being refilled and ** the root page number of the index is taken from pIndex->tnum. */ static void sqlite4RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){ Table *pTab = pIndex->pTable; /* The table that is indexed */ int iTab = pParse->nTab++; /* Cursor used for pTab */ int iIdx = pParse->nTab++; /* Cursor used for pIndex */ int iSorter; /* Cursor opened by OpenSorter (if in use) */ int addr1; /* Address of top of loop */ int addr2; /* Address to jump to for next iteration */ int tnum; /* Root page of index */ Vdbe *v; /* Generate code into this virtual machine */ KeyInfo *pKey; /* KeyInfo for index */ #ifdef SQLITE_OMIT_MERGE_SORT |
︙ | ︙ | |||
2585 2586 2587 2588 2589 2590 2591 | zExtra = (char *)(&pIndex->zName[nName+1]); memcpy(pIndex->zName, zName, nName+1); pIndex->pTable = pTab; pIndex->nColumn = pList->nExpr; pIndex->onError = (u8)onError; pIndex->autoIndex = (u8)(pName==0); pIndex->pSchema = db->aDb[iDb].pSchema; | < | 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 | zExtra = (char *)(&pIndex->zName[nName+1]); memcpy(pIndex->zName, zName, nName+1); pIndex->pTable = pTab; pIndex->nColumn = pList->nExpr; pIndex->onError = (u8)onError; pIndex->autoIndex = (u8)(pName==0); pIndex->pSchema = db->aDb[iDb].pSchema; /* Check to see if we should honor DESC requests on index columns */ if( pDb->pSchema->file_format>=4 ){ sortOrderMask = -1; /* Honor DESC */ }else{ sortOrderMask = 0; /* Ignore DESC */ |
︙ | ︙ | |||
2715 2716 2717 2718 2719 2720 2721 | } /* Link the new Index structure to its table and to the other ** in-memory database structures. */ if( db->init.busy ){ Index *p; | < | 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 | } /* Link the new Index structure to its table and to the other ** in-memory database structures. */ if( db->init.busy ){ Index *p; p = sqlite4HashInsert(&pIndex->pSchema->idxHash, pIndex->zName, sqlite4Strlen30(pIndex->zName), pIndex); if( p ){ assert( p==pIndex ); /* Malloc must have failed */ db->mallocFailed = 1; goto exit_create_index; |
︙ | ︙ | |||
3320 3321 3322 3323 3324 3325 3326 | sqlite4 *db; Vdbe *v; int i; assert( pParse!=0 ); db = pParse->db; assert( db!=0 ); | < | | 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 | sqlite4 *db; Vdbe *v; int i; assert( pParse!=0 ); db = pParse->db; assert( db!=0 ); if( sqlite4AuthCheck(pParse, SQLITE_TRANSACTION, "BEGIN", 0, 0) ){ return; } v = sqlite4GetVdbe(pParse); if( !v ) return; if( type!=TK_DEFERRED ){ for(i=0; i<db->nDb; i++){ sqlite4VdbeAddOp2(v, OP_Transaction, i, (type==TK_EXCLUSIVE)+1); sqlite4VdbeUsesStorage(v, i); } } sqlite4VdbeAddOp2(v, OP_AutoCommit, 0, 0); } /* ** Commit a transaction |
︙ | ︙ | |||
3395 3396 3397 3398 3399 3400 3401 | /* ** Make sure the TEMP database is open and available for use. Return ** the number of errors. Leave any error messages in the pParse structure. */ int sqlite4OpenTempDatabase(Parse *pParse){ sqlite4 *db = pParse->db; | | | > | > < < < < < < | 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 | /* ** Make sure the TEMP database is open and available for use. Return ** the number of errors. Leave any error messages in the pParse structure. */ int sqlite4OpenTempDatabase(Parse *pParse){ sqlite4 *db = pParse->db; if( db->aDb[1].pKV==0 && !pParse->explain ){ int rc; #if 0 static const int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_TEMP_DB; #endif rc = sqlite4KVStoreOpen(db, "temp", ":memory:", &db->aDb[1].pKV, SQLITE_KVOPEN_TEMPORARY); if( rc!=SQLITE_OK ){ sqlite4ErrorMsg(pParse, "unable to open a temporary database " "file for storing temporary tables"); pParse->rc = rc; return 1; } assert( db->aDb[1].pSchema ); } return 0; } /* ** Generate VDBE code that will verify the schema cookie and start ** a read-transaction for all named database files. |
︙ | ︙ | |||
3458 3459 3460 3461 3462 3463 3464 | pToplevel->cookieGoto = sqlite4VdbeAddOp2(v, OP_Goto, 0, 0)+1; } if( iDb>=0 ){ sqlite4 *db = pToplevel->db; yDbMask mask; assert( iDb<db->nDb ); | | < | | 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 | pToplevel->cookieGoto = sqlite4VdbeAddOp2(v, OP_Goto, 0, 0)+1; } if( iDb>=0 ){ sqlite4 *db = pToplevel->db; yDbMask mask; assert( iDb<db->nDb ); assert( db->aDb[iDb].pKV!=0 || iDb==1 ); assert( iDb<SQLITE_MAX_ATTACHED+2 ); mask = ((yDbMask)1)<<iDb; if( (pToplevel->cookieMask & mask)==0 ){ pToplevel->cookieMask |= mask; pToplevel->cookieValue[iDb] = db->aDb[iDb].pSchema->schema_cookie; if( !OMIT_TEMPDB && iDb==1 ){ sqlite4OpenTempDatabase(pToplevel); } } } } /* ** If argument zDb is NULL, then call sqlite4CodeVerifySchema() for each ** attached database. Otherwise, invoke it for the database named zDb only. */ void sqlite4CodeVerifyNamedSchema(Parse *pParse, const char *zDb){ sqlite4 *db = pParse->db; int i; for(i=0; i<db->nDb; i++){ Db *pDb = &db->aDb[i]; if( pDb->pKV && (!zDb || 0==sqlite4StrICmp(zDb, pDb->zName)) ){ sqlite4CodeVerifySchema(pParse, i); } } } /* ** Generate VDBE code that prepares for doing an operation that |
︙ | ︙ | |||
3603 3604 3605 3606 3607 3608 3609 | static void reindexDatabases(Parse *pParse, char const *zColl){ Db *pDb; /* A single database */ int iDb; /* The database index number */ sqlite4 *db = pParse->db; /* The database connection */ HashElem *k; /* For looping over tables in pDb */ Table *pTab; /* A table in the database */ | < | 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 | static void reindexDatabases(Parse *pParse, char const *zColl){ Db *pDb; /* A single database */ int iDb; /* The database index number */ sqlite4 *db = pParse->db; /* The database connection */ HashElem *k; /* For looping over tables in pDb */ Table *pTab; /* A table in the database */ for(iDb=0, pDb=db->aDb; iDb<db->nDb; iDb++, pDb++){ assert( pDb!=0 ); for(k=sqliteHashFirst(&pDb->pSchema->tblHash); k; k=sqliteHashNext(k)){ pTab = (Table*)sqliteHashData(k); reindexTable(pParse, pTab, zColl); } } |
︙ | ︙ |
Changes to src/callback.c.
︙ | ︙ | |||
401 402 403 404 405 406 407 | ** Free all resources held by the schema structure. The void* argument points ** at a Schema struct. This function does not call sqlite4DbFree(db, ) on the ** pointer itself, it just cleans up subsidiary resources (i.e. the contents ** of the schema hash tables). ** ** The Schema.cache_size variable is not cleared. */ | | < | 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | ** Free all resources held by the schema structure. The void* argument points ** at a Schema struct. This function does not call sqlite4DbFree(db, ) on the ** pointer itself, it just cleans up subsidiary resources (i.e. the contents ** of the schema hash tables). ** ** The Schema.cache_size variable is not cleared. */ void sqlite4SchemaClear(Schema *pSchema){ Hash temp1; Hash temp2; HashElem *pElem; temp1 = pSchema->tblHash; temp2 = pSchema->trigHash; sqlite4HashInit(&pSchema->trigHash); sqlite4HashClear(&pSchema->idxHash); for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){ sqlite4DeleteTrigger(0, (Trigger*)sqliteHashData(pElem)); |
︙ | ︙ | |||
433 434 435 436 437 438 439 | } } /* ** Find and return the schema associated with a BTree. Create ** a new one if necessary. */ | | < < < | < | 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | } } /* ** Find and return the schema associated with a BTree. Create ** a new one if necessary. */ Schema *sqlite4SchemaGet(sqlite4 *db){ Schema * p; p = (Schema *)sqlite4DbMallocZero(0, sizeof(Schema)); if( !p ){ db->mallocFailed = 1; }else if ( 0==p->file_format ){ sqlite4HashInit(&p->tblHash); sqlite4HashInit(&p->idxHash); sqlite4HashInit(&p->trigHash); sqlite4HashInit(&p->fkeyHash); p->enc = SQLITE_UTF8; } return p; } |
Changes to src/ctime.c.
︙ | ︙ | |||
235 236 237 238 239 240 241 | #endif #ifdef SQLITE_OMIT_FOREIGN_KEY "OMIT_FOREIGN_KEY", #endif #ifdef SQLITE_OMIT_GET_TABLE "OMIT_GET_TABLE", #endif | < < < | 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | #endif #ifdef SQLITE_OMIT_FOREIGN_KEY "OMIT_FOREIGN_KEY", #endif #ifdef SQLITE_OMIT_GET_TABLE "OMIT_GET_TABLE", #endif #ifdef SQLITE_OMIT_INTEGRITY_CHECK "OMIT_INTEGRITY_CHECK", #endif #ifdef SQLITE_OMIT_LIKE_OPTIMIZATION "OMIT_LIKE_OPTIMIZATION", #endif #ifdef SQLITE_OMIT_LOAD_EXTENSION |
︙ | ︙ |
Changes to src/expr.c.
︙ | ︙ | |||
1648 1649 1650 1651 1652 1653 1654 | ** SELECT... statement are columns, then numeric affinity is used ** if either column has NUMERIC or INTEGER affinity. If neither ** 'x' nor the SELECT... statement are columns, then numeric affinity ** is used. */ pExpr->iTable = pParse->nTab++; addr = sqlite4VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid); | < | 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 | ** SELECT... statement are columns, then numeric affinity is used ** if either column has NUMERIC or INTEGER affinity. If neither ** 'x' nor the SELECT... statement are columns, then numeric affinity ** is used. */ pExpr->iTable = pParse->nTab++; addr = sqlite4VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid); memset(&keyInfo, 0, sizeof(keyInfo)); keyInfo.nField = 1; if( ExprHasProperty(pExpr, EP_xIsSelect) ){ /* Case 1: expr IN (SELECT ...) ** ** Generate code to write the results of the select into the temporary |
︙ | ︙ |
Changes to src/fkey.c.
︙ | ︙ | |||
1180 1181 1182 1183 1184 1185 1186 | ** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash ** hash table. */ void sqlite4FkDelete(sqlite4 *db, Table *pTab){ FKey *pFKey; /* Iterator variable */ FKey *pNext; /* Copy of pFKey->pNextFrom */ | < | 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 | ** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash ** hash table. */ void sqlite4FkDelete(sqlite4 *db, Table *pTab){ FKey *pFKey; /* Iterator variable */ FKey *pNext; /* Copy of pFKey->pNextFrom */ for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){ /* Remove the FK from the fkeyHash hash table. */ if( !db || db->pnBytesFreed==0 ){ if( pFKey->pPrevTo ){ pFKey->pPrevTo->pNextTo = pFKey->pNextTo; }else{ |
︙ | ︙ |
Changes to src/func.c.
︙ | ︙ | |||
1190 1191 1192 1193 1194 1195 1196 | /* IMP: R-64894-50321 The string "?000" is returned if the argument ** is NULL or contains no ASCII alphabetic characters. */ sqlite4_result_text(context, "?000", 4, SQLITE_STATIC); } } #endif /* SQLITE_SOUNDEX */ | | | 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 | /* IMP: R-64894-50321 The string "?000" is returned if the argument ** is NULL or contains no ASCII alphabetic characters. */ sqlite4_result_text(context, "?000", 4, SQLITE_STATIC); } } #endif /* SQLITE_SOUNDEX */ #if 0 /*ndef SQLITE_OMIT_LOAD_EXTENSION*/ /* ** A function that loads a shared-library extension then returns NULL. */ static void loadExt(sqlite4_context *context, int argc, sqlite4_value **argv){ const char *zFile = (const char *)sqlite4_value_text(argv[0]); const char *zProc; sqlite4 *db = sqlite4_context_db_handle(context); |
︙ | ︙ | |||
1564 1565 1566 1567 1568 1569 1570 | FUNCTION(changes, 0, 0, 0, changes ), FUNCTION(total_changes, 0, 0, 0, total_changes ), FUNCTION(replace, 3, 0, 0, replaceFunc ), FUNCTION(zeroblob, 1, 0, 0, zeroblobFunc ), #ifdef SQLITE_SOUNDEX FUNCTION(soundex, 1, 0, 0, soundexFunc ), #endif | | | 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 | FUNCTION(changes, 0, 0, 0, changes ), FUNCTION(total_changes, 0, 0, 0, total_changes ), FUNCTION(replace, 3, 0, 0, replaceFunc ), FUNCTION(zeroblob, 1, 0, 0, zeroblobFunc ), #ifdef SQLITE_SOUNDEX FUNCTION(soundex, 1, 0, 0, soundexFunc ), #endif #if 0 /*ndef SQLITE_OMIT_LOAD_EXTENSION*/ FUNCTION(load_extension, 1, 0, 0, loadExt ), FUNCTION(load_extension, 2, 0, 0, loadExt ), #endif AGGREGATE(sum, 1, 0, 0, sumStep, sumFinalize ), AGGREGATE(total, 1, 0, 0, sumStep, totalFinalize ), AGGREGATE(avg, 1, 0, 0, sumStep, avgFinalize ), /* AGGREGATE(count, 0, 0, 0, countStep, countFinalize ), */ |
︙ | ︙ |
Changes to src/insert.c.
︙ | ︙ | |||
233 234 235 236 237 238 239 | assert( pParse->pTriggerTab==0 ); assert( pParse==sqlite4ParseToplevel(pParse) ); assert( v ); /* We failed long ago if this is not so */ for(p = pParse->pAinc; p; p = p->pNext){ pDb = &db->aDb[p->iDb]; memId = p->regCtr; | < | 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | assert( pParse->pTriggerTab==0 ); assert( pParse==sqlite4ParseToplevel(pParse) ); assert( v ); /* We failed long ago if this is not so */ for(p = pParse->pAinc; p; p = p->pNext){ pDb = &db->aDb[p->iDb]; memId = p->regCtr; sqlite4OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenRead); sqlite4VdbeAddOp3(v, OP_Null, 0, memId, memId+1); addr = sqlite4VdbeCurrentAddr(v); sqlite4VdbeAddOp4(v, OP_String8, 0, memId-1, 0, p->pTab->zName, 0); sqlite4VdbeAddOp2(v, OP_Rewind, 0, addr+9); sqlite4VdbeAddOp3(v, OP_Column, 0, 0, memId); sqlite4VdbeAddOp3(v, OP_Ne, memId-1, addr+7, memId); |
︙ | ︙ | |||
285 286 287 288 289 290 291 | for(p = pParse->pAinc; p; p = p->pNext){ Db *pDb = &db->aDb[p->iDb]; int j1, j2, j3, j4, j5; int iRec; int memId = p->regCtr; iRec = sqlite4GetTempReg(pParse); | < | 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | for(p = pParse->pAinc; p; p = p->pNext){ Db *pDb = &db->aDb[p->iDb]; int j1, j2, j3, j4, j5; int iRec; int memId = p->regCtr; iRec = sqlite4GetTempReg(pParse); sqlite4OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenWrite); j1 = sqlite4VdbeAddOp1(v, OP_NotNull, memId+1); j2 = sqlite4VdbeAddOp0(v, OP_Rewind); j3 = sqlite4VdbeAddOp3(v, OP_Column, 0, 0, iRec); j4 = sqlite4VdbeAddOp3(v, OP_Eq, memId-1, 0, iRec); sqlite4VdbeAddOp2(v, OP_Next, 0, j3); sqlite4VdbeJumpHere(v, j2); |
︙ | ︙ |
Deleted src/journal.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/kvmem.c.
︙ | ︙ | |||
62 63 64 65 66 67 68 | /* ** A complete in-memory Key/Value tree together with its ** transaction logs is an instance of the following object. */ struct KVMem { KVStore base; /* Base class, must be first */ KVMemNode *pRoot; /* Root of the tree of content */ | | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | /* ** A complete in-memory Key/Value tree together with its ** transaction logs is an instance of the following object. */ struct KVMem { KVStore base; /* Base class, must be first */ KVMemNode *pRoot; /* Root of the tree of content */ unsigned openFlags; /* Flags used at open */ KVMemChng **apLog; /* Array of transaction logs */ int nCursor; /* Number of outstanding cursors */ int iMagicKVMemBase; /* Magic number of sanity */ }; #define SQLITE_KVMEMBASE_MAGIC 0xbfcd47d0 /* |
︙ | ︙ | |||
298 299 300 301 302 303 304 | } /* ** Create a new change record */ static KVMemChng *kvmemNewChng(KVMem *p, KVMemNode *pNode){ KVMemChng *pChng; | | | | | | | | 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | } /* ** Create a new change record */ static KVMemChng *kvmemNewChng(KVMem *p, KVMemNode *pNode){ KVMemChng *pChng; assert( p->base.iTransLevel>=2 ); pChng = sqlite4_malloc( sizeof(*pChng) ); if( pChng ){ pChng->pNext = p->apLog[p->base.iTransLevel-2]; p->apLog[p->base.iTransLevel-2] = pChng; pChng->pNode = pNode; pChng->oldTrans = pNode->mxTrans; pNode->mxTrans = p->base.iTransLevel; pChng->pData = pNode->pData; pNode->pData = 0; } return pChng; } /* Create a new node. */ static KVMemNode *kvmemNewNode( KVMem *p, const KVByteArray *aKey, KVSize nKey ){ KVMemNode *pNode; KVMemChng *pChng; assert( p->base.iTransLevel>=2 ); pNode = sqlite4_malloc( sizeof(*pNode)+nKey-2 ); if( pNode ){ memset(pNode, 0, sizeof(*pNode)); memcpy(pNode->aKey, aKey, nKey); pNode->nKey = nKey; pNode->nRef = 1; pChng = kvmemNewChng(p, pNode); if( pChng==0 ){ sqlite4_free(pNode); pNode = 0; |
︙ | ︙ | |||
401 402 403 404 405 406 407 | ** the transaction level will be equal to iLevel. The transaction level ** must be at least 1 to read and at least 2 to write. */ static int kvmemBegin(KVStore *pKVStore, int iLevel){ KVMem *p = (KVMem*)pKVStore; assert( p->iMagicKVMemBase==SQLITE_KVMEMBASE_MAGIC ); assert( iLevel>0 ); | | | > > > > | > > > | | | | | | | | | | | | > > > > > > > > > > | 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 | ** the transaction level will be equal to iLevel. The transaction level ** must be at least 1 to read and at least 2 to write. */ static int kvmemBegin(KVStore *pKVStore, int iLevel){ KVMem *p = (KVMem*)pKVStore; assert( p->iMagicKVMemBase==SQLITE_KVMEMBASE_MAGIC ); assert( iLevel>0 ); assert( iLevel==2 || iLevel==p->base.iTransLevel+1 ); if( iLevel>=2 ){ KVMemChng **apNewLog; apNewLog = sqlite4_realloc(p->apLog, sizeof(apNewLog[0])*(iLevel-1) ); if( apNewLog==0 ) return SQLITE_NOMEM; p->apLog = apNewLog; p->apLog[iLevel-2] = 0; } p->base.iTransLevel = iLevel; return SQLITE_OK; } /* ** Commit a transaction or subtransaction. ** ** Make permanent all changes back through the most recent xBegin ** with the iLevel+1. If iLevel==0 then make all changes permanent. ** The argument iLevel will always be less than the current transaction ** level when this routine is called. ** ** Commit is divided into two phases. A rollback is still possible after ** phase one completes. In this implementation, phase one is a no-op since ** phase two cannot fail. ** ** After this routine returns successfully, the transaction level will be ** equal to iLevel. */ static int kvmemCommitPhaseOne(KVStore *pKVStore, int iLevel){ return SQLITE_OK; } static int kvmemCommitPhaseTwo(KVStore *pKVStore, int iLevel){ KVMem *p = (KVMem*)pKVStore; assert( p->iMagicKVMemBase==SQLITE_KVMEMBASE_MAGIC ); assert( iLevel>=0 ); assert( iLevel<p->base.iTransLevel ); while( p->base.iTransLevel>iLevel && p->base.iTransLevel>1 ){ KVMemChng *pChng, *pNext; for(pChng=p->apLog[p->base.iTransLevel-2]; pChng; pChng=pNext){ KVMemNode *pNode = pChng->pNode; if( pNode->pData ){ pNode->mxTrans = pChng->oldTrans; }else{ kvmemRemoveNode(p, pNode); } kvmemDataUnref(pChng->pData); pNext = pChng->pNext; sqlite4_free(pChng); } p->apLog[p->base.iTransLevel-2] = 0; p->base.iTransLevel--; } p->base.iTransLevel = iLevel; return SQLITE_OK; } /* ** Rollback a transaction or subtransaction. ** ** Revert all uncommitted changes back through the most recent xBegin or ** xCommit with the same iLevel. If iLevel==0 then back out all uncommited ** changes. ** ** After this routine returns successfully, the transaction level will be ** equal to iLevel. */ static int kvmemRollback(KVStore *pKVStore, int iLevel){ KVMem *p = (KVMem*)pKVStore; assert( p->iMagicKVMemBase==SQLITE_KVMEMBASE_MAGIC ); assert( iLevel>=0 ); assert( iLevel<p->base.iTransLevel ); while( p->base.iTransLevel>iLevel && p->base.iTransLevel>1 ){ KVMemChng *pChng, *pNext; for(pChng=p->apLog[p->base.iTransLevel-2]; pChng; pChng=pNext){ KVMemNode *pNode = pChng->pNode; if( pChng->pData ){ kvmemDataUnref(pNode->pData); pNode->pData = pChng->pData; pNode->mxTrans = pChng->oldTrans; }else{ kvmemRemoveNode(p, pNode); } pNext = pChng->pNext; sqlite4_free(pChng); } p->apLog[p->base.iTransLevel-2] = 0; p->base.iTransLevel--; } p->base.iTransLevel = iLevel; return SQLITE_OK; } /* ** Revert a transaction back to what it was when it started. */ static int kvmemRevert(KVStore *pKVStore, int iLevel){ int rc = kvmemRollback(pKVStore, iLevel-1); if( rc==SQLITE_OK ){ rc = kvmemBegin(pKVStore, iLevel); } return rc; } /* ** Implementation of the xReplace(X, aKey, nKey, aData, nData) method. ** ** Insert or replace the entry with the key aKey[0..nKey-1]. The data for ** the new entry is aData[0..nData-1]. Return SQLITE_OK on success or an ** error code if the insert fails. |
︙ | ︙ | |||
509 510 511 512 513 514 515 | const KVByteArray *aData, KVSize nData ){ KVMem *p = (KVMem*)pKVStore; KVMemNode *pNew, *pNode; KVMemData *pData; KVMemChng *pChng; assert( p->iMagicKVMemBase==SQLITE_KVMEMBASE_MAGIC ); | | | 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | const KVByteArray *aData, KVSize nData ){ KVMem *p = (KVMem*)pKVStore; KVMemNode *pNew, *pNode; KVMemData *pData; KVMemChng *pChng; assert( p->iMagicKVMemBase==SQLITE_KVMEMBASE_MAGIC ); assert( p->base.iTransLevel>=2 ); pData = kvmemDataNew(aData, nData); if( pData==0 ) return SQLITE_NOMEM; if( p->pRoot==0 ){ pNode = pNew = kvmemNewNode(p, aKey, nKey); if( pNew==0 ) goto KVMemReplace_nomem; pNew->pUp = 0; }else{ |
︙ | ︙ | |||
539 540 541 542 543 544 545 | }else{ pNode->pAfter = pNew = kvmemNewNode(p, aKey, nKey); if( pNew==0 ) goto KVMemReplace_nomem; pNew->pUp = pNode; break; } }else{ | | | 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 | }else{ pNode->pAfter = pNew = kvmemNewNode(p, aKey, nKey); if( pNew==0 ) goto KVMemReplace_nomem; pNew->pUp = pNode; break; } }else{ if( pNode->mxTrans==p->base.iTransLevel ){ kvmemDataUnref(pNode->pData); }else{ pChng = kvmemNewChng(p, pNode); if( pChng==0 ) goto KVMemReplace_nomem; } pNode->pData = pData; return SQLITE_OK; |
︙ | ︙ | |||
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | KVCursor *pKVCursor, const KVByteArray *aKey, KVSize nKey, int direction ){ KVMemCursor *pCur; KVMemNode *pNode; int c; kvmemReset(pKVCursor); pCur = (KVMemCursor*)pKVCursor; assert( pCur->iMagicKVMemCur==SQLITE_KVMEMCUR_MAGIC ); pNode = pCur->pOwner->pRoot; while( pNode ){ c = kvmemKeyCompare(aKey, nKey, pNode->aKey, pNode->nKey); | > > | > > > > | > > > | > > > > > > > > > > | | | < | | > | | | | 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 | KVCursor *pKVCursor, const KVByteArray *aKey, KVSize nKey, int direction ){ KVMemCursor *pCur; KVMemNode *pNode; KVMemNode *pBest = 0; int c; int rc = SQLITE_NOTFOUND; kvmemReset(pKVCursor); pCur = (KVMemCursor*)pKVCursor; assert( pCur->iMagicKVMemCur==SQLITE_KVMEMCUR_MAGIC ); pNode = pCur->pOwner->pRoot; while( pNode ){ c = kvmemKeyCompare(aKey, nKey, pNode->aKey, pNode->nKey); if( c==0 ){ pBest = pNode; rc = SQLITE_OK; pNode = 0; }else if( c>0 ){ if( direction<0 ){ pBest = pNode; rc = SQLITE_INEXACT; } pNode = pNode->pAfter; }else{ if( direction>0 ){ pBest = pNode; rc = SQLITE_INEXACT; } pNode = pNode->pBefore; } } kvmemNodeUnref(pCur->pNode); kvmemDataUnref(pCur->pData); if( pBest ){ pCur->pNode = kvmemNodeRef(pBest); pCur->pData = kvmemDataRef(pBest->pData); }else{ pCur->pNode = 0; pCur->pData = 0; } return rc; } /* ** Delete the entry that the cursor is pointing to. ** ** Though the entry is "deleted", it still continues to exist as a ** phantom. Subsequent xNext or xPrev calls will work, as will ** calls to xKey and xData, thought the result from xKey and xData ** are undefined. */ static int kvmemDelete(KVCursor *pKVCursor){ KVMemCursor *pCur; KVMemNode *pNode; KVMemChng *pChng; KVMem *p; pCur = (KVMemCursor*)pKVCursor; assert( pCur->iMagicKVMemCur==SQLITE_KVMEMCUR_MAGIC ); p = pCur->pOwner; assert( p->iMagicKVMemBase==SQLITE_KVMEMBASE_MAGIC ); assert( p->base.iTransLevel>=2 ); pNode = pCur->pNode; if( pNode==0 ) return SQLITE_OK; if( pNode->pData==0 ) return SQLITE_OK; if( pNode->mxTrans<p->base.iTransLevel ){ pChng = kvmemNewChng(p, pNode); if( pChng==0 ) return SQLITE_NOMEM; }else{ kvmemDataUnref(pNode->pData); pNode->pData = 0; } return SQLITE_OK; |
︙ | ︙ | |||
694 695 696 697 698 699 700 | do{ pNode = kvmemNext(pNode); }while( pNode && pNode->pData==0 ); if( pNode ){ pCur->pNode = kvmemNodeRef(pNode); pCur->pData = kvmemDataRef(pNode->pData); } | | | | 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 | do{ pNode = kvmemNext(pNode); }while( pNode && pNode->pData==0 ); if( pNode ){ pCur->pNode = kvmemNodeRef(pNode); pCur->pData = kvmemDataRef(pNode->pData); } return pNode ? SQLITE_OK : SQLITE_NOTFOUND; } /* ** Move a cursor to the previous non-deleted node. */ static int kvmemPrevEntry(KVCursor *pKVCursor){ KVMemCursor *pCur; KVMemNode *pNode; pCur = (KVMemCursor*)pKVCursor; assert( pCur->iMagicKVMemCur==SQLITE_KVMEMCUR_MAGIC ); pNode = pCur->pNode; kvmemReset(pKVCursor); do{ pNode = kvmemPrev(pNode); }while( pNode && pNode->pData==0 ); if( pNode ){ pCur->pNode = kvmemNodeRef(pNode); pCur->pData = kvmemDataRef(pNode->pData); } return pNode ? SQLITE_OK : SQLITE_NOTFOUND; } /* ** Return the key of the node the cursor is pointing to. */ static int kvmemKey( KVCursor *pKVCursor, /* The cursor whose key is desired */ |
︙ | ︙ | |||
776 777 778 779 780 781 782 | ** Destructor for the entire in-memory storage tree. */ static int kvmemClose(KVStore *pKVStore){ KVMem *p = (KVMem*)pKVStore; if( p==0 ) return SQLITE_OK; assert( p->iMagicKVMemBase==SQLITE_KVMEMBASE_MAGIC ); assert( p->nCursor==0 ); | > | > > | > > | > | 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 | ** Destructor for the entire in-memory storage tree. */ static int kvmemClose(KVStore *pKVStore){ KVMem *p = (KVMem*)pKVStore; if( p==0 ) return SQLITE_OK; assert( p->iMagicKVMemBase==SQLITE_KVMEMBASE_MAGIC ); assert( p->nCursor==0 ); if( p->base.iTransLevel ){ kvmemCommitPhaseOne(pKVStore, 0); kvmemCommitPhaseTwo(pKVStore, 0); } sqlite4_free(p->apLog); kvmemClearTree(p->pRoot); memset(p, 0, sizeof(*p)); sqlite4_free(p); return SQLITE_OK; } /* Virtual methods for the in-memory storage engine */ static const KVStoreMethods kvmemMethods = { kvmemReplace, kvmemOpenCursor, kvmemSeek, kvmemNextEntry, kvmemPrevEntry, kvmemDelete, kvmemKey, kvmemData, kvmemReset, kvmemCloseCursor, kvmemBegin, kvmemCommitPhaseOne, kvmemCommitPhaseTwo, kvmemRollback, kvmemRevert, kvmemClose }; /* ** Create a new in-memory storage engine and return a pointer to it. */ int sqlite4KVStoreOpenMem(KVStore **ppKVStore, unsigned openFlags){ KVMem *pNew = sqlite4_malloc( sizeof(*pNew) ); if( pNew==0 ) return SQLITE_NOMEM; memset(pNew, 0, sizeof(*pNew)); pNew->base.pStoreVfunc = &kvmemMethods; pNew->iMagicKVMemBase = SQLITE_KVMEMBASE_MAGIC; pNew->openFlags = openFlags; *ppKVStore = (KVStore*)pNew; return SQLITE_OK; } |
Changes to src/legacy.c.
︙ | ︙ | |||
66 67 68 69 70 71 72 | nCol = sqlite4_column_count(pStmt); while( 1 ){ int i; rc = sqlite4_step(pStmt); /* Invoke the callback function if required */ | | < < | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | nCol = sqlite4_column_count(pStmt); while( 1 ){ int i; rc = sqlite4_step(pStmt); /* Invoke the callback function if required */ if( xCallback && SQLITE_ROW==rc ){ if( !callbackIsInit ){ azCols = sqlite4DbMallocZero(db, 2*nCol*sizeof(const char*) + 1); if( azCols==0 ){ goto exec_out; } for(i=0; i<nCol; i++){ azCols[i] = (char *)sqlite4_column_name(pStmt, i); |
︙ | ︙ |
Deleted src/loadext.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/main.c.
︙ | ︙ | |||
169 170 171 172 173 174 175 | } /* Do the rest of the initialization under the recursive mutex so ** that we will be able to handle recursive calls into ** sqlite4_initialize(). The recursive calls normally come through ** sqlite4_os_init() when it invokes sqlite4_vfs_register(), but other ** recursive calls might also be possible. | < < < < < < < < < < < < | < < < < < < | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | } /* Do the rest of the initialization under the recursive mutex so ** that we will be able to handle recursive calls into ** sqlite4_initialize(). The recursive calls normally come through ** sqlite4_os_init() when it invokes sqlite4_vfs_register(), but other ** recursive calls might also be possible. */ sqlite4_mutex_enter(sqlite4GlobalConfig.pInitMutex); if( sqlite4GlobalConfig.isInit==0 && sqlite4GlobalConfig.inProgress==0 ){ FuncDefHash *pHash = &GLOBAL(FuncDefHash, sqlite4GlobalFunctions); sqlite4GlobalConfig.inProgress = 1; memset(pHash, 0, sizeof(sqlite4GlobalFunctions)); sqlite4RegisterGlobalFunctions(); rc = sqlite4OsInit(); sqlite4GlobalConfig.inProgress = 0; } sqlite4_mutex_leave(sqlite4GlobalConfig.pInitMutex); /* Go back under the static mutex and clean up the recursive ** mutex to prevent a resource leak. */ |
︙ | ︙ | |||
258 259 260 261 262 263 264 | int sqlite4_shutdown(void){ if( sqlite4GlobalConfig.isInit ){ #ifdef SQLITE_EXTRA_SHUTDOWN void SQLITE_EXTRA_SHUTDOWN(void); SQLITE_EXTRA_SHUTDOWN(); #endif sqlite4_os_end(); | | < < < < | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | int sqlite4_shutdown(void){ if( sqlite4GlobalConfig.isInit ){ #ifdef SQLITE_EXTRA_SHUTDOWN void SQLITE_EXTRA_SHUTDOWN(void); SQLITE_EXTRA_SHUTDOWN(); #endif sqlite4_os_end(); /* sqlite4_reset_auto_extension(); */ sqlite4GlobalConfig.isInit = 0; } if( sqlite4GlobalConfig.isMallocInit ){ sqlite4MallocEnd(); sqlite4GlobalConfig.isMallocInit = 0; } if( sqlite4GlobalConfig.isMutexInit ){ sqlite4MutexEnd(); sqlite4GlobalConfig.isMutexInit = 0; |
︙ | ︙ | |||
356 357 358 359 360 361 362 | case SQLITE_CONFIG_SCRATCH: { /* Designate a buffer for scratch memory space */ sqlite4GlobalConfig.pScratch = va_arg(ap, void*); sqlite4GlobalConfig.szScratch = va_arg(ap, int); sqlite4GlobalConfig.nScratch = va_arg(ap, int); break; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | case SQLITE_CONFIG_SCRATCH: { /* Designate a buffer for scratch memory space */ sqlite4GlobalConfig.pScratch = va_arg(ap, void*); sqlite4GlobalConfig.szScratch = va_arg(ap, int); sqlite4GlobalConfig.nScratch = va_arg(ap, int); break; } #if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5) case SQLITE_CONFIG_HEAP: { /* Designate a buffer for heap memory space */ sqlite4GlobalConfig.pHeap = va_arg(ap, void*); sqlite4GlobalConfig.nHeap = va_arg(ap, int); sqlite4GlobalConfig.mnReq = va_arg(ap, int); |
︙ | ︙ | |||
535 536 537 538 539 540 541 | } /* ** Free up as much memory as we can from the given database ** connection. */ int sqlite4_db_release_memory(sqlite4 *db){ | < < < < < < < < < < | 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | } /* ** Free up as much memory as we can from the given database ** connection. */ int sqlite4_db_release_memory(sqlite4 *db){ sqlite4_mutex_enter(db->mutex); sqlite4_mutex_leave(db->mutex); return SQLITE_OK; } /* ** Configuration settings for an individual database connection */ |
︙ | ︙ | |||
752 753 754 755 756 757 758 | sqlite4Error(db, SQLITE_BUSY, "unable to close due to unfinalised statements"); sqlite4_mutex_leave(db->mutex); return SQLITE_BUSY; } assert( sqlite4SafetyCheckSickOrOk(db) ); | < < < < < < < < < < | < < | 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 | sqlite4Error(db, SQLITE_BUSY, "unable to close due to unfinalised statements"); sqlite4_mutex_leave(db->mutex); return SQLITE_BUSY; } assert( sqlite4SafetyCheckSickOrOk(db) ); /* Free any outstanding Savepoint structures. */ sqlite4CloseSavepoints(db); for(j=0; j<db->nDb; j++){ struct Db *pDb = &db->aDb[j]; if( pDb->pKV ){ sqlite4KVStoreClose(pDb->pKV); pDb->pKV = 0; if( j!=1 ){ pDb->pSchema = 0; } } } |
︙ | ︙ | |||
824 825 826 827 828 829 830 | sqlite4HashClear(&db->aModule); #endif sqlite4Error(db, SQLITE_OK, 0); /* Deallocates any cached error strings. */ if( db->pErr ){ sqlite4ValueFree(db->pErr); } | < | | 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | sqlite4HashClear(&db->aModule); #endif sqlite4Error(db, SQLITE_OK, 0); /* Deallocates any cached error strings. */ if( db->pErr ){ sqlite4ValueFree(db->pErr); } db->magic = SQLITE_MAGIC_ERROR; /* The temp-database schema is allocated differently from the other schema ** objects (using sqliteMalloc() directly, instead of sqlite4BTreeSchema()). ** So it needs to be freed here. Todo: Why not roll the temp schema into ** the same sqliteMalloc() as the one that allocates the database ** structure? */ sqlite4DbFree(db, db->aDb[1].pSchema); sqlite4_mutex_leave(db->mutex); db->magic = SQLITE_MAGIC_CLOSED; |
︙ | ︙ | |||
855 856 857 858 859 860 861 | */ void sqlite4RollbackAll(sqlite4 *db){ int i; int inTrans = 0; assert( sqlite4_mutex_held(db->mutex) ); sqlite4BeginBenignMalloc(); for(i=0; i<db->nDb; i++){ | | | | | 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 | */ void sqlite4RollbackAll(sqlite4 *db){ int i; int inTrans = 0; assert( sqlite4_mutex_held(db->mutex) ); sqlite4BeginBenignMalloc(); for(i=0; i<db->nDb; i++){ if( db->aDb[i].pKV ){ if( db->aDb[i].pKV->iTransLevel ){ inTrans = 1; } sqlite4KVStoreRollback(db->aDb[i].pKV, 0); db->aDb[i].inTrans = 0; } } sqlite4VtabRollback(db); sqlite4EndBenignMalloc(); if( db->flags&SQLITE_InternChanges ){ |
︙ | ︙ | |||
1476 1477 1478 1479 1480 1481 1482 | ** to contains a zero-length string, all attached databases are ** checkpointed. */ int sqlite4_wal_checkpoint(sqlite4 *db, const char *zDb){ return sqlite4_wal_checkpoint_v2(db, zDb, SQLITE_CHECKPOINT_PASSIVE, 0, 0); } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 | ** to contains a zero-length string, all attached databases are ** checkpointed. */ int sqlite4_wal_checkpoint(sqlite4 *db, const char *zDb){ return sqlite4_wal_checkpoint_v2(db, zDb, SQLITE_CHECKPOINT_PASSIVE, 0, 0); } /* ** This function returns true if main-memory should be used instead of ** a temporary file for transient pager files and statement journals. ** The value returned depends on the value of db->temp_store (runtime ** parameter) and the compile time value of SQLITE_TEMP_STORE. The ** following table describes the relationship between these two values ** and this functions return value. |
︙ | ︙ | |||
1661 1662 1663 1664 1665 1666 1667 | */ static int createCollation( sqlite4* db, const char *zName, u8 enc, void* pCtx, int(*xCompare)(void*,int,const void*,int,const void*), | | | 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 | */ static int createCollation( sqlite4* db, const char *zName, u8 enc, void* pCtx, int(*xCompare)(void*,int,const void*,int,const void*), int(*xMakeKey)(void*,const void*,int,const void*,int), void(*xDel)(void*) ){ CollSeq *pColl; int enc2; int nName = sqlite4Strlen30(zName); assert( sqlite4_mutex_held(db->mutex) ); |
︙ | ︙ | |||
2075 2076 2077 2078 2079 2080 2081 | sqlite4 **ppDb, /* OUT: Returned database handle */ unsigned int flags, /* Operational flags */ const char *zVfs /* Name of the VFS to use */ ){ sqlite4 *db; /* Store allocated handle here */ int rc; /* Return code */ int isThreadsafe; /* True for threadsafe connections */ | | | 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 | sqlite4 **ppDb, /* OUT: Returned database handle */ unsigned int flags, /* Operational flags */ const char *zVfs /* Name of the VFS to use */ ){ sqlite4 *db; /* Store allocated handle here */ int rc; /* Return code */ int isThreadsafe; /* True for threadsafe connections */ char *zOpen = 0; /* Filename passed to StorageOpen() */ char *zErrMsg = 0; /* Error message from sqlite4ParseUri() */ *ppDb = 0; #ifndef SQLITE_OMIT_AUTOINIT rc = sqlite4_initialize(); if( rc ) return rc; #endif |
︙ | ︙ | |||
2162 2163 2164 2165 2166 2167 2168 | db->aDb = db->aDbStatic; assert( sizeof(db->aLimit)==sizeof(aHardLimit) ); memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit)); db->autoCommit = 1; db->nextAutovac = -1; db->nextPagesize = 0; | | | 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 | db->aDb = db->aDbStatic; assert( sizeof(db->aLimit)==sizeof(aHardLimit) ); memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit)); db->autoCommit = 1; db->nextAutovac = -1; db->nextPagesize = 0; db->flags |= SQLITE_AutoIndex | SQLITE_EnableTrigger #if SQLITE_DEFAULT_FILE_FORMAT<4 | SQLITE_LegacyFileFmt #endif #ifdef SQLITE_ENABLE_LOAD_EXTENSION | SQLITE_LoadExtension #endif #if SQLITE_DEFAULT_RECURSIVE_TRIGGERS |
︙ | ︙ | |||
2209 2210 2211 2212 2213 2214 2215 | if( rc==SQLITE_NOMEM ) db->mallocFailed = 1; sqlite4Error(db, rc, zErrMsg ? "%s" : 0, zErrMsg); sqlite4_free(zErrMsg); goto opendb_out; } /* Open the backend database driver */ | | < | | < < < | | 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 | if( rc==SQLITE_NOMEM ) db->mallocFailed = 1; sqlite4Error(db, rc, zErrMsg ? "%s" : 0, zErrMsg); sqlite4_free(zErrMsg); goto opendb_out; } /* Open the backend database driver */ rc = sqlite4KVStoreOpen(db, "main", zOpen, &db->aDb[0].pKV, 0); if( rc!=SQLITE_OK ){ if( rc==SQLITE_IOERR_NOMEM ){ rc = SQLITE_NOMEM; } sqlite4Error(db, rc, 0); goto opendb_out; } db->aDb[0].pSchema = sqlite4SchemaGet(db); db->aDb[1].pSchema = sqlite4SchemaGet(db); /* The default safety_level for the main database is 'full'; for the temp ** database it is 'NONE'. This matches the pager layer defaults. */ db->aDb[0].zName = "main"; db->aDb[1].zName = "temp"; db->magic = SQLITE_MAGIC_OPEN; if( db->mallocFailed ){ goto opendb_out; } /* Register all built-in functions, but do not attempt to read the ** database schema yet. This is delayed until the first time the database ** is accessed. */ sqlite4Error(db, SQLITE_OK, 0); sqlite4RegisterBuiltinFunctions(db); /* Load automatic extensions - extensions that have been registered ** using the sqlite4_automatic_extension() API. */ rc = sqlite4_errcode(db); if( rc==SQLITE_OK ){ /* sqlite4AutoLoadExtensions(db); */ rc = sqlite4_errcode(db); if( rc!=SQLITE_OK ){ goto opendb_out; } } #ifdef SQLITE_ENABLE_FTS1 |
︙ | ︙ | |||
2288 2289 2290 2291 2292 2293 2294 | if( !db->mallocFailed && rc==SQLITE_OK){ rc = sqlite4RtreeInit(db); } #endif sqlite4Error(db, rc, 0); | < < < < < < < < < < | 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 | if( !db->mallocFailed && rc==SQLITE_OK){ rc = sqlite4RtreeInit(db); } #endif sqlite4Error(db, rc, 0); /* Enable the lookaside-malloc subsystem */ setupLookaside(db, 0, sqlite4GlobalConfig.szLookaside, sqlite4GlobalConfig.nLookaside); sqlite4_wal_autocheckpoint(db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT); opendb_out: |
︙ | ︙ | |||
2492 2493 2494 2495 2496 2497 2498 | sqlite4_log(SQLITE_CANTOPEN, "cannot open file at line %d of [%.10s]", lineno, 20+sqlite4_sourceid()); return SQLITE_CANTOPEN; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 | sqlite4_log(SQLITE_CANTOPEN, "cannot open file at line %d of [%.10s]", lineno, 20+sqlite4_sourceid()); return SQLITE_CANTOPEN; } /* ** Sleep for a little while. Return the amount of time slept. */ int sqlite4_sleep(int ms){ sqlite4_vfs *pVfs; int rc; pVfs = sqlite4_vfs_find(0); |
︙ | ︙ | |||
2643 2644 2645 2646 2647 2648 2649 | int sqlite4_extended_result_codes(sqlite4 *db, int onoff){ sqlite4_mutex_enter(db->mutex); db->errMask = onoff ? 0xffffffff : 0xff; sqlite4_mutex_leave(db->mutex); return SQLITE_OK; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 | int sqlite4_extended_result_codes(sqlite4 *db, int onoff){ sqlite4_mutex_enter(db->mutex); db->errMask = onoff ? 0xffffffff : 0xff; sqlite4_mutex_leave(db->mutex); return SQLITE_OK; } /* ** Interface to the testing logic. */ int sqlite4_test_control(int op, ...){ int rc = 0; #ifndef SQLITE_OMIT_BUILTIN_TEST |
︙ | ︙ | |||
2826 2827 2828 2829 2830 2831 2832 | */ case SQLITE_TESTCTRL_ALWAYS: { int x = va_arg(ap,int); rc = ALWAYS(x); break; } | < < < < < < < < < < < < < < | 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 | */ case SQLITE_TESTCTRL_ALWAYS: { int x = va_arg(ap,int); rc = ALWAYS(x); break; } /* sqlite4_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, sqlite4 *db, int N) ** ** Enable or disable various optimizations for testing purposes. The ** argument N is a bitmask of optimizations to be disabled. For normal ** operation N should be 0. The idea is that a test program (like the ** SQL Logic Test or SLT test module) can run the same SQL multiple times ** with various optimizations disabled to verify that the same answer |
︙ | ︙ | |||
2969 2970 2971 2972 2973 2974 2975 | const char *z = sqlite4_uri_parameter(zFilename, zParam); sqlite4_int64 v; if( z && sqlite4Atoi64(z, &v, sqlite4Strlen30(z), SQLITE_UTF8)==SQLITE_OK ){ bDflt = v; } return bDflt; } | < < < < < < < < < < < < < < | 2658 2659 2660 2661 2662 2663 2664 | const char *z = sqlite4_uri_parameter(zFilename, zParam); sqlite4_int64 v; if( z && sqlite4Atoi64(z, &v, sqlite4Strlen30(z), SQLITE_UTF8)==SQLITE_OK ){ bDflt = v; } return bDflt; } |
Deleted src/memjournal.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/notify.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/os.c.
︙ | ︙ | |||
13 14 15 16 17 18 19 | ** This file contains OS interface code that is common to all ** architectures. */ #define _SQLITE_OS_C_ 1 #include "sqliteInt.h" #undef _SQLITE_OS_C_ | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | ** This file contains OS interface code that is common to all ** architectures. */ #define _SQLITE_OS_C_ 1 #include "sqliteInt.h" #undef _SQLITE_OS_C_ /* ** The following routines are convenience wrappers around methods ** of the sqlite4_file object. This is mostly just syntactic sugar. All ** of this would be completely automatic if SQLite were coded using ** C++ instead of plain old C. */ int sqlite4OsClose(sqlite4_file *pId){ int rc = SQLITE_OK; if( pId->pMethods ){ rc = pId->pMethods->xClose(pId); pId->pMethods = 0; } return rc; } int sqlite4OsRead(sqlite4_file *id, void *pBuf, int amt, i64 offset){ return id->pMethods->xRead(id, pBuf, amt, offset); } int sqlite4OsWrite(sqlite4_file *id, const void *pBuf, int amt, i64 offset){ return id->pMethods->xWrite(id, pBuf, amt, offset); } int sqlite4OsTruncate(sqlite4_file *id, i64 size){ return id->pMethods->xTruncate(id, size); } int sqlite4OsSync(sqlite4_file *id, int flags){ return id->pMethods->xSync(id, flags); } int sqlite4OsFileSize(sqlite4_file *id, i64 *pSize){ return id->pMethods->xFileSize(id, pSize); } int sqlite4OsLock(sqlite4_file *id, int lockType){ return id->pMethods->xLock(id, lockType); } int sqlite4OsUnlock(sqlite4_file *id, int lockType){ return id->pMethods->xUnlock(id, lockType); } int sqlite4OsCheckReservedLock(sqlite4_file *id, int *pResOut){ return id->pMethods->xCheckReservedLock(id, pResOut); } /* ** Use sqlite4OsFileControl() when we are doing something that might fail ** and we need to know about the failures. Use sqlite4OsFileControlHint() ** when simply tossing information over the wall to the VFS and we do not ** really care if the VFS receives and understands the information since it ** is only a hint and can be safely ignored. The sqlite4OsFileControlHint() ** routine has no return value since the return value would be meaningless. */ int sqlite4OsFileControl(sqlite4_file *id, int op, void *pArg){ return id->pMethods->xFileControl(id, op, pArg); } void sqlite4OsFileControlHint(sqlite4_file *id, int op, void *pArg){ (void)id->pMethods->xFileControl(id, op, pArg); } int sqlite4OsSectorSize(sqlite4_file *id){ |
︙ | ︙ | |||
133 134 135 136 137 138 139 | int sqlite4OsShmMap( sqlite4_file *id, /* Database file handle */ int iPage, int pgsz, int bExtend, /* True to extend file if necessary */ void volatile **pp /* OUT: Pointer to mapping */ ){ | < < < < < | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | int sqlite4OsShmMap( sqlite4_file *id, /* Database file handle */ int iPage, int pgsz, int bExtend, /* True to extend file if necessary */ void volatile **pp /* OUT: Pointer to mapping */ ){ return id->pMethods->xShmMap(id, iPage, pgsz, bExtend, pp); } /* ** The next group of routines are convenience wrappers around the ** VFS methods. */ int sqlite4OsOpen( sqlite4_vfs *pVfs, const char *zPath, sqlite4_file *pFile, int flags, int *pFlagsOut ){ int rc; /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed ** down into the VFS layer. Some SQLITE_OPEN_ flags (for example, ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before ** reaching the VFS. */ rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut); assert( rc==SQLITE_OK || pFile->pMethods==0 ); return rc; } int sqlite4OsDelete(sqlite4_vfs *pVfs, const char *zPath, int dirSync){ assert( dirSync==0 || dirSync==1 ); return pVfs->xDelete(pVfs, zPath, dirSync); } int sqlite4OsAccess( sqlite4_vfs *pVfs, const char *zPath, int flags, int *pResOut ){ return pVfs->xAccess(pVfs, zPath, flags, pResOut); } int sqlite4OsFullPathname( sqlite4_vfs *pVfs, const char *zPath, int nPathOut, char *zPathOut ){ zPathOut[0] = 0; return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut); } #ifndef SQLITE_OMIT_LOAD_EXTENSION void *sqlite4OsDlOpen(sqlite4_vfs *pVfs, const char *zPath){ return pVfs->xDlOpen(pVfs, zPath); } |
︙ | ︙ |
Deleted src/pager.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/pager.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/pcache.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/pcache.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/pcache1.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/pragma.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** This file contains code used to implement the PRAGMA command. */ #include "sqliteInt.h" /* | | < < < < < < < | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | ** ************************************************************************* ** This file contains code used to implement the PRAGMA command. */ #include "sqliteInt.h" /* ** Interpret the given string as a boolean value. */ u8 sqlite4GetBoolean(const char *z){ /* 123456789 12345 */ static const char zText[] = "onoffalseyestrue"; static const u8 iOffset[] = {0, 1, 2, 4, 9, 12}; static const u8 iLength[] = {2, 2, 3, 5, 3, 4}; static const u8 iValue[] = {1, 0, 0, 0, 1, 1}; int i, n; if( sqlite4Isdigit(*z) ){ return (u8)sqlite4Atoi(z); } n = sqlite4Strlen30(z); for(i=0; i<ArraySize(iLength); i++){ if( iLength[i]==n && sqlite4StrNICmp(&zText[iOffset[i]],z,n)==0 ){ return iValue[i]; } } return 1; } /* The sqlite4GetBoolean() function is used by other modules but the ** remainder of this file is specific to PRAGMA processing. So omit ** the rest of the file if PRAGMAs are omitted from the build. */ #if !defined(SQLITE_OMIT_PRAGMA) /* ** Generate code to return a single integer value. */ static void returnSingleInt(Parse *pParse, const char *zLabel, i64 value){ Vdbe *v = sqlite4GetVdbe(pParse); int mem = ++pParse->nMem; i64 *pI64 = sqlite4DbMallocRaw(pParse->db, sizeof(value)); |
︙ | ︙ | |||
149 150 151 152 153 154 155 | ** Also, implement the pragma. */ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){ static const struct sPragmaType { const char *zName; /* Name of the pragma */ int mask; /* Mask for the db->flags value */ } aPragma[] = { | < < < < < < < < < < > > > < < < < < | | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | ** Also, implement the pragma. */ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){ static const struct sPragmaType { const char *zName; /* Name of the pragma */ int mask; /* Mask for the db->flags value */ } aPragma[] = { { "reverse_unordered_selects", SQLITE_ReverseOrder }, #ifdef SQLITE_DEBUG { "sql_trace", SQLITE_SqlTrace }, { "vdbe_listing", SQLITE_VdbeListing }, { "vdbe_trace", SQLITE_VdbeTrace }, { "kv_trace", SQLITE_KvTrace }, { "trace", SQLITE_SqlTrace | SQLITE_VdbeListing | SQLITE_VdbeTrace | SQLITE_KvTrace }, #endif #ifndef SQLITE_OMIT_CHECK { "ignore_check_constraints", SQLITE_IgnoreChecks }, #endif /* The following is VERY experimental */ { "writable_schema", SQLITE_WriteSchema|SQLITE_RecoveryMode }, /* This flag may only be set if both foreign-key and trigger support ** are present in the build. */ #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) { "foreign_keys", SQLITE_ForeignKeys }, #endif }; int i, j; const struct sPragmaType *p; for(i=0, p=aPragma; i<ArraySize(aPragma); i++, p++){ if( sqlite4StrICmp(zLeft, p->zName)==0 ){ sqlite4 *db = pParse->db; Vdbe *v; v = sqlite4GetVdbe(pParse); assert( v!=0 ); /* Already allocated by sqlite4Pragma() */ |
︙ | ︙ | |||
213 214 215 216 217 218 219 220 221 222 223 224 225 226 | /* Many of the flag-pragmas modify the code generated by the SQL ** compiler (eg. count_changes). So add an opcode to expire all ** compiled SQL statements after modifying a pragma value. */ sqlite4VdbeAddOp2(v, OP_Expire, 0, 0); } } return 1; } } return 0; } | > > > > > | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | /* Many of the flag-pragmas modify the code generated by the SQL ** compiler (eg. count_changes). So add an opcode to expire all ** compiled SQL statements after modifying a pragma value. */ sqlite4VdbeAddOp2(v, OP_Expire, 0, 0); } for(j=0; j<db->nDb; j++){ if( db->aDb[j].pKV ){ db->aDb[j].pKV->fTrace = (db->flags & SQLITE_KvTrace)!=0; } } } return 1; } } return 0; } |
︙ | ︙ | |||
241 242 243 244 245 246 247 | assert( action==OE_None ); break; } return zName; } #endif | < < < < < < < < < < < < < < < < < < < < < | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | assert( action==OE_None ); break; } return zName; } #endif /* ** Process a pragma statement. ** ** Pragmas are of this form: ** ** PRAGMA [database.]id [= value] ** |
︙ | ︙ | |||
323 324 325 326 327 328 329 | assert( pId2 ); zDb = pId2->n>0 ? pDb->zName : 0; if( sqlite4AuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, zDb) ){ goto pragma_out; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | assert( pId2 ); zDb = pId2->n>0 ? pDb->zName : 0; if( sqlite4AuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, zDb) ){ goto pragma_out; } #ifndef SQLITE_OMIT_FLAG_PRAGMAS if( flagPragma(pParse, zLeft, zRight) ){ /* The flagPragma() subroutine also generates any necessary code ** there is nothing more to do here */ }else #endif /* SQLITE_OMIT_FLAG_PRAGMAS */ |
︙ | ︙ | |||
824 825 826 827 828 829 830 | if( sqlite4ReadSchema(pParse) ) goto pragma_out; sqlite4VdbeSetNumCols(v, 3); pParse->nMem = 3; sqlite4VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC); sqlite4VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC); sqlite4VdbeSetColName(v, 2, COLNAME_NAME, "file", SQLITE_STATIC); for(i=0; i<db->nDb; i++){ | | | | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | if( sqlite4ReadSchema(pParse) ) goto pragma_out; sqlite4VdbeSetNumCols(v, 3); pParse->nMem = 3; sqlite4VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC); sqlite4VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC); sqlite4VdbeSetColName(v, 2, COLNAME_NAME, "file", SQLITE_STATIC); for(i=0; i<db->nDb; i++){ if( db->aDb[i].pKV==0 ) continue; assert( db->aDb[i].zName!=0 ); sqlite4VdbeAddOp2(v, OP_Integer, i, 1); sqlite4VdbeAddOp4(v, OP_String8, 0, 2, 0, db->aDb[i].zName, 0); sqlite4VdbeAddOp4(v, OP_String8, 0, 3, 0, "filename", 0); sqlite4VdbeAddOp2(v, OP_ResultRow, 1, 3); } }else if( sqlite4StrICmp(zLeft, "collation_list")==0 ){ int i = 0; HashElem *p; |
︙ | ︙ | |||
921 922 923 924 925 926 927 | } }else #ifndef SQLITE_INTEGRITY_CHECK_ERROR_MAX # define SQLITE_INTEGRITY_CHECK_ERROR_MAX 100 #endif | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | } }else #ifndef SQLITE_INTEGRITY_CHECK_ERROR_MAX # define SQLITE_INTEGRITY_CHECK_ERROR_MAX 100 #endif #ifndef SQLITE_OMIT_UTF16 /* ** PRAGMA encoding ** PRAGMA encoding = "utf-8"|"utf-16"|"utf-16le"|"utf-16be" ** ** In its first form, this pragma returns the encoding of the main |
︙ | ︙ | |||
1158 1159 1160 1161 1162 1163 1164 | sqlite4ErrorMsg(pParse, "unsupported encoding: %s", zRight); } } } }else #endif /* SQLITE_OMIT_UTF16 */ | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | sqlite4ErrorMsg(pParse, "unsupported encoding: %s", zRight); } } } }else #endif /* SQLITE_OMIT_UTF16 */ #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS /* ** PRAGMA compile_options ** ** Return the names of all compile-time options used in this build, ** one option per row. |
︙ | ︙ | |||
1262 1263 1264 1265 1266 1267 1268 | ** This pragma attempts to free as much memory as possible from the ** current database connection. */ if( sqlite4StrICmp(zLeft, "shrink_memory")==0 ){ sqlite4_db_release_memory(db); }else | < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | ** This pragma attempts to free as much memory as possible from the ** current database connection. */ if( sqlite4StrICmp(zLeft, "shrink_memory")==0 ){ sqlite4_db_release_memory(db); }else {/* Empty ELSE clause */} pragma_out: sqlite4DbFree(db, zLeft); sqlite4DbFree(db, zRight); } #endif /* SQLITE_OMIT_PRAGMA */ |
Changes to src/prepare.c.
︙ | ︙ | |||
129 130 131 132 133 134 135 | ** database file is given by iDb. iDb==0 is used for the main ** database. iDb==1 should never be used. iDb>=2 is used for ** auxiliary databases. Return one of the SQLITE_ error codes to ** indicate success or failure. */ static int sqlite4InitOne(sqlite4 *db, int iDb, char **pzErrMsg){ int rc; | < < | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | ** database file is given by iDb. iDb==0 is used for the main ** database. iDb==1 should never be used. iDb>=2 is used for ** auxiliary databases. Return one of the SQLITE_ error codes to ** indicate success or failure. */ static int sqlite4InitOne(sqlite4 *db, int iDb, char **pzErrMsg){ int rc; Table *pTab; Db *pDb; char const *azArg[4]; unsigned int meta[5]; InitData initData; char const *zMasterSchema; char const *zMasterName; int openedTransaction = 0; /* ** The master database table has a structure like this |
︙ | ︙ | |||
169 170 171 172 173 174 175 | #else #define temp_master_schema 0 #endif assert( iDb>=0 && iDb<db->nDb ); assert( db->aDb[iDb].pSchema ); assert( sqlite4_mutex_held(db->mutex) ); | < | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | #else #define temp_master_schema 0 #endif assert( iDb>=0 && iDb<db->nDb ); assert( db->aDb[iDb].pSchema ); assert( sqlite4_mutex_held(db->mutex) ); /* zMasterSchema and zInitScript are set to point at the master schema ** and initialisation script appropriate for the database being ** initialised. zMasterName is the name of the master table. */ if( !OMIT_TEMPDB && iDb==1 ){ zMasterSchema = temp_master_schema; |
︙ | ︙ | |||
204 205 206 207 208 209 210 | if( ALWAYS(pTab) ){ pTab->tabFlags |= TF_Readonly; } /* Create a cursor to hold the database open */ pDb = &db->aDb[iDb]; | | | | < | | | | | | | | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | if( ALWAYS(pTab) ){ pTab->tabFlags |= TF_Readonly; } /* Create a cursor to hold the database open */ pDb = &db->aDb[iDb]; if( pDb->pKV==0 ){ if( !OMIT_TEMPDB && ALWAYS(iDb==1) ){ DbSetProperty(db, 1, DB_SchemaLoaded); } return SQLITE_OK; } /* If there is not already a read-only (or read-write) transaction opened ** on the database, open one now. If a transaction is opened, it ** will be closed before this function returns. */ if( pDb->pKV->iTransLevel==0 ){ rc = sqlite4KVStoreBegin(pDb->pKV, 1); if( rc!=SQLITE_OK ){ sqlite4SetString(pzErrMsg, db, "%s", sqlite4ErrStr(rc)); goto initone_error_out; } openedTransaction = 1; } /* Get the database meta information. ** ** Meta values are as follows: ** meta[0] Schema cookie. Changes with each schema change. ** meta[1] unused ** meta[2] unused ** meta[3] unused ** meta[4] unused ** meta[5] unused ** meta[6] unused ** meta[7] unused ** meta[8] unused ** meta[9] unused ** ** Note: The #defined SQLITE_UTF* symbols in sqliteInt.h correspond to ** the possible values of meta[4]. */ sqlite4KVStoreGetMeta(pDb->pKV, 0, ArraySize(meta), meta); pDb->pSchema->schema_cookie = meta[0]; /* Read the schema information out of the schema tables */ assert( db->init.busy ); { char *zSql; zSql = sqlite4MPrintf(db, |
︙ | ︙ | |||
354 355 356 357 358 359 360 | ** even when its contents have been corrupted. */ DbSetProperty(db, iDb, DB_SchemaLoaded); rc = SQLITE_OK; } /* Jump here for an error that occurs after successfully allocating | < | | < | 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | ** even when its contents have been corrupted. */ DbSetProperty(db, iDb, DB_SchemaLoaded); rc = SQLITE_OK; } /* Jump here for an error that occurs after successfully allocating ** curMain. For an error that occurs before that point, jump to error_out. */ initone_error_out: if( openedTransaction ){ sqlite4KVStoreCommit(pDb->pKV, 0); } error_out: if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){ db->mallocFailed = 1; } return rc; } |
︙ | ︙ | |||
451 452 453 454 455 456 457 | int rc; int cookie; assert( pParse->checkSchema ); assert( sqlite4_mutex_held(db->mutex) ); for(iDb=0; iDb<db->nDb; iDb++){ int openedTransaction = 0; /* True if a transaction is opened */ | | | | | | < | | 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | int rc; int cookie; assert( pParse->checkSchema ); assert( sqlite4_mutex_held(db->mutex) ); for(iDb=0; iDb<db->nDb; iDb++){ int openedTransaction = 0; /* True if a transaction is opened */ KVStore *pKV = db->aDb[iDb].pKV; /* Database to read cookie from */ if( pKV==0 ) continue; /* If there is not already a read-only (or read-write) transaction opened ** on the b-tree database, open one now. If a transaction is opened, it ** will be closed immediately after reading the meta-value. */ if( pKV->iTransLevel==0 ){ rc = sqlite4KVStoreBegin(pKV, 1); if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){ db->mallocFailed = 1; } if( rc!=SQLITE_OK ) return; openedTransaction = 1; } /* Read the schema cookie from the database. If it does not match the ** value stored as part of the in-memory schema representation, ** set Parse.rc to SQLITE_SCHEMA. */ sqlite4KVStoreGetMeta(pKV, 0, 1, (u32 *)&cookie); if( cookie!=db->aDb[iDb].pSchema->schema_cookie ){ sqlite4ResetInternalSchema(db, iDb); pParse->rc = SQLITE_SCHEMA; } /* Close the transaction, if one was opened. */ if( openedTransaction ){ sqlite4KVStoreCommit(pKV, 0); } } } /* ** Convert a schema pointer into the iDb index that indicates ** which database file in db->aDb[] the schema refers to. |
︙ | ︙ | |||
543 544 545 546 547 548 549 | goto end_prepare; } pParse->pReprepare = pReprepare; assert( ppStmt && *ppStmt==0 ); assert( !db->mallocFailed ); assert( sqlite4_mutex_held(db->mutex) ); | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | goto end_prepare; } pParse->pReprepare = pReprepare; assert( ppStmt && *ppStmt==0 ); assert( !db->mallocFailed ); assert( sqlite4_mutex_held(db->mutex) ); sqlite4VtabUnlockList(db); pParse->db = db; pParse->nQueryLoop = (double)1; if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){ char *zSqlCopy; int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH]; |
︙ | ︙ | |||
694 695 696 697 698 699 700 | int rc; assert( ppStmt!=0 ); *ppStmt = 0; if( !sqlite4SafetyCheckOk(db) ){ return SQLITE_MISUSE_BKPT; } sqlite4_mutex_enter(db->mutex); | < < | 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 | int rc; assert( ppStmt!=0 ); *ppStmt = 0; if( !sqlite4SafetyCheckOk(db) ){ return SQLITE_MISUSE_BKPT; } sqlite4_mutex_enter(db->mutex); rc = sqlite4Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail); if( rc==SQLITE_SCHEMA ){ sqlite4_finalize(*ppStmt); rc = sqlite4Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail); } sqlite4_mutex_leave(db->mutex); return rc; } /* ** Rerun the compilation of a statement after a schema change. ** |
︙ | ︙ |
Changes to src/select.c.
︙ | ︙ | |||
1185 1186 1187 1188 1189 1190 1191 | Parse *pParse, /* Parser context */ SrcList *pTabList, /* List of tables */ ExprList *pEList /* Expressions defining the result set */ ){ Vdbe *v = pParse->pVdbe; int i, j; sqlite4 *db = pParse->db; | < < < | 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 | Parse *pParse, /* Parser context */ SrcList *pTabList, /* List of tables */ ExprList *pEList /* Expressions defining the result set */ ){ Vdbe *v = pParse->pVdbe; int i, j; sqlite4 *db = pParse->db; #ifndef SQLITE_OMIT_EXPLAIN /* If this is an EXPLAIN, skip this step */ if( pParse->explain ){ return; } #endif if( pParse->colNamesSet || NEVER(v==0) || db->mallocFailed ) return; pParse->colNamesSet = 1; sqlite4VdbeSetNumCols(v, pEList->nExpr); for(i=0; i<pEList->nExpr; i++){ Expr *p; p = pEList->a[i].pExpr; if( NEVER(p==0) ) continue; if( pEList->a[i].zName ){ char *zName = pEList->a[i].zName; |
︙ | ︙ | |||
1222 1223 1224 1225 1226 1227 1228 | if( iCol<0 ) iCol = pTab->iPKey; assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) ); if( iCol<0 ){ zCol = "rowid"; }else{ zCol = pTab->aCol[iCol].zName; } | < < < < < < < < | < | 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 | if( iCol<0 ) iCol = pTab->iPKey; assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) ); if( iCol<0 ){ zCol = "rowid"; }else{ zCol = pTab->aCol[iCol].zName; } sqlite4VdbeSetColName(v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT); }else{ sqlite4VdbeSetColName(v, i, COLNAME_NAME, sqlite4DbStrDup(db, pEList->a[i].zSpan), SQLITE_DYNAMIC); } } generateColumnTypes(pParse, pTabList, pEList); } |
︙ | ︙ | |||
1387 1388 1389 1390 1391 1392 1393 | /* ** Given a SELECT statement, generate a Table structure that describes ** the result set of that SELECT. */ Table *sqlite4ResultSetOfSelect(Parse *pParse, Select *pSelect){ Table *pTab; sqlite4 *db = pParse->db; | < < < < < | 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 | /* ** Given a SELECT statement, generate a Table structure that describes ** the result set of that SELECT. */ Table *sqlite4ResultSetOfSelect(Parse *pParse, Select *pSelect){ Table *pTab; sqlite4 *db = pParse->db; sqlite4SelectPrep(pParse, pSelect, 0); if( pParse->nErr ) return 0; while( pSelect->pPrior ) pSelect = pSelect->pPrior; pTab = sqlite4DbMallocZero(db, sizeof(Table) ); if( pTab==0 ){ return 0; } /* The sqlite4ResultSetOfSelect() is only used n contexts where lookaside ** is disabled */ assert( db->lookaside.bEnabled==0 ); |
︙ | ︙ | |||
1613 1614 1615 1616 1617 1618 1619 | assert( v!=0 ); /* The VDBE already created by calling function */ /* Create the destination temporary table if necessary */ if( dest.eDest==SRT_EphemTab ){ assert( p->pEList ); sqlite4VdbeAddOp2(v, OP_OpenEphemeral, dest.iParm, p->pEList->nExpr); | < | 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 | assert( v!=0 ); /* The VDBE already created by calling function */ /* Create the destination temporary table if necessary */ if( dest.eDest==SRT_EphemTab ){ assert( p->pEList ); sqlite4VdbeAddOp2(v, OP_OpenEphemeral, dest.iParm, p->pEList->nExpr); dest.eDest = SRT_Table; } /* Make sure all SELECTs in the statement have the same number of elements ** in their result sets. */ assert( p->pEList && pPrior->pEList ); |
︙ | ︙ | |||
3313 3314 3315 3316 3317 3318 3319 | ** If we get here it means the result set contains one or more "*" ** operators that need to be expanded. Loop through each expression ** in the result set and expand them one by one. */ struct ExprList_item *a = pEList->a; ExprList *pNew = 0; int flags = pParse->db->flags; | < < | 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 | ** If we get here it means the result set contains one or more "*" ** operators that need to be expanded. Loop through each expression ** in the result set and expand them one by one. */ struct ExprList_item *a = pEList->a; ExprList *pNew = 0; int flags = pParse->db->flags; for(k=0; k<pEList->nExpr; k++){ Expr *pE = a[k].pExpr; assert( pE->op!=TK_DOT || pE->pRight!=0 ); if( pE->op!=TK_ALL && (pE->op!=TK_DOT || pE->pRight->op!=TK_ALL) ){ /* This particular expression does not need to be expanded. */ |
︙ | ︙ | |||
3386 3387 3388 3389 3390 3391 3392 | ** using clause from the table on the right. */ continue; } } pRight = sqlite4Expr(db, TK_ID, zName); zColname = zName; zToFree = 0; | | < < < < | 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 | ** using clause from the table on the right. */ continue; } } pRight = sqlite4Expr(db, TK_ID, zName); zColname = zName; zToFree = 0; if( pTabList->nSrc>1 ){ Expr *pLeft; pLeft = sqlite4Expr(db, TK_ID, zTabName); pExpr = sqlite4PExpr(pParse, TK_DOT, pLeft, pRight, 0); }else{ pExpr = pRight; } pNew = sqlite4ExprListAppend(pParse, pNew, pExpr); sColname.z = zColname; sColname.n = sqlite4Strlen30(zColname); sqlite4ExprListSetName(pParse, pNew, &sColname, 0); |
︙ | ︙ | |||
4002 4003 4004 4005 4006 4007 4008 | */ if( p->selFlags & SF_Distinct ){ KeyInfo *pKeyInfo; distinct = pParse->nTab++; pKeyInfo = keyInfoFromExprList(pParse, p->pEList); addrDistinctIndex = sqlite4VdbeAddOp4(v, OP_OpenEphemeral, distinct, 0, 0, (char*)pKeyInfo, P4_KEYINFO_HANDOFF); | < | 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 | */ if( p->selFlags & SF_Distinct ){ KeyInfo *pKeyInfo; distinct = pParse->nTab++; pKeyInfo = keyInfoFromExprList(pParse, p->pEList); addrDistinctIndex = sqlite4VdbeAddOp4(v, OP_OpenEphemeral, distinct, 0, 0, (char*)pKeyInfo, P4_KEYINFO_HANDOFF); }else{ distinct = addrDistinctIndex = -1; } /* Aggregate and non-aggregate queries are handled differently */ if( !isAgg && pGroupBy==0 ){ ExprList *pDist = (isDistinct ? p->pEList : 0); |
︙ | ︙ |
Changes to src/shell.c.
︙ | ︙ | |||
1047 1048 1049 1050 1051 1052 1053 | sqlite4_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Successful lookaside attempts: %d\n", iHiwtr); sqlite4_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Lookaside failures due to size: %d\n", iHiwtr); sqlite4_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Lookaside failures due to OOM: %d\n", iHiwtr); iHiwtr = iCur = -1; | < < < < < < < < | 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 | sqlite4_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Successful lookaside attempts: %d\n", iHiwtr); sqlite4_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Lookaside failures due to size: %d\n", iHiwtr); sqlite4_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Lookaside failures due to OOM: %d\n", iHiwtr); iHiwtr = iCur = -1; sqlite4_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Schema Heap Usage: %d bytes\n", iCur); iHiwtr = iCur = -1; sqlite4_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset); fprintf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n", iCur); } |
︙ | ︙ | |||
1355 1356 1357 1358 1359 1360 1361 | return rc; } /* ** Text of a help message */ static char zHelp[] = | < | 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 | return rc; } /* ** Text of a help message */ static char zHelp[] = ".bail ON|OFF Stop after hitting an error. Default OFF\n" ".databases List names and files of attached databases\n" ".dump ?TABLE? ... Dump the database in an SQL text format\n" " If TABLE specified, only dump tables matching\n" " LIKE pattern TABLE.\n" ".echo ON|OFF Turn command echo on or off\n" ".exit Exit this program\n" |
︙ | ︙ | |||
1393 1394 1395 1396 1397 1398 1399 | " tcl TCL list elements\n" ".nullvalue STRING Print STRING in place of NULL values\n" ".output FILENAME Send output to FILENAME\n" ".output stdout Send output to the screen\n" ".prompt MAIN CONTINUE Replace the standard prompts\n" ".quit Exit this program\n" ".read FILENAME Execute SQL in FILENAME\n" | < < | 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 | " tcl TCL list elements\n" ".nullvalue STRING Print STRING in place of NULL values\n" ".output FILENAME Send output to FILENAME\n" ".output stdout Send output to the screen\n" ".prompt MAIN CONTINUE Replace the standard prompts\n" ".quit Exit this program\n" ".read FILENAME Execute SQL in FILENAME\n" ".schema ?TABLE? Show the CREATE statements\n" " If TABLE specified, only show tables matching\n" " LIKE pattern TABLE.\n" ".separator STRING Change separator used by output mode and .import\n" ".show Show the current values for various settings\n" ".stats ON|OFF Turn stats on or off\n" ".tables ?TABLE? List names of tables\n" " If TABLE specified, only list tables matching\n" " LIKE pattern TABLE.\n" ".timeout MS Try opening locked tables for MS milliseconds\n" ".width NUM1 NUM2 ... Set column widths for \"column\" mode\n" ; static char zTimerHelp[] = ".timer ON|OFF Turn the CPU timer measurement on or off\n" ; |
︙ | ︙ | |||
1432 1433 1434 1435 1436 1437 1438 | shellstaticFunc, 0, 0); } if( db==0 || SQLITE_OK!=sqlite4_errcode(db) ){ fprintf(stderr,"Error: unable to open database \"%s\": %s\n", p->zDbFilename, sqlite4_errmsg(db)); exit(1); } | | | 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 | shellstaticFunc, 0, 0); } if( db==0 || SQLITE_OK!=sqlite4_errcode(db) ){ fprintf(stderr,"Error: unable to open database \"%s\": %s\n", p->zDbFilename, sqlite4_errmsg(db)); exit(1); } #if 0 /*ndef SQLITE_OMIT_LOAD_EXTENSION*/ sqlite4_enable_load_extension(p->db, 1); #endif } } /* ** Do C-language style dequoting. |
︙ | ︙ | |||
1502 1503 1504 1505 1506 1507 1508 | ** process that line. ** ** Return 1 on error, 2 to exit, and 0 otherwise. */ static int do_meta_command(char *zLine, struct callback_data *p){ int i = 1; int nArg = 0; | < > | 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 | ** process that line. ** ** Return 1 on error, 2 to exit, and 0 otherwise. */ static int do_meta_command(char *zLine, struct callback_data *p){ int i = 1; int nArg = 0; int rc = 0; int c, n; char *azArg[50]; /* Parse the input line into tokens. */ while( zLine[i] && nArg<ArraySize(azArg) ){ while( IsSpace(zLine[i]) ){ i++; } if( zLine[i]==0 ) break; |
︙ | ︙ | |||
1527 1528 1529 1530 1531 1532 1533 | azArg[nArg++] = &zLine[i]; while( zLine[i] && !IsSpace(zLine[i]) ){ i++; } if( zLine[i] ) zLine[i++] = 0; resolve_backslashes(azArg[nArg-1]); } } | | < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < | 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 | azArg[nArg++] = &zLine[i]; while( zLine[i] && !IsSpace(zLine[i]) ){ i++; } if( zLine[i] ) zLine[i++] = 0; resolve_backslashes(azArg[nArg-1]); } } if( nArg==0 ) return 0; /* no tokens, no error */ n = strlen30(azArg[0]); c = azArg[0][0]; if( c=='b' && n>=3 && strncmp(azArg[0], "bail", n)==0 && nArg>1 && nArg<3 ){ bail_on_error = booleanValue(azArg[1]); }else if( c=='d' && n>1 && strncmp(azArg[0], "databases", n)==0 && nArg==1 ){ struct callback_data data; char *zErrMsg = 0; open_db(p); memcpy(&data, p, sizeof(data)); data.showHeader = 1; data.mode = MODE_Column; |
︙ | ︙ | |||
1885 1886 1887 1888 1889 1890 1891 | }else{ sqlite4IoTrace = iotracePrintf; } } }else #endif | | | 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 | }else{ sqlite4IoTrace = iotracePrintf; } } }else #endif #if 0 /*ndef SQLITE_OMIT_LOAD_EXTENSION*/ if( c=='l' && strncmp(azArg[0], "load", n)==0 && nArg>=2 ){ const char *zFile, *zProc; char *zErrMsg = 0; zFile = azArg[1]; zProc = nArg>=3 ? azArg[2] : 0; open_db(p); rc = sqlite4_load_extension(p->db, zFile, zProc, &zErrMsg); |
︙ | ︙ | |||
2013 2014 2015 2016 2017 2018 2019 | rc = 1; }else{ rc = process_input(p, alt); fclose(alt); } }else | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 | rc = 1; }else{ rc = process_input(p, alt); fclose(alt); } }else if( c=='s' && strncmp(azArg[0], "schema", n)==0 && nArg<3 ){ struct callback_data data; char *zErrMsg = 0; open_db(p); memcpy(&data, p, sizeof(data)); data.showHeader = 0; |
︙ | ︙ | |||
2357 2358 2359 2360 2361 2362 2363 | ){ enableTimer = booleanValue(azArg[1]); }else if( c=='v' && strncmp(azArg[0], "version", n)==0 ){ printf("SQLite %s %s\n" /*extra-version-info*/, sqlite4_libversion(), sqlite4_sourceid()); | < < < < < < < < < < < < | 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 | ){ enableTimer = booleanValue(azArg[1]); }else if( c=='v' && strncmp(azArg[0], "version", n)==0 ){ printf("SQLite %s %s\n" /*extra-version-info*/, sqlite4_libversion(), sqlite4_sourceid()); }else if( c=='w' && strncmp(azArg[0], "width", n)==0 && nArg>1 ){ int j; assert( nArg<=ArraySize(azArg) ); for(j=1; j<nArg && j<ArraySize(p->colWidth); j++){ p->colWidth[j-1] = atoi(azArg[j]); |
︙ | ︙ |
Changes to src/sqlite.h.in.
︙ | ︙ | |||
3847 3848 3849 3850 3851 3852 3853 | ** using these functions, we are not going to tell you what they do. */ #ifndef SQLITE_OMIT_DEPRECATED SQLITE_DEPRECATED int sqlite4_aggregate_count(sqlite4_context*); SQLITE_DEPRECATED int sqlite4_expired(sqlite4_stmt*); SQLITE_DEPRECATED int sqlite4_transfer_bindings(sqlite4_stmt*, sqlite4_stmt*); SQLITE_DEPRECATED int sqlite4_global_recover(void); | < | 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 | ** using these functions, we are not going to tell you what they do. */ #ifndef SQLITE_OMIT_DEPRECATED SQLITE_DEPRECATED int sqlite4_aggregate_count(sqlite4_context*); SQLITE_DEPRECATED int sqlite4_expired(sqlite4_stmt*); SQLITE_DEPRECATED int sqlite4_transfer_bindings(sqlite4_stmt*, sqlite4_stmt*); SQLITE_DEPRECATED int sqlite4_global_recover(void); SQLITE_DEPRECATED int sqlite4_memory_alarm(void(*)(void*,sqlite4_int64,int),void*,sqlite4_int64); #endif /* ** CAPI3REF: Obtaining SQL Function Parameter Values ** ** The C-language implementation of SQL functions and aggregates uses |
︙ | ︙ | |||
4551 4552 4553 4554 4555 4556 4557 | */ void *sqlite4_update_hook( sqlite4*, void(*)(void *,int ,char const *,char const *,sqlite4_int64), void* ); | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 | */ void *sqlite4_update_hook( sqlite4*, void(*)(void *,int ,char const *,char const *,sqlite4_int64), void* ); /* ** CAPI3REF: Attempt To Free Heap Memory ** ** ^The sqlite4_release_memory() interface attempts to free N bytes ** of heap memory by deallocating non-essential memory allocations ** held by the database library. Memory used to cache database ** pages to improve performance is an example of non-essential memory. |
︙ | ︙ | |||
5125 5126 5127 5128 5129 5130 5131 | ** to be experimental. The interface might change in incompatible ways. ** If this is a problem for you, do not use the interface at this time. ** ** When the virtual-table mechanism stabilizes, we will declare the ** interface fixed, support it indefinitely, and remove this comment. */ | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 | ** to be experimental. The interface might change in incompatible ways. ** If this is a problem for you, do not use the interface at this time. ** ** When the virtual-table mechanism stabilizes, we will declare the ** interface fixed, support it indefinitely, and remove this comment. */ /* ** CAPI3REF: Virtual File System Objects ** ** A virtual filesystem (VFS) is an [sqlite4_vfs] object ** that SQLite uses to interact ** with the underlying operating system. Most SQLite builds come with a ** single default VFS that is appropriate for the host computer. |
︙ | ︙ | |||
5614 5615 5616 5617 5618 5619 5620 | ** prepared to accommodate additional static mutexes. */ #define SQLITE_MUTEX_FAST 0 #define SQLITE_MUTEX_RECURSIVE 1 #define SQLITE_MUTEX_STATIC_MASTER 2 #define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite4_malloc() */ #define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */ | | | 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 | ** prepared to accommodate additional static mutexes. */ #define SQLITE_MUTEX_FAST 0 #define SQLITE_MUTEX_RECURSIVE 1 #define SQLITE_MUTEX_STATIC_MASTER 2 #define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite4_malloc() */ #define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */ #define SQLITE_MUTEX_STATIC_OPEN 4 /* NOT USED */ #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite4_random() */ #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ #define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */ #define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite4PageMalloc() */ /* ** CAPI3REF: Retrieve the mutex for a database connection |
︙ | ︙ | |||
6231 6232 6233 6234 6235 6236 6237 | void (*xUnpin)(sqlite4_pcache*, void*, int discard); void (*xRekey)(sqlite4_pcache*, void*, unsigned oldKey, unsigned newKey); void (*xTruncate)(sqlite4_pcache*, unsigned iLimit); void (*xDestroy)(sqlite4_pcache*); }; | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 | void (*xUnpin)(sqlite4_pcache*, void*, int discard); void (*xRekey)(sqlite4_pcache*, void*, unsigned oldKey, unsigned newKey); void (*xTruncate)(sqlite4_pcache*, unsigned iLimit); void (*xDestroy)(sqlite4_pcache*); }; /* ** CAPI3REF: Unlock Notification ** ** ^When running in shared-cache mode, a database operation may fail with ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or ** individual tables within the shared-cache cannot be obtained. See ** [SQLite Shared-Cache Mode] for a description of shared-cache locking. |
︙ | ︙ |
Deleted src/sqlite4ext.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/sqliteInt.h.
︙ | ︙ | |||
675 676 677 678 679 680 681 | typedef struct VtabCtx VtabCtx; typedef struct Walker Walker; typedef struct WherePlan WherePlan; typedef struct WhereInfo WhereInfo; typedef struct WhereLevel WhereLevel; /* | | < < < < | | < < | | | | 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 | typedef struct VtabCtx VtabCtx; typedef struct Walker Walker; typedef struct WherePlan WherePlan; typedef struct WhereInfo WhereInfo; typedef struct WhereLevel WhereLevel; /* ** Defer sourcing vdbe.h until after the "u8" and ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque ** pointer types (i.e. FuncDef) defined above. */ #include "vdbe.h" #include "storage.h" #include "os.h" #include "mutex.h" /* ** Each database file to be accessed by the system is an instance ** of the following structure. There are normally two of these structures ** in the sqlite.aDb[] array. aDb[0] is the main database file and ** aDb[1] is the database file used to hold temporary tables. Additional ** databases may be attached. */ struct Db { char *zName; /* Name of this database */ KVStore *pKV; /* KV store for the database file */ u8 inTrans; /* 0: not writable. 1: Transaction. 2: Checkpoint */ u8 chngFlag; /* True if modified */ Schema *pSchema; /* Pointer to database schema (possibly shared) */ }; /* ** An instance of the following structure stores a database schema. ** ** Most Schema objects are associated with a database file. The exception is ** the Schema for the TEMP databaes (sqlite4.aDb[1]) which is free-standing. ** ** Schema objects are automatically deallocated when the last database that ** references them is destroyed. The TEMP Schema is manually freed by ** sqlite4_close(). * ** A thread must be holding a mutex on the corresponding database in order ** to access Schema content. This implies that the thread must also be ** holding a mutex on the sqlite4 connection pointer that owns the database ** For a TEMP Schema, only the connection mutex is required. */ struct Schema { int schema_cookie; /* Database schema version number for this file */ int iGeneration; /* Generation counter. Incremented with each change */ Hash tblHash; /* All tables indexed by name */ Hash idxHash; /* All (named) indices indexed by name */ |
︙ | ︙ | |||
955 956 957 958 959 960 961 | #define ENC(db) ((db)->aDb[0].pSchema->enc) /* ** Possible values for the sqlite4.flags. */ #define SQLITE_VdbeTrace 0x00000100 /* True to trace VDBE execution */ #define SQLITE_InternChanges 0x00000200 /* Uncommitted Hash table changes */ | < < < < | < < < | 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 | #define ENC(db) ((db)->aDb[0].pSchema->enc) /* ** Possible values for the sqlite4.flags. */ #define SQLITE_VdbeTrace 0x00000100 /* True to trace VDBE execution */ #define SQLITE_InternChanges 0x00000200 /* Uncommitted Hash table changes */ #define SQLITE_CountRows 0x00001000 /* Count rows changed by INSERT, */ /* DELETE, or UPDATE and return */ /* the count using a callback. */ #define SQLITE_SqlTrace 0x00004000 /* Debug print SQL as it executes */ #define SQLITE_VdbeListing 0x00008000 /* Debug listings of VDBE programs */ #define SQLITE_WriteSchema 0x00010000 /* OK to update SQLITE_MASTER */ #define SQLITE_KvTrace 0x00020000 /* Trace Key/value storage calls */ #define SQLITE_IgnoreChecks 0x00040000 /* Do not enforce check constraints */ #define SQLITE_ReadUncommitted 0x0080000 /* For shared-cache mode */ #define SQLITE_LegacyFileFmt 0x00100000 /* Create new databases in format 1 */ #define SQLITE_RecoveryMode 0x00800000 /* Ignore schema errors */ #define SQLITE_ReverseOrder 0x01000000 /* Reverse unordered SELECTs */ #define SQLITE_RecTriggers 0x02000000 /* Enable recursive triggers */ #define SQLITE_ForeignKeys 0x04000000 /* Enforce foreign key constraints */ #define SQLITE_AutoIndex 0x08000000 /* Enable automatic indexes */ #define SQLITE_PreferBuiltin 0x10000000 /* Preference to built-in funcs */ #define SQLITE_EnableTrigger 0x40000000 /* True to enable triggers */ /* ** Bits of the sqlite4.flags field that are used by the ** sqlite4_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface. ** These must be the low-order bits of the flags field. */ |
︙ | ︙ | |||
1432 1433 1434 1435 1436 1437 1438 | #define OE_SetDflt 8 /* Set the foreign key value to its default */ #define OE_Cascade 9 /* Cascade the changes */ #define OE_Default 99 /* Do whatever the default action is */ /* | | | | | > | 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 | #define OE_SetDflt 8 /* Set the foreign key value to its default */ #define OE_Cascade 9 /* Cascade the changes */ #define OE_Default 99 /* Do whatever the default action is */ /* ** An instance of the following structure describes an index key. It ** includes information such as sort order and collating sequence for ** each key, and the number of primary key fields appended to the end. */ struct KeyInfo { sqlite4 *db; /* The database connection */ u8 enc; /* Text encoding - one of the SQLITE_UTF* values */ u16 nField; /* Total number of entries in aColl[] */ u16 nPK; /* Number of primary key entries at the end of aColl[] */ u8 *aSortOrder; /* Sort order for each column. May be NULL */ CollSeq *aColl[1]; /* Collating sequence for each term of the key */ }; /* ** An instance of the following structure holds information about a ** single index record that has already been parsed out into individual |
︙ | ︙ | |||
2324 2325 2326 2327 2328 2329 2330 | /* ** Bitfield flags for P5 value in OP_Insert and OP_Delete */ #define OPFLAG_NCHANGE 0x01 /* Set to update db->nChange */ #define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */ #define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */ #define OPFLAG_APPEND 0x08 /* This is likely to be an append */ | | | 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 | /* ** Bitfield flags for P5 value in OP_Insert and OP_Delete */ #define OPFLAG_NCHANGE 0x01 /* Set to update db->nChange */ #define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */ #define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */ #define OPFLAG_APPEND 0x08 /* This is likely to be an append */ #define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek on insert */ #define OPFLAG_CLEARCACHE 0x20 /* Clear pseudo-table cache in OP_Column */ #define OPFLAG_APPENDBIAS 0x40 /* Bias inserts for appending */ /* * Each trigger present in the database schema is stored as an instance of * struct Trigger. * |
︙ | ︙ | |||
2966 2967 2968 2969 2970 2971 2972 | ** the MACRO form does). */ int sqlite4PutVarint(unsigned char*, u64); int sqlite4PutVarint32(unsigned char*, u32); u8 sqlite4GetVarint(const unsigned char *, u64 *); u8 sqlite4GetVarint32(const unsigned char *, u32 *); int sqlite4VarintLen(u64 v); | | | 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 | ** the MACRO form does). */ int sqlite4PutVarint(unsigned char*, u64); int sqlite4PutVarint32(unsigned char*, u32); u8 sqlite4GetVarint(const unsigned char *, u64 *); u8 sqlite4GetVarint32(const unsigned char *, u32 *); int sqlite4VarintLen(u64 v); int sqlite4GetVarint64(const unsigned char*, int, sqlite4_uint64 *pResult); int sqlite4PutVarint64(unsigned char*, sqlite4_uint64); /* ** The header of a record consists of a sequence variable-length integers. ** These integers are almost always small and are encoded as a single byte. ** The following macros take advantage this fact to provide a fast encode ** and decode of the integers in a record header. It is faster for the common |
︙ | ︙ | |||
3072 3073 3074 3075 3076 3077 3078 | int sqlite4FindDb(sqlite4*, Token*); int sqlite4FindDbName(sqlite4 *, const char *); int sqlite4AnalysisLoad(sqlite4*,int iDB); void sqlite4DeleteIndexSamples(sqlite4*,Index*); void sqlite4DefaultRowEst(Index*); void sqlite4RegisterLikeFunctions(sqlite4*, int); int sqlite4IsLikeFunction(sqlite4*,Expr*,int*,char*); | < | | < < < | 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 | int sqlite4FindDb(sqlite4*, Token*); int sqlite4FindDbName(sqlite4 *, const char *); int sqlite4AnalysisLoad(sqlite4*,int iDB); void sqlite4DeleteIndexSamples(sqlite4*,Index*); void sqlite4DefaultRowEst(Index*); void sqlite4RegisterLikeFunctions(sqlite4*, int); int sqlite4IsLikeFunction(sqlite4*,Expr*,int*,char*); void sqlite4SchemaClear(Schema*); Schema *sqlite4SchemaGet(sqlite4*); int sqlite4SchemaToIndex(sqlite4 *db, Schema *); KeyInfo *sqlite4IndexKeyinfo(Parse *, Index *); int sqlite4CreateFunc(sqlite4 *, const char *, int, int, void *, void (*)(sqlite4_context*,int,sqlite4_value **), void (*)(sqlite4_context*,int,sqlite4_value **), void (*)(sqlite4_context*), FuncDestructor *pDestructor ); int sqlite4ApiExit(sqlite4 *db, int); int sqlite4OpenTempDatabase(Parse *); void sqlite4StrAccumInit(StrAccum*, char*, int, int); void sqlite4StrAccumAppend(StrAccum*,const char*,int); void sqlite4AppendSpace(StrAccum*,int); char *sqlite4StrAccumFinish(StrAccum*); void sqlite4StrAccumReset(StrAccum*); void sqlite4SelectDestInit(SelectDest*,int,int); Expr *sqlite4CreateColumnExpr(sqlite4 *, SrcList *, int, int); /* ** The interface to the LEMON-generated parser */ void *sqlite4ParserAlloc(void*(*)(size_t)); void sqlite4ParserFree(void*, void(*)(void*)); void sqlite4Parser(void*, int, Token, Parse*); #ifdef YYTRACKMAXSTACKDEPTH |
︙ | ︙ |
Changes to src/status.c.
︙ | ︙ | |||
136 137 138 139 140 141 142 | ** Return an approximation for the amount of memory currently used ** by all pagers associated with the given database connection. The ** highwater mark is meaningless and is returned as zero. */ case SQLITE_DBSTATUS_CACHE_USED: { int totalUsed = 0; int i; | < < < < < < < < < < | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | ** Return an approximation for the amount of memory currently used ** by all pagers associated with the given database connection. The ** highwater mark is meaningless and is returned as zero. */ case SQLITE_DBSTATUS_CACHE_USED: { int totalUsed = 0; int i; *pCurrent = totalUsed; *pHighwater = 0; break; } /* ** *pCurrent gets an accurate estimate of the amount of memory used ** to store the schema for all databases (main, temp, and any ATTACHed ** databases. *pHighwater is set to zero. */ case SQLITE_DBSTATUS_SCHEMA_USED: { int i; /* Used to iterate through schemas */ int nByte = 0; /* Used to accumulate return value */ db->pnBytesFreed = &nByte; for(i=0; i<db->nDb; i++){ Schema *pSchema = db->aDb[i].pSchema; if( ALWAYS(pSchema!=0) ){ HashElem *p; nByte += sqlite4GlobalConfig.m.xRoundup(sizeof(HashElem)) * ( |
︙ | ︙ | |||
186 187 188 189 190 191 192 | } for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){ sqlite4DeleteTable(db, (Table *)sqliteHashData(p)); } } } db->pnBytesFreed = 0; | < | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | } for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){ sqlite4DeleteTable(db, (Table *)sqliteHashData(p)); } } } db->pnBytesFreed = 0; *pHighwater = 0; *pCurrent = nByte; break; } /* |
︙ | ︙ | |||
223 224 225 226 227 228 229 | ** pagers the database handle is connected to. *pHighwater is always set ** to zero. */ case SQLITE_DBSTATUS_CACHE_HIT: case SQLITE_DBSTATUS_CACHE_MISS: { int i; int nRet = 0; | < < < < < < < < | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | ** pagers the database handle is connected to. *pHighwater is always set ** to zero. */ case SQLITE_DBSTATUS_CACHE_HIT: case SQLITE_DBSTATUS_CACHE_MISS: { int i; int nRet = 0; *pHighwater = 0; *pCurrent = nRet; break; } default: { rc = SQLITE_ERROR; } } sqlite4_mutex_leave(db->mutex); return rc; } |
Changes to src/storage.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2012 January 21 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** General wrapper functions around the various KV storage engine | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > | > > | < | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | /* ** 2012 January 21 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** General wrapper functions around the various KV storage engine ** implementations. It also implements tracing of calls to the KV ** engine and some higher-level ensembles of the low-level storage ** calls. */ #include "sqliteInt.h" /* ** Names of error codes used for tracing. */ static const char *kvErrName(int e){ const char *zName; switch( e ){ case SQLITE_OK: zName = "OK"; break; case SQLITE_ERROR: zName = "ERROR"; break; case SQLITE_INTERNAL: zName = "INTERNAL"; break; case SQLITE_PERM: zName = "PERM"; break; case SQLITE_ABORT: zName = "ABORT"; break; case SQLITE_BUSY: zName = "BUSY"; break; case SQLITE_LOCKED: zName = "LOCKED"; break; case SQLITE_NOMEM: zName = "NOMEM"; break; case SQLITE_READONLY: zName = "READONLY"; break; case SQLITE_INTERRUPT: zName = "INTERRUPT"; break; case SQLITE_IOERR: zName = "IOERR"; break; case SQLITE_CORRUPT: zName = "CORRUPT"; break; case SQLITE_NOTFOUND: zName = "NOTFOUND"; break; case SQLITE_FULL: zName = "FULL"; break; case SQLITE_CANTOPEN: zName = "CANTOPEN"; break; case SQLITE_PROTOCOL: zName = "PROTOCOL"; break; case SQLITE_EMPTY: zName = "EMPTY"; break; case SQLITE_SCHEMA: zName = "SCHEMA"; break; case SQLITE_TOOBIG: zName = "TOOBIG"; break; case SQLITE_CONSTRAINT: zName = "CONSTRAINT"; break; case SQLITE_MISMATCH: zName = "MISMATCH"; break; case SQLITE_MISUSE: zName = "MISUSE"; break; case SQLITE_NOLFS: zName = "NOLFS"; break; case SQLITE_AUTH: zName = "AUTH"; break; case SQLITE_FORMAT: zName = "FORMAT"; break; case SQLITE_RANGE: zName = "RANGE"; break; case SQLITE_NOTADB: zName = "NOTADB"; break; case SQLITE_ROW: zName = "ROW"; break; case SQLITE_DONE: zName = "DONE"; break; case SQLITE_INEXACT: zName = "INEXACT"; break; default: zName = "???"; break; } return zName; } /* ** Do any requested tracing */ static void kvTrace(KVStore *p, const char *zFormat, ...){ if( p->fTrace ){ va_list ap; char *z; va_start(ap, zFormat); z = sqlite4_vmprintf(zFormat, ap); va_end(ap); printf("%s.%s\n", p->zKVName, z); fflush(stdout); sqlite4_free(z); } } /* ** Open a storage engine via URI */ int sqlite4KVStoreOpen( sqlite4 *db, /* The database connection doing the open */ const char *zName, /* Symbolic name for this database */ const char *zUri, /* URI for this database */ KVStore **ppKVStore, /* Write the new KVStore object here */ unsigned flags /* Option flags */ ){ KVStore *pNew = 0; int rc; rc = sqlite4KVStoreOpenMem(&pNew, flags); *ppKVStore = pNew; if( pNew ){ sqlite4_randomness(sizeof(pNew->kvId), &pNew->kvId); sqlite4_snprintf(sizeof(pNew->zKVName), pNew->zKVName, "%s", zName); pNew->fTrace = (db->flags & SQLITE_KvTrace)!=0; kvTrace(pNew, "open(%s,%d,0x%04x)", zUri, pNew->kvId, flags); } return rc; } /* Convert binary data to hex for display in trace messages */ static void binToHex(char *zOut, int mxOut, const KVByteArray *a, KVSize n){ int i; |
︙ | ︙ | |||
53 54 55 56 57 58 59 | KVStore *p, const KVByteArray *pKey, KVSize nKey, const KVByteArray *pData, KVSize nData ){ if( p->fTrace ){ char zKey[52], zData[52]; binToHex(zKey, sizeof(zKey), pKey, nKey); | | | > | | < > | < | < < | < < | < < | < | | | | > > < | < > > | > > > > > > > > > | > > > > | > > | > > > > > > > > | | | < > > > | > > > > > > > > | > | > > > > | > > > > > > > | > > > > | > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | KVStore *p, const KVByteArray *pKey, KVSize nKey, const KVByteArray *pData, KVSize nData ){ if( p->fTrace ){ char zKey[52], zData[52]; binToHex(zKey, sizeof(zKey), pKey, nKey); binToHex(zData, sizeof(zData), pData, nData); kvTrace(p, "xReplace(%d,%s,%d,%s,%d)", p->kvId, zKey, (int)nKey, zData, (int)nData); } return p->pStoreVfunc->xReplace(p,pKey,nKey,pData,nData); } int sqlite4KVStoreOpenCursor(KVStore *p, KVCursor **ppKVCursor){ KVCursor *pCur; int rc; rc = p->pStoreVfunc->xOpenCursor(p, &pCur); *ppKVCursor = pCur; if( pCur ){ sqlite4_randomness(sizeof(pCur->curId), &pCur->curId); pCur->fTrace = p->fTrace; pCur->pStore = p; } kvTrace(p, "xOpenCursor(%d,%d) -> %s", p->kvId, pCur?pCur->curId:-1, kvErrName(rc)); return rc; } int sqlite4KVCursorSeek( KVCursor *p, const KVByteArray *pKey, KVSize nKey, int dir ){ int rc; rc = p->pStoreVfunc->xSeek(p,pKey,nKey,dir); if( p->fTrace ){ char zKey[52]; binToHex(zKey, sizeof(zKey), pKey, nKey); kvTrace(p->pStore, "xSeek(%d,%s,%d,%d) -> %s", p->curId, zKey, (int)nKey, dir, kvErrName(rc)); } return rc; } int sqlite4KVCursorNext(KVCursor *p){ int rc; rc = p->pStoreVfunc->xNext(p); kvTrace(p->pStore, "xNext(%d) -> %s", p->curId, kvErrName(rc)); return rc; } int sqlite4KVCursorPrev(KVCursor *p){ int rc; rc = p->pStoreVfunc->xPrev(p); kvTrace(p->pStore, "xPrev(%d) -> %s", p->curId, kvErrName(rc)); return rc; } int sqlite4KVCursorDelete(KVCursor *p){ int rc; rc = p->pStoreVfunc->xDelete(p); kvTrace(p->pStore, "xDelete(%d) -> %s", p->curId, kvErrName(rc)); return rc; } int sqlite4KVCursorReset(KVCursor *p){ int rc; rc = p->pStoreVfunc->xReset(p); kvTrace(p->pStore, "xReset(%d) -> %s", p->curId, kvErrName(rc)); return rc; } int sqlite4KVCursorKey(KVCursor *p, const KVByteArray **ppKey, KVSize *pnKey){ int rc; rc = p->pStoreVfunc->xKey(p, ppKey, pnKey); if( p->fTrace ){ if( rc==SQLITE_OK ){ char zKey[52]; binToHex(zKey, sizeof(zKey), *ppKey, *pnKey); kvTrace(p->pStore, "xKey(%d,%s,%d)", p->curId, zKey, (int)*pnKey); }else{ kvTrace(p->pStore, "xKey(%d,<error-%d>)", p->curId, rc); } } return rc; } int sqlite4KVCursorData( KVCursor *p, KVSize ofst, KVSize n, const KVByteArray **ppData, KVSize *pnData ){ int rc; rc = p->pStoreVfunc->xData(p, ofst, n, ppData, pnData); if( p->fTrace ){ if( rc==SQLITE_OK ){ char zData[52]; binToHex(zData, sizeof(zData), *ppData, *pnData); kvTrace(p->pStore, "xData(%d,%d,%d,%s,%d)", p->curId, (int)ofst, (int)n, zData, (int)*pnData); }else{ kvTrace(p->pStore, "xData(%d,%d,%d,<error-%d>)", p->curId, (int)ofst, (int)n, rc); } } return rc; } int sqlite4KVCursorClose(KVCursor *p){ int rc = SQLITE_OK; if( p ){ KVStore *pStore = p->pStore; int curId = p->curId; rc = p->pStoreVfunc->xCloseCursor(p); kvTrace(pStore, "xCloseCursor(%d) -> %s", curId, kvErrName(rc)); } return rc; } int sqlite4KVStoreBegin(KVStore *p, int iLevel){ int rc; assert( (iLevel==2 && p->iTransLevel==0) || p->iTransLevel+1==iLevel ); rc = p->pStoreVfunc->xBegin(p, iLevel); kvTrace(p, "xBegin(%d,%d) -> %s", p->kvId, iLevel, kvErrName(rc)); assert( p->iTransLevel==iLevel || rc!=SQLITE_OK ); return rc; } int sqlite4KVStoreCommitPhaseOne(KVStore *p, int iLevel){ int rc; assert( iLevel>=0 ); assert( iLevel<=p->iTransLevel ); if( p->iTransLevel==iLevel ) return SQLITE_OK; if( p->pStoreVfunc->xCommitPhaseOne ){ rc = p->pStoreVfunc->xCommitPhaseOne(p, iLevel); }else{ rc = SQLITE_OK; } kvTrace(p, "xCommitPhaseOne(%d,%d) -> %s", p->kvId, iLevel, kvErrName(rc)); assert( p->iTransLevel>iLevel ); return rc; } int sqlite4KVStoreCommitPhaseTwo(KVStore *p, int iLevel){ int rc; assert( iLevel>=0 ); assert( iLevel<=p->iTransLevel ); if( p->iTransLevel==iLevel ) return SQLITE_OK; rc = p->pStoreVfunc->xCommitPhaseTwo(p, iLevel); kvTrace(p, "xCommitPhaseTwo(%d,%d) -> %s", p->kvId, iLevel, kvErrName(rc)); assert( p->iTransLevel==iLevel || rc!=SQLITE_OK ); return rc; } int sqlite4KVStoreCommit(KVStore *p, int iLevel){ int rc; rc = sqlite4KVStoreCommitPhaseOne(p, iLevel); if( rc==SQLITE_OK ) rc = sqlite4KVStoreCommitPhaseTwo(p, iLevel); return rc; } int sqlite4KVStoreRollback(KVStore *p, int iLevel){ int rc; assert( iLevel>=0 ); assert( iLevel<=p->iTransLevel ); rc = p->pStoreVfunc->xRollback(p, iLevel); kvTrace(p, "xRollback(%d,%d) -> %s", p->kvId, iLevel, kvErrName(rc)); assert( p->iTransLevel==iLevel || rc!=SQLITE_OK ); return rc; } int sqlite4KVStoreRevert(KVStore *p, int iLevel){ int rc; assert( iLevel>0 ); assert( iLevel<=p->iTransLevel ); if( p->pStoreVfunc->xRevert ){ rc = p->pStoreVfunc->xRevert(p, iLevel); kvTrace(p, "xRevert(%d,%d) -> %s", p->kvId, iLevel, kvErrName(rc)); }else{ rc = sqlite4KVStoreRollback(p, iLevel-1); if( rc==SQLITE_OK ){ rc = sqlite4KVStoreBegin(p, iLevel); } } assert( p->iTransLevel==iLevel || rc!=SQLITE_OK ); return rc; } int sqlite4KVStoreClose(KVStore *p){ int rc; if( p ){ kvTrace(p, "xClose(%d)", p->kvId); rc = p->pStoreVfunc->xClose(p); } return rc; } /* ** Key for the meta-data */ static const KVByteArray metadataKey[] = { 0x00, 0x00 }; /* ** Read nMeta unsigned 32-bit integers of metadata beginning at iStart. */ int sqlite4KVStoreGetMeta(KVStore *p, int iStart, int nMeta, unsigned int *a){ KVCursor *pCur; int rc; int i, j; KVSize nData; const KVByteArray *aData; rc = sqlite4KVStoreOpenCursor(p, &pCur); if( rc==SQLITE_OK ){ rc = sqlite4KVCursorSeek(pCur, metadataKey, sizeof(metadataKey), 0); if( rc==SQLITE_NOTFOUND ){ rc = SQLITE_OK; nData = 0; }else if( rc==SQLITE_OK ){ rc = sqlite4KVCursorData(pCur, 0, -1, &aData, &nData); } if( rc==SQLITE_OK ){ i = 0; j = iStart*4; while( i<nMeta && j+3<nData ){ a[i] = (aData[j]<<24) | (aData[j+1]<<16) | (aData[j+2]<<8) | aData[j+3]; i++; j += 4; } while( i<nMeta ) a[i++] = 0; } sqlite4KVCursorClose(pCur); } return rc; } /* ** Write nMeta unsigned 32-bit integers beginning with iStart. */ int sqlite4KVStorePutMeta( sqlite4 *db, /* Database connection. Needed to malloc */ KVStore *p, /* Write to this database */ int iStart, /* Start writing here */ int nMeta, /* number of 32-bit integers to be written */ unsigned int *a /* The integers to write */ ){ KVCursor *pCur; int rc; int i, j; KVSize nData; const KVByteArray *aData; KVByteArray *aNew; KVSize nNew; rc = sqlite4KVStoreOpenCursor(p, &pCur); if( rc==SQLITE_OK ){ rc = sqlite4KVCursorSeek(pCur, metadataKey, sizeof(metadataKey), 0); if( rc==SQLITE_OK ){ rc = sqlite4KVCursorData(pCur, 0, -1, &aData, &nData); }else if( rc==SQLITE_NOTFOUND ){ nData = 0; aData = 0; rc = SQLITE_OK; } if( rc==SQLITE_OK ){ nNew = iStart+nMeta; if( nNew<nData ) nNew = nData; aNew = sqlite4DbMallocRaw(db, nNew*sizeof(a[0]) ); if( aNew==0 ){ rc = SQLITE_NOMEM; }else{ memcpy(aNew, aData, nData); i = 0; j = iStart*4; while( i<nMeta && j+3<nData ){ aNew[j] = (a[i]>>24)&0xff; aNew[j+1] = (a[i]>>16)&0xff; aNew[j+2] = (a[i]>>8)&0xff; aNew[j+3] = a[i] & 0xff; i++; j += 4; } rc = sqlite4KVStoreReplace(p, metadataKey, sizeof(metadataKey), aNew, nNew); sqlite4DbFree(db, aNew); } } sqlite4KVCursorClose(pCur); } return rc; } |
Changes to src/storage.h.
︙ | ︙ | |||
20 21 22 23 24 25 26 | ** ** The xBegin, xCommit, and xRollback methods change the transaction level ** of the store. The transaction level is a non-negative integer that is ** initialized to zero. The transaction level must be at least 1 in order ** for content to be read. The transaction level must be at least 2 for ** content to be modified. ** | | | > | | | > > > > > > > > > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | ** ** The xBegin, xCommit, and xRollback methods change the transaction level ** of the store. The transaction level is a non-negative integer that is ** initialized to zero. The transaction level must be at least 1 in order ** for content to be read. The transaction level must be at least 2 for ** content to be modified. ** ** The xBegin method increases transaction level. The increase may be no ** more than 1 unless the transaction level is initially 0 in which case ** it can be increased immediately to 2. Increasing the transaction level ** to 1 or more makes a "snapshot" of the complete store such that changes ** made by other connections are not visible. An xBegin call may fail ** with SQLITE_BUSY if the initial transaction level is 0 or 1. ** ** A read-only store will fail an attempt to increase xBegin above 1. An ** implementation that does not support nested transactions will fail any ** attempt to increase the transaction level above 2. ** ** The xCommitPhaseOne and xCommitPhaseTwo methods implementat a 2-phase ** commit that lowers the transaction level to the value given in the ** second argument, and makes all the changes made at higher transaction levels ** permanent. A rollback is still possible following phase one. If ** possible, errors should be reported during phase one so that a ** multiple-database transaction can still be rolled back if the ** phase one fails on a different database. Implementations that do not ** support two-phase commit can implement xCommitPhaseOne as a no-op function ** returning SQLITE_OK. ** ** The xRollback method lowers the transaction level to the value given in ** its argument and reverts or undoes all changes made at higher transaction ** levels. An xRollback to level N causes the database to revert to the state ** it was in on the most recent xBegin to level N+1. ** ** The xRevert(N) method causes the state of the database file to go back ** to what it was immediately after the most recent xCommit(N). Higher-level ** subtransactions are cancelled. This call is equivalent to xRollback(N-1) ** followed by xBegin(N) but might be more efficient. ** ** The xReplace method replaces the value for an existing entry with the ** given key, or creates a new entry with the given key and value if no ** prior entry exists with the given key. The key and value pointers passed ** into xReplace will likely be destroyed when the call to xReplace returns ** so the xReplace routine must make its own copy of that information. ** |
︙ | ︙ | |||
64 65 66 67 68 69 70 71 72 73 74 75 76 77 | ** pointing to EOF. If dir is negative, then an exact match is ** found if it is available, otherwise the cursor is positioned at the largest ** entry that is less than the search key or to EOF if the store contains no ** entry less than the search key. If dir is positive, then an exist match ** is found if it is available, otherwise the cursor is left pointing the ** the smallest entry that is larger than the search key, or to EOF if there ** are no entries larger than the search key. ** ** The xNext method may only be used following an xSeek with a positive dir, ** or another xNext. The xPrev method may only be used following an xSeek with ** a negative dir or another xPrev. ** ** Values returned by xKey and xData are guaranteed to remain stable until ** the next xSeek, xNext, xPrev, xReset, or xCloseCursor on the same cursor. | > > > > > > > > > > > > > > | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | ** pointing to EOF. If dir is negative, then an exact match is ** found if it is available, otherwise the cursor is positioned at the largest ** entry that is less than the search key or to EOF if the store contains no ** entry less than the search key. If dir is positive, then an exist match ** is found if it is available, otherwise the cursor is left pointing the ** the smallest entry that is larger than the search key, or to EOF if there ** are no entries larger than the search key. ** ** The xSeek return code might be one of the following: ** ** SQLITE_OK The cursor is left pointing to any entry that ** exactly matchings the probe key. ** ** SQLITE_INEXACT The cursor is left pointing to the nearest entry ** to the probe it could find, either before or after ** the probe, according to the dir argument. ** ** SQLITE_NOTFOUND No suitable entry could be found. Either dir==0 and ** there was no exact match, or dir<0 and the probe is ** smaller than every entry in the database, or dir>0 and ** the probe is larger than every entry in the database. ** ** The xNext method may only be used following an xSeek with a positive dir, ** or another xNext. The xPrev method may only be used following an xSeek with ** a negative dir or another xPrev. ** ** Values returned by xKey and xData are guaranteed to remain stable until ** the next xSeek, xNext, xPrev, xReset, or xCloseCursor on the same cursor. |
︙ | ︙ | |||
92 93 94 95 96 97 98 | typedef struct KVStoreMethods KVStoreMethods; typedef struct KVCursor KVCursor; typedef unsigned char KVByteArray; typedef int KVSize; /* ** A Key-Value storage engine is defined by an instance of the following | | | > > > > > > > > > > | | > > > > > > | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | typedef struct KVStoreMethods KVStoreMethods; typedef struct KVCursor KVCursor; typedef unsigned char KVByteArray; typedef int KVSize; /* ** A Key-Value storage engine is defined by an instance of the following ** structures: */ struct KVStoreMethods { int (*xReplace)(KVStore*, const KVByteArray *pKey, KVSize nKey, const KVByteArray *pData, KVSize nData); int (*xOpenCursor)(KVStore*, KVCursor**); int (*xSeek)(KVCursor*, const KVByteArray *pKey, KVSize nKey, int dir); int (*xNext)(KVCursor*); int (*xPrev)(KVCursor*); int (*xDelete)(KVCursor*); int (*xKey)(KVCursor*, const KVByteArray **ppKey, KVSize *pnKey); int (*xData)(KVCursor*, KVSize ofst, KVSize n, const KVByteArray **ppData, KVSize *pnData); int (*xReset)(KVCursor*); int (*xCloseCursor)(KVCursor*); int (*xBegin)(KVStore*, int); int (*xCommitPhaseOne)(KVStore*, int); int (*xCommitPhaseTwo)(KVStore*, int); int (*xRollback)(KVStore*, int); int (*xRevert)(KVStore*, int); int (*xClose)(KVStore*); }; struct KVStore { const KVStoreMethods *pStoreVfunc; /* Virtual method table */ int iTransLevel; /* Current transaction level */ u16 kvId; /* Unique ID used for tracing */ u8 fTrace; /* True to enable tracing */ char zKVName[12]; /* Used for debugging */ /* Subclasses will typically append additional fields */ }; /* ** Base class for cursors */ struct KVCursor { KVStore *pStore; /* The owner of this cursor */ const KVStoreMethods *pStoreVfunc; /* Methods */ int iTransLevel; /* Current transaction level */ u16 curId; /* Unique ID for tracing */ u8 fTrace; /* True to enable tracing */ /* Subclasses will typically add additional fields */ }; /* ** Valid flags for sqlite4KVStorageOpen() */ #define SQLITE_KVOPEN_TEMPORARY 0x0001 /* A temporary database */ #define SQLITE_KVOPEN_NO_TRANSACTIONS 0x0002 /* No transactions will be used */ int sqlite4KVStoreOpenMem(KVStore**, unsigned); int sqlite4KVStoreOpen( sqlite4*, const char *zLabel, const char *zUri, KVStore**, unsigned flags ); int sqlite4KVStoreReplace( KVStore*, const KVByteArray *pKey, KVSize nKey, const KVByteArray *pData, KVSize nData ); int sqlite4KVStoreOpenCursor(KVStore *p, KVCursor **ppKVCursor); int sqlite4KVCursorSeek( |
︙ | ︙ | |||
158 159 160 161 162 163 164 165 166 167 | KVSize ofst, KVSize n, const KVByteArray **ppData, KVSize *pnData ); int sqlite4KVCursorClose(KVCursor *p); int sqlite4KVStoreBegin(KVStore *p, int iLevel); int sqlite4KVStoreCommit(KVStore *p, int iLevel); int sqlite4KVStoreRollback(KVStore *p, int iLevel); int sqlite4KVStoreClose(KVStore *p); | > > > > > > | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | KVSize ofst, KVSize n, const KVByteArray **ppData, KVSize *pnData ); int sqlite4KVCursorClose(KVCursor *p); int sqlite4KVStoreBegin(KVStore *p, int iLevel); int sqlite4KVStoreCommitPhaseOne(KVStore *p, int iLevel); int sqlite4KVStoreCommitPhaseTwo(KVStore *p, int iLevel); int sqlite4KVStoreCommit(KVStore *p, int iLevel); int sqlite4KVStoreRollback(KVStore *p, int iLevel); int sqlite4KVStoreRevert(KVStore *p, int iLevel); int sqlite4KVStoreClose(KVStore *p); int sqlite4KVStoreGetMeta(KVStore *p, int, int, unsigned int*); int sqlite4KVStorePutMeta(sqlite4*, KVStore *p, int, int, unsigned int*); |
Changes to src/tclsqlite.c.
︙ | ︙ | |||
98 99 100 101 102 103 104 | sqlite4_stmt *pStmt; /* The prepared statement */ int nSql; /* chars in zSql[] */ const char *zSql; /* Text of the SQL statement */ int nParm; /* Size of apParm array */ Tcl_Obj **apParm; /* Array of referenced object pointers */ }; | < < | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | sqlite4_stmt *pStmt; /* The prepared statement */ int nSql; /* chars in zSql[] */ const char *zSql; /* Text of the SQL statement */ int nParm; /* Size of apParm array */ Tcl_Obj **apParm; /* Array of referenced object pointers */ }; /* ** There is one instance of this structure for each SQLite database ** that has been opened by the SQLite TCL interface. ** ** If this module is built with SQLITE_TEST defined (to create the SQLite ** testfixture executable), then it may be configured to use either ** sqlite4_prepare_v2() or sqlite4_prepare() to prepare SQL statements. |
︙ | ︙ | |||
133 134 135 136 137 138 139 | SqlCollate *pCollate; /* List of SQL collation functions */ int rc; /* Return code of most recent sqlite4_exec() */ Tcl_Obj *pCollateNeeded; /* Collation needed script */ SqlPreparedStmt *stmtList; /* List of prepared statements*/ SqlPreparedStmt *stmtLast; /* Last statement in the list */ int maxStmt; /* The next maximum number of stmtList */ int nStmt; /* Number of statements in stmtList */ | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | SqlCollate *pCollate; /* List of SQL collation functions */ int rc; /* Return code of most recent sqlite4_exec() */ Tcl_Obj *pCollateNeeded; /* Collation needed script */ SqlPreparedStmt *stmtList; /* List of prepared statements*/ SqlPreparedStmt *stmtLast; /* Last statement in the list */ int maxStmt; /* The next maximum number of stmtList */ int nStmt; /* Number of statements in stmtList */ int nStep, nSort, nIndex; /* Statistics for most recent operation */ int nTransaction; /* Number of nested [transaction] methods */ #ifdef SQLITE_TEST int bLegacyPrepare; /* True to use sqlite4_prepare() */ #endif }; /* ** Compute a string length that is limited to what can be stored in ** lower 30 bits of a 32-bit signed integer. */ static int strlen30(const char *z){ const char *z2 = z; while( *z2 ){ z2++; } return 0x3fffffff & (int)(z2 - z); } /* ** Look at the script prefix in pCmd. We will be executing this script ** after first appending one or more arguments. This routine analyzes ** the script to see if it is safe to use Tcl_EvalObjv() on the script ** rather than the more general Tcl_EvalEx(). Tcl_EvalObjv() is much ** faster. |
︙ | ︙ | |||
469 470 471 472 473 474 475 | /* ** TCL calls this procedure when an sqlite4 database command is ** deleted. */ static void DbDeleteCmd(void *db){ SqliteDb *pDb = (SqliteDb*)db; flushStmtCache(pDb); | < | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | /* ** TCL calls this procedure when an sqlite4 database command is ** deleted. */ static void DbDeleteCmd(void *db){ SqliteDb *pDb = (SqliteDb*)db; flushStmtCache(pDb); sqlite4_close(pDb->db); while( pDb->pFunc ){ SqlFunc *pFunc = pDb->pFunc; pDb->pFunc = pFunc->pNext; Tcl_DecrRefCount(pFunc->pScript); Tcl_Free((char*)pFunc); } |
︙ | ︙ | |||
1623 1624 1625 1626 1627 1628 1629 | ** subroutine to be invoked. */ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ SqliteDb *pDb = (SqliteDb*)cd; int choice; int rc = TCL_OK; static const char *DB_strs[] = { | | | | | | < | | | | | | | | | | | < | | | | | | | 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 | ** subroutine to be invoked. */ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ SqliteDb *pDb = (SqliteDb*)cd; int choice; int rc = TCL_OK; static const char *DB_strs[] = { "authorizer", "busy", "cache", "changes", "close", "collate", "collation_needed", "commit_hook", "complete", "copy", "enable_load_extension","errorcode", "eval", "exists", "function", "interrupt", "last_insert_rowid", "nullvalue", "onecolumn", "profile", "rekey", "rollback_hook", "status", "timeout", "total_changes", "trace", "transaction", "unlock_notify", "update_hook", "version", "wal_hook", 0 }; enum DB_enum { DB_AUTHORIZER, DB_BUSY, DB_CACHE, DB_CHANGES, DB_CLOSE, DB_COLLATE, DB_COLLATION_NEEDED, DB_COMMIT_HOOK, DB_COMPLETE, DB_COPY, DB_ENABLE_LOAD_EXTENSION,DB_ERRORCODE, DB_EVAL, DB_EXISTS, DB_FUNCTION, DB_INTERRUPT, DB_LAST_INSERT_ROWID,DB_NULLVALUE, DB_ONECOLUMN, DB_PROFILE, DB_REKEY, DB_ROLLBACK_HOOK, DB_STATUS, DB_TIMEOUT, DB_TOTAL_CHANGES, DB_TRACE, DB_TRANSACTION, DB_UNLOCK_NOTIFY, DB_UPDATE_HOOK, DB_VERSION, DB_WAL_HOOK }; /* don't leave trailing commas on DB_enum, it confuses the AIX xlc compiler */ if( objc<2 ){ Tcl_WrongNumArgs(interp, 1, objv, "SUBCOMMAND ..."); return TCL_ERROR; } |
︙ | ︙ | |||
1716 1717 1718 1719 1720 1721 1722 | sqlite4_set_authorizer(pDb->db, 0, 0); } } #endif break; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 | sqlite4_set_authorizer(pDb->db, 0, 0); } } #endif break; } /* $db busy ?CALLBACK? ** ** Invoke the given callback if an SQL statement attempts to open ** a locked database file. */ case DB_BUSY: { if( objc>3 ){ |
︙ | ︙ | |||
2185 2186 2187 2188 2189 2190 2191 | /* ** $db enable_load_extension BOOLEAN ** ** Turn the extension loading feature on or off. It if off by ** default. */ case DB_ENABLE_LOAD_EXTENSION: { | < < < < < < < < < < < < < | 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 | /* ** $db enable_load_extension BOOLEAN ** ** Turn the extension loading feature on or off. It if off by ** default. */ case DB_ENABLE_LOAD_EXTENSION: { Tcl_AppendResult(interp, "extension loading is turned off at compile-time", 0); return TCL_ERROR; } /* ** $db errorcode ** ** Return the numeric error code that was returned by the most recent ** call to sqlite4_exec(). |
︙ | ︙ | |||
2351 2352 2353 2354 2355 2356 2357 | if( rc!=SQLITE_OK ){ rc = TCL_ERROR; Tcl_SetResult(interp, (char *)sqlite4_errmsg(pDb->db), TCL_VOLATILE); } break; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 | if( rc!=SQLITE_OK ){ rc = TCL_ERROR; Tcl_SetResult(interp, (char *)sqlite4_errmsg(pDb->db), TCL_VOLATILE); } break; } /* ** $db interrupt ** ** Interrupt the execution of the inner-most SQL interpreter. This ** causes the SQL statement to return an error of SQLITE_INTERRUPT. */ case DB_INTERRUPT: { |
︙ | ︙ | |||
2520 2521 2522 2523 2524 2525 2526 | Tcl_AppendResult(interp, sqlite4ErrStr(rc), 0); rc = TCL_ERROR; } #endif break; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 | Tcl_AppendResult(interp, sqlite4ErrStr(rc), 0); rc = TCL_ERROR; } #endif break; } /* ** $db status (step|sort|autoindex) ** ** Display SQLITE_STMTSTATUS_FULLSCAN_STEP or ** SQLITE_STMTSTATUS_SORT for the most recent eval. */ case DB_STATUS: { |
︙ | ︙ | |||
3619 3620 3621 3622 3623 3624 3625 | Md5_Init(interp); #endif #ifdef SQLITE_TEST { extern int Sqliteconfig_Init(Tcl_Interp*); extern int Sqlitetest1_Init(Tcl_Interp*); | < < < | 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 | Md5_Init(interp); #endif #ifdef SQLITE_TEST { extern int Sqliteconfig_Init(Tcl_Interp*); extern int Sqlitetest1_Init(Tcl_Interp*); extern int Sqlitetest3_Init(Tcl_Interp*); extern int Sqlitetest4_Init(Tcl_Interp*); extern int Sqlitetest5_Init(Tcl_Interp*); extern int Sqlitetest6_Init(Tcl_Interp*); extern int Sqlitetest7_Init(Tcl_Interp*); extern int Sqlitetest8_Init(Tcl_Interp*); extern int Sqlitetest9_Init(Tcl_Interp*); extern int Sqlitetest_demovfs_Init(Tcl_Interp *); extern int Sqlitetest_func_Init(Tcl_Interp*); extern int Sqlitetest_hexio_Init(Tcl_Interp*); extern int Sqlitetest_init_Init(Tcl_Interp*); extern int Sqlitetest_malloc_Init(Tcl_Interp*); extern int Sqlitetest_mutex_Init(Tcl_Interp*); extern int Sqlitetestschema_Init(Tcl_Interp*); extern int Sqlitetestsse_Init(Tcl_Interp*); extern int Sqlitetesttclvar_Init(Tcl_Interp*); extern int SqlitetestThread_Init(Tcl_Interp*); extern int SqlitetestOnefile_Init(); extern int SqlitetestOsinst_Init(Tcl_Interp*); extern int Sqlitetestintarray_Init(Tcl_Interp*); extern int Sqlitetestvfs_Init(Tcl_Interp *); extern int Sqlitetestrtree_Init(Tcl_Interp*); extern int Sqlitequota_Init(Tcl_Interp*); extern int SqliteSuperlock_Init(Tcl_Interp*); extern int SqlitetestSyscall_Init(Tcl_Interp*); extern int Sqlitetestfuzzer_Init(Tcl_Interp*); |
︙ | ︙ | |||
3662 3663 3664 3665 3666 3667 3668 | #ifdef SQLITE_ENABLE_ZIPVFS extern int Zipvfs_Init(Tcl_Interp*); Zipvfs_Init(interp); #endif Sqliteconfig_Init(interp); Sqlitetest1_Init(interp); | < < < < < < < < | 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 | #ifdef SQLITE_ENABLE_ZIPVFS extern int Zipvfs_Init(Tcl_Interp*); Zipvfs_Init(interp); #endif Sqliteconfig_Init(interp); Sqlitetest1_Init(interp); Sqlitetest4_Init(interp); Sqlitetest5_Init(interp); Sqlitetest6_Init(interp); Sqlitetest7_Init(interp); Sqlitetest8_Init(interp); Sqlitetest9_Init(interp); Sqlitetest_demovfs_Init(interp); Sqlitetest_hexio_Init(interp); Sqlitetest_init_Init(interp); Sqlitetest_malloc_Init(interp); Sqlitetest_mutex_Init(interp); Sqlitetestschema_Init(interp); Sqlitetesttclvar_Init(interp); SqlitetestThread_Init(interp); SqlitetestOnefile_Init(interp); SqlitetestOsinst_Init(interp); Sqlitetestintarray_Init(interp); Sqlitetestvfs_Init(interp); Sqlitetestrtree_Init(interp); Sqlitetestfuzzer_Init(interp); Sqlitetestwholenumber_Init(interp); Sqliteteststorage_Init(interp); #if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) Sqlitetestfts3_Init(interp); #endif |
︙ | ︙ |
Changes to src/test1.c.
︙ | ︙ | |||
1458 1459 1460 1461 1462 1463 1464 | d = (d<<32) + x1; memcpy(&r, &d, sizeof(r)); z = sqlite4_mprintf(argv[1], r); Tcl_AppendResult(interp, z, 0); sqlite4_free(z); return TCL_OK; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 | d = (d<<32) + x1; memcpy(&r, &d, sizeof(r)); z = sqlite4_mprintf(argv[1], r); Tcl_AppendResult(interp, z, 0); sqlite4_free(z); return TCL_OK; } /* ** Usage: sqlite4_extended_result_codes DB BOOLEAN ** */ static int test_extended_result_codes( ClientData clientData, /* Pointer to sqlite4_enable_XXX function */ |
︙ | ︙ | |||
1589 1590 1591 1592 1593 1594 1595 | Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(autoincrement)); Tcl_SetObjResult(interp, pRet); return TCL_OK; } #endif | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 | Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(autoincrement)); Tcl_SetObjResult(interp, pRet); return TCL_OK; } #endif /* ** Usage: sqlite4_create_collation DB-HANDLE NAME CMP-PROC DEL-PROC ** ** This Tcl proc is used for testing the experimental ** sqlite4_create_collation() interface. */ |
︙ | ︙ | |||
2004 2005 2006 2007 2008 2009 2010 | Tcl_ResetResult(interp); Tcl_AppendResult(interp, sqlite4TestErrorName(rc), 0); return TCL_ERROR; } return TCL_OK; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 | Tcl_ResetResult(interp); Tcl_AppendResult(interp, sqlite4TestErrorName(rc), 0); return TCL_ERROR; } return TCL_OK; } /* ** Usage: sqlite_abort ** ** Shutdown the process immediately. This is not a clean shutdown. ** This command is used to test the recoverability of a database in ** the event of a program crash. |
︙ | ︙ | |||
2376 2377 2378 2379 2380 2381 2382 | Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetStringFromObj(objv[0], 0), " STMT", 0); return TCL_ERROR; } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; rc = sqlite4_stmt_readonly(pStmt); | | | 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 | Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetStringFromObj(objv[0], 0), " STMT", 0); return TCL_ERROR; } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; rc = sqlite4_stmt_readonly(pStmt); Tcl_SetObjResult(interp, Tcl_NewBooleanObj(((Vdbe *)pStmt)->needSavepoint)); return TCL_OK; } /* ** Usage: sqlite4_reset STMT ** |
︙ | ︙ | |||
4625 4626 4627 4628 4629 4630 4631 | } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; rc = sqlite4_db_release_memory(db); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return TCL_OK; } | < < < < < < < < < < < < < < < < < < < < < < < | 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 | } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; rc = sqlite4_db_release_memory(db); Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return TCL_OK; } /* ** Usage: sqlite4_soft_heap_limit ?N? ** ** Query or set the soft heap limit for the current thread. The ** limit is only changed if the N is present. The previous limit ** is returned. */ |
︙ | ︙ | |||
4675 4676 4677 4678 4679 4680 4681 | if( Tcl_GetWideIntFromObj(interp, objv[1], &N) ) return TCL_ERROR; } amt = sqlite4_soft_heap_limit64(N); Tcl_SetObjResult(interp, Tcl_NewWideIntObj(amt)); return TCL_OK; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 | if( Tcl_GetWideIntFromObj(interp, objv[1], &N) ) return TCL_ERROR; } amt = sqlite4_soft_heap_limit64(N); Tcl_SetObjResult(interp, Tcl_NewWideIntObj(amt)); return TCL_OK; } /* ** tclcmd: working_64bit_int ** ** Some TCL builds (ex: cygwin) do not support 64-bit integers. This ** leads to a number of test failures. The present command checks the ** TCL build to see whether or not it supports 64-bit integers. It |
︙ | ︙ | |||
4933 4934 4935 4936 4937 4938 4939 | for(i=0; i<nVfs; i++){ sqlite4_vfs_register(apVfs[i], i==0); } return TCL_OK; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 | for(i=0; i<nVfs; i++){ sqlite4_vfs_register(apVfs[i], i==0); } return TCL_OK; } /* ** tclcmd: sqlite4_vfs_list ** ** Return a tcl list containing the names of all registered vfs's. */ static int vfs_list( |
︙ | ︙ | |||
5411 5412 5413 5414 5415 5416 5417 | int objc, /* Number of arguments */ Tcl_Obj *CONST objv[] /* Command arguments */ ){ sqlite4_test_control(SQLITE_TESTCTRL_PRNG_RESET); return TCL_OK; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 | int objc, /* Number of arguments */ Tcl_Obj *CONST objv[] /* Command arguments */ ){ sqlite4_test_control(SQLITE_TESTCTRL_PRNG_RESET); return TCL_OK; } #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY static void test_unlock_notify_cb(void **aArg, int nArg){ int ii; for(ii=0; ii<nArg; ii++){ Tcl_EvalEx((Tcl_Interp *)aArg[ii], "unlock_notify", -1, TCL_EVAL_GLOBAL); } |
︙ | ︙ | |||
5942 5943 5944 5945 5946 5947 5948 | extern int sqlite4_open_file_count; extern int sqlite4_sort_count; extern int sqlite4_current_time; #if SQLITE_OS_UNIX && defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE extern int sqlite4_hostid_num; #endif extern int sqlite4_max_blobsize; | < < | 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 | extern int sqlite4_open_file_count; extern int sqlite4_sort_count; extern int sqlite4_current_time; #if SQLITE_OS_UNIX && defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE extern int sqlite4_hostid_num; #endif extern int sqlite4_max_blobsize; static struct { char *zName; Tcl_CmdProc *xProc; } aCmd[] = { { "db_enter", (Tcl_CmdProc*)db_enter }, { "db_leave", (Tcl_CmdProc*)db_leave }, { "sqlite4_mprintf_int", (Tcl_CmdProc*)sqlite4_mprintf_int }, |
︙ | ︙ | |||
6037 6038 6039 6040 6041 6042 6043 | { "sqlite4_next_stmt", test_next_stmt ,0 }, { "sqlite4_stmt_readonly", test_stmt_readonly ,0 }, { "sqlite4_stmt_busy", test_stmt_busy ,0 }, { "uses_stmt_journal", uses_stmt_journal ,0 }, { "sqlite4_release_memory", test_release_memory, 0}, { "sqlite4_db_release_memory", test_db_release_memory, 0}, | < < < < < | 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 | { "sqlite4_next_stmt", test_next_stmt ,0 }, { "sqlite4_stmt_readonly", test_stmt_readonly ,0 }, { "sqlite4_stmt_busy", test_stmt_busy ,0 }, { "uses_stmt_journal", uses_stmt_journal ,0 }, { "sqlite4_release_memory", test_release_memory, 0}, { "sqlite4_db_release_memory", test_db_release_memory, 0}, { "sqlite4_soft_heap_limit", test_soft_heap_limit, 0}, { "sqlite4_extended_result_codes", test_extended_result_codes, 0}, { "sqlite4_limit", test_limit, 0}, { "save_prng_state", save_prng_state, 0 }, { "restore_prng_state", restore_prng_state, 0 }, { "reset_prng_state", reset_prng_state, 0 }, { "optimization_control", optimization_control,0}, |
︙ | ︙ | |||
6098 6099 6100 6101 6102 6103 6104 | { "sqlite4_create_collation", test_create_collation, 0 }, { "sqlite4_global_recover", test_global_recover, 0 }, { "working_64bit_int", working_64bit_int, 0 }, { "vfs_unlink_test", vfs_unlink_test, 0 }, { "vfs_initfail_test", vfs_initfail_test, 0 }, { "vfs_unregister_all", vfs_unregister_all, 0 }, { "vfs_reregister_all", vfs_reregister_all, 0 }, | < < < < < < < < < < < < < < < < < < < < < < < < < < < | 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 | { "sqlite4_create_collation", test_create_collation, 0 }, { "sqlite4_global_recover", test_global_recover, 0 }, { "working_64bit_int", working_64bit_int, 0 }, { "vfs_unlink_test", vfs_unlink_test, 0 }, { "vfs_initfail_test", vfs_initfail_test, 0 }, { "vfs_unregister_all", vfs_unregister_all, 0 }, { "vfs_reregister_all", vfs_reregister_all, 0 }, { "sqlite4_vfs_list", vfs_list, 0 }, { "sqlite4_create_function_v2", test_create_function_v2, 0 }, /* Functions from os.h */ #ifndef SQLITE_OMIT_UTF16 { "add_test_collate", test_collate, 0 }, { "add_test_collate_needed", test_collate_needed, 0 }, { "add_test_function", test_function, 0 }, #endif { "sqlite4_test_errstr", test_errstr, 0 }, { "tcl_variable_type", tcl_variable_type, 0 }, { "sqlite4_libversion_number", test_libversion_number, 0 }, { "sqlite4_wal_checkpoint", test_wal_checkpoint, 0 }, { "sqlite4_wal_checkpoint_v2",test_wal_checkpoint_v2, 0 }, { "test_sqlite4_log", test_sqlite4_log, 0 }, #ifndef SQLITE_OMIT_EXPLAIN { "print_explain_query_plan", test_print_eqp, 0 }, #endif { "sqlite4_test_control", test_test_control }, |
︙ | ︙ | |||
6200 6201 6202 6203 6204 6205 6206 | (char*)&sqlite4_current_time, TCL_LINK_INT); #if SQLITE_OS_UNIX && defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE Tcl_LinkVar(interp, "sqlite_hostid_num", (char*)&sqlite4_hostid_num, TCL_LINK_INT); #endif Tcl_LinkVar(interp, "sqlite4_xferopt_count", (char*)&sqlite4_xferopt_count, TCL_LINK_INT); | < < < < < < | 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 | (char*)&sqlite4_current_time, TCL_LINK_INT); #if SQLITE_OS_UNIX && defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE Tcl_LinkVar(interp, "sqlite_hostid_num", (char*)&sqlite4_hostid_num, TCL_LINK_INT); #endif Tcl_LinkVar(interp, "sqlite4_xferopt_count", (char*)&sqlite4_xferopt_count, TCL_LINK_INT); #ifndef SQLITE_OMIT_UTF16 Tcl_LinkVar(interp, "unaligned_string_counter", (char*)&unaligned_string_counter, TCL_LINK_INT); #endif #ifndef SQLITE_OMIT_UTF16 Tcl_LinkVar(interp, "sqlite_last_needed_collation", (char*)&pzNeededCollation, TCL_LINK_STRING|TCL_LINK_READ_ONLY); |
︙ | ︙ | |||
6227 6228 6229 6230 6231 6232 6233 | (char*)&query_plan, TCL_LINK_STRING|TCL_LINK_READ_ONLY); #endif #ifdef SQLITE_DEBUG Tcl_LinkVar(interp, "sqlite_addop_trace", (char*)&sqlite4VdbeAddopTrace, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite_where_trace", (char*)&sqlite4WhereTrace, TCL_LINK_INT); | < < < < < < < < < < | 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 | (char*)&query_plan, TCL_LINK_STRING|TCL_LINK_READ_ONLY); #endif #ifdef SQLITE_DEBUG Tcl_LinkVar(interp, "sqlite_addop_trace", (char*)&sqlite4VdbeAddopTrace, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite_where_trace", (char*)&sqlite4WhereTrace, TCL_LINK_INT); #endif Tcl_LinkVar(interp, "sqlite_static_bind_value", (char*)&sqlite_static_bind_value, TCL_LINK_STRING); Tcl_LinkVar(interp, "sqlite_static_bind_nbyte", (char*)&sqlite_static_bind_nbyte, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite_temp_directory", (char*)&sqlite4_temp_directory, TCL_LINK_STRING); |
︙ | ︙ |
Deleted src/test2.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/test3.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/test4.c.
︙ | ︙ | |||
90 91 92 93 94 95 96 | p->db = 0; } if( p->zErr && p->zErr!=p->zStaticErr ){ sqlite4_free(p->zErr); p->zErr = 0; } p->completed++; | < < < | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | p->db = 0; } if( p->zErr && p->zErr!=p->zStaticErr ){ sqlite4_free(p->zErr); p->zErr = 0; } p->completed++; return 0; } /* ** Get a thread ID which is an upper case letter. Return the index. ** If the argument is not a valid thread ID put an error message in ** the interpreter and return -1. |
︙ | ︙ |
Changes to src/test7.c.
︙ | ︙ | |||
112 113 114 115 116 117 118 | p->db = 0; } if( p->zErr && p->zErr!=p->zStaticErr ){ sqlite4_free(p->zErr); p->zErr = 0; } p->completed++; | < < < | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | p->db = 0; } if( p->zErr && p->zErr!=p->zStaticErr ){ sqlite4_free(p->zErr); p->zErr = 0; } p->completed++; return 0; } /* ** Get a thread ID which is an upper case letter. Return the index. ** If the argument is not a valid thread ID put an error message in ** the interpreter and return -1. |
︙ | ︙ |
Deleted src/test_autoext.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/test_backup.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/test_btree.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/test_config.c.
︙ | ︙ | |||
315 316 317 318 319 320 321 | #ifdef SQLITE_ENABLE_ICU Tcl_SetVar2(interp, "sqlite_options", "icu", "1", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "sqlite_options", "icu", "0", TCL_GLOBAL_ONLY); #endif | < < < < < < | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | #ifdef SQLITE_ENABLE_ICU Tcl_SetVar2(interp, "sqlite_options", "icu", "1", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "sqlite_options", "icu", "0", TCL_GLOBAL_ONLY); #endif #ifdef SQLITE_OMIT_INTEGRITY_CHECK Tcl_SetVar2(interp, "sqlite_options", "integrityck", "0", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "sqlite_options", "integrityck", "1", TCL_GLOBAL_ONLY); #endif #if defined(SQLITE_DEFAULT_FILE_FORMAT) && SQLITE_DEFAULT_FILE_FORMAT==1 |
︙ | ︙ |
Deleted src/test_loadext.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/test_malloc.c.
︙ | ︙ | |||
992 993 994 995 996 997 998 | return TCL_ERROR; } if( discardChance<0 || discardChance>100 ){ Tcl_AppendResult(interp, "discard-chance should be between 0 and 100", (char*)0); return TCL_ERROR; } | < < | 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 | return TCL_ERROR; } if( discardChance<0 || discardChance>100 ){ Tcl_AppendResult(interp, "discard-chance should be between 0 and 100", (char*)0); return TCL_ERROR; } return TCL_OK; } /* ** Usage: sqlite4_config_memstatus BOOLEAN ** ** Enable or disable memory status reporting using SQLITE_CONFIG_MEMSTATUS. |
︙ | ︙ | |||
1397 1398 1399 1400 1401 1402 1403 | const sqlite4_mem_methods *sqlite4MemGetMemsys3(void); rc = sqlite4_config(SQLITE_CONFIG_MALLOC, sqlite4MemGetMemsys3()); #endif Tcl_SetResult(interp, (char *)sqlite4TestErrorName(rc), TCL_VOLATILE); return TCL_OK; } | < < < < < < < < < < < < < < < < < < < | 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 | const sqlite4_mem_methods *sqlite4MemGetMemsys3(void); rc = sqlite4_config(SQLITE_CONFIG_MALLOC, sqlite4MemGetMemsys3()); #endif Tcl_SetResult(interp, (char *)sqlite4TestErrorName(rc), TCL_VOLATILE); return TCL_OK; } /* ** Register commands with the TCL interpreter. */ int Sqlitetest_malloc_Init(Tcl_Interp *interp){ static struct { char *zName; Tcl_ObjCmdProc *xProc; |
︙ | ︙ | |||
1454 1455 1456 1457 1458 1459 1460 | { "sqlite4_config_lookaside", test_config_lookaside ,0 }, { "sqlite4_config_error", test_config_error ,0 }, { "sqlite4_config_uri", test_config_uri ,0 }, { "sqlite4_db_config_lookaside",test_db_config_lookaside ,0 }, { "sqlite4_dump_memsys3", test_dump_memsys3 ,3 }, { "sqlite4_dump_memsys5", test_dump_memsys3 ,5 }, { "sqlite4_install_memsys3", test_install_memsys3 ,0 }, | < | 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 | { "sqlite4_config_lookaside", test_config_lookaside ,0 }, { "sqlite4_config_error", test_config_error ,0 }, { "sqlite4_config_uri", test_config_uri ,0 }, { "sqlite4_db_config_lookaside",test_db_config_lookaside ,0 }, { "sqlite4_dump_memsys3", test_dump_memsys3 ,3 }, { "sqlite4_dump_memsys5", test_dump_memsys3 ,5 }, { "sqlite4_install_memsys3", test_install_memsys3 ,0 }, }; int i; for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ ClientData c = (ClientData)SQLITE_INT_TO_PTR(aObjCmd[i].clientData); Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, c, 0); } return TCL_OK; } #endif |
Changes to src/test_schema.c.
︙ | ︙ | |||
26 27 28 29 30 31 32 | "name," /* Column name */ \ "type," /* Specified type (i.e. VARCHAR(32)) */ \ "not_null," /* Boolean. True if NOT NULL was specified */ \ "dflt_value," /* Default value for this column */ \ "pk" /* True if this column is part of the primary key */ \ ")" | < < < < < | | < < < < | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | "name," /* Column name */ \ "type," /* Specified type (i.e. VARCHAR(32)) */ \ "not_null," /* Boolean. True if NOT NULL was specified */ \ "dflt_value," /* Default value for this column */ \ "pk" /* True if this column is part of the primary key */ \ ")" #include "sqliteInt.h" #include "tcl.h" #include <stdlib.h> #include <string.h> #include <assert.h> typedef struct schema_vtab schema_vtab; typedef struct schema_cursor schema_cursor; |
︙ | ︙ |
Deleted src/test_server.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/test_storage.c.
︙ | ︙ | |||
25 26 27 28 29 30 31 | */ static void storageSetTclErrorName(Tcl_Interp *interp, int rc){ extern const char *sqlite4TestErrorName(int); Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite4TestErrorName(rc), -1)); } /* | | > > | | > > | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | */ static void storageSetTclErrorName(Tcl_Interp *interp, int rc){ extern const char *sqlite4TestErrorName(int); Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite4TestErrorName(rc), -1)); } /* ** TCLCMD: storage_open URI FLAGS ** ** Return a string that identifies the new storage object. */ static int test_storage_open( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ KVStore *pNew = 0; int rc; int flags; sqlite4 db; char zRes[50]; if( objc!=3 ){ Tcl_WrongNumArgs(interp, 2, objv, "URI FLAGS"); return TCL_ERROR; } if( Tcl_GetIntFromObj(interp, objv[2], &flags) ) return TCL_ERROR; memset(&db, 0, sizeof(db)); rc = sqlite4KVStoreOpen(&db, "test", Tcl_GetString(objv[1]), &pNew, flags); if( rc ){ sqlite4KVStoreClose(pNew); storageSetTclErrorName(interp, rc); return TCL_ERROR; } sqlite4_snprintf(sizeof(zRes),zRes, "%p", pNew); Tcl_SetObjResult(interp, Tcl_NewStringObj(zRes,-1)); |
︙ | ︙ | |||
223 224 225 226 227 228 229 | int iLevel; if( objc!=3 ){ Tcl_WrongNumArgs(interp, 2, objv, "STORAGE LEVEL"); return TCL_ERROR; } p = sqlite4TestTextToPtr(Tcl_GetString(objv[1])); if( Tcl_GetIntFromObj(interp, objv[2], &iLevel) ) return TCL_ERROR; | | > > > > > | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | int iLevel; if( objc!=3 ){ Tcl_WrongNumArgs(interp, 2, objv, "STORAGE LEVEL"); return TCL_ERROR; } p = sqlite4TestTextToPtr(Tcl_GetString(objv[1])); if( Tcl_GetIntFromObj(interp, objv[2], &iLevel) ) return TCL_ERROR; rc = sqlite4KVStoreCommitPhaseOne(p, iLevel); if( rc ){ storageSetTclErrorName(interp, rc); return TCL_ERROR; } rc = sqlite4KVStoreCommitPhaseTwo(p, iLevel); if( rc ){ storageSetTclErrorName(interp, rc); return TCL_ERROR; } return TCL_OK; } |
︙ | ︙ |
Deleted src/test_superlock.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/test_syscall.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/trigger.c.
︙ | ︙ | |||
50 51 52 53 54 55 56 | if( pParse->disableTriggers ){ return 0; } if( pTmpSchema!=pTab->pSchema ){ HashElem *p; | < | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | if( pParse->disableTriggers ){ return 0; } if( pTmpSchema!=pTab->pSchema ){ HashElem *p; for(p=sqliteHashFirst(&pTmpSchema->trigHash); p; p=sqliteHashNext(p)){ Trigger *pTrig = (Trigger *)sqliteHashData(p); if( pTrig->pTabSchema==pTab->pSchema && 0==sqlite4StrICmp(pTrig->table, pTab->zName) ){ pTrig->pNext = (pList ? pList : pTab->pTrigger); pList = pTrig; |
︙ | ︙ | |||
175 176 177 178 179 180 181 | /* Check that the trigger name is not reserved and that no trigger of the ** specified name exists */ zName = sqlite4NameFromToken(db, pName); if( !zName || SQLITE_OK!=sqlite4CheckObjectName(pParse, zName) ){ goto trigger_cleanup; } | < | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | /* Check that the trigger name is not reserved and that no trigger of the ** specified name exists */ zName = sqlite4NameFromToken(db, pName); if( !zName || SQLITE_OK!=sqlite4CheckObjectName(pParse, zName) ){ goto trigger_cleanup; } if( sqlite4HashFind(&(db->aDb[iDb].pSchema->trigHash), zName, sqlite4Strlen30(zName)) ){ if( !noErr ){ sqlite4ErrorMsg(pParse, "trigger %T already exists", pName); }else{ assert( !db->init.busy ); sqlite4CodeVerifySchema(pParse, iDb); |
︙ | ︙ | |||
317 318 319 320 321 322 323 | sqlite4VdbeAddParseSchemaOp(v, iDb, sqlite4MPrintf(db, "type='trigger' AND name='%q'", zName)); } if( db->init.busy ){ Trigger *pLink = pTrig; Hash *pHash = &db->aDb[iDb].pSchema->trigHash; | < | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | sqlite4VdbeAddParseSchemaOp(v, iDb, sqlite4MPrintf(db, "type='trigger' AND name='%q'", zName)); } if( db->init.busy ){ Trigger *pLink = pTrig; Hash *pHash = &db->aDb[iDb].pSchema->trigHash; pTrig = sqlite4HashInsert(pHash, zName, sqlite4Strlen30(zName), pTrig); if( pTrig ){ db->mallocFailed = 1; }else if( pLink->pSchema==pLink->pTabSchema ){ Table *pTab; int n = sqlite4Strlen30(pLink->table); pTab = sqlite4HashFind(&pLink->pTabSchema->tblHash, pLink->table, n); |
︙ | ︙ | |||
499 500 501 502 503 504 505 | goto drop_trigger_cleanup; } assert( pName->nSrc==1 ); zDb = pName->a[0].zDatabase; zName = pName->a[0].zName; nName = sqlite4Strlen30(zName); | < < | 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | goto drop_trigger_cleanup; } assert( pName->nSrc==1 ); zDb = pName->a[0].zDatabase; zName = pName->a[0].zName; nName = sqlite4Strlen30(zName); for(i=OMIT_TEMPDB; i<db->nDb; i++){ int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */ if( zDb && sqlite4StrICmp(db->aDb[j].zName, zDb) ) continue; pTrigger = sqlite4HashFind(&(db->aDb[j].pSchema->trigHash), zName, nName); if( pTrigger ) break; } if( !pTrigger ){ if( !noErr ){ sqlite4ErrorMsg(pParse, "no such trigger: %S", pName, 0); }else{ |
︙ | ︙ | |||
597 598 599 600 601 602 603 | /* ** Remove a trigger from the hash tables of the sqlite* pointer. */ void sqlite4UnlinkAndDeleteTrigger(sqlite4 *db, int iDb, const char *zName){ Trigger *pTrigger; Hash *pHash; | < | 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | /* ** Remove a trigger from the hash tables of the sqlite* pointer. */ void sqlite4UnlinkAndDeleteTrigger(sqlite4 *db, int iDb, const char *zName){ Trigger *pTrigger; Hash *pHash; pHash = &(db->aDb[iDb].pSchema->trigHash); pTrigger = sqlite4HashInsert(pHash, zName, sqlite4Strlen30(zName), 0); if( ALWAYS(pTrigger) ){ if( pTrigger->pSchema==pTrigger->pTabSchema ){ Table *pTab = tableOfTrigger(pTrigger); Trigger **pp; for(pp=&pTab->pTrigger; *pp!=pTrigger; pp=&((*pp)->pNext)); |
︙ | ︙ |
Changes to src/update.c.
︙ | ︙ | |||
640 641 642 643 644 645 646 | /* Create the ephemeral table into which the update results will ** be stored. */ assert( v ); ephemTab = pParse->nTab++; sqlite4VdbeAddOp2(v, OP_OpenEphemeral, ephemTab, pTab->nCol+1+(pRowid!=0)); | < | 640 641 642 643 644 645 646 647 648 649 650 651 652 653 | /* Create the ephemeral table into which the update results will ** be stored. */ assert( v ); ephemTab = pParse->nTab++; sqlite4VdbeAddOp2(v, OP_OpenEphemeral, ephemTab, pTab->nCol+1+(pRowid!=0)); /* fill the ephemeral table */ sqlite4SelectDestInit(&dest, SRT_Table, ephemTab); sqlite4Select(pParse, pSelect, &dest); /* Generate code to scan the ephemeral table and call VUpdate. */ |
︙ | ︙ |
Changes to src/varint.c.
︙ | ︙ | |||
92 93 94 95 96 97 98 | ** 8 2**56-1 16.8 ** 9 2**64-1 19.2 ** */ #include "sqliteInt.h" /* | | | > > > | > > > > > > > | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | ** 8 2**56-1 16.8 ** 9 2**64-1 19.2 ** */ #include "sqliteInt.h" /* ** Decode the varint in the first n bytes z[]. Write the integer value ** into *pResult and return the number of bytes in the varint. ** ** If the decode fails because there are not enough bytes in z[] then ** return 0; */ int sqlite4GetVarint64( const unsigned char *z, int n, sqlite4_uint64 *pResult ){ unsigned int x; if( n<1 ) return 0; if( z[0]<=240 ){ *pResult = z[0]; return 1; } if( z[0]<=248 ){ if( n<2 ) return 0; *pResult = (z[0]-241)*256 + z[1] + 240; return 2; } if( n<z[0]-246 ) return 0; if( z[0]==249 ){ *pResult = 2288 + 256*z[1] + z[2]; return 3; } if( z[0]==250 ){ *pResult = (z[1]<<16) + (z[2]<<8) + z[3]; return 4; |
︙ | ︙ | |||
240 241 242 243 244 245 246 | x = (x<<32) + randInt(); nbit = randInt()%65; if( nbit<64 ){ x &= (((sqlite4_uint64)1)<<nbit)-1; } n1 = sqlite4PutVarint64(z, x); assert( n1>=1 && n1<=9 ); | | > > | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | x = (x<<32) + randInt(); nbit = randInt()%65; if( nbit<64 ){ x &= (((sqlite4_uint64)1)<<nbit)-1; } n1 = sqlite4PutVarint64(z, x); assert( n1>=1 && n1<=9 ); n2 = sqlite4GetVarint64(z, n1, &y); assert( n1==n2 ); assert( x==y ); n2 = sqlite4GetVarint64(z, n1-1, &y); assert( n2==0 ); if( i>0 ){ int c = memcmp(z,zp,pn<n1?pn:n1); if( x<px ){ assert( c<0 ); }else if( x>px ){ assert( c>0 ); }else{ |
︙ | ︙ |
Changes to src/vdbe.c.
︙ | ︙ | |||
187 188 189 190 191 192 193 | ** if we run out of memory. */ static VdbeCursor *allocateCursor( Vdbe *p, /* The virtual machine */ int iCur, /* Index of the new VdbeCursor */ int nField, /* Number of fields in the table or index */ int iDb, /* Database the cursor belongs to, or -1 */ | | | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | ** if we run out of memory. */ static VdbeCursor *allocateCursor( Vdbe *p, /* The virtual machine */ int iCur, /* Index of the new VdbeCursor */ int nField, /* Number of fields in the table or index */ int iDb, /* Database the cursor belongs to, or -1 */ int isTrueCursor /* True real cursor. False for pseudo-table or vtab */ ){ /* Find the memory cell that will be used to store the blob of memory ** required for this VdbeCursor structure. It is convenient to use a ** vdbe memory cell to manage the memory allocation required for a ** VdbeCursor structure for the following reasons: ** ** * Sometimes cursor numbers are used for a couple of different |
︙ | ︙ | |||
213 214 215 216 217 218 219 | */ Mem *pMem = &p->aMem[p->nMem-iCur]; int nByte; VdbeCursor *pCx = 0; nByte = ROUND8(sizeof(VdbeCursor)) + | < < < < < < < < < | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | */ Mem *pMem = &p->aMem[p->nMem-iCur]; int nByte; VdbeCursor *pCx = 0; nByte = ROUND8(sizeof(VdbeCursor)) + 2*nField*sizeof(u32); assert( iCur<p->nCursor ); if( p->apCsr[iCur] ){ sqlite4VdbeFreeCursor(p, p->apCsr[iCur]); p->apCsr[iCur] = 0; } if( SQLITE_OK==sqlite4VdbeMemGrow(pMem, nByte, 0) ){ p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z; memset(pCx, 0, sizeof(VdbeCursor)); pCx->iDb = iDb; pCx->nField = nField; } return pCx; } /* ** Try to convert a value into a numeric representation if we can ** do so without loss of information. In other words, if the string |
︙ | ︙ | |||
474 475 476 477 478 479 480 | ** implement a loop. This test used to be on every single instruction, ** but that meant we more testing than we needed. By only testing the ** flag on jump instructions, we get a (small) speed improvement. */ #define CHECK_FOR_INTERRUPT \ if( db->u1.isInterrupted ) goto abort_due_to_interrupt; | < < < < < < < < < < < < < < < < < < < < < | 465 466 467 468 469 470 471 472 473 474 475 476 477 478 | ** implement a loop. This test used to be on every single instruction, ** but that meant we more testing than we needed. By only testing the ** flag on jump instructions, we get a (small) speed improvement. */ #define CHECK_FOR_INTERRUPT \ if( db->u1.isInterrupted ) goto abort_due_to_interrupt; /* ** Transfer error message text from an sqlite4_vtab.zErrMsg (text stored ** in memory obtained from sqlite4_malloc) into a Vdbe.zErrMsg (text stored ** in memory obtained from sqlite4DbMalloc). */ static void importVtabErrMsg(Vdbe *p, sqlite4_vtab *pVtab){ sqlite4 *db = p->db; |
︙ | ︙ | |||
569 570 571 572 573 574 575 | #ifdef VDBE_PROFILE u64 start; /* CPU clock count at start of opcode */ int origPc; /* Program counter at start of opcode */ #endif /*** INSERT STACK UNION HERE ***/ assert( p->magic==VDBE_MAGIC_RUN ); /* sqlite4_step() verifies this */ | < | 539 540 541 542 543 544 545 546 547 548 549 550 551 552 | #ifdef VDBE_PROFILE u64 start; /* CPU clock count at start of opcode */ int origPc; /* Program counter at start of opcode */ #endif /*** INSERT STACK UNION HERE ***/ assert( p->magic==VDBE_MAGIC_RUN ); /* sqlite4_step() verifies this */ if( p->rc==SQLITE_NOMEM ){ /* This happens if a malloc() inside a call to sqlite4_column_text() or ** sqlite4_column_text16() failed. */ goto no_mem; } assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY ); p->rc = SQLITE_OK; |
︙ | ︙ | |||
1112 1113 1114 1115 1116 1117 1118 | assert( pOp->p1+pOp->p2<=p->nMem+1 ); /* If this statement has violated immediate foreign key constraints, do ** not return the number of rows modified. And do not RELEASE the statement ** transaction. It needs to be rolled back. */ if( SQLITE_OK!=(rc = sqlite4VdbeCheckFk(p, 0)) ){ assert( db->flags&SQLITE_CountRows ); | | < | 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 | assert( pOp->p1+pOp->p2<=p->nMem+1 ); /* If this statement has violated immediate foreign key constraints, do ** not return the number of rows modified. And do not RELEASE the statement ** transaction. It needs to be rolled back. */ if( SQLITE_OK!=(rc = sqlite4VdbeCheckFk(p, 0)) ){ assert( db->flags&SQLITE_CountRows ); assert( p->needSavepoint ); break; } /* If the SQLITE_CountRows flag is set in sqlite4.flags mask, then ** DML statements invoke this opcode to return the number of rows ** modified to the user. This is the only way that a VM that ** opens a statement transaction may invoke this opcode. ** ** In case this is such a statement, close any statement transaction ** opened by this VM before returning control to the user. This is to ** ensure that statement-transactions are always nested, not overlapping. ** If the open statement-transaction is not closed here, then the user ** may step another VM that opens its own statement transaction. This ** may lead to overlapping statement transactions. ** ** The statement transaction is never a top-level transaction. Hence ** the RELEASE call below can never fail. */ rc = sqlite4VdbeCloseStatement(p, SAVEPOINT_RELEASE); if( NEVER(rc!=SQLITE_OK) ){ break; } /* Invalidate all ephemeral cursor row caches */ p->cacheCtr = (p->cacheCtr + 2)|1; |
︙ | ︙ | |||
1817 1818 1819 1820 1821 1822 1823 | if( affinity ){ applyAffinity(pIn1, affinity, encoding); applyAffinity(pIn3, affinity, encoding); if( db->mallocFailed ) goto no_mem; } assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 ); | < < | 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 | if( affinity ){ applyAffinity(pIn1, affinity, encoding); applyAffinity(pIn3, affinity, encoding); if( db->mallocFailed ) goto no_mem; } assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 ); res = sqlite4MemCompare(pIn3, pIn1, pOp->p4.pColl); } switch( pOp->opcode ){ case OP_Eq: res = res==0; break; case OP_Ne: res = res!=0; break; case OP_Lt: res = res<0; break; case OP_Le: res = res<=0; break; |
︙ | ︙ | |||
2118 2119 2120 2121 2122 2123 2124 | ** ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor, ** then the cache of the cursor is reset prior to extracting the column. ** The first OP_Column against a pseudo-table after the value of the content ** register has changed should have this bit set. */ case OP_Column: { | | | | < | < < < < < < < < | | | < < < < < | | < < < < < < < < < < < < < < < < < < | | < < < | < < < < < < < < < < < < | < < | | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < | < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < | < < < < < < < < < < < < < | < < < | < < < < < | < < | < < < < < < < < < < < < < < < < < < < < | 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 | ** ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor, ** then the cache of the cursor is reset prior to extracting the column. ** The first OP_Column against a pseudo-table after the value of the content ** register has changed should have this bit set. */ case OP_Column: { KVCursor *pKVCur; /* Cursor for current entry in the KV storage */ ValueDecoder *pCodec; /* The decoder object */ int p1; /* Index of VdbeCursor to decode */ VdbeCursor *pC; /* The VDBE cursor */ Mem *pDest; /* Where to write the results */ const KVByteArray *aData; /* The content to be decoded */ KVSize nData; /* Size of aData[] in bytes */ Mem *pDefault; /* Default value from P4 */ Mem *pReg; /* */ p1 = pOp->p1; assert( p1<p->nCursor ); assert( pOp->p3>0 && pOp->p3<=p->nMem ); pDest = &aMem[pOp->p3]; memAboutToChange(p, pDest); pC = p->apCsr[p1]; assert( pC!=0 ); #ifndef SQLITE_OMIT_VIRTUALTABLE assert( pC->pVtabCursor==0 ); #endif pKVCur = pC->pKVCur; if( pKVCur!=0 ){ if( pC->nullRow ){ aData = 0; }else{ rc = sqlite4KVCursorData(pKVCur, 0, -1, &aData, &nData); } }else if( ALWAYS(pC->pseudoTableReg>0) ){ pReg = &aMem[pC->pseudoTableReg]; assert( pReg->flags & MEM_Blob ); assert( memIsValid(pReg) ); aData = (const KVByteArray*)pReg->z; nData = pReg->n; }else{ aData = 0; MemSetTypeFlag(pDest, MEM_Null); } if( rc==SQLITE_OK && aData ){ rc = sqlite4VdbeCreateDecoder(db, aData, nData, pC->nField, &pCodec); if( rc==0 ){ pDefault = (pOp->p4type==P4_MEM) ? pOp->p4.pMem : 0; rc = sqlite4VdbeDecodeValue(pCodec, pOp->p2, pDefault, pDest); sqlite4VdbeDestroyDecoder(pCodec); } }else{ sqlite4VdbeMemSetNull(pDest); } UPDATE_MAX_BLOBSIZE(pDest); REGISTER_TRACE(pOp->p3, pDest); break; } /* Opcode: Affinity P1 P2 * P4 * ** |
︙ | ︙ | |||
2428 2429 2430 2431 2432 2433 2434 | zAffinity = pOp->p4.z; assert( zAffinity!=0 ); assert( zAffinity[pOp->p2]==0 ); pIn1 = &aMem[pOp->p1]; while( (cAff = *(zAffinity++))!=0 ){ assert( pIn1 <= &p->aMem[p->nMem] ); assert( memIsValid(pIn1) ); | < | | < < < | | < < < < < < < < > < < < > > | | < < < > > > < | | | | | | | < < < < < < < < < < < | > | | < < < | < < < < < < | | | < < < < > > | < < < < < < < < < < < | < | < < < < < < < < < < | < < < | > | < < > | < > | | > > < | | | < | < | > > > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | | < < < < < | < < | > > < | | | < > | | < < < < | | < | | | | < < < < | < < < | < < < < | | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < > > | < < < < | < < > | | < < < < | 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 | zAffinity = pOp->p4.z; assert( zAffinity!=0 ); assert( zAffinity[pOp->p2]==0 ); pIn1 = &aMem[pOp->p1]; while( (cAff = *(zAffinity++))!=0 ){ assert( pIn1 <= &p->aMem[p->nMem] ); assert( memIsValid(pIn1) ); applyAffinity(pIn1, cAff, encoding); pIn1++; } break; } /* Opcode: MakeKey P1 P2 * * * ** ** This must be followed immediately by a MakeRecord opcode. This ** opcode performs the subsequent MakeRecord and also generates ** a key for the cursor P1 and stores that key in register P2. */ /* Opcode: MakeRecord P1 P2 P3 P4 * ** ** Convert registers P1..P1+P2-1 into a data record and store the result ** in register P3. The OP_Column opcode can be used to decode the record. ** ** P4 may be a string that is P2 characters long. The nth character of the ** string indicates the column affinity that should be used for the nth ** field of the index key. ** ** The mapping from character to affinity is given by the SQLITE_AFF_ ** macros defined in sqliteInt.h. ** ** If P4 is NULL then all index fields have the affinity NONE. */ case OP_MakeKey: case OP_MakeRecord: { Mem *pData0; /* First field to be combined into the record */ Mem *pLast; /* Last field of the record */ Mem *pMem; /* For looping over inputs */ int nField; /* Number of fields in the record */ char *zAffinity; /* The affinity string for the record */ VdbeCursor *pC; /* Cursor to generate key for */ Mem *pKeyOut; /* Where to store the generated key */ int keyReg; /* Register into which to write the key */ u8 *aRec; /* The constructed key or value */ int nRec; /* Size of aRec[] in bytes */ if( pOp->opcode==OP_MakeKey ){ pC = p->apCsr[pOp->p1]; keyReg = pOp->p2; pKeyOut = &aMem[keyReg]; memAboutToChange(p, pKeyOut); assert( pC!=0 ); assert( pC->pKeyInfo!=0 ); pc++; pOp++; assert( pOp->opcode==OP_MakeRecord ); }else{ pC = 0; } nField = pOp->p1; zAffinity = pOp->p4.z; assert( nField>0 && pOp->p2>0 && pOp->p2+nField<=p->nMem+1 ); pData0 = &aMem[nField]; nField = pOp->p2; pLast = &pData0[nField-1]; /* Identify the output register */ assert( pOp->p3<pOp->p1 || pOp->p3>=pOp->p1+pOp->p2 ); pOut = &aMem[pOp->p3]; memAboutToChange(p, pOut); /* Loop through the input elements. Apply affinity to each one and ** expand all zero-blobs. */ for(pMem=pData0; pMem<=pLast; pMem++){ assert( memIsValid(pMem) ); if( zAffinity ){ applyAffinity(pMem, *(zAffinity++), encoding); } if( pMem->flags&MEM_Zero ){ sqlite4VdbeMemExpandBlob(pMem); } } /* Compute the key (if this is a MakeKey opcode) */ if( pC ){ aRec = 0; rc = sqlite4VdbeEncodeKey(db, pData0, nField, pC->iRoot, pC->pKeyInfo, &aRec, &nRec, 0); if( rc ){ sqlite4DbFree(db, aRec); }else{ rc = sqlite4VdbeMemSetStr(pKeyOut, aRec, nRec, 0, SQLITE_DYNAMIC); REGISTER_TRACE(keyReg, pKeyOut); UPDATE_MAX_BLOBSIZE(pKeyOut); } } /* Compute the value */ if( rc==SQLITE_OK ){ aRec = 0; rc = sqlite4VdbeEncodeData(db, pData0, nField, &aRec, &nRec); if( rc ){ sqlite4DbFree(db, aRec); }else{ rc = sqlite4VdbeMemSetStr(pOut, aRec, nRec, 0, SQLITE_DYNAMIC); REGISTER_TRACE(pOp->p3, pOut); UPDATE_MAX_BLOBSIZE(pOut); } } break; } /* Opcode: Count P1 P2 * * * ** ** Store the number of entries (an integer value) in the table or index ** opened by cursor P1 in register P2 */ case OP_Count: { /* out2-prerelease */ i64 nEntry; VdbeCursor *pC; pC = p->apCsr[pOp->p1]; rc = sqlite4VdbeSeekEnd(pC, +1); nEntry = 0; while( rc!=SQLITE_NOTFOUND ){ nEntry++; rc = sqlite4VdbeNext(pC); } sqlite4VdbeMemSetInt64(pOut, nEntry); break; } /* Opcode: Savepoint P1 * * P4 * ** ** Open, release or rollback the savepoint named by parameter P4, depending ** on the value of P1. To open a new savepoint, P1==0. To release (commit) an ** existing savepoint, P1==1, or to rollback an existing savepoint P1==2. */ case OP_Savepoint: { break; } /* Opcode: AutoCommit P1 P2 * * * ** ** Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll ** back any currently active btree transactions. If there are any active ** VMs (apart from this one), then a ROLLBACK fails. A COMMIT fails if ** there are active writing VMs or active VMs that use shared cache. ** ** This instruction causes the VM to halt. */ case OP_AutoCommit: { break; } /* Opcode: Transaction P1 P2 * * * ** ** Begin a transaction. ** ** P1 is the index of the database file on which the transaction is ** started. Index 0 is the main database file and index 1 is the ** file used for temporary tables. Indices of 2 or more are used for ** attached databases. ** ** If P2 is non-zero, then a write-transaction is started. If P2 is zero ** then a read-transaction is started. ** ** If a write-transaction is started and the Vdbe.needSavepoint flag is ** true (this flag is set if the Vdbe may modify more than one row and may ** throw an ABORT exception), a statement transaction may also be opened. ** More specifically, a statement transaction is opened iff the database ** connection is currently not in autocommit mode, or if there are other ** active statements. A statement transaction allows the affects of this ** VDBE to be rolled back after an error without having to roll back the ** entire transaction. If no error is encountered, the statement transaction ** will automatically commit when the VDBE halts. */ case OP_Transaction: { Db *pDb; KVStore *pKV; int needStmt; assert( pOp->p1>=0 && pOp->p1<db->nDb ); pDb = &db->aDb[pOp->p1]; pKV = pDb->pKV; if( pOp->p2==0 ){ /* Read transaction needed. Start if we are not already in one. */ if( pKV->iTransLevel==0 ){ rc = sqlite4KVStoreBegin(pKV, 1); } }else{ /* A write transaction is needed */ needStmt = pKV->iTransLevel>0 && (p->needSavepoint || db->activeVdbeCnt>1); if( pKV->iTransLevel<2 ){ rc = sqlite4KVStoreBegin(pKV, 2); }else if( p->needSavepoint ){ rc = sqlite4KVStoreBegin(pKV, pKV->iTransLevel+1); if( rc==SQLITE_OK ){ p->stmtTransMask |= ((yDbMask)1)<<pOp->p1; } } } break; } /* Opcode: SetCookie P1 P2 P3 * * ** ** Write the content of register P3 (interpreted as an integer) ** into cookie number P2 of database P1. P2==1 is the schema version. ** P2==2 is the database format. P2==3 is the recommended pager cache ** size, and so forth. P1==0 is the main database file and P1==1 is the ** database file used to store temporary tables. ** ** A transaction must be started before executing this opcode. */ case OP_SetCookie: { /* in3 */ Db *pDb; u32 v; int n; assert( pOp->p1>=0 && pOp->p1<db->nDb ); pDb = &db->aDb[pOp->p1]; pIn3 = &aMem[pOp->p3]; sqlite4VdbeMemIntegerify(pIn3); v = (u32)pIn3->u.i; rc = sqlite4KVStorePutMeta(db, pDb->pKV, 0, 1, &v); pDb->pSchema->schema_cookie = (int)pIn3->u.i; db->flags |= SQLITE_InternChanges; if( pOp->p1==1 ){ /* Invalidate all prepared statements whenever the TEMP database ** schema is changed. Ticket #1644 */ sqlite4ExpirePreparedStatements(db); p->expired = 0; } break; |
︙ | ︙ | |||
3011 3012 3013 3014 3015 3016 3017 | ** Either a transaction needs to have been started or an OP_Open needs ** to be executed (to establish a read lock) before this opcode is ** invoked. */ case OP_VerifyCookie: { int iMeta; int iGen; | | > > < < | | | > | 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 | ** Either a transaction needs to have been started or an OP_Open needs ** to be executed (to establish a read lock) before this opcode is ** invoked. */ case OP_VerifyCookie: { int iMeta; int iGen; KVStore *pKV; KVByteArray *aData; KVSize nData; assert( pOp->p1>=0 && pOp->p1<db->nDb ); pKV = db->aDb[pOp->p1].pKV; if( pKV ){ rc = sqlite4KVStoreGetMeta(pKV, 0, 1, &iMeta); if( rc ) break; iGen = db->aDb[pOp->p1].pSchema->iGeneration; }else{ iGen = iMeta = 0; } if( iMeta!=pOp->p2 || iGen!=pOp->p3 ){ sqlite4DbFree(db, p->zErrMsg); p->zErrMsg = sqlite4DbStrDup(db, "database schema has changed"); |
︙ | ︙ | |||
3104 3105 3106 3107 3108 3109 3110 | */ case OP_OpenRead: case OP_OpenWrite: { int nField; KeyInfo *pKeyInfo; int p2; int iDb; | < | < | < < < < < < < < < | 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 | */ case OP_OpenRead: case OP_OpenWrite: { int nField; KeyInfo *pKeyInfo; int p2; int iDb; KVStore *pX; VdbeCursor *pCur; Db *pDb; if( p->expired ){ rc = SQLITE_ABORT; break; } nField = 0; pKeyInfo = 0; p2 = pOp->p2; iDb = pOp->p3; assert( iDb>=0 && iDb<db->nDb ); pDb = &db->aDb[iDb]; pX = pDb->pKV; assert( pX!=0 ); if( pOp->p5 ){ assert( p2>0 ); assert( p2<=p->nMem ); pIn2 = &aMem[p2]; assert( memIsValid(pIn2) ); assert( (pIn2->flags & MEM_Int)!=0 ); sqlite4VdbeMemIntegerify(pIn2); |
︙ | ︙ | |||
3162 3163 3164 3165 3166 3167 3168 | } assert( pOp->p1>=0 ); pCur = allocateCursor(p, pOp->p1, nField, iDb, 1); if( pCur==0 ) goto no_mem; pCur->nullRow = 1; pCur->isOrdered = 1; pCur->iRoot = p2; | | < < < < | 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 | } assert( pOp->p1>=0 ); pCur = allocateCursor(p, pOp->p1, nField, iDb, 1); if( pCur==0 ) goto no_mem; pCur->nullRow = 1; pCur->isOrdered = 1; pCur->iRoot = p2; rc = sqlite4KVStoreOpenCursor(pX, &pCur->pKVCur); pCur->pKeyInfo = pKeyInfo; /* Set the VdbeCursor.isTable and isIndex variables. Previous versions of ** SQLite used to check if the root-page flags were sane at this point ** and report database corruption if they were not, but this check has ** since moved into the btree layer. */ pCur->isTable = pOp->p4type!=P4_KEYINFO; pCur->isIndex = !pCur->isTable; break; |
︙ | ︙ | |||
3211 3212 3213 3214 3215 3216 3217 | ** different name to distinguish its use. Tables created using ** by this opcode will be used for automatically created transient ** indices in joins. */ case OP_OpenAutoindex: case OP_OpenEphemeral: { VdbeCursor *pCx; | < < < < < < < < < | < < < | < < < < < < < < < < < < < | | < < < < < < < < | | 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 | ** different name to distinguish its use. Tables created using ** by this opcode will be used for automatically created transient ** indices in joins. */ case OP_OpenAutoindex: case OP_OpenEphemeral: { VdbeCursor *pCx; assert( pOp->p1>=0 ); pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, 1); if( pCx==0 ) goto no_mem; pCx->nullRow = 1; rc = sqlite4KVStoreOpen(db, "ephm", ":memory:", &pCx->pTmpKV, SQLITE_KVOPEN_TEMPORARY | SQLITE_KVOPEN_NO_TRANSACTIONS); pCx->pKeyInfo = pOp->p4.pKeyInfo; if( pCx->pKeyInfo ) pCx->pKeyInfo->enc = ENC(p->db); pCx->isIndex = !pCx->isTable; break; } /* Opcode: OpenSorter P1 P2 * P4 * ** ** This opcode works like OP_OpenEphemeral except that it opens ** a transient index that is specifically designed to sort large ** tables using an external merge-sort algorithm. */ case OP_SorterOpen: { /* VdbeCursor *pCx; */ #ifndef SQLITE_OMIT_MERGE_SORT pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, 1); if( pCx==0 ) goto no_mem; pCx->pKeyInfo = pOp->p4.pKeyInfo; pCx->pKeyInfo->enc = ENC(p->db); pCx->isSorter = 1; rc = sqlite4VdbeSorterInit(db, pCx); |
︙ | ︙ | |||
3375 3376 3377 3378 3379 3380 3381 | ** ** See also: Found, NotFound, Distinct, SeekGt, SeekGe, SeekLt */ case OP_SeekLt: /* jump, in3 */ case OP_SeekLe: /* jump, in3 */ case OP_SeekGe: /* jump, in3 */ case OP_SeekGt: { /* jump, in3 */ | < < > > > | > > > < | | | < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < | < | < | < > > | < < > | < < < < < < < | < | > > | < < | < < < < < < < < < | < | < < | < < < < < < < | < | < < < < | < | < < < < | < < < < | | < < | < < < < | | | < < < < < > | | < | | < < < < < < < < < < > > > < | | | > > | < | > | | | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > | < > > > | > > > | > > | > | > > > > | | > > > > | | > > > | | > | < < | > > > > | > > | | < > > | > | < < > | < > | < | > > > > > > > | > > > > > | 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 | ** ** See also: Found, NotFound, Distinct, SeekGt, SeekGe, SeekLt */ case OP_SeekLt: /* jump, in3 */ case OP_SeekLe: /* jump, in3 */ case OP_SeekGe: /* jump, in3 */ case OP_SeekGt: { /* jump, in3 */ int oc; VdbeCursor *pC; int nField; KVByteArray *aProbe; KVSize nProbe; const KVByteArray *aKey; KVSize nKey; int c; int n; sqlite4_uint64 iRoot; assert( pOp->p1>=0 && pOp->p1<p->nCursor ); assert( pOp->p2!=0 ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); assert( pC->pseudoTableReg==0 ); assert( OP_SeekLe == OP_SeekLt+1 ); assert( OP_SeekGe == OP_SeekLt+2 ); assert( OP_SeekGt == OP_SeekLt+3 ); assert( pC->isOrdered ); oc = pOp->opcode; pC->nullRow = 0; if( pC->isTable ){ nField = 1; }else{ nField = pOp->p4.i; } rc = sqlite4VdbeEncodeKey(db, pIn3, nField, pC->iRoot, pC->pKeyInfo, &aProbe, &nProbe, 0); if( rc ){ sqlite4DbFree(db, aProbe); break; } rc = sqlite4KVCursorSeek(pC->pKVCur, aProbe, nProbe, oc<=OP_SeekLe ? -1 : 1); sqlite4DbFree(db, aProbe); if( rc==SQLITE_OK ){ if( oc==OP_SeekLt ){ rc = sqlite4KVCursorPrev(pC->pKVCur); }else if( oc==OP_SeekGt ){ rc = sqlite4KVCursorNext(pC->pKVCur); } }else if( rc==SQLITE_INEXACT ){ rc = SQLITE_OK; } if( rc==SQLITE_OK ){ rc = sqlite4KVCursorKey(pC->pKVCur, &aKey, &nKey); if( rc==SQLITE_OK ){ iRoot = 0; n = sqlite4GetVarint64(aKey, nKey, &iRoot); if( iRoot!=pC->iRoot ) rc = SQLITE_DONE; c = aKey[n]; if( c<0x05 || c>0xfa ) rc = SQLITE_DONE; } } if( rc==SQLITE_DONE ){ rc = SQLITE_OK; pc = pOp->p2 - 1; } break; } /* Opcode: Seek P1 P2 * * * ** ** P1 is an open table cursor and P2 is a rowid integer. Arrange ** for P1 to move so that it points to the rowid given by P2. */ case OP_Seek: { /* in2 */ VdbeCursor *pC; KVCursor *pKVCur; KVByteArray *aKey; KVSize nKey; assert( pOp->p1>=0 && pOp->p1<p->nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); assert( pC->isTable ); pKVCur = pC->pKVCur; rc = sqlite4VdbeEncodeKey(db, aMem+pOp->p2, 1, pC->iRoot, 0, &aKey, &nKey, 0); if( rc==SQLITE_OK ){ rc = sqlite4KVCursorSeek(pKVCur, aKey, nKey, 0); if( rc==SQLITE_NOTFOUND ) rc = SQLITE_CORRUPT_BKPT; } sqlite4DbFree(db, aKey); break; } /* Opcode: Found P1 P2 P3 P4 * ** ** If P4==0 then register P3 holds a blob constructed by MakeKey. If ** P4>0 then register P3 is the first of P4 registers that should be ** combined to generate a key. ** ** Cursor P1 is open on an index. If the record identified by P3 and P4 ** is a prefix of any entry in P1 then a jump is made to P2 and ** P1 is left pointing at the matching entry. */ /* Opcode: NotFound P1 P2 P3 P4 * ** ** If P4==0 then register P3 holds a blob constructed by MakeKey. If ** P4>0 then register P3 is the first of P4 registers that should be ** combined to generate key. ** ** Cursor P1 is on an index. If the record identified by P3 and P4 ** is not the prefix of any entry in P1 then a jump is made to P2. If P1 ** does contain an entry whose prefix matches the P3/P4 record then control ** falls through to the next instruction and P1 is left pointing at the ** matching entry. ** ** See also: Found, NotExists, IsUnique */ /* Opcode: NotExists P1 P2 P3 * * ** ** Use the content of register P3 as an integer key. If a record ** with that key does not exist in table of P1, then jump to P2. ** If the record does exist, then fall through. The cursor is left ** pointing to the record if it exists. ** ** The difference between this operation and NotFound is that this ** operation assumes the key is an integer and that P1 is a table whereas ** NotFound assumes key is a blob constructed from MakeRecord and ** P1 is an index. ** ** See also: Found, NotFound, IsUnique */ case OP_NotExists: { /* jump, in3 */ pOp->p4.i = 1; pOp->p4type = P4_INT32; /* Fall through into OP_NotFound */ } case OP_NotFound: /* jump, in3 */ case OP_Found: { /* jump, in3 */ int alreadyExists; VdbeCursor *pC; KVByteArray *pFree; KVByteArray *pProbe; KVSize nProbe; const KVByteArray *pKey; KVSize nKey; #ifdef SQLITE_TEST sqlite4_found_count++; #endif alreadyExists = 0; assert( pOp->p1>=0 && pOp->p1<p->nCursor ); assert( pOp->p4type==P4_INT32 ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); pIn3 = &aMem[pOp->p3]; assert( pC->pKVCur!=0 ); assert( pC->isTable==0 || pOp->opcode==OP_NotExists ); if( pOp->p4.i>0 ){ rc = sqlite4VdbeEncodeKey(db, pIn3, pOp->p4.i, pC->iRoot, pC->pKeyInfo, &pProbe, &nProbe, 0); pFree = pProbe; }else{ pProbe = (KVByteArray*)pIn3->z; nProbe = pIn3->n; pFree = 0; } if( rc==SQLITE_OK ){ rc = sqlite4KVCursorSeek(pC->pKVCur, pProbe, nProbe, +1); if( rc==SQLITE_INEXACT || rc==SQLITE_OK ){ rc = sqlite4KVCursorKey(pC->pKVCur, &pKey, &nKey); if( rc==SQLITE_OK && nKey>=nProbe && memcmp(pKey, pProbe, nKey)==0 ){ alreadyExists = 1; pC->nullRow = 0; } } } sqlite4DbFree(db, pFree); if( pOp->opcode==OP_Found ){ if( alreadyExists ) pc = pOp->p2 - 1; }else{ if( !alreadyExists ) pc = pOp->p2 - 1; } break; } /* Opcode: IsUnique P1 P2 P3 P4 * ** ** Cursor P1 is open on an index. ** ** The P3 register contains an integer record number. Call this record ** number R. Register P4 is the first in a set of N contiguous registers ** that make up an unpacked index key that can be used with cursor P1. ** The value of N can be inferred from the KeyInfo.nField of the cursor. ** N includes the rowid value appended to the end of the index record. ** This rowid value may or may not be the same as R. ** ** If any of the N registers beginning with register P4 contains a NULL ** value, jump immediately to P2. ** ** Otherwise, this instruction checks if cursor P1 contains an entry ** where the first (N-1) fields match but the rowid value at the end ** of the index entry is not R. If there is no such entry (meaning that ** a row about to be inserted with rowid R is unique) then control jumps ** to instruction P2. Otherwise, the rowid of the conflicting index ** entry is copied to register P3 and control falls through to the next ** instruction. ** ** See also: NotFound, NotExists, Found */ case OP_IsUnique: { /* jump, in3 */ #if 0 u16 ii; VdbeCursor *pCx; KVCursor *pKVCur; u16 nField; Mem *aMx; KVByteArray *pProbe; KVSize nProbe; KVSize nShort; KVSize nData; int isUnique; i64 R; /* Rowid stored in register P3 */ pIn3 = &aMem[pOp->p3]; aMx = &aMem[pOp->p4.i]; /* Assert that the values of parameters P1 and P4 are in range. */ assert( pOp->p4type==P4_INT32 ); assert( pOp->p4.i>0 && pOp->p4.i<=p->nMem ); assert( pOp->p1>=0 && pOp->p1<p->nCursor ); /* Find the index cursor. */ pCx = p->apCsr[pOp->p1]; pCx->seekResult = 0; pCx->cacheStatus = CACHE_STALE; pKVCur = pCx->pKVCur; nField = pCx->pKeyInfo->nField; /* If any of the values are NULL, take the jump. */ nField = pCx->pKeyInfo->nField; for(ii=0; ii<nField; ii++){ if( aMx[ii].flags & MEM_Null ){ pc = pOp->p2 - 1; pCrsr = 0; break; } } assert( (aMx[nField].flags & MEM_Null)==0 ); isUnique = 1; if( pCrsr!=0 ){ /* Extract the value of R from register P3. */ sqlite4VdbeMemIntegerify(pIn3); R = pIn3->u.i; /* Generate the probe key */ rc = sqlite4VdbeEncodeKey(db, pIn3, nField, pCx->iRoot, pCx->pKeyInfo, &pProbe, &nProbe, &nShort); if( rc==SQLITE_OK ){ rc = sqlite4KVCursorSeek(pKVCur, pProbe, nProbe, +1); if( rc==SQLITE_OK ){ /* Full key already exists in the index. Not unique. */ isUnique = 0; }else if( rc==SQLITE_INEXACT ){ int c = sqlite4KVCursorCompare(pKVCur, pProbe, nShort); if( c>0 ){ rc = sqlite4KVCursorPrev(pKVCur); if( rc==SQLITE_OK ){ c = sqlite4KVCursorCompare(pKVCur, pProbe, nShort); } } if( c ) isUnique = 0; } sqlite4DbFree(db, pProbe); if( isUnique ){ pc = pOp->p2 - 1; }else{ /* Collision. Copy the conflicting rowid into register P3. */ rc = sqlite4KVCursorData(pKVCur, 0, -1, &aData, &nData); if( rc==SQLITE_OK ){ rc = sqlite4VdbeCreateDecoder(db, aData, nData, nField, &pCodec); if( rc==SQLITE_OK ){ rc = sqlite4VdbeDecodeValue(pCodec, nField-1, 0, pIn3); sqlite4VdbeDestroyDecoder(pCodec); } } } } } #endif break; } /* Opcode: Sequence P1 P2 * * * ** ** Find the next available sequence number for cursor P1. ** Write the sequence number into register P2. |
︙ | ︙ | |||
3796 3797 3798 3799 3800 3801 3802 | /* Opcode: NewRowid P1 P2 P3 * * ** ** Get a new integer record number (a.k.a "rowid") used as the key to a table. ** The record number is not previously used as a key in the database ** table that cursor P1 points to. The new record number is written ** to register P2. | < < < < < < < | | > | | < < < | | > > > > | | | | | | | | | | | | | | | < < < < < < < < < | < < | | | < < < < | < | | < < < < < < < | | | < < < < < < < < < < < < | < < < < < < | < < < < < < < < | < > < < < < < < < < < < < < < < < < < < < < < | < < | | < < < < < < < < | < | | 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 | /* Opcode: NewRowid P1 P2 P3 * * ** ** Get a new integer record number (a.k.a "rowid") used as the key to a table. ** The record number is not previously used as a key in the database ** table that cursor P1 points to. The new record number is written ** to register P2. */ case OP_NewRowid: { /* out2-prerelease */ i64 v; /* The new rowid */ VdbeCursor *pC; /* Cursor of table to get the new rowid */ const KVByteArray *aKey; /* Key of an existing row */ KVSize nKey; /* Size of the existing row key */ int n; /* Number of bytes decoded */ v = 0; assert( pOp->p1>=0 && pOp->p1<p->nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); /* Some compilers complain about constants of the form 0x7fffffffffffffff. ** Others complain about 0x7ffffffffffffffffLL. The following macro seems ** to provide the constant while making all compilers happy. */ # define MAX_ROWID (i64)( (((u64)0x7fffffff)<<32) | (u64)0xffffffff ) /* The next rowid or record number (different terms for the same ** thing) is obtained in a two-step algorithm. ** ** First we attempt to find the largest existing rowid and add one ** to that. But if the largest existing rowid is already the maximum ** positive integer, we have to fall through to the second ** probabilistic algorithm ** ** The second algorithm is to select a rowid at random and see if ** it already exists in the table. If it does not exist, we have ** succeeded. If the random rowid does exist, we select a new one ** and try again, up to 100 times. */ assert( pC->isTable ); rc = sqlite4VdbeSeekEnd(pC, -1); if( rc==SQLITE_NOTFOUND ){ v = 0; rc = SQLITE_OK; }else if( rc==SQLITE_OK ){ rc = sqlite4KVCursorKey(pC->pKVCur, &aKey, &nKey); if( rc==SQLITE_OK ){ n = sqlite4GetVarint64(aKey, nKey, &v); if( n==0 ) rc = SQLITE_CORRUPT; if( v!=pC->iRoot ) rc = SQLITE_CORRUPT; } if( rc==SQLITE_OK ){ n = sqlite4VdbeDecodeIntKey(&aKey[n], nKey-n, &v); if( n==0 ) rc = SQLITE_CORRUPT; } }else{ break; } pOut->flags = MEM_Int; pOut->u.i = v+1; break; } /* Opcode: Insert P1 P2 P3 P4 P5 ** ** Write an entry into the table of cursor P1. A new entry is ** created if it doesn't already exist or the data for an existing |
︙ | ︙ | |||
3989 3990 3991 3992 3993 3994 3995 | */ case OP_Insert: case OP_InsertInt: { Mem *pData; /* MEM cell holding data for the record to be inserted */ Mem *pKey; /* MEM cell holding key for the record */ i64 iKey; /* The integer ROWID or key for the record to be inserted */ VdbeCursor *pC; /* Cursor to table into which insert is written */ | < < > > < < | 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 | */ case OP_Insert: case OP_InsertInt: { Mem *pData; /* MEM cell holding data for the record to be inserted */ Mem *pKey; /* MEM cell holding key for the record */ i64 iKey; /* The integer ROWID or key for the record to be inserted */ VdbeCursor *pC; /* Cursor to table into which insert is written */ const char *zDb; /* database name - used by the update hook */ const char *zTbl; /* Table name - used by the opdate hook */ int op; /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */ int n; KVByteArray aKey[24]; pData = &aMem[pOp->p2]; assert( pOp->p1>=0 && pOp->p1<p->nCursor ); assert( memIsValid(pData) ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); assert( pC->isTable ); REGISTER_TRACE(pOp->p2, pData); if( pOp->opcode==OP_Insert ){ pKey = &aMem[pOp->p3]; assert( pKey->flags & MEM_Int ); assert( memIsValid(pKey) ); |
︙ | ︙ | |||
4024 4025 4026 4027 4028 4029 4030 | if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = iKey; if( pData->flags & MEM_Null ){ pData->z = 0; pData->n = 0; }else{ assert( pData->flags & (MEM_Blob|MEM_Str) ); } | < < < < | < | | | < < < < < | 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 | if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = iKey; if( pData->flags & MEM_Null ){ pData->z = 0; pData->n = 0; }else{ assert( pData->flags & (MEM_Blob|MEM_Str) ); } n = sqlite4PutVarint64(aKey, pC->iRoot); n += sqlite4VdbeEncodeIntKey(&aKey[n], iKey); rc = sqlite4KVStoreReplace(pC->pKVCur->pStore, aKey, n, (const KVByteArray*)pData->z, pData->n); /* Invoke the update-hook if required. */ if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p4.z ){ zDb = db->aDb[pC->iDb].zName; zTbl = pOp->p4.z; op = ((pOp->p5 & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_INSERT); assert( pC->isTable ); |
︙ | ︙ | |||
4079 4080 4081 4082 4083 4084 4085 | i64 iKey; VdbeCursor *pC; iKey = 0; assert( pOp->p1>=0 && pOp->p1<p->nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); | < < < < < < < < < | < < < < < > | 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 | i64 iKey; VdbeCursor *pC; iKey = 0; assert( pOp->p1>=0 && pOp->p1<p->nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); /* If the update-hook will be invoked, set iKey to the rowid of the ** row being deleted. */ if( db->xUpdateCallback && pOp->p4.z ){ assert( pC->isTable ); assert( pC->rowidIsValid ); /* lastRowid set by previous OP_NotFound */ iKey = pC->lastRowid; } rc = sqlite4KVCursorDelete(pC->pKVCur); /* Invoke the update-hook if required. */ if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p4.z ){ const char *zDb = db->aDb[pC->iDb].zName; const char *zTbl = pOp->p4.z; db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, zTbl, iKey); assert( pC->iDb>=0 ); } if( pOp->p2 & OPFLAG_NCHANGE ) p->nChange++; break; } /* Opcode: ResetCount * * * * * ** ** The value of the change counter is copied to the database handle ** change counter (returned by subsequent calls to sqlite4_changes()). ** Then the VMs internal change counter resets to 0. ** This is used by trigger programs. */ |
︙ | ︙ | |||
4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 | ** fall through to the next instruction. Otherwise, jump to instruction P2. */ case OP_SorterCompare: { VdbeCursor *pC; int res; pC = p->apCsr[pOp->p1]; assert( isSorter(pC) ); pIn3 = &aMem[pOp->p3]; rc = sqlite4VdbeSorterCompare(pC, pIn3, &res); if( res ){ pc = pOp->p2-1; } break; }; /* Opcode: SorterData P1 P2 * * * ** ** Write into register P2 the current sorter data for sorter cursor P1. */ case OP_SorterData: { | > | < > > | 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 | ** fall through to the next instruction. Otherwise, jump to instruction P2. */ case OP_SorterCompare: { VdbeCursor *pC; int res; pC = p->apCsr[pOp->p1]; assert( pC->iRoot>0 ); assert( isSorter(pC) ); pIn3 = &aMem[pOp->p3]; rc = sqlite4VdbeSorterCompare(pC, pIn3, &res); if( res ){ pc = pOp->p2-1; } break; }; /* Opcode: SorterData P1 P2 * * * ** ** Write into register P2 the current sorter data for sorter cursor P1. */ case OP_SorterData: { VdbeCursor *pC; pOut = &aMem[pOp->p2]; pC = p->apCsr[pOp->p1]; assert( pC!=0 ); #ifndef SQLITE_OMIT_MERGE_SORT assert( pC->isSorter ); rc = sqlite4VdbeSorterRowkey(pC, pOut); #else pOp->opcode = OP_RowKey; pc--; #endif break; |
︙ | ︙ | |||
4190 4191 4192 4193 4194 4195 4196 | ** ** If the P1 cursor must be pointing to a valid row (not a NULL row) ** of a real table, not a pseudo-table. */ case OP_RowKey: case OP_RowData: { VdbeCursor *pC; | | | | | | < | < < < < < | < | < < | < < < | < < < < | | | < | < < < < < < < < < > > > < < < | | < < < > | | < < < < < < < < < | < < < < < | > | | 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 | ** ** If the P1 cursor must be pointing to a valid row (not a NULL row) ** of a real table, not a pseudo-table. */ case OP_RowKey: case OP_RowData: { VdbeCursor *pC; KVCursor *pCrsr; const KVByteArray *pData; KVSize nData; pOut = &aMem[pOp->p2]; memAboutToChange(p, pOut); /* Note that RowKey and RowData are really exactly the same instruction */ assert( pOp->p1>=0 && pOp->p1<p->nCursor ); pC = p->apCsr[pOp->p1]; assert( pC->isSorter==0 ); assert( pC->isIndex || pOp->opcode==OP_RowData ); assert( pC!=0 ); assert( pC->nullRow==0 ); assert( pC->pseudoTableReg==0 ); assert( !pC->isSorter ); assert( pC->pKVCur!=0 ); pCrsr = pC->pKVCur; if( pOp->opcode==OP_RowKey ){ rc = sqlite4KVCursorKey(pCrsr, &pData, &nData); }else{ rc = sqlite4KVCursorData(pCrsr, 0, -1, &pData, &nData); } if( rc==SQLITE_OK && nData>db->aLimit[SQLITE_LIMIT_LENGTH] ){ goto too_big; } sqlite4VdbeMemSetStr(pOut, (const char*)pData, nData, 0, SQLITE_DYNAMIC); pOut->enc = SQLITE_UTF8; /* In case the blob is ever cast to text */ UPDATE_MAX_BLOBSIZE(pOut); break; } /* Opcode: Rowid P1 P2 * * * ** ** Store in register P2 an integer which is the key of the table entry that ** P1 is currently point to. ** ** P1 can be either an ordinary table or a virtual table. There used to ** be a separate OP_VRowid opcode for use with virtual tables, but this ** one opcode now works for both table types. */ case OP_Rowid: { /* out2-prerelease */ VdbeCursor *pC; i64 v; sqlite4_vtab *pVtab; const sqlite4_module *pModule; const KVByteArray *aKey; KVSize nKey; int n; assert( pOp->p1>=0 && pOp->p1<p->nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); assert( pC->pseudoTableReg==0 ); if( pC->nullRow ){ pOut->flags = MEM_Null; break; #ifndef SQLITE_OMIT_VIRTUALTABLE }else if( pC->pVtabCursor ){ pVtab = pC->pVtabCursor->pVtab; pModule = pVtab->pModule; assert( pModule->xRowid ); rc = pModule->xRowid(pC->pVtabCursor, &v); importVtabErrMsg(p, pVtab); #endif /* SQLITE_OMIT_VIRTUALTABLE */ }else{ rc = sqlite4KVCursorKey(pC->pKVCur, &aKey, &nKey); if( rc==SQLITE_OK ){ n = sqlite4GetVarint64(aKey, nKey, (sqlite4_uint64*)&v); n = sqlite4VdbeDecodeIntKey(&aKey[n], nKey-n, &v); if( n==0 ) rc = SQLITE_CORRUPT; } } pOut->u.i = v; break; } /* Opcode: NullRow P1 * * * * ** ** Move the cursor P1 to a null row. Any OP_Column operations ** that occur while the cursor is on the null row will always ** write a NULL. */ case OP_NullRow: { VdbeCursor *pC; assert( pOp->p1>=0 && pOp->p1<p->nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); pC->nullRow = 1; pC->rowidIsValid = 0; break; } /* Opcode: Last P1 P2 * * * ** ** The next use of the Rowid or Column or Next instruction for P1 ** will refer to the last entry in the database table or index. ** If the table or index is empty and P2>0, then jump immediately to P2. ** If P2 is 0 or if the table or index is not empty, fall through ** to the following instruction. */ case OP_Last: { /* jump */ VdbeCursor *pC; assert( pOp->p1>=0 && pOp->p1<p->nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); rc = sqlite4VdbeSeekEnd(pC, -1); if( rc==SQLITE_NOTFOUND ){ rc = SQLITE_OK; if( pOp->p2 ) pc = pOp->p2 - 1; } break; } /* Opcode: Sort P1 P2 * * * ** |
︙ | ︙ | |||
4383 4384 4385 4386 4387 4388 4389 | ** will refer to the first entry in the database table or index. ** If the table or index is empty and P2>0, then jump immediately to P2. ** If P2 is 0 or if the table or index is not empty, fall through ** to the following instruction. */ case OP_Rewind: { /* jump */ VdbeCursor *pC; | < | | | < < | > | | < > | | > | | | | | 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 | ** will refer to the first entry in the database table or index. ** If the table or index is empty and P2>0, then jump immediately to P2. ** If P2 is 0 or if the table or index is not empty, fall through ** to the following instruction. */ case OP_Rewind: { /* jump */ VdbeCursor *pC; int doJump; assert( pOp->p1>=0 && pOp->p1<p->nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); assert( pC->isSorter==(pOp->opcode==OP_SorterSort) ); doJump = 1; if( isSorter(pC) ){ rc = sqlite4VdbeSorterRewind(db, pC, &doJump); }else{ rc = sqlite4VdbeSeekEnd(pC, +1); if( rc==SQLITE_NOTFOUND ){ rc = SQLITE_OK; doJump = 1; }else{ doJump = 0; } } pC->nullRow = (u8)doJump; assert( pOp->p2>0 && pOp->p2<p->nOp ); if( doJump ){ pc = pOp->p2 - 1; } break; } /* Opcode: Next P1 P2 * P4 P5 ** ** Advance cursor P1 so that it points to the next key/data pair in its ** table or index. If there are no more key/value pairs then fall through ** to the following instruction. But if the cursor advance was successful, ** jump immediately to P2. ** ** The P1 cursor must be for a real table, not a pseudo-table. ** ** P4 is always of type P4_ADVANCE. The function pointer points to ** sqlite4VdbeNext(). ** ** If P5 is positive and the jump is taken, then event counter ** number P5-1 in the prepared statement is incremented. ** ** See also: Prev */ /* Opcode: Prev P1 P2 * * P5 ** ** Back up cursor P1 so that it points to the previous key/data pair in its ** table or index. If there is no previous key/value pairs then fall through ** to the following instruction. But if the cursor backup was successful, ** jump immediately to P2. ** ** The P1 cursor must be for a real table, not a pseudo-table. ** ** P4 is always of type P4_ADVANCE. The function pointer points to ** sqlite4VdbePrevious(). ** ** If P5 is positive and the jump is taken, then event counter ** number P5-1 in the prepared statement is incremented. */ case OP_SorterNext: /* jump */ #ifdef SQLITE_OMIT_MERGE_SORT pOp->opcode = OP_Next; |
︙ | ︙ | |||
4462 4463 4464 4465 4466 4467 4468 4469 4470 | if( pC==0 ){ break; /* See ticket #2273 */ } assert( pC->isSorter==(pOp->opcode==OP_SorterNext) ); if( isSorter(pC) ){ assert( pOp->opcode==OP_SorterNext ); rc = sqlite4VdbeSorterNext(db, pC, &res); }else{ res = 1; | > < < | | | < < | > > > > | < < < < < < < < < | | | < | > | < < < < < < < < | | | > > > > > > > > > > > > > > < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < | 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 | if( pC==0 ){ break; /* See ticket #2273 */ } assert( pC->isSorter==(pOp->opcode==OP_SorterNext) ); if( isSorter(pC) ){ assert( pOp->opcode==OP_SorterNext ); rc = sqlite4VdbeSorterNext(db, pC, &res); if( rc==SQLITE_OK && res ) rc = SQLITE_NOTFOUND; }else{ res = 1; assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite4VdbeNext ); assert( pOp->opcode!=OP_Prev || pOp->p4.xAdvance==sqlite4VdbePrevious ); rc = pOp->p4.xAdvance(pC); } if( rc==SQLITE_OK ){ pc = pOp->p2 - 1; if( pOp->p5 ) p->aCounter[pOp->p5-1]++; pC->nullRow = 0; #ifdef SQLITE_TEST sqlite4_search_count++; #endif }else if( rc==SQLITE_NOTFOUND ){ pC->nullRow = 1; rc = SQLITE_OK; } pC->rowidIsValid = 0; break; } /* Opcode: IdxInsert P1 P2 * * P5 ** ** Register P2 holds an SQL index key made using the ** MakeRecord instructions. This opcode writes that key ** into the index P1. Data for the entry is nil. ** ** P3 is a flag that provides a hint to the b-tree layer that this ** insert is likely to be an append. ** ** This instruction only works for indices. The equivalent instruction ** for tables is OP_Insert. */ case OP_SorterInsert: { /* in2 */ VdbeCursor *pC; assert( pOp->p1>=0 && pOp->p1<p->nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); assert( pC->isSorter==(pOp->opcode==OP_SorterInsert) ); pIn2 = &aMem[pOp->p2]; assert( pIn2->flags & MEM_Blob ); assert( pC->isTable==0 ); rc = ExpandBlob(pIn2); if( rc==SQLITE_OK ){ rc = sqlite4VdbeSorterWrite(db, pC, pIn2); } break; } /* Opcode: IdxInsert P1 P2 * * P5 ** ** Register P2 holds an SQL index key made using the ** MakeRecord instructions. This opcode writes that key ** into the index P1. Data for the entry is nil. ** ** P3 is a flag that provides a hint to the b-tree layer that this ** insert is likely to be an append. ** ** This instruction only works for indices. The equivalent instruction ** for tables is OP_Insert. */ case OP_IdxInsert: { /* in2 */ assert( 0 ); break; } /* Opcode: IdxDelete P1 P2 P3 * * ** ** The content of P3 registers starting at register P2 form ** an unpacked index key. This opcode removes that entry from the ** index opened by cursor P1. */ case OP_IdxDelete: { assert( 0 ); break; } /* Opcode: IdxRowid P1 P2 * * * ** ** Write into register P2 an integer which is the last entry in the record at ** the end of the index key pointed to by cursor P1. This integer should be ** the rowid of the table entry to which this index entry points. ** ** See also: Rowid, MakeRecord. */ case OP_IdxRowid: { /* out2-prerelease */ assert( 0 ); break; } /* Opcode: IdxGE P1 P2 P3 P4 P5 ** ** The P4 register values beginning with P3 form an unpacked index ** key that omits the ROWID. Compare this key value against the index |
︙ | ︙ | |||
4632 4633 4634 4635 4636 4637 4638 | ** Otherwise fall through to the next instruction. ** ** If P5 is non-zero then the key value is increased by an epsilon prior ** to the comparison. This makes the opcode work like IdxLE. */ case OP_IdxLT: /* jump */ case OP_IdxGE: { /* jump */ | < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < | 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 | ** Otherwise fall through to the next instruction. ** ** If P5 is non-zero then the key value is increased by an epsilon prior ** to the comparison. This makes the opcode work like IdxLE. */ case OP_IdxLT: /* jump */ case OP_IdxGE: { /* jump */ assert( 0 ); break; } /* Opcode: Destroy P1 P2 P3 * * ** ** Delete an entire database table or index whose root page in the database ** file is given by P1. ** ** The table being destroyed is in the main database file if P3==0. If ** P3==1 then the table to be clear is in the auxiliary database file ** that is used to store tables create using CREATE TEMPORARY TABLE. ** ** See also: Clear */ case OP_Destroy: { /* out2-prerelease */ assert( 0 ); break; } /* Opcode: Clear P1 P2 P3 ** ** Delete all contents of the database table or index whose root page ** in the database file is given by P1. But, unlike Destroy, do not |
︙ | ︙ | |||
4729 4730 4731 4732 4733 4734 4735 | ** count is incremented by the number of rows in the table being cleared. ** If P3 is greater than zero, then the value stored in register P3 is ** also incremented by the number of rows in the table being cleared. ** ** See also: Destroy */ case OP_Clear: { | < < < < < < < < < < | < < < < | 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 | ** count is incremented by the number of rows in the table being cleared. ** If P3 is greater than zero, then the value stored in register P3 is ** also incremented by the number of rows in the table being cleared. ** ** See also: Destroy */ case OP_Clear: { assert( 0 ); break; } /* Opcode: CreateTable P1 P2 * * * ** ** Allocate a new table in the main database file if P1==0 or in the ** auxiliary database file if P1==1 or in an attached database if |
︙ | ︙ | |||
4771 4772 4773 4774 4775 4776 4777 | ** P1>1. Write the root page number of the new table into ** register P2. ** ** See documentation on OP_CreateTable for additional information. */ case OP_CreateIndex: /* out2-prerelease */ case OP_CreateTable: { /* out2-prerelease */ | | < > > > > > | < > | | > > > > > > > | | > > > > < > | > > > | < < < < < < < < < < | 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 | ** P1>1. Write the root page number of the new table into ** register P2. ** ** See documentation on OP_CreateTable for additional information. */ case OP_CreateIndex: /* out2-prerelease */ case OP_CreateTable: { /* out2-prerelease */ sqlite4_uint64 iTabno; Db *pDb; KVCursor *pCur; const KVByteArray *aKey; KVSize nKey; int n; KVByteArray aProbe[12]; iTabno = 0; assert( pOp->p1>=0 && pOp->p1<db->nDb ); pDb = &db->aDb[pOp->p1]; memset(aProbe, 0xff, 9); rc = sqlite4KVStoreOpenCursor(pDb->pKV, &pCur); if( rc ) break; rc = sqlite4KVCursorSeek(pCur, aProbe, 9, -1); if( rc==SQLITE_OK ){ sqlite4KVCursorClose(pCur); rc = SQLITE_CORRUPT; break; } if( rc==SQLITE_NOTFOUND ){ iTabno = 2; n = 1; rc = SQLITE_OK; }else if( rc==SQLITE_INEXACT ){ rc = sqlite4KVCursorKey(pCur, &aKey, &nKey); n = sqlite4GetVarint64(aKey, nKey, &iTabno); }else{ break; } sqlite4KVCursorClose(pCur); if( n==0 ){ rc = SQLITE_CORRUPT; } pOut->u.i = iTabno; 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, ** then runs the new virtual machine. It is thus a re-entrant opcode. */ case OP_ParseSchema: { int iDb; const char *zMaster; char *zSql; InitData initData; iDb = pOp->p1; assert( iDb>=0 && iDb<db->nDb ); assert( DbHasProperty(db, iDb, DB_SchemaLoaded) ); /* Used to be a conditional */ { zMaster = SCHEMA_TABLE(iDb); initData.db = db; initData.iDb = pOp->p1; |
︙ | ︙ | |||
4918 4919 4920 4921 4922 4923 4924 | ** ** If P5 is not zero, the check is done on the auxiliary database ** file, not the main database file. ** ** This opcode is used to implement the integrity_check pragma. */ case OP_IntegrityCk: { | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 | ** ** If P5 is not zero, the check is done on the auxiliary database ** file, not the main database file. ** ** This opcode is used to implement the integrity_check pragma. */ case OP_IntegrityCk: { break; } #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ /* Opcode: RowSetAdd P1 P2 * * * ** ** Insert the integer value held by register P2 into a boolean index |
︙ | ︙ | |||
5420 5421 5422 5423 5424 5425 5426 | ** operation. No IO is required. ** ** If changing into or out of WAL mode the procedure is more complicated. ** ** Write a string containing the final journal-mode to register P2. */ case OP_JournalMode: { /* out2-prerelease */ | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 | ** operation. No IO is required. ** ** If changing into or out of WAL mode the procedure is more complicated. ** ** Write a string containing the final journal-mode to register P2. */ case OP_JournalMode: { /* out2-prerelease */ break; }; #endif /* SQLITE_OMIT_PRAGMA */ /* Opcode: Expire P1 * * * * ** |
︙ | ︙ | |||
5494 5495 5496 5497 5498 5499 5500 | ** ** P2 contains the root-page of the table to lock. ** ** P4 contains a pointer to the name of the table being locked. This is only ** used to generate an error message if the lock cannot be obtained. */ case OP_TableLock: { | < < < < < < < < < < < < | 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 | ** ** P2 contains the root-page of the table to lock. ** ** P4 contains a pointer to the name of the table being locked. This is only ** used to generate an error message if the lock cannot be obtained. */ case OP_TableLock: { break; } #endif /* SQLITE_OMIT_SHARED_CACHE */ #ifndef SQLITE_OMIT_VIRTUALTABLE /* Opcode: VBegin * * * P4 * ** |
︙ | ︙ | |||
5978 5979 5980 5981 5982 5983 5984 | } /* This is the only way out of this procedure. We have to ** release the mutexes on btrees that were acquired at the ** top. */ vdbe_return: db->lastRowid = lastRowid; | < | 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 | } /* This is the only way out of this procedure. We have to ** release the mutexes on btrees that were acquired at the ** top. */ vdbe_return: db->lastRowid = lastRowid; return rc; /* Jump to here if a string or blob larger than SQLITE_MAX_LENGTH ** is encountered. */ too_big: sqlite4SetString(&p->zErrMsg, db, "string or blob too big"); |
︙ | ︙ |
Changes to src/vdbe.h.
︙ | ︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 | /* ** The names of the following types declared in vdbeInt.h are required ** for the VdbeOp definition. */ typedef struct VdbeFunc VdbeFunc; typedef struct Mem Mem; typedef struct SubProgram SubProgram; /* ** A single instruction of the virtual machine has an opcode ** and as many as three operands. The instruction is recorded ** as an instance of the following structure: */ struct VdbeOp { | > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | /* ** The names of the following types declared in vdbeInt.h are required ** for the VdbeOp definition. */ typedef struct VdbeFunc VdbeFunc; typedef struct Mem Mem; typedef struct SubProgram SubProgram; typedef struct VdbeCursor VdbeCursor; /* ** A single instruction of the virtual machine has an opcode ** and as many as three operands. The instruction is recorded ** as an instance of the following structure: */ struct VdbeOp { |
︙ | ︙ | |||
57 58 59 60 61 62 63 | VdbeFunc *pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */ CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */ Mem *pMem; /* Used when p4type is P4_MEM */ VTable *pVtab; /* Used when p4type is P4_VTAB */ KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */ int *ai; /* Used when p4type is P4_INTARRAY */ SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */ | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | VdbeFunc *pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */ CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */ Mem *pMem; /* Used when p4type is P4_MEM */ VTable *pVtab; /* Used when p4type is P4_VTAB */ KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */ int *ai; /* Used when p4type is P4_INTARRAY */ SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */ int (*xAdvance)(VdbeCursor*); } p4; #ifdef SQLITE_DEBUG char *zComment; /* Comment to improve readability */ #endif #ifdef VDBE_PROFILE int cnt; /* Number of times this instruction was executed */ u64 cycles; /* Total time spent executing this instruction */ |
︙ | ︙ | |||
179 180 181 182 183 184 185 | void sqlite4VdbeChangeP1(Vdbe*, u32 addr, int P1); void sqlite4VdbeChangeP2(Vdbe*, u32 addr, int P2); void sqlite4VdbeChangeP3(Vdbe*, u32 addr, int P3); void sqlite4VdbeChangeP5(Vdbe*, u8 P5); void sqlite4VdbeJumpHere(Vdbe*, int addr); void sqlite4VdbeChangeToNoop(Vdbe*, int addr); void sqlite4VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); | | | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | void sqlite4VdbeChangeP1(Vdbe*, u32 addr, int P1); void sqlite4VdbeChangeP2(Vdbe*, u32 addr, int P2); void sqlite4VdbeChangeP3(Vdbe*, u32 addr, int P3); void sqlite4VdbeChangeP5(Vdbe*, u8 P5); void sqlite4VdbeJumpHere(Vdbe*, int addr); void sqlite4VdbeChangeToNoop(Vdbe*, int addr); void sqlite4VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); void sqlite4VdbeUsesStorage(Vdbe*, int); VdbeOp *sqlite4VdbeGetOp(Vdbe*, int); int sqlite4VdbeMakeLabel(Vdbe*); void sqlite4VdbeRunOnlyOnce(Vdbe*); void sqlite4VdbeDelete(Vdbe*); void sqlite4VdbeDeleteObject(sqlite4*,Vdbe*); void sqlite4VdbeMakeReady(Vdbe*,Parse*); int sqlite4VdbeFinalize(Vdbe*); |
︙ | ︙ |
Changes to src/vdbeInt.h.
︙ | ︙ | |||
36 37 38 39 40 41 42 | /* Opaque type used by the explainer */ typedef struct Explain Explain; /* Opaque type used by vdbecodec.c */ typedef struct ValueDecoder ValueDecoder; /* | | | | < < < | | < < < < < < < < < < < < < < < | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | /* Opaque type used by the explainer */ typedef struct Explain Explain; /* Opaque type used by vdbecodec.c */ typedef struct ValueDecoder ValueDecoder; /* ** A cursor is a pointer into a single database. ** The cursor can seek to an entry with a particular key, or ** loop over all entries. You can also insert new ** entries or retrieve the key or data from the entry that the cursor ** is currently pointing to. ** ** Every cursor that the virtual machine has open is represented by an ** instance of the following structure. */ struct VdbeCursor { KVCursor *pKVCur; /* The cursor structure of the backend */ KVStore *pTmpKV; /* Separate file holding a temporary table */ KeyInfo *pKeyInfo; /* Info about index keys needed by index cursors */ int iDb; /* Index of cursor database in db->aDb[] (or -1) */ int iRoot; /* Root page of the table */ int pseudoTableReg; /* Register holding pseudotable content. */ int nField; /* Number of fields in the header */ Bool zeroed; /* True if zeroed out and ready for reuse */ Bool rowidIsValid; /* True if lastRowid is valid */ Bool atFirst; /* True if pointing to first entry */ Bool useRandomRowid; /* Generate new record numbers semi-randomly */ Bool nullRow; /* True if pointing to a row with no data */ Bool isTable; /* True if a table requiring integer keys */ Bool isIndex; /* True if an index containing keys only - no data */ Bool isOrdered; /* True if the underlying table is BTREE_UNORDERED */ Bool isSorter; /* True if a new-style sorter */ sqlite4_vtab_cursor *pVtabCursor; /* The cursor for a virtual table */ const sqlite4_module *pModule; /* Module for cursor pVtabCursor */ i64 seqCount; /* Sequence counter */ i64 movetoTarget; /* Argument to the deferred move-to */ i64 lastRowid; /* Last rowid from a Next or NextIdx operation */ VdbeSorter *pSorter; /* Sorter object for OP_SorterOpen cursors */ /* Result of last sqlite4-Moveto() done by an OP_NotExists or ** OP_IsUnique opcode on this cursor. */ int seekResult; }; typedef struct VdbeCursor VdbeCursor; /* ** When a sub-program is executed (OP_Program), a structure of this type ** is allocated to store the current value of the program counter, as ** well as the current memory cell array and various other frame specific |
︙ | ︙ | |||
202 203 204 205 206 207 208 | */ #define MEM_Term 0x0200 /* String rep is nul terminated */ #define MEM_Dyn 0x0400 /* Need to call sqliteFree() on Mem.z */ #define MEM_Static 0x0800 /* Mem.z points to a static string */ #define MEM_Ephem 0x1000 /* Mem.z points to an ephemeral string */ #define MEM_Agg 0x2000 /* Mem.z points to an agg function context */ #define MEM_Zero 0x4000 /* Mem.i contains count of 0s appended to blob */ | < < < < | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | */ #define MEM_Term 0x0200 /* String rep is nul terminated */ #define MEM_Dyn 0x0400 /* Need to call sqliteFree() on Mem.z */ #define MEM_Static 0x0800 /* Mem.z points to a static string */ #define MEM_Ephem 0x1000 /* Mem.z points to an ephemeral string */ #define MEM_Agg 0x2000 /* Mem.z points to an agg function context */ #define MEM_Zero 0x4000 /* Mem.i contains count of 0s appended to blob */ /* ** Clear any existing type flags from a Mem and replace them with f */ #define MemSetTypeFlag(p, f) \ ((p)->flags = ((p)->flags&~(MEM_TypeMask|MEM_Zero))|f) |
︙ | ︙ | |||
322 323 324 325 326 327 328 | u8 errorAction; /* Recovery action to do in case of an error */ u8 explain; /* True if EXPLAIN present on SQL command */ u8 changeCntOn; /* True to update the change-counter */ u8 expired; /* True if the VM needs to be recompiled */ u8 runOnlyOnce; /* Automatically expire on reset */ u8 minWriteFileFormat; /* Minimum file format for writable database files */ u8 inVtabMethod; /* See comments above */ | | | < < | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | u8 errorAction; /* Recovery action to do in case of an error */ u8 explain; /* True if EXPLAIN present on SQL command */ u8 changeCntOn; /* True to update the change-counter */ u8 expired; /* True if the VM needs to be recompiled */ u8 runOnlyOnce; /* Automatically expire on reset */ u8 minWriteFileFormat; /* Minimum file format for writable database files */ u8 inVtabMethod; /* See comments above */ u8 needSavepoint; /* True if a change might abort and needs savepoint */ u8 readOnly; /* True for read-only statements */ u8 isPrepareV2; /* True if prepared with prepare_v2() */ int nChange; /* Number of db changes made since last reset */ yDbMask stmtTransMask; /* db->aDb[] entries that have a subtransaction */ int aCounter[3]; /* Counters used by sqlite4_stmt_status() */ #ifndef SQLITE_OMIT_TRACE i64 startTime; /* Time when query started - used for profiling */ #endif i64 nFkConstraint; /* Number of imm. FK constraints this VM */ i64 nStmtDefCons; /* Number of def. constraints when stmt started */ char *zSql; /* Text of the SQL statement that generated this */ |
︙ | ︙ | |||
366 367 368 369 370 371 372 | #define VDBE_MAGIC_DEAD 0xb606c3c8 /* The VDBE has been deallocated */ /* ** Function prototypes */ void sqlite4VdbeFreeCursor(Vdbe *, VdbeCursor*); void sqliteVdbePopStack(Vdbe*,int); | < | 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | #define VDBE_MAGIC_DEAD 0xb606c3c8 /* The VDBE has been deallocated */ /* ** Function prototypes */ void sqlite4VdbeFreeCursor(Vdbe *, VdbeCursor*); void sqliteVdbePopStack(Vdbe*,int); #if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE) void sqlite4VdbePrintOp(FILE*, int, Op*); #endif u32 sqlite4VdbeSerialTypeLen(u32); u32 sqlite4VdbeSerialType(Mem*, int); u32 sqlite4VdbeSerialPut(unsigned char*, int, Mem*, int); u32 sqlite4VdbeSerialGet(const unsigned char*, u32, Mem*); |
︙ | ︙ | |||
404 405 406 407 408 409 410 | int sqlite4VdbeEncodeKey( sqlite4 *db, /* The database connection */ Mem *aIn, /* Values to be encoded */ int nIn, /* Number of entries in aIn[] */ int iTabno, /* The table this key applies to */ KeyInfo *pKeyInfo, /* Collating sequence information */ u8 **pzOut, /* Write the resulting key here */ | | > < | | | 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | int sqlite4VdbeEncodeKey( sqlite4 *db, /* The database connection */ Mem *aIn, /* Values to be encoded */ int nIn, /* Number of entries in aIn[] */ int iTabno, /* The table this key applies to */ KeyInfo *pKeyInfo, /* Collating sequence information */ u8 **pzOut, /* Write the resulting key here */ int *pnOut, /* Number of bytes in the key */ int *pnShort /* Number of bytes omitting primary key */ ); int sqlite4VdbeEncodeIntKey(u8 *aBuf,sqlite4_int64 v); int sqlite4VdbeDecodeIntKey(const KVByteArray*, KVSize, sqlite4_int64*); int sqlite4MemCompare(const Mem*, const Mem*, const CollSeq*); int sqlite4VdbeExec(Vdbe*); int sqlite4VdbeList(Vdbe*); int sqlite4VdbeHalt(Vdbe*); int sqlite4VdbeChangeEncoding(Mem *, int); int sqlite4VdbeMemTooBig(Mem*); int sqlite4VdbeMemCopy(Mem*, const Mem*); |
︙ | ︙ | |||
437 438 439 440 441 442 443 | int sqlite4VdbeMemStringify(Mem*, int); i64 sqlite4VdbeIntValue(Mem*); int sqlite4VdbeMemIntegerify(Mem*); double sqlite4VdbeRealValue(Mem*); void sqlite4VdbeIntegerAffinity(Mem*); int sqlite4VdbeMemRealify(Mem*); int sqlite4VdbeMemNumerify(Mem*); | | > > > < < < < < < < < | < < < | | < | 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | int sqlite4VdbeMemStringify(Mem*, int); i64 sqlite4VdbeIntValue(Mem*); int sqlite4VdbeMemIntegerify(Mem*); double sqlite4VdbeRealValue(Mem*); void sqlite4VdbeIntegerAffinity(Mem*); int sqlite4VdbeMemRealify(Mem*); int sqlite4VdbeMemNumerify(Mem*); void sqlite4VdbeMemRelease(Mem *p); void sqlite4VdbeMemReleaseExternal(Mem *p); #define VdbeMemRelease(X) \ if((X)->flags&(MEM_Agg|MEM_Dyn|MEM_RowSet|MEM_Frame)) \ sqlite4VdbeMemReleaseExternal(X); int sqlite4VdbeMemFinalize(Mem*, FuncDef*); const char *sqlite4OpcodeName(int); int sqlite4VdbeMemGrow(Mem *pMem, int n, int preserve); int sqlite4VdbeCloseStatement(Vdbe *, int); void sqlite4VdbeFrameDelete(VdbeFrame*); int sqlite4VdbeFrameRestore(VdbeFrame *); void sqlite4VdbeMemStoreType(Mem *pMem); int sqlite4VdbeTransferError(Vdbe *p); int sqlite4VdbeSeekEnd(VdbeCursor*, int); int sqlite4VdbeNext(VdbeCursor*); int sqlite4VdbePrevious(VdbeCursor*); #ifdef SQLITE_OMIT_MERGE_SORT # define sqlite4VdbeSorterInit(Y,Z) SQLITE_OK # define sqlite4VdbeSorterWrite(X,Y,Z) SQLITE_OK # define sqlite4VdbeSorterClose(Y,Z) # define sqlite4VdbeSorterRowkey(Y,Z) SQLITE_OK # define sqlite4VdbeSorterRewind(X,Y,Z) SQLITE_OK # define sqlite4VdbeSorterNext(X,Y,Z) SQLITE_OK # define sqlite4VdbeSorterCompare(X,Y,Z) SQLITE_OK #else int sqlite4VdbeSorterInit(sqlite4 *, VdbeCursor *); void sqlite4VdbeSorterClose(sqlite4 *, VdbeCursor *); int sqlite4VdbeSorterRowkey(VdbeCursor *, Mem *); int sqlite4VdbeSorterNext(sqlite4 *, VdbeCursor *, int *); int sqlite4VdbeSorterRewind(sqlite4 *, VdbeCursor *, int *); int sqlite4VdbeSorterWrite(sqlite4 *, VdbeCursor *, Mem *); int sqlite4VdbeSorterCompare(VdbeCursor *, Mem *, int *); #endif #ifdef SQLITE_DEBUG void sqlite4VdbeMemAboutToChange(Vdbe*,Mem*); #endif #ifndef SQLITE_OMIT_FOREIGN_KEY int sqlite4VdbeCheckFk(Vdbe *, int); #else # define sqlite4VdbeCheckFk(p,i) 0 #endif int sqlite4VdbeMemTranslate(Mem*, u8); #ifdef SQLITE_DEBUG void sqlite4VdbePrintSql(Vdbe*); void sqlite4VdbeMemPrettyPrint(Mem *pMem, char *zBuf); #endif int sqlite4VdbeMemHandleBom(Mem *pMem); #define sqlite4VdbeMemExpandBlob(x) SQLITE_OK #define ExpandBlob(P) SQLITE_OK #endif /* !defined(_VDBEINT_H_) */ |
Changes to src/vdbeapi.c.
︙ | ︙ | |||
304 305 306 307 308 309 310 | void sqlite4_result_error_nomem(sqlite4_context *pCtx){ assert( sqlite4_mutex_held(pCtx->s.db->mutex) ); sqlite4VdbeMemSetNull(&pCtx->s); pCtx->isError = SQLITE_NOMEM; pCtx->s.db->mallocFailed = 1; } | < < < < < < < < < < < < < < < < < < < < < | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | void sqlite4_result_error_nomem(sqlite4_context *pCtx){ assert( sqlite4_mutex_held(pCtx->s.db->mutex) ); sqlite4VdbeMemSetNull(&pCtx->s); pCtx->isError = SQLITE_NOMEM; pCtx->s.db->mallocFailed = 1; } /* ** Execute the statement pStmt, either until a row of data is ready, the ** statement is completely executed or an error occurs. ** ** This routine implements the bulk of the logic behind the sqlite_step() ** API. The only thing omitted is the automatic recompile if a ** schema change has occurred. That detail is handled by the |
︙ | ︙ | |||
421 422 423 424 425 426 427 | if( rc!=SQLITE_ROW && db->xProfile && !db->init.busy && p->zSql ){ sqlite4_int64 iNow; sqlite4OsCurrentTimeInt64(db->pVfs, &iNow); db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000); } #endif | < < < < < < < < | 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | if( rc!=SQLITE_ROW && db->xProfile && !db->init.busy && p->zSql ){ sqlite4_int64 iNow; sqlite4OsCurrentTimeInt64(db->pVfs, &iNow); db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000); } #endif db->errCode = rc; if( SQLITE_NOMEM==sqlite4ApiExit(p->db, p->rc) ){ p->rc = SQLITE_NOMEM; } end_of_step: /* At this point local variable rc holds the value that should be ** returned if this statement was compiled using the legacy |
︙ | ︙ |
Changes to src/vdbeaux.c.
︙ | ︙ | |||
202 203 204 205 206 207 208 | ** The zWhere string must have been obtained from sqlite4_malloc(). ** This routine will take ownership of the allocated memory. */ void sqlite4VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){ int j; int addr = sqlite4VdbeAddOp3(p, OP_ParseSchema, iDb, 0, 0); sqlite4VdbeChangeP4(p, addr, zWhere, P4_DYNAMIC); | | | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | ** The zWhere string must have been obtained from sqlite4_malloc(). ** This routine will take ownership of the allocated memory. */ void sqlite4VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){ int j; int addr = sqlite4VdbeAddOp3(p, OP_ParseSchema, iDb, 0, 0); sqlite4VdbeChangeP4(p, addr, zWhere, P4_DYNAMIC); for(j=0; j<p->db->nDb; j++) sqlite4VdbeUsesStorage(p, j); } /* ** Add an opcode that includes the p4 value as an integer. */ int sqlite4VdbeAddOp4Int( Vdbe *p, /* Add the opcode to this VM */ |
︙ | ︙ | |||
431 432 433 434 435 436 437 | int n; assert( p->nOp - i >= 3 ); assert( pOp[-1].opcode==OP_Integer ); n = pOp[-1].p1; if( n>nMaxArgs ) nMaxArgs = n; #endif }else if( opcode==OP_Next || opcode==OP_SorterNext ){ | | | | 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | int n; assert( p->nOp - i >= 3 ); assert( pOp[-1].opcode==OP_Integer ); n = pOp[-1].p1; if( n>nMaxArgs ) nMaxArgs = n; #endif }else if( opcode==OP_Next || opcode==OP_SorterNext ){ pOp->p4.xAdvance = sqlite4VdbeNext; pOp->p4type = P4_ADVANCE; }else if( opcode==OP_Prev ){ pOp->p4.xAdvance = sqlite4VdbePrevious; pOp->p4type = P4_ADVANCE; } if( (pOp->opflags & OPFLG_JUMP)!=0 && pOp->p2<0 ){ assert( -1-pOp->p2<p->nLabel ); pOp->p2 = aLabel[-1-pOp->p2]; } |
︙ | ︙ | |||
472 473 474 475 476 477 478 | ** the number of entries in the Vdbe.apArg[] array required to execute the ** returned program. */ VdbeOp *sqlite4VdbeTakeOpArray(Vdbe *p, int *pnOp, int *pnMaxArg){ VdbeOp *aOp = p->aOp; assert( aOp && !p->db->mallocFailed ); | < < < | 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | ** the number of entries in the Vdbe.apArg[] array required to execute the ** returned program. */ VdbeOp *sqlite4VdbeTakeOpArray(Vdbe *p, int *pnOp, int *pnMaxArg){ VdbeOp *aOp = p->aOp; assert( aOp && !p->db->mallocFailed ); resolveP2Values(p, pnMaxArg); *pnOp = p->nOp; p->aOp = 0; return aOp; } /* |
︙ | ︙ | |||
957 958 959 960 961 962 963 | } assert( zP4!=0 ); return zP4; } #endif /* | | < < < < < | < < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 | } assert( zP4!=0 ); return zP4; } #endif /* ** Declare to the Vdbe that the database at db->aDb[i] is used. */ void sqlite4VdbeUsesStorage(Vdbe *p, int i){ assert( i>=0 && i<p->db->nDb && i<(int)sizeof(yDbMask)*8 ); } #if defined(VDBE_PROFILE) || defined(SQLITE_DEBUG) /* ** Print a single opcode. This routine is used for debugging only. */ void sqlite4VdbePrintOp(FILE *pOut, int pc, Op *pOp){ char *zP4; |
︙ | ︙ | |||
1431 1432 1433 1434 1435 1436 1437 | p->pc = -1; p->rc = SQLITE_OK; p->errorAction = OE_Abort; p->magic = VDBE_MAGIC_RUN; p->nChange = 0; p->cacheCtr = 1; p->minWriteFileFormat = 255; | | | 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 | p->pc = -1; p->rc = SQLITE_OK; p->errorAction = OE_Abort; p->magic = VDBE_MAGIC_RUN; p->nChange = 0; p->cacheCtr = 1; p->minWriteFileFormat = 255; p->stmtTransMask = 0; p->nFkConstraint = 0; #ifdef VDBE_PROFILE for(i=0; i<p->nOp; i++){ p->aOp[i].cnt = 0; p->aOp[i].cycles = 0; } #endif |
︙ | ︙ | |||
1505 1506 1507 1508 1509 1510 1511 | /* Allocate space for memory registers, SQL variables, VDBE cursors and ** an array to marshal SQL function arguments in. */ zCsr = (u8*)&p->aOp[p->nOp]; /* Memory avaliable for allocation */ zEnd = (u8*)&p->aOp[p->nOpAlloc]; /* First byte past end of zCsr[] */ resolveP2Values(p, &nArg); | | | 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 | /* Allocate space for memory registers, SQL variables, VDBE cursors and ** an array to marshal SQL function arguments in. */ zCsr = (u8*)&p->aOp[p->nOp]; /* Memory avaliable for allocation */ zEnd = (u8*)&p->aOp[p->nOpAlloc]; /* First byte past end of zCsr[] */ resolveP2Values(p, &nArg); p->needSavepoint = (u8)(pParse->isMultiWrite && pParse->mayAbort); if( pParse->explain && nMem<10 ){ nMem = 10; } memset(zCsr, 0, zEnd-zCsr); zCsr += (zCsr - (u8*)0)&7; assert( EIGHT_BYTE_ALIGNMENT(zCsr) ); p->expired = 0; |
︙ | ︙ | |||
1575 1576 1577 1578 1579 1580 1581 | ** happens to hold. */ void sqlite4VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){ if( pCx==0 ){ return; } sqlite4VdbeSorterClose(p->db, pCx); | | > > | < < < < < | 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 | ** happens to hold. */ void sqlite4VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){ if( pCx==0 ){ return; } sqlite4VdbeSorterClose(p->db, pCx); if( pCx->pKVCur ){ sqlite4KVCursorClose(pCx->pKVCur); } if( pCx->pTmpKV ){ sqlite4KVStoreClose(pCx->pTmpKV); } #ifndef SQLITE_OMIT_VIRTUALTABLE if( pCx->pVtabCursor ){ sqlite4_vtab_cursor *pVtabCursor = pCx->pVtabCursor; const sqlite4_module *pModule = pCx->pModule; p->inVtabMethod = 1; pModule->xClose(pVtabCursor); p->inVtabMethod = 0; |
︙ | ︙ | |||
1753 1754 1755 1756 1757 1758 1759 | /* With this option, sqlite4VtabSync() is defined to be simply ** SQLITE_OK so p is not used. */ UNUSED_PARAMETER(p); #endif /* Before doing anything else, call the xSync() callback for any | | < < < < < < < | < | | | < | < < < < < < < < < < < < < < < < < < < < < | < < < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | < < < < < < | 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 | /* With this option, sqlite4VtabSync() is defined to be simply ** SQLITE_OK so p is not used. */ UNUSED_PARAMETER(p); #endif /* Before doing anything else, call the xSync() callback for any ** virtual module tables written in this transaction. */ rc = sqlite4VtabSync(db, &p->zErrMsg); /* Phase one commit */ for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ KVStore *pKV = db->aDb[i].pKV; if( pKV && pKV->iTransLevel ){ needXcommit = 1; rc = sqlite4KVStoreCommitPhaseOne(pKV, 0); } } /* If there are any write-transactions at all, invoke the commit hook */ if( needXcommit && db->xCommitCallback ){ rc = db->xCommitCallback(db->pCommitArg); if( rc ){ return SQLITE_CONSTRAINT; } } /* Do phase two of the commit */ for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ KVStore *pKV = db->aDb[i].pKV; if( pKV ){ rc = sqlite4KVStoreCommitPhaseTwo(pKV, 0); } } return rc; } /* ** This routine checks that the sqlite4.activeVdbeCnt count variable ** matches the number of vdbe's in the list sqlite4.pVdbe that are |
︙ | ︙ | |||
2003 2004 2005 2006 2007 2008 2009 | assert( cnt==db->activeVdbeCnt ); assert( nWrite==db->writeVdbeCnt ); } #else #define checkActiveVdbeCnt(x) #endif | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 | assert( cnt==db->activeVdbeCnt ); assert( nWrite==db->writeVdbeCnt ); } #else #define checkActiveVdbeCnt(x) #endif /* ** If the Vdbe passed as the first argument opened a statement-transaction, ** close it now. Argument eOp must be either SAVEPOINT_ROLLBACK or ** SAVEPOINT_RELEASE. If it is SAVEPOINT_ROLLBACK, then the statement ** transaction is rolled back. If eOp is SAVEPOINT_RELEASE, then the ** statement transaction is commtted. ** ** If an IO error occurs, an SQLITE_IOERR_XXX error code is returned. ** Otherwise SQLITE_OK. */ int sqlite4VdbeCloseStatement(Vdbe *p, int eOp){ return SQLITE_OK; } /* ** This function is called when a transaction opened by the database ** handle associated with the VM passed as an argument is about to be ** committed. If there are outstanding deferred foreign key constraint ** violations, return SQLITE_ERROR. Otherwise, SQLITE_OK. |
︙ | ︙ | |||
2130 2131 2132 2133 2134 2135 2136 | ** call this on a VM that is in the SQLITE_MAGIC_HALT state. ** ** Return an error code. If the commit could not complete because of ** lock contention, return SQLITE_BUSY. If SQLITE_BUSY is returned, it ** means the close did not happen and needs to be repeated. */ int sqlite4VdbeHalt(Vdbe *p){ | | < < < < < < < < < < < < < < < < < | < < | < < < | < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < | | < < < < | | | | | | | | | < | | | | | | | | | < < | | | < < < < < < | | < < | < < < < < < < > | | < < < < < < | < < < < | < < < < < < < < | < | | < < < < | | < < < < < < < < < < < | 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 | ** call this on a VM that is in the SQLITE_MAGIC_HALT state. ** ** Return an error code. If the commit could not complete because of ** lock contention, return SQLITE_BUSY. If SQLITE_BUSY is returned, it ** means the close did not happen and needs to be repeated. */ int sqlite4VdbeHalt(Vdbe *p){ int rc; sqlite4 *db = p->db; if( db->mallocFailed ) p->rc = SQLITE_NOMEM; if( p->aOnceFlag ) memset(p->aOnceFlag, 0, p->nOnceFlag); closeAllCursors(p); if( p->magic!=VDBE_MAGIC_RUN ){ return SQLITE_OK; } checkActiveVdbeCnt(db); if( p->pc<0 ){ /* No commit or rollback needed if the program never started */ }else{ /* Check for immediate foreign key violations. */ if( p->rc==SQLITE_OK ){ sqlite4VdbeCheckFk(p, 0); } /* If the auto-commit flag is set and this is the only active writer ** VM, then we do either a commit or rollback of the current transaction. */ if( !sqlite4VtabInSync(db) && db->autoCommit && db->writeVdbeCnt==(p->readOnly==0) ){ rc = sqlite4VdbeCheckFk(p, 1); if( rc!=SQLITE_OK ){ rc = SQLITE_CONSTRAINT; }else{ /* The auto-commit flag is true, the vdbe program was successful ** or hit an 'OR FAIL' constraint and there are no deferred foreign ** key constraints to hold up the transaction. This means a commit ** is required. */ rc = vdbeCommit(db, p); } if( rc==SQLITE_BUSY && p->readOnly ){ /* will return the error */ }else if( rc!=SQLITE_OK ){ p->rc = rc; sqlite4RollbackAll(db); }else{ db->nDeferredCons = 0; sqlite4CommitInternalChanges(db); } }else{ /* Not in auto-commit mode. If the statement failed, rollback ** the effects of just this one statement */ if( p->rc!=SQLITE_OK && p->stmtTransMask!=0 ){ int i; for(i=0; i<db->nDb; i++){ if( p->stmtTransMask & ((yDbMask)1)<<i ){ KVStore *pKV = db->aDb[i].pKV; rc = sqlite4KVStoreRollback(pKV, pKV->iTransLevel-1); if( rc ){ sqlite4RollbackAll(db); break; } } } } } } /* We have successfully halted and closed the VM. Record this fact. */ if( p->pc>=0 ){ db->activeVdbeCnt--; if( !p->readOnly ){ db->writeVdbeCnt--; } assert( db->activeVdbeCnt>=db->writeVdbeCnt ); } p->magic = VDBE_MAGIC_HALT; checkActiveVdbeCnt(db); if( p->db->mallocFailed ){ p->rc = SQLITE_NOMEM; } return (p->rc==SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK); } /* ** Each VDBE holds the result of the most recent sqlite4_step() call ** in p->rc. This routine sets that result back to SQLITE_OK. |
︙ | ︙ | |||
2519 2520 2521 2522 2523 2524 2525 | p->pNext->pPrev = p->pPrev; } p->magic = VDBE_MAGIC_DEAD; p->db = 0; sqlite4VdbeDeleteObject(db, p); } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 | p->pNext->pPrev = p->pPrev; } p->magic = VDBE_MAGIC_DEAD; p->db = 0; sqlite4VdbeDeleteObject(db, p); } /* ** The following functions: ** ** sqlite4VdbeSerialType() ** sqlite4VdbeSerialTypeLen() ** sqlite4VdbeSerialLen() ** sqlite4VdbeSerialPut() |
︙ | ︙ | |||
3072 3073 3074 3075 3076 3077 3078 | }else if( idx1<szHdr1 ){ rc = 1; } return rc; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 | }else if( idx1<szHdr1 ){ rc = 1; } return rc; } /* ** This routine sets the value to be returned by subsequent calls to ** sqlite4_changes() on the database handle 'db'. */ void sqlite4VdbeSetChanges(sqlite4 *db, int nChange){ assert( sqlite4_mutex_held(db->mutex) ); db->nChange = nChange; |
︙ | ︙ |
Deleted src/vdbeblob.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/vdbecodec.c.
︙ | ︙ | |||
73 74 75 76 77 78 79 80 81 82 83 | u32 size; /* Size of a field */ sqlite4_uint64 ofst; /* Offset to the payload */ sqlite4_uint64 type; /* Datatype */ sqlite4_uint64 subtype; /* Subtype for a typed blob */ int cclass; /* class of content */ int n; /* Offset into the header */ int i; /* Loop counter */ int endHdr; /* First byte past header */ sqlite4VdbeMemSetNull(pOut); assert( iVal<=p->mxCol ); | > | > > | > > | > > > > | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | u32 size; /* Size of a field */ sqlite4_uint64 ofst; /* Offset to the payload */ sqlite4_uint64 type; /* Datatype */ sqlite4_uint64 subtype; /* Subtype for a typed blob */ int cclass; /* class of content */ int n; /* Offset into the header */ int i; /* Loop counter */ int sz; /* Size of a varint */ int endHdr; /* First byte past header */ sqlite4VdbeMemSetNull(pOut); assert( iVal<=p->mxCol ); n = sqlite4GetVarint64(p->a, p->n, &ofst); if( n==0 ) return SQLITE_CORRUPT; ofst += n; endHdr = ofst; if( endHdr>p->n ) return SQLITE_CORRUPT; for(i=0; i<=iVal && n<endHdr; i++){ sz = sqlite4GetVarint64(p->a+n, p->n-n, &type); if( sz==0 ) return SQLITE_CORRUPT; n += sz; if( type>=22 ){ cclass = (type-22)%3; if( cclass==2 ){ sz = sqlite4GetVarint64(p->a+n, p->n-n, &subtype); if( sz==0 ) return SQLITE_CORRUPT; n += sz; } size = (type-22)/3; }else if( type<=2 ){ size = 0; }else if( type<=10 ){ size = type - 2; }else{ size = type - 9; |
︙ | ︙ | |||
107 108 109 110 111 112 113 | v = v*256 + p->a[ofst+i-3]; } sqlite4VdbeMemSetInt64(pOut, v); }else if( type<=21 ){ sqlite4_uint64 x; int e; double r; | | | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | v = v*256 + p->a[ofst+i-3]; } sqlite4VdbeMemSetInt64(pOut, v); }else if( type<=21 ){ sqlite4_uint64 x; int e; double r; n = sqlite4GetVarint64(p->a+ofst, p->n-ofst, &x); e = (int)x; n += sqlite4GetVarint64(p->a+ofst+n, p->n-(ofst+n), &x); if( n!=size ) return SQLITE_CORRUPT; r = (double)x; if( e&1 ) r = -r; if( e&2 ){ e = -(e>>2); while( e<=-10 ){ r /= 1.0e10; e += 10; } while( e<0 ){ r /= 10.0; e++; } |
︙ | ︙ | |||
138 139 140 141 142 143 144 | sqlite4VdbeMemSetStr(pOut, (char*)(p->a+ofst+1), size-1, enc[p->a[ofst]], SQLITE_TRANSIENT); } }else{ sqlite4VdbeMemSetStr(pOut, (char*)(p->a+ofst), size, 0, SQLITE_TRANSIENT); } } | > > | > > > > | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | sqlite4VdbeMemSetStr(pOut, (char*)(p->a+ofst+1), size-1, enc[p->a[ofst]], SQLITE_TRANSIENT); } }else{ sqlite4VdbeMemSetStr(pOut, (char*)(p->a+ofst), size, 0, SQLITE_TRANSIENT); } } if( i<iVal ){ if( pDefault ){ sqlite4VdbeMemShallowCopy(pOut, pDefault, MEM_Static); }else{ sqlite4VdbeMemSetNull(pOut); } } return SQLITE_OK; } /* ** Return the number of bytes needed to represent a 64-bit signed integer. */ static int significantBytes(sqlite4_int64 v){ |
︙ | ︙ | |||
340 341 342 343 344 345 346 | ** the integer from most significant to least significant, packed to ** digits to a byte. Each digit is represented by a number between 1 ** and 10 with 1 representing 0 and 10 representing 9. A zero value ** marks the end of the significand. An extra zero is added to fill out ** the final byte, if necessary. */ static void encodeIntKey(sqlite4_uint64 m, KeyEncoder *p){ | | | | > | | | < | | > | > > > > > > > > > > > > > > > > > > | < | | | | < < < | < | < | | | | | < < < | < | 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | ** the integer from most significant to least significant, packed to ** digits to a byte. Each digit is represented by a number between 1 ** and 10 with 1 representing 0 and 10 representing 9. A zero value ** marks the end of the significand. An extra zero is added to fill out ** the final byte, if necessary. */ static void encodeIntKey(sqlite4_uint64 m, KeyEncoder *p){ int i = 0; unsigned char aDigits[20]; assert( m>0 ); do{ aDigits[i++] = m%100; m /= 100; }while( m ); p->nOut += sqlite4PutVarint64(p->aOut+p->nOut, i); while( i ) p->aOut[p->nOut++] = aDigits[--i]*2 + 1; p->aOut[p->nOut-1] &= 0xfe; } /* ** Encode a single integer using the key encoding. The caller must ** ensure that sufficient space exits in a[] (at least 12 bytes). ** The return value is the number of bytes of a[] used. */ int sqlite4VdbeEncodeIntKey(u8 *a, sqlite4_int64 v){ int i; KeyEncoder s; s.aOut = a; s.nOut = 1; if( v<0 ){ a[0] = 0x08; encodeIntKey((sqlite4_uint64)-v, &s); for(i=1; i<s.nOut; i++) a[i] ^= 0xff; }else{ a[0] = 0x0c; encodeIntKey((sqlite4_uint64)v, &s); } return s.nOut; } /* ** Encode the small positive floating point number r using the key ** encoding. The caller guarantees that r will be less than 1.0 and ** greater than 0.0. ** ** The key encoding is the negative of the exponent E followed by the ** mantessa M. The exponent E is one less than the number of digits to ** the left of the decimal point. Since r is less than 1, E will always ** be negative here. E is output as a varint, and varints must be ** positive, which is why we output -E. The mantissa is stored two-digits ** per byte as described for the integer encoding above. */ static void encodeSmallFloatKey(double r, KeyEncoder *p){ int e = 0; int i, n; assert( r>0.0 && r<1.0 ); while( r<1e-8 ){ r *= 1e8; e+=4; } while( r<1.0 ){ r *= 100.0; e++; } n = sqlite4PutVarint64(p->aOut+p->nOut, e); for(i=0; i<n; i++) p->aOut[i+p->nOut] ^= 0xff; p->nOut += n; for(i=0; i<18 && r!=0.0; i++){ int d = r; p->aOut[p->nOut++] = 2*d + 1; r -= d; r *= 100.0; } p->aOut[p->nOut-1] &= 0xfe; } /* ** Encode the large positive floating point number r using the key ** encoding. The caller guarantees that r will be finite and greater than ** or equal to 1.0. ** ** The key encoding is the exponent E followed by the mantessa M. ** The exponent E is one less than the number of digits to the left ** of the decimal point. Since r is at least than 1.0, E will always ** be non-negative here. The mantissa is stored two-digits per byte ** as described for the integer encoding above. */ static void encodeLargeFloatKey(double r, KeyEncoder *p){ int e = 0; int i, n; assert( r>=1.0 ); while( r>=1e32 && e<=350 ){ r *= 1e-32; e+=16; } while( r>=1e8 && e<=350 ){ r *= 1e-8; e+=4; } while( r>=100.0 && e<=350 ){ r *= 0.01; e++; } while( r<1.0 ){ r *= 10.0; e--; } n = sqlite4PutVarint64(p->aOut+p->nOut, e); p->nOut += n; for(i=0; i<18 && r!=0.0; i++){ int d = r; p->aOut[p->nOut++] = 2*d + 1; r -= d; r *= 100.0; } p->aOut[p->nOut-1] &= 0xfe; } /* ** Encode a single column of the key */ static int encodeOneKeyValue( |
︙ | ︙ | |||
544 545 546 547 548 549 550 | int sqlite4VdbeEncodeKey( sqlite4 *db, /* The database connection */ Mem *aIn, /* Values to be encoded */ int nIn, /* Number of entries in aIn[] */ int iTabno, /* The table this key applies to */ KeyInfo *pKeyInfo, /* Collating sequence information */ u8 **paOut, /* Write the resulting key here */ | | > | > > > > > > | < > | > > > > > > > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | int sqlite4VdbeEncodeKey( sqlite4 *db, /* The database connection */ Mem *aIn, /* Values to be encoded */ int nIn, /* Number of entries in aIn[] */ int iTabno, /* The table this key applies to */ KeyInfo *pKeyInfo, /* Collating sequence information */ u8 **paOut, /* Write the resulting key here */ int *pnOut, /* Number of bytes in the key */ int *pnShort /* Number of bytes without the primary key */ ){ int i; int rc = SQLITE_OK; KeyEncoder x; u8 *so; int iShort; int nField; CollSeq **aColl; CollSeq *xColl; static const CollSeq defaultColl; x.db = db; x.aOut = 0; x.nOut = 0; x.nAlloc = 0; *paOut = 0; *pnOut = 0; if( enlargeEncoderAllocation(&x, (nIn+1)*10) ) return SQLITE_NOMEM; x.nOut = sqlite4PutVarint64(x.aOut, iTabno); if( pKeyInfo ){ nField = pKeyInfo->nField; iShort = nField - pKeyInfo->nPK; aColl = pKeyInfo->aColl; so = pKeyInfo->aSortOrder; }else{ nField = 1; iShort = 0; xColl = &defaultColl; aColl = &xColl; so = 0; } for(i=0; i<nField && rc==SQLITE_OK; i++){ if( pnShort && i==iShort ) *pnShort = x.nOut; rc = encodeOneKeyValue(&x, aIn+i, so ? so[i] : SQLITE_SO_ASC, aColl[i]); } if( rc ){ sqlite4DbFree(db, x.aOut); }else{ *paOut = x.aOut; *pnOut = x.nOut; } return rc; } /* ** Decode an integer key encoding. Return the number of bytes in the ** encoding on success. On an error, return 0. */ int sqlite4VdbeDecodeIntKey( const KVByteArray *aKey, /* Input encoding */ KVSize nKey, /* Number of bytes in aKey[] */ sqlite4_int64 *pVal /* Write the result here */ ){ int isNeg; int e; int i, n; sqlite4_int64 m; KVByteArray aBuf[12]; if( nKey<3 ) return 0; if( nKey>sizeof(aBuf) ) nKey = sizeof(aBuf); if( aKey[0]==0x08 ){ isNeg = 1; memcpy(aBuf, aKey, nKey); aKey = aBuf; for(i=1; i<nKey; i++) aBuf[i] ^= 0xff; }else if( aKey[0]==0x0c ){ isNeg = 0; }else{ return 0; } n = sqlite4GetVarint64(aKey+1, nKey-1, (sqlite4_uint64*)&m); if( m>10 || m==0 ) return 0; e = m; if( n==0 || n+1>=nKey ) return 0; m = 0; i = n+1; do{ m = m*100 + aKey[i]/2; e--; }while( aKey[i++] & 1 ); if( isNeg ){ *pVal = -m; }else{ *pVal = m; } return m==0 ? 0 : i; } |
Added src/vdbecursor.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | /* ** 2012 February 16 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This file contains methods for the VdbeCursor object. ** ** A VdbeCursor is an abstraction of the KVCursor that includes knowledge ** about different "tables" in the key space. A VdbeCursor is only active ** over a particular table. Thus, for example, sqlite4VdbeNext() will ** return SQLITE_NOTFOUND when advancing off the end of a table into the ** next table whereas the lower-level sqlite4KVCursorNext() routine will ** not return SQLITE_NOTFOUND until it is advanced off the end of the very ** last table in the database. */ #include "sqliteInt.h" #include "vdbeInt.h" /* ** Move a VDBE cursor to the first or to the last element of its table. The ** first element is sought if iEnd==+1 and the last element if iEnd==-1. ** ** Return SQLITE_OK on success. Return SQLITE_NOTFOUND if the table is empty. * Other error codes are also possible for various kinds of errors. */ int sqlite4VdbeSeekEnd(VdbeCursor *pC, int iEnd){ KVCursor *pCur = pC->pKVCur; const KVByteArray *aKey; KVSize nKey; KVSize nProbe; int rc; KVByteArray aProbe[16]; assert( iEnd==(+1) || iEnd==(-1) ); nProbe = sqlite4PutVarint64(aProbe, pC->iRoot); aProbe[nProbe++] = 10 - iEnd*6; rc = sqlite4KVCursorSeek(pCur, aProbe, nProbe, iEnd); if( rc==SQLITE_OK ){ return SQLITE_CORRUPT; } if( rc==SQLITE_INEXACT ){ rc = sqlite4KVCursorKey(pCur, &aKey, &nKey); if( rc==SQLITE_OK && (nKey<nProbe-1 || memcmp(aKey, aProbe, nProbe-1)!=0) ){ rc = SQLITE_NOTFOUND; } } return rc; } /* ** Move a VDBE cursor to the next element in its table. ** Return SQLITE_NOTFOUND if the seek falls of the end of the table. */ int sqlite4VdbeNext(VdbeCursor *pC){ KVCursor *pCur = pC->pKVCur; const KVByteArray *aKey; KVSize nKey; int rc; sqlite4_uint64 iTabno; rc = sqlite4KVCursorNext(pCur); if( rc==SQLITE_OK ){ rc = sqlite4KVCursorKey(pCur, &aKey, &nKey); if( rc==SQLITE_OK ){ iTabno = 0; sqlite4GetVarint64(aKey, nKey, &iTabno); if( iTabno!=pC->iRoot ) rc = SQLITE_NOTFOUND; } } return rc; } /* ** Move a VDBE cursor to the previous element in its table. ** Return SQLITE_NOTFOUND if the seek falls of the end of the table. */ int sqlite4VdbePrevious(VdbeCursor *pC){ KVCursor *pCur = pC->pKVCur; const KVByteArray *aKey; KVSize nKey; int rc; sqlite4_uint64 iTabno; rc = sqlite4KVCursorPrev(pCur); if( rc==SQLITE_OK ){ rc = sqlite4KVCursorKey(pCur, &aKey, &nKey); if( rc==SQLITE_OK ){ iTabno = 0; sqlite4GetVarint64(aKey, nKey, &iTabno); if( iTabno!=pC->iRoot ) rc = SQLITE_NOTFOUND; } } return rc; } |
Changes to src/vdbemem.c.
︙ | ︙ | |||
131 132 133 134 135 136 137 | pMem->pScopyFrom = 0; #endif } return SQLITE_OK; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | pMem->pScopyFrom = 0; #endif } return SQLITE_OK; } /* ** Make sure the given Mem is \u0000 terminated. */ int sqlite4VdbeMemNulTerminate(Mem *pMem){ assert( pMem->db==0 || sqlite4_mutex_held(pMem->db->mutex) ); if( (pMem->flags & MEM_Term)!=0 || (pMem->flags & MEM_Str)==0 ){ |
︙ | ︙ | |||
496 497 498 499 500 501 502 | sqlite4VdbeMemRelease(pMem); pMem->flags = MEM_Blob|MEM_Zero; pMem->type = SQLITE_BLOB; pMem->n = 0; if( n<0 ) n = 0; pMem->u.nZero = n; pMem->enc = SQLITE_UTF8; | < < < < < < < < | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | sqlite4VdbeMemRelease(pMem); pMem->flags = MEM_Blob|MEM_Zero; pMem->type = SQLITE_BLOB; pMem->n = 0; if( n<0 ) n = 0; pMem->u.nZero = n; pMem->enc = SQLITE_UTF8; } /* ** Delete any previous value and set the value stored in *pMem to val, ** manifest type INTEGER. */ void sqlite4VdbeMemSetInt64(Mem *pMem, i64 val){ |
︙ | ︙ | |||
867 868 869 870 871 872 873 | } /* Both values must be blobs. Compare using memcmp(). */ rc = memcmp(pMem1->z, pMem2->z, (pMem1->n>pMem2->n)?pMem2->n:pMem1->n); if( rc==0 ){ rc = pMem1->n - pMem2->n; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 830 831 832 833 834 835 836 837 838 839 840 841 842 843 | } /* Both values must be blobs. Compare using memcmp(). */ rc = memcmp(pMem1->z, pMem2->z, (pMem1->n>pMem2->n)?pMem2->n:pMem1->n); if( rc==0 ){ rc = pMem1->n - pMem2->n; } return rc; } /* This function is only available internally, it is not part of the ** external API. It works in a similar way to sqlite4_value_text(), ** except the data returned is in the encoding specified by the second ** parameter, which must be one of SQLITE_UTF16BE, SQLITE_UTF16LE or |
︙ | ︙ |
Changes to src/vdbesort.c.
︙ | ︙ | |||
380 381 382 383 384 385 386 | return SQLITE_OK; } /* ** Initialize the temporary index cursor just opened as a sorter cursor. */ int sqlite4VdbeSorterInit(sqlite4 *db, VdbeCursor *pCsr){ | < < | < < < | 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | return SQLITE_OK; } /* ** Initialize the temporary index cursor just opened as a sorter cursor. */ int sqlite4VdbeSorterInit(sqlite4 *db, VdbeCursor *pCsr){ int mxCache; /* Cache size */ VdbeSorter *pSorter; /* The new sorter */ char *d; /* Dummy */ assert( pCsr->pKeyInfo && pCsr->pBt==0 ); pCsr->pSorter = pSorter = sqlite4DbMallocZero(db, sizeof(VdbeSorter)); if( pSorter==0 ){ return SQLITE_NOMEM; } pSorter->pUnpacked = sqlite4VdbeAllocUnpackedRecord(pCsr->pKeyInfo, 0, 0, &d); if( pSorter->pUnpacked==0 ) return SQLITE_NOMEM; assert( pSorter->pUnpacked==(UnpackedRecord *)d ); if( !sqlite4TempInMemory(db) ){ pSorter->mnPmaSize = 100000; } return SQLITE_OK; } /* ** Free the list of sorted records starting at pRecord. |
︙ | ︙ |
Changes to src/vtab.c.
︙ | ︙ | |||
149 150 151 152 153 154 155 | ** connection db is left in the p->pVTable list. */ static VTable *vtabDisconnectAll(sqlite4 *db, Table *p){ VTable *pRet = 0; VTable *pVTable = p->pVTable; p->pVTable = 0; | < < < < < < < < | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | ** connection db is left in the p->pVTable list. */ static VTable *vtabDisconnectAll(sqlite4 *db, Table *p){ VTable *pRet = 0; VTable *pVTable = p->pVTable; p->pVTable = 0; while( pVTable ){ sqlite4 *db2 = pVTable->db; VTable *pNext = pVTable->pNext; assert( db2 ); if( db2==db ){ pRet = pVTable; p->pVTable = pRet; |
︙ | ︙ | |||
201 202 203 204 205 206 207 | ** As a result, a sqlite4.pDisconnect cannot be accessed simultaneously ** by multiple threads. It is thread-safe. */ void sqlite4VtabUnlockList(sqlite4 *db){ VTable *p = db->pDisconnect; db->pDisconnect = 0; | < | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | ** As a result, a sqlite4.pDisconnect cannot be accessed simultaneously ** by multiple threads. It is thread-safe. */ void sqlite4VtabUnlockList(sqlite4 *db){ VTable *p = db->pDisconnect; db->pDisconnect = 0; assert( sqlite4_mutex_held(db->mutex) ); if( p ){ sqlite4ExpirePreparedStatements(db); do { VTable *pNext = p->pNext; sqlite4VtabUnlock(p); |
︙ | ︙ | |||
394 395 396 397 398 399 400 | ** allows a schema that contains virtual tables to be loaded before ** the required virtual table implementations are registered. */ else { Table *pOld; Schema *pSchema = pTab->pSchema; const char *zName = pTab->zName; int nName = sqlite4Strlen30(zName); | < | 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | ** allows a schema that contains virtual tables to be loaded before ** the required virtual table implementations are registered. */ else { Table *pOld; Schema *pSchema = pTab->pSchema; const char *zName = pTab->zName; int nName = sqlite4Strlen30(zName); pOld = sqlite4HashInsert(&pSchema->tblHash, zName, nName, pTab); if( pOld ){ db->mallocFailed = 1; assert( pTab==pOld ); /* Malloc must have failed inside HashInsert() */ return; } pParse->pNewTable = 0; |
︙ | ︙ |
Changes to src/where.c.
︙ | ︙ | |||
1618 1619 1620 1621 1622 1623 1624 | if( wsFlags & WHERE_COLUMN_IN ) return 0; if( pIdx->bUnordered ) return 0; nTerm = pOrderBy->nExpr; assert( nTerm>0 ); /* Argument pIdx must either point to a 'real' named index structure, | | | 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 | if( wsFlags & WHERE_COLUMN_IN ) return 0; if( pIdx->bUnordered ) return 0; nTerm = pOrderBy->nExpr; assert( nTerm>0 ); /* Argument pIdx must either point to a 'real' named index structure, ** or an index structure allocated on the stack by bestKVIndex() to ** represent the rowid index that is part of every table. */ assert( pIdx->zName || (pIdx->nColumn==1 && pIdx->aiColumn[0]==-1) ); /* Match terms of the ORDER BY clause against columns of ** the index. ** ** Note that indices have pIdx->nColumn regular columns plus |
︙ | ︙ | |||
2410 2411 2412 2413 2414 2415 2416 | if( pUsage[i].argvIndex>0 ){ pCost->used |= pWC->a[pIdxCons[i].iTermOffset].prereqRight; } } /* If there is an ORDER BY clause, and the selected virtual table index ** does not satisfy it, increase the cost of the scan accordingly. This | | | 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 | if( pUsage[i].argvIndex>0 ){ pCost->used |= pWC->a[pIdxCons[i].iTermOffset].prereqRight; } } /* If there is an ORDER BY clause, and the selected virtual table index ** does not satisfy it, increase the cost of the scan accordingly. This ** matches the processing for non-virtual tables in bestKVIndex(). */ rCost = pIdxInfo->estimatedCost; if( pOrderBy && pIdxInfo->orderByConsumed==0 ){ rCost += estLog(rCost)*rCost; } /* The cost is not allowed to be larger than SQLITE_BIG_DBL (the |
︙ | ︙ | |||
2867 2868 2869 2870 2871 2872 2873 | ** then the cost is calculated in the usual way. ** ** If a NOT INDEXED clause (pSrc->notIndexed!=0) was attached to the table ** in the SELECT statement, then no indexes are considered. However, the ** selected plan may still take advantage of the built-in rowid primary key ** index. */ | | | 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 | ** then the cost is calculated in the usual way. ** ** If a NOT INDEXED clause (pSrc->notIndexed!=0) was attached to the table ** in the SELECT statement, then no indexes are considered. However, the ** selected plan may still take advantage of the built-in rowid primary key ** index. */ static void bestKVIndex( Parse *pParse, /* The parsing context */ WhereClause *pWC, /* The WHERE clause */ struct SrcList_item *pSrc, /* The FROM clause term to search */ Bitmask notReady, /* Mask of cursors not available for indexing */ Bitmask notValid, /* Cursors not available for any purpose */ ExprList *pOrderBy, /* The ORDER BY clause */ ExprList *pDistinct, /* The select-list if query is DISTINCT */ |
︙ | ︙ | |||
3370 3371 3372 3373 3374 3375 3376 | if( p->needToFreeIdxStr ){ sqlite4_free(p->idxStr); } sqlite4DbFree(pParse->db, p); }else #endif { | | | 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 | if( p->needToFreeIdxStr ){ sqlite4_free(p->idxStr); } sqlite4DbFree(pParse->db, p); }else #endif { bestKVIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, 0, pCost); } } /* ** Disable a term in the WHERE clause. Except, do not disable the term ** if it controls a LEFT OUTER JOIN and it did not originate in the ON ** or USING clause of that join. |
︙ | ︙ | |||
4534 4535 4536 4537 4538 4539 4540 | ** ** Note that the loops might not be nested in the order in which they ** appear in the FROM clause if a different order is better able to make ** use of indices. Note also that when the IN operator appears in ** the WHERE clause, it might result in additional nested loops for ** scanning through all values on the right-hand side of the IN. ** | | | 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 | ** ** Note that the loops might not be nested in the order in which they ** appear in the FROM clause if a different order is better able to make ** use of indices. Note also that when the IN operator appears in ** the WHERE clause, it might result in additional nested loops for ** scanning through all values on the right-hand side of the IN. ** ** There are cursors associated with each table. t1 uses cursor ** number pTabList->a[0].iCursor. t2 uses the cursor pTabList->a[1].iCursor. ** And so forth. This routine generates code to open those VDBE cursors ** and sqlite4WhereEnd() generates the code to close them. ** ** The code that sqlite4WhereBegin() generates leaves the cursors named ** in pTabList pointing at their appropriate entries. The [...] code ** can use OP_Column and OP_Rowid opcodes on these cursors to extract |
︙ | ︙ | |||
4844 4845 4846 4847 4848 4849 4850 | if( IsVirtual(pTabItem->pTab) ){ sqlite4_index_info **pp = &pWInfo->a[j].pIdxInfo; bestVirtualIndex(pParse, pWC, pTabItem, mask, notReady, pOrderBy, &sCost, pp); }else #endif { | | | 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 | if( IsVirtual(pTabItem->pTab) ){ sqlite4_index_info **pp = &pWInfo->a[j].pIdxInfo; bestVirtualIndex(pParse, pWC, pTabItem, mask, notReady, pOrderBy, &sCost, pp); }else #endif { bestKVIndex(pParse, pWC, pTabItem, mask, notReady, pOrderBy, pDist, &sCost); } assert( isOptimal || (sCost.used¬Ready)==0 ); /* If an INDEXED BY clause is present, then the plan must use that ** index if it uses any index at all */ assert( pTabItem->pIndex==0 |
︙ | ︙ |
Deleted test/backup.test.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted test/backup2.test.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted test/backup_ioerr.test.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted test/backup_malloc.test.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted test/incrblob.test.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted test/incrblob2.test.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted test/incrblob3.test.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted test/incrblob_err.test.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted test/incrblobfault.test.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |