Hello shess,

I'd like you to do a code review.  Please execute
        g4 diff -c 9359314

or point your web browser to
        http://mondrian/9359314

to review the following code:

Change 9359314 by mpcompl...@mpcomplete-gears on 2008/12/10 16:37:42 *pending*

        Merge in changes from Chrome's copy of sqlite.
        
        I disabled sqlite3PagerLoadall because it was written for sqlite 3.4.2 
using APIs that no longer exist.
        
        R=shess
        [email protected],brettw,evanm
        DELTA=551  (296 added, 71 deleted, 184 changed)
        OCL=9359314

Affected files ...

... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/README.google#3 
edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2.c#6
 edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2_icu.c#1
 edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2_tokenizer.c#2
 edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/ext/icu/icu.c#2 
edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/preprocessed/opcodes.c#2
 edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/preprocessed/opcodes.h#2
 edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/preprocessed/sqlite3.h#2
 edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/src/build.c#3 
edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/src/pager.c#2 
edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/src/pager.h#2 
edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/src/shell.c#2 
edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/src/sqlite.h.in#2
 edit

551 delta lines: 296 added, 71 deleted, 184 changed

Also consider running:
        g4 lint -c 9359314

which verifies that the changelist doesn't introduce new style violations.

If you can't do the review, please let me know as soon as possible.  During
your review, please ensure that all new code has corresponding unit tests and
that existing unit tests are updated appropriately.  Visit
http://www/eng/code_review.html for more information.

This is a semiautomated message from "g4 mail".  Complaints or suggestions?
Mail [email protected].
Change 9359314 by mpcompl...@mpcomplete-gears on 2008/12/10 16:37:42 *pending*

        Merge in changes from Chrome's copy of sqlite.
        
        I disabled sqlite3PagerLoadall because it was written for sqlite 3.4.2 
using APIs that no longer exist. 
        
        R=shess
        [email protected],brettw,evanm
        DELTA=551  (296 added, 71 deleted, 184 changed)
        OCL=9359314

Affected files ...

... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/README.google#3 
edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2.c#6
 edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2_icu.c#1
 edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2_tokenizer.c#2
 edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/ext/icu/icu.c#2 
edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/preprocessed/opcodes.c#2
 edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/preprocessed/opcodes.h#2
 edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/preprocessed/sqlite3.h#2
 edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/src/build.c#3 
edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/src/pager.c#2 
edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/src/pager.h#2 
edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/src/shell.c#2 
edit
... 
//depot/googleclient/gears/opensource/third_party/sqlite_google/src/sqlite.h.in#2
 edit

==== 
//depot/googleclient/gears/opensource/third_party/sqlite_google/README.google#3 
- 
C:\src\gears/googleclient/gears/opensource/third_party/sqlite_google/README.google
 ====
# action=edit type=text
--- googleclient/gears/opensource/third_party/sqlite_google/README.google       
2008-12-10 16:37:40.000000000 -0800
+++ googleclient/gears/opensource/third_party/sqlite_google/README.google       
2008-12-11 12:27:05.000000000 -0800
@@ -96,3 +96,23 @@
  - Modifications to Makefile.linux-gcc and main.mk for compiling
    SQLite tests.
  - Compile warning fixed in func.c (check if this is still needed)
+
+Changes from Chrome:
+ - I marked all changes I made with "evanm", so you can find them with
+   "grep evanm *".
+ - Most files include sqlite3ext.h with SQLITE_CORE #defined, but two don't:
+   fts2_tokenizer.c and icu.c.  Without this #define, the calls in
+   fts2_tokenizer.c try to go through some pointer to the sqlite API instead
+   of calling the functions directly (to work as a loadable module), but then
+   crash (because the other files never initialize that loadable module
+   support).  As a hack I #defined it in these files, but it'd be nice to
+   figure out what really ought to happen here (perhaps this file is new and
+   hasn't been tested to verify it works right).
+ - shell_icu.c is a Chrome-specific file used to load our ICU data.  shell.c
+   has been modifed to call into shell_icu.c.
+ - fts2_icu.c has a critical bug. U8_NEXT is used over a UTF-16 string. It's
+   rep$ by U16_NEXT (jungshik)
+ - Added a new function sqlite3Preload we use to prime the database cache. It
+   allows much faster performance by reading the file in one contiguous
+   operation rather than bringing it in organically, which involves a lot of
+   seeking.
==== 
//depot/googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2.c#6
 - 
C:\src\gears/googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2.c
 ====
# action=edit type=text
--- googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2.c     
2008-12-10 16:37:41.000000000 -0800
+++ googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2.c     
2008-12-11 12:27:05.000000000 -0800
@@ -3595,6 +3595,16 @@
       pQuery->nextIsOr = 1;
       continue;
     }
+    
+    // If a tokenizer recognizes "*" as a separate word, we mark the word
+    // before it as a prefix search.  The other isPrefix code below that tests
+    // for a word that's tokenized with the star as its last character.
+    // TODO(evanm): this is incorrect in that "foo *" parses as "foo*".
+    if( pQuery->nTerms>0 && nToken==1 && pSegment[iBegin]=='*' ){
+      pQuery->pTerms[pQuery->nTerms-1].isPrefix = 1;
+      continue;
+    }
+    
     queryAdd(pQuery, pToken, nToken);
     if( !inPhrase && iBegin>0 && pSegment[iBegin-1]=='-' ){
       pQuery->pTerms[pQuery->nTerms-1].isNot = 1;
==== 
//depot/googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2_icu.c#1
 - 
C:\src\gears/googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2_icu.c
 ====
# action=edit type=text
--- googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2_icu.c 
2008-12-10 16:37:41.000000000 -0800
+++ googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2_icu.c 
2008-12-11 12:27:05.000000000 -0800
@@ -196,7 +196,7 @@
 
     while( iStart<iEnd ){
       int iWhite = iStart;
-      U8_NEXT(pCsr->aChar, iWhite, pCsr->nChar, c);
+      U16_NEXT(pCsr->aChar, iWhite, pCsr->nChar, c);
       if( u_isspace(c) ){
         iStart = iWhite;
       }else{
==== 
//depot/googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2_tokenizer.c#2
 - 
C:\src\gears/googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2_tokenizer.c
 ====
# action=edit type=text
--- 
googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2_tokenizer.c
   2008-12-10 16:37:41.000000000 -0800
+++ 
googleclient/gears/opensource/third_party/sqlite_google/ext/fts2/fts2_tokenizer.c
   2008-12-11 12:27:06.000000000 -0800
@@ -25,6 +25,9 @@
 */
 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2)
 
+// TODO(evanm): figure out why this is the only file that #includes sqlite3.h
+// without #defining SQLITE_CORE first.
+#define SQLITE_CORE 1
 
 #include "sqlite3.h"
 #include "sqlite3ext.h"
==== 
//depot/googleclient/gears/opensource/third_party/sqlite_google/ext/icu/icu.c#2 
- 
C:\src\gears/googleclient/gears/opensource/third_party/sqlite_google/ext/icu/icu.c
 ====
# action=edit type=text
--- googleclient/gears/opensource/third_party/sqlite_google/ext/icu/icu.c       
2008-12-10 16:37:41.000000000 -0800
+++ googleclient/gears/opensource/third_party/sqlite_google/ext/icu/icu.c       
2008-12-11 12:27:06.000000000 -0800
@@ -37,6 +37,11 @@
 #include <unicode/ucol.h>
 
 #include <assert.h>
+
+// TODO(evanm): this is cut'n'pasted from fts2.c.  Why is it necessary?
+#if defined(SQLITE_ENABLE_FTS2) && !defined(SQLITE_CORE)
+# define SQLITE_CORE 1
+#endif
 
 #ifndef SQLITE_CORE
   #include "sqlite3ext.h"
==== 
//depot/googleclient/gears/opensource/third_party/sqlite_google/preprocessed/opcodes.c#2
 - 
C:\src\gears/googleclient/gears/opensource/third_party/sqlite_google/preprocessed/opcodes.c
 ====
# action=edit type=text
--- 
googleclient/gears/opensource/third_party/sqlite_google/preprocessed/opcodes.c  
    2008-12-10 16:37:41.000000000 -0800
+++ 
googleclient/gears/opensource/third_party/sqlite_google/preprocessed/opcodes.c  
    2008-12-11 12:27:06.000000000 -0800
@@ -3,70 +3,70 @@
 #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) 
|| defined(SQLITE_DEBUG)
 const char *sqlite3OpcodeName(int i){
  static const char *const azName[] = { "?",
-     /*   1 */ "VNext",
-     /*   2 */ "Affinity",
-     /*   3 */ "Column",
-     /*   4 */ "SetCookie",
-     /*   5 */ "Sequence",
-     /*   6 */ "MoveGt",
-     /*   7 */ "RowKey",
-     /*   8 */ "SCopy",
-     /*   9 */ "OpenWrite",
-     /*  10 */ "If",
-     /*  11 */ "VRowid",
-     /*  12 */ "CollSeq",
-     /*  13 */ "OpenRead",
-     /*  14 */ "Expire",
-     /*  15 */ "AutoCommit",
+     /*   1 */ "NotExists",
+     /*   2 */ "MoveLt",
+     /*   3 */ "IncrVacuum",
+     /*   4 */ "VCreate",
+     /*   5 */ "ResultRow",
+     /*   6 */ "DropTrigger",
+     /*   7 */ "OpenPseudo",
+     /*   8 */ "Affinity",
+     /*   9 */ "IntegrityCk",
+     /*  10 */ "RowKey",
+     /*  11 */ "LoadAnalysis",
+     /*  12 */ "Last",
+     /*  13 */ "SetCookie",
+     /*  14 */ "Sequence",
+     /*  15 */ "VRename",
      /*  16 */ "Not",
-     /*  17 */ "Pagecount",
-     /*  18 */ "IntegrityCk",
-     /*  19 */ "Sort",
-     /*  20 */ "Copy",
-     /*  21 */ "Trace",
-     /*  22 */ "Function",
-     /*  23 */ "IfNeg",
-     /*  24 */ "Noop",
-     /*  25 */ "Return",
-     /*  26 */ "NewRowid",
-     /*  27 */ "Variable",
-     /*  28 */ "String",
-     /*  29 */ "RealAffinity",
-     /*  30 */ "VRename",
-     /*  31 */ "ParseSchema",
-     /*  32 */ "VOpen",
-     /*  33 */ "Close",
-     /*  34 */ "CreateIndex",
-     /*  35 */ "IsUnique",
-     /*  36 */ "NotFound",
-     /*  37 */ "Int64",
-     /*  38 */ "MustBeInt",
-     /*  39 */ "Halt",
-     /*  40 */ "Rowid",
-     /*  41 */ "IdxLT",
-     /*  42 */ "AddImm",
-     /*  43 */ "Statement",
-     /*  44 */ "RowData",
-     /*  45 */ "MemMax",
-     /*  46 */ "NotExists",
-     /*  47 */ "Gosub",
-     /*  48 */ "Integer",
-     /*  49 */ "Prev",
-     /*  50 */ "VColumn",
-     /*  51 */ "CreateTable",
-     /*  52 */ "Last",
-     /*  53 */ "IncrVacuum",
-     /*  54 */ "IdxRowid",
-     /*  55 */ "ResetCount",
-     /*  56 */ "FifoWrite",
-     /*  57 */ "ContextPush",
-     /*  58 */ "Yield",
-     /*  59 */ "DropTrigger",
+     /*  17 */ "SCopy",
+     /*  18 */ "VUpdate",
+     /*  19 */ "VColumn",
+     /*  20 */ "DropTable",
+     /*  21 */ "ContextPush",
+     /*  22 */ "Rowid",
+     /*  23 */ "VFilter",
+     /*  24 */ "NullRow",
+     /*  25 */ "Noop",
+     /*  26 */ "VRowid",
+     /*  27 */ "ParseSchema",
+     /*  28 */ "Statement",
+     /*  29 */ "CollSeq",
+     /*  30 */ "ContextPop",
+     /*  31 */ "MoveGe",
+     /*  32 */ "If",
+     /*  33 */ "IfNot",
+     /*  34 */ "Destroy",
+     /*  35 */ "Permutation",
+     /*  36 */ "CreateIndex",
+     /*  37 */ "SetNumColumns",
+     /*  38 */ "ResetCount",
+     /*  39 */ "Goto",
+     /*  40 */ "IdxDelete",
+     /*  41 */ "Found",
+     /*  42 */ "MoveGt",
+     /*  43 */ "Jump",
+     /*  44 */ "Pagecount",
+     /*  45 */ "MustBeInt",
+     /*  46 */ "Prev",
+     /*  47 */ "AutoCommit",
+     /*  48 */ "String",
+     /*  49 */ "FifoWrite",
+     /*  50 */ "Return",
+     /*  51 */ "Copy",
+     /*  52 */ "AddImm",
+     /*  53 */ "Function",
+     /*  54 */ "Trace",
+     /*  55 */ "NewRowid",
+     /*  56 */ "Blob",
+     /*  57 */ "Next",
+     /*  58 */ "ForceInt",
+     /*  59 */ "ReadCookie",
      /*  60 */ "Or",
      /*  61 */ "And",
-     /*  62 */ "DropIndex",
-     /*  63 */ "IdxGE",
-     /*  64 */ "IdxDelete",
+     /*  62 */ "Halt",
+     /*  63 */ "Expire",
+     /*  64 */ "DropIndex",
      /*  65 */ "IsNull",
      /*  66 */ "NotNull",
      /*  67 */ "Ne",
@@ -75,7 +75,7 @@
      /*  70 */ "Le",
      /*  71 */ "Lt",
      /*  72 */ "Ge",
-     /*  73 */ "Vacuum",
+     /*  73 */ "IdxInsert",
      /*  74 */ "BitAnd",
      /*  75 */ "BitOr",
      /*  76 */ "ShiftLeft",
@@ -86,53 +86,53 @@
      /*  81 */ "Divide",
      /*  82 */ "Remainder",
      /*  83 */ "Concat",
-     /*  84 */ "MoveLe",
-     /*  85 */ "IfNot",
-     /*  86 */ "DropTable",
+     /*  84 */ "FifoRead",
+     /*  85 */ "Column",
+     /*  86 */ "Int64",
      /*  87 */ "BitNot",
      /*  88 */ "String8",
-     /*  89 */ "MakeRecord",
-     /*  90 */ "ResultRow",
-     /*  91 */ "Delete",
-     /*  92 */ "AggFinal",
-     /*  93 */ "Compare",
-     /*  94 */ "Goto",
-     /*  95 */ "TableLock",
-     /*  96 */ "FifoRead",
-     /*  97 */ "Clear",
-     /*  98 */ "MoveLt",
-     /*  99 */ "VerifyCookie",
-     /* 100 */ "AggStep",
-     /* 101 */ "SetNumColumns",
-     /* 102 */ "Transaction",
-     /* 103 */ "VFilter",
-     /* 104 */ "VDestroy",
-     /* 105 */ "ContextPop",
-     /* 106 */ "Next",
-     /* 107 */ "IdxInsert",
-     /* 108 */ "Insert",
-     /* 109 */ "Destroy",
-     /* 110 */ "ReadCookie",
-     /* 111 */ "ForceInt",
-     /* 112 */ "LoadAnalysis",
-     /* 113 */ "Explain",
-     /* 114 */ "OpenPseudo",
-     /* 115 */ "OpenEphemeral",
-     /* 116 */ "Null",
-     /* 117 */ "Move",
-     /* 118 */ "Blob",
-     /* 119 */ "Rewind",
-     /* 120 */ "MoveGe",
-     /* 121 */ "VBegin",
-     /* 122 */ "VUpdate",
-     /* 123 */ "IfZero",
-     /* 124 */ "VCreate",
+     /*  89 */ "Gosub",
+     /*  90 */ "RowData",
+     /*  91 */ "Move",
+     /*  92 */ "MemMax",
+     /*  93 */ "Close",
+     /*  94 */ "VerifyCookie",
+     /*  95 */ "Null",
+     /*  96 */ "Integer",
+     /*  97 */ "Transaction",
+     /*  98 */ "IdxLT",
+     /*  99 */ "Delete",
+     /* 100 */ "IfZero",
+     /* 101 */ "Rewind",
+     /* 102 */ "RealAffinity",
+     /* 103 */ "Clear",
+     /* 104 */ "Explain",
+     /* 105 */ "AggStep",
+     /* 106 */ "Vacuum",
+     /* 107 */ "VDestroy",
+     /* 108 */ "IsUnique",
+     /* 109 */ "VOpen",
+     /* 110 */ "Yield",
+     /* 111 */ "AggFinal",
+     /* 112 */ "OpenWrite",
+     /* 113 */ "VNext",
+     /* 114 */ "Sort",
+     /* 115 */ "NotFound",
+     /* 116 */ "MoveLe",
+     /* 117 */ "MakeRecord",
+     /* 118 */ "IfNeg",
+     /* 119 */ "Variable",
+     /* 120 */ "CreateTable",
+     /* 121 */ "Insert",
+     /* 122 */ "Compare",
+     /* 123 */ "IdxGE",
+     /* 124 */ "OpenRead",
      /* 125 */ "Real",
-     /* 126 */ "Found",
-     /* 127 */ "IfPos",
-     /* 128 */ "NullRow",
-     /* 129 */ "Jump",
-     /* 130 */ "Permutation",
+     /* 126 */ "IdxRowid",
+     /* 127 */ "VBegin",
+     /* 128 */ "TableLock",
+     /* 129 */ "IfPos",
+     /* 130 */ "OpenEphemeral",
      /* 131 */ "NotUsed_131",
      /* 132 */ "NotUsed_132",
      /* 133 */ "NotUsed_133",
==== 
//depot/googleclient/gears/opensource/third_party/sqlite_google/preprocessed/opcodes.h#2
 - 
C:\src\gears/googleclient/gears/opensource/third_party/sqlite_google/preprocessed/opcodes.h
 ====
# action=edit type=text
--- 
googleclient/gears/opensource/third_party/sqlite_google/preprocessed/opcodes.h  
    2008-12-10 16:37:41.000000000 -0800
+++ 
googleclient/gears/opensource/third_party/sqlite_google/preprocessed/opcodes.h  
    2008-12-11 12:27:07.000000000 -0800
@@ -1,140 +1,140 @@
 /* Automatically generated.  Do not edit */
 /* See the mkopcodeh.awk script for details */
-#define OP_VNext                                1
-#define OP_Affinity                             2
-#define OP_Column                               3
-#define OP_SetCookie                            4
+#define OP_NotExists                            1
+#define OP_MoveLt                               2
+#define OP_IncrVacuum                           3
+#define OP_Multiply                            80   /* same as TK_STAR     */
+#define OP_VCreate                              4
+#define OP_BitAnd                              74   /* same as TK_BITAND   */
+#define OP_ResultRow                            5
+#define OP_DropTrigger                          6
+#define OP_OpenPseudo                           7
+#define OP_Affinity                             8
+#define OP_IntegrityCk                          9
+#define OP_RowKey                              10
+#define OP_LoadAnalysis                        11
+#define OP_Last                                12
+#define OP_Subtract                            79   /* same as TK_MINUS    */
+#define OP_Remainder                           82   /* same as TK_REM      */
+#define OP_SetCookie                           13
+#define OP_Sequence                            14
+#define OP_VRename                             15
+#define OP_SCopy                               17
+#define OP_VUpdate                             18
+#define OP_VColumn                             19
+#define OP_DropTable                           20
+#define OP_ContextPush                         21
+#define OP_NotNull                             66   /* same as TK_NOTNULL  */
+#define OP_Rowid                               22
 #define OP_Real                               125   /* same as TK_FLOAT    */
-#define OP_Sequence                             5
-#define OP_MoveGt                               6
+#define OP_String8                             88   /* same as TK_STRING   */
+#define OP_And                                 61   /* same as TK_AND      */
+#define OP_BitNot                              87   /* same as TK_BITNOT   */
+#define OP_VFilter                             23
+#define OP_NullRow                             24
+#define OP_Noop                                25
+#define OP_VRowid                              26
 #define OP_Ge                                  72   /* same as TK_GE       */
-#define OP_RowKey                               7
-#define OP_SCopy                                8
+#define OP_ParseSchema                         27
+#define OP_Statement                           28
+#define OP_CollSeq                             29
+#define OP_ContextPop                          30
+#define OP_ToText                             138   /* same as TK_TO_TEXT  */
+#define OP_MoveGe                              31
 #define OP_Eq                                  68   /* same as TK_EQ       */
-#define OP_OpenWrite                            9
-#define OP_NotNull                             66   /* same as TK_NOTNULL  */
-#define OP_If                                  10
+#define OP_ToNumeric                          140   /* same as TK_TO_NUMERIC*/
+#define OP_If                                  32
+#define OP_IfNot                               33
+#define OP_ShiftRight                          77   /* same as TK_RSHIFT   */
+#define OP_Destroy                             34
+#define OP_Permutation                         35
+#define OP_CreateIndex                         36
+#define OP_SetNumColumns                       37
+#define OP_Not                                 16   /* same as TK_NOT      */
+#define OP_Gt                                  69   /* same as TK_GT       */
+#define OP_ResetCount                          38
+#define OP_Goto                                39
+#define OP_IdxDelete                           40
+#define OP_Found                               41
+#define OP_MoveGt                              42
+#define OP_Jump                                43
+#define OP_Pagecount                           44
+#define OP_MustBeInt                           45
+#define OP_Prev                                46
+#define OP_AutoCommit                          47
+#define OP_String                              48
+#define OP_FifoWrite                           49
 #define OP_ToInt                              141   /* same as TK_TO_INT   */
-#define OP_String8                             88   /* same as TK_STRING   */
-#define OP_VRowid                              11
-#define OP_CollSeq                             12
-#define OP_OpenRead                            13
-#define OP_Expire                              14
-#define OP_AutoCommit                          15
-#define OP_Gt                                  69   /* same as TK_GT       */
-#define OP_Pagecount                           17
-#define OP_IntegrityCk                         18
-#define OP_Sort                                19
-#define OP_Copy                                20
-#define OP_Trace                               21
-#define OP_Function                            22
-#define OP_IfNeg                               23
-#define OP_And                                 61   /* same as TK_AND      */
-#define OP_Subtract                            79   /* same as TK_MINUS    */
-#define OP_Noop                                24
-#define OP_Return                              25
-#define OP_Remainder                           82   /* same as TK_REM      */
-#define OP_NewRowid                            26
-#define OP_Multiply                            80   /* same as TK_STAR     */
-#define OP_Variable                            27
-#define OP_String                              28
-#define OP_RealAffinity                        29
-#define OP_VRename                             30
-#define OP_ParseSchema                         31
-#define OP_VOpen                               32
-#define OP_Close                               33
-#define OP_CreateIndex                         34
-#define OP_IsUnique                            35
-#define OP_NotFound                            36
-#define OP_Int64                               37
-#define OP_MustBeInt                           38
-#define OP_Halt                                39
-#define OP_Rowid                               40
-#define OP_IdxLT                               41
-#define OP_AddImm                              42
-#define OP_Statement                           43
-#define OP_RowData                             44
-#define OP_MemMax                              45
+#define OP_Return                              50
+#define OP_Copy                                51
+#define OP_AddImm                              52
+#define OP_Function                            53
+#define OP_Trace                               54
+#define OP_Concat                              83   /* same as TK_CONCAT   */
+#define OP_NewRowid                            55
+#define OP_Blob                                56
+#define OP_IsNull                              65   /* same as TK_ISNULL   */
+#define OP_Next                                57
+#define OP_ForceInt                            58
+#define OP_ReadCookie                          59
+#define OP_Halt                                62
+#define OP_Expire                              63
 #define OP_Or                                  60   /* same as TK_OR       */
-#define OP_NotExists                           46
-#define OP_Gosub                               47
+#define OP_DropIndex                           64
+#define OP_IdxInsert                           73
+#define OP_ShiftLeft                           76   /* same as TK_LSHIFT   */
+#define OP_FifoRead                            84
+#define OP_Column                              85
+#define OP_Int64                               86
+#define OP_Gosub                               89
+#define OP_RowData                             90
+#define OP_Move                                91
+#define OP_BitOr                               75   /* same as TK_BITOR    */
+#define OP_MemMax                              92
+#define OP_Close                               93
+#define OP_ToReal                             142   /* same as TK_TO_REAL  */
+#define OP_VerifyCookie                        94
+#define OP_Null                                95
+#define OP_Integer                             96
+#define OP_Transaction                         97
 #define OP_Divide                              81   /* same as TK_SLASH    */
-#define OP_Integer                             48
-#define OP_ToNumeric                          140   /* same as TK_TO_NUMERIC*/
-#define OP_Prev                                49
-#define OP_Concat                              83   /* same as TK_CONCAT   */
-#define OP_BitAnd                              74   /* same as TK_BITAND   */
-#define OP_VColumn                             50
-#define OP_CreateTable                         51
-#define OP_Last                                52
-#define OP_IsNull                              65   /* same as TK_ISNULL   */
-#define OP_IncrVacuum                          53
-#define OP_IdxRowid                            54
-#define OP_ShiftRight                          77   /* same as TK_RSHIFT   */
-#define OP_ResetCount                          55
-#define OP_FifoWrite                           56
-#define OP_ContextPush                         57
-#define OP_Yield                               58
-#define OP_DropTrigger                         59
-#define OP_DropIndex                           62
-#define OP_IdxGE                               63
-#define OP_IdxDelete                           64
-#define OP_Vacuum                              73
-#define OP_MoveLe                              84
-#define OP_IfNot                               85
-#define OP_DropTable                           86
-#define OP_MakeRecord                          89
+#define OP_IdxLT                               98
+#define OP_Delete                              99
+#define OP_IfZero                             100
+#define OP_Rewind                             101
+#define OP_RealAffinity                       102
+#define OP_Clear                              103
+#define OP_Explain                            104
+#define OP_AggStep                            105
+#define OP_Vacuum                             106
+#define OP_VDestroy                           107
+#define OP_IsUnique                           108
+#define OP_VOpen                              109
+#define OP_Yield                              110
+#define OP_AggFinal                           111
+#define OP_OpenWrite                          112
+#define OP_Le                                  70   /* same as TK_LE       */
+#define OP_VNext                              113
+#define OP_Sort                               114
+#define OP_NotFound                           115
+#define OP_MoveLe                             116
+#define OP_MakeRecord                         117
+#define OP_Add                                 78   /* same as TK_PLUS     */
+#define OP_IfNeg                              118
+#define OP_Ne                                  67   /* same as TK_NE       */
+#define OP_Variable                           119
+#define OP_CreateTable                        120
+#define OP_Insert                             121
+#define OP_Compare                            122
+#define OP_IdxGE                              123
+#define OP_OpenRead                           124
+#define OP_IdxRowid                           126
 #define OP_ToBlob                             139   /* same as TK_TO_BLOB  */
-#define OP_ResultRow                           90
-#define OP_Delete                              91
-#define OP_AggFinal                            92
-#define OP_Compare                             93
-#define OP_ShiftLeft                           76   /* same as TK_LSHIFT   */
-#define OP_Goto                                94
-#define OP_TableLock                           95
-#define OP_FifoRead                            96
-#define OP_Clear                               97
-#define OP_MoveLt                              98
-#define OP_Le                                  70   /* same as TK_LE       */
-#define OP_VerifyCookie                        99
-#define OP_AggStep                            100
-#define OP_ToText                             138   /* same as TK_TO_TEXT  */
-#define OP_Not                                 16   /* same as TK_NOT      */
-#define OP_ToReal                             142   /* same as TK_TO_REAL  */
-#define OP_SetNumColumns                      101
-#define OP_Transaction                        102
-#define OP_VFilter                            103
-#define OP_Ne                                  67   /* same as TK_NE       */
-#define OP_VDestroy                           104
-#define OP_ContextPop                         105
-#define OP_BitOr                               75   /* same as TK_BITOR    */
-#define OP_Next                               106
-#define OP_IdxInsert                          107
+#define OP_VBegin                             127
+#define OP_TableLock                          128
+#define OP_IfPos                              129
+#define OP_OpenEphemeral                      130
 #define OP_Lt                                  71   /* same as TK_LT       */
-#define OP_Insert                             108
-#define OP_Destroy                            109
-#define OP_ReadCookie                         110
-#define OP_ForceInt                           111
-#define OP_LoadAnalysis                       112
-#define OP_Explain                            113
-#define OP_OpenPseudo                         114
-#define OP_OpenEphemeral                      115
-#define OP_Null                               116
-#define OP_Move                               117
-#define OP_Blob                               118
-#define OP_Add                                 78   /* same as TK_PLUS     */
-#define OP_Rewind                             119
-#define OP_MoveGe                             120
-#define OP_VBegin                             121
-#define OP_VUpdate                            122
-#define OP_IfZero                             123
-#define OP_BitNot                              87   /* same as TK_BITNOT   */
-#define OP_VCreate                            124
-#define OP_Found                              126
-#define OP_IfPos                              127
-#define OP_NullRow                            128
-#define OP_Jump                               129
-#define OP_Permutation                        130
 
 /* The following opcode values are never used */
 #define OP_NotUsed_131                        131
@@ -157,21 +157,21 @@
 #define OPFLG_IN3             0x0010  /* in3:   P3 is an input */
 #define OPFLG_OUT3            0x0020  /* out3:  P3 is an output */
 #define OPFLG_INITIALIZER {\
-/*   0 */ 0x00, 0x01, 0x00, 0x00, 0x10, 0x02, 0x11, 0x00,\
-/*   8 */ 0x00, 0x00, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00,\
-/*  16 */ 0x04, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05,\
-/*  24 */ 0x00, 0x04, 0x02, 0x02, 0x02, 0x04, 0x00, 0x00,\
-/*  32 */ 0x00, 0x00, 0x02, 0x11, 0x11, 0x02, 0x05, 0x00,\
-/*  40 */ 0x02, 0x11, 0x04, 0x00, 0x00, 0x0c, 0x11, 0x01,\
-/*  48 */ 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x02, 0x00,\
-/*  56 */ 0x04, 0x00, 0x00, 0x00, 0x2c, 0x2c, 0x00, 0x11,\
+/*   0 */ 0x00, 0x11, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00,\
+/*   8 */ 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x02, 0x00,\
+/*  16 */ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01,\
+/*  24 */ 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x11,\
+/*  32 */ 0x05, 0x05, 0x02, 0x00, 0x02, 0x00, 0x00, 0x01,\
+/*  40 */ 0x00, 0x11, 0x11, 0x01, 0x02, 0x05, 0x01, 0x00,\
+/*  48 */ 0x02, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00, 0x02,\
+/*  56 */ 0x02, 0x01, 0x05, 0x02, 0x2c, 0x2c, 0x00, 0x00,\
 /*  64 */ 0x00, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
-/*  72 */ 0x15, 0x00, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c,\
-/*  80 */ 0x2c, 0x2c, 0x2c, 0x2c, 0x11, 0x05, 0x00, 0x04,\
-/*  88 */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,\
-/*  96 */ 0x01, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x01,\
-/* 104 */ 0x00, 0x00, 0x01, 0x08, 0x00, 0x02, 0x02, 0x05,\
-/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x01,\
-/* 120 */ 0x11, 0x00, 0x00, 0x05, 0x00, 0x02, 0x11, 0x05,\
-/* 128 */ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
+/*  72 */ 0x15, 0x08, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c,\
+/*  80 */ 0x2c, 0x2c, 0x2c, 0x2c, 0x01, 0x00, 0x02, 0x04,\
+/*  88 */ 0x02, 0x01, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x02,\
+/*  96 */ 0x02, 0x00, 0x11, 0x00, 0x05, 0x01, 0x04, 0x00,\
+/* 104 */ 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,\
+/* 112 */ 0x00, 0x01, 0x01, 0x11, 0x11, 0x00, 0x05, 0x02,\
+/* 120 */ 0x02, 0x00, 0x00, 0x11, 0x00, 0x02, 0x02, 0x00,\
+/* 128 */ 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
 /* 136 */ 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04,}
==== 
//depot/googleclient/gears/opensource/third_party/sqlite_google/preprocessed/sqlite3.h#2
 - 
C:\src\gears/googleclient/gears/opensource/third_party/sqlite_google/preprocessed/sqlite3.h
 ====
# action=edit type=text
--- 
googleclient/gears/opensource/third_party/sqlite_google/preprocessed/sqlite3.h  
    2008-12-10 16:37:41.000000000 -0800
+++ 
googleclient/gears/opensource/third_party/sqlite_google/preprocessed/sqlite3.h  
    2008-12-11 12:27:07.000000000 -0800
@@ -5758,6 +5758,19 @@
 int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
 
 /*
+** Preload the databases into the pager cache, up to the maximum size of the
+** pager cache.
+**
+** For a database to be loaded successfully, the pager must be active. That is,
+** there must be an open statement on that database. See sqlite3pager_loadall
+**
+** There might be many databases attached to the given connection. We iterate
+** them all and try to load them. If none are loadable successfully, we return
+** an error. Otherwise, we return OK.
+*/
+int sqlite3Preload(sqlite3 *db);
+
+/*
 ** CAPI3REF: Virtual File System Objects {H11200} <S20100>
 **
 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
==== 
//depot/googleclient/gears/opensource/third_party/sqlite_google/src/build.c#3 - 
C:\src\gears/googleclient/gears/opensource/third_party/sqlite_google/src/build.c
 ====
# action=edit type=text
--- googleclient/gears/opensource/third_party/sqlite_google/src/build.c 
2008-12-10 16:37:41.000000000 -0800
+++ googleclient/gears/opensource/third_party/sqlite_google/src/build.c 
2008-12-11 12:27:07.000000000 -0800
@@ -26,6 +26,9 @@
 */
 #include "sqliteInt.h"
 #include <ctype.h>
+
+#include "pager.h"
+#include "btree.h"
 
 /*
 ** This routine is called when a new SQL statement is beginning to
@@ -3493,3 +3496,28 @@
   }
   return pKey;
 }
+
+/* See declaration in sqlite3.h for information */
+int sqlite3Preload(sqlite3 *db)
+{
+  Pager *pPager;
+  Btree *pBt;
+  int rc;
+  int i;
+  int dbsLoaded = 0;
+
+  for(i=0; i<db->nDb; i++) {
+    pBt = db->aDb[i].pBt;
+    if( !pBt )
+      continue;
+    pPager = sqlite3BtreePager(pBt);
+    if( pPager ) {
+      rc = sqlite3PagerLoadall(pPager);
+      if (rc == SQLITE_OK)
+        dbsLoaded++;
+    }
+  }
+  if (dbsLoaded == 0)
+    return SQLITE_ERROR;
+  return SQLITE_OK;
+}
==== 
//depot/googleclient/gears/opensource/third_party/sqlite_google/src/pager.c#2 - 
C:\src\gears/googleclient/gears/opensource/third_party/sqlite_google/src/pager.c
 ====
# action=edit type=text
--- googleclient/gears/opensource/third_party/sqlite_google/src/pager.c 
2008-12-10 16:37:41.000000000 -0800
+++ googleclient/gears/opensource/third_party/sqlite_google/src/pager.c 
2008-12-11 12:27:08.000000000 -0800
@@ -502,6 +502,14 @@
 ** The maximum legal page number is (2^31 - 1).
 */
 #define PAGER_MAX_PGNO 2147483647
+
+/* See comments above the definition. */
+int sqlite3PagerAcquire2(
+  Pager *pPager,
+  Pgno pgno,
+  DbPage **ppPage,
+  int noContent,
+  unsigned char *pDataToFill);
 
 /*
 ** The pagerEnter() and pagerLeave() routines acquire and release
@@ -3766,6 +3774,25 @@
   DbPage **ppPage,    /* Write a pointer to the page here */
   int noContent       /* Do not bother reading content from disk if true */
 ){
+  /* This just passes through to our modified version with NULL data. */
+  return sqlite3PagerAcquire2(pPager, pgno, ppPage, noContent, 0);
+}
+
+/*
+** This is an internal version of sqlite3PagerAcquire that takes an extra
+** parameter of data to use to fill the page with. This allows more efficient
+** filling for preloaded data. If this extra parameter is NULL, we'll go to
+** the file.
+**
+** See sqlite3PagerLoadall which uses this function.
+*/
+int sqlite3PagerAcquire2(
+  Pager *pPager,      /* The pager open on the database file */
+  Pgno pgno,          /* Page number to fetch */
+  DbPage **ppPage,    /* Write a pointer to the page here */
+  int noContent,      /* Do not bother reading content from disk if true */
+  unsigned char* pDataToFill
+){
   PgHdr *pPg;
   int rc;
 
@@ -3834,11 +3861,18 @@
       pPg->needRead = noContent && !pPager->alwaysRollback;
       IOTRACE(("ZERO %p %d\n", pPager, pgno));
     }else{
-      rc = readDbPage(pPager, pPg, pgno);
-      if( rc!=SQLITE_OK && rc!=SQLITE_IOERR_SHORT_READ ){
-        pPg->pgno = 0;
-        sqlite3PagerUnref(pPg);
-        return rc;
+      if (pDataToFill) {
+        /* Just copy from the given memory. */
+        memcpy(PGHDR_TO_DATA(pPg), pDataToFill, pPager->pageSize);
+        CODEC1(pPager, PGHDR_TO_DATA(pPg), pPg->pgno, 3);
+      } else {
+        /* Load from disk (old regular sqlite code path). */
+        rc = readDbPage(pPager, pPg, pgno);
+        if( rc!=SQLITE_OK && rc!=SQLITE_IOERR_SHORT_READ ){
+          pPg->pgno = 0;
+          sqlite3PagerUnref(pPg);
+          return rc;
+        }
       }
       pPg->needRead = 0;
     }
@@ -5303,6 +5337,96 @@
 }
 #endif
 
+// TODO(mpcomplete): a lot of the APIs this uses were removed since 3.4.2.
+// Figure out how to fix it.
+int sqlite3PagerLoadall(Pager* pPager) {
+  return SQLITE_ERROR;
+}
+#if 0
+/**
+** When making large allocations, there is no need to stress the heap and
+** potentially hold its lock while we allocate a bunch of memory.  If we know
+** the allocation will be large, go directly to the OS instead of the heap.
+**/
+static void* allocLarge(size_t size) {
+#if OS_WIN
+  return VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
+#else
+  return sqliteMallocRaw(size);
+#endif
+}
+
+static void freeLarge(void* ptr) {
+#if OS_WIN
+  VirtualFree(ptr, 0, MEM_RELEASE);
+#else
+  sqliteFree(ptr);
+#endif
+}
+
+/**
+** Addition: This will attempt to populate the database cache with
+** the first N bytes of the file, where N is the total size of the cache.
+** Because we can load this as one chunk from the disk, this is much faster
+** than loading a subset of the pages one at a time in random order.
+**
+** The pager must be initialized before this function is called. This means a
+** statement must be open that has initialized the pager and is keeping the
+** cache in memory.
+**/
+int sqlite3PagerLoadall(Pager* pPager)
+{
+  int i;
+  int rc;
+  int loadSize;
+  int loadPages;
+  unsigned char *fileData;
+
+  if (pPager->dbSize < 0 || pPager->pageSize < 0) {
+    /* pager not initialized, this means a statement is not open */
+    return SQLITE_MISUSE;
+  }
+
+  /* compute sizes */
+  if (pPager->mxPage < pPager->dbSize)
+    loadPages = pPager->mxPage;
+  else
+    loadPages = pPager->dbSize;
+  loadSize = loadPages * pPager->pageSize;
+
+  rc = sqlite3OsSeek(pPager->fd, 0);
+  if (rc != SQLITE_OK)
+    return rc;
+
+  /* load the file as one chunk */
+  fileData = allocLarge(loadSize);
+  if (! fileData)
+    return SQLITE_NOMEM;
+  rc = sqlite3OsRead(pPager->fd, fileData, loadSize);
+  if (rc != SQLITE_OK) {
+    freeLarge(fileData);
+    return rc;
+  }
+
+  /* Copy the data to each page. Note that the page numbers we pass to _get
+   * are one-based, 0 is a marker for no page. We also need to check that we
+   * haven't loaded more pages than the cache can hold total. There may have
+   * already been a few pages loaded before, so we may fill the cache before
+   * loading all of the pages we want to.
+   */
+  for(i=1; i <= loadPages && pPager->nPage < pPager->mxPage; i++) {
+    DbPage *pPage;
+    rc = sqlite3PagerAcquire2(pPager, i, &pPage, 0,
+                              &fileData[(i-1)*(i64)pPager->pageSize]);
+    if (rc != SQLITE_OK)
+      break;
+    sqlite3PagerUnref(pPage);
+  }
+  freeLarge(fileData);
+  return SQLITE_OK;
+}
+#endif
+
 /*
 ** Return a pointer to the data for the specified page.
 */
==== 
//depot/googleclient/gears/opensource/third_party/sqlite_google/src/pager.h#2 - 
C:\src\gears/googleclient/gears/opensource/third_party/sqlite_google/src/pager.h
 ====
# action=edit type=text
--- googleclient/gears/opensource/third_party/sqlite_google/src/pager.h 
2008-12-10 16:37:41.000000000 -0800
+++ googleclient/gears/opensource/third_party/sqlite_google/src/pager.h 
2008-12-11 12:27:08.000000000 -0800
@@ -109,6 +109,7 @@
 void *sqlite3PagerGetData(DbPage *); 
 void *sqlite3PagerGetExtra(DbPage *); 
 int sqlite3PagerLockingMode(Pager *, int);
+int sqlite3PagerLoadall(Pager*);
 int sqlite3PagerJournalMode(Pager *, int);
 i64 sqlite3PagerJournalSizeLimit(Pager *, i64);
 void *sqlite3PagerTempSpace(Pager*);
==== 
//depot/googleclient/gears/opensource/third_party/sqlite_google/src/shell.c#2 - 
C:\src\gears/googleclient/gears/opensource/third_party/sqlite_google/src/shell.c
 ====
# action=edit type=text
--- googleclient/gears/opensource/third_party/sqlite_google/src/shell.c 
2008-12-10 16:37:41.000000000 -0800
+++ googleclient/gears/opensource/third_party/sqlite_google/src/shell.c 
2008-12-11 12:27:08.000000000 -0800
@@ -1917,6 +1917,14 @@
   char *zFirstCmd = 0;
   int i;
   int rc = 0;
+
+  // Begin evanm patch.
+  extern int sqlite_shell_init_icu();
+  if( !sqlite_shell_init_icu() ){
+    fprintf(stderr, "%s: warning: couldn't find icudt38.dll; "
+                    "queries against ICU FTS tables will fail.\n", argv[0]);
+  }
+  // End evanm patch.
 
   Argv0 = argv[0];
   main_init(&data);
==== 
//depot/googleclient/gears/opensource/third_party/sqlite_google/src/sqlite.h.in#2
 - 
C:\src\gears/googleclient/gears/opensource/third_party/sqlite_google/src/sqlite.h.in
 ====
# action=edit type=text
--- googleclient/gears/opensource/third_party/sqlite_google/src/sqlite.h.in     
2008-12-10 16:37:41.000000000 -0800
+++ googleclient/gears/opensource/third_party/sqlite_google/src/sqlite.h.in     
2008-12-11 12:27:09.000000000 -0800
@@ -5758,6 +5758,19 @@
 int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
 
 /*
+** Preload the databases into the pager cache, up to the maximum size of the
+** pager cache.
+**
+** For a database to be loaded successfully, the pager must be active. That is,
+** there must be an open statement on that database. See sqlite3pager_loadall
+**
+** There might be many databases attached to the given connection. We iterate
+** them all and try to load them. If none are loadable successfully, we return
+** an error. Otherwise, we return OK.
+*/
+int sqlite3Preload(sqlite3 *db);
+
+/*
 ** CAPI3REF: Virtual File System Objects {H11200} <S20100>
 **
 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object

Reply via email to