Fossil SCM

Merge in the latest SQLite updates.

drh 2007-07-24 12:54 UTC trunk
Commit d8590e093f90a262d5eda169781143a5a25942eb
2 files changed +212 -255 +14 -10
+212 -255
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** 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
44
** single large file, the entire code can be compiled as a one translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% are more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -9,17 +9,17 @@
99
**
1010
** This file is all you need to compile SQLite. To use SQLite in other
1111
** programs, you need this file and the "sqlite3.h" header file that defines
1212
** the programming interface to the SQLite library. (If you do not have
1313
** 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
1515
** needed if you want a wrapper to interface SQLite with your choice of
1616
** programming language. The code for the "sqlite3" command-line shell
1717
** is also in a separate file. This file contains only code for the core
1818
** SQLite library.
1919
**
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.
2121
*/
2222
#define SQLITE_AMALGAMATION 1
2323
#ifndef SQLITE_PRIVATE
2424
# define SQLITE_PRIVATE static
2525
#endif
@@ -57,11 +57,11 @@
5757
** The name of this file under configuration management is "sqlite.h.in".
5858
** The makefile makes some minor changes to this file (such as inserting
5959
** the version number) and changes its name to "sqlite3.h" as
6060
** part of the build process.
6161
**
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 $
6363
*/
6464
#ifndef _SQLITE3_H_
6565
#define _SQLITE3_H_
6666
#include <stdarg.h> /* Needed for the definition of va_list */
6767
@@ -108,12 +108,12 @@
108108
** version 3.1.1 or greater at compile time, programs may use the test
109109
** (SQLITE_VERSION_NUMBER>=3001001).
110110
**
111111
** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()].
112112
*/
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
115115
116116
/*
117117
** CAPI3REF: Run-Time Library Version Numbers
118118
**
119119
** These routines return values equivalent to the header constants
@@ -990,14 +990,18 @@
990990
** The first argument "db" is an [sqlite3 | SQLite database handle]
991991
** obtained from a prior call to [sqlite3_open()] or [sqlite3_open16()].
992992
** The second argument "zSql" is the statement to be compiled, encoded
993993
** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
994994
** 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
996998
** 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.
9991003
**
10001004
** *pzTail is made to point to the first byte past the end of the first
10011005
** SQL statement in zSql. This routine only compiles the first statement
10021006
** in zSql, so *pzTail is left pointing to what remains uncompiled.
10031007
**
@@ -1046,32 +1050,32 @@
10461050
** </ol>
10471051
*/
10481052
SQLITE_API int sqlite3_prepare(
10491053
sqlite3 *db, /* Database handle */
10501054
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. */
10521056
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
10531057
const char **pzTail /* OUT: Pointer to unused portion of zSql */
10541058
);
10551059
int sqlite3_prepare_v2(
10561060
sqlite3 *db, /* Database handle */
10571061
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. */
10591063
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
10601064
const char **pzTail /* OUT: Pointer to unused portion of zSql */
10611065
);
10621066
SQLITE_API int sqlite3_prepare16(
10631067
sqlite3 *db, /* Database handle */
10641068
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. */
10661070
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
10671071
const void **pzTail /* OUT: Pointer to unused portion of zSql */
10681072
);
10691073
int sqlite3_prepare16_v2(
10701074
sqlite3 *db, /* Database handle */
10711075
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. */
10731077
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
10741078
const void **pzTail /* OUT: Pointer to unused portion of zSql */
10751079
);
10761080
10771081
/*
@@ -2788,11 +2792,11 @@
27882792
** May you share freely, never taking more than you give.
27892793
**
27902794
*************************************************************************
27912795
** Internal interface definitions for SQLite.
27922796
**
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 $
27942798
*/
27952799
#ifndef _SQLITEINT_H_
27962800
#define _SQLITEINT_H_
27972801
/************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/
27982802
/************** Begin file sqliteLimit.h *************************************/
@@ -5919,65 +5923,18 @@
59195923
* even when no triggers exist
59205924
*/
59215925
extern int sqlite3_always_code_trigger_setup;
59225926
59235927
/*
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
+*/
59715931
#define SQLITE_SKIP_UTF8(zIn) { \
59725932
if( (*(zIn++))>=0xc0 ){ \
59735933
while( (*zIn & 0xc0)==0x80 ){ zIn++; } \
59745934
} \
59755935
}
5976
-
5977
-
5978
-
59795936
59805937
/*
59815938
** The SQLITE_CORRUPT_BKPT macro can be either a constant (for production
59825939
** builds) or a function call (for debugging). If it is a function call,
59835940
** it allows the operator to set a breakpoint at the spot where database
@@ -6193,11 +6150,11 @@
61936150
SQLITE_API char *sqlite3_snprintf(int,char*,const char*,...);
61946151
SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);
61956152
SQLITE_PRIVATE int sqlite3FitsIn64Bits(const char *);
61966153
SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar);
61976154
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**);
61996156
SQLITE_PRIVATE int sqlite3PutVarint(unsigned char *, u64);
62006157
SQLITE_PRIVATE int sqlite3GetVarint(const unsigned char *, u64 *);
62016158
SQLITE_PRIVATE int sqlite3GetVarint32(const unsigned char *, u32 *);
62026159
SQLITE_PRIVATE int sqlite3VarintLen(u64 v);
62036160
SQLITE_PRIVATE void sqlite3IndexAffinityStr(Vdbe *, Index *);
@@ -6265,10 +6222,17 @@
62656222
SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int);
62666223
SQLITE_PRIVATE void sqlite3FailedMalloc(void);
62676224
SQLITE_PRIVATE void sqlite3AbortOtherActiveVdbes(sqlite3 *, Vdbe *);
62686225
SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *);
62696226
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
+
62706234
#ifndef SQLITE_OMIT_LOAD_EXTENSION
62716235
SQLITE_PRIVATE void sqlite3CloseExtensions(sqlite3*);
62726236
SQLITE_PRIVATE int sqlite3AutoLoadExtensions(sqlite3*);
62736237
#else
62746238
# define sqlite3CloseExtensions(X)
@@ -9286,11 +9250,11 @@
92869250
**
92879251
*************************************************************************
92889252
** This file contains routines used to translate between UTF-8,
92899253
** UTF-16, UTF-16BE, and UTF-16LE.
92909254
**
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 $
92929256
**
92939257
** Notes on UTF-8:
92949258
**
92959259
** Byte-0 Byte-1 Byte-2 Byte-3 Value
92969260
** 0xxxxxxx 00000000 00000000 0xxxxxxx
@@ -9764,10 +9728,11 @@
97649728
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
97659729
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
97669730
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
97679731
0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,
97689732
};
9733
+
97699734
97709735
#define WRITE_UTF8(zOut, c) { \
97719736
if( c<0x00080 ){ \
97729737
*zOut++ = (c&0xFF); \
97739738
} \
@@ -9830,10 +9795,58 @@
98309795
c2 += (*zIn++); \
98319796
c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \
98329797
if( (c & 0xFFFF0000)==0 ) c = 0xFFFD; \
98339798
} \
98349799
}
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
+
98359848
98369849
/*
98379850
** If the TRANSLATE_TRACE macro is defined, the value of each Mem is
98389851
** printed on stderr on the way into and out of sqlite3VdbeMemTranslate().
98399852
*/
@@ -9924,85 +9937,23 @@
99249937
zOut = zShort;
99259938
}
99269939
z = zOut;
99279940
99289941
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
-
99859942
if( desiredEnc==SQLITE_UTF16LE ){
99869943
/* UTF-8 -> UTF-16 Little-endian */
99879944
while( zIn<zTerm ){
9988
- SQLITE_READ_UTF8(zIn, c);
9945
+ c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn);
99899946
WRITE_UTF16LE(z, c);
99909947
}
9991
- if( iExtra!=0xD800 ){
9992
- WRITE_UTF16LE(z, iExtra);
9993
- }
99949948
}else{
99959949
assert( desiredEnc==SQLITE_UTF16BE );
99969950
/* UTF-8 -> UTF-16 Big-endian */
99979951
while( zIn<zTerm ){
9998
- SQLITE_READ_UTF8(zIn, c);
9952
+ c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn);
99999953
WRITE_UTF16BE(z, c);
100009954
}
10001
- if( iExtra!=0xD800 ){
10002
- WRITE_UTF16BE(z, iExtra);
10003
- }
100049955
}
100059956
pMem->n = z - zOut;
100069957
*z++ = 0;
100079958
}else{
100089959
assert( desiredEnc==SQLITE_UTF8 );
@@ -10182,15 +10133,15 @@
1018210133
** correct UTF-8 encoding to be longer than a malformed encoding).
1018310134
*/
1018410135
SQLITE_PRIVATE int sqlite3Utf8To8(unsigned char *zIn){
1018510136
unsigned char *zOut = zIn;
1018610137
unsigned char *zStart = zIn;
10187
- int c;
10138
+ unsigned char *zTerm;
10139
+ u32 c;
1018810140
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);
1019210143
if( c!=0xfffd ){
1019310144
WRITE_UTF8(zOut, c);
1019410145
}
1019510146
}
1019610147
*zOut = 0;
@@ -10206,20 +10157,22 @@
1020610157
*/
1020710158
SQLITE_PRIVATE void sqlite3UtfSelfTest(){
1020810159
unsigned int i, t;
1020910160
unsigned char zBuf[20];
1021010161
unsigned char *z;
10162
+ unsigned char *zTerm;
1021110163
int n;
1021210164
unsigned int c;
1021310165
1021410166
for(i=0; i<0x00110000; i++){
1021510167
z = zBuf;
1021610168
WRITE_UTF8(z, i);
1021710169
n = z-zBuf;
1021810170
z[0] = 0;
10171
+ zTerm = z;
1021910172
z = zBuf;
10220
- SQLITE_READ_UTF8(z, c);
10173
+ c = sqlite3Utf8Read(z, zTerm, (const u8**)&z);
1022110174
t = i;
1022210175
if( i>=0xD800 && i<=0xDFFF ) t = 0xFFFD;
1022310176
if( (i&0xFFFFFFFE)==0xFFFE ) t = 0xFFFD;
1022410177
assert( c==t );
1022510178
assert( (z-zBuf)==n );
@@ -17876,11 +17829,11 @@
1787617829
** is separate from the database file. The pager also implements file
1787717830
** locking to prevent two processes from writing the same database
1787817831
** file simultaneously, or one process from reading the database while
1787917832
** another is writing.
1788017833
**
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 $
1788217835
*/
1788317836
#ifndef SQLITE_OMIT_DISKIO
1788417837
1788517838
/*
1788617839
** Macros for troubleshooting. Normally turned off
@@ -18402,21 +18355,10 @@
1840218355
static int write32bits(OsFile *fd, u32 val){
1840318356
char ac[4];
1840418357
put32bits(ac, val);
1840518358
return sqlite3OsWrite(fd, ac, 4);
1840618359
}
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
-
1841818360
1841918361
/*
1842018362
** This function should be called when an error occurs within the pager
1842118363
** code. The first argument is a pointer to the pager structure, the
1842218364
** second the error-code about to be returned by a pager API function.
@@ -21725,14 +21667,12 @@
2172521667
rc = sqlite3PagerGet(pPager, 1, &pPgHdr);
2172621668
if( rc!=SQLITE_OK ) return rc;
2172721669
rc = sqlite3PagerWrite(pPgHdr);
2172821670
if( rc!=SQLITE_OK ) return rc;
2172921671
21730
- /* Read the current value at byte 24. */
21731
- change_counter = retrieve32bits(pPgHdr, 24);
21732
-
2173321672
/* Increment the value just read and write it back to byte 24. */
21673
+ change_counter = sqlite3Get4byte((u8*)pPager->dbFileVers);
2173421674
change_counter++;
2173521675
put32bits(((char*)PGHDR_TO_DATA(pPgHdr))+24, change_counter);
2173621676
/* Release the page reference. */
2173721677
sqlite3PagerUnref(pPgHdr);
2173821678
pPager->changeCountDone = 1;
@@ -22347,11 +22287,11 @@
2234722287
** May you do good and not evil.
2234822288
** May you find forgiveness for yourself and forgive others.
2234922289
** May you share freely, never taking more than you give.
2235022290
**
2235122291
*************************************************************************
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 $
2235322293
**
2235422294
** This file implements a external (disk-based) database using BTrees.
2235522295
** See the header comment on "btreeInt.h" for additional information.
2235622296
** Including a description of file format and an overview of operation.
2235722297
*/
@@ -24934,11 +24874,11 @@
2493424874
}
2493524875
if( rc==SQLITE_DONE ){
2493624876
assert(nFin==0 || pBt->nTrunc==0 || nFin<=pBt->nTrunc);
2493724877
rc = SQLITE_OK;
2493824878
if( pBt->nTrunc ){
24939
- sqlite3PagerWrite(pBt->pPage1->pDbPage);
24879
+ rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
2494024880
put4byte(&pBt->pPage1->aData[32], 0);
2494124881
put4byte(&pBt->pPage1->aData[36], 0);
2494224882
pBt->nTrunc = nFin;
2494324883
}
2494424884
}
@@ -33573,11 +33513,11 @@
3357333513
** documentation, headers files, or other derived files. The formatting
3357433514
** of the code in this file is, therefore, important. See other comments
3357533515
** in this file for details. If in doubt, do not deviate from existing
3357633516
** commenting and indentation practices when changing or adding code.
3357733517
**
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 $
3357933519
*/
3358033520
3358133521
/*
3358233522
** The following global variable is incremented every time a cursor
3358333523
** moves, either by the OP_MoveXX, OP_Next, or OP_Prev opcodes. The test
@@ -37824,18 +37764,18 @@
3782437764
3782537765
for(nRoot=0; &pTos[-nRoot]>=p->aStack; nRoot++){
3782637766
if( (pTos[-nRoot].flags & MEM_Int)==0 ) break;
3782737767
}
3782837768
assert( nRoot>0 );
37829
- aRoot = sqliteMallocRaw( sizeof(int*)*(nRoot+1) );
37769
+ aRoot = sqliteMallocRaw( sizeof(int)*(nRoot+1) );
3783037770
if( aRoot==0 ) goto no_mem;
3783137771
j = pOp->p1;
3783237772
assert( j>=0 && j<p->nMem );
3783337773
pnErr = &p->aMem[j];
3783437774
assert( (pnErr->flags & MEM_Int)!=0 );
3783537775
for(j=0; j<nRoot; j++){
37836
- aRoot[j] = pTos[-j].u.i;
37776
+ aRoot[j] = (pTos-j)->u.i;
3783737777
}
3783837778
aRoot[j] = 0;
3783937779
popStack(&pTos, nRoot);
3784037780
pTos++;
3784137781
z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p2].pBt, aRoot, nRoot,
@@ -39076,11 +39016,11 @@
3907639016
**
3907739017
*************************************************************************
3907839018
** This file contains routines used for analyzing expressions and
3907939019
** for generating VDBE code that evaluates expressions in SQLite.
3908039020
**
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 $
3908239022
*/
3908339023
3908439024
/*
3908539025
** Return the 'affinity' of the expression pExpr if any.
3908639026
**
@@ -40202,15 +40142,21 @@
4020240142
*/
4020340143
if( cnt==0 && (pEList = pNC->pEList)!=0 && zTab==0 ){
4020440144
for(j=0; j<pEList->nExpr; j++){
4020540145
char *zAs = pEList->a[j].zName;
4020640146
if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){
40207
- Expr *pDup;
40147
+ Expr *pDup, *pOrig;
4020840148
assert( pExpr->pLeft==0 && pExpr->pRight==0 );
4020940149
assert( pExpr->pList==0 );
4021040150
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);
4021240158
if( pExpr->flags & EP_ExpCollate ){
4021340159
pDup->pColl = pExpr->pColl;
4021440160
pDup->flags |= EP_ExpCollate;
4021540161
}
4021640162
if( pExpr->span.dyn ) sqliteFree((char*)pExpr->span.z);
@@ -47909,13 +47855,14 @@
4790947855
**
4791047856
** There is only one exported symbol in this file - the function
4791147857
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
4791247858
** All other code has file scope.
4791347859
**
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 $
4791547861
*/
4791647862
/* #include <math.h> */
47863
+
4791747864
4791847865
/*
4791947866
** Return the collating function associated with a function.
4792047867
*/
4792147868
static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){
@@ -48284,19 +48231,10 @@
4828448231
static const struct compareInfo likeInfoNorm = { '%', '_', 0, 1 };
4828548232
/* If SQLITE_CASE_SENSITIVE_LIKE is defined, then the LIKE operator
4828648233
** is case sensitive causing 'a' LIKE 'A' to be false */
4828748234
static const struct compareInfo likeInfoAlt = { '%', '_', 0, 0 };
4828848235
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
-
4829848236
/*
4829948237
** Compare two UTF-8 strings for equality where the first string can
4830048238
** potentially be a "glob" expression. Return true (1) if they
4830148239
** are the same and false (0) if they are different.
4830248240
**
@@ -48327,101 +48265,106 @@
4832748265
const u8 *zPattern, /* The glob pattern */
4832848266
const u8 *zString, /* The string to compare against the glob */
4832948267
const struct compareInfo *pInfo, /* Information about how to do the compare */
4833048268
const int esc /* The escape character */
4833148269
){
48332
- register int c;
48270
+ int c, c2;
4833348271
int invert;
4833448272
int seen;
48335
- int c2;
4833648273
u8 matchOne = pInfo->matchOne;
4833748274
u8 matchAll = pInfo->matchAll;
4833848275
u8 matchSet = pInfo->matchSet;
4833948276
u8 noCase = pInfo->noCase;
4834048277
int prevEscape = 0; /* True if the previous character was 'escape' */
4834148278
48342
- while( (c = *zPattern)!=0 ){
48279
+ while( (c = sqlite3Utf8Read(zPattern,0,&zPattern))!=0 ){
4834348280
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 ){
4836048298
SQLITE_SKIP_UTF8(zString);
4836148299
}
4836248300
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 ){
4837648321
return 0;
4837748322
}
48378
- }else if( !prevEscape && c==matchOne ){
48379
- if( *zString==0 ) return 0;
48380
- SQLITE_SKIP_UTF8(zString);
48381
- zPattern++;
4838248323
}else if( c==matchSet ){
4838348324
int prior_c = 0;
4838448325
assert( esc==0 ); /* This only occurs for GLOB, not LIKE */
4838548326
seen = 0;
4838648327
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
+ }
4842348366
prevEscape = 0;
4842448367
}
4842548368
}
4842648369
return *zString==0;
4842748370
}
@@ -48477,11 +48420,11 @@
4847748420
if( sqlite3Utf8CharLen((char*)zEsc, -1)!=1 ){
4847848421
sqlite3_result_error(context,
4847948422
"ESCAPE expression must be a single character", -1);
4848048423
return;
4848148424
}
48482
- escape = sqlite3ReadUtf8(zEsc);
48425
+ escape = sqlite3Utf8Read(zEsc, 0, &zEsc);
4848348426
}
4848448427
if( zA && zB ){
4848548428
struct compareInfo *pInfo = sqlite3_user_data(context);
4848648429
#ifdef SQLITE_TEST
4848748430
sqlite3_like_count++;
@@ -49395,11 +49338,11 @@
4939549338
**
4939649339
*************************************************************************
4939749340
** This file contains C code routines that are called by the parser
4939849341
** to handle INSERT statements in SQLite.
4939949342
**
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 $
4940149344
*/
4940249345
4940349346
/*
4940449347
** Set P3 of the most recently inserted opcode to a column affinity
4940549348
** string for index pIdx. A column affinity string has one character
@@ -50409,11 +50352,11 @@
5040950352
pParse->ckOffset = nCol;
5041050353
sqlite3ExprIfTrue(pParse, pTab->pCheck, allOk, 1);
5041150354
assert( pParse->ckOffset==nCol );
5041250355
pParse->ckOffset = 0;
5041350356
onError = overrideError!=OE_Default ? overrideError : OE_Abort;
50414
- if( onError==OE_Ignore || onError==OE_Replace ){
50357
+ if( onError==OE_Ignore ){
5041550358
sqlite3VdbeAddOp(v, OP_Pop, nCol+1+hasTwoRowids, 0);
5041650359
sqlite3VdbeAddOp(v, OP_Goto, 0, ignoreDest);
5041750360
}else{
5041850361
sqlite3VdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError);
5041950362
}
@@ -51155,20 +51098,26 @@
5115551098
** shared libraries that want to be imported as extensions into
5115651099
** an SQLite instance. Shared libraries that intend to be loaded
5115751100
** as extensions by SQLite should #include this file instead of
5115851101
** sqlite3.h.
5115951102
**
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 $
5116151104
*/
5116251105
#ifndef _SQLITE3EXT_H_
5116351106
#define _SQLITE3EXT_H_
5116451107
5116551108
typedef struct sqlite3_api_routines sqlite3_api_routines;
5116651109
5116751110
/*
5116851111
** The following structure hold pointers to all of the SQLite API
5116951112
** 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!
5117051119
*/
5117151120
struct sqlite3_api_routines {
5117251121
void * (*aggregate_context)(sqlite3_context*,int nBytes);
5117351122
int (*aggregate_count)(sqlite3_context*);
5117451123
int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
@@ -51215,11 +51164,10 @@
5121551164
int (*create_collation)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*));
5121651165
int (*create_collation16)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*));
5121751166
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*));
5121851167
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*));
5121951168
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 *));
5122151169
int (*data_count)(sqlite3_stmt*pStmt);
5122251170
sqlite3 * (*db_handle)(sqlite3_stmt*);
5122351171
int (*declare_vtab)(sqlite3*,const char*);
5122451172
int (*enable_shared_cache)(int);
5122551173
int (*errcode)(sqlite3*db);
@@ -51287,10 +51235,11 @@
5128751235
char *(*vmprintf)(const char*,va_list);
5128851236
int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);
5128951237
int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
5129051238
int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
5129151239
int (*clear_bindings)(sqlite3_stmt*);
51240
+ int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,void (*xDestroy)(void *));
5129251241
};
5129351242
5129451243
/*
5129551244
** The following macros redefine the API routines so that they are
5129651245
** redirected throught the global sqlite3_api structure.
@@ -51570,11 +51519,10 @@
5157051519
sqlite3_create_collation,
5157151520
sqlite3_create_collation16,
5157251521
sqlite3_create_function,
5157351522
sqlite3_create_function16,
5157451523
sqlite3_create_module,
51575
- sqlite3_create_module_v2,
5157651524
sqlite3_data_count,
5157751525
sqlite3_db_handle,
5157851526
sqlite3_declare_vtab,
5157951527
sqlite3_enable_shared_cache,
5158051528
sqlite3_errcode,
@@ -51654,10 +51602,16 @@
5165451602
** Added after 3.3.13
5165551603
*/
5165651604
sqlite3_prepare_v2,
5165751605
sqlite3_prepare16_v2,
5165851606
sqlite3_clear_bindings,
51607
+
51608
+ /*
51609
+ ** Added for 3.4.1
51610
+ */
51611
+ sqlite3_create_module_v2,
51612
+
5165951613
};
5166051614
5166151615
/*
5166251616
** Attempt to load an SQLite extension library contained in the file
5166351617
** zFile. The entry point is zProc. zProc may be 0 in which case a
@@ -53737,11 +53691,11 @@
5373753691
**
5373853692
*************************************************************************
5373953693
** This file contains C code routines that are called by the parser
5374053694
** to handle SELECT statements in SQLite.
5374153695
**
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 $
5374353697
*/
5374453698
5374553699
5374653700
/*
5374753701
** Delete all the content of a Select structure but do not deallocate
@@ -56237,10 +56191,20 @@
5623756191
(char*)pKey, P3_KEYINFO_HANDOFF);
5623856192
if( seekOp==OP_Rewind ){
5623956193
sqlite3VdbeAddOp(v, OP_Null, 0, 0);
5624056194
sqlite3VdbeAddOp(v, OP_MakeRecord, 1, 0);
5624156195
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
+ }
5624256206
}
5624356207
sqlite3VdbeAddOp(v, seekOp, iIdx, 0);
5624456208
sqlite3VdbeAddOp(v, OP_IdxRowid, iIdx, 0);
5624556209
sqlite3VdbeAddOp(v, OP_Close, iIdx, 0);
5624656210
sqlite3VdbeAddOp(v, OP_MoveGe, base, 0);
@@ -65805,11 +65769,11 @@
6580565769
**
6580665770
** This file contains C code that splits an SQL input string up into
6580765771
** individual tokens and sends those tokens one-by-one over to the
6580865772
** parser for analysis.
6580965773
**
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 $
6581165775
*/
6581265776
6581365777
/*
6581465778
** The charMap() macro maps alphabetic characters into their
6581565779
** lower-case ASCII equivalent. On ASCII machines, this is just
@@ -66282,17 +66246,10 @@
6628266246
}
6628366247
SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){
6628466248
return getToken(z, tokenType);
6628566249
}
6628666250
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
-
6629466251
/*
6629566252
** Run the parser on the given SQL string. The parser structure is
6629666253
** passed in. An SQLITE_ status code is returned. If an error occurs
6629766254
** and pzErrMsg!=NULL then an error message might be written into
6629866255
** memory obtained from malloc() and *pzErrMsg made to point to that
6629966256
--- 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 @@
2828
** The name of this file under configuration management is "sqlite.h.in".
2929
** The makefile makes some minor changes to this file (such as inserting
3030
** the version number) and changes its name to "sqlite3.h" as
3131
** part of the build process.
3232
**
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 $
3434
*/
3535
#ifndef _SQLITE3_H_
3636
#define _SQLITE3_H_
3737
#include <stdarg.h> /* Needed for the definition of va_list */
3838
@@ -79,12 +79,12 @@
7979
** version 3.1.1 or greater at compile time, programs may use the test
8080
** (SQLITE_VERSION_NUMBER>=3001001).
8181
**
8282
** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()].
8383
*/
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
8686
8787
/*
8888
** CAPI3REF: Run-Time Library Version Numbers
8989
**
9090
** These routines return values equivalent to the header constants
@@ -961,14 +961,18 @@
961961
** The first argument "db" is an [sqlite3 | SQLite database handle]
962962
** obtained from a prior call to [sqlite3_open()] or [sqlite3_open16()].
963963
** The second argument "zSql" is the statement to be compiled, encoded
964964
** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
965965
** 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
967969
** 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.
970974
**
971975
** *pzTail is made to point to the first byte past the end of the first
972976
** SQL statement in zSql. This routine only compiles the first statement
973977
** in zSql, so *pzTail is left pointing to what remains uncompiled.
974978
**
@@ -1017,32 +1021,32 @@
10171021
** </ol>
10181022
*/
10191023
int sqlite3_prepare(
10201024
sqlite3 *db, /* Database handle */
10211025
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. */
10231027
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
10241028
const char **pzTail /* OUT: Pointer to unused portion of zSql */
10251029
);
10261030
int sqlite3_prepare_v2(
10271031
sqlite3 *db, /* Database handle */
10281032
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. */
10301034
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
10311035
const char **pzTail /* OUT: Pointer to unused portion of zSql */
10321036
);
10331037
int sqlite3_prepare16(
10341038
sqlite3 *db, /* Database handle */
10351039
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. */
10371041
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
10381042
const void **pzTail /* OUT: Pointer to unused portion of zSql */
10391043
);
10401044
int sqlite3_prepare16_v2(
10411045
sqlite3 *db, /* Database handle */
10421046
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. */
10441048
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
10451049
const void **pzTail /* OUT: Pointer to unused portion of zSql */
10461050
);
10471051
10481052
/*
10491053
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button