/ Check-in [ee35a897]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merge the changes for the 3.7.16.1 release candidate into the sessions branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sessions
Files: files | file ages | folders
SHA1: ee35a89712b8ea9f4e70d61a29150348896b519f
User & Date: drh 2013-03-28 01:19:26
Context
2013-04-10
15:01
Designate the beginning and the end of the sqlite3session.h file in the constructed sqlite3.h file. check-in: 53f5be74 user: drh tags: sessions
2013-03-28
01:19
Merge the changes for the 3.7.16.1 release candidate into the sessions branch. check-in: ee35a897 user: drh tags: sessions
2013-03-27
20:41
Fix harmless compiler warnings coming from MSVC64 in test code. No changes to the core. check-in: 274d2a22 user: drh tags: trunk
2013-03-19
17:10
Also export the sqlite3changeset interfaces in the amalgamated version of the sessions extension. check-in: 5b399f2b user: drh tags: sessions
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to VERSION.

     1         -3.7.16
            1  +3.7.16.1

Changes to configure.

     1      1   #! /bin/sh
     2      2   # Guess values for system-dependent variables and create Makefiles.
     3         -# Generated by GNU Autoconf 2.62 for sqlite 3.7.16.
            3  +# Generated by GNU Autoconf 2.62 for sqlite 3.7.16.1.
     4      4   #
     5      5   # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
     6      6   # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
     7      7   # This configure script is free software; the Free Software Foundation
     8      8   # gives unlimited permission to copy, distribute and modify it.
     9      9   ## --------------------- ##
    10     10   ## M4sh Initialization.  ##
................................................................................
   739    739   MFLAGS=
   740    740   MAKEFLAGS=
   741    741   SHELL=${CONFIG_SHELL-/bin/sh}
   742    742   
   743    743   # Identity of this package.
   744    744   PACKAGE_NAME='sqlite'
   745    745   PACKAGE_TARNAME='sqlite'
   746         -PACKAGE_VERSION='3.7.16'
   747         -PACKAGE_STRING='sqlite 3.7.16'
          746  +PACKAGE_VERSION='3.7.16.1'
          747  +PACKAGE_STRING='sqlite 3.7.16.1'
   748    748   PACKAGE_BUGREPORT=''
   749    749   
   750    750   # Factoring default headers for most tests.
   751    751   ac_includes_default="\
   752    752   #include <stdio.h>
   753    753   #ifdef HAVE_SYS_TYPES_H
   754    754   # include <sys/types.h>
................................................................................
  1480   1480   #
  1481   1481   # Report the --help message.
  1482   1482   #
  1483   1483   if test "$ac_init_help" = "long"; then
  1484   1484     # Omit some internal or obsolete options to make the list less imposing.
  1485   1485     # This message is too long to be a string in the A/UX 3.1 sh.
  1486   1486     cat <<_ACEOF
  1487         -\`configure' configures sqlite 3.7.16 to adapt to many kinds of systems.
         1487  +\`configure' configures sqlite 3.7.16.1 to adapt to many kinds of systems.
  1488   1488   
  1489   1489   Usage: $0 [OPTION]... [VAR=VALUE]...
  1490   1490   
  1491   1491   To assign environment variables (e.g., CC, CFLAGS...), specify them as
  1492   1492   VAR=VALUE.  See below for descriptions of some of the useful variables.
  1493   1493   
  1494   1494   Defaults for the options are specified in brackets.
................................................................................
  1545   1545     --build=BUILD     configure for building on BUILD [guessed]
  1546   1546     --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  1547   1547   _ACEOF
  1548   1548   fi
  1549   1549   
  1550   1550   if test -n "$ac_init_help"; then
  1551   1551     case $ac_init_help in
  1552         -     short | recursive ) echo "Configuration of sqlite 3.7.16:";;
         1552  +     short | recursive ) echo "Configuration of sqlite 3.7.16.1:";;
  1553   1553      esac
  1554   1554     cat <<\_ACEOF
  1555   1555   
  1556   1556   Optional Features:
  1557   1557     --disable-option-checking  ignore unrecognized --enable/--with options
  1558   1558     --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  1559   1559     --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
................................................................................
  1661   1661       cd "$ac_pwd" || { ac_status=$?; break; }
  1662   1662     done
  1663   1663   fi
  1664   1664   
  1665   1665   test -n "$ac_init_help" && exit $ac_status
  1666   1666   if $ac_init_version; then
  1667   1667     cat <<\_ACEOF
  1668         -sqlite configure 3.7.16
         1668  +sqlite configure 3.7.16.1
  1669   1669   generated by GNU Autoconf 2.62
  1670   1670   
  1671   1671   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
  1672   1672   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
  1673   1673   This configure script is free software; the Free Software Foundation
  1674   1674   gives unlimited permission to copy, distribute and modify it.
  1675   1675   _ACEOF
  1676   1676     exit
  1677   1677   fi
  1678   1678   cat >config.log <<_ACEOF
  1679   1679   This file contains any messages produced by compilers while
  1680   1680   running configure, to aid debugging if configure makes a mistake.
  1681   1681   
  1682         -It was created by sqlite $as_me 3.7.16, which was
         1682  +It was created by sqlite $as_me 3.7.16.1, which was
  1683   1683   generated by GNU Autoconf 2.62.  Invocation command line was
  1684   1684   
  1685   1685     $ $0 $@
  1686   1686   
  1687   1687   _ACEOF
  1688   1688   exec 5>>config.log
  1689   1689   {
................................................................................
 14028  14028   
 14029  14029   exec 6>&1
 14030  14030   
 14031  14031   # Save the log message, to keep $[0] and so on meaningful, and to
 14032  14032   # report actual input values of CONFIG_FILES etc. instead of their
 14033  14033   # values after options handling.
 14034  14034   ac_log="
 14035         -This file was extended by sqlite $as_me 3.7.16, which was
        14035  +This file was extended by sqlite $as_me 3.7.16.1, which was
 14036  14036   generated by GNU Autoconf 2.62.  Invocation command line was
 14037  14037   
 14038  14038     CONFIG_FILES    = $CONFIG_FILES
 14039  14039     CONFIG_HEADERS  = $CONFIG_HEADERS
 14040  14040     CONFIG_LINKS    = $CONFIG_LINKS
 14041  14041     CONFIG_COMMANDS = $CONFIG_COMMANDS
 14042  14042     $ $0 $@
................................................................................
 14081  14081   $config_commands
 14082  14082   
 14083  14083   Report bugs to <bug-autoconf@gnu.org>."
 14084  14084   
 14085  14085   _ACEOF
 14086  14086   cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 14087  14087   ac_cs_version="\\
 14088         -sqlite config.status 3.7.16
        14088  +sqlite config.status 3.7.16.1
 14089  14089   configured by $0, generated by GNU Autoconf 2.62,
 14090  14090     with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 14091  14091   
 14092  14092   Copyright (C) 2008 Free Software Foundation, Inc.
 14093  14093   This config.status script is free software; the Free Software Foundation
 14094  14094   gives unlimited permission to copy, distribute and modify it."
 14095  14095   

Changes to ext/fts1/ft_hash.h.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** This is the header file for the generic hash-table implemenation
           12  +** This is the header file for the generic hash-table implementation
    13     13   ** used in SQLite.  We've modified it slightly to serve as a standalone
    14     14   ** hash table implementation for the full-text indexing module.
    15     15   **
    16     16   */
    17     17   #ifndef _HASH_H_
    18     18   #define _HASH_H_
    19     19   

Changes to ext/fts1/fts1_hash.h.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** This is the header file for the generic hash-table implemenation
           12  +** This is the header file for the generic hash-table implementation
    13     13   ** used in SQLite.  We've modified it slightly to serve as a standalone
    14     14   ** hash table implementation for the full-text indexing module.
    15     15   **
    16     16   */
    17     17   #ifndef _FTS1_HASH_H_
    18     18   #define _FTS1_HASH_H_
    19     19   

Changes to ext/fts2/fts2.c.

  6775   6775   void sqlite3Fts2SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule);
  6776   6776   void sqlite3Fts2PorterTokenizerModule(sqlite3_tokenizer_module const**ppModule);
  6777   6777   void sqlite3Fts2IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule);
  6778   6778   
  6779   6779   int sqlite3Fts2InitHashTable(sqlite3 *, fts2Hash *, const char *);
  6780   6780   
  6781   6781   /*
  6782         -** Initialise the fts2 extension. If this extension is built as part
         6782  +** Initialize the fts2 extension. If this extension is built as part
  6783   6783   ** of the sqlite library, then this function is called directly by
  6784   6784   ** SQLite. If fts2 is built as a dynamically loadable extension, this
  6785   6785   ** function is called by the sqlite3_extension_init() entry point.
  6786   6786   */
  6787   6787   int sqlite3Fts2Init(sqlite3 *db){
  6788   6788     int rc = SQLITE_OK;
  6789   6789     fts2Hash *pHash = 0;
................................................................................
  6793   6793   
  6794   6794     sqlite3Fts2SimpleTokenizerModule(&pSimple);
  6795   6795     sqlite3Fts2PorterTokenizerModule(&pPorter);
  6796   6796   #ifdef SQLITE_ENABLE_ICU
  6797   6797     sqlite3Fts2IcuTokenizerModule(&pIcu);
  6798   6798   #endif
  6799   6799   
  6800         -  /* Allocate and initialise the hash-table used to store tokenizers. */
         6800  +  /* Allocate and initialize the hash-table used to store tokenizers. */
  6801   6801     pHash = sqlite3_malloc(sizeof(fts2Hash));
  6802   6802     if( !pHash ){
  6803   6803       rc = SQLITE_NOMEM;
  6804   6804     }else{
  6805   6805       sqlite3Fts2HashInit(pHash, FTS2_HASH_STRING, 1);
  6806   6806     }
  6807   6807   

Changes to ext/fts2/fts2_hash.h.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** This is the header file for the generic hash-table implemenation
           12  +** This is the header file for the generic hash-table implementation
    13     13   ** used in SQLite.  We've modified it slightly to serve as a standalone
    14     14   ** hash table implementation for the full-text indexing module.
    15     15   **
    16     16   */
    17     17   #ifndef _FTS2_HASH_H_
    18     18   #define _FTS2_HASH_H_
    19     19   

Changes to ext/fts2/fts2_tokenizer.c.

   315    315   }
   316    316   
   317    317   #endif
   318    318   
   319    319   /*
   320    320   ** Set up SQL objects in database db used to access the contents of
   321    321   ** the hash table pointed to by argument pHash. The hash table must
   322         -** been initialised to use string keys, and to take a private copy 
          322  +** been initialized to use string keys, and to take a private copy 
   323    323   ** of the key when a value is inserted. i.e. by a call similar to:
   324    324   **
   325    325   **    sqlite3Fts2HashInit(pHash, FTS2_HASH_STRING, 1);
   326    326   **
   327    327   ** This function adds a scalar function (see header comment above
   328    328   ** scalarFunc() in this file for details) and, if ENABLE_TABLE is
   329    329   ** defined at compilation time, a temporary virtual table (see header 

Changes to ext/fts2/fts2_tokenizer.h.

    66     66     **
    67     67     ** then argc is set to 2, and the argv[] array contains pointers
    68     68     ** to the strings "arg1" and "arg2".
    69     69     **
    70     70     ** This method should return either SQLITE_OK (0), or an SQLite error 
    71     71     ** code. If SQLITE_OK is returned, then *ppTokenizer should be set
    72     72     ** to point at the newly created tokenizer structure. The generic
    73         -  ** sqlite3_tokenizer.pModule variable should not be initialised by
           73  +  ** sqlite3_tokenizer.pModule variable should not be initialized by
    74     74     ** this callback. The caller will do so.
    75     75     */
    76     76     int (*xCreate)(
    77     77       int argc,                           /* Size of argv array */
    78     78       const char *const*argv,             /* Tokenizer argument strings */
    79     79       sqlite3_tokenizer **ppTokenizer     /* OUT: Created tokenizer */
    80     80     );

Changes to ext/fts3/fts3.c.

  1567   1567         sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId);
  1568   1568         pCsr->isRequireSeek = 0;
  1569   1569         if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){
  1570   1570           return SQLITE_OK;
  1571   1571         }else{
  1572   1572           rc = sqlite3_reset(pCsr->pStmt);
  1573   1573           if( rc==SQLITE_OK && ((Fts3Table *)pCsr->base.pVtab)->zContentTbl==0 ){
  1574         -          /* If no row was found and no error has occured, then the %_content
         1574  +          /* If no row was found and no error has occurred, then the %_content
  1575   1575             ** table is missing a row that is present in the full-text index.
  1576   1576             ** The data structures are corrupt.  */
  1577   1577             rc = FTS_CORRUPT_VTAB;
  1578   1578             pCsr->isEof = 1;
  1579   1579           }
  1580   1580         }
  1581   1581       }
................................................................................
  2807   2807   */
  2808   2808   static void fts3SegReaderCursorFree(Fts3MultiSegReader *pSegcsr){
  2809   2809     sqlite3Fts3SegReaderFinish(pSegcsr);
  2810   2810     sqlite3_free(pSegcsr);
  2811   2811   }
  2812   2812   
  2813   2813   /*
  2814         -** This function retreives the doclist for the specified term (or term
         2814  +** This function retrieves the doclist for the specified term (or term
  2815   2815   ** prefix) from the database.
  2816   2816   */
  2817   2817   static int fts3TermSelect(
  2818   2818     Fts3Table *p,                   /* Virtual table handle */
  2819   2819     Fts3PhraseToken *pTok,          /* Token to query for */
  2820   2820     int iColumn,                    /* Column to query (or -ve for all columns) */
  2821   2821     int *pnOut,                     /* OUT: Size of buffer at *ppOut */
................................................................................
  3558   3558   void sqlite3Fts3UnicodeTokenizer(sqlite3_tokenizer_module const**ppModule);
  3559   3559   #endif
  3560   3560   #ifdef SQLITE_ENABLE_ICU
  3561   3561   void sqlite3Fts3IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule);
  3562   3562   #endif
  3563   3563   
  3564   3564   /*
  3565         -** Initialise the fts3 extension. If this extension is built as part
         3565  +** Initialize the fts3 extension. If this extension is built as part
  3566   3566   ** of the sqlite library, then this function is called directly by
  3567   3567   ** SQLite. If fts3 is built as a dynamically loadable extension, this
  3568   3568   ** function is called by the sqlite3_extension_init() entry point.
  3569   3569   */
  3570   3570   int sqlite3Fts3Init(sqlite3 *db){
  3571   3571     int rc = SQLITE_OK;
  3572   3572     Fts3Hash *pHash = 0;
................................................................................
  3592   3592   
  3593   3593     rc = sqlite3Fts3InitAux(db);
  3594   3594     if( rc!=SQLITE_OK ) return rc;
  3595   3595   
  3596   3596     sqlite3Fts3SimpleTokenizerModule(&pSimple);
  3597   3597     sqlite3Fts3PorterTokenizerModule(&pPorter);
  3598   3598   
  3599         -  /* Allocate and initialise the hash-table used to store tokenizers. */
         3599  +  /* Allocate and initialize the hash-table used to store tokenizers. */
  3600   3600     pHash = sqlite3_malloc(sizeof(Fts3Hash));
  3601   3601     if( !pHash ){
  3602   3602       rc = SQLITE_NOMEM;
  3603   3603     }else{
  3604   3604       sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1);
  3605   3605     }
  3606   3606   
................................................................................
  5191   5191   ** must be of type FTSQUERY_PHRASE. 
  5192   5192   **
  5193   5193   ** The returned value is either NULL or a pointer to a buffer containing
  5194   5194   ** a position-list indicating the occurrences of the phrase in column iCol
  5195   5195   ** of the current row. 
  5196   5196   **
  5197   5197   ** More specifically, the returned buffer contains 1 varint for each 
  5198         -** occurence of the phrase in the column, stored using the normal (delta+2) 
         5198  +** occurrence of the phrase in the column, stored using the normal (delta+2) 
  5199   5199   ** compression and is terminated by either an 0x01 or 0x00 byte. For example,
  5200   5200   ** if the requested column contains "a b X c d X X" and the position-list
  5201   5201   ** for 'X' is requested, the buffer returned may contain:
  5202   5202   **
  5203   5203   **     0x04 0x05 0x03 0x01   or   0x04 0x05 0x03 0x00
  5204   5204   **
  5205   5205   ** This function works regardless of whether or not the phrase is deferred,

Changes to ext/fts3/fts3_expr.c.

   102    102     int nNest;                          /* Number of nested brackets */
   103    103   };
   104    104   
   105    105   /*
   106    106   ** This function is equivalent to the standard isspace() function. 
   107    107   **
   108    108   ** The standard isspace() can be awkward to use safely, because although it
   109         -** is defined to accept an argument of type int, its behaviour when passed
          109  +** is defined to accept an argument of type int, its behavior when passed
   110    110   ** an integer that falls outside of the range of the unsigned char type
   111    111   ** is undefined (and sometimes, "undefined" means segfault). This wrapper
   112    112   ** is defined to accept an argument of type char, and always returns 0 for
   113    113   ** any values that fall outside of the range of the unsigned char type (i.e.
   114    114   ** negative values).
   115    115   */
   116    116   static int fts3isspace(char c){

Changes to ext/fts3/fts3_hash.h.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** This is the header file for the generic hash-table implemenation
           12  +** This is the header file for the generic hash-table implementation
    13     13   ** used in SQLite.  We've modified it slightly to serve as a standalone
    14     14   ** hash table implementation for the full-text indexing module.
    15     15   **
    16     16   */
    17     17   #ifndef _FTS3_HASH_H_
    18     18   #define _FTS3_HASH_H_
    19     19   

Changes to ext/fts3/fts3_snippet.c.

   385    385   
   386    386   /*
   387    387   ** Select the fragment of text consisting of nFragment contiguous tokens 
   388    388   ** from column iCol that represent the "best" snippet. The best snippet
   389    389   ** is the snippet with the highest score, where scores are calculated
   390    390   ** by adding:
   391    391   **
   392         -**   (a) +1 point for each occurence of a matchable phrase in the snippet.
          392  +**   (a) +1 point for each occurrence of a matchable phrase in the snippet.
   393    393   **
   394         -**   (b) +1000 points for the first occurence of each matchable phrase in 
          394  +**   (b) +1000 points for the first occurrence of each matchable phrase in 
   395    395   **       the snippet for which the corresponding mCovered bit is not set.
   396    396   **
   397    397   ** The selected snippet parameters are stored in structure *pFragment before
   398    398   ** returning. The score of the selected snippet is stored in *piScore
   399    399   ** before returning.
   400    400   */
   401    401   static int fts3BestSnippet(

Changes to ext/fts3/fts3_test.c.

   263    263   **
   264    264   ** If present, the first argument is the chunksize in bytes to load doclists
   265    265   ** in. The second argument is the minimum doclist size in bytes to use
   266    266   ** incremental loading with.
   267    267   **
   268    268   ** Whether or not the arguments are present, this command returns a list of
   269    269   ** two integers - the initial chunksize and threshold when the command is
   270         -** invoked. This can be used to restore the default behaviour after running
          270  +** invoked. This can be used to restore the default behavior after running
   271    271   ** tests. For example:
   272    272   **
   273    273   **    # Override incr-load settings for testing:
   274    274   **    set cfg [fts3_configure_incr_load $new_chunksize $new_threshold]
   275    275   **
   276    276   **    .... run tests ....
   277    277   **

Changes to ext/fts3/fts3_tokenizer.c.

   424    424   }
   425    425   
   426    426   #endif
   427    427   
   428    428   /*
   429    429   ** Set up SQL objects in database db used to access the contents of
   430    430   ** the hash table pointed to by argument pHash. The hash table must
   431         -** been initialised to use string keys, and to take a private copy 
          431  +** been initialized to use string keys, and to take a private copy 
   432    432   ** of the key when a value is inserted. i.e. by a call similar to:
   433    433   **
   434    434   **    sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1);
   435    435   **
   436    436   ** This function adds a scalar function (see header comment above
   437    437   ** scalarFunc() in this file for details) and, if ENABLE_TABLE is
   438    438   ** defined at compilation time, a temporary virtual table (see header 

Changes to ext/fts3/fts3_tokenizer.h.

    66     66     **
    67     67     ** then argc is set to 2, and the argv[] array contains pointers
    68     68     ** to the strings "arg1" and "arg2".
    69     69     **
    70     70     ** This method should return either SQLITE_OK (0), or an SQLite error 
    71     71     ** code. If SQLITE_OK is returned, then *ppTokenizer should be set
    72     72     ** to point at the newly created tokenizer structure. The generic
    73         -  ** sqlite3_tokenizer.pModule variable should not be initialised by
           73  +  ** sqlite3_tokenizer.pModule variable should not be initialized by
    74     74     ** this callback. The caller will do so.
    75     75     */
    76     76     int (*xCreate)(
    77     77       int argc,                           /* Size of argv array */
    78     78       const char *const*argv,             /* Tokenizer argument strings */
    79     79       sqlite3_tokenizer **ppTokenizer     /* OUT: Created tokenizer */
    80     80     );

Changes to ext/fts3/fts3_unicode.c.

   121    121   ** If so, no action is taken. Otherwise, the codepoint is added to the 
   122    122   ** unicode_tokenizer.aiException[] array. For the purposes of tokenization,
   123    123   ** the return value of sqlite3FtsUnicodeIsalnum() is inverted for all
   124    124   ** codepoints in the aiException[] array.
   125    125   **
   126    126   ** If a standalone diacritic mark (one that sqlite3FtsUnicodeIsdiacritic()
   127    127   ** identifies as a diacritic) occurs in the zIn/nIn string it is ignored.
   128         -** It is not possible to change the behaviour of the tokenizer with respect
          128  +** It is not possible to change the behavior of the tokenizer with respect
   129    129   ** to these codepoints.
   130    130   */
   131    131   static int unicodeAddExceptions(
   132    132     unicode_tokenizer *p,           /* Tokenizer to add exceptions to */
   133    133     int bAlnum,                     /* Replace Isalnum() return value with this */
   134    134     const char *zIn,                /* Array of characters to make exceptions */
   135    135     int nIn                         /* Length of z in bytes */

Changes to ext/fts3/fts3_write.c.

  1478   1478       ** size of the previous offset-list.
  1479   1479       */
  1480   1480       if( ppOffsetList ){
  1481   1481         *ppOffsetList = pReader->pOffsetList;
  1482   1482         *pnOffsetList = (int)(p - pReader->pOffsetList - 1);
  1483   1483       }
  1484   1484   
         1485  +    /* List may have been edited in place by fts3EvalNearTrim() */
  1485   1486       while( p<pEnd && *p==0 ) p++;
  1486   1487     
  1487   1488       /* If there are no more entries in the doclist, set pOffsetList to
  1488   1489       ** NULL. Otherwise, set Fts3SegReader.iDocid to the next docid and
  1489   1490       ** Fts3SegReader.pOffsetList to point to the next offset list before
  1490   1491       ** returning.
  1491   1492       */
................................................................................
  2493   2494   ** When this function is called, buffer *ppList (size *pnList bytes) contains 
  2494   2495   ** a position list that may (or may not) feature multiple columns. This
  2495   2496   ** function adjusts the pointer *ppList and the length *pnList so that they
  2496   2497   ** identify the subset of the position list that corresponds to column iCol.
  2497   2498   **
  2498   2499   ** If there are no entries in the input position list for column iCol, then
  2499   2500   ** *pnList is set to zero before returning.
         2501  +**
         2502  +** If parameter bZero is non-zero, then any part of the input list following
         2503  +** the end of the output list is zeroed before returning.
  2500   2504   */
  2501   2505   static void fts3ColumnFilter(
  2502   2506     int iCol,                       /* Column to filter on */
         2507  +  int bZero,                      /* Zero out anything following *ppList */
  2503   2508     char **ppList,                  /* IN/OUT: Pointer to position list */
  2504   2509     int *pnList                     /* IN/OUT: Size of buffer *ppList in bytes */
  2505   2510   ){
  2506   2511     char *pList = *ppList;
  2507   2512     int nList = *pnList;
  2508   2513     char *pEnd = &pList[nList];
  2509   2514     int iCurrent = 0;
................................................................................
  2524   2529       if( nList==0 ){
  2525   2530         break;
  2526   2531       }
  2527   2532       p = &pList[1];
  2528   2533       p += sqlite3Fts3GetVarint32(p, &iCurrent);
  2529   2534     }
  2530   2535   
         2536  +  if( bZero && &pList[nList]!=pEnd ){
         2537  +    memset(&pList[nList], 0, pEnd - &pList[nList]);
         2538  +  }
  2531   2539     *ppList = pList;
  2532   2540     *pnList = nList;
  2533   2541   }
  2534   2542   
  2535   2543   /*
  2536   2544   ** Cache data in the Fts3MultiSegReader.aBuffer[] buffer (overwriting any
  2537   2545   ** existing data). Grow the buffer if required.
................................................................................
  2596   2604           && apSegment[j]->iDocid==iDocid
  2597   2605         ){
  2598   2606           rc = fts3SegReaderNextDocid(p, apSegment[j], 0, 0);
  2599   2607           j++;
  2600   2608         }
  2601   2609         if( rc!=SQLITE_OK ) return rc;
  2602   2610         fts3SegReaderSort(pMsr->apSegment, nMerge, j, xCmp);
         2611  +
         2612  +      if( nList>0 && fts3SegReaderIsPending(apSegment[0]) ){
         2613  +        rc = fts3MsrBufferData(pMsr, pList, nList+1);
         2614  +        if( rc!=SQLITE_OK ) return rc;
         2615  +        assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 );
         2616  +        pList = pMsr->aBuffer;
         2617  +      }
  2603   2618   
  2604   2619         if( pMsr->iColFilter>=0 ){
  2605         -        fts3ColumnFilter(pMsr->iColFilter, &pList, &nList);
         2620  +        fts3ColumnFilter(pMsr->iColFilter, 1, &pList, &nList);
  2606   2621         }
  2607   2622   
  2608   2623         if( nList>0 ){
  2609         -        if( fts3SegReaderIsPending(apSegment[0]) ){
  2610         -          rc = fts3MsrBufferData(pMsr, pList, nList+1);
  2611         -          if( rc!=SQLITE_OK ) return rc;
  2612         -          *paPoslist = pMsr->aBuffer;
  2613         -          assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 );
  2614         -        }else{
  2615         -          *paPoslist = pList;
  2616         -        }
         2624  +        *paPoslist = pList;
  2617   2625           *piDocid = iDocid;
  2618   2626           *pnPoslist = nList;
  2619   2627           break;
  2620   2628         }
  2621   2629       }
  2622   2630     }
  2623   2631   
................................................................................
  2852   2860               && apSegment[j]->iDocid==iDocid
  2853   2861           ){
  2854   2862             fts3SegReaderNextDocid(p, apSegment[j], 0, 0);
  2855   2863             j++;
  2856   2864           }
  2857   2865   
  2858   2866           if( isColFilter ){
  2859         -          fts3ColumnFilter(pFilter->iCol, &pList, &nList);
         2867  +          fts3ColumnFilter(pFilter->iCol, 0, &pList, &nList);
  2860   2868           }
  2861   2869   
  2862   2870           if( !isIgnoreEmpty || nList>0 ){
  2863   2871   
  2864   2872             /* Calculate the 'docid' delta value to write into the merged 
  2865   2873             ** doclist. */
  2866   2874             sqlite3_int64 iDelta;

Changes to ext/icu/README.txt.

    94     94       comparision operator "REGEXP", based on the regular expression functions
    95     95       provided by the ICU library. The syntax of the operator is as described
    96     96       in SQLite documentation:
    97     97   
    98     98           <string> REGEXP <re-pattern>
    99     99   
   100    100       This extension uses the ICU defaults for regular expression matching
   101         -    behaviour. Specifically, this means that:
          101  +    behavior. Specifically, this means that:
   102    102   
   103    103           * Matching is case-sensitive,
   104    104           * Regular expression comments are not allowed within patterns, and
   105    105           * The '^' and '$' characters match the beginning and end of the
   106    106             <string> argument, not the beginning and end of lines within
   107    107             the <string> argument.
   108    108   

Changes to ext/rtree/rtree.c.

  2661   2661   static int rtreeDeleteRowid(Rtree *pRtree, sqlite3_int64 iDelete){
  2662   2662     int rc;                         /* Return code */
  2663   2663     RtreeNode *pLeaf = 0;           /* Leaf node containing record iDelete */
  2664   2664     int iCell;                      /* Index of iDelete cell in pLeaf */
  2665   2665     RtreeNode *pRoot;               /* Root node of rtree structure */
  2666   2666   
  2667   2667   
  2668         -  /* Obtain a reference to the root node to initialise Rtree.iDepth */
         2668  +  /* Obtain a reference to the root node to initialize Rtree.iDepth */
  2669   2669     rc = nodeAcquire(pRtree, 1, 0, &pRoot);
  2670   2670   
  2671   2671     /* Obtain a reference to the leaf node that contains the entry 
  2672   2672     ** about to be deleted. 
  2673   2673     */
  2674   2674     if( rc==SQLITE_OK ){
  2675   2675       rc = findLeafNode(pRtree, iDelete, &pLeaf);

Changes to src/attach.c.

   105    105       assert( z && zName );
   106    106       if( sqlite3StrICmp(z, zName)==0 ){
   107    107         zErrDyn = sqlite3MPrintf(db, "database %s is already in use", zName);
   108    108         goto attach_error;
   109    109       }
   110    110     }
   111    111   
   112         -  /* Allocate the new entry in the db->aDb[] array and initialise the schema
          112  +  /* Allocate the new entry in the db->aDb[] array and initialize the schema
   113    113     ** hash tables.
   114    114     */
   115    115     if( db->aDb==db->aDbStatic ){
   116    116       aNew = sqlite3DbMallocRaw(db, sizeof(db->aDb[0])*3 );
   117    117       if( aNew==0 ) return;
   118    118       memcpy(aNew, db->aDb, sizeof(db->aDb[0])*2);
   119    119     }else{
................................................................................
   122    122     }
   123    123     db->aDb = aNew;
   124    124     aNew = &db->aDb[db->nDb];
   125    125     memset(aNew, 0, sizeof(*aNew));
   126    126   
   127    127     /* Open the database file. If the btree is successfully opened, use
   128    128     ** it to obtain the database schema. At this point the schema may
   129         -  ** or may not be initialised.
          129  +  ** or may not be initialized.
   130    130     */
   131    131     flags = db->openFlags;
   132    132     rc = sqlite3ParseUri(db->pVfs->zName, zFile, &flags, &pVfs, &zPath, &zErr);
   133    133     if( rc!=SQLITE_OK ){
   134    134       if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;
   135    135       sqlite3_result_error(context, zErr, -1);
   136    136       sqlite3_free(zErr);

Changes to src/bitvec.c.

    68     68   
    69     69   #define BITVEC_NPTR      (BITVEC_USIZE/sizeof(Bitvec *))
    70     70   
    71     71   
    72     72   /*
    73     73   ** A bitmap is an instance of the following structure.
    74     74   **
    75         -** This bitmap records the existance of zero or more bits
           75  +** This bitmap records the existence of zero or more bits
    76     76   ** with values between 1 and iSize, inclusive.
    77     77   **
    78     78   ** There are three possible representations of the bitmap.
    79     79   ** If iSize<=BITVEC_NBIT, then Bitvec.u.aBitmap[] is a straight
    80     80   ** bitmap.  The least significant bit is bit 1.
    81     81   **
    82     82   ** If iSize>BITVEC_NBIT and iDivisor==0 then Bitvec.u.aHash[] is

Changes to src/btree.c.

   570    570   ** Clear (destroy) the BtShared.pHasContent bitvec. This should be
   571    571   ** invoked at the conclusion of each write-transaction.
   572    572   */
   573    573   static void btreeClearHasContent(BtShared *pBt){
   574    574     sqlite3BitvecDestroy(pBt->pHasContent);
   575    575     pBt->pHasContent = 0;
   576    576   }
          577  +
          578  +/*
          579  +** Release all of the apPage[] pages for a cursor.
          580  +*/
          581  +static void btreeReleaseAllCursorPages(BtCursor *pCur){
          582  +  int i;
          583  +  for(i=0; i<=pCur->iPage; i++){
          584  +    releasePage(pCur->apPage[i]);
          585  +    pCur->apPage[i] = 0;
          586  +  }
          587  +  pCur->iPage = -1;
          588  +}
          589  +
   577    590   
   578    591   /*
   579    592   ** Save the current cursor position in the variables BtCursor.nKey 
   580    593   ** and BtCursor.pKey. The cursor's state is set to CURSOR_REQUIRESEEK.
   581    594   **
   582    595   ** The caller must ensure that the cursor is valid (has eState==CURSOR_VALID)
   583    596   ** prior to calling this routine.  
................................................................................
   610    623       }else{
   611    624         rc = SQLITE_NOMEM;
   612    625       }
   613    626     }
   614    627     assert( !pCur->apPage[0]->intKey || !pCur->pKey );
   615    628   
   616    629     if( rc==SQLITE_OK ){
   617         -    int i;
   618         -    for(i=0; i<=pCur->iPage; i++){
   619         -      releasePage(pCur->apPage[i]);
   620         -      pCur->apPage[i] = 0;
   621         -    }
   622         -    pCur->iPage = -1;
          630  +    btreeReleaseAllCursorPages(pCur);
   623    631       pCur->eState = CURSOR_REQUIRESEEK;
   624    632     }
   625    633   
   626    634     invalidateOverflowCache(pCur);
   627    635     return rc;
   628    636   }
   629    637   
................................................................................
   633    641   ** pExcept is used to modify the table (BtreeDelete() or BtreeInsert()).
   634    642   */
   635    643   static int saveAllCursors(BtShared *pBt, Pgno iRoot, BtCursor *pExcept){
   636    644     BtCursor *p;
   637    645     assert( sqlite3_mutex_held(pBt->mutex) );
   638    646     assert( pExcept==0 || pExcept->pBt==pBt );
   639    647     for(p=pBt->pCursor; p; p=p->pNext){
   640         -    if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) && 
   641         -        p->eState==CURSOR_VALID ){
   642         -      int rc = saveCursorPosition(p);
   643         -      if( SQLITE_OK!=rc ){
   644         -        return rc;
          648  +    if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ){
          649  +      if( p->eState==CURSOR_VALID ){
          650  +        int rc = saveCursorPosition(p);
          651  +        if( SQLITE_OK!=rc ){
          652  +          return rc;
          653  +        }
          654  +      }else{
          655  +        testcase( p->iPage>0 );
          656  +        btreeReleaseAllCursorPages(p);
   645    657         }
   646    658       }
   647    659     }
   648    660     return SQLITE_OK;
   649    661   }
   650    662   
   651    663   /*
................................................................................
  2225   2237   ** may only be called if it is guaranteed that the b-tree mutex is already
  2226   2238   ** held.
  2227   2239   **
  2228   2240   ** This is useful in one special case in the backup API code where it is
  2229   2241   ** known that the shared b-tree mutex is held, but the mutex on the 
  2230   2242   ** database handle that owns *p is not. In this case if sqlite3BtreeEnter()
  2231   2243   ** were to be called, it might collide with some other operation on the
  2232         -** database handle that owns *p, causing undefined behaviour.
         2244  +** database handle that owns *p, causing undefined behavior.
  2233   2245   */
  2234   2246   int sqlite3BtreeGetReserveNoMutex(Btree *p){
  2235   2247     assert( sqlite3_mutex_held(p->pBt->mutex) );
  2236   2248     return p->pBt->pageSize - p->pBt->usableSize;
  2237   2249   }
  2238   2250   #endif /* SQLITE_HAS_CODEC || SQLITE_DEBUG */
  2239   2251   
................................................................................
  5505   5517         /* If the database supports auto-vacuum, and the second or subsequent
  5506   5518         ** overflow page is being allocated, add an entry to the pointer-map
  5507   5519         ** for that page now. 
  5508   5520         **
  5509   5521         ** If this is the first overflow page, then write a partial entry 
  5510   5522         ** to the pointer-map. If we write nothing to this pointer-map slot,
  5511   5523         ** then the optimistic overflow chain processing in clearCell()
  5512         -      ** may misinterpret the uninitialised values and delete the
         5524  +      ** may misinterpret the uninitialized values and delete the
  5513   5525         ** wrong pages from the database.
  5514   5526         */
  5515   5527         if( pBt->autoVacuum && rc==SQLITE_OK ){
  5516   5528           u8 eType = (pgnoPtrmap?PTRMAP_OVERFLOW2:PTRMAP_OVERFLOW1);
  5517   5529           ptrmapPut(pBt, pgnoOvfl, eType, pgnoPtrmap, &rc);
  5518   5530           if( rc ){
  5519   5531             releasePage(pOvfl);
................................................................................
  6978   6990       idx = ++pCur->aiIdx[pCur->iPage];
  6979   6991     }else{
  6980   6992       assert( pPage->leaf );
  6981   6993     }
  6982   6994     insertCell(pPage, idx, newCell, szNew, 0, 0, &rc);
  6983   6995     assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 );
  6984   6996   
  6985         -  /* If no error has occured and pPage has an overflow cell, call balance() 
         6997  +  /* If no error has occurred and pPage has an overflow cell, call balance() 
  6986   6998     ** to redistribute the cells within the tree. Since balance() may move
  6987   6999     ** the cursor, zero the BtCursor.info.nSize and BtCursor.validNKey
  6988   7000     ** variables.
  6989   7001     **
  6990   7002     ** Previous versions of SQLite called moveToRoot() to move the cursor
  6991   7003     ** back to the root page as balance() used to invalidate the contents
  6992   7004     ** of BtCursor.apPage[] and BtCursor.aiIdx[]. Instead of doing that,

Changes to src/build.c.

  2096   2096       );
  2097   2097     }
  2098   2098   #endif
  2099   2099   
  2100   2100     /* Drop all SQLITE_MASTER table and index entries that refer to the
  2101   2101     ** table. The program name loops through the master table and deletes
  2102   2102     ** every row that refers to a table of the same name as the one being
  2103         -  ** dropped. Triggers are handled seperately because a trigger can be
         2103  +  ** dropped. Triggers are handled separately because a trigger can be
  2104   2104     ** created in the temp database that refers to a table in another
  2105   2105     ** database.
  2106   2106     */
  2107   2107     sqlite3NestedParse(pParse, 
  2108   2108         "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'",
  2109   2109         pDb->zName, SCHEMA_TABLE(iDb), pTab->zName);
  2110   2110     if( !isView && !IsVirtual(pTab) ){
................................................................................
  2388   2388     int iIdx = pParse->nTab++;     /* Btree cursor used for pIndex */
  2389   2389     int iSorter;                   /* Cursor opened by OpenSorter (if in use) */
  2390   2390     int addr1;                     /* Address of top of loop */
  2391   2391     int addr2;                     /* Address to jump to for next iteration */
  2392   2392     int tnum;                      /* Root page of index */
  2393   2393     Vdbe *v;                       /* Generate code into this virtual machine */
  2394   2394     KeyInfo *pKey;                 /* KeyInfo for index */
  2395         -#ifdef SQLITE_OMIT_MERGE_SORT
  2396         -  int regIdxKey;                 /* Registers containing the index key */
  2397         -#endif
  2398   2395     int regRecord;                 /* Register holding assemblied index record */
  2399   2396     sqlite3 *db = pParse->db;      /* The database connection */
  2400   2397     int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);
  2401   2398   
  2402   2399   #ifndef SQLITE_OMIT_AUTHORIZATION
  2403   2400     if( sqlite3AuthCheck(pParse, SQLITE_REINDEX, pIndex->zName, 0,
  2404   2401         db->aDb[iDb].zName ) ){
................................................................................
  2418   2415       sqlite3VdbeAddOp2(v, OP_Clear, tnum, iDb);
  2419   2416     }
  2420   2417     pKey = sqlite3IndexKeyinfo(pParse, pIndex);
  2421   2418     sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, 
  2422   2419                       (char *)pKey, P4_KEYINFO_HANDOFF);
  2423   2420     sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR|((memRootPage>=0)?OPFLAG_P2ISREG:0));
  2424   2421   
  2425         -#ifndef SQLITE_OMIT_MERGE_SORT
  2426   2422     /* Open the sorter cursor if we are to use one. */
  2427   2423     iSorter = pParse->nTab++;
  2428   2424     sqlite3VdbeAddOp4(v, OP_SorterOpen, iSorter, 0, 0, (char*)pKey, P4_KEYINFO);
  2429         -#else
  2430         -  iSorter = iTab;
  2431         -#endif
  2432   2425   
  2433   2426     /* Open the table. Loop through all rows of the table, inserting index
  2434   2427     ** records into the sorter. */
  2435   2428     sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
  2436   2429     addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0);
  2437   2430     regRecord = sqlite3GetTempReg(pParse);
  2438   2431   
  2439         -#ifndef SQLITE_OMIT_MERGE_SORT
  2440   2432     sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1);
  2441   2433     sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);
  2442   2434     sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1);
  2443   2435     sqlite3VdbeJumpHere(v, addr1);
  2444   2436     addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0);
  2445   2437     if( pIndex->onError!=OE_None ){
  2446   2438       int j2 = sqlite3VdbeCurrentAddr(v) + 3;
................................................................................
  2452   2444       );
  2453   2445     }else{
  2454   2446       addr2 = sqlite3VdbeCurrentAddr(v);
  2455   2447     }
  2456   2448     sqlite3VdbeAddOp2(v, OP_SorterData, iSorter, regRecord);
  2457   2449     sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 1);
  2458   2450     sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
  2459         -#else
  2460         -  regIdxKey = sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1);
  2461         -  addr2 = addr1 + 1;
  2462         -  if( pIndex->onError!=OE_None ){
  2463         -    const int regRowid = regIdxKey + pIndex->nColumn;
  2464         -    const int j2 = sqlite3VdbeCurrentAddr(v) + 2;
  2465         -    void * const pRegKey = SQLITE_INT_TO_PTR(regIdxKey);
  2466         -
  2467         -    /* The registers accessed by the OP_IsUnique opcode were allocated
  2468         -    ** using sqlite3GetTempRange() inside of the sqlite3GenerateIndexKey()
  2469         -    ** call above. Just before that function was freed they were released
  2470         -    ** (made available to the compiler for reuse) using 
  2471         -    ** sqlite3ReleaseTempRange(). So in some ways having the OP_IsUnique
  2472         -    ** opcode use the values stored within seems dangerous. However, since
  2473         -    ** we can be sure that no other temp registers have been allocated
  2474         -    ** since sqlite3ReleaseTempRange() was called, it is safe to do so.
  2475         -    */
  2476         -    sqlite3VdbeAddOp4(v, OP_IsUnique, iIdx, j2, regRowid, pRegKey, P4_INT32);
  2477         -    sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_UNIQUE,
  2478         -        "indexed columns are not unique", P4_STATIC);
  2479         -  }
  2480         -  sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 0);
  2481         -  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
  2482         -#endif
  2483   2451     sqlite3ReleaseTempReg(pParse, regRecord);
  2484   2452     sqlite3VdbeAddOp2(v, OP_SorterNext, iSorter, addr2);
  2485   2453     sqlite3VdbeJumpHere(v, addr1);
  2486   2454   
  2487   2455     sqlite3VdbeAddOp1(v, OP_Close, iTab);
  2488   2456     sqlite3VdbeAddOp1(v, OP_Close, iIdx);
  2489   2457     sqlite3VdbeAddOp1(v, OP_Close, iSorter);
................................................................................
  2835   2803         if( k==pIdx->nColumn ){
  2836   2804           if( pIdx->onError!=pIndex->onError ){
  2837   2805             /* This constraint creates the same index as a previous
  2838   2806             ** constraint specified somewhere in the CREATE TABLE statement.
  2839   2807             ** However the ON CONFLICT clauses are different. If both this 
  2840   2808             ** constraint and the previous equivalent constraint have explicit
  2841   2809             ** ON CONFLICT clauses this is an error. Otherwise, use the
  2842         -          ** explicitly specified behaviour for the index.
         2810  +          ** explicitly specified behavior for the index.
  2843   2811             */
  2844   2812             if( !(pIdx->onError==OE_Default || pIndex->onError==OE_Default) ){
  2845   2813               sqlite3ErrorMsg(pParse, 
  2846   2814                   "conflicting ON CONFLICT clauses specified", 0);
  2847   2815             }
  2848   2816             if( pIdx->onError==OE_Default ){
  2849   2817               pIdx->onError = pIndex->onError;

Changes to src/ctime.c.

   259    259   #endif
   260    260   #ifdef SQLITE_OMIT_LOOKASIDE
   261    261     "OMIT_LOOKASIDE",
   262    262   #endif
   263    263   #ifdef SQLITE_OMIT_MEMORYDB
   264    264     "OMIT_MEMORYDB",
   265    265   #endif
   266         -#ifdef SQLITE_OMIT_MERGE_SORT
   267         -  "OMIT_MERGE_SORT",
   268         -#endif
   269    266   #ifdef SQLITE_OMIT_OR_OPTIMIZATION
   270    267     "OMIT_OR_OPTIMIZATION",
   271    268   #endif
   272    269   #ifdef SQLITE_OMIT_PAGER_PRAGMAS
   273    270     "OMIT_PAGER_PRAGMAS",
   274    271   #endif
   275    272   #ifdef SQLITE_OMIT_PRAGMA

Changes to src/expr.c.

  3538   3538     Vdbe *v = pParse->pVdbe;
  3539   3539     int op = 0;
  3540   3540     int regFree1 = 0;
  3541   3541     int regFree2 = 0;
  3542   3542     int r1, r2;
  3543   3543   
  3544   3544     assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 );
  3545         -  if( NEVER(v==0) )     return;  /* Existance of VDBE checked by caller */
         3545  +  if( NEVER(v==0) )     return;  /* Existence of VDBE checked by caller */
  3546   3546     if( NEVER(pExpr==0) ) return;  /* No way this can happen */
  3547   3547     op = pExpr->op;
  3548   3548     switch( op ){
  3549   3549       case TK_AND: {
  3550   3550         int d2 = sqlite3VdbeMakeLabel(v);
  3551   3551         testcase( jumpIfNull==0 );
  3552   3552         sqlite3ExprCachePush(pParse);
................................................................................
  3658   3658     Vdbe *v = pParse->pVdbe;
  3659   3659     int op = 0;
  3660   3660     int regFree1 = 0;
  3661   3661     int regFree2 = 0;
  3662   3662     int r1, r2;
  3663   3663   
  3664   3664     assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 );
  3665         -  if( NEVER(v==0) ) return; /* Existance of VDBE checked by caller */
         3665  +  if( NEVER(v==0) ) return; /* Existence of VDBE checked by caller */
  3666   3666     if( pExpr==0 )    return;
  3667   3667   
  3668   3668     /* The value of pExpr->op and op are related as follows:
  3669   3669     **
  3670   3670     **       pExpr->op            op
  3671   3671     **       ---------          ----------
  3672   3672     **       TK_ISNULL          OP_NotNull

Changes to src/hash.h.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** This is the header file for the generic hash-table implemenation
           12  +** This is the header file for the generic hash-table implementation
    13     13   ** used in SQLite.
    14     14   */
    15     15   #ifndef _SQLITE_HASH_H_
    16     16   #define _SQLITE_HASH_H_
    17     17   
    18     18   /* Forward declarations of structures. */
    19     19   typedef struct Hash Hash;

Changes to src/main.c.

   881    881     if( db->magic!=SQLITE_MAGIC_ZOMBIE || connectionIsBusy(db) ){
   882    882       sqlite3_mutex_leave(db->mutex);
   883    883       return;
   884    884     }
   885    885   
   886    886     /* If we reach this point, it means that the database connection has
   887    887     ** closed all sqlite3_stmt and sqlite3_backup objects and has been
   888         -  ** pased to sqlite3_close (meaning that it is a zombie).  Therefore,
          888  +  ** passed to sqlite3_close (meaning that it is a zombie).  Therefore,
   889    889     ** go ahead and free all resources.
   890    890     */
   891    891   
   892    892     /* Free any outstanding Savepoint structures. */
   893    893     sqlite3CloseSavepoints(db);
   894    894   
   895    895     /* Close all database connections */

Changes to src/os_unix.c.

   333    333   /*
   334    334   ** Many system calls are accessed through pointer-to-functions so that
   335    335   ** they may be overridden at runtime to facilitate fault injection during
   336    336   ** testing and sandboxing.  The following array holds the names and pointers
   337    337   ** to all overrideable system calls.
   338    338   */
   339    339   static struct unix_syscall {
   340         -  const char *zName;            /* Name of the sytem call */
          340  +  const char *zName;            /* Name of the system call */
   341    341     sqlite3_syscall_ptr pCurrent; /* Current value of the system call */
   342    342     sqlite3_syscall_ptr pDefault; /* Default value */
   343    343   } aSyscall[] = {
   344    344     { "open",         (sqlite3_syscall_ptr)posixOpen,  0  },
   345    345   #define osOpen      ((int(*)(const char*,int,int))aSyscall[0].pCurrent)
   346    346   
   347    347     { "close",        (sqlite3_syscall_ptr)close,      0  },
................................................................................
  1905   1905   
  1906   1906   /******************* End of the no-op lock implementation *********************
  1907   1907   ******************************************************************************/
  1908   1908   
  1909   1909   /******************************************************************************
  1910   1910   ************************* Begin dot-file Locking ******************************
  1911   1911   **
  1912         -** The dotfile locking implementation uses the existance of separate lock
         1912  +** The dotfile locking implementation uses the existence of separate lock
  1913   1913   ** files (really a directory) to control access to the database.  This works
  1914   1914   ** on just about every filesystem imaginable.  But there are serious downsides:
  1915   1915   **
  1916   1916   **    (1)  There is zero concurrency.  A single reader blocks all other
  1917   1917   **         connections from reading or writing the database.
  1918   1918   **
  1919   1919   **    (2)  An application crash or power loss can leave stale lock files
................................................................................
  1920   1920   **         sitting around that need to be cleared manually.
  1921   1921   **
  1922   1922   ** Nevertheless, a dotlock is an appropriate locking mode for use if no
  1923   1923   ** other locking strategy is available.
  1924   1924   **
  1925   1925   ** Dotfile locking works by creating a subdirectory in the same directory as
  1926   1926   ** the database and with the same name but with a ".lock" extension added.
  1927         -** The existance of a lock directory implies an EXCLUSIVE lock.  All other
         1927  +** The existence of a lock directory implies an EXCLUSIVE lock.  All other
  1928   1928   ** lock types (SHARED, RESERVED, PENDING) are mapped into EXCLUSIVE.
  1929   1929   */
  1930   1930   
  1931   1931   /*
  1932   1932   ** The file suffix added to the data base filename in order to create the
  1933   1933   ** lock directory.
  1934   1934   */
................................................................................
  3409   3409     SimulateIOError( rc=1 );
  3410   3410     if( rc ){
  3411   3411       pFile->lastErrno = errno;
  3412   3412       return unixLogError(SQLITE_IOERR_FSYNC, "full_fsync", pFile->zPath);
  3413   3413     }
  3414   3414   
  3415   3415     /* Also fsync the directory containing the file if the DIRSYNC flag
  3416         -  ** is set.  This is a one-time occurrance.  Many systems (examples: AIX)
         3416  +  ** is set.  This is a one-time occurrence.  Many systems (examples: AIX)
  3417   3417     ** are unable to fsync a directory, so ignore errors on the fsync.
  3418   3418     */
  3419   3419     if( pFile->ctrlFlags & UNIXFILE_DIRSYNC ){
  3420   3420       int dirfd;
  3421   3421       OSTRACE(("DIRSYNC %s (have_fullfsync=%d fullsync=%d)\n", pFile->zPath,
  3422   3422               HAVE_FULLFSYNC, isFullsync));
  3423   3423       rc = osOpenDirectory(pFile->zPath, &dirfd);
................................................................................
  4783   4783   #if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE
  4784   4784       || pLockingStyle == &nfsIoMethods
  4785   4785   #endif
  4786   4786     ){
  4787   4787       unixEnterMutex();
  4788   4788       rc = findInodeInfo(pNew, &pNew->pInode);
  4789   4789       if( rc!=SQLITE_OK ){
  4790         -      /* If an error occured in findInodeInfo(), close the file descriptor
         4790  +      /* If an error occurred in findInodeInfo(), close the file descriptor
  4791   4791         ** immediately, before releasing the mutex. findInodeInfo() may fail
  4792   4792         ** in two scenarios:
  4793   4793         **
  4794   4794         **   (a) A call to fstat() failed.
  4795   4795         **   (b) A malloc failed.
  4796   4796         **
  4797   4797         ** Scenario (b) may only occur if the process is holding no other
................................................................................
  5421   5421       }
  5422   5422     }
  5423   5423   #endif
  5424   5424     return rc;
  5425   5425   }
  5426   5426   
  5427   5427   /*
  5428         -** Test the existance of or access permissions of file zPath. The
         5428  +** Test the existence of or access permissions of file zPath. The
  5429   5429   ** test performed depends on the value of flags:
  5430   5430   **
  5431   5431   **     SQLITE_ACCESS_EXISTS: Return 1 if the file exists
  5432   5432   **     SQLITE_ACCESS_READWRITE: Return 1 if the file is read and writable.
  5433   5433   **     SQLITE_ACCESS_READONLY: Return 1 if the file is readable.
  5434   5434   **
  5435   5435   ** Otherwise return 0.

Changes to src/os_win.c.

   304    304   /*
   305    305   ** Many system calls are accessed through pointer-to-functions so that
   306    306   ** they may be overridden at runtime to facilitate fault injection during
   307    307   ** testing and sandboxing.  The following array holds the names and pointers
   308    308   ** to all overrideable system calls.
   309    309   */
   310    310   static struct win_syscall {
   311         -  const char *zName;            /* Name of the sytem call */
          311  +  const char *zName;            /* Name of the system call */
   312    312     sqlite3_syscall_ptr pCurrent; /* Current value of the system call */
   313    313     sqlite3_syscall_ptr pDefault; /* Default value */
   314    314   } aSyscall[] = {
   315    315   #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
   316    316     { "AreFileApisANSI",         (SYSCALL)AreFileApisANSI,         0 },
   317    317   #else
   318    318     { "AreFileApisANSI",         (SYSCALL)0,                       0 },
................................................................................
  2021   2021     upperBits = (LONG)((iOffset>>32) & 0x7fffffff);
  2022   2022     lowerBits = (LONG)(iOffset & 0xffffffff);
  2023   2023   
  2024   2024     /* API oddity: If successful, SetFilePointer() returns a dword 
  2025   2025     ** containing the lower 32-bits of the new file-offset. Or, if it fails,
  2026   2026     ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, 
  2027   2027     ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine 
  2028         -  ** whether an error has actually occured, it is also necessary to call 
         2028  +  ** whether an error has actually occurred, it is also necessary to call 
  2029   2029     ** GetLastError().
  2030   2030     */
  2031   2031     dwRet = osSetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
  2032   2032   
  2033   2033     if( (dwRet==INVALID_SET_FILE_POINTER
  2034   2034         && ((lastErrno = osGetLastError())!=NO_ERROR)) ){
  2035   2035       pFile->lastErrno = lastErrno;
................................................................................
  2167   2167   */
  2168   2168   static int winWrite(
  2169   2169     sqlite3_file *id,               /* File to write into */
  2170   2170     const void *pBuf,               /* The bytes to be written */
  2171   2171     int amt,                        /* Number of bytes to write */
  2172   2172     sqlite3_int64 offset            /* Offset into the file to begin writing at */
  2173   2173   ){
  2174         -  int rc = 0;                     /* True if error has occured, else false */
         2174  +  int rc = 0;                     /* True if error has occurred, else false */
  2175   2175     winFile *pFile = (winFile*)id;  /* File handle */
  2176   2176     int nRetry = 0;                 /* Number of retries */
  2177   2177   
  2178   2178     assert( amt>0 );
  2179   2179     assert( pFile );
  2180   2180     SimulateIOError(return SQLITE_IOERR_WRITE);
  2181   2181     SimulateDiskfullError(return SQLITE_FULL);
................................................................................
  3989   3989     }
  3990   3990     sqlite3_free(zConverted);
  3991   3991     OSTRACE(("DELETE \"%s\" %s\n", zFilename, (rc ? "failed" : "ok" )));
  3992   3992     return rc;
  3993   3993   }
  3994   3994   
  3995   3995   /*
  3996         -** Check the existance and status of a file.
         3996  +** Check the existence and status of a file.
  3997   3997   */
  3998   3998   static int winAccess(
  3999   3999     sqlite3_vfs *pVfs,         /* Not used on win32 */
  4000   4000     const char *zFilename,     /* Name of file to check */
  4001   4001     int flags,                 /* Type of test to make on this file */
  4002   4002     int *pResOut               /* OUT: Result */
  4003   4003   ){

Changes to src/pager.c.

   269    269   **    by finalizing the journal file. Once in WRITER_FINISHED state, it is 
   270    270   **    not possible to modify the database further. At this point, the upper 
   271    271   **    layer must either commit or rollback the transaction.
   272    272   **
   273    273   **    * A write transaction is active.
   274    274   **    * An EXCLUSIVE or greater lock is held on the database file.
   275    275   **    * All writing and syncing of journal and database data has finished.
   276         -**      If no error occured, all that remains is to finalize the journal to
          276  +**      If no error occurred, all that remains is to finalize the journal to
   277    277   **      commit the transaction. If an error did occur, the caller will need
   278    278   **      to rollback the transaction. 
   279    279   **
   280    280   **  ERROR:
   281    281   **
   282    282   **    The ERROR state is entered when an IO or disk-full error (including
   283    283   **    SQLITE_IOERR_NOMEM) occurs at a point in the code that makes it 
................................................................................
   517    517   **   The flag is cleared as soon as the journal file is finalized (either
   518    518   **   by PagerCommitPhaseTwo or PagerRollback). If an IO error prevents the
   519    519   **   journal file from being successfully finalized, the setMaster flag
   520    520   **   is cleared anyway (and the pager will move to ERROR state).
   521    521   **
   522    522   ** doNotSpill, doNotSyncSpill
   523    523   **
   524         -**   These two boolean variables control the behaviour of cache-spills
          524  +**   These two boolean variables control the behavior of cache-spills
   525    525   **   (calls made by the pcache module to the pagerStress() routine to
   526    526   **   write cached data to the file-system in order to free up memory).
   527    527   **
   528    528   **   When doNotSpill is non-zero, writing to the database from pagerStress()
   529    529   **   is disabled altogether. This is done in a very obscure case that
   530    530   **   comes up during savepoint rollback that requires the pcache module
   531    531   **   to allocate a new page to prevent the journal file from being written
................................................................................
  1395   1395     ){
  1396   1396       memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic));
  1397   1397       put32bits(&zHeader[sizeof(aJournalMagic)], 0xffffffff);
  1398   1398     }else{
  1399   1399       memset(zHeader, 0, sizeof(aJournalMagic)+4);
  1400   1400     }
  1401   1401   
  1402         -  /* The random check-hash initialiser */ 
         1402  +  /* The random check-hash initializer */ 
  1403   1403     sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit);
  1404   1404     put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit);
  1405   1405     /* The initial database size */
  1406   1406     put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize);
  1407   1407     /* The assumed sector size for this process */
  1408   1408     put32bits(&zHeader[sizeof(aJournalMagic)+12], pPager->sectorSize);
  1409   1409   
................................................................................
  3727   3727   **      be necessary to write the current content out to the sub-journal
  3728   3728   **      (as determined by function subjRequiresPage()).
  3729   3729   **
  3730   3730   ** If the condition asserted by this function were not true, and the
  3731   3731   ** dirty page were to be discarded from the cache via the pagerStress()
  3732   3732   ** routine, pagerStress() would not write the current page content to
  3733   3733   ** the database file. If a savepoint transaction were rolled back after
  3734         -** this happened, the correct behaviour would be to restore the current
         3734  +** this happened, the correct behavior would be to restore the current
  3735   3735   ** content of the page. However, since this content is not present in either
  3736   3736   ** the database file or the portion of the rollback journal and 
  3737   3737   ** sub-journal rolled back the content could not be restored and the
  3738   3738   ** database image would become corrupt. It is therefore fortunate that 
  3739   3739   ** this circumstance cannot arise.
  3740   3740   */
  3741   3741   #if defined(SQLITE_DEBUG)

Changes to src/prepare.c.

   175    175     assert( iDb>=0 && iDb<db->nDb );
   176    176     assert( db->aDb[iDb].pSchema );
   177    177     assert( sqlite3_mutex_held(db->mutex) );
   178    178     assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );
   179    179   
   180    180     /* zMasterSchema and zInitScript are set to point at the master schema
   181    181     ** and initialisation script appropriate for the database being
   182         -  ** initialised. zMasterName is the name of the master table.
          182  +  ** initialized. zMasterName is the name of the master table.
   183    183     */
   184    184     if( !OMIT_TEMPDB && iDb==1 ){
   185    185       zMasterSchema = temp_master_schema;
   186    186     }else{
   187    187       zMasterSchema = master_schema;
   188    188     }
   189    189     zMasterName = SCHEMA_TABLE(iDb);
................................................................................
   400    400       if( DbHasProperty(db, i, DB_SchemaLoaded) || i==1 ) continue;
   401    401       rc = sqlite3InitOne(db, i, pzErrMsg);
   402    402       if( rc ){
   403    403         sqlite3ResetOneSchema(db, i);
   404    404       }
   405    405     }
   406    406   
   407         -  /* Once all the other databases have been initialised, load the schema
          407  +  /* Once all the other databases have been initialized, load the schema
   408    408     ** for the TEMP database. This is loaded last, as the TEMP database
   409    409     ** schema may contain references to objects in other databases.
   410    410     */
   411    411   #ifndef SQLITE_OMIT_TEMPDB
   412    412     if( rc==SQLITE_OK && ALWAYS(db->nDb>1)
   413    413                       && !DbHasProperty(db, 1, DB_SchemaLoaded) ){
   414    414       rc = sqlite3InitOne(db, 1, pzErrMsg);
................................................................................
   423    423       sqlite3CommitInternalChanges(db);
   424    424     }
   425    425   
   426    426     return rc; 
   427    427   }
   428    428   
   429    429   /*
   430         -** This routine is a no-op if the database schema is already initialised.
          430  +** This routine is a no-op if the database schema is already initialized.
   431    431   ** Otherwise, the schema is loaded. An error code is returned.
   432    432   */
   433    433   int sqlite3ReadSchema(Parse *pParse){
   434    434     int rc = SQLITE_OK;
   435    435     sqlite3 *db = pParse->db;
   436    436     assert( sqlite3_mutex_held(db->mutex) );
   437    437     if( !db->init.busy ){

Changes to src/select.c.

  4566   4566           ** If where.c is able to produce results sorted in this order, then
  4567   4567           ** add vdbe code to break out of the processing loop after the 
  4568   4568           ** first iteration (since the first iteration of the loop is 
  4569   4569           ** guaranteed to operate on the row with the minimum or maximum 
  4570   4570           ** value of x, the only row required).
  4571   4571           **
  4572   4572           ** A special flag must be passed to sqlite3WhereBegin() to slightly
  4573         -        ** modify behaviour as follows:
         4573  +        ** modify behavior as follows:
  4574   4574           **
  4575   4575           **   + If the query is a "SELECT min(x)", then the loop coded by
  4576   4576           **     where.c should not iterate over any values with a NULL value
  4577   4577           **     for x.
  4578   4578           **
  4579   4579           **   + The optimizer code in where.c (the thing that decides which
  4580   4580           **     index or indices to use) should place a different priority on 

Changes to src/sqlite.h.in.

  2671   2671   **
  2672   2672   **   <li> <b>cache</b>: ^The cache parameter may be set to either "shared" or
  2673   2673   **     "private". ^Setting it to "shared" is equivalent to setting the
  2674   2674   **     SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to
  2675   2675   **     sqlite3_open_v2(). ^Setting the cache parameter to "private" is 
  2676   2676   **     equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.
  2677   2677   **     ^If sqlite3_open_v2() is used and the "cache" parameter is present in
  2678         -**     a URI filename, its value overrides any behaviour requested by setting
         2678  +**     a URI filename, its value overrides any behavior requested by setting
  2679   2679   **     SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.
  2680   2680   ** </ul>
  2681   2681   **
  2682   2682   ** ^Specifying an unknown parameter in the query component of a URI is not an
  2683   2683   ** error.  Future versions of SQLite might understand additional query
  2684   2684   ** parameters.  See "[query parameters with special meaning to SQLite]" for
  2685   2685   ** additional information.
................................................................................
  3989   3989   */
  3990   3990   #ifndef SQLITE_OMIT_DEPRECATED
  3991   3991   SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
  3992   3992   SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
  3993   3993   SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
  3994   3994   SQLITE_DEPRECATED int sqlite3_global_recover(void);
  3995   3995   SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
  3996         -SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64);
         3996  +SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
         3997  +                      void*,sqlite3_int64);
  3997   3998   #endif
  3998   3999   
  3999   4000   /*
  4000   4001   ** CAPI3REF: Obtaining SQL Function Parameter Values
  4001   4002   **
  4002   4003   ** The C-language implementation of SQL functions and aggregates uses
  4003   4004   ** this set of interface routines to access the parameter values on
................................................................................
  4069   4070   ** called once for each invocation of the xStep callback and then one
  4070   4071   ** last time when the xFinal callback is invoked.  ^(When no rows match
  4071   4072   ** an aggregate query, the xStep() callback of the aggregate function
  4072   4073   ** implementation is never called and xFinal() is called exactly once.
  4073   4074   ** In those cases, sqlite3_aggregate_context() might be called for the
  4074   4075   ** first time from within xFinal().)^
  4075   4076   **
  4076         -** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is
  4077         -** less than or equal to zero or if a memory allocate error occurs.
         4077  +** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer 
         4078  +** when first called if N is less than or equal to zero or if a memory
         4079  +** allocate error occurs.
  4078   4080   **
  4079   4081   ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
  4080   4082   ** determined by the N parameter on first successful call.  Changing the
  4081   4083   ** value of N in subsequent call to sqlite3_aggregate_context() within
  4082   4084   ** the same aggregate function instance will not resize the memory
  4083         -** allocation.)^
         4085  +** allocation.)^  Within the xFinal callback, it is customary to set
         4086  +** N=0 in calls to sqlite3_aggregate_context(C,N) so that no 
         4087  +** pointless memory allocations occur.
  4084   4088   **
  4085   4089   ** ^SQLite automatically frees the memory allocated by 
  4086   4090   ** sqlite3_aggregate_context() when the aggregate query concludes.
  4087   4091   **
  4088   4092   ** The first parameter must be a copy of the
  4089   4093   ** [sqlite3_context | SQL function context] that is the first parameter
  4090   4094   ** to the xStep or xFinal callback routine that implements the aggregate
................................................................................
  6370   6374   ** If the requested page is already in the page cache, then the page cache
  6371   6375   ** implementation must return a pointer to the page buffer with its content
  6372   6376   ** intact.  If the requested page is not already in the cache, then the
  6373   6377   ** cache implementation should use the value of the createFlag
  6374   6378   ** parameter to help it determined what action to take:
  6375   6379   **
  6376   6380   ** <table border=1 width=85% align=center>
  6377         -** <tr><th> createFlag <th> Behaviour when page is not already in cache
         6381  +** <tr><th> createFlag <th> Behavior when page is not already in cache
  6378   6382   ** <tr><td> 0 <td> Do not allocate a new page.  Return NULL.
  6379   6383   ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.
  6380   6384   **                 Otherwise return NULL.
  6381   6385   ** <tr><td> 2 <td> Make every effort to allocate a new page.  Only return
  6382   6386   **                 NULL if allocating a new page is effectively impossible.
  6383   6387   ** </table>
  6384   6388   **

Changes to src/tclsqlite.c.

  1045   1045     zEnd = azEnd[(rc==TCL_ERROR)*2 + (pDb->nTransaction==0)];
  1046   1046   
  1047   1047     pDb->disableAuth++;
  1048   1048     if( sqlite3_exec(pDb->db, zEnd, 0, 0, 0) ){
  1049   1049         /* This is a tricky scenario to handle. The most likely cause of an
  1050   1050         ** error is that the exec() above was an attempt to commit the 
  1051   1051         ** top-level transaction that returned SQLITE_BUSY. Or, less likely,
  1052         -      ** that an IO-error has occured. In either case, throw a Tcl exception
         1052  +      ** that an IO-error has occurred. In either case, throw a Tcl exception
  1053   1053         ** and try to rollback the transaction.
  1054   1054         **
  1055   1055         ** But it could also be that the user executed one or more BEGIN, 
  1056   1056         ** COMMIT, SAVEPOINT, RELEASE or ROLLBACK commands that are confusing
  1057   1057         ** this method's logic. Not clear how this would be best handled.
  1058   1058         */
  1059   1059       if( rc!=TCL_ERROR ){

Changes to src/test6.c.

    83     83   **   If the IOCAP_ATOMIC flag is set, then option (3) above is 
    84     84   **   never selected.
    85     85   **
    86     86   **   If the IOCAP_ATOMIC512 flag is set, and the WriteBuffer represents
    87     87   **   an aligned write() of an integer number of 512 byte regions, then
    88     88   **   option (3) above is never selected. Instead, each 512 byte region
    89     89   **   is either correctly written or left completely untouched. Similar
    90         -**   logic governs the behaviour if any of the other ATOMICXXX flags
           90  +**   logic governs the behavior if any of the other ATOMICXXX flags
    91     91   **   is set.
    92     92   **
    93     93   **   If either the IOCAP_SAFEAPPEND or IOCAP_SEQUENTIAL flags are set
    94     94   **   and a crash is being simulated, then an entry of the write-list is
    95     95   **   selected at random. Everything in the list after the selected entry 
    96     96   **   is discarded before processing begins.
    97     97   **

Changes to src/test_config.c.

   397    397   
   398    398   #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
   399    399     Tcl_SetVar2(interp, "sqlite_options", "memorymanage", "1", TCL_GLOBAL_ONLY);
   400    400   #else
   401    401     Tcl_SetVar2(interp, "sqlite_options", "memorymanage", "0", TCL_GLOBAL_ONLY);
   402    402   #endif
   403    403   
   404         -#ifdef SQLITE_OMIT_MERGE_SORT
   405         -  Tcl_SetVar2(interp, "sqlite_options", "mergesort", "0", TCL_GLOBAL_ONLY);
   406         -#else
   407         -  Tcl_SetVar2(interp, "sqlite_options", "mergesort", "1", TCL_GLOBAL_ONLY);
   408         -#endif
          404  +Tcl_SetVar2(interp, "sqlite_options", "mergesort", "1", TCL_GLOBAL_ONLY);
   409    405   
   410    406   #ifdef SQLITE_OMIT_OR_OPTIMIZATION
   411    407     Tcl_SetVar2(interp, "sqlite_options", "or_opt", "0", TCL_GLOBAL_ONLY);
   412    408   #else
   413    409     Tcl_SetVar2(interp, "sqlite_options", "or_opt", "1", TCL_GLOBAL_ONLY);
   414    410   #endif
   415    411   

Changes to src/test_fs.c.

    95     95   
    96     96     if( argc!=4 ){
    97     97       *pzErr = sqlite3_mprintf("wrong number of arguments");
    98     98       return SQLITE_ERROR;
    99     99     }
   100    100     zTbl = argv[3];
   101    101   
   102         -  nByte = sizeof(fs_vtab) + strlen(zTbl) + 1 + strlen(zDb) + 1;
          102  +  nByte = sizeof(fs_vtab) + (int)strlen(zTbl) + 1 + (int)strlen(zDb) + 1;
   103    103     pVtab = (fs_vtab *)sqlite3MallocZero( nByte );
   104    104     if( !pVtab ) return SQLITE_NOMEM;
   105    105   
   106    106     pVtab->zTbl = (char *)&pVtab[1];
   107    107     pVtab->zDb = &pVtab->zTbl[strlen(zTbl)+1];
   108    108     pVtab->db = db;
   109    109     memcpy(pVtab->zTbl, zTbl, strlen(zTbl));

Changes to src/test_multiplex.c.

    56     56   #ifndef SQLITE_CORE
    57     57     #define SQLITE_CORE 1  /* Disable the API redefinition in sqlite3ext.h */
    58     58   #endif
    59     59   #include "sqlite3ext.h"
    60     60   
    61     61   /* 
    62     62   ** These should be defined to be the same as the values in 
    63         -** sqliteInt.h.  They are defined seperately here so that
           63  +** sqliteInt.h.  They are defined separately here so that
    64     64   ** the multiplex VFS shim can be built as a loadable 
    65     65   ** module.
    66     66   */
    67     67   #define UNUSED_PARAMETER(x) (void)(x)
    68     68   #define MAX_PAGE_SIZE       0x10000
    69     69   #define DEFAULT_SECTOR_SIZE 0x1000
    70     70   

Changes to src/test_regexp.c.

   184    184     int c = RE_EOF+1;
   185    185     int cPrev = 0;
   186    186     int rc = 0;
   187    187     ReInput in;
   188    188   
   189    189     in.z = zIn;
   190    190     in.i = 0;
   191         -  in.mx = nIn>=0 ? nIn : strlen((char const*)zIn);
          191  +  in.mx = nIn>=0 ? nIn : (int)strlen((char const*)zIn);
   192    192   
   193    193     /* Look for the initial prefix match, if there is one. */
   194    194     if( pRe->nInit ){
   195    195       unsigned char x = pRe->zInit[0];
   196    196       while( in.i+pRe->nInit<=in.mx 
   197    197        && (zIn[in.i]!=x ||
   198    198            strncmp((const char*)zIn+in.i, (const char*)pRe->zInit, pRe->nInit)!=0)
................................................................................
   624    624     if( zIn[0]=='^' ){
   625    625       zIn++;
   626    626     }else{
   627    627       re_append(pRe, RE_OP_ANYSTAR, 0);
   628    628     }
   629    629     pRe->sIn.z = (unsigned char*)zIn;
   630    630     pRe->sIn.i = 0;
   631         -  pRe->sIn.mx = strlen(zIn);
          631  +  pRe->sIn.mx = (int)strlen(zIn);
   632    632     zErr = re_subcompile_re(pRe);
   633    633     if( zErr ){
   634    634       re_free(pRe);
   635    635       return zErr;
   636    636     }
   637    637     if( rePeek(pRe)=='$' && pRe->sIn.i+1>=pRe->sIn.mx ){
   638    638       re_append(pRe, RE_OP_MATCH, RE_EOF);

Changes to src/test_sqllog.c.

    28     28   **
    29     29   **   At runtime, logging is enabled by setting environment variable
    30     30   **   SQLITE_SQLLOG_DIR to the name of a directory in which to store logged 
    31     31   **   data. The directory must already exist.
    32     32   **
    33     33   **   Usually, if the application opens the same database file more than once
    34     34   **   (either by attaching it or by using more than one database handle), only
    35         -**   a single copy is made. This behaviour may be overridden (so that a 
           35  +**   a single copy is made. This behavior may be overridden (so that a 
    36     36   **   separate copy is taken each time the database file is opened or attached)
    37     37   **   by setting the environment variable SQLITE_SQLLOG_REUSE_FILES to 0.
    38     38   **
    39     39   ** OUTPUT:
    40     40   **
    41     41   **   The SQLITE_SQLLOG_DIR is populated with three types of files:
    42     42   **

Changes to src/update.c.

   454    454       sqlite3VdbeAddOp2(v, OP_Affinity, regNew, pTab->nCol);
   455    455       sqlite3TableAffinityStr(v, pTab);
   456    456       sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, 
   457    457           TRIGGER_BEFORE, pTab, regOldRowid, onError, addr);
   458    458   
   459    459       /* The row-trigger may have deleted the row being updated. In this
   460    460       ** case, jump to the next row. No updates or AFTER triggers are 
   461         -    ** required. This behaviour - what happens when the row being updated
          461  +    ** required. This behavior - what happens when the row being updated
   462    462       ** is deleted or renamed by a BEFORE trigger - is left undefined in the
   463    463       ** documentation.
   464    464       */
   465    465       sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid);
   466    466   
   467    467       /* If it did not delete it, the row-trigger may still have modified 
   468    468       ** some of the columns of the row being updated. Load the values for 

Changes to src/util.c.

   257    257   **
   258    258   ** If some prefix of the input string is a valid number, this routine
   259    259   ** returns FALSE but it still converts the prefix and writes the result
   260    260   ** into *pResult.
   261    261   */
   262    262   int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){
   263    263   #ifndef SQLITE_OMIT_FLOATING_POINT
   264         -  int incr = (enc==SQLITE_UTF8?1:2);
          264  +  int incr;
   265    265     const char *zEnd = z + length;
   266    266     /* sign * significand * (10 ^ (esign * exponent)) */
   267    267     int sign = 1;    /* sign of significand */
   268    268     i64 s = 0;       /* significand */
   269    269     int d = 0;       /* adjust exponent for shifting decimal point */
   270    270     int esign = 1;   /* sign of exponent */
   271    271     int e = 0;       /* exponent */
   272    272     int eValid = 1;  /* True exponent is either not used or is well-formed */
   273    273     double result;
   274    274     int nDigits = 0;
          275  +  int nonNum = 0;
   275    276   
          277  +  assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
   276    278     *pResult = 0.0;   /* Default return value, in case of an error */
   277    279   
   278         -  if( enc==SQLITE_UTF16BE ) z++;
          280  +  if( enc==SQLITE_UTF8 ){
          281  +    incr = 1;
          282  +  }else{
          283  +    int i;
          284  +    incr = 2;
          285  +    assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
          286  +    for(i=3-enc; i<length && z[i]==0; i+=2){}
          287  +    nonNum = i<length;
          288  +    zEnd = z+i+enc-3;
          289  +    z += (enc&1);
          290  +  }
   279    291   
   280    292     /* skip leading spaces */
   281    293     while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;
   282    294     if( z>=zEnd ) return 0;
   283    295   
   284    296     /* get sign of significand */
   285    297     if( *z=='-' ){
................................................................................
   404    416       }
   405    417     }
   406    418   
   407    419     /* store the result */
   408    420     *pResult = result;
   409    421   
   410    422     /* return true if number and no extra non-whitespace chracters after */
   411         -  return z>=zEnd && nDigits>0 && eValid;
          423  +  return z>=zEnd && nDigits>0 && eValid && nonNum==0;
   412    424   #else
   413    425     return !sqlite3Atoi64(z, pResult, length, enc);
   414    426   #endif /* SQLITE_OMIT_FLOATING_POINT */
   415    427   }
   416    428   
   417    429   /*
   418    430   ** Compare the 19-character string zNum against the text representation
................................................................................
   453    465   ** integer, then write that value into *pNum and return 0.
   454    466   **
   455    467   ** If zNum is exactly 9223372036854665808, return 2.  This special
   456    468   ** case is broken out because while 9223372036854665808 cannot be a 
   457    469   ** signed 64-bit integer, its negative -9223372036854665808 can be.
   458    470   **
   459    471   ** If zNum is too big for a 64-bit integer and is not
   460         -** 9223372036854665808 then return 1.
          472  +** 9223372036854665808  or if zNum contains any non-numeric text,
          473  +** then return 1.
   461    474   **
   462    475   ** length is the number of bytes in the string (bytes, not characters).
   463    476   ** The string is not necessarily zero-terminated.  The encoding is
   464    477   ** given by enc.
   465    478   */
   466    479   int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){
   467         -  int incr = (enc==SQLITE_UTF8?1:2);
          480  +  int incr;
   468    481     u64 u = 0;
   469    482     int neg = 0; /* assume positive */
   470    483     int i;
   471    484     int c = 0;
          485  +  int nonNum = 0;
   472    486     const char *zStart;
   473    487     const char *zEnd = zNum + length;
   474         -  if( enc==SQLITE_UTF16BE ) zNum++;
          488  +  assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
          489  +  if( enc==SQLITE_UTF8 ){
          490  +    incr = 1;
          491  +  }else{
          492  +    incr = 2;
          493  +    assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
          494  +    for(i=3-enc; i<length && zNum[i]==0; i+=2){}
          495  +    nonNum = i<length;
          496  +    zEnd = zNum+i+enc-3;
          497  +    zNum += (enc&1);
          498  +  }
   475    499     while( zNum<zEnd && sqlite3Isspace(*zNum) ) zNum+=incr;
   476    500     if( zNum<zEnd ){
   477    501       if( *zNum=='-' ){
   478    502         neg = 1;
   479    503         zNum+=incr;
   480    504       }else if( *zNum=='+' ){
   481    505         zNum+=incr;
................................................................................
   492    516       *pNum = -(i64)u;
   493    517     }else{
   494    518       *pNum = (i64)u;
   495    519     }
   496    520     testcase( i==18 );
   497    521     testcase( i==19 );
   498    522     testcase( i==20 );
   499         -  if( (c!=0 && &zNum[i]<zEnd) || (i==0 && zStart==zNum) || i>19*incr ){
          523  +  if( (c+nonNum!=0 && &zNum[i]<zEnd) || (i==0 && zStart==zNum) || i>19*incr ){
   500    524       /* zNum is empty or contains non-numeric text or is longer
   501    525       ** than 19 digits (thus guaranteeing that it is too large) */
   502    526       return 1;
   503    527     }else if( i<19*incr ){
   504    528       /* Less than 19 digits, so we know that it fits in 64 bits */
   505    529       assert( u<=LARGEST_INT64 );
   506    530       return 0;

Changes to src/vdbe.c.

   158    158   ** converts an MEM_Ephem string into an MEM_Dyn string.
   159    159   */
   160    160   #define Deephemeralize(P) \
   161    161      if( ((P)->flags&MEM_Ephem)!=0 \
   162    162          && sqlite3VdbeMemMakeWriteable(P) ){ goto no_mem;}
   163    163   
   164    164   /* Return true if the cursor was opened using the OP_OpenSorter opcode. */
   165         -#ifdef SQLITE_OMIT_MERGE_SORT
   166         -# define isSorter(x) 0
   167         -#else
   168    165   # define isSorter(x) ((x)->pSorter!=0)
   169         -#endif
   170    166   
   171    167   /*
   172    168   ** Argument pMem points at a register that will be passed to a
   173    169   ** user-defined function or returned to the user as the result of a query.
   174    170   ** This routine sets the pMem->type variable used by the sqlite3_value_*() 
   175    171   ** routines.
   176    172   */
................................................................................
  3327   3323   ** This opcode works like OP_OpenEphemeral except that it opens
  3328   3324   ** a transient index that is specifically designed to sort large
  3329   3325   ** tables using an external merge-sort algorithm.
  3330   3326   */
  3331   3327   case OP_SorterOpen: {
  3332   3328     VdbeCursor *pCx;
  3333   3329   
  3334         -#ifndef SQLITE_OMIT_MERGE_SORT
  3335   3330     pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, 1);
  3336   3331     if( pCx==0 ) goto no_mem;
  3337   3332     pCx->pKeyInfo = pOp->p4.pKeyInfo;
  3338   3333     pCx->pKeyInfo->enc = ENC(p->db);
  3339   3334     pCx->isSorter = 1;
  3340   3335     rc = sqlite3VdbeSorterInit(db, pCx);
  3341         -#else
  3342         -  pOp->opcode = OP_OpenEphemeral;
  3343         -  pc--;
  3344         -#endif
  3345   3336     break;
  3346   3337   }
  3347   3338   
  3348   3339   /* Opcode: OpenPseudo P1 P2 P3 * P5
  3349   3340   **
  3350   3341   ** Open a new cursor that points to a fake table that contains a single
  3351   3342   ** row of data.  The content of that one row in the content of memory
................................................................................
  4262   4253   /* Opcode: SorterData P1 P2 * * *
  4263   4254   **
  4264   4255   ** Write into register P2 the current sorter data for sorter cursor P1.
  4265   4256   */
  4266   4257   case OP_SorterData: {
  4267   4258     VdbeCursor *pC;
  4268   4259   
  4269         -#ifndef SQLITE_OMIT_MERGE_SORT
  4270   4260     pOut = &aMem[pOp->p2];
  4271   4261     pC = p->apCsr[pOp->p1];
  4272   4262     assert( pC->isSorter );
  4273   4263     rc = sqlite3VdbeSorterRowkey(pC, pOut);
  4274         -#else
  4275         -  pOp->opcode = OP_RowKey;
  4276         -  pc--;
  4277         -#endif
  4278   4264     break;
  4279   4265   }
  4280   4266   
  4281   4267   /* Opcode: RowData P1 P2 * * *
  4282   4268   **
  4283   4269   ** Write into register P2 the complete row data for cursor P1.
  4284   4270   ** There is no interpretation of the data.  
................................................................................
  4469   4455   ** then rewinding that index and playing it back from beginning to
  4470   4456   ** end.  We use the OP_Sort opcode instead of OP_Rewind to do the
  4471   4457   ** rewinding so that the global variable will be incremented and
  4472   4458   ** regression tests can determine whether or not the optimizer is
  4473   4459   ** correctly optimizing out sorts.
  4474   4460   */
  4475   4461   case OP_SorterSort:    /* jump */
  4476         -#ifdef SQLITE_OMIT_MERGE_SORT
  4477         -  pOp->opcode = OP_Sort;
  4478         -#endif
  4479   4462   case OP_Sort: {        /* jump */
  4480   4463   #ifdef SQLITE_TEST
  4481   4464     sqlite3_sort_count++;
  4482   4465     sqlite3_search_count--;
  4483   4466   #endif
  4484   4467     p->aCounter[SQLITE_STMTSTATUS_SORT-1]++;
  4485   4468     /* Fall through into OP_Rewind */
................................................................................
  4550   4533   ** P4 is always of type P4_ADVANCE. The function pointer points to
  4551   4534   ** sqlite3BtreePrevious().
  4552   4535   **
  4553   4536   ** If P5 is positive and the jump is taken, then event counter
  4554   4537   ** number P5-1 in the prepared statement is incremented.
  4555   4538   */
  4556   4539   case OP_SorterNext:    /* jump */
  4557         -#ifdef SQLITE_OMIT_MERGE_SORT
  4558         -  pOp->opcode = OP_Next;
  4559         -#endif
  4560   4540   case OP_Prev:          /* jump */
  4561   4541   case OP_Next: {        /* jump */
  4562   4542     VdbeCursor *pC;
  4563   4543     int res;
  4564   4544   
  4565   4545     CHECK_FOR_INTERRUPT;
  4566   4546     assert( pOp->p1>=0 && pOp->p1<p->nCursor );
................................................................................
  4603   4583   ** P3 is a flag that provides a hint to the b-tree layer that this
  4604   4584   ** insert is likely to be an append.
  4605   4585   **
  4606   4586   ** This instruction only works for indices.  The equivalent instruction
  4607   4587   ** for tables is OP_Insert.
  4608   4588   */
  4609   4589   case OP_SorterInsert:       /* in2 */
  4610         -#ifdef SQLITE_OMIT_MERGE_SORT
  4611         -  pOp->opcode = OP_IdxInsert;
  4612         -#endif
  4613   4590   case OP_IdxInsert: {        /* in2 */
  4614   4591     VdbeCursor *pC;
  4615   4592     BtCursor *pCrsr;
  4616   4593     int nKey;
  4617   4594     const char *zKey;
  4618   4595   
  4619   4596     assert( pOp->p1>=0 && pOp->p1<p->nCursor );
................................................................................
  5832   5809     assert(pVtab && pModule);
  5833   5810     rc = pModule->xOpen(pVtab, &pVtabCursor);
  5834   5811     importVtabErrMsg(p, pVtab);
  5835   5812     if( SQLITE_OK==rc ){
  5836   5813       /* Initialize sqlite3_vtab_cursor base class */
  5837   5814       pVtabCursor->pVtab = pVtab;
  5838   5815   
  5839         -    /* Initialise vdbe cursor object */
         5816  +    /* Initialize vdbe cursor object */
  5840   5817       pCur = allocateCursor(p, pOp->p1, 0, -1, 0);
  5841   5818       if( pCur ){
  5842   5819         pCur->pVtabCursor = pVtabCursor;
  5843   5820         pCur->pModule = pVtabCursor->pVtab->pModule;
  5844   5821       }else{
  5845   5822         db->mallocFailed = 1;
  5846   5823         pModule->xClose(pVtabCursor);

Changes to src/vdbeInt.h.

   446    446   void sqlite3VdbeFrameDelete(VdbeFrame*);
   447    447   int sqlite3VdbeFrameRestore(VdbeFrame *);
   448    448   void sqlite3VdbeMemStoreType(Mem *pMem);
   449    449   void sqlite3VdbePreUpdateHook(
   450    450       Vdbe *, VdbeCursor *, int, const char*, Table *, i64, int);
   451    451   int sqlite3VdbeTransferError(Vdbe *p);
   452    452   
   453         -#ifdef SQLITE_OMIT_MERGE_SORT
   454         -# define sqlite3VdbeSorterInit(Y,Z)      SQLITE_OK
   455         -# define sqlite3VdbeSorterWrite(X,Y,Z)   SQLITE_OK
   456         -# define sqlite3VdbeSorterClose(Y,Z)
   457         -# define sqlite3VdbeSorterRowkey(Y,Z)    SQLITE_OK
   458         -# define sqlite3VdbeSorterRewind(X,Y,Z)  SQLITE_OK
   459         -# define sqlite3VdbeSorterNext(X,Y,Z)    SQLITE_OK
   460         -# define sqlite3VdbeSorterCompare(X,Y,Z) SQLITE_OK
   461         -#else
   462    453   int sqlite3VdbeSorterInit(sqlite3 *, VdbeCursor *);
   463    454   void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);
   464    455   int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
   465    456   int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *, int *);
   466    457   int sqlite3VdbeSorterRewind(sqlite3 *, const VdbeCursor *, int *);
   467    458   int sqlite3VdbeSorterWrite(sqlite3 *, const VdbeCursor *, Mem *);
   468    459   int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int *);
   469         -#endif
   470    460   
   471    461   #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0
   472    462     void sqlite3VdbeEnter(Vdbe*);
   473    463     void sqlite3VdbeLeave(Vdbe*);
   474    464   #else
   475    465   # define sqlite3VdbeEnter(X)
   476    466   # define sqlite3VdbeLeave(X)

Changes to src/vdbeapi.c.

   441    441     */
   442    442     assert( rc==SQLITE_ROW  || rc==SQLITE_DONE   || rc==SQLITE_ERROR 
   443    443          || rc==SQLITE_BUSY || rc==SQLITE_MISUSE
   444    444     );
   445    445     assert( p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE );
   446    446     if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){
   447    447       /* If this statement was prepared using sqlite3_prepare_v2(), and an
   448         -    ** error has occured, then return the error code in p->rc to the
          448  +    ** error has occurred, then return the error code in p->rc to the
   449    449       ** caller. Set the error code in the database handle to the same value.
   450    450       */ 
   451    451       rc = sqlite3VdbeTransferError(p);
   452    452     }
   453    453     return (rc&db->errMask);
   454    454   }
   455    455   

Changes to src/vdbeaux.c.

   372    372       ){
   373    373         hasAbort = 1;
   374    374         break;
   375    375       }
   376    376     }
   377    377     sqlite3DbFree(v->db, sIter.apSub);
   378    378   
   379         -  /* Return true if hasAbort==mayAbort. Or if a malloc failure occured.
          379  +  /* Return true if hasAbort==mayAbort. Or if a malloc failure occurred.
   380    380     ** If malloc failed, then the while() loop above may not have iterated
   381    381     ** through all opcodes and hasAbort may be set incorrectly. Return
   382    382     ** true for this case to prevent the assert() in the callers frame
   383    383     ** from failing.  */
   384    384     return ( v->db->mallocFailed || hasAbort==mayAbort );
   385    385   }
   386    386   #endif /* SQLITE_DEBUG - the sqlite3AssertMayAbort() function */
................................................................................
  2004   2004   */
  2005   2005   int sqlite3VdbeCloseStatement(Vdbe *p, int eOp){
  2006   2006     sqlite3 *const db = p->db;
  2007   2007     int rc = SQLITE_OK;
  2008   2008   
  2009   2009     /* If p->iStatement is greater than zero, then this Vdbe opened a 
  2010   2010     ** statement transaction that should be closed here. The only exception
  2011         -  ** is that an IO error may have occured, causing an emergency rollback.
         2011  +  ** is that an IO error may have occurred, causing an emergency rollback.
  2012   2012     ** In this case (db->nStatement==0), and there is nothing to do.
  2013   2013     */
  2014   2014     if( db->nStatement && p->iStatement ){
  2015   2015       int i;
  2016   2016       const int iSavepoint = p->iStatement-1;
  2017   2017   
  2018   2018       assert( eOp==SAVEPOINT_ROLLBACK || eOp==SAVEPOINT_RELEASE);
................................................................................
  2140   2140         /* If the query was read-only and the error code is SQLITE_INTERRUPT, 
  2141   2141         ** no rollback is necessary. Otherwise, at least a savepoint 
  2142   2142         ** transaction must be rolled back to restore the database to a 
  2143   2143         ** consistent state.
  2144   2144         **
  2145   2145         ** Even if the statement is read-only, it is important to perform
  2146   2146         ** a statement or transaction rollback operation. If the error 
  2147         -      ** occured while writing to the journal, sub-journal or database
         2147  +      ** occurred while writing to the journal, sub-journal or database
  2148   2148         ** file as part of an effort to free up cache space (see function
  2149   2149         ** pagerStress() in pager.c), the rollback is required to restore 
  2150   2150         ** the pager to a consistent state.
  2151   2151         */
  2152   2152         if( !p->readOnly || mrc!=SQLITE_INTERRUPT ){
  2153   2153           if( (mrc==SQLITE_NOMEM || mrc==SQLITE_FULL) && p->usesStmtJournal ){
  2154   2154             eStatementOp = SAVEPOINT_ROLLBACK;
................................................................................
  2554   2554   ** 'serial-type' and a blob of data. The serial type is an 8-byte unsigned
  2555   2555   ** integer, stored as a varint.
  2556   2556   **
  2557   2557   ** In an SQLite index record, the serial type is stored directly before
  2558   2558   ** the blob of data that it corresponds to. In a table record, all serial
  2559   2559   ** types are stored at the start of the record, and the blobs of data at
  2560   2560   ** the end. Hence these functions allow the caller to handle the
  2561         -** serial-type and data blob seperately.
         2561  +** serial-type and data blob separately.
  2562   2562   **
  2563   2563   ** The following table describes the various storage classes for data:
  2564   2564   **
  2565   2565   **   serial type        bytes of data      type
  2566   2566   **   --------------     ---------------    ---------------
  2567   2567   **      0                     0            NULL
  2568   2568   **      1                     1            signed integer

Changes to src/vdbesort.c.

    14     14   ** example, by CREATE INDEX statements on tables too large to fit in main
    15     15   ** memory).
    16     16   */
    17     17   
    18     18   #include "sqliteInt.h"
    19     19   #include "vdbeInt.h"
    20     20   
    21         -#ifndef SQLITE_OMIT_MERGE_SORT
    22     21   
    23     22   typedef struct VdbeSorterIter VdbeSorterIter;
    24     23   typedef struct SorterRecord SorterRecord;
    25     24   typedef struct FileWriter FileWriter;
    26     25   
    27     26   /*
    28     27   ** NOTES ON DATA STRUCTURE USED FOR N-WAY MERGES:
................................................................................
  1033   1032     VdbeSorter *pSorter = pCsr->pSorter;
  1034   1033     void *pKey; int nKey;           /* Sorter key to compare pVal with */
  1035   1034   
  1036   1035     pKey = vdbeSorterRowkey(pSorter, &nKey);
  1037   1036     vdbeSorterCompare(pCsr, 1, pVal->z, pVal->n, pKey, nKey, pRes);
  1038   1037     return SQLITE_OK;
  1039   1038   }
  1040         -
  1041         -#endif /* #ifndef SQLITE_OMIT_MERGE_SORT */

Changes to src/where.c.

   258    258   #define WHERE_BTM_LIMIT    0x00200000  /* x>EXPR or x>=EXPR constraint */
   259    259   #define WHERE_BOTH_LIMIT   0x00300000  /* Both x>EXPR and x<EXPR */
   260    260   #define WHERE_IDX_ONLY     0x00400000  /* Use index only - omit table */
   261    261   #define WHERE_ORDERED      0x00800000  /* Output will appear in correct order */
   262    262   #define WHERE_REVERSE      0x01000000  /* Scan in reverse order */
   263    263   #define WHERE_UNIQUE       0x02000000  /* Selects no more than one row */
   264    264   #define WHERE_ALL_UNIQUE   0x04000000  /* This and all prior have one row */
          265  +#define WHERE_OB_UNIQUE    0x00004000  /* Values in ORDER BY columns are 
          266  +                                       ** different for every output row */
   265    267   #define WHERE_VIRTUALTABLE 0x08000000  /* Use virtual-table processing */
   266    268   #define WHERE_MULTI_OR     0x10000000  /* OR using multiple indices */
   267    269   #define WHERE_TEMP_INDEX   0x20000000  /* Uses an ephemeral index */
   268    270   #define WHERE_DISTINCT     0x40000000  /* Correct order for DISTINCT */
   269    271   #define WHERE_COVER_SCAN   0x80000000  /* Full scan of a covering index */
   270    272   
   271    273   /*
................................................................................
   558    560   */
   559    561   #define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;}
   560    562   
   561    563   /*
   562    564   ** Commute a comparison operator.  Expressions of the form "X op Y"
   563    565   ** are converted into "Y op X".
   564    566   **
   565         -** If left/right precendence rules come into play when determining the
          567  +** If left/right precedence rules come into play when determining the
   566    568   ** collating
   567    569   ** side of the comparison, it remains associated with the same side after
   568    570   ** the commutation. So "Y collate NOCASE op X" becomes 
   569    571   ** "X op Y". This is because any collation sequence on
   570    572   ** the left hand side of a comparison overrides any collation sequence 
   571    573   ** attached to the right. For the same reason the EP_Collate flag
   572    574   ** is not commuted.
................................................................................
  2899   2901   ** The *pbRev value is set to 0 order 1 depending on whether or not
  2900   2902   ** pIdx should be run in the forward order or in reverse order.
  2901   2903   */
  2902   2904   static int isSortingIndex(
  2903   2905     WhereBestIdx *p,    /* Best index search context */
  2904   2906     Index *pIdx,        /* The index we are testing */
  2905   2907     int base,           /* Cursor number for the table to be sorted */
  2906         -  int *pbRev          /* Set to 1 for reverse-order scan of pIdx */
         2908  +  int *pbRev,         /* Set to 1 for reverse-order scan of pIdx */
         2909  +  int *pbObUnique     /* ORDER BY column values will different in every row */
  2907   2910   ){
  2908   2911     int i;                        /* Number of pIdx terms used */
  2909   2912     int j;                        /* Number of ORDER BY terms satisfied */
  2910   2913     int sortOrder = 2;            /* 0: forward.  1: backward.  2: unknown */
  2911   2914     int nTerm;                    /* Number of ORDER BY terms */
  2912   2915     struct ExprList_item *pOBItem;/* A term of the ORDER BY clause */
  2913   2916     Table *pTab = pIdx->pTable;   /* Table that owns index pIdx */
  2914   2917     ExprList *pOrderBy;           /* The ORDER BY clause */
  2915   2918     Parse *pParse = p->pParse;    /* Parser context */
  2916   2919     sqlite3 *db = pParse->db;     /* Database connection */
  2917   2920     int nPriorSat;                /* ORDER BY terms satisfied by outer loops */
  2918   2921     int seenRowid = 0;            /* True if an ORDER BY rowid term is seen */
  2919   2922     int uniqueNotNull;            /* pIdx is UNIQUE with all terms are NOT NULL */
         2923  +  int outerObUnique;            /* Outer loops generate different values in
         2924  +                                ** every row for the ORDER BY columns */
  2920   2925   
  2921   2926     if( p->i==0 ){
  2922   2927       nPriorSat = 0;
         2928  +    outerObUnique = 1;
  2923   2929     }else{
         2930  +    u32 wsFlags = p->aLevel[p->i-1].plan.wsFlags;
  2924   2931       nPriorSat = p->aLevel[p->i-1].plan.nOBSat;
  2925         -    if( (p->aLevel[p->i-1].plan.wsFlags & WHERE_ORDERED)==0 ){
         2932  +    if( (wsFlags & WHERE_ORDERED)==0 ){
  2926   2933         /* This loop cannot be ordered unless the next outer loop is
  2927   2934         ** also ordered */
  2928   2935         return nPriorSat;
  2929   2936       }
  2930   2937       if( OptimizationDisabled(db, SQLITE_OrderByIdxJoin) ){
  2931   2938         /* Only look at the outer-most loop if the OrderByIdxJoin
  2932   2939         ** optimization is disabled */
  2933   2940         return nPriorSat;
  2934   2941       }
         2942  +    testcase( wsFlags & WHERE_OB_UNIQUE );
         2943  +    testcase( wsFlags & WHERE_ALL_UNIQUE );
         2944  +    outerObUnique = (wsFlags & (WHERE_OB_UNIQUE|WHERE_ALL_UNIQUE))!=0;
  2935   2945     }
  2936   2946     pOrderBy = p->pOrderBy;
  2937   2947     assert( pOrderBy!=0 );
  2938   2948     if( pIdx->bUnordered ){
  2939   2949       /* Hash indices (indicated by the "unordered" tag on sqlite_stat1) cannot
  2940   2950       ** be used for sorting */
  2941   2951       return nPriorSat;
................................................................................
  3069   3079       }else if( pTab->aCol[iColumn].notNull==0 && isEq!=1 ){
  3070   3080         testcase( isEq==0 );
  3071   3081         testcase( isEq==2 );
  3072   3082         testcase( isEq==3 );
  3073   3083         uniqueNotNull = 0;
  3074   3084       }
  3075   3085     }
         3086  +  if( seenRowid ){
         3087  +    uniqueNotNull = 1;
         3088  +  }else if( uniqueNotNull==0 || i<pIdx->nColumn ){
         3089  +    uniqueNotNull = 0;
         3090  +  }
  3076   3091   
  3077   3092     /* If we have not found at least one ORDER BY term that matches the
  3078   3093     ** index, then show no progress. */
  3079   3094     if( pOBItem==&pOrderBy->a[nPriorSat] ) return nPriorSat;
         3095  +
         3096  +  /* Either the outer queries must generate rows where there are no two
         3097  +  ** rows with the same values in all ORDER BY columns, or else this
         3098  +  ** loop must generate just a single row of output.  Example:  Suppose
         3099  +  ** the outer loops generate A=1 and A=1, and this loop generates B=3
         3100  +  ** and B=4.  Then without the following test, ORDER BY A,B would 
         3101  +  ** generate the wrong order output: 1,3 1,4 1,3 1,4
         3102  +  */
         3103  +  if( outerObUnique==0 && uniqueNotNull==0 ) return nPriorSat;
         3104  +  *pbObUnique = uniqueNotNull;
  3080   3105   
  3081   3106     /* Return the necessary scan order back to the caller */
  3082   3107     *pbRev = sortOrder & 1;
  3083   3108   
  3084   3109     /* If there was an "ORDER BY rowid" term that matched, or it is only
  3085   3110     ** possible for a single row from this table to match, then skip over
  3086   3111     ** any additional ORDER BY terms dealing with this table.
  3087   3112     */
  3088         -  if( seenRowid || (uniqueNotNull && i>=pIdx->nColumn) ){
         3113  +  if( uniqueNotNull ){
  3089   3114       /* Advance j over additional ORDER BY terms associated with base */
  3090   3115       WhereMaskSet *pMS = p->pWC->pMaskSet;
  3091   3116       Bitmask m = ~getMask(pMS, base);
  3092   3117       while( j<nTerm && (exprTableUsage(pMS, pOrderBy->a[j].pExpr)&m)==0 ){
  3093   3118         j++;
  3094   3119       }
  3095   3120     }
................................................................................
  3365   3390       /* If there is an ORDER BY clause and the index being considered will
  3366   3391       ** naturally scan rows in the required order, set the appropriate flags
  3367   3392       ** in pc.plan.wsFlags. Otherwise, if there is an ORDER BY clause but
  3368   3393       ** the index will scan rows in a different order, set the bSort
  3369   3394       ** variable.  */
  3370   3395       if( bSort && (pSrc->jointype & JT_LEFT)==0 ){
  3371   3396         int bRev = 2;
  3372         -      WHERETRACE(("      --> before isSortingIndex: nPriorSat=%d\n",nPriorSat));
  3373         -      pc.plan.nOBSat = isSortingIndex(p, pProbe, iCur, &bRev);
  3374         -      WHERETRACE(("      --> after  isSortingIndex: bRev=%d nOBSat=%d\n",
  3375         -                  bRev, pc.plan.nOBSat));
         3397  +      int bObUnique = 0;
         3398  +      WHERETRACE(("      --> before isSortIndex: nPriorSat=%d\n",nPriorSat));
         3399  +      pc.plan.nOBSat = isSortingIndex(p, pProbe, iCur, &bRev, &bObUnique);
         3400  +      WHERETRACE(("      --> after  isSortIndex: bRev=%d bObU=%d nOBSat=%d\n",
         3401  +                  bRev, bObUnique, pc.plan.nOBSat));
  3376   3402         if( nPriorSat<pc.plan.nOBSat || (pc.plan.wsFlags & WHERE_ALL_UNIQUE)!=0 ){
  3377   3403           pc.plan.wsFlags |= WHERE_ORDERED;
         3404  +        if( bObUnique ) pc.plan.wsFlags |= WHERE_OB_UNIQUE;
  3378   3405         }
  3379   3406         if( nOrderBy==pc.plan.nOBSat ){
  3380   3407           bSort = 0;
  3381   3408           pc.plan.wsFlags |= WHERE_ROWID_RANGE|WHERE_COLUMN_RANGE;
  3382   3409         }
  3383   3410         if( bRev & 1 ) pc.plan.wsFlags |= WHERE_REVERSE;
  3384   3411       }
................................................................................
  3464   3491       ** on one page and hence more pages have to be fetched.
  3465   3492       **
  3466   3493       ** The ANALYZE command and the sqlite_stat1 and sqlite_stat3 tables do
  3467   3494       ** not give us data on the relative sizes of table and index records.
  3468   3495       ** So this computation assumes table records are about twice as big
  3469   3496       ** as index records
  3470   3497       */
  3471         -    if( (pc.plan.wsFlags&~(WHERE_REVERSE|WHERE_ORDERED))==WHERE_IDX_ONLY
         3498  +    if( (pc.plan.wsFlags&~(WHERE_REVERSE|WHERE_ORDERED|WHERE_OB_UNIQUE))
         3499  +                                                              ==WHERE_IDX_ONLY
  3472   3500        && (pWC->wctrlFlags & WHERE_ONEPASS_DESIRED)==0
  3473   3501        && sqlite3GlobalConfig.bUseCis
  3474   3502        && OptimizationEnabled(pParse->db, SQLITE_CoverIdxScan)
  3475   3503       ){
  3476   3504         /* This index is not useful for indexing, but it is a covering index.
  3477   3505         ** A full-scan of the index might be a little faster than a full-scan
  3478   3506         ** of the table, so give this case a cost slightly less than a table
................................................................................
  3624   3652       wsFlagMask = ~(WHERE_ROWID_EQ|WHERE_ROWID_RANGE);
  3625   3653       eqTermMask = idxEqTermMask;
  3626   3654     }
  3627   3655   
  3628   3656     /* If there is no ORDER BY clause and the SQLITE_ReverseOrder flag
  3629   3657     ** is set, then reverse the order that the index will be scanned
  3630   3658     ** in. This is used for application testing, to help find cases
  3631         -  ** where application behaviour depends on the (undefined) order that
         3659  +  ** where application behavior depends on the (undefined) order that
  3632   3660     ** SQLite outputs rows in in the absence of an ORDER BY clause.  */
  3633   3661     if( !p->pOrderBy && pParse->db->flags & SQLITE_ReverseOrder ){
  3634   3662       p->cost.plan.wsFlags |= WHERE_REVERSE;
  3635   3663     }
  3636   3664   
  3637   3665     assert( p->pOrderBy || (p->cost.plan.wsFlags&WHERE_ORDERED)==0 );
  3638   3666     assert( p->cost.plan.u.pIdx==0 || (p->cost.plan.wsFlags&WHERE_ROWID_EQ)==0 );

Changes to test/backup_ioerr.test.

   111    111   #        from the next call to backup_step() (in step 5 of this test
   112    112   #        procedure).
   113    113   #
   114    114   #   5) Step the backup process to finish the backup. If an IO error is 
   115    115   #      reported, then the backup process is concluded with a call to 
   116    116   #      backup_finish().
   117    117   #
   118         -#      Test that if an IO error occurs, or if one occured while updating
          118  +#      Test that if an IO error occurs, or if one occurred while updating
   119    119   #      the backup database during step 4, then the conditions listed
   120    120   #      under step 3 are all true.
   121    121   #
   122    122   #   6) Finish the backup process.
   123    123   #
   124    124   #   * If the backup succeeds (backup_finish() returns SQLITE_OK), then
   125    125   #     the contents of the backup database should match that of the
................................................................................
   210    210       expr {$rc eq "SQLITE_OK"}
   211    211     } {1}
   212    212   
   213    213     # Step 4: Write to the source database.
   214    214     set rc [catchsql { UPDATE t1 SET b = randstr(1000,1000) WHERE a < 50 } sdb]
   215    215   
   216    216     if {[lindex $rc 0] && $::sqlite_io_error_persist==0} {
   217         -    # The IO error occured while updating the source database. In this
          217  +    # The IO error occurred while updating the source database. In this
   218    218       # case the backup should be able to continue.
   219    219       set rc [B step 5000]
   220    220       if { $rc != "SQLITE_IOERR_UNLOCK" } {
   221    221         do_test backup_ioerr-$iTest.$iError.7 {
   222    222           list [B step 5000] [B finish]
   223    223         } {SQLITE_DONE SQLITE_OK}
   224    224   

Changes to test/cache.test.

    42     42   } {2}
    43     43   
    44     44   # At one point, repeatedly locking and unlocking the cache was causing
    45     45   # a resource leak of one page per repetition. The page wasn't actually
    46     46   # leaked, but would not be reused until the pager-cache was full (i.e. 
    47     47   # 2000 pages by default).
    48     48   #
    49         -# This tests that once the pager-cache is initialised, it can be locked
           49  +# This tests that once the pager-cache is initialized, it can be locked
    50     50   # and unlocked repeatedly without internally allocating any new pages.
    51     51   #
    52     52   set cache_size [pager_cache_size db]
    53     53   for {set ii 0} {$ii < 10} {incr ii} {
    54     54     do_test cache-1.3.$ii {
    55     55       execsql {SELECT * FROM abc}
    56     56       pager_cache_size db

Changes to test/collate4.test.

    56     56   #
    57     57   # These tests - collate4-1.* - check that indices are correctly
    58     58   # selected or not selected to implement ORDER BY clauses when 
    59     59   # user defined collation sequences are involved. 
    60     60   #
    61     61   # Because these tests also exercise all the different ways indices 
    62     62   # can be created, they also serve to verify that indices are correctly 
    63         -# initialised with user-defined collation sequences when they are
           63  +# initialized with user-defined collation sequences when they are
    64     64   # created.
    65     65   #
    66     66   # Tests named collate4-1.1.* use indices with a single column. Tests
    67     67   # collate4-1.2.* use indices with two columns.
    68     68   #
    69     69   do_test collate4-1.1.0 {
    70     70     execsql {

Changes to test/crash5.test.

    61     61           #
    62     62           db eval BEGIN
    63     63           sqlite3_memdebug_fail $iFail -repeat 0
    64     64           catch {db eval { CREATE UNIQUE INDEX i1 ON t1(a); }} msg
    65     65           # puts "$n $msg ac=[sqlite3_get_autocommit db]"
    66     66         
    67     67           # If the transaction is still active (it may not be if the malloc()
    68         -        # failure occured in the OS layer), write to the database. Make sure
           68  +        # failure occurred in the OS layer), write to the database. Make sure
    69     69           # page 4 is among those written.
    70     70           #
    71     71           if {![sqlite3_get_autocommit db]} {
    72     72             db eval {
    73     73               DELETE FROM t1;  -- This will put page 4 on the free list.
    74     74               INSERT INTO t1 VALUES('111111111', '2222222222', '33333333');
    75     75               INSERT INTO t1 SELECT * FROM t1;                     -- 2

Changes to test/e_createtable.test.

  1253   1253     14   "INSERT INTO t2 VALUES(NULL, NULL)"           {}
  1254   1254   }
  1255   1255   
  1256   1256   # EVIDENCE-OF: R-61866-38053 Unless the column is an INTEGER PRIMARY KEY
  1257   1257   # SQLite allows NULL values in a PRIMARY KEY column.
  1258   1258   #
  1259   1259   #     If the column is an integer primary key, attempting to insert a NULL
  1260         -#     into the column triggers the auto-increment behaviour. Attempting
         1260  +#     into the column triggers the auto-increment behavior. Attempting
  1261   1261   #     to use UPDATE to set an ipk column to a NULL value is an error.
  1262   1262   #
  1263   1263   do_createtable_tests 4.5.1 {
  1264   1264     1    "SELECT count(*) FROM t1 WHERE x IS NULL"                   3
  1265   1265     2    "SELECT count(*) FROM t2 WHERE x IS NULL"                   6
  1266   1266     3    "SELECT count(*) FROM t2 WHERE y IS NULL"                   7
  1267   1267     4    "SELECT count(*) FROM t2 WHERE x IS NULL AND y IS NULL"     2

Changes to test/e_fkey.test.

  2737   2737   } {1 {foreign key mismatch - "c2" referencing "p"}}
  2738   2738   do_test e_fkey-60.6 {
  2739   2739     execsql { DROP TABLE c2 }
  2740   2740     execsql { DELETE FROM p }
  2741   2741   } {}
  2742   2742   
  2743   2743   #-------------------------------------------------------------------------
  2744         -# Test that the special behaviours of ALTER and DROP TABLE are only
  2745         -# activated when foreign keys are enabled. Special behaviours are:
         2744  +# Test that the special behaviors of ALTER and DROP TABLE are only
         2745  +# activated when foreign keys are enabled. Special behaviors are:
  2746   2746   #
  2747   2747   #   1. ADD COLUMN not allowing a REFERENCES clause with a non-NULL 
  2748   2748   #      default value.
  2749   2749   #   2. Modifying foreign key definitions when a parent table is RENAMEd.
  2750   2750   #   3. Running an implicit DELETE FROM command as part of DROP TABLE.
  2751   2751   #
  2752   2752   # EVIDENCE-OF: R-54142-41346 The properties of the DROP TABLE and ALTER
................................................................................
  2833   2833         CREATE TABLE p(a, b, c, PRIMARY KEY(b, c));
  2834   2834         CREATE TABLE c(d, e, f, FOREIGN KEY(e, f) REFERENCES p MATCH $zMatch);
  2835   2835       "
  2836   2836     } {}
  2837   2837     do_test e_fkey-62.$zMatch.2 {
  2838   2838       execsql { INSERT INTO p VALUES(1, 2, 3)         }
  2839   2839   
  2840         -    # MATCH SIMPLE behaviour: Allow any child key that contains one or more
         2840  +    # MATCH SIMPLE behavior: Allow any child key that contains one or more
  2841   2841       # NULL value to be inserted. Non-NULL values do not have to map to any
  2842   2842       # parent key values, so long as at least one field of the child key is
  2843   2843       # NULL.
  2844   2844       execsql { INSERT INTO c VALUES('w', 2, 3)       }
  2845   2845       execsql { INSERT INTO c VALUES('x', 'x', NULL)  }
  2846   2846       execsql { INSERT INTO c VALUES('y', NULL, 'x')  }
  2847   2847       execsql { INSERT INTO c VALUES('z', NULL, NULL) }

Changes to test/e_select.test.

  1223   1223     2   "SELECT DISTINCT a FROM h1" {1 4}
  1224   1224   }
  1225   1225   
  1226   1226   # EVIDENCE-OF: R-08861-34280 If the simple SELECT is a SELECT ALL, then
  1227   1227   # the entire set of result rows are returned by the SELECT.
  1228   1228   #
  1229   1229   # EVIDENCE-OF: R-47911-02086 If neither ALL or DISTINCT are present,
  1230         -# then the behaviour is as if ALL were specified.
         1230  +# then the behavior is as if ALL were specified.
  1231   1231   #
  1232   1232   # EVIDENCE-OF: R-14442-41305 If the simple SELECT is a SELECT DISTINCT,
  1233   1233   # then duplicate rows are removed from the set of result rows before it
  1234   1234   # is returned.
  1235   1235   #
  1236   1236   #   The three testable statements above are tested by e_select-5.2.*,
  1237   1237   #   5.3.* and 5.4.* respectively.

Changes to test/e_uri.test.

   357    357   # to sqlite3_open_v2().
   358    358   #
   359    359   # EVIDENCE-OF: R-49793-28525 Setting the cache parameter to "private" is
   360    360   # equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.
   361    361   #
   362    362   # EVIDENCE-OF: R-19510-48080 If sqlite3_open_v2() is used and the
   363    363   # "cache" parameter is present in a URI filename, its value overrides
   364         -# any behaviour requested by setting SQLITE_OPEN_PRIVATECACHE or
          364  +# any behavior requested by setting SQLITE_OPEN_PRIVATECACHE or
   365    365   # SQLITE_OPEN_SHAREDCACHE flag.
   366    366   #
   367    367   set orig [sqlite3_enable_shared_cache]
   368    368   foreach {tn uri flags shared_default isshared} {
   369    369     1.1   "file:test.db"                  ""         0    0
   370    370     1.2   "file:test.db"                  ""         1    1
   371    371     1.3   "file:test.db"                  private    0    0

Changes to test/enc2.test.

    28     28   # The rough organisation of tests in this file is:
    29     29   #
    30     30   # enc2.1.*: Simple tests with a UTF-8 db.
    31     31   # enc2.2.*: Simple tests with a UTF-16LE db.
    32     32   # enc2.3.*: Simple tests with a UTF-16BE db.
    33     33   # enc2.4.*: Test that attached databases must have the same text encoding
    34     34   #           as the main database.
    35         -# enc2.5.*: Test the behaviour of the library when a collation sequence is
           35  +# enc2.5.*: Test the behavior of the library when a collation sequence is
    36     36   #           not available for the most desirable text encoding.
    37     37   # enc2.6.*: Similar test for user functions.
    38     38   # enc2.7.*: Test that the VerifyCookie opcode protects against assuming the
    39     39   #           wrong text encoding for the database.
    40     40   # enc2.8.*: Test sqlite3_complete16()
    41     41   #
    42     42   

Changes to test/fts3near.test.

   575    575     }
   576    576   } {}
   577    577   do_test fts3near-6.5 {
   578    578     execsql {
   579    579       SELECT docid FROM t1 WHERE content MATCH 'abbrev NEAR/10000 zygosis'
   580    580     }
   581    581   } {3}
          582  +
          583  +# Ticket 38b1ae018f.
          584  +#
          585  +do_execsql_test fts3near-7.1 {
          586  +  CREATE VIRTUAL TABLE x USING fts4(y,z);
          587  +  INSERT INTO x VALUES('aaa bbb ccc ddd', 'bbb ddd aaa ccc');
          588  +  SELECT * FROM x where y MATCH 'bbb NEAR/6 aaa';
          589  +} {{aaa bbb ccc ddd} {bbb ddd aaa ccc}}
          590  +
          591  +do_execsql_test fts3near-7.2 {
          592  +  CREATE VIRTUAL TABLE t2 USING fts4(a, b);
          593  +  INSERT INTO t2 VALUES('A B C', 'A D E');
          594  +  SELECT * FROM t2 where t2 MATCH 'a:A NEAR E'
          595  +} {}
   582    596   
   583    597   
   584    598   finish_test

Changes to test/incrblob.test.

   501    501       }
   502    502     } {a different invocation}
   503    503     db2 close
   504    504   }
   505    505   sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
   506    506   
   507    507   #-----------------------------------------------------------------------
   508         -# The following tests verify the behaviour of the incremental IO
          508  +# The following tests verify the behavior of the incremental IO
   509    509   # APIs in the following cases:
   510    510   #
   511    511   #     7.1 A row that containing an open blob is modified.
   512    512   #
   513    513   #     7.2 A CREATE TABLE requires that an overflow page that is part
   514    514   #         of an open blob is moved.
   515    515   #
   516    516   #     7.3 An INCREMENTAL VACUUM moves an overflow page that is part
   517    517   #         of an open blob.
   518    518   #
   519         -# In the first case above, correct behaviour is for all subsequent
          519  +# In the first case above, correct behavior is for all subsequent
   520    520   # read/write operations on the blob-handle to return SQLITE_ABORT.
   521    521   # More accurately, blob-handles are invalidated whenever the table
   522    522   # they belong to is written to.
   523    523   #
   524    524   # The second two cases have no external effect. They are testing
   525    525   # that the internal cache of overflow page numbers is correctly
   526    526   # invalidated.

Changes to test/io.test.

   203    203   # Internally, this case is handled differently to the one above. The
   204    204   # journal file is not actually created until the 'COMMIT' statement
   205    205   # is executed.
   206    206   #
   207    207   # Changed 2010-03-27:  The size of the database is now stored in 
   208    208   # bytes 28..31 and so when a page is added to the database, page 1
   209    209   # is immediately modified and the journal file immediately comes into
   210         -# existance.  To fix this test, the BEGIN is changed into a a
          210  +# existence.  To fix this test, the BEGIN is changed into a a
   211    211   # BEGIN IMMEDIATE and the INSERT is omitted.
   212    212   #
   213    213   do_test io-2.6.1 {
   214    214     execsql {
   215    215       BEGIN IMMEDIATE;
   216    216       -- INSERT INTO abc VALUES(9, randstr(1000,1000));
   217    217     }

Changes to test/malloc.test.

   838    838     CREATE TABLE t1(a, b);
   839    839     INSERT INTO t1 VALUES(1, 2);
   840    840     INSERT INTO t1 VALUES(3, 4);
   841    841   } -sqlbody {
   842    842     SELECT test_agg_errmsg16(), group_concat(a) FROM t1
   843    843   }
   844    844   
   845         -# At one point, if an OOM occured immediately after obtaining a shared lock
          845  +# At one point, if an OOM occurred immediately after obtaining a shared lock
   846    846   # on the database file, the file remained locked. This test case ensures
   847    847   # that bug has been fixed.i
   848    848   if {[db eval {PRAGMA locking_mode}]!="exclusive"} {
   849    849     do_malloc_test 37 -tclprep {
   850    850       sqlite3 db2 test.db
   851    851       execsql {
   852    852         CREATE TABLE t1(a, b);

Changes to test/malloc3.test.

   591    591           set ac [sqlite3_get_autocommit $::DB]        ;# Auto-Commit
   592    592           sqlite3_memdebug_fail $iFail -repeat 0
   593    593           set rc [catch {db eval [lindex $v 2]} msg]   ;# True error occurs
   594    594           set nac [sqlite3_get_autocommit $::DB]       ;# New Auto-Commit 
   595    595   
   596    596           if {$rc != 0 && $nac && !$ac} {
   597    597             # Before [db eval] the auto-commit flag was clear. Now it
   598         -          # is set. Since an error occured we assume this was not a
   599         -          # commit - therefore a rollback occured. Check that the
          598  +          # is set. Since an error occurred we assume this was not a
          599  +          # commit - therefore a rollback occurred. Check that the
   600    600             # rollback-hook was invoked.
   601    601             do_test malloc3-rollback_hook_count.$iterid {
   602    602               set ::rollback_hook_count
   603    603             } {1}
   604    604           }
   605    605   
   606    606           set nFail [sqlite3_memdebug_fail -1 -benigncnt nBenign]

Changes to test/notify2.test.

   146    146           sqlite3_close $::DB
   147    147           opendb
   148    148         } 
   149    149       } elseif {$rc} {
   150    150         # Hit some other kind of error. This is a malfunction.
   151    151         error $msg
   152    152       } else {
   153         -      # No error occured. Check that any SELECT statements in the transaction
          153  +      # No error occurred. Check that any SELECT statements in the transaction
   154    154         # returned "1". Otherwise, the invariant was false, indicating that
   155         -      # some malfunction has occured.
          155  +      # some malfunction has occurred.
   156    156         foreach r $msg { if {$r != 1} { puts "Invariant check failed: $msg" } }
   157    157       }
   158    158     }
   159    159   
   160    160     # Close the database connection and return 0.
   161    161     #
   162    162     sqlite3_close $::DB

Added test/numcast.test.

            1  +# 2013 March 20
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library. 
           12  +# This particular file does testing of casting strings into numeric
           13  +# values.
           14  +#
           15  +
           16  +set testdir [file dirname $argv0]
           17  +source $testdir/tester.tcl
           18  +
           19  +foreach enc {utf8 utf16le utf16be} {
           20  +  do_test numcast-$enc.0 {
           21  +    db close
           22  +    sqlite3 db :memory:
           23  +    db eval "PRAGMA encoding='$enc'"
           24  +    set x [db eval {PRAGMA encoding}]
           25  +    string map {- {}} [string tolower $x]
           26  +  } $enc
           27  +  foreach {idx str rval ival} {
           28  +     1 12345.0       12345.0    12345
           29  +     2 12345.0e0     12345.0    12345
           30  +     3 -12345.0e0   -12345.0   -12345
           31  +     4 -12345.25    -12345.25  -12345
           32  +     5 { -12345.0}  -12345.0   -12345
           33  +     6 { 876xyz}       876.0      876
           34  +     7 { 456ķ89}       456.0      456
           35  +     8 { Ġ 321.5}        0.0        0
           36  +  } {
           37  +    do_test numcast-$enc.$idx.1 {
           38  +      db eval {SELECT CAST($str AS real)}
           39  +    } $rval
           40  +    do_test numcast-$enc.$idx.2 {
           41  +      db eval {SELECT CAST($str AS integer)}
           42  +    } $ival
           43  +  }
           44  +}
           45  +
           46  +finish_test

Added test/orderby4.test.

            1  +# 2013 March 26
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library.  The
           12  +# focus of this file is testing that the optimizations that disable
           13  +# ORDER BY clauses work correctly on multi-value primary keys and
           14  +# unique indices when only some prefix of the terms in the key are
           15  +# used.  See ticket http://www.sqlite.org/src/info/a179fe74659
           16  +#
           17  +
           18  +
           19  +set testdir [file dirname $argv0]
           20  +source $testdir/tester.tcl
           21  +set ::testprefix orderby4
           22  +
           23  +# Generate test data for a join.  Verify that the join gets the
           24  +# correct answer.
           25  +#
           26  +do_execsql_test 1.1 {
           27  +  CREATE TABLE t1(a, b, PRIMARY KEY(a,b));
           28  +  INSERT INTO t1 VALUES(1,1),(1,2);
           29  +  CREATE TABLE t2(x, y, PRIMARY KEY(x,y));
           30  +  INSERT INTO t2 VALUES(3,3),(4,4);
           31  +  SELECT a, x FROM t1, t2 ORDER BY 1, 2;
           32  +} {1 3 1 3 1 4 1 4}
           33  +do_execsql_test 1.2 {
           34  +  SELECT a, x FROM t1 CROSS JOIN t2 ORDER BY 1, 2;
           35  +} {1 3 1 3 1 4 1 4}
           36  +do_execsql_test 1.3 {
           37  +  SELECT a, x FROM t2 CROSS JOIN t1 ORDER BY 1, 2;
           38  +} {1 3 1 3 1 4 1 4}
           39  +
           40  +do_execsql_test 2.1 {
           41  +  CREATE TABLE t3(a);
           42  +  INSERT INTO t3 VALUES(1),(1);
           43  +  CREATE INDEX t3a ON t3(a);
           44  +  CREATE TABLE t4(x);
           45  +  INSERT INTO t4 VALUES(3),(4);
           46  +  CREATE INDEX t4x ON t4(x);
           47  +  SELECT a, x FROM t3, t4 ORDER BY 1, 2;
           48  +} {1 3 1 3 1 4 1 4}
           49  +do_execsql_test 2.2 {
           50  +  SELECT a, x FROM t3 CROSS JOIN t4 ORDER BY 1, 2;
           51  +} {1 3 1 3 1 4 1 4}
           52  +do_execsql_test 2.3 {
           53  +  SELECT a, x FROM t4 CROSS JOIN t3 ORDER BY 1, 2;
           54  +} {1 3 1 3 1 4 1 4}
           55  +
           56  +finish_test

Changes to test/subquery.test.

   417    417   
   418    418   
   419    419   #------------------------------------------------------------------
   420    420   # These tests - subquery-4.* - use the TCL statement cache to try 
   421    421   # and expose bugs to do with re-using statements that have been 
   422    422   # passed to sqlite3_reset().
   423    423   #
   424         -# One problem was that VDBE memory cells were not being initialised
          424  +# One problem was that VDBE memory cells were not being initialized
   425    425   # to NULL on the second and subsequent executions.
   426    426   #
   427    427   do_test subquery-4.1.1 {
   428    428     execsql {
   429    429       SELECT (SELECT a FROM t1);
   430    430     }
   431    431   } {1}

Changes to test/temptable.test.

   146    146     }
   147    147     catchsql {DROP INDEX i2}
   148    148   } {1 {no such index: i2}}
   149    149   
   150    150   # Check for correct name collision processing. A name collision can
   151    151   # occur when process A creates a temporary table T then process B
   152    152   # creates a permanent table also named T.  The temp table in process A
   153         -# hides the existance of the permanent table.
          153  +# hides the existence of the permanent table.
   154    154   #
   155    155   do_test temptable-4.1 {
   156    156     execsql {
   157    157       CREATE TEMP TABLE t2(x,y);
   158    158       INSERT INTO t2 VALUES(10,20);
   159    159       SELECT * FROM t2;
   160    160     } db2

Changes to test/tester.tcl.

   119    119         if {[info exists ::G(perm:dbconfig)]} {
   120    120           set ::dbhandle [lindex $args 0]
   121    121           uplevel #0 $::G(perm:dbconfig)
   122    122         }
   123    123         set res
   124    124       } else {
   125    125         # This command is not opening a new database connection. Pass the 
   126         -      # arguments through to the C implemenation as the are.
          126  +      # arguments through to the C implementation as the are.
   127    127         #
   128    128         uplevel 1 sqlite_orig $args
   129    129       }
   130    130     }
   131    131   }
   132    132   
   133    133   proc getFileRetries {} {
................................................................................
  1039   1039   # written into the files on disk. Argument $crashdelay indicates the
  1040   1040   # number of file syncs to wait before crashing.
  1041   1041   #
  1042   1042   # The return value is a list of two elements. The first element is a
  1043   1043   # boolean, indicating whether or not the process actually crashed or
  1044   1044   # reported some other error. The second element in the returned list is the
  1045   1045   # error message. This is "child process exited abnormally" if the crash
  1046         -# occured.
         1046  +# occurred.
  1047   1047   #
  1048   1048   #   crashsql -delay CRASHDELAY -file CRASHFILE ?-blocksize BLOCKSIZE? $sql
  1049   1049   #
  1050   1050   proc crashsql {args} {
  1051   1051   
  1052   1052     set blocksize ""
  1053   1053     set crashdelay 1
................................................................................
  1319   1319             array set stats [btree_pager_stats $bt]
  1320   1320             db_leave db
  1321   1321             set stats(state)
  1322   1322           } 0
  1323   1323         }
  1324   1324       }
  1325   1325   
  1326         -    # If an IO error occured, then the checksum of the database should
         1326  +    # If an IO error occurred, then the checksum of the database should
  1327   1327       # be the same as before the script that caused the IO error was run.
  1328   1328       #
  1329   1329       if {$::go && $::sqlite_io_error_hardhit && $::ioerropts(-cksum)} {
  1330   1330         do_test $testname.$n.6 {
  1331   1331           catch {db close}
  1332   1332           catch {db2 close}
  1333   1333           set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db]

Added test/tkt-6bfb98dfc0.test.

            1  +# 2013 March 27
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library. Specifically,
           12  +# it tests that ticket [6bfb98dfc0]
           13  +#
           14  +# The final INSERT in the script below reports that the database is
           15  +# corrupt (SQLITE_CORRUPT) and aborts even though the database is not
           16  +# corrupt.
           17  +#
           18  +#    PRAGMA page_size=512;
           19  +#    CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
           20  +#    INSERT INTO t1 VALUES(1,randomblob(400));
           21  +#    INSERT INTO t1 VALUES(2,randomblob(400));
           22  +#    INSERT INTO t1 SELECT x+2, randomblob(400) FROM t1;
           23  +#    INSERT INTO t1 SELECT x+4, randomblob(400) FROM t1;
           24  +#    INSERT INTO t1 SELECT x+8, randomblob(400) FROM t1;
           25  +#    INSERT INTO t1 SELECT x+16, randomblob(400) FROM t1;
           26  +#    INSERT INTO t1 SELECT x+32, randomblob(400) FROM t1;
           27  +#    INSERT INTO t1 SELECT x+64, randomblob(400) FROM t1 WHERE x<10;
           28  +#    CREATE TRIGGER r1 AFTER INSERT ON t1 WHEN new.x=74 BEGIN
           29  +#      DELETE FROM t1;
           30  +#      INSERT INTO t1 VALUES(75, randomblob(400));
           31  +#      INSERT INTO t1 VALUES(76, randomblob(400));
           32  +#    END;
           33  +#    INSERT INTO t1 VALUES(74, randomblob(400));
           34  +#
           35  +
           36  +set testdir [file dirname $argv0]
           37  +source $testdir/tester.tcl
           38  +
           39  +do_test tkt-6bfb98dfc0.100 {
           40  +  db eval {
           41  +    PRAGMA page_size=512;
           42  +    CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
           43  +    INSERT INTO t1 VALUES(1,randomblob(400));
           44  +    INSERT INTO t1 VALUES(2,randomblob(400));
           45  +    INSERT INTO t1 SELECT x+2, randomblob(400) FROM t1;
           46  +    INSERT INTO t1 SELECT x+4, randomblob(400) FROM t1;
           47  +    INSERT INTO t1 SELECT x+8, randomblob(400) FROM t1;
           48  +    INSERT INTO t1 SELECT x+16, randomblob(400) FROM t1;
           49  +    INSERT INTO t1 SELECT x+32, randomblob(400) FROM t1;
           50  +    INSERT INTO t1 SELECT x+64, randomblob(400) FROM t1 WHERE x<10;
           51  +    CREATE TRIGGER r1 AFTER INSERT ON t1 WHEN new.x=74 BEGIN
           52  +      DELETE FROM t1;
           53  +      INSERT INTO t1 VALUES(75, randomblob(400));
           54  +      INSERT INTO t1 VALUES(76, randomblob(400));
           55  +    END;
           56  +    INSERT INTO t1 VALUES(74, randomblob(400));
           57  +    SELECT x, length(y) FROM t1 ORDER BY x;
           58  +  }
           59  +} {75 400 76 400}
           60  +    
           61  +finish_test

Changes to test/tkt2409.test.

   103    103   } {SQLITE_OK}
   104    104   
   105    105   # Check the integrity of the cache.
   106    106   #
   107    107   integrity_check tkt2409-1.3
   108    108   
   109    109   # Check that the transaction was rolled back. Because the INSERT
   110         -# statement in which the "I/O error" occured did not open a statement
          110  +# statement in which the "I/O error" occurred did not open a statement
   111    111   # transaction, SQLite had no choice but to roll back the transaction.
   112    112   #
   113    113   do_test tkt2409-1.4 {
   114    114     unread_lock_db
   115    115     catchsql { ROLLBACK }
   116    116   } {0 {}}
   117    117   
................................................................................
   171    171   } {SQLITE_OK}
   172    172   
   173    173   # Check the integrity of the cache.
   174    174   #
   175    175   integrity_check tkt2409-3.3
   176    176   
   177    177   # Check that the transaction was rolled back. Because the INSERT
   178         -# statement in which the "I/O error" occured did not open a statement
          178  +# statement in which the "I/O error" occurred did not open a statement
   179    179   # transaction, SQLite had no choice but to roll back the transaction.
   180    180   #
   181    181   do_test tkt2409-3.4 {
   182    182     unread_lock_db
   183    183     catchsql { ROLLBACK }
   184    184   } {0 {}}
   185    185   integrity_check tkt2409-3.5