Fossil SCM
Merge in the latest SQLite updates.
Commit
d8590e093f90a262d5eda169781143a5a25942eb
Parent
b807acf62eecfbf…
2 files changed
+212
-255
+14
-10
+212
-255
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | -** version 3.4.0. By combining all the individual C code files into this | |
| 3 | +** version 3.4.1. By combining all the individual C code files into this | |
| 4 | 4 | ** single large file, the entire code can be compiled as a one translation |
| 5 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | 7 | ** of 5% are more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| @@ -9,17 +9,17 @@ | ||
| 9 | 9 | ** |
| 10 | 10 | ** This file is all you need to compile SQLite. To use SQLite in other |
| 11 | 11 | ** programs, you need this file and the "sqlite3.h" header file that defines |
| 12 | 12 | ** the programming interface to the SQLite library. (If you do not have |
| 13 | 13 | ** the "sqlite3.h" header file at hand, you will find a copy in the first |
| 14 | -** 2698 lines past this header comment.) Additional code files may be | |
| 14 | +** 2702 lines past this header comment.) Additional code files may be | |
| 15 | 15 | ** needed if you want a wrapper to interface SQLite with your choice of |
| 16 | 16 | ** programming language. The code for the "sqlite3" command-line shell |
| 17 | 17 | ** is also in a separate file. This file contains only code for the core |
| 18 | 18 | ** SQLite library. |
| 19 | 19 | ** |
| 20 | -** This amalgamation was generated on 2007-07-17 16:48:46 UTC. | |
| 20 | +** This amalgamation was generated on 2007-07-24 12:53:26 UTC. | |
| 21 | 21 | */ |
| 22 | 22 | #define SQLITE_AMALGAMATION 1 |
| 23 | 23 | #ifndef SQLITE_PRIVATE |
| 24 | 24 | # define SQLITE_PRIVATE static |
| 25 | 25 | #endif |
| @@ -57,11 +57,11 @@ | ||
| 57 | 57 | ** The name of this file under configuration management is "sqlite.h.in". |
| 58 | 58 | ** The makefile makes some minor changes to this file (such as inserting |
| 59 | 59 | ** the version number) and changes its name to "sqlite3.h" as |
| 60 | 60 | ** part of the build process. |
| 61 | 61 | ** |
| 62 | -** @(#) $Id: sqlite.h.in,v 1.217 2007/06/27 15:53:35 danielk1977 Exp $ | |
| 62 | +** @(#) $Id: sqlite.h.in,v 1.218 2007/07/19 12:41:40 drh Exp $ | |
| 63 | 63 | */ |
| 64 | 64 | #ifndef _SQLITE3_H_ |
| 65 | 65 | #define _SQLITE3_H_ |
| 66 | 66 | #include <stdarg.h> /* Needed for the definition of va_list */ |
| 67 | 67 | |
| @@ -108,12 +108,12 @@ | ||
| 108 | 108 | ** version 3.1.1 or greater at compile time, programs may use the test |
| 109 | 109 | ** (SQLITE_VERSION_NUMBER>=3001001). |
| 110 | 110 | ** |
| 111 | 111 | ** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()]. |
| 112 | 112 | */ |
| 113 | -#define SQLITE_VERSION "3.4.0" | |
| 114 | -#define SQLITE_VERSION_NUMBER 3004000 | |
| 113 | +#define SQLITE_VERSION "3.4.1" | |
| 114 | +#define SQLITE_VERSION_NUMBER 3004001 | |
| 115 | 115 | |
| 116 | 116 | /* |
| 117 | 117 | ** CAPI3REF: Run-Time Library Version Numbers |
| 118 | 118 | ** |
| 119 | 119 | ** These routines return values equivalent to the header constants |
| @@ -990,14 +990,18 @@ | ||
| 990 | 990 | ** The first argument "db" is an [sqlite3 | SQLite database handle] |
| 991 | 991 | ** obtained from a prior call to [sqlite3_open()] or [sqlite3_open16()]. |
| 992 | 992 | ** The second argument "zSql" is the statement to be compiled, encoded |
| 993 | 993 | ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() |
| 994 | 994 | ** interfaces uses UTF-8 and sqlite3_prepare16() and sqlite3_prepare16_v2() |
| 995 | -** use UTF-16. If the next argument, "nBytes", is less | |
| 995 | +** use UTF-16. | |
| 996 | +** | |
| 997 | +** If the nByte argument is less | |
| 996 | 998 | ** than zero, then zSql is read up to the first zero terminator. If |
| 997 | -** "nBytes" is not less than zero, then it is the length of the string zSql | |
| 998 | -** in bytes (not characters). | |
| 999 | +** nByte is non-negative, then it is the maximum number of | |
| 1000 | +** bytes read from zSql. When nByte is non-negative, the | |
| 1001 | +** zSql string ends at either the first '\000' character or | |
| 1002 | +** until the nByte-th byte, whichever comes first. | |
| 999 | 1003 | ** |
| 1000 | 1004 | ** *pzTail is made to point to the first byte past the end of the first |
| 1001 | 1005 | ** SQL statement in zSql. This routine only compiles the first statement |
| 1002 | 1006 | ** in zSql, so *pzTail is left pointing to what remains uncompiled. |
| 1003 | 1007 | ** |
| @@ -1046,32 +1050,32 @@ | ||
| 1046 | 1050 | ** </ol> |
| 1047 | 1051 | */ |
| 1048 | 1052 | SQLITE_API int sqlite3_prepare( |
| 1049 | 1053 | sqlite3 *db, /* Database handle */ |
| 1050 | 1054 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
| 1051 | - int nBytes, /* Length of zSql in bytes. */ | |
| 1055 | + int nByte, /* Maximum length of zSql in bytes. */ | |
| 1052 | 1056 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1053 | 1057 | const char **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1054 | 1058 | ); |
| 1055 | 1059 | int sqlite3_prepare_v2( |
| 1056 | 1060 | sqlite3 *db, /* Database handle */ |
| 1057 | 1061 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
| 1058 | - int nBytes, /* Length of zSql in bytes. */ | |
| 1062 | + int nByte, /* Maximum length of zSql in bytes. */ | |
| 1059 | 1063 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1060 | 1064 | const char **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1061 | 1065 | ); |
| 1062 | 1066 | SQLITE_API int sqlite3_prepare16( |
| 1063 | 1067 | sqlite3 *db, /* Database handle */ |
| 1064 | 1068 | const void *zSql, /* SQL statement, UTF-16 encoded */ |
| 1065 | - int nBytes, /* Length of zSql in bytes. */ | |
| 1069 | + int nByte, /* Maximum length of zSql in bytes. */ | |
| 1066 | 1070 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1067 | 1071 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1068 | 1072 | ); |
| 1069 | 1073 | int sqlite3_prepare16_v2( |
| 1070 | 1074 | sqlite3 *db, /* Database handle */ |
| 1071 | 1075 | const void *zSql, /* SQL statement, UTF-16 encoded */ |
| 1072 | - int nBytes, /* Length of zSql in bytes. */ | |
| 1076 | + int nByte, /* Maximum length of zSql in bytes. */ | |
| 1073 | 1077 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1074 | 1078 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1075 | 1079 | ); |
| 1076 | 1080 | |
| 1077 | 1081 | /* |
| @@ -2788,11 +2792,11 @@ | ||
| 2788 | 2792 | ** May you share freely, never taking more than you give. |
| 2789 | 2793 | ** |
| 2790 | 2794 | ************************************************************************* |
| 2791 | 2795 | ** Internal interface definitions for SQLite. |
| 2792 | 2796 | ** |
| 2793 | -** @(#) $Id: sqliteInt.h,v 1.578 2007/06/26 10:38:55 danielk1977 Exp $ | |
| 2797 | +** @(#) $Id: sqliteInt.h,v 1.580 2007/07/23 19:31:17 drh Exp $ | |
| 2794 | 2798 | */ |
| 2795 | 2799 | #ifndef _SQLITEINT_H_ |
| 2796 | 2800 | #define _SQLITEINT_H_ |
| 2797 | 2801 | /************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/ |
| 2798 | 2802 | /************** Begin file sqliteLimit.h *************************************/ |
| @@ -5919,65 +5923,18 @@ | ||
| 5919 | 5923 | * even when no triggers exist |
| 5920 | 5924 | */ |
| 5921 | 5925 | extern int sqlite3_always_code_trigger_setup; |
| 5922 | 5926 | |
| 5923 | 5927 | /* |
| 5924 | -** A lookup table used by the SQLITE_READ_UTF8 macro. The definition | |
| 5925 | -** is in utf.c. | |
| 5926 | -*/ | |
| 5927 | -extern const unsigned char sqlite3UtfTrans1[]; | |
| 5928 | - | |
| 5929 | -/* | |
| 5930 | -** Macros for reading UTF8 characters. | |
| 5931 | -** | |
| 5932 | -** SQLITE_READ_UTF8(x,c) reads a single UTF8 value out of x and writes | |
| 5933 | -** that value into c. The type of x must be unsigned char*. The type | |
| 5934 | -** of c must be unsigned int. | |
| 5935 | -** | |
| 5936 | -** SQLITE_SKIP_UTF8(x) advances x forward by one character. The type of | |
| 5937 | -** x must be unsigned char*. | |
| 5938 | -** | |
| 5939 | -** Notes On Invalid UTF-8: | |
| 5940 | -** | |
| 5941 | -** * These macros never allow a 7-bit character (0x00 through 0x7f) to | |
| 5942 | -** be encoded as a multi-byte character. Any multi-byte character that | |
| 5943 | -** attempts to encode a value between 0x00 and 0x7f is rendered as 0xfffd. | |
| 5944 | -** | |
| 5945 | -** * These macros never allow a UTF16 surrogate value to be encoded. | |
| 5946 | -** If a multi-byte character attempts to encode a value between | |
| 5947 | -** 0xd800 and 0xe000 then it is rendered as 0xfffd. | |
| 5948 | -** | |
| 5949 | -** * Bytes in the range of 0x80 through 0xbf which occur as the first | |
| 5950 | -** byte of a character are interpreted as single-byte characters | |
| 5951 | -** and rendered as themselves even though they are technically | |
| 5952 | -** invalid characters. | |
| 5953 | -** | |
| 5954 | -** * These routines accept an infinite number of different UTF8 encodings | |
| 5955 | -** for unicode values 0x80 and greater. They do not change over-length | |
| 5956 | -** encodings to 0xfffd as some systems recommend. | |
| 5957 | -** | |
| 5958 | -*/ | |
| 5959 | -#define SQLITE_READ_UTF8(zIn, c) { \ | |
| 5960 | - c = *(zIn++); \ | |
| 5961 | - if( c>=0xc0 ){ \ | |
| 5962 | - c = sqlite3UtfTrans1[c-0xc0]; \ | |
| 5963 | - while( (*zIn & 0xc0)==0x80 ){ \ | |
| 5964 | - c = (c<<6) + (0x3f & *(zIn++)); \ | |
| 5965 | - } \ | |
| 5966 | - if( c<0x80 \ | |
| 5967 | - || (c&0xFFFFF800)==0xD800 \ | |
| 5968 | - || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \ | |
| 5969 | - } \ | |
| 5970 | -} | |
| 5928 | +** Assuming zIn points to the first byte of a UTF-8 character, | |
| 5929 | +** advance zIn to point to the first byte of the next UTF-8 character. | |
| 5930 | +*/ | |
| 5971 | 5931 | #define SQLITE_SKIP_UTF8(zIn) { \ |
| 5972 | 5932 | if( (*(zIn++))>=0xc0 ){ \ |
| 5973 | 5933 | while( (*zIn & 0xc0)==0x80 ){ zIn++; } \ |
| 5974 | 5934 | } \ |
| 5975 | 5935 | } |
| 5976 | - | |
| 5977 | - | |
| 5978 | - | |
| 5979 | 5936 | |
| 5980 | 5937 | /* |
| 5981 | 5938 | ** The SQLITE_CORRUPT_BKPT macro can be either a constant (for production |
| 5982 | 5939 | ** builds) or a function call (for debugging). If it is a function call, |
| 5983 | 5940 | ** it allows the operator to set a breakpoint at the spot where database |
| @@ -6193,11 +6150,11 @@ | ||
| 6193 | 6150 | SQLITE_API char *sqlite3_snprintf(int,char*,const char*,...); |
| 6194 | 6151 | SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*); |
| 6195 | 6152 | SQLITE_PRIVATE int sqlite3FitsIn64Bits(const char *); |
| 6196 | 6153 | SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar); |
| 6197 | 6154 | SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte); |
| 6198 | -SQLITE_PRIVATE u32 sqlite3ReadUtf8(const unsigned char *); | |
| 6155 | +SQLITE_PRIVATE int sqlite3Utf8Read(const u8*, const u8*, const u8**); | |
| 6199 | 6156 | SQLITE_PRIVATE int sqlite3PutVarint(unsigned char *, u64); |
| 6200 | 6157 | SQLITE_PRIVATE int sqlite3GetVarint(const unsigned char *, u64 *); |
| 6201 | 6158 | SQLITE_PRIVATE int sqlite3GetVarint32(const unsigned char *, u32 *); |
| 6202 | 6159 | SQLITE_PRIVATE int sqlite3VarintLen(u64 v); |
| 6203 | 6160 | SQLITE_PRIVATE void sqlite3IndexAffinityStr(Vdbe *, Index *); |
| @@ -6265,10 +6222,17 @@ | ||
| 6265 | 6222 | SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int); |
| 6266 | 6223 | SQLITE_PRIVATE void sqlite3FailedMalloc(void); |
| 6267 | 6224 | SQLITE_PRIVATE void sqlite3AbortOtherActiveVdbes(sqlite3 *, Vdbe *); |
| 6268 | 6225 | SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *); |
| 6269 | 6226 | |
| 6227 | +/* | |
| 6228 | +** The interface to the LEMON-generated parser | |
| 6229 | +*/ | |
| 6230 | +SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(size_t)); | |
| 6231 | +SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*)); | |
| 6232 | +SQLITE_PRIVATE void sqlite3Parser(void*, int, Token, Parse*); | |
| 6233 | + | |
| 6270 | 6234 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 6271 | 6235 | SQLITE_PRIVATE void sqlite3CloseExtensions(sqlite3*); |
| 6272 | 6236 | SQLITE_PRIVATE int sqlite3AutoLoadExtensions(sqlite3*); |
| 6273 | 6237 | #else |
| 6274 | 6238 | # define sqlite3CloseExtensions(X) |
| @@ -9286,11 +9250,11 @@ | ||
| 9286 | 9250 | ** |
| 9287 | 9251 | ************************************************************************* |
| 9288 | 9252 | ** This file contains routines used to translate between UTF-8, |
| 9289 | 9253 | ** UTF-16, UTF-16BE, and UTF-16LE. |
| 9290 | 9254 | ** |
| 9291 | -** $Id: utf.c,v 1.51 2007/05/23 16:23:09 danielk1977 Exp $ | |
| 9255 | +** $Id: utf.c,v 1.52 2007/07/23 19:12:42 drh Exp $ | |
| 9292 | 9256 | ** |
| 9293 | 9257 | ** Notes on UTF-8: |
| 9294 | 9258 | ** |
| 9295 | 9259 | ** Byte-0 Byte-1 Byte-2 Byte-3 Value |
| 9296 | 9260 | ** 0xxxxxxx 00000000 00000000 0xxxxxxx |
| @@ -9764,10 +9728,11 @@ | ||
| 9764 | 9728 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
| 9765 | 9729 | 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 9766 | 9730 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
| 9767 | 9731 | 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00, |
| 9768 | 9732 | }; |
| 9733 | + | |
| 9769 | 9734 | |
| 9770 | 9735 | #define WRITE_UTF8(zOut, c) { \ |
| 9771 | 9736 | if( c<0x00080 ){ \ |
| 9772 | 9737 | *zOut++ = (c&0xFF); \ |
| 9773 | 9738 | } \ |
| @@ -9830,10 +9795,58 @@ | ||
| 9830 | 9795 | c2 += (*zIn++); \ |
| 9831 | 9796 | c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \ |
| 9832 | 9797 | if( (c & 0xFFFF0000)==0 ) c = 0xFFFD; \ |
| 9833 | 9798 | } \ |
| 9834 | 9799 | } |
| 9800 | + | |
| 9801 | +/* | |
| 9802 | +** Translate a single UTF-8 character. Return the unicode value. | |
| 9803 | +** | |
| 9804 | +** During translation, assume that the byte that zTerm points | |
| 9805 | +** is a 0x00. | |
| 9806 | +** | |
| 9807 | +** Write a pointer to the next unread byte back into *pzNext. | |
| 9808 | +** | |
| 9809 | +** Notes On Invalid UTF-8: | |
| 9810 | +** | |
| 9811 | +** * This routine never allows a 7-bit character (0x00 through 0x7f) to | |
| 9812 | +** be encoded as a multi-byte character. Any multi-byte character that | |
| 9813 | +** attempts to encode a value between 0x00 and 0x7f is rendered as 0xfffd. | |
| 9814 | +** | |
| 9815 | +** * This routine never allows a UTF16 surrogate value to be encoded. | |
| 9816 | +** If a multi-byte character attempts to encode a value between | |
| 9817 | +** 0xd800 and 0xe000 then it is rendered as 0xfffd. | |
| 9818 | +** | |
| 9819 | +** * Bytes in the range of 0x80 through 0xbf which occur as the first | |
| 9820 | +** byte of a character are interpreted as single-byte characters | |
| 9821 | +** and rendered as themselves even though they are technically | |
| 9822 | +** invalid characters. | |
| 9823 | +** | |
| 9824 | +** * This routine accepts an infinite number of different UTF8 encodings | |
| 9825 | +** for unicode values 0x80 and greater. It do not change over-length | |
| 9826 | +** encodings to 0xfffd as some systems recommend. | |
| 9827 | +*/ | |
| 9828 | +SQLITE_PRIVATE int sqlite3Utf8Read( | |
| 9829 | + const unsigned char *z, /* First byte of UTF-8 character */ | |
| 9830 | + const unsigned char *zTerm, /* Pretend this byte is 0x00 */ | |
| 9831 | + const unsigned char **pzNext /* Write first byte past UTF-8 char here */ | |
| 9832 | +){ | |
| 9833 | + int c = *(z++); | |
| 9834 | + if( c>=0xc0 ){ | |
| 9835 | + c = sqlite3UtfTrans1[c-0xc0]; | |
| 9836 | + while( z!=zTerm && (*z & 0xc0)==0x80 ){ | |
| 9837 | + c = (c<<6) + (0x3f & *(z++)); | |
| 9838 | + } | |
| 9839 | + if( c<0x80 | |
| 9840 | + || (c&0xFFFFF800)==0xD800 | |
| 9841 | + || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } | |
| 9842 | + } | |
| 9843 | + *pzNext = z; | |
| 9844 | + return c; | |
| 9845 | +} | |
| 9846 | + | |
| 9847 | + | |
| 9835 | 9848 | |
| 9836 | 9849 | /* |
| 9837 | 9850 | ** If the TRANSLATE_TRACE macro is defined, the value of each Mem is |
| 9838 | 9851 | ** printed on stderr on the way into and out of sqlite3VdbeMemTranslate(). |
| 9839 | 9852 | */ |
| @@ -9924,85 +9937,23 @@ | ||
| 9924 | 9937 | zOut = zShort; |
| 9925 | 9938 | } |
| 9926 | 9939 | z = zOut; |
| 9927 | 9940 | |
| 9928 | 9941 | if( pMem->enc==SQLITE_UTF8 ){ |
| 9929 | - unsigned int iExtra = 0xD800; | |
| 9930 | - | |
| 9931 | - if( 0==(pMem->flags&MEM_Term) && zTerm>zIn && (zTerm[-1]&0x80) ){ | |
| 9932 | - /* This UTF8 string is not nul-terminated, and the last byte is | |
| 9933 | - ** not a character in the ascii range (codpoints 0..127). This | |
| 9934 | - ** means the SQLITE_READ_UTF8() macro might read past the end | |
| 9935 | - ** of the allocated buffer. | |
| 9936 | - ** | |
| 9937 | - ** There are four possibilities: | |
| 9938 | - ** | |
| 9939 | - ** 1. The last byte is the first byte of a non-ASCII character, | |
| 9940 | - ** | |
| 9941 | - ** 2. The final N bytes of the input string are continuation bytes | |
| 9942 | - ** and immediately preceding them is the first byte of a | |
| 9943 | - ** non-ASCII character. | |
| 9944 | - ** | |
| 9945 | - ** 3. The final N bytes of the input string are continuation bytes | |
| 9946 | - ** and immediately preceding them is a byte that encodes a | |
| 9947 | - ** character in the ASCII range. | |
| 9948 | - ** | |
| 9949 | - ** 4. The entire string consists of continuation characters. | |
| 9950 | - ** | |
| 9951 | - ** Cases (3) and (4) require no special handling. The SQLITE_READ_UTF8() | |
| 9952 | - ** macro will not overread the buffer in these cases. | |
| 9953 | - */ | |
| 9954 | - unsigned char *zExtra = &zTerm[-1]; | |
| 9955 | - while( zExtra>zIn && (zExtra[0]&0xC0)==0x80 ){ | |
| 9956 | - zExtra--; | |
| 9957 | - } | |
| 9958 | - | |
| 9959 | - if( (zExtra[0]&0xC0)==0xC0 ){ | |
| 9960 | - /* Make a copy of the last character encoding in the input string. | |
| 9961 | - ** Then make sure it is nul-terminated and use SQLITE_READ_UTF8() | |
| 9962 | - ** to decode the codepoint. Store the codepoint in variable iExtra, | |
| 9963 | - ** it will be appended to the output string later. | |
| 9964 | - */ | |
| 9965 | - unsigned char *zFree = 0; | |
| 9966 | - unsigned char zBuf[16]; | |
| 9967 | - int nExtra = (pMem->n+zIn-zExtra); | |
| 9968 | - zTerm = zExtra; | |
| 9969 | - if( nExtra>15 ){ | |
| 9970 | - zExtra = sqliteMallocRaw(nExtra+1); | |
| 9971 | - if( !zExtra ){ | |
| 9972 | - return SQLITE_NOMEM; | |
| 9973 | - } | |
| 9974 | - zFree = zExtra; | |
| 9975 | - }else{ | |
| 9976 | - zExtra = zBuf; | |
| 9977 | - } | |
| 9978 | - memcpy(zExtra, zTerm, nExtra); | |
| 9979 | - zExtra[nExtra] = '\0'; | |
| 9980 | - SQLITE_READ_UTF8(zExtra, iExtra); | |
| 9981 | - sqliteFree(zFree); | |
| 9982 | - } | |
| 9983 | - } | |
| 9984 | - | |
| 9985 | 9942 | if( desiredEnc==SQLITE_UTF16LE ){ |
| 9986 | 9943 | /* UTF-8 -> UTF-16 Little-endian */ |
| 9987 | 9944 | while( zIn<zTerm ){ |
| 9988 | - SQLITE_READ_UTF8(zIn, c); | |
| 9945 | + c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn); | |
| 9989 | 9946 | WRITE_UTF16LE(z, c); |
| 9990 | 9947 | } |
| 9991 | - if( iExtra!=0xD800 ){ | |
| 9992 | - WRITE_UTF16LE(z, iExtra); | |
| 9993 | - } | |
| 9994 | 9948 | }else{ |
| 9995 | 9949 | assert( desiredEnc==SQLITE_UTF16BE ); |
| 9996 | 9950 | /* UTF-8 -> UTF-16 Big-endian */ |
| 9997 | 9951 | while( zIn<zTerm ){ |
| 9998 | - SQLITE_READ_UTF8(zIn, c); | |
| 9952 | + c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn); | |
| 9999 | 9953 | WRITE_UTF16BE(z, c); |
| 10000 | 9954 | } |
| 10001 | - if( iExtra!=0xD800 ){ | |
| 10002 | - WRITE_UTF16BE(z, iExtra); | |
| 10003 | - } | |
| 10004 | 9955 | } |
| 10005 | 9956 | pMem->n = z - zOut; |
| 10006 | 9957 | *z++ = 0; |
| 10007 | 9958 | }else{ |
| 10008 | 9959 | assert( desiredEnc==SQLITE_UTF8 ); |
| @@ -10182,15 +10133,15 @@ | ||
| 10182 | 10133 | ** correct UTF-8 encoding to be longer than a malformed encoding). |
| 10183 | 10134 | */ |
| 10184 | 10135 | SQLITE_PRIVATE int sqlite3Utf8To8(unsigned char *zIn){ |
| 10185 | 10136 | unsigned char *zOut = zIn; |
| 10186 | 10137 | unsigned char *zStart = zIn; |
| 10187 | - int c; | |
| 10138 | + unsigned char *zTerm; | |
| 10139 | + u32 c; | |
| 10188 | 10140 | |
| 10189 | - while(1){ | |
| 10190 | - SQLITE_READ_UTF8(zIn, c); | |
| 10191 | - if( c==0 ) break; | |
| 10141 | + while( zIn[0] ){ | |
| 10142 | + c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn); | |
| 10192 | 10143 | if( c!=0xfffd ){ |
| 10193 | 10144 | WRITE_UTF8(zOut, c); |
| 10194 | 10145 | } |
| 10195 | 10146 | } |
| 10196 | 10147 | *zOut = 0; |
| @@ -10206,20 +10157,22 @@ | ||
| 10206 | 10157 | */ |
| 10207 | 10158 | SQLITE_PRIVATE void sqlite3UtfSelfTest(){ |
| 10208 | 10159 | unsigned int i, t; |
| 10209 | 10160 | unsigned char zBuf[20]; |
| 10210 | 10161 | unsigned char *z; |
| 10162 | + unsigned char *zTerm; | |
| 10211 | 10163 | int n; |
| 10212 | 10164 | unsigned int c; |
| 10213 | 10165 | |
| 10214 | 10166 | for(i=0; i<0x00110000; i++){ |
| 10215 | 10167 | z = zBuf; |
| 10216 | 10168 | WRITE_UTF8(z, i); |
| 10217 | 10169 | n = z-zBuf; |
| 10218 | 10170 | z[0] = 0; |
| 10171 | + zTerm = z; | |
| 10219 | 10172 | z = zBuf; |
| 10220 | - SQLITE_READ_UTF8(z, c); | |
| 10173 | + c = sqlite3Utf8Read(z, zTerm, (const u8**)&z); | |
| 10221 | 10174 | t = i; |
| 10222 | 10175 | if( i>=0xD800 && i<=0xDFFF ) t = 0xFFFD; |
| 10223 | 10176 | if( (i&0xFFFFFFFE)==0xFFFE ) t = 0xFFFD; |
| 10224 | 10177 | assert( c==t ); |
| 10225 | 10178 | assert( (z-zBuf)==n ); |
| @@ -17876,11 +17829,11 @@ | ||
| 17876 | 17829 | ** is separate from the database file. The pager also implements file |
| 17877 | 17830 | ** locking to prevent two processes from writing the same database |
| 17878 | 17831 | ** file simultaneously, or one process from reading the database while |
| 17879 | 17832 | ** another is writing. |
| 17880 | 17833 | ** |
| 17881 | -** @(#) $Id: pager.c,v 1.349 2007/06/26 22:10:12 drh Exp $ | |
| 17834 | +** @(#) $Id: pager.c,v 1.351 2007/07/20 00:33:36 drh Exp $ | |
| 17882 | 17835 | */ |
| 17883 | 17836 | #ifndef SQLITE_OMIT_DISKIO |
| 17884 | 17837 | |
| 17885 | 17838 | /* |
| 17886 | 17839 | ** Macros for troubleshooting. Normally turned off |
| @@ -18402,21 +18355,10 @@ | ||
| 18402 | 18355 | static int write32bits(OsFile *fd, u32 val){ |
| 18403 | 18356 | char ac[4]; |
| 18404 | 18357 | put32bits(ac, val); |
| 18405 | 18358 | return sqlite3OsWrite(fd, ac, 4); |
| 18406 | 18359 | } |
| 18407 | - | |
| 18408 | -/* | |
| 18409 | -** Read a 32-bit integer at offset 'offset' from the page identified by | |
| 18410 | -** page header 'p'. | |
| 18411 | -*/ | |
| 18412 | -static u32 retrieve32bits(PgHdr *p, int offset){ | |
| 18413 | - unsigned char *ac; | |
| 18414 | - ac = &((unsigned char*)PGHDR_TO_DATA(p))[offset]; | |
| 18415 | - return sqlite3Get4byte(ac); | |
| 18416 | -} | |
| 18417 | - | |
| 18418 | 18360 | |
| 18419 | 18361 | /* |
| 18420 | 18362 | ** This function should be called when an error occurs within the pager |
| 18421 | 18363 | ** code. The first argument is a pointer to the pager structure, the |
| 18422 | 18364 | ** second the error-code about to be returned by a pager API function. |
| @@ -21725,14 +21667,12 @@ | ||
| 21725 | 21667 | rc = sqlite3PagerGet(pPager, 1, &pPgHdr); |
| 21726 | 21668 | if( rc!=SQLITE_OK ) return rc; |
| 21727 | 21669 | rc = sqlite3PagerWrite(pPgHdr); |
| 21728 | 21670 | if( rc!=SQLITE_OK ) return rc; |
| 21729 | 21671 | |
| 21730 | - /* Read the current value at byte 24. */ | |
| 21731 | - change_counter = retrieve32bits(pPgHdr, 24); | |
| 21732 | - | |
| 21733 | 21672 | /* Increment the value just read and write it back to byte 24. */ |
| 21673 | + change_counter = sqlite3Get4byte((u8*)pPager->dbFileVers); | |
| 21734 | 21674 | change_counter++; |
| 21735 | 21675 | put32bits(((char*)PGHDR_TO_DATA(pPgHdr))+24, change_counter); |
| 21736 | 21676 | /* Release the page reference. */ |
| 21737 | 21677 | sqlite3PagerUnref(pPgHdr); |
| 21738 | 21678 | pPager->changeCountDone = 1; |
| @@ -22347,11 +22287,11 @@ | ||
| 22347 | 22287 | ** May you do good and not evil. |
| 22348 | 22288 | ** May you find forgiveness for yourself and forgive others. |
| 22349 | 22289 | ** May you share freely, never taking more than you give. |
| 22350 | 22290 | ** |
| 22351 | 22291 | ************************************************************************* |
| 22352 | -** $Id: btree.c,v 1.392 2007/06/26 01:04:49 drh Exp $ | |
| 22292 | +** $Id: btree.c,v 1.393 2007/07/23 19:26:17 drh Exp $ | |
| 22353 | 22293 | ** |
| 22354 | 22294 | ** This file implements a external (disk-based) database using BTrees. |
| 22355 | 22295 | ** See the header comment on "btreeInt.h" for additional information. |
| 22356 | 22296 | ** Including a description of file format and an overview of operation. |
| 22357 | 22297 | */ |
| @@ -24934,11 +24874,11 @@ | ||
| 24934 | 24874 | } |
| 24935 | 24875 | if( rc==SQLITE_DONE ){ |
| 24936 | 24876 | assert(nFin==0 || pBt->nTrunc==0 || nFin<=pBt->nTrunc); |
| 24937 | 24877 | rc = SQLITE_OK; |
| 24938 | 24878 | if( pBt->nTrunc ){ |
| 24939 | - sqlite3PagerWrite(pBt->pPage1->pDbPage); | |
| 24879 | + rc = sqlite3PagerWrite(pBt->pPage1->pDbPage); | |
| 24940 | 24880 | put4byte(&pBt->pPage1->aData[32], 0); |
| 24941 | 24881 | put4byte(&pBt->pPage1->aData[36], 0); |
| 24942 | 24882 | pBt->nTrunc = nFin; |
| 24943 | 24883 | } |
| 24944 | 24884 | } |
| @@ -33573,11 +33513,11 @@ | ||
| 33573 | 33513 | ** documentation, headers files, or other derived files. The formatting |
| 33574 | 33514 | ** of the code in this file is, therefore, important. See other comments |
| 33575 | 33515 | ** in this file for details. If in doubt, do not deviate from existing |
| 33576 | 33516 | ** commenting and indentation practices when changing or adding code. |
| 33577 | 33517 | ** |
| 33578 | -** $Id: vdbe.c,v 1.636 2007/07/01 21:18:40 drh Exp $ | |
| 33518 | +** $Id: vdbe.c,v 1.638 2007/07/22 19:10:21 drh Exp $ | |
| 33579 | 33519 | */ |
| 33580 | 33520 | |
| 33581 | 33521 | /* |
| 33582 | 33522 | ** The following global variable is incremented every time a cursor |
| 33583 | 33523 | ** moves, either by the OP_MoveXX, OP_Next, or OP_Prev opcodes. The test |
| @@ -37824,18 +37764,18 @@ | ||
| 37824 | 37764 | |
| 37825 | 37765 | for(nRoot=0; &pTos[-nRoot]>=p->aStack; nRoot++){ |
| 37826 | 37766 | if( (pTos[-nRoot].flags & MEM_Int)==0 ) break; |
| 37827 | 37767 | } |
| 37828 | 37768 | assert( nRoot>0 ); |
| 37829 | - aRoot = sqliteMallocRaw( sizeof(int*)*(nRoot+1) ); | |
| 37769 | + aRoot = sqliteMallocRaw( sizeof(int)*(nRoot+1) ); | |
| 37830 | 37770 | if( aRoot==0 ) goto no_mem; |
| 37831 | 37771 | j = pOp->p1; |
| 37832 | 37772 | assert( j>=0 && j<p->nMem ); |
| 37833 | 37773 | pnErr = &p->aMem[j]; |
| 37834 | 37774 | assert( (pnErr->flags & MEM_Int)!=0 ); |
| 37835 | 37775 | for(j=0; j<nRoot; j++){ |
| 37836 | - aRoot[j] = pTos[-j].u.i; | |
| 37776 | + aRoot[j] = (pTos-j)->u.i; | |
| 37837 | 37777 | } |
| 37838 | 37778 | aRoot[j] = 0; |
| 37839 | 37779 | popStack(&pTos, nRoot); |
| 37840 | 37780 | pTos++; |
| 37841 | 37781 | z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p2].pBt, aRoot, nRoot, |
| @@ -39076,11 +39016,11 @@ | ||
| 39076 | 39016 | ** |
| 39077 | 39017 | ************************************************************************* |
| 39078 | 39018 | ** This file contains routines used for analyzing expressions and |
| 39079 | 39019 | ** for generating VDBE code that evaluates expressions in SQLite. |
| 39080 | 39020 | ** |
| 39081 | -** $Id: expr.c,v 1.300 2007/06/25 16:29:34 danielk1977 Exp $ | |
| 39021 | +** $Id: expr.c,v 1.301 2007/07/23 22:51:15 drh Exp $ | |
| 39082 | 39022 | */ |
| 39083 | 39023 | |
| 39084 | 39024 | /* |
| 39085 | 39025 | ** Return the 'affinity' of the expression pExpr if any. |
| 39086 | 39026 | ** |
| @@ -40202,15 +40142,21 @@ | ||
| 40202 | 40142 | */ |
| 40203 | 40143 | if( cnt==0 && (pEList = pNC->pEList)!=0 && zTab==0 ){ |
| 40204 | 40144 | for(j=0; j<pEList->nExpr; j++){ |
| 40205 | 40145 | char *zAs = pEList->a[j].zName; |
| 40206 | 40146 | if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){ |
| 40207 | - Expr *pDup; | |
| 40147 | + Expr *pDup, *pOrig; | |
| 40208 | 40148 | assert( pExpr->pLeft==0 && pExpr->pRight==0 ); |
| 40209 | 40149 | assert( pExpr->pList==0 ); |
| 40210 | 40150 | assert( pExpr->pSelect==0 ); |
| 40211 | - pDup = sqlite3ExprDup(pEList->a[j].pExpr); | |
| 40151 | + pOrig = pEList->a[j].pExpr; | |
| 40152 | + if( !pNC->allowAgg && ExprHasProperty(pOrig, EP_Agg) ){ | |
| 40153 | + sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs); | |
| 40154 | + sqliteFree(zCol); | |
| 40155 | + return 2; | |
| 40156 | + } | |
| 40157 | + pDup = sqlite3ExprDup(pOrig); | |
| 40212 | 40158 | if( pExpr->flags & EP_ExpCollate ){ |
| 40213 | 40159 | pDup->pColl = pExpr->pColl; |
| 40214 | 40160 | pDup->flags |= EP_ExpCollate; |
| 40215 | 40161 | } |
| 40216 | 40162 | if( pExpr->span.dyn ) sqliteFree((char*)pExpr->span.z); |
| @@ -47909,13 +47855,14 @@ | ||
| 47909 | 47855 | ** |
| 47910 | 47856 | ** There is only one exported symbol in this file - the function |
| 47911 | 47857 | ** sqliteRegisterBuildinFunctions() found at the bottom of the file. |
| 47912 | 47858 | ** All other code has file scope. |
| 47913 | 47859 | ** |
| 47914 | -** $Id: func.c,v 1.161 2007/06/22 15:21:16 danielk1977 Exp $ | |
| 47860 | +** $Id: func.c,v 1.162 2007/07/23 19:12:42 drh Exp $ | |
| 47915 | 47861 | */ |
| 47916 | 47862 | /* #include <math.h> */ |
| 47863 | + | |
| 47917 | 47864 | |
| 47918 | 47865 | /* |
| 47919 | 47866 | ** Return the collating function associated with a function. |
| 47920 | 47867 | */ |
| 47921 | 47868 | static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){ |
| @@ -48284,19 +48231,10 @@ | ||
| 48284 | 48231 | static const struct compareInfo likeInfoNorm = { '%', '_', 0, 1 }; |
| 48285 | 48232 | /* If SQLITE_CASE_SENSITIVE_LIKE is defined, then the LIKE operator |
| 48286 | 48233 | ** is case sensitive causing 'a' LIKE 'A' to be false */ |
| 48287 | 48234 | static const struct compareInfo likeInfoAlt = { '%', '_', 0, 0 }; |
| 48288 | 48235 | |
| 48289 | -/* | |
| 48290 | -** Read a single UTF-8 character and return its value. | |
| 48291 | -*/ | |
| 48292 | -SQLITE_PRIVATE u32 sqlite3ReadUtf8(const unsigned char *z){ | |
| 48293 | - u32 c; | |
| 48294 | - SQLITE_READ_UTF8(z, c); | |
| 48295 | - return c; | |
| 48296 | -} | |
| 48297 | - | |
| 48298 | 48236 | /* |
| 48299 | 48237 | ** Compare two UTF-8 strings for equality where the first string can |
| 48300 | 48238 | ** potentially be a "glob" expression. Return true (1) if they |
| 48301 | 48239 | ** are the same and false (0) if they are different. |
| 48302 | 48240 | ** |
| @@ -48327,101 +48265,106 @@ | ||
| 48327 | 48265 | const u8 *zPattern, /* The glob pattern */ |
| 48328 | 48266 | const u8 *zString, /* The string to compare against the glob */ |
| 48329 | 48267 | const struct compareInfo *pInfo, /* Information about how to do the compare */ |
| 48330 | 48268 | const int esc /* The escape character */ |
| 48331 | 48269 | ){ |
| 48332 | - register int c; | |
| 48270 | + int c, c2; | |
| 48333 | 48271 | int invert; |
| 48334 | 48272 | int seen; |
| 48335 | - int c2; | |
| 48336 | 48273 | u8 matchOne = pInfo->matchOne; |
| 48337 | 48274 | u8 matchAll = pInfo->matchAll; |
| 48338 | 48275 | u8 matchSet = pInfo->matchSet; |
| 48339 | 48276 | u8 noCase = pInfo->noCase; |
| 48340 | 48277 | int prevEscape = 0; /* True if the previous character was 'escape' */ |
| 48341 | 48278 | |
| 48342 | - while( (c = *zPattern)!=0 ){ | |
| 48279 | + while( (c = sqlite3Utf8Read(zPattern,0,&zPattern))!=0 ){ | |
| 48343 | 48280 | if( !prevEscape && c==matchAll ){ |
| 48344 | - while( (c=zPattern[1]) == matchAll || c == matchOne ){ | |
| 48345 | - if( c==matchOne ){ | |
| 48346 | - if( *zString==0 ) return 0; | |
| 48347 | - SQLITE_SKIP_UTF8(zString); | |
| 48348 | - } | |
| 48349 | - zPattern++; | |
| 48350 | - } | |
| 48351 | - if( c && esc && sqlite3ReadUtf8(&zPattern[1])==esc ){ | |
| 48352 | - u8 const *zTemp = &zPattern[1]; | |
| 48353 | - SQLITE_SKIP_UTF8(zTemp); | |
| 48354 | - c = *zTemp; | |
| 48355 | - } | |
| 48356 | - if( c==0 ) return 1; | |
| 48357 | - if( c==matchSet ){ | |
| 48358 | - assert( esc==0 ); /* This is GLOB, not LIKE */ | |
| 48359 | - while( *zString && patternCompare(&zPattern[1],zString,pInfo,esc)==0 ){ | |
| 48281 | + while( (c=sqlite3Utf8Read(zPattern,0,&zPattern)) == matchAll | |
| 48282 | + || c == matchOne ){ | |
| 48283 | + if( c==matchOne && sqlite3Utf8Read(zString, 0, &zString)==0 ){ | |
| 48284 | + return 0; | |
| 48285 | + } | |
| 48286 | + } | |
| 48287 | + if( c==0 ){ | |
| 48288 | + return 1; | |
| 48289 | + }else if( c==esc ){ | |
| 48290 | + c = sqlite3Utf8Read(zPattern, 0, &zPattern); | |
| 48291 | + if( c==0 ){ | |
| 48292 | + return 0; | |
| 48293 | + } | |
| 48294 | + }else if( c==matchSet ){ | |
| 48295 | + assert( esc==0 ); /* This is GLOB, not LIKE */ | |
| 48296 | + assert( matchSet<0x80 ); /* '[' is a single-byte character */ | |
| 48297 | + while( *zString && patternCompare(&zPattern[-1],zString,pInfo,esc)==0 ){ | |
| 48360 | 48298 | SQLITE_SKIP_UTF8(zString); |
| 48361 | 48299 | } |
| 48362 | 48300 | return *zString!=0; |
| 48363 | - }else{ | |
| 48364 | - while( (c2 = *zString)!=0 ){ | |
| 48365 | - if( noCase ){ | |
| 48366 | - c2 = sqlite3UpperToLower[c2]; | |
| 48367 | - c = sqlite3UpperToLower[c]; | |
| 48368 | - while( c2 != 0 && c2 != c ){ c2 = sqlite3UpperToLower[*++zString]; } | |
| 48369 | - }else{ | |
| 48370 | - while( c2 != 0 && c2 != c ){ c2 = *++zString; } | |
| 48371 | - } | |
| 48372 | - if( c2==0 ) return 0; | |
| 48373 | - if( patternCompare(&zPattern[1],zString,pInfo,esc) ) return 1; | |
| 48374 | - SQLITE_SKIP_UTF8(zString); | |
| 48375 | - } | |
| 48301 | + } | |
| 48302 | + while( (c2 = sqlite3Utf8Read(zString,0,&zString))!=0 ){ | |
| 48303 | + if( noCase ){ | |
| 48304 | + c2 = c2<0x80 ? sqlite3UpperToLower[c2] : c2; | |
| 48305 | + c = c<0x80 ? sqlite3UpperToLower[c] : c; | |
| 48306 | + while( c2 != 0 && c2 != c ){ | |
| 48307 | + c2 = sqlite3Utf8Read(zString, 0, &zString); | |
| 48308 | + if( c2<0x80 ) c2 = sqlite3UpperToLower[c2]; | |
| 48309 | + } | |
| 48310 | + }else{ | |
| 48311 | + while( c2 != 0 && c2 != c ){ | |
| 48312 | + c2 = sqlite3Utf8Read(zString, 0, &zString); | |
| 48313 | + } | |
| 48314 | + } | |
| 48315 | + if( c2==0 ) return 0; | |
| 48316 | + if( patternCompare(zPattern,zString,pInfo,esc) ) return 1; | |
| 48317 | + } | |
| 48318 | + return 0; | |
| 48319 | + }else if( !prevEscape && c==matchOne ){ | |
| 48320 | + if( sqlite3Utf8Read(zString, 0, &zString)==0 ){ | |
| 48376 | 48321 | return 0; |
| 48377 | 48322 | } |
| 48378 | - }else if( !prevEscape && c==matchOne ){ | |
| 48379 | - if( *zString==0 ) return 0; | |
| 48380 | - SQLITE_SKIP_UTF8(zString); | |
| 48381 | - zPattern++; | |
| 48382 | 48323 | }else if( c==matchSet ){ |
| 48383 | 48324 | int prior_c = 0; |
| 48384 | 48325 | assert( esc==0 ); /* This only occurs for GLOB, not LIKE */ |
| 48385 | 48326 | seen = 0; |
| 48386 | 48327 | invert = 0; |
| 48387 | - c = sqlite3ReadUtf8(zString); | |
| 48388 | - if( c==0 ) return 0; | |
| 48389 | - c2 = *++zPattern; | |
| 48390 | - if( c2=='^' ){ invert = 1; c2 = *++zPattern; } | |
| 48391 | - if( c2==']' ){ | |
| 48392 | - if( c==']' ) seen = 1; | |
| 48393 | - c2 = *++zPattern; | |
| 48394 | - } | |
| 48395 | - while( (c2 = sqlite3ReadUtf8(zPattern))!=0 && c2!=']' ){ | |
| 48396 | - if( c2=='-' && zPattern[1]!=']' && zPattern[1]!=0 && prior_c>0 ){ | |
| 48397 | - zPattern++; | |
| 48398 | - c2 = sqlite3ReadUtf8(zPattern); | |
| 48399 | - if( c>=prior_c && c<=c2 ) seen = 1; | |
| 48400 | - prior_c = 0; | |
| 48401 | - }else if( c==c2 ){ | |
| 48402 | - seen = 1; | |
| 48403 | - prior_c = c2; | |
| 48404 | - }else{ | |
| 48405 | - prior_c = c2; | |
| 48406 | - } | |
| 48407 | - SQLITE_SKIP_UTF8(zPattern); | |
| 48408 | - } | |
| 48409 | - if( c2==0 || (seen ^ invert)==0 ) return 0; | |
| 48410 | - SQLITE_SKIP_UTF8(zString); | |
| 48411 | - zPattern++; | |
| 48412 | - }else if( esc && !prevEscape && sqlite3ReadUtf8(zPattern)==esc){ | |
| 48413 | - prevEscape = 1; | |
| 48414 | - SQLITE_SKIP_UTF8(zPattern); | |
| 48415 | - }else{ | |
| 48416 | - if( noCase ){ | |
| 48417 | - if( sqlite3UpperToLower[c] != sqlite3UpperToLower[*zString] ) return 0; | |
| 48418 | - }else{ | |
| 48419 | - if( c != *zString ) return 0; | |
| 48420 | - } | |
| 48421 | - zPattern++; | |
| 48422 | - zString++; | |
| 48328 | + c = sqlite3Utf8Read(zString, 0, &zString); | |
| 48329 | + if( c==0 ) return 0; | |
| 48330 | + c2 = sqlite3Utf8Read(zPattern, 0, &zPattern); | |
| 48331 | + if( c2=='^' ){ | |
| 48332 | + invert = 1; | |
| 48333 | + c2 = sqlite3Utf8Read(zPattern, 0, &zPattern); | |
| 48334 | + } | |
| 48335 | + if( c2==']' ){ | |
| 48336 | + if( c==']' ) seen = 1; | |
| 48337 | + c2 = sqlite3Utf8Read(zPattern, 0, &zPattern); | |
| 48338 | + } | |
| 48339 | + while( c2 && c2!=']' ){ | |
| 48340 | + if( c2=='-' && zPattern[0]!=']' && zPattern[0]!=0 && prior_c>0 ){ | |
| 48341 | + c2 = sqlite3Utf8Read(zPattern, 0, &zPattern); | |
| 48342 | + if( c>=prior_c && c<=c2 ) seen = 1; | |
| 48343 | + prior_c = 0; | |
| 48344 | + }else{ | |
| 48345 | + if( c==c2 ){ | |
| 48346 | + seen = 1; | |
| 48347 | + } | |
| 48348 | + prior_c = c2; | |
| 48349 | + } | |
| 48350 | + c2 = sqlite3Utf8Read(zPattern, 0, &zPattern); | |
| 48351 | + } | |
| 48352 | + if( c2==0 || (seen ^ invert)==0 ){ | |
| 48353 | + return 0; | |
| 48354 | + } | |
| 48355 | + }else if( esc==c && !prevEscape ){ | |
| 48356 | + prevEscape = 1; | |
| 48357 | + }else{ | |
| 48358 | + c2 = sqlite3Utf8Read(zString, 0, &zString); | |
| 48359 | + if( noCase ){ | |
| 48360 | + c = c<0x80 ? sqlite3UpperToLower[c] : c; | |
| 48361 | + c2 = c2<0x80 ? sqlite3UpperToLower[c2] : c2; | |
| 48362 | + } | |
| 48363 | + if( c!=c2 ){ | |
| 48364 | + return 0; | |
| 48365 | + } | |
| 48423 | 48366 | prevEscape = 0; |
| 48424 | 48367 | } |
| 48425 | 48368 | } |
| 48426 | 48369 | return *zString==0; |
| 48427 | 48370 | } |
| @@ -48477,11 +48420,11 @@ | ||
| 48477 | 48420 | if( sqlite3Utf8CharLen((char*)zEsc, -1)!=1 ){ |
| 48478 | 48421 | sqlite3_result_error(context, |
| 48479 | 48422 | "ESCAPE expression must be a single character", -1); |
| 48480 | 48423 | return; |
| 48481 | 48424 | } |
| 48482 | - escape = sqlite3ReadUtf8(zEsc); | |
| 48425 | + escape = sqlite3Utf8Read(zEsc, 0, &zEsc); | |
| 48483 | 48426 | } |
| 48484 | 48427 | if( zA && zB ){ |
| 48485 | 48428 | struct compareInfo *pInfo = sqlite3_user_data(context); |
| 48486 | 48429 | #ifdef SQLITE_TEST |
| 48487 | 48430 | sqlite3_like_count++; |
| @@ -49395,11 +49338,11 @@ | ||
| 49395 | 49338 | ** |
| 49396 | 49339 | ************************************************************************* |
| 49397 | 49340 | ** This file contains C code routines that are called by the parser |
| 49398 | 49341 | ** to handle INSERT statements in SQLite. |
| 49399 | 49342 | ** |
| 49400 | -** $Id: insert.c,v 1.187 2007/06/26 10:38:55 danielk1977 Exp $ | |
| 49343 | +** $Id: insert.c,v 1.188 2007/07/23 19:39:47 drh Exp $ | |
| 49401 | 49344 | */ |
| 49402 | 49345 | |
| 49403 | 49346 | /* |
| 49404 | 49347 | ** Set P3 of the most recently inserted opcode to a column affinity |
| 49405 | 49348 | ** string for index pIdx. A column affinity string has one character |
| @@ -50409,11 +50352,11 @@ | ||
| 50409 | 50352 | pParse->ckOffset = nCol; |
| 50410 | 50353 | sqlite3ExprIfTrue(pParse, pTab->pCheck, allOk, 1); |
| 50411 | 50354 | assert( pParse->ckOffset==nCol ); |
| 50412 | 50355 | pParse->ckOffset = 0; |
| 50413 | 50356 | onError = overrideError!=OE_Default ? overrideError : OE_Abort; |
| 50414 | - if( onError==OE_Ignore || onError==OE_Replace ){ | |
| 50357 | + if( onError==OE_Ignore ){ | |
| 50415 | 50358 | sqlite3VdbeAddOp(v, OP_Pop, nCol+1+hasTwoRowids, 0); |
| 50416 | 50359 | sqlite3VdbeAddOp(v, OP_Goto, 0, ignoreDest); |
| 50417 | 50360 | }else{ |
| 50418 | 50361 | sqlite3VdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError); |
| 50419 | 50362 | } |
| @@ -51155,20 +51098,26 @@ | ||
| 51155 | 51098 | ** shared libraries that want to be imported as extensions into |
| 51156 | 51099 | ** an SQLite instance. Shared libraries that intend to be loaded |
| 51157 | 51100 | ** as extensions by SQLite should #include this file instead of |
| 51158 | 51101 | ** sqlite3.h. |
| 51159 | 51102 | ** |
| 51160 | -** @(#) $Id: sqlite3ext.h,v 1.11 2007/06/22 15:21:16 danielk1977 Exp $ | |
| 51103 | +** @(#) $Id: sqlite3ext.h,v 1.12 2007/07/20 10:48:36 drh Exp $ | |
| 51161 | 51104 | */ |
| 51162 | 51105 | #ifndef _SQLITE3EXT_H_ |
| 51163 | 51106 | #define _SQLITE3EXT_H_ |
| 51164 | 51107 | |
| 51165 | 51108 | typedef struct sqlite3_api_routines sqlite3_api_routines; |
| 51166 | 51109 | |
| 51167 | 51110 | /* |
| 51168 | 51111 | ** The following structure hold pointers to all of the SQLite API |
| 51169 | 51112 | ** routines. |
| 51113 | +** | |
| 51114 | +** WARNING: In order to maintain backwards compatibility, add new | |
| 51115 | +** interfaces to the end of this structure only. If you insert new | |
| 51116 | +** interfaces in the middle of this structure, then older different | |
| 51117 | +** versions of SQLite will not be able to load each others shared | |
| 51118 | +** libraries! | |
| 51170 | 51119 | */ |
| 51171 | 51120 | struct sqlite3_api_routines { |
| 51172 | 51121 | void * (*aggregate_context)(sqlite3_context*,int nBytes); |
| 51173 | 51122 | int (*aggregate_count)(sqlite3_context*); |
| 51174 | 51123 | int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*)); |
| @@ -51215,11 +51164,10 @@ | ||
| 51215 | 51164 | int (*create_collation)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*)); |
| 51216 | 51165 | int (*create_collation16)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*)); |
| 51217 | 51166 | int (*create_function)(sqlite3*,const char*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*)); |
| 51218 | 51167 | int (*create_function16)(sqlite3*,const void*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*)); |
| 51219 | 51168 | int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*); |
| 51220 | - int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,void (*xDestroy)(void *)); | |
| 51221 | 51169 | int (*data_count)(sqlite3_stmt*pStmt); |
| 51222 | 51170 | sqlite3 * (*db_handle)(sqlite3_stmt*); |
| 51223 | 51171 | int (*declare_vtab)(sqlite3*,const char*); |
| 51224 | 51172 | int (*enable_shared_cache)(int); |
| 51225 | 51173 | int (*errcode)(sqlite3*db); |
| @@ -51287,10 +51235,11 @@ | ||
| 51287 | 51235 | char *(*vmprintf)(const char*,va_list); |
| 51288 | 51236 | int (*overload_function)(sqlite3*, const char *zFuncName, int nArg); |
| 51289 | 51237 | int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**); |
| 51290 | 51238 | int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); |
| 51291 | 51239 | int (*clear_bindings)(sqlite3_stmt*); |
| 51240 | + int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,void (*xDestroy)(void *)); | |
| 51292 | 51241 | }; |
| 51293 | 51242 | |
| 51294 | 51243 | /* |
| 51295 | 51244 | ** The following macros redefine the API routines so that they are |
| 51296 | 51245 | ** redirected throught the global sqlite3_api structure. |
| @@ -51570,11 +51519,10 @@ | ||
| 51570 | 51519 | sqlite3_create_collation, |
| 51571 | 51520 | sqlite3_create_collation16, |
| 51572 | 51521 | sqlite3_create_function, |
| 51573 | 51522 | sqlite3_create_function16, |
| 51574 | 51523 | sqlite3_create_module, |
| 51575 | - sqlite3_create_module_v2, | |
| 51576 | 51524 | sqlite3_data_count, |
| 51577 | 51525 | sqlite3_db_handle, |
| 51578 | 51526 | sqlite3_declare_vtab, |
| 51579 | 51527 | sqlite3_enable_shared_cache, |
| 51580 | 51528 | sqlite3_errcode, |
| @@ -51654,10 +51602,16 @@ | ||
| 51654 | 51602 | ** Added after 3.3.13 |
| 51655 | 51603 | */ |
| 51656 | 51604 | sqlite3_prepare_v2, |
| 51657 | 51605 | sqlite3_prepare16_v2, |
| 51658 | 51606 | sqlite3_clear_bindings, |
| 51607 | + | |
| 51608 | + /* | |
| 51609 | + ** Added for 3.4.1 | |
| 51610 | + */ | |
| 51611 | + sqlite3_create_module_v2, | |
| 51612 | + | |
| 51659 | 51613 | }; |
| 51660 | 51614 | |
| 51661 | 51615 | /* |
| 51662 | 51616 | ** Attempt to load an SQLite extension library contained in the file |
| 51663 | 51617 | ** zFile. The entry point is zProc. zProc may be 0 in which case a |
| @@ -53737,11 +53691,11 @@ | ||
| 53737 | 53691 | ** |
| 53738 | 53692 | ************************************************************************* |
| 53739 | 53693 | ** This file contains C code routines that are called by the parser |
| 53740 | 53694 | ** to handle SELECT statements in SQLite. |
| 53741 | 53695 | ** |
| 53742 | -** $Id: select.c,v 1.353 2007/06/26 10:38:55 danielk1977 Exp $ | |
| 53696 | +** $Id: select.c,v 1.354 2007/07/18 18:17:12 drh Exp $ | |
| 53743 | 53697 | */ |
| 53744 | 53698 | |
| 53745 | 53699 | |
| 53746 | 53700 | /* |
| 53747 | 53701 | ** Delete all the content of a Select structure but do not deallocate |
| @@ -56237,10 +56191,20 @@ | ||
| 56237 | 56191 | (char*)pKey, P3_KEYINFO_HANDOFF); |
| 56238 | 56192 | if( seekOp==OP_Rewind ){ |
| 56239 | 56193 | sqlite3VdbeAddOp(v, OP_Null, 0, 0); |
| 56240 | 56194 | sqlite3VdbeAddOp(v, OP_MakeRecord, 1, 0); |
| 56241 | 56195 | seekOp = OP_MoveGt; |
| 56196 | + } | |
| 56197 | + if( pIdx->aSortOrder[0]==SQLITE_SO_DESC ){ | |
| 56198 | + /* Ticket #2514: invert the seek operator if we are using | |
| 56199 | + ** a descending index. */ | |
| 56200 | + if( seekOp==OP_Last ){ | |
| 56201 | + seekOp = OP_Rewind; | |
| 56202 | + }else{ | |
| 56203 | + assert( seekOp==OP_MoveGt ); | |
| 56204 | + seekOp = OP_MoveLt; | |
| 56205 | + } | |
| 56242 | 56206 | } |
| 56243 | 56207 | sqlite3VdbeAddOp(v, seekOp, iIdx, 0); |
| 56244 | 56208 | sqlite3VdbeAddOp(v, OP_IdxRowid, iIdx, 0); |
| 56245 | 56209 | sqlite3VdbeAddOp(v, OP_Close, iIdx, 0); |
| 56246 | 56210 | sqlite3VdbeAddOp(v, OP_MoveGe, base, 0); |
| @@ -65805,11 +65769,11 @@ | ||
| 65805 | 65769 | ** |
| 65806 | 65770 | ** This file contains C code that splits an SQL input string up into |
| 65807 | 65771 | ** individual tokens and sends those tokens one-by-one over to the |
| 65808 | 65772 | ** parser for analysis. |
| 65809 | 65773 | ** |
| 65810 | -** $Id: tokenize.c,v 1.130 2007/07/13 10:26:08 drh Exp $ | |
| 65774 | +** $Id: tokenize.c,v 1.131 2007/07/23 19:31:17 drh Exp $ | |
| 65811 | 65775 | */ |
| 65812 | 65776 | |
| 65813 | 65777 | /* |
| 65814 | 65778 | ** The charMap() macro maps alphabetic characters into their |
| 65815 | 65779 | ** lower-case ASCII equivalent. On ASCII machines, this is just |
| @@ -66282,17 +66246,10 @@ | ||
| 66282 | 66246 | } |
| 66283 | 66247 | SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){ |
| 66284 | 66248 | return getToken(z, tokenType); |
| 66285 | 66249 | } |
| 66286 | 66250 | |
| 66287 | -/* | |
| 66288 | -** The interface to the LEMON-generated parser | |
| 66289 | -*/ | |
| 66290 | -SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(size_t)); | |
| 66291 | -SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*)); | |
| 66292 | -SQLITE_PRIVATE void sqlite3Parser(void*, int, Token, Parse*); | |
| 66293 | - | |
| 66294 | 66251 | /* |
| 66295 | 66252 | ** Run the parser on the given SQL string. The parser structure is |
| 66296 | 66253 | ** passed in. An SQLITE_ status code is returned. If an error occurs |
| 66297 | 66254 | ** and pzErrMsg!=NULL then an error message might be written into |
| 66298 | 66255 | ** memory obtained from malloc() and *pzErrMsg made to point to that |
| 66299 | 66256 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -1,8 +1,8 @@ | |
| 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.4.0. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a one translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | ** of 5% are more are commonly seen when SQLite is compiled as a single |
| 8 | ** translation unit. |
| @@ -9,17 +9,17 @@ | |
| 9 | ** |
| 10 | ** This file is all you need to compile SQLite. To use SQLite in other |
| 11 | ** programs, you need this file and the "sqlite3.h" header file that defines |
| 12 | ** the programming interface to the SQLite library. (If you do not have |
| 13 | ** the "sqlite3.h" header file at hand, you will find a copy in the first |
| 14 | ** 2698 lines past this header comment.) Additional code files may be |
| 15 | ** needed if you want a wrapper to interface SQLite with your choice of |
| 16 | ** programming language. The code for the "sqlite3" command-line shell |
| 17 | ** is also in a separate file. This file contains only code for the core |
| 18 | ** SQLite library. |
| 19 | ** |
| 20 | ** This amalgamation was generated on 2007-07-17 16:48:46 UTC. |
| 21 | */ |
| 22 | #define SQLITE_AMALGAMATION 1 |
| 23 | #ifndef SQLITE_PRIVATE |
| 24 | # define SQLITE_PRIVATE static |
| 25 | #endif |
| @@ -57,11 +57,11 @@ | |
| 57 | ** The name of this file under configuration management is "sqlite.h.in". |
| 58 | ** The makefile makes some minor changes to this file (such as inserting |
| 59 | ** the version number) and changes its name to "sqlite3.h" as |
| 60 | ** part of the build process. |
| 61 | ** |
| 62 | ** @(#) $Id: sqlite.h.in,v 1.217 2007/06/27 15:53:35 danielk1977 Exp $ |
| 63 | */ |
| 64 | #ifndef _SQLITE3_H_ |
| 65 | #define _SQLITE3_H_ |
| 66 | #include <stdarg.h> /* Needed for the definition of va_list */ |
| 67 | |
| @@ -108,12 +108,12 @@ | |
| 108 | ** version 3.1.1 or greater at compile time, programs may use the test |
| 109 | ** (SQLITE_VERSION_NUMBER>=3001001). |
| 110 | ** |
| 111 | ** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()]. |
| 112 | */ |
| 113 | #define SQLITE_VERSION "3.4.0" |
| 114 | #define SQLITE_VERSION_NUMBER 3004000 |
| 115 | |
| 116 | /* |
| 117 | ** CAPI3REF: Run-Time Library Version Numbers |
| 118 | ** |
| 119 | ** These routines return values equivalent to the header constants |
| @@ -990,14 +990,18 @@ | |
| 990 | ** The first argument "db" is an [sqlite3 | SQLite database handle] |
| 991 | ** obtained from a prior call to [sqlite3_open()] or [sqlite3_open16()]. |
| 992 | ** The second argument "zSql" is the statement to be compiled, encoded |
| 993 | ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() |
| 994 | ** interfaces uses UTF-8 and sqlite3_prepare16() and sqlite3_prepare16_v2() |
| 995 | ** use UTF-16. If the next argument, "nBytes", is less |
| 996 | ** than zero, then zSql is read up to the first zero terminator. If |
| 997 | ** "nBytes" is not less than zero, then it is the length of the string zSql |
| 998 | ** in bytes (not characters). |
| 999 | ** |
| 1000 | ** *pzTail is made to point to the first byte past the end of the first |
| 1001 | ** SQL statement in zSql. This routine only compiles the first statement |
| 1002 | ** in zSql, so *pzTail is left pointing to what remains uncompiled. |
| 1003 | ** |
| @@ -1046,32 +1050,32 @@ | |
| 1046 | ** </ol> |
| 1047 | */ |
| 1048 | SQLITE_API int sqlite3_prepare( |
| 1049 | sqlite3 *db, /* Database handle */ |
| 1050 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
| 1051 | int nBytes, /* Length of zSql in bytes. */ |
| 1052 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1053 | const char **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1054 | ); |
| 1055 | int sqlite3_prepare_v2( |
| 1056 | sqlite3 *db, /* Database handle */ |
| 1057 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
| 1058 | int nBytes, /* Length of zSql in bytes. */ |
| 1059 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1060 | const char **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1061 | ); |
| 1062 | SQLITE_API int sqlite3_prepare16( |
| 1063 | sqlite3 *db, /* Database handle */ |
| 1064 | const void *zSql, /* SQL statement, UTF-16 encoded */ |
| 1065 | int nBytes, /* Length of zSql in bytes. */ |
| 1066 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1067 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1068 | ); |
| 1069 | int sqlite3_prepare16_v2( |
| 1070 | sqlite3 *db, /* Database handle */ |
| 1071 | const void *zSql, /* SQL statement, UTF-16 encoded */ |
| 1072 | int nBytes, /* Length of zSql in bytes. */ |
| 1073 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1074 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1075 | ); |
| 1076 | |
| 1077 | /* |
| @@ -2788,11 +2792,11 @@ | |
| 2788 | ** May you share freely, never taking more than you give. |
| 2789 | ** |
| 2790 | ************************************************************************* |
| 2791 | ** Internal interface definitions for SQLite. |
| 2792 | ** |
| 2793 | ** @(#) $Id: sqliteInt.h,v 1.578 2007/06/26 10:38:55 danielk1977 Exp $ |
| 2794 | */ |
| 2795 | #ifndef _SQLITEINT_H_ |
| 2796 | #define _SQLITEINT_H_ |
| 2797 | /************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/ |
| 2798 | /************** Begin file sqliteLimit.h *************************************/ |
| @@ -5919,65 +5923,18 @@ | |
| 5919 | * even when no triggers exist |
| 5920 | */ |
| 5921 | extern int sqlite3_always_code_trigger_setup; |
| 5922 | |
| 5923 | /* |
| 5924 | ** A lookup table used by the SQLITE_READ_UTF8 macro. The definition |
| 5925 | ** is in utf.c. |
| 5926 | */ |
| 5927 | extern const unsigned char sqlite3UtfTrans1[]; |
| 5928 | |
| 5929 | /* |
| 5930 | ** Macros for reading UTF8 characters. |
| 5931 | ** |
| 5932 | ** SQLITE_READ_UTF8(x,c) reads a single UTF8 value out of x and writes |
| 5933 | ** that value into c. The type of x must be unsigned char*. The type |
| 5934 | ** of c must be unsigned int. |
| 5935 | ** |
| 5936 | ** SQLITE_SKIP_UTF8(x) advances x forward by one character. The type of |
| 5937 | ** x must be unsigned char*. |
| 5938 | ** |
| 5939 | ** Notes On Invalid UTF-8: |
| 5940 | ** |
| 5941 | ** * These macros never allow a 7-bit character (0x00 through 0x7f) to |
| 5942 | ** be encoded as a multi-byte character. Any multi-byte character that |
| 5943 | ** attempts to encode a value between 0x00 and 0x7f is rendered as 0xfffd. |
| 5944 | ** |
| 5945 | ** * These macros never allow a UTF16 surrogate value to be encoded. |
| 5946 | ** If a multi-byte character attempts to encode a value between |
| 5947 | ** 0xd800 and 0xe000 then it is rendered as 0xfffd. |
| 5948 | ** |
| 5949 | ** * Bytes in the range of 0x80 through 0xbf which occur as the first |
| 5950 | ** byte of a character are interpreted as single-byte characters |
| 5951 | ** and rendered as themselves even though they are technically |
| 5952 | ** invalid characters. |
| 5953 | ** |
| 5954 | ** * These routines accept an infinite number of different UTF8 encodings |
| 5955 | ** for unicode values 0x80 and greater. They do not change over-length |
| 5956 | ** encodings to 0xfffd as some systems recommend. |
| 5957 | ** |
| 5958 | */ |
| 5959 | #define SQLITE_READ_UTF8(zIn, c) { \ |
| 5960 | c = *(zIn++); \ |
| 5961 | if( c>=0xc0 ){ \ |
| 5962 | c = sqlite3UtfTrans1[c-0xc0]; \ |
| 5963 | while( (*zIn & 0xc0)==0x80 ){ \ |
| 5964 | c = (c<<6) + (0x3f & *(zIn++)); \ |
| 5965 | } \ |
| 5966 | if( c<0x80 \ |
| 5967 | || (c&0xFFFFF800)==0xD800 \ |
| 5968 | || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \ |
| 5969 | } \ |
| 5970 | } |
| 5971 | #define SQLITE_SKIP_UTF8(zIn) { \ |
| 5972 | if( (*(zIn++))>=0xc0 ){ \ |
| 5973 | while( (*zIn & 0xc0)==0x80 ){ zIn++; } \ |
| 5974 | } \ |
| 5975 | } |
| 5976 | |
| 5977 | |
| 5978 | |
| 5979 | |
| 5980 | /* |
| 5981 | ** The SQLITE_CORRUPT_BKPT macro can be either a constant (for production |
| 5982 | ** builds) or a function call (for debugging). If it is a function call, |
| 5983 | ** it allows the operator to set a breakpoint at the spot where database |
| @@ -6193,11 +6150,11 @@ | |
| 6193 | SQLITE_API char *sqlite3_snprintf(int,char*,const char*,...); |
| 6194 | SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*); |
| 6195 | SQLITE_PRIVATE int sqlite3FitsIn64Bits(const char *); |
| 6196 | SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar); |
| 6197 | SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte); |
| 6198 | SQLITE_PRIVATE u32 sqlite3ReadUtf8(const unsigned char *); |
| 6199 | SQLITE_PRIVATE int sqlite3PutVarint(unsigned char *, u64); |
| 6200 | SQLITE_PRIVATE int sqlite3GetVarint(const unsigned char *, u64 *); |
| 6201 | SQLITE_PRIVATE int sqlite3GetVarint32(const unsigned char *, u32 *); |
| 6202 | SQLITE_PRIVATE int sqlite3VarintLen(u64 v); |
| 6203 | SQLITE_PRIVATE void sqlite3IndexAffinityStr(Vdbe *, Index *); |
| @@ -6265,10 +6222,17 @@ | |
| 6265 | SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int); |
| 6266 | SQLITE_PRIVATE void sqlite3FailedMalloc(void); |
| 6267 | SQLITE_PRIVATE void sqlite3AbortOtherActiveVdbes(sqlite3 *, Vdbe *); |
| 6268 | SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *); |
| 6269 | |
| 6270 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 6271 | SQLITE_PRIVATE void sqlite3CloseExtensions(sqlite3*); |
| 6272 | SQLITE_PRIVATE int sqlite3AutoLoadExtensions(sqlite3*); |
| 6273 | #else |
| 6274 | # define sqlite3CloseExtensions(X) |
| @@ -9286,11 +9250,11 @@ | |
| 9286 | ** |
| 9287 | ************************************************************************* |
| 9288 | ** This file contains routines used to translate between UTF-8, |
| 9289 | ** UTF-16, UTF-16BE, and UTF-16LE. |
| 9290 | ** |
| 9291 | ** $Id: utf.c,v 1.51 2007/05/23 16:23:09 danielk1977 Exp $ |
| 9292 | ** |
| 9293 | ** Notes on UTF-8: |
| 9294 | ** |
| 9295 | ** Byte-0 Byte-1 Byte-2 Byte-3 Value |
| 9296 | ** 0xxxxxxx 00000000 00000000 0xxxxxxx |
| @@ -9764,10 +9728,11 @@ | |
| 9764 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
| 9765 | 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 9766 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
| 9767 | 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00, |
| 9768 | }; |
| 9769 | |
| 9770 | #define WRITE_UTF8(zOut, c) { \ |
| 9771 | if( c<0x00080 ){ \ |
| 9772 | *zOut++ = (c&0xFF); \ |
| 9773 | } \ |
| @@ -9830,10 +9795,58 @@ | |
| 9830 | c2 += (*zIn++); \ |
| 9831 | c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \ |
| 9832 | if( (c & 0xFFFF0000)==0 ) c = 0xFFFD; \ |
| 9833 | } \ |
| 9834 | } |
| 9835 | |
| 9836 | /* |
| 9837 | ** If the TRANSLATE_TRACE macro is defined, the value of each Mem is |
| 9838 | ** printed on stderr on the way into and out of sqlite3VdbeMemTranslate(). |
| 9839 | */ |
| @@ -9924,85 +9937,23 @@ | |
| 9924 | zOut = zShort; |
| 9925 | } |
| 9926 | z = zOut; |
| 9927 | |
| 9928 | if( pMem->enc==SQLITE_UTF8 ){ |
| 9929 | unsigned int iExtra = 0xD800; |
| 9930 | |
| 9931 | if( 0==(pMem->flags&MEM_Term) && zTerm>zIn && (zTerm[-1]&0x80) ){ |
| 9932 | /* This UTF8 string is not nul-terminated, and the last byte is |
| 9933 | ** not a character in the ascii range (codpoints 0..127). This |
| 9934 | ** means the SQLITE_READ_UTF8() macro might read past the end |
| 9935 | ** of the allocated buffer. |
| 9936 | ** |
| 9937 | ** There are four possibilities: |
| 9938 | ** |
| 9939 | ** 1. The last byte is the first byte of a non-ASCII character, |
| 9940 | ** |
| 9941 | ** 2. The final N bytes of the input string are continuation bytes |
| 9942 | ** and immediately preceding them is the first byte of a |
| 9943 | ** non-ASCII character. |
| 9944 | ** |
| 9945 | ** 3. The final N bytes of the input string are continuation bytes |
| 9946 | ** and immediately preceding them is a byte that encodes a |
| 9947 | ** character in the ASCII range. |
| 9948 | ** |
| 9949 | ** 4. The entire string consists of continuation characters. |
| 9950 | ** |
| 9951 | ** Cases (3) and (4) require no special handling. The SQLITE_READ_UTF8() |
| 9952 | ** macro will not overread the buffer in these cases. |
| 9953 | */ |
| 9954 | unsigned char *zExtra = &zTerm[-1]; |
| 9955 | while( zExtra>zIn && (zExtra[0]&0xC0)==0x80 ){ |
| 9956 | zExtra--; |
| 9957 | } |
| 9958 | |
| 9959 | if( (zExtra[0]&0xC0)==0xC0 ){ |
| 9960 | /* Make a copy of the last character encoding in the input string. |
| 9961 | ** Then make sure it is nul-terminated and use SQLITE_READ_UTF8() |
| 9962 | ** to decode the codepoint. Store the codepoint in variable iExtra, |
| 9963 | ** it will be appended to the output string later. |
| 9964 | */ |
| 9965 | unsigned char *zFree = 0; |
| 9966 | unsigned char zBuf[16]; |
| 9967 | int nExtra = (pMem->n+zIn-zExtra); |
| 9968 | zTerm = zExtra; |
| 9969 | if( nExtra>15 ){ |
| 9970 | zExtra = sqliteMallocRaw(nExtra+1); |
| 9971 | if( !zExtra ){ |
| 9972 | return SQLITE_NOMEM; |
| 9973 | } |
| 9974 | zFree = zExtra; |
| 9975 | }else{ |
| 9976 | zExtra = zBuf; |
| 9977 | } |
| 9978 | memcpy(zExtra, zTerm, nExtra); |
| 9979 | zExtra[nExtra] = '\0'; |
| 9980 | SQLITE_READ_UTF8(zExtra, iExtra); |
| 9981 | sqliteFree(zFree); |
| 9982 | } |
| 9983 | } |
| 9984 | |
| 9985 | if( desiredEnc==SQLITE_UTF16LE ){ |
| 9986 | /* UTF-8 -> UTF-16 Little-endian */ |
| 9987 | while( zIn<zTerm ){ |
| 9988 | SQLITE_READ_UTF8(zIn, c); |
| 9989 | WRITE_UTF16LE(z, c); |
| 9990 | } |
| 9991 | if( iExtra!=0xD800 ){ |
| 9992 | WRITE_UTF16LE(z, iExtra); |
| 9993 | } |
| 9994 | }else{ |
| 9995 | assert( desiredEnc==SQLITE_UTF16BE ); |
| 9996 | /* UTF-8 -> UTF-16 Big-endian */ |
| 9997 | while( zIn<zTerm ){ |
| 9998 | SQLITE_READ_UTF8(zIn, c); |
| 9999 | WRITE_UTF16BE(z, c); |
| 10000 | } |
| 10001 | if( iExtra!=0xD800 ){ |
| 10002 | WRITE_UTF16BE(z, iExtra); |
| 10003 | } |
| 10004 | } |
| 10005 | pMem->n = z - zOut; |
| 10006 | *z++ = 0; |
| 10007 | }else{ |
| 10008 | assert( desiredEnc==SQLITE_UTF8 ); |
| @@ -10182,15 +10133,15 @@ | |
| 10182 | ** correct UTF-8 encoding to be longer than a malformed encoding). |
| 10183 | */ |
| 10184 | SQLITE_PRIVATE int sqlite3Utf8To8(unsigned char *zIn){ |
| 10185 | unsigned char *zOut = zIn; |
| 10186 | unsigned char *zStart = zIn; |
| 10187 | int c; |
| 10188 | |
| 10189 | while(1){ |
| 10190 | SQLITE_READ_UTF8(zIn, c); |
| 10191 | if( c==0 ) break; |
| 10192 | if( c!=0xfffd ){ |
| 10193 | WRITE_UTF8(zOut, c); |
| 10194 | } |
| 10195 | } |
| 10196 | *zOut = 0; |
| @@ -10206,20 +10157,22 @@ | |
| 10206 | */ |
| 10207 | SQLITE_PRIVATE void sqlite3UtfSelfTest(){ |
| 10208 | unsigned int i, t; |
| 10209 | unsigned char zBuf[20]; |
| 10210 | unsigned char *z; |
| 10211 | int n; |
| 10212 | unsigned int c; |
| 10213 | |
| 10214 | for(i=0; i<0x00110000; i++){ |
| 10215 | z = zBuf; |
| 10216 | WRITE_UTF8(z, i); |
| 10217 | n = z-zBuf; |
| 10218 | z[0] = 0; |
| 10219 | z = zBuf; |
| 10220 | SQLITE_READ_UTF8(z, c); |
| 10221 | t = i; |
| 10222 | if( i>=0xD800 && i<=0xDFFF ) t = 0xFFFD; |
| 10223 | if( (i&0xFFFFFFFE)==0xFFFE ) t = 0xFFFD; |
| 10224 | assert( c==t ); |
| 10225 | assert( (z-zBuf)==n ); |
| @@ -17876,11 +17829,11 @@ | |
| 17876 | ** is separate from the database file. The pager also implements file |
| 17877 | ** locking to prevent two processes from writing the same database |
| 17878 | ** file simultaneously, or one process from reading the database while |
| 17879 | ** another is writing. |
| 17880 | ** |
| 17881 | ** @(#) $Id: pager.c,v 1.349 2007/06/26 22:10:12 drh Exp $ |
| 17882 | */ |
| 17883 | #ifndef SQLITE_OMIT_DISKIO |
| 17884 | |
| 17885 | /* |
| 17886 | ** Macros for troubleshooting. Normally turned off |
| @@ -18402,21 +18355,10 @@ | |
| 18402 | static int write32bits(OsFile *fd, u32 val){ |
| 18403 | char ac[4]; |
| 18404 | put32bits(ac, val); |
| 18405 | return sqlite3OsWrite(fd, ac, 4); |
| 18406 | } |
| 18407 | |
| 18408 | /* |
| 18409 | ** Read a 32-bit integer at offset 'offset' from the page identified by |
| 18410 | ** page header 'p'. |
| 18411 | */ |
| 18412 | static u32 retrieve32bits(PgHdr *p, int offset){ |
| 18413 | unsigned char *ac; |
| 18414 | ac = &((unsigned char*)PGHDR_TO_DATA(p))[offset]; |
| 18415 | return sqlite3Get4byte(ac); |
| 18416 | } |
| 18417 | |
| 18418 | |
| 18419 | /* |
| 18420 | ** This function should be called when an error occurs within the pager |
| 18421 | ** code. The first argument is a pointer to the pager structure, the |
| 18422 | ** second the error-code about to be returned by a pager API function. |
| @@ -21725,14 +21667,12 @@ | |
| 21725 | rc = sqlite3PagerGet(pPager, 1, &pPgHdr); |
| 21726 | if( rc!=SQLITE_OK ) return rc; |
| 21727 | rc = sqlite3PagerWrite(pPgHdr); |
| 21728 | if( rc!=SQLITE_OK ) return rc; |
| 21729 | |
| 21730 | /* Read the current value at byte 24. */ |
| 21731 | change_counter = retrieve32bits(pPgHdr, 24); |
| 21732 | |
| 21733 | /* Increment the value just read and write it back to byte 24. */ |
| 21734 | change_counter++; |
| 21735 | put32bits(((char*)PGHDR_TO_DATA(pPgHdr))+24, change_counter); |
| 21736 | /* Release the page reference. */ |
| 21737 | sqlite3PagerUnref(pPgHdr); |
| 21738 | pPager->changeCountDone = 1; |
| @@ -22347,11 +22287,11 @@ | |
| 22347 | ** May you do good and not evil. |
| 22348 | ** May you find forgiveness for yourself and forgive others. |
| 22349 | ** May you share freely, never taking more than you give. |
| 22350 | ** |
| 22351 | ************************************************************************* |
| 22352 | ** $Id: btree.c,v 1.392 2007/06/26 01:04:49 drh Exp $ |
| 22353 | ** |
| 22354 | ** This file implements a external (disk-based) database using BTrees. |
| 22355 | ** See the header comment on "btreeInt.h" for additional information. |
| 22356 | ** Including a description of file format and an overview of operation. |
| 22357 | */ |
| @@ -24934,11 +24874,11 @@ | |
| 24934 | } |
| 24935 | if( rc==SQLITE_DONE ){ |
| 24936 | assert(nFin==0 || pBt->nTrunc==0 || nFin<=pBt->nTrunc); |
| 24937 | rc = SQLITE_OK; |
| 24938 | if( pBt->nTrunc ){ |
| 24939 | sqlite3PagerWrite(pBt->pPage1->pDbPage); |
| 24940 | put4byte(&pBt->pPage1->aData[32], 0); |
| 24941 | put4byte(&pBt->pPage1->aData[36], 0); |
| 24942 | pBt->nTrunc = nFin; |
| 24943 | } |
| 24944 | } |
| @@ -33573,11 +33513,11 @@ | |
| 33573 | ** documentation, headers files, or other derived files. The formatting |
| 33574 | ** of the code in this file is, therefore, important. See other comments |
| 33575 | ** in this file for details. If in doubt, do not deviate from existing |
| 33576 | ** commenting and indentation practices when changing or adding code. |
| 33577 | ** |
| 33578 | ** $Id: vdbe.c,v 1.636 2007/07/01 21:18:40 drh Exp $ |
| 33579 | */ |
| 33580 | |
| 33581 | /* |
| 33582 | ** The following global variable is incremented every time a cursor |
| 33583 | ** moves, either by the OP_MoveXX, OP_Next, or OP_Prev opcodes. The test |
| @@ -37824,18 +37764,18 @@ | |
| 37824 | |
| 37825 | for(nRoot=0; &pTos[-nRoot]>=p->aStack; nRoot++){ |
| 37826 | if( (pTos[-nRoot].flags & MEM_Int)==0 ) break; |
| 37827 | } |
| 37828 | assert( nRoot>0 ); |
| 37829 | aRoot = sqliteMallocRaw( sizeof(int*)*(nRoot+1) ); |
| 37830 | if( aRoot==0 ) goto no_mem; |
| 37831 | j = pOp->p1; |
| 37832 | assert( j>=0 && j<p->nMem ); |
| 37833 | pnErr = &p->aMem[j]; |
| 37834 | assert( (pnErr->flags & MEM_Int)!=0 ); |
| 37835 | for(j=0; j<nRoot; j++){ |
| 37836 | aRoot[j] = pTos[-j].u.i; |
| 37837 | } |
| 37838 | aRoot[j] = 0; |
| 37839 | popStack(&pTos, nRoot); |
| 37840 | pTos++; |
| 37841 | z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p2].pBt, aRoot, nRoot, |
| @@ -39076,11 +39016,11 @@ | |
| 39076 | ** |
| 39077 | ************************************************************************* |
| 39078 | ** This file contains routines used for analyzing expressions and |
| 39079 | ** for generating VDBE code that evaluates expressions in SQLite. |
| 39080 | ** |
| 39081 | ** $Id: expr.c,v 1.300 2007/06/25 16:29:34 danielk1977 Exp $ |
| 39082 | */ |
| 39083 | |
| 39084 | /* |
| 39085 | ** Return the 'affinity' of the expression pExpr if any. |
| 39086 | ** |
| @@ -40202,15 +40142,21 @@ | |
| 40202 | */ |
| 40203 | if( cnt==0 && (pEList = pNC->pEList)!=0 && zTab==0 ){ |
| 40204 | for(j=0; j<pEList->nExpr; j++){ |
| 40205 | char *zAs = pEList->a[j].zName; |
| 40206 | if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){ |
| 40207 | Expr *pDup; |
| 40208 | assert( pExpr->pLeft==0 && pExpr->pRight==0 ); |
| 40209 | assert( pExpr->pList==0 ); |
| 40210 | assert( pExpr->pSelect==0 ); |
| 40211 | pDup = sqlite3ExprDup(pEList->a[j].pExpr); |
| 40212 | if( pExpr->flags & EP_ExpCollate ){ |
| 40213 | pDup->pColl = pExpr->pColl; |
| 40214 | pDup->flags |= EP_ExpCollate; |
| 40215 | } |
| 40216 | if( pExpr->span.dyn ) sqliteFree((char*)pExpr->span.z); |
| @@ -47909,13 +47855,14 @@ | |
| 47909 | ** |
| 47910 | ** There is only one exported symbol in this file - the function |
| 47911 | ** sqliteRegisterBuildinFunctions() found at the bottom of the file. |
| 47912 | ** All other code has file scope. |
| 47913 | ** |
| 47914 | ** $Id: func.c,v 1.161 2007/06/22 15:21:16 danielk1977 Exp $ |
| 47915 | */ |
| 47916 | /* #include <math.h> */ |
| 47917 | |
| 47918 | /* |
| 47919 | ** Return the collating function associated with a function. |
| 47920 | */ |
| 47921 | static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){ |
| @@ -48284,19 +48231,10 @@ | |
| 48284 | static const struct compareInfo likeInfoNorm = { '%', '_', 0, 1 }; |
| 48285 | /* If SQLITE_CASE_SENSITIVE_LIKE is defined, then the LIKE operator |
| 48286 | ** is case sensitive causing 'a' LIKE 'A' to be false */ |
| 48287 | static const struct compareInfo likeInfoAlt = { '%', '_', 0, 0 }; |
| 48288 | |
| 48289 | /* |
| 48290 | ** Read a single UTF-8 character and return its value. |
| 48291 | */ |
| 48292 | SQLITE_PRIVATE u32 sqlite3ReadUtf8(const unsigned char *z){ |
| 48293 | u32 c; |
| 48294 | SQLITE_READ_UTF8(z, c); |
| 48295 | return c; |
| 48296 | } |
| 48297 | |
| 48298 | /* |
| 48299 | ** Compare two UTF-8 strings for equality where the first string can |
| 48300 | ** potentially be a "glob" expression. Return true (1) if they |
| 48301 | ** are the same and false (0) if they are different. |
| 48302 | ** |
| @@ -48327,101 +48265,106 @@ | |
| 48327 | const u8 *zPattern, /* The glob pattern */ |
| 48328 | const u8 *zString, /* The string to compare against the glob */ |
| 48329 | const struct compareInfo *pInfo, /* Information about how to do the compare */ |
| 48330 | const int esc /* The escape character */ |
| 48331 | ){ |
| 48332 | register int c; |
| 48333 | int invert; |
| 48334 | int seen; |
| 48335 | int c2; |
| 48336 | u8 matchOne = pInfo->matchOne; |
| 48337 | u8 matchAll = pInfo->matchAll; |
| 48338 | u8 matchSet = pInfo->matchSet; |
| 48339 | u8 noCase = pInfo->noCase; |
| 48340 | int prevEscape = 0; /* True if the previous character was 'escape' */ |
| 48341 | |
| 48342 | while( (c = *zPattern)!=0 ){ |
| 48343 | if( !prevEscape && c==matchAll ){ |
| 48344 | while( (c=zPattern[1]) == matchAll || c == matchOne ){ |
| 48345 | if( c==matchOne ){ |
| 48346 | if( *zString==0 ) return 0; |
| 48347 | SQLITE_SKIP_UTF8(zString); |
| 48348 | } |
| 48349 | zPattern++; |
| 48350 | } |
| 48351 | if( c && esc && sqlite3ReadUtf8(&zPattern[1])==esc ){ |
| 48352 | u8 const *zTemp = &zPattern[1]; |
| 48353 | SQLITE_SKIP_UTF8(zTemp); |
| 48354 | c = *zTemp; |
| 48355 | } |
| 48356 | if( c==0 ) return 1; |
| 48357 | if( c==matchSet ){ |
| 48358 | assert( esc==0 ); /* This is GLOB, not LIKE */ |
| 48359 | while( *zString && patternCompare(&zPattern[1],zString,pInfo,esc)==0 ){ |
| 48360 | SQLITE_SKIP_UTF8(zString); |
| 48361 | } |
| 48362 | return *zString!=0; |
| 48363 | }else{ |
| 48364 | while( (c2 = *zString)!=0 ){ |
| 48365 | if( noCase ){ |
| 48366 | c2 = sqlite3UpperToLower[c2]; |
| 48367 | c = sqlite3UpperToLower[c]; |
| 48368 | while( c2 != 0 && c2 != c ){ c2 = sqlite3UpperToLower[*++zString]; } |
| 48369 | }else{ |
| 48370 | while( c2 != 0 && c2 != c ){ c2 = *++zString; } |
| 48371 | } |
| 48372 | if( c2==0 ) return 0; |
| 48373 | if( patternCompare(&zPattern[1],zString,pInfo,esc) ) return 1; |
| 48374 | SQLITE_SKIP_UTF8(zString); |
| 48375 | } |
| 48376 | return 0; |
| 48377 | } |
| 48378 | }else if( !prevEscape && c==matchOne ){ |
| 48379 | if( *zString==0 ) return 0; |
| 48380 | SQLITE_SKIP_UTF8(zString); |
| 48381 | zPattern++; |
| 48382 | }else if( c==matchSet ){ |
| 48383 | int prior_c = 0; |
| 48384 | assert( esc==0 ); /* This only occurs for GLOB, not LIKE */ |
| 48385 | seen = 0; |
| 48386 | invert = 0; |
| 48387 | c = sqlite3ReadUtf8(zString); |
| 48388 | if( c==0 ) return 0; |
| 48389 | c2 = *++zPattern; |
| 48390 | if( c2=='^' ){ invert = 1; c2 = *++zPattern; } |
| 48391 | if( c2==']' ){ |
| 48392 | if( c==']' ) seen = 1; |
| 48393 | c2 = *++zPattern; |
| 48394 | } |
| 48395 | while( (c2 = sqlite3ReadUtf8(zPattern))!=0 && c2!=']' ){ |
| 48396 | if( c2=='-' && zPattern[1]!=']' && zPattern[1]!=0 && prior_c>0 ){ |
| 48397 | zPattern++; |
| 48398 | c2 = sqlite3ReadUtf8(zPattern); |
| 48399 | if( c>=prior_c && c<=c2 ) seen = 1; |
| 48400 | prior_c = 0; |
| 48401 | }else if( c==c2 ){ |
| 48402 | seen = 1; |
| 48403 | prior_c = c2; |
| 48404 | }else{ |
| 48405 | prior_c = c2; |
| 48406 | } |
| 48407 | SQLITE_SKIP_UTF8(zPattern); |
| 48408 | } |
| 48409 | if( c2==0 || (seen ^ invert)==0 ) return 0; |
| 48410 | SQLITE_SKIP_UTF8(zString); |
| 48411 | zPattern++; |
| 48412 | }else if( esc && !prevEscape && sqlite3ReadUtf8(zPattern)==esc){ |
| 48413 | prevEscape = 1; |
| 48414 | SQLITE_SKIP_UTF8(zPattern); |
| 48415 | }else{ |
| 48416 | if( noCase ){ |
| 48417 | if( sqlite3UpperToLower[c] != sqlite3UpperToLower[*zString] ) return 0; |
| 48418 | }else{ |
| 48419 | if( c != *zString ) return 0; |
| 48420 | } |
| 48421 | zPattern++; |
| 48422 | zString++; |
| 48423 | prevEscape = 0; |
| 48424 | } |
| 48425 | } |
| 48426 | return *zString==0; |
| 48427 | } |
| @@ -48477,11 +48420,11 @@ | |
| 48477 | if( sqlite3Utf8CharLen((char*)zEsc, -1)!=1 ){ |
| 48478 | sqlite3_result_error(context, |
| 48479 | "ESCAPE expression must be a single character", -1); |
| 48480 | return; |
| 48481 | } |
| 48482 | escape = sqlite3ReadUtf8(zEsc); |
| 48483 | } |
| 48484 | if( zA && zB ){ |
| 48485 | struct compareInfo *pInfo = sqlite3_user_data(context); |
| 48486 | #ifdef SQLITE_TEST |
| 48487 | sqlite3_like_count++; |
| @@ -49395,11 +49338,11 @@ | |
| 49395 | ** |
| 49396 | ************************************************************************* |
| 49397 | ** This file contains C code routines that are called by the parser |
| 49398 | ** to handle INSERT statements in SQLite. |
| 49399 | ** |
| 49400 | ** $Id: insert.c,v 1.187 2007/06/26 10:38:55 danielk1977 Exp $ |
| 49401 | */ |
| 49402 | |
| 49403 | /* |
| 49404 | ** Set P3 of the most recently inserted opcode to a column affinity |
| 49405 | ** string for index pIdx. A column affinity string has one character |
| @@ -50409,11 +50352,11 @@ | |
| 50409 | pParse->ckOffset = nCol; |
| 50410 | sqlite3ExprIfTrue(pParse, pTab->pCheck, allOk, 1); |
| 50411 | assert( pParse->ckOffset==nCol ); |
| 50412 | pParse->ckOffset = 0; |
| 50413 | onError = overrideError!=OE_Default ? overrideError : OE_Abort; |
| 50414 | if( onError==OE_Ignore || onError==OE_Replace ){ |
| 50415 | sqlite3VdbeAddOp(v, OP_Pop, nCol+1+hasTwoRowids, 0); |
| 50416 | sqlite3VdbeAddOp(v, OP_Goto, 0, ignoreDest); |
| 50417 | }else{ |
| 50418 | sqlite3VdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError); |
| 50419 | } |
| @@ -51155,20 +51098,26 @@ | |
| 51155 | ** shared libraries that want to be imported as extensions into |
| 51156 | ** an SQLite instance. Shared libraries that intend to be loaded |
| 51157 | ** as extensions by SQLite should #include this file instead of |
| 51158 | ** sqlite3.h. |
| 51159 | ** |
| 51160 | ** @(#) $Id: sqlite3ext.h,v 1.11 2007/06/22 15:21:16 danielk1977 Exp $ |
| 51161 | */ |
| 51162 | #ifndef _SQLITE3EXT_H_ |
| 51163 | #define _SQLITE3EXT_H_ |
| 51164 | |
| 51165 | typedef struct sqlite3_api_routines sqlite3_api_routines; |
| 51166 | |
| 51167 | /* |
| 51168 | ** The following structure hold pointers to all of the SQLite API |
| 51169 | ** routines. |
| 51170 | */ |
| 51171 | struct sqlite3_api_routines { |
| 51172 | void * (*aggregate_context)(sqlite3_context*,int nBytes); |
| 51173 | int (*aggregate_count)(sqlite3_context*); |
| 51174 | int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*)); |
| @@ -51215,11 +51164,10 @@ | |
| 51215 | int (*create_collation)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*)); |
| 51216 | int (*create_collation16)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*)); |
| 51217 | int (*create_function)(sqlite3*,const char*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*)); |
| 51218 | int (*create_function16)(sqlite3*,const void*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*)); |
| 51219 | int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*); |
| 51220 | int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,void (*xDestroy)(void *)); |
| 51221 | int (*data_count)(sqlite3_stmt*pStmt); |
| 51222 | sqlite3 * (*db_handle)(sqlite3_stmt*); |
| 51223 | int (*declare_vtab)(sqlite3*,const char*); |
| 51224 | int (*enable_shared_cache)(int); |
| 51225 | int (*errcode)(sqlite3*db); |
| @@ -51287,10 +51235,11 @@ | |
| 51287 | char *(*vmprintf)(const char*,va_list); |
| 51288 | int (*overload_function)(sqlite3*, const char *zFuncName, int nArg); |
| 51289 | int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**); |
| 51290 | int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); |
| 51291 | int (*clear_bindings)(sqlite3_stmt*); |
| 51292 | }; |
| 51293 | |
| 51294 | /* |
| 51295 | ** The following macros redefine the API routines so that they are |
| 51296 | ** redirected throught the global sqlite3_api structure. |
| @@ -51570,11 +51519,10 @@ | |
| 51570 | sqlite3_create_collation, |
| 51571 | sqlite3_create_collation16, |
| 51572 | sqlite3_create_function, |
| 51573 | sqlite3_create_function16, |
| 51574 | sqlite3_create_module, |
| 51575 | sqlite3_create_module_v2, |
| 51576 | sqlite3_data_count, |
| 51577 | sqlite3_db_handle, |
| 51578 | sqlite3_declare_vtab, |
| 51579 | sqlite3_enable_shared_cache, |
| 51580 | sqlite3_errcode, |
| @@ -51654,10 +51602,16 @@ | |
| 51654 | ** Added after 3.3.13 |
| 51655 | */ |
| 51656 | sqlite3_prepare_v2, |
| 51657 | sqlite3_prepare16_v2, |
| 51658 | sqlite3_clear_bindings, |
| 51659 | }; |
| 51660 | |
| 51661 | /* |
| 51662 | ** Attempt to load an SQLite extension library contained in the file |
| 51663 | ** zFile. The entry point is zProc. zProc may be 0 in which case a |
| @@ -53737,11 +53691,11 @@ | |
| 53737 | ** |
| 53738 | ************************************************************************* |
| 53739 | ** This file contains C code routines that are called by the parser |
| 53740 | ** to handle SELECT statements in SQLite. |
| 53741 | ** |
| 53742 | ** $Id: select.c,v 1.353 2007/06/26 10:38:55 danielk1977 Exp $ |
| 53743 | */ |
| 53744 | |
| 53745 | |
| 53746 | /* |
| 53747 | ** Delete all the content of a Select structure but do not deallocate |
| @@ -56237,10 +56191,20 @@ | |
| 56237 | (char*)pKey, P3_KEYINFO_HANDOFF); |
| 56238 | if( seekOp==OP_Rewind ){ |
| 56239 | sqlite3VdbeAddOp(v, OP_Null, 0, 0); |
| 56240 | sqlite3VdbeAddOp(v, OP_MakeRecord, 1, 0); |
| 56241 | seekOp = OP_MoveGt; |
| 56242 | } |
| 56243 | sqlite3VdbeAddOp(v, seekOp, iIdx, 0); |
| 56244 | sqlite3VdbeAddOp(v, OP_IdxRowid, iIdx, 0); |
| 56245 | sqlite3VdbeAddOp(v, OP_Close, iIdx, 0); |
| 56246 | sqlite3VdbeAddOp(v, OP_MoveGe, base, 0); |
| @@ -65805,11 +65769,11 @@ | |
| 65805 | ** |
| 65806 | ** This file contains C code that splits an SQL input string up into |
| 65807 | ** individual tokens and sends those tokens one-by-one over to the |
| 65808 | ** parser for analysis. |
| 65809 | ** |
| 65810 | ** $Id: tokenize.c,v 1.130 2007/07/13 10:26:08 drh Exp $ |
| 65811 | */ |
| 65812 | |
| 65813 | /* |
| 65814 | ** The charMap() macro maps alphabetic characters into their |
| 65815 | ** lower-case ASCII equivalent. On ASCII machines, this is just |
| @@ -66282,17 +66246,10 @@ | |
| 66282 | } |
| 66283 | SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){ |
| 66284 | return getToken(z, tokenType); |
| 66285 | } |
| 66286 | |
| 66287 | /* |
| 66288 | ** The interface to the LEMON-generated parser |
| 66289 | */ |
| 66290 | SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(size_t)); |
| 66291 | SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*)); |
| 66292 | SQLITE_PRIVATE void sqlite3Parser(void*, int, Token, Parse*); |
| 66293 | |
| 66294 | /* |
| 66295 | ** Run the parser on the given SQL string. The parser structure is |
| 66296 | ** passed in. An SQLITE_ status code is returned. If an error occurs |
| 66297 | ** and pzErrMsg!=NULL then an error message might be written into |
| 66298 | ** memory obtained from malloc() and *pzErrMsg made to point to that |
| 66299 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -1,8 +1,8 @@ | |
| 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.4.1. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a one translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | ** of 5% are more are commonly seen when SQLite is compiled as a single |
| 8 | ** translation unit. |
| @@ -9,17 +9,17 @@ | |
| 9 | ** |
| 10 | ** This file is all you need to compile SQLite. To use SQLite in other |
| 11 | ** programs, you need this file and the "sqlite3.h" header file that defines |
| 12 | ** the programming interface to the SQLite library. (If you do not have |
| 13 | ** the "sqlite3.h" header file at hand, you will find a copy in the first |
| 14 | ** 2702 lines past this header comment.) Additional code files may be |
| 15 | ** needed if you want a wrapper to interface SQLite with your choice of |
| 16 | ** programming language. The code for the "sqlite3" command-line shell |
| 17 | ** is also in a separate file. This file contains only code for the core |
| 18 | ** SQLite library. |
| 19 | ** |
| 20 | ** This amalgamation was generated on 2007-07-24 12:53:26 UTC. |
| 21 | */ |
| 22 | #define SQLITE_AMALGAMATION 1 |
| 23 | #ifndef SQLITE_PRIVATE |
| 24 | # define SQLITE_PRIVATE static |
| 25 | #endif |
| @@ -57,11 +57,11 @@ | |
| 57 | ** The name of this file under configuration management is "sqlite.h.in". |
| 58 | ** The makefile makes some minor changes to this file (such as inserting |
| 59 | ** the version number) and changes its name to "sqlite3.h" as |
| 60 | ** part of the build process. |
| 61 | ** |
| 62 | ** @(#) $Id: sqlite.h.in,v 1.218 2007/07/19 12:41:40 drh Exp $ |
| 63 | */ |
| 64 | #ifndef _SQLITE3_H_ |
| 65 | #define _SQLITE3_H_ |
| 66 | #include <stdarg.h> /* Needed for the definition of va_list */ |
| 67 | |
| @@ -108,12 +108,12 @@ | |
| 108 | ** version 3.1.1 or greater at compile time, programs may use the test |
| 109 | ** (SQLITE_VERSION_NUMBER>=3001001). |
| 110 | ** |
| 111 | ** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()]. |
| 112 | */ |
| 113 | #define SQLITE_VERSION "3.4.1" |
| 114 | #define SQLITE_VERSION_NUMBER 3004001 |
| 115 | |
| 116 | /* |
| 117 | ** CAPI3REF: Run-Time Library Version Numbers |
| 118 | ** |
| 119 | ** These routines return values equivalent to the header constants |
| @@ -990,14 +990,18 @@ | |
| 990 | ** The first argument "db" is an [sqlite3 | SQLite database handle] |
| 991 | ** obtained from a prior call to [sqlite3_open()] or [sqlite3_open16()]. |
| 992 | ** The second argument "zSql" is the statement to be compiled, encoded |
| 993 | ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() |
| 994 | ** interfaces uses UTF-8 and sqlite3_prepare16() and sqlite3_prepare16_v2() |
| 995 | ** use UTF-16. |
| 996 | ** |
| 997 | ** If the nByte argument is less |
| 998 | ** than zero, then zSql is read up to the first zero terminator. If |
| 999 | ** nByte is non-negative, then it is the maximum number of |
| 1000 | ** bytes read from zSql. When nByte is non-negative, the |
| 1001 | ** zSql string ends at either the first '\000' character or |
| 1002 | ** until the nByte-th byte, whichever comes first. |
| 1003 | ** |
| 1004 | ** *pzTail is made to point to the first byte past the end of the first |
| 1005 | ** SQL statement in zSql. This routine only compiles the first statement |
| 1006 | ** in zSql, so *pzTail is left pointing to what remains uncompiled. |
| 1007 | ** |
| @@ -1046,32 +1050,32 @@ | |
| 1050 | ** </ol> |
| 1051 | */ |
| 1052 | SQLITE_API int sqlite3_prepare( |
| 1053 | sqlite3 *db, /* Database handle */ |
| 1054 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
| 1055 | int nByte, /* Maximum length of zSql in bytes. */ |
| 1056 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1057 | const char **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1058 | ); |
| 1059 | int sqlite3_prepare_v2( |
| 1060 | sqlite3 *db, /* Database handle */ |
| 1061 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
| 1062 | int nByte, /* Maximum length of zSql in bytes. */ |
| 1063 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1064 | const char **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1065 | ); |
| 1066 | SQLITE_API int sqlite3_prepare16( |
| 1067 | sqlite3 *db, /* Database handle */ |
| 1068 | const void *zSql, /* SQL statement, UTF-16 encoded */ |
| 1069 | int nByte, /* Maximum length of zSql in bytes. */ |
| 1070 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1071 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1072 | ); |
| 1073 | int sqlite3_prepare16_v2( |
| 1074 | sqlite3 *db, /* Database handle */ |
| 1075 | const void *zSql, /* SQL statement, UTF-16 encoded */ |
| 1076 | int nByte, /* Maximum length of zSql in bytes. */ |
| 1077 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1078 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1079 | ); |
| 1080 | |
| 1081 | /* |
| @@ -2788,11 +2792,11 @@ | |
| 2792 | ** May you share freely, never taking more than you give. |
| 2793 | ** |
| 2794 | ************************************************************************* |
| 2795 | ** Internal interface definitions for SQLite. |
| 2796 | ** |
| 2797 | ** @(#) $Id: sqliteInt.h,v 1.580 2007/07/23 19:31:17 drh Exp $ |
| 2798 | */ |
| 2799 | #ifndef _SQLITEINT_H_ |
| 2800 | #define _SQLITEINT_H_ |
| 2801 | /************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/ |
| 2802 | /************** Begin file sqliteLimit.h *************************************/ |
| @@ -5919,65 +5923,18 @@ | |
| 5923 | * even when no triggers exist |
| 5924 | */ |
| 5925 | extern int sqlite3_always_code_trigger_setup; |
| 5926 | |
| 5927 | /* |
| 5928 | ** Assuming zIn points to the first byte of a UTF-8 character, |
| 5929 | ** advance zIn to point to the first byte of the next UTF-8 character. |
| 5930 | */ |
| 5931 | #define SQLITE_SKIP_UTF8(zIn) { \ |
| 5932 | if( (*(zIn++))>=0xc0 ){ \ |
| 5933 | while( (*zIn & 0xc0)==0x80 ){ zIn++; } \ |
| 5934 | } \ |
| 5935 | } |
| 5936 | |
| 5937 | /* |
| 5938 | ** The SQLITE_CORRUPT_BKPT macro can be either a constant (for production |
| 5939 | ** builds) or a function call (for debugging). If it is a function call, |
| 5940 | ** it allows the operator to set a breakpoint at the spot where database |
| @@ -6193,11 +6150,11 @@ | |
| 6150 | SQLITE_API char *sqlite3_snprintf(int,char*,const char*,...); |
| 6151 | SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*); |
| 6152 | SQLITE_PRIVATE int sqlite3FitsIn64Bits(const char *); |
| 6153 | SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar); |
| 6154 | SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte); |
| 6155 | SQLITE_PRIVATE int sqlite3Utf8Read(const u8*, const u8*, const u8**); |
| 6156 | SQLITE_PRIVATE int sqlite3PutVarint(unsigned char *, u64); |
| 6157 | SQLITE_PRIVATE int sqlite3GetVarint(const unsigned char *, u64 *); |
| 6158 | SQLITE_PRIVATE int sqlite3GetVarint32(const unsigned char *, u32 *); |
| 6159 | SQLITE_PRIVATE int sqlite3VarintLen(u64 v); |
| 6160 | SQLITE_PRIVATE void sqlite3IndexAffinityStr(Vdbe *, Index *); |
| @@ -6265,10 +6222,17 @@ | |
| 6222 | SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int); |
| 6223 | SQLITE_PRIVATE void sqlite3FailedMalloc(void); |
| 6224 | SQLITE_PRIVATE void sqlite3AbortOtherActiveVdbes(sqlite3 *, Vdbe *); |
| 6225 | SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *); |
| 6226 | |
| 6227 | /* |
| 6228 | ** The interface to the LEMON-generated parser |
| 6229 | */ |
| 6230 | SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(size_t)); |
| 6231 | SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*)); |
| 6232 | SQLITE_PRIVATE void sqlite3Parser(void*, int, Token, Parse*); |
| 6233 | |
| 6234 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 6235 | SQLITE_PRIVATE void sqlite3CloseExtensions(sqlite3*); |
| 6236 | SQLITE_PRIVATE int sqlite3AutoLoadExtensions(sqlite3*); |
| 6237 | #else |
| 6238 | # define sqlite3CloseExtensions(X) |
| @@ -9286,11 +9250,11 @@ | |
| 9250 | ** |
| 9251 | ************************************************************************* |
| 9252 | ** This file contains routines used to translate between UTF-8, |
| 9253 | ** UTF-16, UTF-16BE, and UTF-16LE. |
| 9254 | ** |
| 9255 | ** $Id: utf.c,v 1.52 2007/07/23 19:12:42 drh Exp $ |
| 9256 | ** |
| 9257 | ** Notes on UTF-8: |
| 9258 | ** |
| 9259 | ** Byte-0 Byte-1 Byte-2 Byte-3 Value |
| 9260 | ** 0xxxxxxx 00000000 00000000 0xxxxxxx |
| @@ -9764,10 +9728,11 @@ | |
| 9728 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
| 9729 | 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 9730 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
| 9731 | 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00, |
| 9732 | }; |
| 9733 | |
| 9734 | |
| 9735 | #define WRITE_UTF8(zOut, c) { \ |
| 9736 | if( c<0x00080 ){ \ |
| 9737 | *zOut++ = (c&0xFF); \ |
| 9738 | } \ |
| @@ -9830,10 +9795,58 @@ | |
| 9795 | c2 += (*zIn++); \ |
| 9796 | c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \ |
| 9797 | if( (c & 0xFFFF0000)==0 ) c = 0xFFFD; \ |
| 9798 | } \ |
| 9799 | } |
| 9800 | |
| 9801 | /* |
| 9802 | ** Translate a single UTF-8 character. Return the unicode value. |
| 9803 | ** |
| 9804 | ** During translation, assume that the byte that zTerm points |
| 9805 | ** is a 0x00. |
| 9806 | ** |
| 9807 | ** Write a pointer to the next unread byte back into *pzNext. |
| 9808 | ** |
| 9809 | ** Notes On Invalid UTF-8: |
| 9810 | ** |
| 9811 | ** * This routine never allows a 7-bit character (0x00 through 0x7f) to |
| 9812 | ** be encoded as a multi-byte character. Any multi-byte character that |
| 9813 | ** attempts to encode a value between 0x00 and 0x7f is rendered as 0xfffd. |
| 9814 | ** |
| 9815 | ** * This routine never allows a UTF16 surrogate value to be encoded. |
| 9816 | ** If a multi-byte character attempts to encode a value between |
| 9817 | ** 0xd800 and 0xe000 then it is rendered as 0xfffd. |
| 9818 | ** |
| 9819 | ** * Bytes in the range of 0x80 through 0xbf which occur as the first |
| 9820 | ** byte of a character are interpreted as single-byte characters |
| 9821 | ** and rendered as themselves even though they are technically |
| 9822 | ** invalid characters. |
| 9823 | ** |
| 9824 | ** * This routine accepts an infinite number of different UTF8 encodings |
| 9825 | ** for unicode values 0x80 and greater. It do not change over-length |
| 9826 | ** encodings to 0xfffd as some systems recommend. |
| 9827 | */ |
| 9828 | SQLITE_PRIVATE int sqlite3Utf8Read( |
| 9829 | const unsigned char *z, /* First byte of UTF-8 character */ |
| 9830 | const unsigned char *zTerm, /* Pretend this byte is 0x00 */ |
| 9831 | const unsigned char **pzNext /* Write first byte past UTF-8 char here */ |
| 9832 | ){ |
| 9833 | int c = *(z++); |
| 9834 | if( c>=0xc0 ){ |
| 9835 | c = sqlite3UtfTrans1[c-0xc0]; |
| 9836 | while( z!=zTerm && (*z & 0xc0)==0x80 ){ |
| 9837 | c = (c<<6) + (0x3f & *(z++)); |
| 9838 | } |
| 9839 | if( c<0x80 |
| 9840 | || (c&0xFFFFF800)==0xD800 |
| 9841 | || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } |
| 9842 | } |
| 9843 | *pzNext = z; |
| 9844 | return c; |
| 9845 | } |
| 9846 | |
| 9847 | |
| 9848 | |
| 9849 | /* |
| 9850 | ** If the TRANSLATE_TRACE macro is defined, the value of each Mem is |
| 9851 | ** printed on stderr on the way into and out of sqlite3VdbeMemTranslate(). |
| 9852 | */ |
| @@ -9924,85 +9937,23 @@ | |
| 9937 | zOut = zShort; |
| 9938 | } |
| 9939 | z = zOut; |
| 9940 | |
| 9941 | if( pMem->enc==SQLITE_UTF8 ){ |
| 9942 | if( desiredEnc==SQLITE_UTF16LE ){ |
| 9943 | /* UTF-8 -> UTF-16 Little-endian */ |
| 9944 | while( zIn<zTerm ){ |
| 9945 | c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn); |
| 9946 | WRITE_UTF16LE(z, c); |
| 9947 | } |
| 9948 | }else{ |
| 9949 | assert( desiredEnc==SQLITE_UTF16BE ); |
| 9950 | /* UTF-8 -> UTF-16 Big-endian */ |
| 9951 | while( zIn<zTerm ){ |
| 9952 | c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn); |
| 9953 | WRITE_UTF16BE(z, c); |
| 9954 | } |
| 9955 | } |
| 9956 | pMem->n = z - zOut; |
| 9957 | *z++ = 0; |
| 9958 | }else{ |
| 9959 | assert( desiredEnc==SQLITE_UTF8 ); |
| @@ -10182,15 +10133,15 @@ | |
| 10133 | ** correct UTF-8 encoding to be longer than a malformed encoding). |
| 10134 | */ |
| 10135 | SQLITE_PRIVATE int sqlite3Utf8To8(unsigned char *zIn){ |
| 10136 | unsigned char *zOut = zIn; |
| 10137 | unsigned char *zStart = zIn; |
| 10138 | unsigned char *zTerm; |
| 10139 | u32 c; |
| 10140 | |
| 10141 | while( zIn[0] ){ |
| 10142 | c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn); |
| 10143 | if( c!=0xfffd ){ |
| 10144 | WRITE_UTF8(zOut, c); |
| 10145 | } |
| 10146 | } |
| 10147 | *zOut = 0; |
| @@ -10206,20 +10157,22 @@ | |
| 10157 | */ |
| 10158 | SQLITE_PRIVATE void sqlite3UtfSelfTest(){ |
| 10159 | unsigned int i, t; |
| 10160 | unsigned char zBuf[20]; |
| 10161 | unsigned char *z; |
| 10162 | unsigned char *zTerm; |
| 10163 | int n; |
| 10164 | unsigned int c; |
| 10165 | |
| 10166 | for(i=0; i<0x00110000; i++){ |
| 10167 | z = zBuf; |
| 10168 | WRITE_UTF8(z, i); |
| 10169 | n = z-zBuf; |
| 10170 | z[0] = 0; |
| 10171 | zTerm = z; |
| 10172 | z = zBuf; |
| 10173 | c = sqlite3Utf8Read(z, zTerm, (const u8**)&z); |
| 10174 | t = i; |
| 10175 | if( i>=0xD800 && i<=0xDFFF ) t = 0xFFFD; |
| 10176 | if( (i&0xFFFFFFFE)==0xFFFE ) t = 0xFFFD; |
| 10177 | assert( c==t ); |
| 10178 | assert( (z-zBuf)==n ); |
| @@ -17876,11 +17829,11 @@ | |
| 17829 | ** is separate from the database file. The pager also implements file |
| 17830 | ** locking to prevent two processes from writing the same database |
| 17831 | ** file simultaneously, or one process from reading the database while |
| 17832 | ** another is writing. |
| 17833 | ** |
| 17834 | ** @(#) $Id: pager.c,v 1.351 2007/07/20 00:33:36 drh Exp $ |
| 17835 | */ |
| 17836 | #ifndef SQLITE_OMIT_DISKIO |
| 17837 | |
| 17838 | /* |
| 17839 | ** Macros for troubleshooting. Normally turned off |
| @@ -18402,21 +18355,10 @@ | |
| 18355 | static int write32bits(OsFile *fd, u32 val){ |
| 18356 | char ac[4]; |
| 18357 | put32bits(ac, val); |
| 18358 | return sqlite3OsWrite(fd, ac, 4); |
| 18359 | } |
| 18360 | |
| 18361 | /* |
| 18362 | ** This function should be called when an error occurs within the pager |
| 18363 | ** code. The first argument is a pointer to the pager structure, the |
| 18364 | ** second the error-code about to be returned by a pager API function. |
| @@ -21725,14 +21667,12 @@ | |
| 21667 | rc = sqlite3PagerGet(pPager, 1, &pPgHdr); |
| 21668 | if( rc!=SQLITE_OK ) return rc; |
| 21669 | rc = sqlite3PagerWrite(pPgHdr); |
| 21670 | if( rc!=SQLITE_OK ) return rc; |
| 21671 | |
| 21672 | /* Increment the value just read and write it back to byte 24. */ |
| 21673 | change_counter = sqlite3Get4byte((u8*)pPager->dbFileVers); |
| 21674 | change_counter++; |
| 21675 | put32bits(((char*)PGHDR_TO_DATA(pPgHdr))+24, change_counter); |
| 21676 | /* Release the page reference. */ |
| 21677 | sqlite3PagerUnref(pPgHdr); |
| 21678 | pPager->changeCountDone = 1; |
| @@ -22347,11 +22287,11 @@ | |
| 22287 | ** May you do good and not evil. |
| 22288 | ** May you find forgiveness for yourself and forgive others. |
| 22289 | ** May you share freely, never taking more than you give. |
| 22290 | ** |
| 22291 | ************************************************************************* |
| 22292 | ** $Id: btree.c,v 1.393 2007/07/23 19:26:17 drh Exp $ |
| 22293 | ** |
| 22294 | ** This file implements a external (disk-based) database using BTrees. |
| 22295 | ** See the header comment on "btreeInt.h" for additional information. |
| 22296 | ** Including a description of file format and an overview of operation. |
| 22297 | */ |
| @@ -24934,11 +24874,11 @@ | |
| 24874 | } |
| 24875 | if( rc==SQLITE_DONE ){ |
| 24876 | assert(nFin==0 || pBt->nTrunc==0 || nFin<=pBt->nTrunc); |
| 24877 | rc = SQLITE_OK; |
| 24878 | if( pBt->nTrunc ){ |
| 24879 | rc = sqlite3PagerWrite(pBt->pPage1->pDbPage); |
| 24880 | put4byte(&pBt->pPage1->aData[32], 0); |
| 24881 | put4byte(&pBt->pPage1->aData[36], 0); |
| 24882 | pBt->nTrunc = nFin; |
| 24883 | } |
| 24884 | } |
| @@ -33573,11 +33513,11 @@ | |
| 33513 | ** documentation, headers files, or other derived files. The formatting |
| 33514 | ** of the code in this file is, therefore, important. See other comments |
| 33515 | ** in this file for details. If in doubt, do not deviate from existing |
| 33516 | ** commenting and indentation practices when changing or adding code. |
| 33517 | ** |
| 33518 | ** $Id: vdbe.c,v 1.638 2007/07/22 19:10:21 drh Exp $ |
| 33519 | */ |
| 33520 | |
| 33521 | /* |
| 33522 | ** The following global variable is incremented every time a cursor |
| 33523 | ** moves, either by the OP_MoveXX, OP_Next, or OP_Prev opcodes. The test |
| @@ -37824,18 +37764,18 @@ | |
| 37764 | |
| 37765 | for(nRoot=0; &pTos[-nRoot]>=p->aStack; nRoot++){ |
| 37766 | if( (pTos[-nRoot].flags & MEM_Int)==0 ) break; |
| 37767 | } |
| 37768 | assert( nRoot>0 ); |
| 37769 | aRoot = sqliteMallocRaw( sizeof(int)*(nRoot+1) ); |
| 37770 | if( aRoot==0 ) goto no_mem; |
| 37771 | j = pOp->p1; |
| 37772 | assert( j>=0 && j<p->nMem ); |
| 37773 | pnErr = &p->aMem[j]; |
| 37774 | assert( (pnErr->flags & MEM_Int)!=0 ); |
| 37775 | for(j=0; j<nRoot; j++){ |
| 37776 | aRoot[j] = (pTos-j)->u.i; |
| 37777 | } |
| 37778 | aRoot[j] = 0; |
| 37779 | popStack(&pTos, nRoot); |
| 37780 | pTos++; |
| 37781 | z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p2].pBt, aRoot, nRoot, |
| @@ -39076,11 +39016,11 @@ | |
| 39016 | ** |
| 39017 | ************************************************************************* |
| 39018 | ** This file contains routines used for analyzing expressions and |
| 39019 | ** for generating VDBE code that evaluates expressions in SQLite. |
| 39020 | ** |
| 39021 | ** $Id: expr.c,v 1.301 2007/07/23 22:51:15 drh Exp $ |
| 39022 | */ |
| 39023 | |
| 39024 | /* |
| 39025 | ** Return the 'affinity' of the expression pExpr if any. |
| 39026 | ** |
| @@ -40202,15 +40142,21 @@ | |
| 40142 | */ |
| 40143 | if( cnt==0 && (pEList = pNC->pEList)!=0 && zTab==0 ){ |
| 40144 | for(j=0; j<pEList->nExpr; j++){ |
| 40145 | char *zAs = pEList->a[j].zName; |
| 40146 | if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){ |
| 40147 | Expr *pDup, *pOrig; |
| 40148 | assert( pExpr->pLeft==0 && pExpr->pRight==0 ); |
| 40149 | assert( pExpr->pList==0 ); |
| 40150 | assert( pExpr->pSelect==0 ); |
| 40151 | pOrig = pEList->a[j].pExpr; |
| 40152 | if( !pNC->allowAgg && ExprHasProperty(pOrig, EP_Agg) ){ |
| 40153 | sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs); |
| 40154 | sqliteFree(zCol); |
| 40155 | return 2; |
| 40156 | } |
| 40157 | pDup = sqlite3ExprDup(pOrig); |
| 40158 | if( pExpr->flags & EP_ExpCollate ){ |
| 40159 | pDup->pColl = pExpr->pColl; |
| 40160 | pDup->flags |= EP_ExpCollate; |
| 40161 | } |
| 40162 | if( pExpr->span.dyn ) sqliteFree((char*)pExpr->span.z); |
| @@ -47909,13 +47855,14 @@ | |
| 47855 | ** |
| 47856 | ** There is only one exported symbol in this file - the function |
| 47857 | ** sqliteRegisterBuildinFunctions() found at the bottom of the file. |
| 47858 | ** All other code has file scope. |
| 47859 | ** |
| 47860 | ** $Id: func.c,v 1.162 2007/07/23 19:12:42 drh Exp $ |
| 47861 | */ |
| 47862 | /* #include <math.h> */ |
| 47863 | |
| 47864 | |
| 47865 | /* |
| 47866 | ** Return the collating function associated with a function. |
| 47867 | */ |
| 47868 | static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){ |
| @@ -48284,19 +48231,10 @@ | |
| 48231 | static const struct compareInfo likeInfoNorm = { '%', '_', 0, 1 }; |
| 48232 | /* If SQLITE_CASE_SENSITIVE_LIKE is defined, then the LIKE operator |
| 48233 | ** is case sensitive causing 'a' LIKE 'A' to be false */ |
| 48234 | static const struct compareInfo likeInfoAlt = { '%', '_', 0, 0 }; |
| 48235 | |
| 48236 | /* |
| 48237 | ** Compare two UTF-8 strings for equality where the first string can |
| 48238 | ** potentially be a "glob" expression. Return true (1) if they |
| 48239 | ** are the same and false (0) if they are different. |
| 48240 | ** |
| @@ -48327,101 +48265,106 @@ | |
| 48265 | const u8 *zPattern, /* The glob pattern */ |
| 48266 | const u8 *zString, /* The string to compare against the glob */ |
| 48267 | const struct compareInfo *pInfo, /* Information about how to do the compare */ |
| 48268 | const int esc /* The escape character */ |
| 48269 | ){ |
| 48270 | int c, c2; |
| 48271 | int invert; |
| 48272 | int seen; |
| 48273 | u8 matchOne = pInfo->matchOne; |
| 48274 | u8 matchAll = pInfo->matchAll; |
| 48275 | u8 matchSet = pInfo->matchSet; |
| 48276 | u8 noCase = pInfo->noCase; |
| 48277 | int prevEscape = 0; /* True if the previous character was 'escape' */ |
| 48278 | |
| 48279 | while( (c = sqlite3Utf8Read(zPattern,0,&zPattern))!=0 ){ |
| 48280 | if( !prevEscape && c==matchAll ){ |
| 48281 | while( (c=sqlite3Utf8Read(zPattern,0,&zPattern)) == matchAll |
| 48282 | || c == matchOne ){ |
| 48283 | if( c==matchOne && sqlite3Utf8Read(zString, 0, &zString)==0 ){ |
| 48284 | return 0; |
| 48285 | } |
| 48286 | } |
| 48287 | if( c==0 ){ |
| 48288 | return 1; |
| 48289 | }else if( c==esc ){ |
| 48290 | c = sqlite3Utf8Read(zPattern, 0, &zPattern); |
| 48291 | if( c==0 ){ |
| 48292 | return 0; |
| 48293 | } |
| 48294 | }else if( c==matchSet ){ |
| 48295 | assert( esc==0 ); /* This is GLOB, not LIKE */ |
| 48296 | assert( matchSet<0x80 ); /* '[' is a single-byte character */ |
| 48297 | while( *zString && patternCompare(&zPattern[-1],zString,pInfo,esc)==0 ){ |
| 48298 | SQLITE_SKIP_UTF8(zString); |
| 48299 | } |
| 48300 | return *zString!=0; |
| 48301 | } |
| 48302 | while( (c2 = sqlite3Utf8Read(zString,0,&zString))!=0 ){ |
| 48303 | if( noCase ){ |
| 48304 | c2 = c2<0x80 ? sqlite3UpperToLower[c2] : c2; |
| 48305 | c = c<0x80 ? sqlite3UpperToLower[c] : c; |
| 48306 | while( c2 != 0 && c2 != c ){ |
| 48307 | c2 = sqlite3Utf8Read(zString, 0, &zString); |
| 48308 | if( c2<0x80 ) c2 = sqlite3UpperToLower[c2]; |
| 48309 | } |
| 48310 | }else{ |
| 48311 | while( c2 != 0 && c2 != c ){ |
| 48312 | c2 = sqlite3Utf8Read(zString, 0, &zString); |
| 48313 | } |
| 48314 | } |
| 48315 | if( c2==0 ) return 0; |
| 48316 | if( patternCompare(zPattern,zString,pInfo,esc) ) return 1; |
| 48317 | } |
| 48318 | return 0; |
| 48319 | }else if( !prevEscape && c==matchOne ){ |
| 48320 | if( sqlite3Utf8Read(zString, 0, &zString)==0 ){ |
| 48321 | return 0; |
| 48322 | } |
| 48323 | }else if( c==matchSet ){ |
| 48324 | int prior_c = 0; |
| 48325 | assert( esc==0 ); /* This only occurs for GLOB, not LIKE */ |
| 48326 | seen = 0; |
| 48327 | invert = 0; |
| 48328 | c = sqlite3Utf8Read(zString, 0, &zString); |
| 48329 | if( c==0 ) return 0; |
| 48330 | c2 = sqlite3Utf8Read(zPattern, 0, &zPattern); |
| 48331 | if( c2=='^' ){ |
| 48332 | invert = 1; |
| 48333 | c2 = sqlite3Utf8Read(zPattern, 0, &zPattern); |
| 48334 | } |
| 48335 | if( c2==']' ){ |
| 48336 | if( c==']' ) seen = 1; |
| 48337 | c2 = sqlite3Utf8Read(zPattern, 0, &zPattern); |
| 48338 | } |
| 48339 | while( c2 && c2!=']' ){ |
| 48340 | if( c2=='-' && zPattern[0]!=']' && zPattern[0]!=0 && prior_c>0 ){ |
| 48341 | c2 = sqlite3Utf8Read(zPattern, 0, &zPattern); |
| 48342 | if( c>=prior_c && c<=c2 ) seen = 1; |
| 48343 | prior_c = 0; |
| 48344 | }else{ |
| 48345 | if( c==c2 ){ |
| 48346 | seen = 1; |
| 48347 | } |
| 48348 | prior_c = c2; |
| 48349 | } |
| 48350 | c2 = sqlite3Utf8Read(zPattern, 0, &zPattern); |
| 48351 | } |
| 48352 | if( c2==0 || (seen ^ invert)==0 ){ |
| 48353 | return 0; |
| 48354 | } |
| 48355 | }else if( esc==c && !prevEscape ){ |
| 48356 | prevEscape = 1; |
| 48357 | }else{ |
| 48358 | c2 = sqlite3Utf8Read(zString, 0, &zString); |
| 48359 | if( noCase ){ |
| 48360 | c = c<0x80 ? sqlite3UpperToLower[c] : c; |
| 48361 | c2 = c2<0x80 ? sqlite3UpperToLower[c2] : c2; |
| 48362 | } |
| 48363 | if( c!=c2 ){ |
| 48364 | return 0; |
| 48365 | } |
| 48366 | prevEscape = 0; |
| 48367 | } |
| 48368 | } |
| 48369 | return *zString==0; |
| 48370 | } |
| @@ -48477,11 +48420,11 @@ | |
| 48420 | if( sqlite3Utf8CharLen((char*)zEsc, -1)!=1 ){ |
| 48421 | sqlite3_result_error(context, |
| 48422 | "ESCAPE expression must be a single character", -1); |
| 48423 | return; |
| 48424 | } |
| 48425 | escape = sqlite3Utf8Read(zEsc, 0, &zEsc); |
| 48426 | } |
| 48427 | if( zA && zB ){ |
| 48428 | struct compareInfo *pInfo = sqlite3_user_data(context); |
| 48429 | #ifdef SQLITE_TEST |
| 48430 | sqlite3_like_count++; |
| @@ -49395,11 +49338,11 @@ | |
| 49338 | ** |
| 49339 | ************************************************************************* |
| 49340 | ** This file contains C code routines that are called by the parser |
| 49341 | ** to handle INSERT statements in SQLite. |
| 49342 | ** |
| 49343 | ** $Id: insert.c,v 1.188 2007/07/23 19:39:47 drh Exp $ |
| 49344 | */ |
| 49345 | |
| 49346 | /* |
| 49347 | ** Set P3 of the most recently inserted opcode to a column affinity |
| 49348 | ** string for index pIdx. A column affinity string has one character |
| @@ -50409,11 +50352,11 @@ | |
| 50352 | pParse->ckOffset = nCol; |
| 50353 | sqlite3ExprIfTrue(pParse, pTab->pCheck, allOk, 1); |
| 50354 | assert( pParse->ckOffset==nCol ); |
| 50355 | pParse->ckOffset = 0; |
| 50356 | onError = overrideError!=OE_Default ? overrideError : OE_Abort; |
| 50357 | if( onError==OE_Ignore ){ |
| 50358 | sqlite3VdbeAddOp(v, OP_Pop, nCol+1+hasTwoRowids, 0); |
| 50359 | sqlite3VdbeAddOp(v, OP_Goto, 0, ignoreDest); |
| 50360 | }else{ |
| 50361 | sqlite3VdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError); |
| 50362 | } |
| @@ -51155,20 +51098,26 @@ | |
| 51098 | ** shared libraries that want to be imported as extensions into |
| 51099 | ** an SQLite instance. Shared libraries that intend to be loaded |
| 51100 | ** as extensions by SQLite should #include this file instead of |
| 51101 | ** sqlite3.h. |
| 51102 | ** |
| 51103 | ** @(#) $Id: sqlite3ext.h,v 1.12 2007/07/20 10:48:36 drh Exp $ |
| 51104 | */ |
| 51105 | #ifndef _SQLITE3EXT_H_ |
| 51106 | #define _SQLITE3EXT_H_ |
| 51107 | |
| 51108 | typedef struct sqlite3_api_routines sqlite3_api_routines; |
| 51109 | |
| 51110 | /* |
| 51111 | ** The following structure hold pointers to all of the SQLite API |
| 51112 | ** routines. |
| 51113 | ** |
| 51114 | ** WARNING: In order to maintain backwards compatibility, add new |
| 51115 | ** interfaces to the end of this structure only. If you insert new |
| 51116 | ** interfaces in the middle of this structure, then older different |
| 51117 | ** versions of SQLite will not be able to load each others shared |
| 51118 | ** libraries! |
| 51119 | */ |
| 51120 | struct sqlite3_api_routines { |
| 51121 | void * (*aggregate_context)(sqlite3_context*,int nBytes); |
| 51122 | int (*aggregate_count)(sqlite3_context*); |
| 51123 | int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*)); |
| @@ -51215,11 +51164,10 @@ | |
| 51164 | int (*create_collation)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*)); |
| 51165 | int (*create_collation16)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*)); |
| 51166 | int (*create_function)(sqlite3*,const char*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*)); |
| 51167 | int (*create_function16)(sqlite3*,const void*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*)); |
| 51168 | int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*); |
| 51169 | int (*data_count)(sqlite3_stmt*pStmt); |
| 51170 | sqlite3 * (*db_handle)(sqlite3_stmt*); |
| 51171 | int (*declare_vtab)(sqlite3*,const char*); |
| 51172 | int (*enable_shared_cache)(int); |
| 51173 | int (*errcode)(sqlite3*db); |
| @@ -51287,10 +51235,11 @@ | |
| 51235 | char *(*vmprintf)(const char*,va_list); |
| 51236 | int (*overload_function)(sqlite3*, const char *zFuncName, int nArg); |
| 51237 | int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**); |
| 51238 | int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); |
| 51239 | int (*clear_bindings)(sqlite3_stmt*); |
| 51240 | int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,void (*xDestroy)(void *)); |
| 51241 | }; |
| 51242 | |
| 51243 | /* |
| 51244 | ** The following macros redefine the API routines so that they are |
| 51245 | ** redirected throught the global sqlite3_api structure. |
| @@ -51570,11 +51519,10 @@ | |
| 51519 | sqlite3_create_collation, |
| 51520 | sqlite3_create_collation16, |
| 51521 | sqlite3_create_function, |
| 51522 | sqlite3_create_function16, |
| 51523 | sqlite3_create_module, |
| 51524 | sqlite3_data_count, |
| 51525 | sqlite3_db_handle, |
| 51526 | sqlite3_declare_vtab, |
| 51527 | sqlite3_enable_shared_cache, |
| 51528 | sqlite3_errcode, |
| @@ -51654,10 +51602,16 @@ | |
| 51602 | ** Added after 3.3.13 |
| 51603 | */ |
| 51604 | sqlite3_prepare_v2, |
| 51605 | sqlite3_prepare16_v2, |
| 51606 | sqlite3_clear_bindings, |
| 51607 | |
| 51608 | /* |
| 51609 | ** Added for 3.4.1 |
| 51610 | */ |
| 51611 | sqlite3_create_module_v2, |
| 51612 | |
| 51613 | }; |
| 51614 | |
| 51615 | /* |
| 51616 | ** Attempt to load an SQLite extension library contained in the file |
| 51617 | ** zFile. The entry point is zProc. zProc may be 0 in which case a |
| @@ -53737,11 +53691,11 @@ | |
| 53691 | ** |
| 53692 | ************************************************************************* |
| 53693 | ** This file contains C code routines that are called by the parser |
| 53694 | ** to handle SELECT statements in SQLite. |
| 53695 | ** |
| 53696 | ** $Id: select.c,v 1.354 2007/07/18 18:17:12 drh Exp $ |
| 53697 | */ |
| 53698 | |
| 53699 | |
| 53700 | /* |
| 53701 | ** Delete all the content of a Select structure but do not deallocate |
| @@ -56237,10 +56191,20 @@ | |
| 56191 | (char*)pKey, P3_KEYINFO_HANDOFF); |
| 56192 | if( seekOp==OP_Rewind ){ |
| 56193 | sqlite3VdbeAddOp(v, OP_Null, 0, 0); |
| 56194 | sqlite3VdbeAddOp(v, OP_MakeRecord, 1, 0); |
| 56195 | seekOp = OP_MoveGt; |
| 56196 | } |
| 56197 | if( pIdx->aSortOrder[0]==SQLITE_SO_DESC ){ |
| 56198 | /* Ticket #2514: invert the seek operator if we are using |
| 56199 | ** a descending index. */ |
| 56200 | if( seekOp==OP_Last ){ |
| 56201 | seekOp = OP_Rewind; |
| 56202 | }else{ |
| 56203 | assert( seekOp==OP_MoveGt ); |
| 56204 | seekOp = OP_MoveLt; |
| 56205 | } |
| 56206 | } |
| 56207 | sqlite3VdbeAddOp(v, seekOp, iIdx, 0); |
| 56208 | sqlite3VdbeAddOp(v, OP_IdxRowid, iIdx, 0); |
| 56209 | sqlite3VdbeAddOp(v, OP_Close, iIdx, 0); |
| 56210 | sqlite3VdbeAddOp(v, OP_MoveGe, base, 0); |
| @@ -65805,11 +65769,11 @@ | |
| 65769 | ** |
| 65770 | ** This file contains C code that splits an SQL input string up into |
| 65771 | ** individual tokens and sends those tokens one-by-one over to the |
| 65772 | ** parser for analysis. |
| 65773 | ** |
| 65774 | ** $Id: tokenize.c,v 1.131 2007/07/23 19:31:17 drh Exp $ |
| 65775 | */ |
| 65776 | |
| 65777 | /* |
| 65778 | ** The charMap() macro maps alphabetic characters into their |
| 65779 | ** lower-case ASCII equivalent. On ASCII machines, this is just |
| @@ -66282,17 +66246,10 @@ | |
| 66246 | } |
| 66247 | SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){ |
| 66248 | return getToken(z, tokenType); |
| 66249 | } |
| 66250 | |
| 66251 | /* |
| 66252 | ** Run the parser on the given SQL string. The parser structure is |
| 66253 | ** passed in. An SQLITE_ status code is returned. If an error occurs |
| 66254 | ** and pzErrMsg!=NULL then an error message might be written into |
| 66255 | ** memory obtained from malloc() and *pzErrMsg made to point to that |
| 66256 |
+14
-10
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -28,11 +28,11 @@ | ||
| 28 | 28 | ** The name of this file under configuration management is "sqlite.h.in". |
| 29 | 29 | ** The makefile makes some minor changes to this file (such as inserting |
| 30 | 30 | ** the version number) and changes its name to "sqlite3.h" as |
| 31 | 31 | ** part of the build process. |
| 32 | 32 | ** |
| 33 | -** @(#) $Id: sqlite.h.in,v 1.217 2007/06/27 15:53:35 danielk1977 Exp $ | |
| 33 | +** @(#) $Id: sqlite.h.in,v 1.218 2007/07/19 12:41:40 drh Exp $ | |
| 34 | 34 | */ |
| 35 | 35 | #ifndef _SQLITE3_H_ |
| 36 | 36 | #define _SQLITE3_H_ |
| 37 | 37 | #include <stdarg.h> /* Needed for the definition of va_list */ |
| 38 | 38 | |
| @@ -79,12 +79,12 @@ | ||
| 79 | 79 | ** version 3.1.1 or greater at compile time, programs may use the test |
| 80 | 80 | ** (SQLITE_VERSION_NUMBER>=3001001). |
| 81 | 81 | ** |
| 82 | 82 | ** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()]. |
| 83 | 83 | */ |
| 84 | -#define SQLITE_VERSION "3.4.0" | |
| 85 | -#define SQLITE_VERSION_NUMBER 3004000 | |
| 84 | +#define SQLITE_VERSION "3.4.1" | |
| 85 | +#define SQLITE_VERSION_NUMBER 3004001 | |
| 86 | 86 | |
| 87 | 87 | /* |
| 88 | 88 | ** CAPI3REF: Run-Time Library Version Numbers |
| 89 | 89 | ** |
| 90 | 90 | ** These routines return values equivalent to the header constants |
| @@ -961,14 +961,18 @@ | ||
| 961 | 961 | ** The first argument "db" is an [sqlite3 | SQLite database handle] |
| 962 | 962 | ** obtained from a prior call to [sqlite3_open()] or [sqlite3_open16()]. |
| 963 | 963 | ** The second argument "zSql" is the statement to be compiled, encoded |
| 964 | 964 | ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() |
| 965 | 965 | ** interfaces uses UTF-8 and sqlite3_prepare16() and sqlite3_prepare16_v2() |
| 966 | -** use UTF-16. If the next argument, "nBytes", is less | |
| 966 | +** use UTF-16. | |
| 967 | +** | |
| 968 | +** If the nByte argument is less | |
| 967 | 969 | ** than zero, then zSql is read up to the first zero terminator. If |
| 968 | -** "nBytes" is not less than zero, then it is the length of the string zSql | |
| 969 | -** in bytes (not characters). | |
| 970 | +** nByte is non-negative, then it is the maximum number of | |
| 971 | +** bytes read from zSql. When nByte is non-negative, the | |
| 972 | +** zSql string ends at either the first '\000' character or | |
| 973 | +** until the nByte-th byte, whichever comes first. | |
| 970 | 974 | ** |
| 971 | 975 | ** *pzTail is made to point to the first byte past the end of the first |
| 972 | 976 | ** SQL statement in zSql. This routine only compiles the first statement |
| 973 | 977 | ** in zSql, so *pzTail is left pointing to what remains uncompiled. |
| 974 | 978 | ** |
| @@ -1017,32 +1021,32 @@ | ||
| 1017 | 1021 | ** </ol> |
| 1018 | 1022 | */ |
| 1019 | 1023 | int sqlite3_prepare( |
| 1020 | 1024 | sqlite3 *db, /* Database handle */ |
| 1021 | 1025 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
| 1022 | - int nBytes, /* Length of zSql in bytes. */ | |
| 1026 | + int nByte, /* Maximum length of zSql in bytes. */ | |
| 1023 | 1027 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1024 | 1028 | const char **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1025 | 1029 | ); |
| 1026 | 1030 | int sqlite3_prepare_v2( |
| 1027 | 1031 | sqlite3 *db, /* Database handle */ |
| 1028 | 1032 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
| 1029 | - int nBytes, /* Length of zSql in bytes. */ | |
| 1033 | + int nByte, /* Maximum length of zSql in bytes. */ | |
| 1030 | 1034 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1031 | 1035 | const char **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1032 | 1036 | ); |
| 1033 | 1037 | int sqlite3_prepare16( |
| 1034 | 1038 | sqlite3 *db, /* Database handle */ |
| 1035 | 1039 | const void *zSql, /* SQL statement, UTF-16 encoded */ |
| 1036 | - int nBytes, /* Length of zSql in bytes. */ | |
| 1040 | + int nByte, /* Maximum length of zSql in bytes. */ | |
| 1037 | 1041 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1038 | 1042 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1039 | 1043 | ); |
| 1040 | 1044 | int sqlite3_prepare16_v2( |
| 1041 | 1045 | sqlite3 *db, /* Database handle */ |
| 1042 | 1046 | const void *zSql, /* SQL statement, UTF-16 encoded */ |
| 1043 | - int nBytes, /* Length of zSql in bytes. */ | |
| 1047 | + int nByte, /* Maximum length of zSql in bytes. */ | |
| 1044 | 1048 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1045 | 1049 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1046 | 1050 | ); |
| 1047 | 1051 | |
| 1048 | 1052 | /* |
| 1049 | 1053 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -28,11 +28,11 @@ | |
| 28 | ** The name of this file under configuration management is "sqlite.h.in". |
| 29 | ** The makefile makes some minor changes to this file (such as inserting |
| 30 | ** the version number) and changes its name to "sqlite3.h" as |
| 31 | ** part of the build process. |
| 32 | ** |
| 33 | ** @(#) $Id: sqlite.h.in,v 1.217 2007/06/27 15:53:35 danielk1977 Exp $ |
| 34 | */ |
| 35 | #ifndef _SQLITE3_H_ |
| 36 | #define _SQLITE3_H_ |
| 37 | #include <stdarg.h> /* Needed for the definition of va_list */ |
| 38 | |
| @@ -79,12 +79,12 @@ | |
| 79 | ** version 3.1.1 or greater at compile time, programs may use the test |
| 80 | ** (SQLITE_VERSION_NUMBER>=3001001). |
| 81 | ** |
| 82 | ** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()]. |
| 83 | */ |
| 84 | #define SQLITE_VERSION "3.4.0" |
| 85 | #define SQLITE_VERSION_NUMBER 3004000 |
| 86 | |
| 87 | /* |
| 88 | ** CAPI3REF: Run-Time Library Version Numbers |
| 89 | ** |
| 90 | ** These routines return values equivalent to the header constants |
| @@ -961,14 +961,18 @@ | |
| 961 | ** The first argument "db" is an [sqlite3 | SQLite database handle] |
| 962 | ** obtained from a prior call to [sqlite3_open()] or [sqlite3_open16()]. |
| 963 | ** The second argument "zSql" is the statement to be compiled, encoded |
| 964 | ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() |
| 965 | ** interfaces uses UTF-8 and sqlite3_prepare16() and sqlite3_prepare16_v2() |
| 966 | ** use UTF-16. If the next argument, "nBytes", is less |
| 967 | ** than zero, then zSql is read up to the first zero terminator. If |
| 968 | ** "nBytes" is not less than zero, then it is the length of the string zSql |
| 969 | ** in bytes (not characters). |
| 970 | ** |
| 971 | ** *pzTail is made to point to the first byte past the end of the first |
| 972 | ** SQL statement in zSql. This routine only compiles the first statement |
| 973 | ** in zSql, so *pzTail is left pointing to what remains uncompiled. |
| 974 | ** |
| @@ -1017,32 +1021,32 @@ | |
| 1017 | ** </ol> |
| 1018 | */ |
| 1019 | int sqlite3_prepare( |
| 1020 | sqlite3 *db, /* Database handle */ |
| 1021 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
| 1022 | int nBytes, /* Length of zSql in bytes. */ |
| 1023 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1024 | const char **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1025 | ); |
| 1026 | int sqlite3_prepare_v2( |
| 1027 | sqlite3 *db, /* Database handle */ |
| 1028 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
| 1029 | int nBytes, /* Length of zSql in bytes. */ |
| 1030 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1031 | const char **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1032 | ); |
| 1033 | int sqlite3_prepare16( |
| 1034 | sqlite3 *db, /* Database handle */ |
| 1035 | const void *zSql, /* SQL statement, UTF-16 encoded */ |
| 1036 | int nBytes, /* Length of zSql in bytes. */ |
| 1037 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1038 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1039 | ); |
| 1040 | int sqlite3_prepare16_v2( |
| 1041 | sqlite3 *db, /* Database handle */ |
| 1042 | const void *zSql, /* SQL statement, UTF-16 encoded */ |
| 1043 | int nBytes, /* Length of zSql in bytes. */ |
| 1044 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1045 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1046 | ); |
| 1047 | |
| 1048 | /* |
| 1049 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -28,11 +28,11 @@ | |
| 28 | ** The name of this file under configuration management is "sqlite.h.in". |
| 29 | ** The makefile makes some minor changes to this file (such as inserting |
| 30 | ** the version number) and changes its name to "sqlite3.h" as |
| 31 | ** part of the build process. |
| 32 | ** |
| 33 | ** @(#) $Id: sqlite.h.in,v 1.218 2007/07/19 12:41:40 drh Exp $ |
| 34 | */ |
| 35 | #ifndef _SQLITE3_H_ |
| 36 | #define _SQLITE3_H_ |
| 37 | #include <stdarg.h> /* Needed for the definition of va_list */ |
| 38 | |
| @@ -79,12 +79,12 @@ | |
| 79 | ** version 3.1.1 or greater at compile time, programs may use the test |
| 80 | ** (SQLITE_VERSION_NUMBER>=3001001). |
| 81 | ** |
| 82 | ** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()]. |
| 83 | */ |
| 84 | #define SQLITE_VERSION "3.4.1" |
| 85 | #define SQLITE_VERSION_NUMBER 3004001 |
| 86 | |
| 87 | /* |
| 88 | ** CAPI3REF: Run-Time Library Version Numbers |
| 89 | ** |
| 90 | ** These routines return values equivalent to the header constants |
| @@ -961,14 +961,18 @@ | |
| 961 | ** The first argument "db" is an [sqlite3 | SQLite database handle] |
| 962 | ** obtained from a prior call to [sqlite3_open()] or [sqlite3_open16()]. |
| 963 | ** The second argument "zSql" is the statement to be compiled, encoded |
| 964 | ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() |
| 965 | ** interfaces uses UTF-8 and sqlite3_prepare16() and sqlite3_prepare16_v2() |
| 966 | ** use UTF-16. |
| 967 | ** |
| 968 | ** If the nByte argument is less |
| 969 | ** than zero, then zSql is read up to the first zero terminator. If |
| 970 | ** nByte is non-negative, then it is the maximum number of |
| 971 | ** bytes read from zSql. When nByte is non-negative, the |
| 972 | ** zSql string ends at either the first '\000' character or |
| 973 | ** until the nByte-th byte, whichever comes first. |
| 974 | ** |
| 975 | ** *pzTail is made to point to the first byte past the end of the first |
| 976 | ** SQL statement in zSql. This routine only compiles the first statement |
| 977 | ** in zSql, so *pzTail is left pointing to what remains uncompiled. |
| 978 | ** |
| @@ -1017,32 +1021,32 @@ | |
| 1021 | ** </ol> |
| 1022 | */ |
| 1023 | int sqlite3_prepare( |
| 1024 | sqlite3 *db, /* Database handle */ |
| 1025 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
| 1026 | int nByte, /* Maximum length of zSql in bytes. */ |
| 1027 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1028 | const char **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1029 | ); |
| 1030 | int sqlite3_prepare_v2( |
| 1031 | sqlite3 *db, /* Database handle */ |
| 1032 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
| 1033 | int nByte, /* Maximum length of zSql in bytes. */ |
| 1034 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1035 | const char **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1036 | ); |
| 1037 | int sqlite3_prepare16( |
| 1038 | sqlite3 *db, /* Database handle */ |
| 1039 | const void *zSql, /* SQL statement, UTF-16 encoded */ |
| 1040 | int nByte, /* Maximum length of zSql in bytes. */ |
| 1041 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1042 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1043 | ); |
| 1044 | int sqlite3_prepare16_v2( |
| 1045 | sqlite3 *db, /* Database handle */ |
| 1046 | const void *zSql, /* SQL statement, UTF-16 encoded */ |
| 1047 | int nByte, /* Maximum length of zSql in bytes. */ |
| 1048 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 1049 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 1050 | ); |
| 1051 | |
| 1052 | /* |
| 1053 |