Fossil SCM

Update to version SQLite 3.6.13

drh 2009-04-13 09:50 trunk
Commit 879e8c5f32be016d3c9cd7fb3f98e787aa823424
2 files changed +1336 -1017 +31 -15
+1336 -1017
--- 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.6.12. By combining all the individual C code files into this
3
+** version 3.6.13. 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
-** 5487 lines past this header comment.) Additional code files may be
14
+** 5503 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 2009-03-31 12:19:59 UTC.
20
+** This amalgamation was generated on 2009-04-13 09:47:15 UTC.
2121
*/
2222
#define SQLITE_CORE 1
2323
#define SQLITE_AMALGAMATION 1
2424
#ifndef SQLITE_PRIVATE
2525
# define SQLITE_PRIVATE static
@@ -39,11 +39,11 @@
3939
** May you share freely, never taking more than you give.
4040
**
4141
*************************************************************************
4242
** Internal interface definitions for SQLite.
4343
**
44
-** @(#) $Id: sqliteInt.h,v 1.848 2009/03/25 16:51:43 drh Exp $
44
+** @(#) $Id: sqliteInt.h,v 1.854 2009/04/08 13:51:51 drh Exp $
4545
*/
4646
#ifndef _SQLITEINT_H_
4747
#define _SQLITEINT_H_
4848
4949
/*
@@ -530,11 +530,11 @@
530530
** The name of this file under configuration management is "sqlite.h.in".
531531
** The makefile makes some minor changes to this file (such as inserting
532532
** the version number) and changes its name to "sqlite3.h" as
533533
** part of the build process.
534534
**
535
-** @(#) $Id: sqlite.h.in,v 1.436 2009/03/20 13:15:30 drh Exp $
535
+** @(#) $Id: sqlite.h.in,v 1.440 2009/04/06 15:55:04 drh Exp $
536536
*/
537537
#ifndef _SQLITE3_H_
538538
#define _SQLITE3_H_
539539
#include <stdarg.h> /* Needed for the definition of va_list */
540540
@@ -599,12 +599,12 @@
599599
**
600600
** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()].
601601
**
602602
** Requirements: [H10011] [H10014]
603603
*/
604
-#define SQLITE_VERSION "3.6.12"
605
-#define SQLITE_VERSION_NUMBER 3006012
604
+#define SQLITE_VERSION "3.6.13"
605
+#define SQLITE_VERSION_NUMBER 3006013
606606
607607
/*
608608
** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
609609
** KEYWORDS: sqlite3_version
610610
**
@@ -882,11 +882,10 @@
882882
#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8))
883883
#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
884884
#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8))
885885
#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
886886
#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
887
-
888887
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) )
889888
890889
/*
891890
** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700>
892891
**
@@ -962,12 +961,13 @@
962961
** [sqlite3_io_methods] object it uses a combination of
963962
** these integer values as the second argument.
964963
**
965964
** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
966965
** sync operation only needs to flush data to mass storage. Inode
967
-** information need not be flushed. The SQLITE_SYNC_NORMAL flag means
968
-** to use normal fsync() semantics. The SQLITE_SYNC_FULL flag means
966
+** information need not be flushed. If the lower four bits of the flag
967
+** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.
968
+** If the lower four bits equal SQLITE_SYNC_FULL, that means
969969
** to use Mac OS X style fullsync instead of fsync().
970970
*/
971971
#define SQLITE_SYNC_NORMAL 0x00002
972972
#define SQLITE_SYNC_FULL 0x00003
973973
#define SQLITE_SYNC_DATAONLY 0x00010
@@ -2729,11 +2729,12 @@
27292729
**
27302730
** To execute an SQL query, it must first be compiled into a byte-code
27312731
** program using one of these routines.
27322732
**
27332733
** The first argument, "db", is a [database connection] obtained from a
2734
-** prior call to [sqlite3_open()], [sqlite3_open_v2()] or [sqlite3_open16()].
2734
+** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
2735
+** [sqlite3_open16()]. The database connection must not have been closed.
27352736
**
27362737
** The second argument, "zSql", is the statement to be compiled, encoded
27372738
** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
27382739
** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
27392740
** use UTF-16.
@@ -2746,21 +2747,22 @@
27462747
** that the supplied string is nul-terminated, then there is a small
27472748
** performance advantage to be gained by passing an nByte parameter that
27482749
** is equal to the number of bytes in the input string <i>including</i>
27492750
** the nul-terminator bytes.
27502751
**
2751
-** *pzTail is made to point to the first byte past the end of the
2752
-** first SQL statement in zSql. These routines only compile the first
2753
-** statement in zSql, so *pzTail is left pointing to what remains
2754
-** uncompiled.
2752
+** If pzTail is not NULL then *pzTail is made to point to the first byte
2753
+** past the end of the first SQL statement in zSql. These routines only
2754
+** compile the first statement in zSql, so *pzTail is left pointing to
2755
+** what remains uncompiled.
27552756
**
27562757
** *ppStmt is left pointing to a compiled [prepared statement] that can be
27572758
** executed using [sqlite3_step()]. If there is an error, *ppStmt is set
27582759
** to NULL. If the input text contains no SQL (if the input is an empty
27592760
** string or a comment) then *ppStmt is set to NULL.
2760
-** {A13018} The calling procedure is responsible for deleting the compiled
2761
+** The calling procedure is responsible for deleting the compiled
27612762
** SQL statement using [sqlite3_finalize()] after it has finished with it.
2763
+** ppStmt may not be NULL.
27622764
**
27632765
** On success, [SQLITE_OK] is returned, otherwise an [error code] is returned.
27642766
**
27652767
** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
27662768
** recommended for all new programs. The two older interfaces are retained
@@ -4130,14 +4132,28 @@
41304132
** the name of a folder (a.k.a. directory), then all temporary files
41314133
** created by SQLite will be placed in that directory. If this variable
41324134
** is a NULL pointer, then SQLite performs a search for an appropriate
41334135
** temporary file directory.
41344136
**
4135
-** It is not safe to modify this variable once a [database connection]
4136
-** has been opened. It is intended that this variable be set once
4137
+** It is not safe to read or modify this variable in more than one
4138
+** thread at a time. It is not safe to read or modify this variable
4139
+** if a [database connection] is being used at the same time in a separate
4140
+** thread.
4141
+** It is intended that this variable be set once
41374142
** as part of process initialization and before any SQLite interface
4138
-** routines have been call and remain unchanged thereafter.
4143
+** routines have been called and that this variable remain unchanged
4144
+** thereafter.
4145
+**
4146
+** The [temp_store_directory pragma] may modify this variable and cause
4147
+** it to point to memory obtained from [sqlite3_malloc]. Furthermore,
4148
+** the [temp_store_directory pragma] always assumes that any string
4149
+** that this variable points to is held in memory obtained from
4150
+** [sqlite3_malloc] and the pragma may attempt to free that memory
4151
+** using [sqlite3_free].
4152
+** Hence, if this variable is modified directly, either it should be
4153
+** made NULL or made to point to memory obtained from [sqlite3_malloc]
4154
+** or else the use of the [temp_store_directory pragma] should be avoided.
41394155
*/
41404156
SQLITE_API char *sqlite3_temp_directory;
41414157
41424158
/*
41434159
** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200>
@@ -6417,10 +6433,15 @@
64176433
/*
64186434
** Round down to the nearest multiple of 8
64196435
*/
64206436
#define ROUNDDOWN8(x) ((x)&~7)
64216437
6438
+/*
6439
+** Assert that the pointer X is aligned to an 8-byte boundary.
6440
+*/
6441
+#define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&7)==0)
6442
+
64226443
/*
64236444
** An instance of the following structure is used to store the busy-handler
64246445
** callback for a given sqlite handle.
64256446
**
64266447
** The sqlite.busyHandler member of the sqlite struct contains the busy
@@ -6571,11 +6592,11 @@
65716592
*************************************************************************
65726593
** This header file defines the interface that the sqlite B-Tree file
65736594
** subsystem. See comments in the source code for a detailed description
65746595
** of what each interface routine does.
65756596
**
6576
-** @(#) $Id: btree.h,v 1.111 2009/03/18 10:33:01 danielk1977 Exp $
6597
+** @(#) $Id: btree.h,v 1.113 2009/04/10 12:55:17 danielk1977 Exp $
65776598
*/
65786599
#ifndef _BTREE_H_
65796600
#define _BTREE_H_
65806601
65816602
/* TODO: This definition is just included so other modules compile. It
@@ -6638,11 +6659,11 @@
66386659
66396660
SQLITE_PRIVATE int sqlite3BtreeClose(Btree*);
66406661
SQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree*,int);
66416662
SQLITE_PRIVATE int sqlite3BtreeSetSafetyLevel(Btree*,int,int);
66426663
SQLITE_PRIVATE int sqlite3BtreeSyncDisabled(Btree*);
6643
-SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree*,int,int);
6664
+SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree*,int,int,int);
66446665
SQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree*);
66456666
SQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree*,int);
66466667
SQLITE_PRIVATE int sqlite3BtreeGetReserve(Btree*);
66476668
SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int);
66486669
SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *);
@@ -6744,46 +6765,43 @@
67446765
/*
67456766
** If we are not using shared cache, then there is no need to
67466767
** use mutexes to access the BtShared structures. So make the
67476768
** Enter and Leave procedures no-ops.
67486769
*/
6749
-#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
6770
+#ifndef SQLITE_OMIT_SHARED_CACHE
67506771
SQLITE_PRIVATE void sqlite3BtreeEnter(Btree*);
6772
+SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3*);
6773
+#else
6774
+# define sqlite3BtreeEnter(X)
6775
+# define sqlite3BtreeEnterAll(X)
6776
+#endif
6777
+
6778
+#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
67516779
SQLITE_PRIVATE void sqlite3BtreeLeave(Btree*);
6752
-#ifndef NDEBUG
6753
- /* This routine is used inside assert() statements only. */
6754
-SQLITE_PRIVATE int sqlite3BtreeHoldsMutex(Btree*);
6755
-#endif
67566780
SQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor*);
67576781
SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor*);
6758
-SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3*);
67596782
SQLITE_PRIVATE void sqlite3BtreeLeaveAll(sqlite3*);
6760
-#ifndef NDEBUG
6761
- /* This routine is used inside assert() statements only. */
6762
-SQLITE_PRIVATE int sqlite3BtreeHoldsAllMutexes(sqlite3*);
6763
-#endif
67646783
SQLITE_PRIVATE void sqlite3BtreeMutexArrayEnter(BtreeMutexArray*);
67656784
SQLITE_PRIVATE void sqlite3BtreeMutexArrayLeave(BtreeMutexArray*);
67666785
SQLITE_PRIVATE void sqlite3BtreeMutexArrayInsert(BtreeMutexArray*, Btree*);
6767
-#else
6768
-# define sqlite3BtreeEnter(X)
6769
-# define sqlite3BtreeLeave(X)
67706786
#ifndef NDEBUG
6771
- /* This routine is used inside assert() statements only. */
6772
-# define sqlite3BtreeHoldsMutex(X) 1
6787
+ /* These routines are used inside assert() statements only. */
6788
+SQLITE_PRIVATE int sqlite3BtreeHoldsMutex(Btree*);
6789
+SQLITE_PRIVATE int sqlite3BtreeHoldsAllMutexes(sqlite3*);
67736790
#endif
6791
+#else
6792
+
6793
+# define sqlite3BtreeLeave(X)
67746794
# define sqlite3BtreeEnterCursor(X)
67756795
# define sqlite3BtreeLeaveCursor(X)
6776
-# define sqlite3BtreeEnterAll(X)
67776796
# define sqlite3BtreeLeaveAll(X)
6778
-#ifndef NDEBUG
6779
- /* This routine is used inside assert() statements only. */
6780
-# define sqlite3BtreeHoldsAllMutexes(X) 1
6781
-#endif
67826797
# define sqlite3BtreeMutexArrayEnter(X)
67836798
# define sqlite3BtreeMutexArrayLeave(X)
67846799
# define sqlite3BtreeMutexArrayInsert(X,Y)
6800
+
6801
+# define sqlite3BtreeHoldsMutex(X) 1
6802
+# define sqlite3BtreeHoldsAllMutexes(X) 1
67856803
#endif
67866804
67876805
67886806
#endif /* _BTREE_H_ */
67896807
@@ -6806,11 +6824,11 @@
68066824
**
68076825
** This header defines the interface to the virtual database engine
68086826
** or VDBE. The VDBE implements an abstract machine that runs a
68096827
** simple program to access and modify the underlying database.
68106828
**
6811
-** $Id: vdbe.h,v 1.140 2009/02/19 14:39:25 danielk1977 Exp $
6829
+** $Id: vdbe.h,v 1.141 2009/04/10 00:56:29 drh Exp $
68126830
*/
68136831
#ifndef _SQLITE_VDBE_H_
68146832
#define _SQLITE_VDBE_H_
68156833
68166834
/*
@@ -7162,12 +7180,11 @@
71627180
SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
71637181
71647182
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
71657183
SQLITE_PRIVATE int sqlite3VdbeReleaseMemory(int);
71667184
#endif
7167
-SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,
7168
- UnpackedRecord*,int);
7185
+SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,char*,int);
71697186
SQLITE_PRIVATE void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord*);
71707187
SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);
71717188
71727189
71737190
#ifndef NDEBUG
@@ -8097,10 +8114,17 @@
80978114
u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
80988115
80998116
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
81008117
/* The following variables are all protected by the STATIC_MASTER
81018118
** mutex, not by sqlite3.mutex. They are used by code in notify.c.
8119
+ **
8120
+ ** When X.pUnlockConnection==Y, that means that X is waiting for Y to
8121
+ ** unlock so that it can proceed.
8122
+ **
8123
+ ** When X.pBlockingConnection==Y, that means that something that X tried
8124
+ ** tried to do recently failed with an SQLITE_LOCKED error due to locks
8125
+ ** held by Y.
81028126
*/
81038127
sqlite3 *pBlockingConnection; /* Connection that caused SQLITE_LOCKED */
81048128
sqlite3 *pUnlockConnection; /* Connection to watch for unlock */
81058129
void *pUnlockArg; /* Argument to xUnlockNotify */
81068130
void (*xUnlockNotify)(void **, int); /* Unlock notify callback */
@@ -8141,11 +8165,10 @@
81418165
#define SQLITE_FullFSync 0x00010000 /* Use full fsync on the backend */
81428166
#define SQLITE_LoadExtension 0x00020000 /* Enable load_extension */
81438167
81448168
#define SQLITE_RecoveryMode 0x00040000 /* Ignore schema errors */
81458169
#define SQLITE_SharedCache 0x00080000 /* Cache sharing is enabled */
8146
-#define SQLITE_Vtab 0x00100000 /* There exists a virtual table */
81478170
#define SQLITE_CommitBusy 0x00200000 /* In the process of committing */
81488171
#define SQLITE_ReverseOrder 0x00400000 /* Reverse unordered SELECTs */
81498172
81508173
/*
81518174
** Possible values for the sqlite.magic field.
@@ -8707,23 +8730,22 @@
87078730
** is a disk table or the "old.*" pseudo-table, then pTab points to the
87088731
** corresponding table definition.
87098732
**
87108733
** ALLOCATION NOTES:
87118734
**
8712
-** Expr structures may be stored as part of the in-memory database schema,
8713
-** for example as part of trigger, view or table definitions. In this case,
8714
-** the amount of memory consumed by complex expressions may be significant.
8715
-** For this reason, less than sizeof(Expr) bytes may be allocated for some
8716
-** Expr structs stored as part of the in-memory database schema.
8717
-**
8718
-** If the EP_Reduced flag is set in Expr.flags, then only EXPR_REDUCEDSIZE
8719
-** bytes of space are allocated for the expression structure. This is enough
8720
-** space to store all fields up to and including the "Token span;" field.
8721
-**
8722
-** If the EP_TokenOnly flag is set in Expr.flags, then only EXPR_TOKENONLYSIZE
8723
-** bytes of space are allocated for the expression structure. This is enough
8724
-** space to store all fields up to and including the "Token token;" field.
8735
+** Expr objects can use a lot of memory space in database schema. To
8736
+** help reduce memory requirements, sometimes an Expr object will be
8737
+** truncated. And to reduce the number of memory allocations, sometimes
8738
+** two or more Expr objects will be stored in a single memory allocation,
8739
+** together with Expr.token and/or Expr.span strings.
8740
+**
8741
+** If the EP_Reduced, EP_SpanToken, and EP_TokenOnly flags are set when
8742
+** an Expr object is truncated. When EP_Reduced is set, then all
8743
+** the child Expr objects in the Expr.pLeft and Expr.pRight subtrees
8744
+** are contained within the same memory allocation. Note, however, that
8745
+** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately
8746
+** allocated, regardless of whether or not EP_Reduced is set.
87258747
*/
87268748
struct Expr {
87278749
u8 op; /* Operation performed by this node */
87288750
char affinity; /* The affinity of the column or 0 if not a column */
87298751
VVA_ONLY(u8 vvaFlags;) /* Flags used for VV&A only. EVVA_* below. */
@@ -8735,11 +8757,11 @@
87358757
** access them will result in a segfault or malfunction.
87368758
*********************************************************************/
87378759
87388760
Token span; /* Complete text of the expression */
87398761
8740
- /* If the EP_SpanOnly flag is set in the Expr.flags mask, then no
8762
+ /* If the EP_SpanToken flag is set in the Expr.flags mask, then no
87418763
** space is allocated for the fields below this point. An attempt to
87428764
** access them will result in a segfault or malfunction.
87438765
*********************************************************************/
87448766
87458767
Expr *pLeft; /* Left subnode */
@@ -8783,11 +8805,11 @@
87838805
#define EP_IntValue 0x0800 /* Integer value contained in iTable */
87848806
#define EP_xIsSelect 0x1000 /* x.pSelect is valid (otherwise x.pList is) */
87858807
87868808
#define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */
87878809
#define EP_TokenOnly 0x4000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
8788
-#define EP_SpanOnly 0x8000 /* Expr struct is EXPR_SPANONLYSIZE bytes only */
8810
+#define EP_SpanToken 0x8000 /* Expr size is EXPR_SPANTOKENSIZE bytes */
87898811
87908812
/*
87918813
** The following are the meanings of bits in the Expr.vvaFlags field.
87928814
** This information is only used when SQLite is compiled with
87938815
** SQLITE_DEBUG defined.
@@ -8808,22 +8830,21 @@
88088830
/*
88098831
** Macros to determine the number of bytes required by a normal Expr
88108832
** struct, an Expr struct with the EP_Reduced flag set in Expr.flags
88118833
** and an Expr struct with the EP_TokenOnly flag set.
88128834
*/
8813
-#define EXPR_FULLSIZE sizeof(Expr)
8814
-#define EXPR_REDUCEDSIZE offsetof(Expr,iTable)
8815
-#define EXPR_TOKENONLYSIZE offsetof(Expr,span)
8816
-#define EXPR_SPANONLYSIZE offsetof(Expr,pLeft)
8835
+#define EXPR_FULLSIZE sizeof(Expr) /* Full size */
8836
+#define EXPR_REDUCEDSIZE offsetof(Expr,iTable) /* Common features */
8837
+#define EXPR_SPANTOKENSIZE offsetof(Expr,pLeft) /* Fewer features */
8838
+#define EXPR_TOKENONLYSIZE offsetof(Expr,span) /* Smallest possible */
88178839
88188840
/*
88198841
** Flags passed to the sqlite3ExprDup() function. See the header comment
88208842
** above sqlite3ExprDup() for details.
88218843
*/
8822
-#define EXPRDUP_REDUCE 0x0001
8823
-#define EXPRDUP_SPAN 0x0002
8824
-#define EXPRDUP_DISTINCTSPAN 0x0004
8844
+#define EXPRDUP_REDUCE 0x0001 /* Used reduced-size Expr nodes */
8845
+#define EXPRDUP_SPAN 0x0002 /* Make a copy of Expr.span */
88258846
88268847
/*
88278848
** A list of expressions. Each expression may optionally have a
88288849
** name. An expr/name combination can be used in several ways, such
88298850
** as the list of "expr AS ID" fields following a "SELECT" or in the
@@ -9799,10 +9820,11 @@
97999820
# define sqlite3TriggersExist(B,C,D,E,F) 0
98009821
# define sqlite3DeleteTrigger(A,B)
98019822
# define sqlite3DropTriggerPtr(A,B)
98029823
# define sqlite3UnlinkAndDeleteTrigger(A,B,C)
98039824
# define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I,J,K,L) 0
9825
+# define sqlite3TriggerList(X, Y) 0
98049826
#endif
98059827
98069828
SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*);
98079829
SQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);
98089830
SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int);
@@ -9830,11 +9852,11 @@
98309852
SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*);
98319853
SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);
98329854
SQLITE_PRIVATE int sqlite3FitsIn64Bits(const char *, int);
98339855
SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar);
98349856
SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte);
9835
-SQLITE_PRIVATE int sqlite3Utf8Read(const u8*, const u8*, const u8**);
9857
+SQLITE_PRIVATE int sqlite3Utf8Read(const u8*, const u8**);
98369858
98379859
/*
98389860
** Routines to read and write variable-length integers. These used to
98399861
** be defined locally, but now we use the varint routines in the util.c
98409862
** file. Code should use the MACRO forms below, as the Varint32 versions
@@ -10427,11 +10449,11 @@
1042710449
**
1042810450
** There is only one exported symbol in this file - the function
1042910451
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
1043010452
** All other code has file scope.
1043110453
**
10432
-** $Id: date.c,v 1.103 2009/02/04 03:59:25 shane Exp $
10454
+** $Id: date.c,v 1.105 2009/04/03 12:04:37 drh Exp $
1043310455
**
1043410456
** SQLite processes all times and dates as Julian Day numbers. The
1043510457
** dates and times are stored as the number of days since noon
1043610458
** in Greenwich on November 24, 4714 B.C. according to the Gregorian
1043710459
** calendar system.
@@ -11361,12 +11383,12 @@
1136111383
break;
1136211384
}
1136311385
case 'm': sqlite3_snprintf(3, &z[j],"%02d",x.M); j+=2; break;
1136411386
case 'M': sqlite3_snprintf(3, &z[j],"%02d",x.m); j+=2; break;
1136511387
case 's': {
11366
- sqlite3_snprintf(30,&z[j],"%d",
11367
- (int)(x.iJD/1000.0 - 210866760000.0));
11388
+ sqlite3_snprintf(30,&z[j],"%lld",
11389
+ (i64)(x.iJD/1000 - 21086676*(i64)10000));
1136811390
j += sqlite3Strlen30(&z[j]);
1136911391
break;
1137011392
}
1137111393
case 'S': sqlite3_snprintf(3,&z[j],"%02d",(int)x.s); j+=2; break;
1137211394
case 'w': {
@@ -15655,11 +15677,11 @@
1565515677
** the public domain. The original comments are included here for
1565615678
** completeness. They are very out-of-date but might be useful as
1565715679
** an historical reference. Most of the "enhancements" have been backed
1565815680
** out so that the functionality is now the same as standard printf().
1565915681
**
15660
-** $Id: printf.c,v 1.99 2008/12/10 19:26:24 drh Exp $
15682
+** $Id: printf.c,v 1.102 2009/04/08 16:10:04 drh Exp $
1566115683
**
1566215684
**************************************************************************
1566315685
**
1566415686
** The following modules is an enhanced replacement for the "printf" subroutines
1566515687
** found in the standard C library. The following enhancements are
@@ -15726,10 +15748,12 @@
1572615748
#define etSRCLIST 13 /* a pointer to a SrcList */
1572715749
#define etPOINTER 14 /* The %p conversion */
1572815750
#define etSQLESCAPE3 15 /* %w -> Strings with '\"' doubled */
1572915751
#define etORDINAL 16 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */
1573015752
15753
+#define etINVALID 0 /* Any unrecognized conversion type */
15754
+
1573115755
1573215756
/*
1573315757
** An "etByte" is an 8-bit unsigned value.
1573415758
*/
1573515759
typedef unsigned char etByte;
@@ -15782,10 +15806,13 @@
1578215806
#endif
1578315807
{ 'i', 10, 1, etRADIX, 0, 0 },
1578415808
{ 'n', 0, 0, etSIZE, 0, 0 },
1578515809
{ '%', 0, 0, etPERCENT, 0, 0 },
1578615810
{ 'p', 16, 0, etPOINTER, 0, 1 },
15811
+
15812
+/* All the rest have the FLAG_INTERN bit set and are thus for internal
15813
+** use only */
1578715814
{ 'T', 0, 2, etTOKEN, 0, 0 },
1578815815
{ 'S', 0, 2, etSRCLIST, 0, 0 },
1578915816
{ 'r', 10, 3, etORDINAL, 0, 0 },
1579015817
};
1579115818
@@ -15984,11 +16011,12 @@
1598416011
}
1598516012
}else{
1598616013
flag_long = flag_longlong = 0;
1598716014
}
1598816015
/* Fetch the info entry for the field */
15989
- infop = 0;
16016
+ infop = &fmtinfo[0];
16017
+ xtype = etINVALID;
1599016018
for(idx=0; idx<ArraySize(fmtinfo); idx++){
1599116019
if( c==fmtinfo[idx].fmttype ){
1599216020
infop = &fmtinfo[idx];
1599316021
if( useExtended || (infop->flags & FLAG_INTERN)==0 ){
1599416022
xtype = infop->type;
@@ -15997,13 +16025,10 @@
1599716025
}
1599816026
break;
1599916027
}
1600016028
}
1600116029
zExtra = 0;
16002
- if( infop==0 ){
16003
- return;
16004
- }
1600516030
1600616031
1600716032
/* Limit the precision to prevent overflowing buf[] during conversion */
1600816033
if( precision>etBUFSIZE-40 && (infop->flags & FLAG_STRING)==0 ){
1600916034
precision = etBUFSIZE-40;
@@ -16336,10 +16361,14 @@
1633616361
sqlite3StrAccumAppend(pAccum, ".", 1);
1633716362
}
1633816363
sqlite3StrAccumAppend(pAccum, pItem->zName, -1);
1633916364
length = width = 0;
1634016365
break;
16366
+ }
16367
+ default: {
16368
+ assert( xtype==etINVALID );
16369
+ return;
1634116370
}
1634216371
}/* End switch over the format type */
1634316372
/*
1634416373
** The text of the conversion is pointed to by "bufpt" and is
1634516374
** "length" characters long. The field width is "width". Do
@@ -16370,17 +16399,20 @@
1637016399
1637116400
/*
1637216401
** Append N bytes of text from z to the StrAccum object.
1637316402
*/
1637416403
SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){
16404
+ assert( z!=0 || N==0 );
1637516405
if( p->tooBig | p->mallocFailed ){
16406
+ testcase(p->tooBig);
16407
+ testcase(p->mallocFailed);
1637616408
return;
1637716409
}
1637816410
if( N<0 ){
1637916411
N = sqlite3Strlen30(z);
1638016412
}
16381
- if( N==0 || z==0 ){
16413
+ if( N==0 || NEVER(z==0) ){
1638216414
return;
1638316415
}
1638416416
if( p->nChar+N >= p->nAlloc ){
1638516417
char *zNew;
1638616418
if( !p->useMalloc ){
@@ -16465,16 +16497,17 @@
1646516497
*/
1646616498
SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){
1646716499
char *z;
1646816500
char zBase[SQLITE_PRINT_BUF_SIZE];
1646916501
StrAccum acc;
16502
+ assert( db!=0 );
1647016503
sqlite3StrAccumInit(&acc, zBase, sizeof(zBase),
16471
- db ? db->aLimit[SQLITE_LIMIT_LENGTH] : SQLITE_MAX_LENGTH);
16504
+ db->aLimit[SQLITE_LIMIT_LENGTH]);
1647216505
acc.db = db;
1647316506
sqlite3VXPrintf(&acc, 1, zFormat, ap);
1647416507
z = sqlite3StrAccumFinish(&acc);
16475
- if( acc.mallocFailed && db ){
16508
+ if( acc.mallocFailed ){
1647616509
db->mallocFailed = 1;
1647716510
}
1647816511
return z;
1647916512
}
1648016513
@@ -16749,11 +16782,11 @@
1674916782
**
1675016783
*************************************************************************
1675116784
** This file contains routines used to translate between UTF-8,
1675216785
** UTF-16, UTF-16BE, and UTF-16LE.
1675316786
**
16754
-** $Id: utf.c,v 1.71 2009/03/31 03:41:57 shane Exp $
16787
+** $Id: utf.c,v 1.73 2009/04/01 18:40:32 drh Exp $
1675516788
**
1675616789
** Notes on UTF-8:
1675716790
**
1675816791
** Byte-0 Byte-1 Byte-2 Byte-3 Value
1675916792
** 0xxxxxxx 00000000 00000000 0xxxxxxx
@@ -16791,11 +16824,11 @@
1679116824
** VDBE. This information used to all be at the top of the single
1679216825
** source code file "vdbe.c". When that file became too big (over
1679316826
** 6000 lines long) it was split up into several smaller files and
1679416827
** this header information was factored out.
1679516828
**
16796
-** $Id: vdbeInt.h,v 1.166 2009/03/18 10:33:02 danielk1977 Exp $
16829
+** $Id: vdbeInt.h,v 1.167 2009/04/10 12:55:17 danielk1977 Exp $
1679716830
*/
1679816831
#ifndef _VDBEINT_H_
1679916832
#define _VDBEINT_H_
1680016833
1680116834
/*
@@ -17154,10 +17187,16 @@
1715417187
SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
1715517188
SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);
1715617189
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
1715717190
SQLITE_PRIVATE int sqlite3VdbeReleaseBuffers(Vdbe *p);
1715817191
#endif
17192
+
17193
+#ifndef SQLITE_OMIT_SHARED_CACHE
17194
+SQLITE_PRIVATE void sqlite3VdbeMutexArrayEnter(Vdbe *p);
17195
+#else
17196
+# define sqlite3VdbeMutexArrayEnter(p)
17197
+#endif
1715917198
1716017199
SQLITE_PRIVATE int sqlite3VdbeMemTranslate(Mem*, u8);
1716117200
#ifdef SQLITE_DEBUG
1716217201
SQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe*);
1716317202
SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf);
@@ -17244,26 +17283,24 @@
1724417283
}
1724517284
1724617285
#define READ_UTF16LE(zIn, c){ \
1724717286
c = (*zIn++); \
1724817287
c += ((*zIn++)<<8); \
17249
- if( c>=0xD800 && c<0xE000 ){ \
17288
+ if( c>=0xD800 && c<0xE000 ){ \
1725017289
int c2 = (*zIn++); \
1725117290
c2 += ((*zIn++)<<8); \
1725217291
c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \
17253
- if( (c & 0xFFFF0000)==0 ) c = 0xFFFD; \
1725417292
} \
1725517293
}
1725617294
1725717295
#define READ_UTF16BE(zIn, c){ \
1725817296
c = ((*zIn++)<<8); \
1725917297
c += (*zIn++); \
17260
- if( c>=0xD800 && c<0xE000 ){ \
17298
+ if( c>=0xD800 && c<0xE000 ){ \
1726117299
int c2 = ((*zIn++)<<8); \
1726217300
c2 += (*zIn++); \
1726317301
c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \
17264
- if( (c & 0xFFFF0000)==0 ) c = 0xFFFD; \
1726517302
} \
1726617303
}
1726717304
1726817305
/*
1726917306
** Translate a single UTF-8 character. Return the unicode value.
@@ -17302,17 +17339,29 @@
1730217339
if( c<0x80 \
1730317340
|| (c&0xFFFFF800)==0xD800 \
1730417341
|| (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \
1730517342
}
1730617343
SQLITE_PRIVATE int sqlite3Utf8Read(
17307
- const unsigned char *z, /* First byte of UTF-8 character */
17308
- const unsigned char *zTerm, /* Pretend this byte is 0x00 */
17344
+ const unsigned char *zIn, /* First byte of UTF-8 character */
1730917345
const unsigned char **pzNext /* Write first byte past UTF-8 char here */
1731017346
){
1731117347
int c;
17312
- READ_UTF8(z, zTerm, c);
17313
- *pzNext = z;
17348
+
17349
+ /* Same as READ_UTF8() above but without the zTerm parameter.
17350
+ ** For this routine, we assume the UTF8 string is always zero-terminated.
17351
+ */
17352
+ c = *(zIn++);
17353
+ if( c>=0xc0 ){
17354
+ c = sqlite3Utf8Trans1[c-0xc0];
17355
+ while( (*zIn & 0xc0)==0x80 ){
17356
+ c = (c<<6) + (0x3f & *(zIn++));
17357
+ }
17358
+ if( c<0x80
17359
+ || (c&0xFFFFF800)==0xD800
17360
+ || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; }
17361
+ }
17362
+ *pzNext = zIn;
1731417363
return c;
1731517364
}
1731617365
1731717366
1731817367
@@ -17475,11 +17524,12 @@
1747517524
*/
1747617525
SQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem){
1747717526
int rc = SQLITE_OK;
1747817527
u8 bom = 0;
1747917528
17480
- if( pMem->n<0 || pMem->n>1 ){
17529
+ assert( pMem->n>=0 );
17530
+ if( pMem->n>1 ){
1748117531
u8 b1 = *(u8 *)pMem->z;
1748217532
u8 b2 = *(((u8 *)pMem->z) + 1);
1748317533
if( b1==0xFE && b2==0xFF ){
1748417534
bom = SQLITE_UTF16BE;
1748517535
}
@@ -17541,15 +17591,14 @@
1754117591
** correct UTF-8 encoding to be longer than a malformed encoding).
1754217592
*/
1754317593
SQLITE_PRIVATE int sqlite3Utf8To8(unsigned char *zIn){
1754417594
unsigned char *zOut = zIn;
1754517595
unsigned char *zStart = zIn;
17546
- unsigned char *zTerm = &zIn[sqlite3Strlen30((char *)zIn)];
1754717596
u32 c;
1754817597
1754917598
while( zIn[0] ){
17550
- c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn);
17599
+ c = sqlite3Utf8Read(zIn, (const u8**)&zIn);
1755117600
if( c!=0xfffd ){
1755217601
WRITE_UTF8(zOut, c);
1755317602
}
1755417603
}
1755517604
*zOut = 0;
@@ -17579,19 +17628,17 @@
1757917628
assert( (m.flags & MEM_Str)!=0 || db->mallocFailed );
1758017629
return (m.flags & MEM_Dyn)!=0 ? m.z : sqlite3DbStrDup(db, m.z);
1758117630
}
1758217631
1758317632
/*
17584
-** pZ is a UTF-16 encoded unicode string. If nChar is less than zero,
17585
-** return the number of bytes up to (but not including), the first pair
17586
-** of consecutive 0x00 bytes in pZ. If nChar is not less than zero,
17587
-** then return the number of bytes in the first nChar unicode characters
17588
-** in pZ (or up until the first pair of 0x00 bytes, whichever comes first).
17633
+** pZ is a UTF-16 encoded unicode string at least nChar characters long.
17634
+** Return the number of bytes in the first nChar unicode characters
17635
+** in pZ. nChar must be non-negative.
1758917636
*/
1759017637
SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *zIn, int nChar){
17591
- unsigned int c = 1;
17592
- char const *z = zIn;
17638
+ int c;
17639
+ unsigned char const *z = zIn;
1759317640
int n = 0;
1759417641
if( SQLITE_UTF16NATIVE==SQLITE_UTF16BE ){
1759517642
/* Using an "if (SQLITE_UTF16NATIVE==SQLITE_UTF16BE)" construct here
1759617643
** and in other parts of this file means that at one branch will
1759717644
** not be covered by coverage testing on any single host. But coverage
@@ -17599,21 +17646,21 @@
1759917646
** big-endian host. Because both the UTF16NATIVE and SQLITE_UTF16BE
1760017647
** macros are constant at compile time the compiler can determine
1760117648
** which branch will be followed. It is therefore assumed that no runtime
1760217649
** penalty is paid for this "if" statement.
1760317650
*/
17604
- while( c && ((nChar<0) || n<nChar) ){
17651
+ while( n<nChar ){
1760517652
READ_UTF16BE(z, c);
1760617653
n++;
1760717654
}
1760817655
}else{
17609
- while( c && ((nChar<0) || n<nChar) ){
17656
+ while( n<nChar ){
1761017657
READ_UTF16LE(z, c);
1761117658
n++;
1761217659
}
1761317660
}
17614
- return (int)(z-(char const *)zIn)-((c==0)?2:0);
17661
+ return (int)(z-(unsigned char const *)zIn);
1761517662
}
1761617663
1761717664
#if defined(SQLITE_TEST)
1761817665
/*
1761917666
** This routine is called from the TCL test function "translate_selftest".
@@ -17622,23 +17669,21 @@
1762217669
*/
1762317670
SQLITE_PRIVATE void sqlite3UtfSelfTest(void){
1762417671
unsigned int i, t;
1762517672
unsigned char zBuf[20];
1762617673
unsigned char *z;
17627
- unsigned char *zTerm;
1762817674
int n;
1762917675
unsigned int c;
1763017676
1763117677
for(i=0; i<0x00110000; i++){
1763217678
z = zBuf;
1763317679
WRITE_UTF8(z, i);
1763417680
n = (int)(z-zBuf);
1763517681
assert( n>0 && n<=4 );
1763617682
z[0] = 0;
17637
- zTerm = z;
1763817683
z = zBuf;
17639
- c = sqlite3Utf8Read(z, zTerm, (const u8**)&z);
17684
+ c = sqlite3Utf8Read(z, (const u8**)&z);
1764017685
t = i;
1764117686
if( i>=0xD800 && i<=0xDFFF ) t = 0xFFFD;
1764217687
if( (i&0xFFFFFFFE)==0xFFFE ) t = 0xFFFD;
1764317688
assert( c==t );
1764417689
assert( (z-zBuf)==n );
@@ -20521,11 +20566,11 @@
2052120566
** * sqlite3_vfs method implementations.
2052220567
** * Locking primitives for the proxy uber-locking-method. (MacOSX only)
2052320568
** * Definitions of sqlite3_vfs objects for all locking methods
2052420569
** plus implementations of sqlite3_os_init() and sqlite3_os_end().
2052520570
**
20526
-** $Id: os_unix.c,v 1.248 2009/03/30 07:39:35 danielk1977 Exp $
20571
+** $Id: os_unix.c,v 1.250 2009/04/07 05:35:04 chw Exp $
2052720572
*/
2052820573
#if SQLITE_OS_UNIX /* This file is used on unix only */
2052920574
2053020575
/*
2053120576
** There are various methods for file locking used for concurrency
@@ -22911,12 +22956,12 @@
2291122956
semUnlock(id, NO_LOCK);
2291222957
assert( pFile );
2291322958
unixEnterMutex();
2291422959
releaseLockInfo(pFile->pLock);
2291522960
releaseOpenCnt(pFile->pOpen);
22916
- closeUnixFile(id);
2291722961
unixLeaveMutex();
22962
+ closeUnixFile(id);
2291822963
}
2291922964
return SQLITE_OK;
2292022965
}
2292122966
2292222967
#endif /* OS_VXWORKS */
@@ -23905,11 +23950,11 @@
2390523950
dotlockLock, /* xLock method */
2390623951
dotlockUnlock, /* xUnlock method */
2390723952
dotlockCheckReservedLock /* xCheckReservedLock method */
2390823953
)
2390923954
23910
-#if SQLITE_ENABLE_LOCKING_STYLE
23955
+#if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS
2391123956
IOMETHODS(
2391223957
flockIoFinder, /* Finder function name */
2391323958
flockIoMethods, /* sqlite3_io_methods object name */
2391423959
flockClose, /* xClose method */
2391523960
flockLock, /* xLock method */
@@ -24029,10 +24074,48 @@
2402924074
static const sqlite3_io_methods *(*const autolockIoFinder)(const char*,int)
2403024075
= autolockIoFinderImpl;
2403124076
2403224077
#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */
2403324078
24079
+#if OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE
24080
+/*
24081
+** This "finder" function attempts to determine the best locking strategy
24082
+** for the database file "filePath". It then returns the sqlite3_io_methods
24083
+** object that implements that strategy.
24084
+**
24085
+** This is for VXWorks only.
24086
+*/
24087
+static const sqlite3_io_methods *autolockIoFinderImpl(
24088
+ const char *filePath, /* name of the database file */
24089
+ int fd /* file descriptor open on the database file */
24090
+){
24091
+ struct flock lockInfo;
24092
+
24093
+ if( !filePath ){
24094
+ /* If filePath==NULL that means we are dealing with a transient file
24095
+ ** that does not need to be locked. */
24096
+ return &nolockIoMethods;
24097
+ }
24098
+
24099
+ /* Test if fcntl() is supported and use POSIX style locks.
24100
+ ** Otherwise fall back to the named semaphore method.
24101
+ */
24102
+ lockInfo.l_len = 1;
24103
+ lockInfo.l_start = 0;
24104
+ lockInfo.l_whence = SEEK_SET;
24105
+ lockInfo.l_type = F_RDLCK;
24106
+ if( fcntl(fd, F_GETLK, &lockInfo)!=-1 ) {
24107
+ return &posixIoMethods;
24108
+ }else{
24109
+ return &semIoMethods;
24110
+ }
24111
+}
24112
+static const sqlite3_io_methods *(*const autolockIoFinder)(const char*,int)
24113
+ = autolockIoFinderImpl;
24114
+
24115
+#endif /* OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE */
24116
+
2403424117
/*
2403524118
** An abstract type for a pointer to a IO method finder function:
2403624119
*/
2403724120
typedef const sqlite3_io_methods *(*finder_type)(const char*,int);
2403824121
@@ -24311,11 +24394,11 @@
2431124394
const char *zPath, /* Pathname of file to be opened */
2431224395
sqlite3_file *pFile, /* The file descriptor to be filled in */
2431324396
int flags, /* Input flags to control the opening */
2431424397
int *pOutFlags /* Output flags returned to SQLite core */
2431524398
){
24316
- int fd = 0; /* File descriptor returned by open() */
24399
+ int fd = -1; /* File descriptor returned by open() */
2431724400
int dirfd = -1; /* Directory file descriptor */
2431824401
int openFlags = 0; /* Flags to pass to open() */
2431924402
int eType = flags&0xFFFFFF00; /* Type of file to open */
2432024403
int noLock; /* True to omit locking primitives */
2432124404
int rc = SQLITE_OK;
@@ -24414,11 +24497,11 @@
2441424497
if( (flags & SQLITE_OPEN_MAIN_DB)!=0 ){
2441524498
((unixFile*)pFile)->isLockable = 1;
2441624499
}
2441724500
#endif
2441824501
24419
- assert(fd!=0);
24502
+ assert( fd>=0 );
2442024503
if( isOpenDirectory ){
2442124504
rc = openDirectory(zPath, &dirfd);
2442224505
if( rc!=SQLITE_OK ){
2442324506
close(fd); /* silently leak if fail, already in error */
2442424507
return rc;
@@ -25759,11 +25842,11 @@
2575925842
** Note that the sqlite3_vfs.pNext field of the VFS object is modified
2576025843
** by the SQLite core when the VFS is registered. So the following
2576125844
** array cannot be const.
2576225845
*/
2576325846
static sqlite3_vfs aVfs[] = {
25764
-#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
25847
+#if SQLITE_ENABLE_LOCKING_STYLE && (OS_VXWORKS || defined(__APPLE__))
2576525848
UNIXVFS("unix", autolockIoFinder ),
2576625849
#else
2576725850
UNIXVFS("unix", posixIoFinder ),
2576825851
#endif
2576925852
UNIXVFS("unix-none", nolockIoFinder ),
@@ -25771,11 +25854,13 @@
2577125854
#if OS_VXWORKS
2577225855
UNIXVFS("unix-namedsem", semIoFinder ),
2577325856
#endif
2577425857
#if SQLITE_ENABLE_LOCKING_STYLE
2577525858
UNIXVFS("unix-posix", posixIoFinder ),
25859
+#if !OS_VXWORKS
2577625860
UNIXVFS("unix-flock", flockIoFinder ),
25861
+#endif
2577725862
#endif
2577825863
#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
2577925864
UNIXVFS("unix-afp", afpIoFinder ),
2578025865
UNIXVFS("unix-proxy", proxyIoFinder ),
2578125866
#endif
@@ -25816,11 +25901,11 @@
2581625901
**
2581725902
******************************************************************************
2581825903
**
2581925904
** This file contains code that is specific to windows.
2582025905
**
25821
-** $Id: os_win.c,v 1.153 2009/03/31 03:41:57 shane Exp $
25906
+** $Id: os_win.c,v 1.154 2009/04/09 14:27:07 chw Exp $
2582225907
*/
2582325908
#if SQLITE_OS_WIN /* This file is used for windows only */
2582425909
2582525910
2582625911
/*
@@ -27612,11 +27697,11 @@
2761227697
const char *zRelative /* UTF-8 file name */
2761327698
){
2761427699
DWORD bytesPerSector = SQLITE_DEFAULT_SECTOR_SIZE;
2761527700
char zFullpath[MAX_PATH+1];
2761627701
int rc;
27617
- DWORD dwRet = 0;
27702
+ DWORD dwRet = 0, dwDummy;
2761827703
2761927704
/*
2762027705
** We need to get the full path name of the file
2762127706
** to get the drive letter to look up the sector
2762227707
** size.
@@ -27636,14 +27721,14 @@
2763627721
p[i] = '\0';
2763727722
break;
2763827723
}
2763927724
}
2764027725
dwRet = GetDiskFreeSpaceW((WCHAR*)zConverted,
27641
- NULL,
27726
+ &dwDummy,
2764227727
&bytesPerSector,
27643
- NULL,
27644
- NULL);
27728
+ &dwDummy,
27729
+ &dwDummy);
2764527730
#if SQLITE_OS_WINCE==0
2764627731
}else{
2764727732
int i;
2764827733
/* trim path to just drive reference */
2764927734
CHAR *p = (CHAR *)zConverted;
@@ -27653,14 +27738,14 @@
2765327738
p[i] = '\0';
2765427739
break;
2765527740
}
2765627741
}
2765727742
dwRet = GetDiskFreeSpaceA((CHAR*)zConverted,
27658
- NULL,
27743
+ &dwDummy,
2765927744
&bytesPerSector,
27660
- NULL,
27661
- NULL);
27745
+ &dwDummy,
27746
+ &dwDummy);
2766227747
#endif
2766327748
}
2766427749
free(zConverted);
2766527750
}
2766627751
if( !dwRet ){
@@ -27938,11 +28023,11 @@
2793828023
** sometimes grow into tens of thousands or larger. The size of the
2793928024
** Bitvec object is the number of pages in the database file at the
2794028025
** start of a transaction, and is thus usually less than a few thousand,
2794128026
** but can be as large as 2 billion for a really big database.
2794228027
**
27943
-** @(#) $Id: bitvec.c,v 1.13 2009/01/20 17:06:27 danielk1977 Exp $
28028
+** @(#) $Id: bitvec.c,v 1.14 2009/04/01 23:49:04 drh Exp $
2794428029
*/
2794528030
2794628031
/* Size of the Bitvec structure in bytes. */
2794728032
#define BITVEC_SZ 512
2794828033
@@ -27997,12 +28082,13 @@
2799728082
** N*iDivisor+1 and (N+1)*iDivisor. Each subbitmap is normalized
2799828083
** to hold deal with values between 1 and iDivisor.
2799928084
*/
2800028085
struct Bitvec {
2800128086
u32 iSize; /* Maximum bit index. Max iSize is 4,294,967,296. */
28002
- u32 nSet; /* Number of bits that are set - only valid for aHash element */
28003
- /* Max nSet is BITVEC_NINT. For BITVEC_SZ of 512, this would be 125. */
28087
+ u32 nSet; /* Number of bits that are set - only valid for aHash
28088
+ ** element. Max is BITVEC_NINT. For BITVEC_SZ of 512,
28089
+ ** this would be 125. */
2800428090
u32 iDivisor; /* Number of bits handled by each apSub[] entry. */
2800528091
/* Should >=0 for apSub element. */
2800628092
/* Max iDivisor is max(u32) / BITVEC_NPTR + 1. */
2800728093
/* For a BITVEC_SZ of 512, this would be 34,359,739. */
2800828094
union {
@@ -28280,11 +28366,12 @@
2828028366
** Bitvec object. Start with the assumption that they do
2828128367
** match (rc==0). Change rc to non-zero if a discrepancy
2828228368
** is found.
2828328369
*/
2828428370
rc = sqlite3BitvecTest(0,0) + sqlite3BitvecTest(pBitvec, sz+1)
28285
- + sqlite3BitvecTest(pBitvec, 0);
28371
+ + sqlite3BitvecTest(pBitvec, 0)
28372
+ + (sqlite3BitvecSize(pBitvec) - sz);
2828628373
for(i=1; i<=sz; i++){
2828728374
if( (TESTBIT(pV,i))!=sqlite3BitvecTest(pBitvec,i) ){
2828828375
rc = i;
2828928376
break;
2829028377
}
@@ -29663,11 +29750,11 @@
2966329750
** the sort) then returns elements one by one by walking the list.
2966429751
**
2966529752
** Big chunks of rowid/next-ptr pairs are allocated at a time, to
2966629753
** reduce the malloc overhead.
2966729754
**
29668
-** $Id: rowset.c,v 1.3 2009/01/13 20:14:16 drh Exp $
29755
+** $Id: rowset.c,v 1.4 2009/04/01 19:35:55 drh Exp $
2966929756
*/
2967029757
2967129758
/*
2967229759
** The number of rowset entries per allocation chunk.
2967329760
*/
@@ -29757,11 +29844,11 @@
2975729844
** memory allocation fails.
2975829845
*/
2975929846
SQLITE_PRIVATE void sqlite3RowSetInsert(RowSet *p, i64 rowid){
2976029847
struct RowSetEntry *pEntry;
2976129848
struct RowSetEntry *pLast;
29762
- if( p==0 ) return; /* Must have been a malloc failure */
29849
+ assert( p!=0 );
2976329850
if( p->nFresh==0 ){
2976429851
struct RowSetChunk *pNew;
2976529852
pNew = sqlite3DbMallocRaw(p->db, sizeof(*pNew));
2976629853
if( pNew==0 ){
2976729854
return;
@@ -29896,11 +29983,11 @@
2989629983
** is separate from the database file. The pager also implements file
2989729984
** locking to prevent two processes from writing the same database
2989829985
** file simultaneously, or one process from reading the database while
2989929986
** another is writing.
2990029987
**
29901
-** @(#) $Id: pager.c,v 1.576 2009/03/31 02:54:40 drh Exp $
29988
+** @(#) $Id: pager.c,v 1.580 2009/04/11 16:27:50 drh Exp $
2990229989
*/
2990329990
#ifndef SQLITE_OMIT_DISKIO
2990429991
2990529992
/*
2990629993
** Macros for troubleshooting. Normally turned off
@@ -31901,15 +31988,15 @@
3190131988
if( rc==SQLITE_DONE ){
3190231989
rc = SQLITE_OK;
3190331990
pPager->journalOff = szJ;
3190431991
break;
3190531992
}else{
31906
- /* If we are unable to rollback, then the database is probably
31907
- ** going to end up being corrupt. It is corrupt to us, anyhow.
31908
- ** Perhaps the next process to come along can fix it....
31993
+ /* If we are unable to rollback, quit and return the error
31994
+ ** code. This will cause the pager to enter the error state
31995
+ ** so that no further harm will be done. Perhaps the next
31996
+ ** process to come along will be able to rollback the database.
3190931997
*/
31910
- rc = SQLITE_CORRUPT_BKPT;
3191131998
goto end_playback;
3191231999
}
3191332000
}
3191432001
}
3191532002
}
@@ -32991,13 +33078,13 @@
3299133078
** may be a wrapper capable of caching the first portion of the journal
3299233079
** file in memory to implement the atomic-write optimization (see
3299333080
** source file journal.c).
3299433081
*/
3299533082
if( sqlite3JournalSize(pVfs)>sqlite3MemJournalSize() ){
32996
- journalFileSize = sqlite3JournalSize(pVfs);
33083
+ journalFileSize = ROUND8(sqlite3JournalSize(pVfs));
3299733084
}else{
32998
- journalFileSize = sqlite3MemJournalSize();
33085
+ journalFileSize = ROUND8(sqlite3MemJournalSize());
3299933086
}
3300033087
3300133088
/* Set the output variable to NULL in case an error occurs. */
3300233089
*ppPager = 0;
3300333090
@@ -33049,27 +33136,29 @@
3304933136
** Main journal file handle (journalFileSize bytes)
3305033137
** Database file name (nPathname+1 bytes)
3305133138
** Journal file name (nPathname+8+1 bytes)
3305233139
*/
3305333140
pPtr = (u8 *)sqlite3MallocZero(
33054
- sizeof(*pPager) + /* Pager structure */
33055
- pcacheSize + /* PCache object */
33056
- pVfs->szOsFile + /* The main db file */
33057
- journalFileSize * 2 + /* The two journal files */
33058
- nPathname + 1 + /* zFilename */
33059
- nPathname + 8 + 1 /* zJournal */
33141
+ ROUND8(sizeof(*pPager)) + /* Pager structure */
33142
+ ROUND8(pcacheSize) + /* PCache object */
33143
+ ROUND8(pVfs->szOsFile) + /* The main db file */
33144
+ journalFileSize * 2 + /* The two journal files */
33145
+ nPathname + 1 + /* zFilename */
33146
+ nPathname + 8 + 1 /* zJournal */
3306033147
);
33148
+ assert( EIGHT_BYTE_ALIGNMENT(journalFileSize) );
3306133149
if( !pPtr ){
3306233150
sqlite3_free(zPathname);
3306333151
return SQLITE_NOMEM;
3306433152
}
3306533153
pPager = (Pager*)(pPtr);
33066
- pPager->pPCache = (PCache*)(pPtr += sizeof(*pPager));
33067
- pPager->fd = (sqlite3_file*)(pPtr += pcacheSize);
33068
- pPager->sjfd = (sqlite3_file*)(pPtr += pVfs->szOsFile);
33154
+ pPager->pPCache = (PCache*)(pPtr += ROUND8(sizeof(*pPager)));
33155
+ pPager->fd = (sqlite3_file*)(pPtr += ROUND8(pcacheSize));
33156
+ pPager->sjfd = (sqlite3_file*)(pPtr += ROUND8(pVfs->szOsFile));
3306933157
pPager->jfd = (sqlite3_file*)(pPtr += journalFileSize);
3307033158
pPager->zFilename = (char*)(pPtr += journalFileSize);
33159
+ assert( EIGHT_BYTE_ALIGNMENT(pPager->jfd) );
3307133160
3307233161
/* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */
3307333162
if( zPathname ){
3307433163
pPager->zJournal = (char*)(pPtr += nPathname + 1);
3307533164
memcpy(pPager->zFilename, zPathname, nPathname);
@@ -34951,18 +35040,15 @@
3495135040
pPg->flags &= ~PGHDR_NEED_SYNC;
3495235041
pPgOld = pager_lookup(pPager, pgno);
3495335042
assert( !pPgOld || pPgOld->nRef==1 );
3495435043
if( pPgOld ){
3495535044
pPg->flags |= (pPgOld->flags&PGHDR_NEED_SYNC);
35045
+ sqlite3PcacheDrop(pPgOld);
3495635046
}
3495735047
3495835048
origPgno = pPg->pgno;
3495935049
sqlite3PcacheMove(pPg, pgno);
34960
- if( pPgOld ){
34961
- sqlite3PcacheDrop(pPgOld);
34962
- }
34963
-
3496435050
sqlite3PcacheMakeDirty(pPg);
3496535051
pPager->dbModified = 1;
3496635052
3496735053
if( needSyncPgno ){
3496835054
/* If needSyncPgno is non-zero, then the journal file needs to be
@@ -35063,34 +35149,37 @@
3506335149
** PAGER_JOURNALMODE_PERSIST
3506435150
** PAGER_JOURNALMODE_OFF
3506535151
** PAGER_JOURNALMODE_MEMORY
3506635152
**
3506735153
** If the parameter is not _QUERY, then the journal-mode is set to the
35068
-** value specified.
35154
+** value specified. Except, an in-memory database can only have its
35155
+** journal mode set to _OFF or _MEMORY. Attempts to change the journal
35156
+** mode of an in-memory database to something other than _OFF or _MEMORY
35157
+** are silently ignored.
3506935158
**
3507035159
** The returned indicate the current (possibly updated) journal-mode.
3507135160
*/
3507235161
SQLITE_PRIVATE int sqlite3PagerJournalMode(Pager *pPager, int eMode){
35073
- if( !MEMDB ){
35074
- assert( eMode==PAGER_JOURNALMODE_QUERY
35075
- || eMode==PAGER_JOURNALMODE_DELETE
35076
- || eMode==PAGER_JOURNALMODE_TRUNCATE
35077
- || eMode==PAGER_JOURNALMODE_PERSIST
35078
- || eMode==PAGER_JOURNALMODE_OFF
35079
- || eMode==PAGER_JOURNALMODE_MEMORY );
35080
- assert( PAGER_JOURNALMODE_QUERY<0 );
35081
- if( eMode>=0 ){
35082
- pPager->journalMode = (u8)eMode;
35083
- }else{
35084
- assert( eMode==PAGER_JOURNALMODE_QUERY );
35085
- }
35162
+ assert( eMode==PAGER_JOURNALMODE_QUERY
35163
+ || eMode==PAGER_JOURNALMODE_DELETE
35164
+ || eMode==PAGER_JOURNALMODE_TRUNCATE
35165
+ || eMode==PAGER_JOURNALMODE_PERSIST
35166
+ || eMode==PAGER_JOURNALMODE_OFF
35167
+ || eMode==PAGER_JOURNALMODE_MEMORY );
35168
+ assert( PAGER_JOURNALMODE_QUERY<0 );
35169
+ if( eMode>=0 && (!MEMDB || eMode==PAGER_JOURNALMODE_MEMORY
35170
+ || eMode==PAGER_JOURNALMODE_OFF) ){
35171
+ pPager->journalMode = (u8)eMode;
3508635172
}
3508735173
return (int)pPager->journalMode;
3508835174
}
3508935175
3509035176
/*
3509135177
** Get/set the size-limit used for persistent journal files.
35178
+**
35179
+** Setting the size limit to -1 means no limit is enforced.
35180
+** An attempt to set a limit smaller than -1 is a no-op.
3509235181
*/
3509335182
SQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *pPager, i64 iLimit){
3509435183
if( iLimit>=-1 ){
3509535184
pPager->journalSizeLimit = iLimit;
3509635185
}
@@ -35121,11 +35210,11 @@
3512135210
** May you find forgiveness for yourself and forgive others.
3512235211
** May you share freely, never taking more than you give.
3512335212
**
3512435213
*************************************************************************
3512535214
**
35126
-** $Id: btmutex.c,v 1.13 2009/03/05 04:20:32 shane Exp $
35215
+** $Id: btmutex.c,v 1.15 2009/04/10 12:55:17 danielk1977 Exp $
3512735216
**
3512835217
** This file contains code used to implement mutexes on Btree objects.
3512935218
** This code really belongs in btree.c. But btree.c is getting too
3513035219
** big and we want to break it down some. This packaged seemed like
3513135220
** a good breakout.
@@ -35773,12 +35862,41 @@
3577335862
SQLITE_PRIVATE void sqlite3BtreeReleaseTempCursor(BtCursor *pCur);
3577435863
SQLITE_PRIVATE void sqlite3BtreeMoveToParent(BtCursor *pCur);
3577535864
3577635865
/************** End of btreeInt.h ********************************************/
3577735866
/************** Continuing where we left off in btmutex.c ********************/
35778
-#if SQLITE_THREADSAFE && !defined(SQLITE_OMIT_SHARED_CACHE)
35867
+#ifndef SQLITE_OMIT_SHARED_CACHE
35868
+#if SQLITE_THREADSAFE
3577935869
35870
+/*
35871
+** Obtain the BtShared mutex associated with B-Tree handle p. Also,
35872
+** set BtShared.db to the database handle associated with p and the
35873
+** p->locked boolean to true.
35874
+*/
35875
+static void lockBtreeMutex(Btree *p){
35876
+ assert( p->locked==0 );
35877
+ assert( sqlite3_mutex_notheld(p->pBt->mutex) );
35878
+ assert( sqlite3_mutex_held(p->db->mutex) );
35879
+
35880
+ sqlite3_mutex_enter(p->pBt->mutex);
35881
+ p->pBt->db = p->db;
35882
+ p->locked = 1;
35883
+}
35884
+
35885
+/*
35886
+** Release the BtShared mutex associated with B-Tree handle p and
35887
+** clear the p->locked boolean.
35888
+*/
35889
+static void unlockBtreeMutex(Btree *p){
35890
+ assert( p->locked==1 );
35891
+ assert( sqlite3_mutex_held(p->pBt->mutex) );
35892
+ assert( sqlite3_mutex_held(p->db->mutex) );
35893
+ assert( p->db==p->pBt->db );
35894
+
35895
+ sqlite3_mutex_leave(p->pBt->mutex);
35896
+ p->locked = 0;
35897
+}
3578035898
3578135899
/*
3578235900
** Enter a mutex on the given BTree object.
3578335901
**
3578435902
** If the object is not sharable, then no mutex is ever required
@@ -35812,19 +35930,24 @@
3581235930
assert( p->sharable || p->wantToLock==0 );
3581335931
3581435932
/* We should already hold a lock on the database connection */
3581535933
assert( sqlite3_mutex_held(p->db->mutex) );
3581635934
35935
+ /* Unless the database is sharable and unlocked, then BtShared.db
35936
+ ** should already be set correctly. */
35937
+ assert( (p->locked==0 && p->sharable) || p->pBt->db==p->db );
35938
+
3581735939
if( !p->sharable ) return;
3581835940
p->wantToLock++;
3581935941
if( p->locked ) return;
3582035942
3582135943
/* In most cases, we should be able to acquire the lock we
3582235944
** want without having to go throught the ascending lock
3582335945
** procedure that follows. Just be sure not to block.
3582435946
*/
3582535947
if( sqlite3_mutex_try(p->pBt->mutex)==SQLITE_OK ){
35948
+ p->pBt->db = p->db;
3582635949
p->locked = 1;
3582735950
return;
3582835951
}
3582935952
3583035953
/* To avoid deadlock, first release all locks with a larger
@@ -35835,20 +35958,17 @@
3583535958
for(pLater=p->pNext; pLater; pLater=pLater->pNext){
3583635959
assert( pLater->sharable );
3583735960
assert( pLater->pNext==0 || pLater->pNext->pBt>pLater->pBt );
3583835961
assert( !pLater->locked || pLater->wantToLock>0 );
3583935962
if( pLater->locked ){
35840
- sqlite3_mutex_leave(pLater->pBt->mutex);
35841
- pLater->locked = 0;
35963
+ unlockBtreeMutex(pLater);
3584235964
}
3584335965
}
35844
- sqlite3_mutex_enter(p->pBt->mutex);
35845
- p->locked = 1;
35966
+ lockBtreeMutex(p);
3584635967
for(pLater=p->pNext; pLater; pLater=pLater->pNext){
3584735968
if( pLater->wantToLock ){
35848
- sqlite3_mutex_enter(pLater->pBt->mutex);
35849
- pLater->locked = 1;
35969
+ lockBtreeMutex(pLater);
3585035970
}
3585135971
}
3585235972
}
3585335973
3585435974
/*
@@ -35857,29 +35977,29 @@
3585735977
SQLITE_PRIVATE void sqlite3BtreeLeave(Btree *p){
3585835978
if( p->sharable ){
3585935979
assert( p->wantToLock>0 );
3586035980
p->wantToLock--;
3586135981
if( p->wantToLock==0 ){
35862
- assert( p->locked );
35863
- sqlite3_mutex_leave(p->pBt->mutex);
35864
- p->locked = 0;
35982
+ unlockBtreeMutex(p);
3586535983
}
3586635984
}
3586735985
}
3586835986
3586935987
#ifndef NDEBUG
3587035988
/*
35871
-** Return true if the BtShared mutex is held on the btree.
35872
-**
35873
-** This routine makes no determination one way or another if the
35874
-** database connection mutex is held.
35989
+** Return true if the BtShared mutex is held on the btree, or if the
35990
+** B-Tree is not marked as sharable.
3587535991
**
3587635992
** This routine is used only from within assert() statements.
3587735993
*/
3587835994
SQLITE_PRIVATE int sqlite3BtreeHoldsMutex(Btree *p){
35879
- return (p->sharable==0 ||
35880
- (p->locked && p->wantToLock && sqlite3_mutex_held(p->pBt->mutex)));
35995
+ assert( p->sharable==0 || p->locked==0 || p->wantToLock>0 );
35996
+ assert( p->sharable==0 || p->locked==0 || p->db==p->pBt->db );
35997
+ assert( p->sharable==0 || p->locked==0 || sqlite3_mutex_held(p->pBt->mutex) );
35998
+ assert( p->sharable==0 || p->locked==0 || sqlite3_mutex_held(p->db->mutex) );
35999
+
36000
+ return (p->sharable==0 || p->locked);
3588136001
}
3588236002
#endif
3588336003
3588436004
3588536005
#ifndef SQLITE_OMIT_INCRBLOB
@@ -35915,25 +36035,24 @@
3591536035
int i;
3591636036
Btree *p, *pLater;
3591736037
assert( sqlite3_mutex_held(db->mutex) );
3591836038
for(i=0; i<db->nDb; i++){
3591936039
p = db->aDb[i].pBt;
36040
+ assert( !p || (p->locked==0 && p->sharable) || p->pBt->db==p->db );
3592036041
if( p && p->sharable ){
3592136042
p->wantToLock++;
3592236043
if( !p->locked ){
3592336044
assert( p->wantToLock==1 );
3592436045
while( p->pPrev ) p = p->pPrev;
3592536046
while( p->locked && p->pNext ) p = p->pNext;
3592636047
for(pLater = p->pNext; pLater; pLater=pLater->pNext){
3592736048
if( pLater->locked ){
35928
- sqlite3_mutex_leave(pLater->pBt->mutex);
35929
- pLater->locked = 0;
36049
+ unlockBtreeMutex(pLater);
3593036050
}
3593136051
}
3593236052
while( p ){
35933
- sqlite3_mutex_enter(p->pBt->mutex);
35934
- p->locked++;
36053
+ lockBtreeMutex(p);
3593536054
p = p->pNext;
3593636055
}
3593736056
}
3593836057
}
3593936058
}
@@ -35946,13 +36065,11 @@
3594636065
p = db->aDb[i].pBt;
3594736066
if( p && p->sharable ){
3594836067
assert( p->wantToLock>0 );
3594936068
p->wantToLock--;
3595036069
if( p->wantToLock==0 ){
35951
- assert( p->locked );
35952
- sqlite3_mutex_leave(p->pBt->mutex);
35953
- p->locked = 0;
36070
+ unlockBtreeMutex(p);
3595436071
}
3595536072
}
3595636073
}
3595736074
}
3595836075
@@ -36037,12 +36154,11 @@
3603736154
/* We should already hold a lock on the database connection */
3603836155
assert( sqlite3_mutex_held(p->db->mutex) );
3603936156
3604036157
p->wantToLock++;
3604136158
if( !p->locked && p->sharable ){
36042
- sqlite3_mutex_enter(p->pBt->mutex);
36043
- p->locked = 1;
36159
+ lockBtreeMutex(p);
3604436160
}
3604536161
}
3604636162
}
3604736163
3604836164
/*
@@ -36060,18 +36176,30 @@
3606036176
/* We should already hold a lock on the database connection */
3606136177
assert( sqlite3_mutex_held(p->db->mutex) );
3606236178
3606336179
p->wantToLock--;
3606436180
if( p->wantToLock==0 && p->locked ){
36065
- sqlite3_mutex_leave(p->pBt->mutex);
36066
- p->locked = 0;
36181
+ unlockBtreeMutex(p);
3606736182
}
3606836183
}
3606936184
}
3607036185
36071
-
36072
-#endif /* SQLITE_THREADSAFE && !SQLITE_OMIT_SHARED_CACHE */
36186
+#else
36187
+SQLITE_PRIVATE void sqlite3BtreeEnter(Btree *p){
36188
+ p->pBt->db = p->db;
36189
+}
36190
+SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3 *db){
36191
+ int i;
36192
+ for(i=0; i<db->nDb; i++){
36193
+ Btree *p = db->aDb[i].pBt;
36194
+ if( p ){
36195
+ p->pBt->db = p->db;
36196
+ }
36197
+ }
36198
+}
36199
+#endif /* if SQLITE_THREADSAFE */
36200
+#endif /* ifndef SQLITE_OMIT_SHARED_CACHE */
3607336201
3607436202
/************** End of btmutex.c *********************************************/
3607536203
/************** Begin file btree.c *******************************************/
3607636204
/*
3607736205
** 2004 April 6
@@ -36082,11 +36210,11 @@
3608236210
** May you do good and not evil.
3608336211
** May you find forgiveness for yourself and forgive others.
3608436212
** May you share freely, never taking more than you give.
3608536213
**
3608636214
*************************************************************************
36087
-** $Id: btree.c,v 1.582 2009/03/30 18:50:05 danielk1977 Exp $
36215
+** $Id: btree.c,v 1.595 2009/04/11 16:06:15 danielk1977 Exp $
3608836216
**
3608936217
** This file implements a external (disk-based) database using BTrees.
3609036218
** See the header comment on "btreeInt.h" for additional information.
3609136219
** Including a description of file format and an overview of operation.
3609236220
*/
@@ -36175,10 +36303,17 @@
3617536303
3617636304
assert( sqlite3BtreeHoldsMutex(p) );
3617736305
assert( eLock==READ_LOCK || eLock==WRITE_LOCK );
3617836306
assert( p->db!=0 );
3617936307
36308
+ /* If requesting a write-lock, then the Btree must have an open write
36309
+ ** transaction on this file. And, obviously, for this to be so there
36310
+ ** must be an open write transaction on the file itself.
36311
+ */
36312
+ assert( eLock==READ_LOCK || (p==pBt->pWriter && p->inTrans==TRANS_WRITE) );
36313
+ assert( eLock==READ_LOCK || pBt->inTransaction==TRANS_WRITE );
36314
+
3618036315
/* This is a no-op if the shared-cache is not enabled */
3618136316
if( !p->sharable ){
3618236317
return SQLITE_OK;
3618336318
}
3618436319
@@ -36210,12 +36345,22 @@
3621036345
0==(p->db->flags&SQLITE_ReadUncommitted) ||
3621136346
eLock==WRITE_LOCK ||
3621236347
iTab==MASTER_ROOT
3621336348
){
3621436349
for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){
36215
- if( pIter->pBtree!=p && pIter->iTable==iTab &&
36216
- (pIter->eLock!=eLock || eLock!=READ_LOCK) ){
36350
+ /* The condition (pIter->eLock!=eLock) in the following if(...)
36351
+ ** statement is a simplification of:
36352
+ **
36353
+ ** (eLock==WRITE_LOCK || pIter->eLock==WRITE_LOCK)
36354
+ **
36355
+ ** since we know that if eLock==WRITE_LOCK, then no other connection
36356
+ ** may hold a WRITE_LOCK on any table in this file (since there can
36357
+ ** only be a single writer).
36358
+ */
36359
+ assert( pIter->eLock==READ_LOCK || pIter->eLock==WRITE_LOCK );
36360
+ assert( eLock==READ_LOCK || pIter->pBtree==p || pIter->eLock==READ_LOCK);
36361
+ if( pIter->pBtree!=p && pIter->iTable==iTab && pIter->eLock!=eLock ){
3621736362
sqlite3ConnectionBlocked(p->db, pIter->pBtree->db);
3621836363
if( eLock==WRITE_LOCK ){
3621936364
assert( p==pBt->pWriter );
3622036365
pBt->isPending = 1;
3622136366
}
@@ -36303,21 +36448,27 @@
3630336448
3630436449
#ifndef SQLITE_OMIT_SHARED_CACHE
3630536450
/*
3630636451
** Release all the table locks (locks obtained via calls to
3630736452
** the setSharedCacheTableLock() procedure) held by Btree handle p.
36453
+**
36454
+** This function assumes that handle p has an open read or write
36455
+** transaction. If it does not, then the BtShared.isPending variable
36456
+** may be incorrectly cleared.
3630836457
*/
3630936458
static void clearAllSharedCacheTableLocks(Btree *p){
3631036459
BtShared *pBt = p->pBt;
3631136460
BtLock **ppIter = &pBt->pLock;
3631236461
3631336462
assert( sqlite3BtreeHoldsMutex(p) );
3631436463
assert( p->sharable || 0==*ppIter );
36464
+ assert( p->inTrans>0 );
3631536465
3631636466
while( *ppIter ){
3631736467
BtLock *pLock = *ppIter;
3631836468
assert( pBt->isExclusive==0 || pBt->pWriter==pLock->pBtree );
36469
+ assert( pLock->pBtree->inTrans>=pLock->eLock );
3631936470
if( pLock->pBtree==p ){
3632036471
*ppIter = pLock->pNext;
3632136472
sqlite3_free(pLock);
3632236473
}else{
3632336474
ppIter = &pLock->pNext;
@@ -36920,76 +37071,78 @@
3692037071
}
3692137072
return SQLITE_OK;
3692237073
}
3692337074
3692437075
/*
36925
-** Allocate nByte bytes of space on a page.
36926
-**
36927
-** Return the index into pPage->aData[] of the first byte of
36928
-** the new allocation. The caller guarantees that there is enough
36929
-** space. This routine will never fail.
36930
-**
36931
-** If the page contains nBytes of free space but does not contain
36932
-** nBytes of contiguous free space, then this routine automatically
36933
-** calls defragmentPage() to consolidate all free space before
36934
-** allocating the new chunk.
37076
+** Allocate nByte bytes of space from within the B-Tree page passed
37077
+** as the first argument. Return the index into pPage->aData[] of the
37078
+** first byte of allocated space.
37079
+**
37080
+** The caller guarantees that the space between the end of the cell-offset
37081
+** array and the start of the cell-content area is at least nByte bytes
37082
+** in size. So this routine can never fail.
37083
+**
37084
+** If there are already 60 or more bytes of fragments within the page,
37085
+** the page is defragmented before returning. If this were not done there
37086
+** is a chance that the number of fragmented bytes could eventually
37087
+** overflow the single-byte field of the page-header in which this value
37088
+** is stored.
3693537089
*/
3693637090
static int allocateSpace(MemPage *pPage, int nByte){
36937
- int addr, pc, hdr;
36938
- int size;
36939
- int nFrag;
37091
+ const int hdr = pPage->hdrOffset; /* Local cache of pPage->hdrOffset */
37092
+ u8 * const data = pPage->aData; /* Local cache of pPage->aData */
37093
+ int nFrag; /* Number of fragmented bytes on pPage */
3694037094
int top;
36941
- int nCell;
36942
- int cellOffset;
36943
- unsigned char *data;
3694437095
36945
- data = pPage->aData;
3694637096
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
3694737097
assert( pPage->pBt );
3694837098
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
3694937099
assert( nByte>=0 ); /* Minimum cell size is 4 */
3695037100
assert( pPage->nFree>=nByte );
3695137101
assert( pPage->nOverflow==0 );
37102
+
37103
+ /* Assert that the space between the cell-offset array and the
37104
+ ** cell-content area is greater than nByte bytes.
37105
+ */
37106
+ assert( nByte <= (
37107
+ get2byte(&data[hdr+5])-(hdr+8+(pPage->leaf?0:4)+2*get2byte(&data[hdr+3]))
37108
+ ));
37109
+
3695237110
pPage->nFree -= (u16)nByte;
36953
- hdr = pPage->hdrOffset;
36954
-
3695537111
nFrag = data[hdr+7];
36956
- if( nFrag<60 ){
36957
- /* Search the freelist looking for a slot big enough to satisfy the
36958
- ** space request. */
36959
- addr = hdr+1;
36960
- while( (pc = get2byte(&data[addr]))>0 ){
36961
- size = get2byte(&data[pc+2]);
37112
+ if( nFrag>=60 ){
37113
+ defragmentPage(pPage);
37114
+ }else{
37115
+ /* Search the freelist looking for a free slot big enough to satisfy
37116
+ ** the request. The allocation is made from the first free slot in
37117
+ ** the list that is large enough to accomadate it.
37118
+ */
37119
+ int pc, addr;
37120
+ for(addr=hdr+1; (pc = get2byte(&data[addr]))>0; addr=pc){
37121
+ int size = get2byte(&data[pc+2]); /* Size of free slot */
3696237122
if( size>=nByte ){
3696337123
int x = size - nByte;
36964
- if( size<nByte+4 ){
37124
+ if( x<4 ){
37125
+ /* Remove the slot from the free-list. Update the number of
37126
+ ** fragmented bytes within the page. */
3696537127
memcpy(&data[addr], &data[pc], 2);
3696637128
data[hdr+7] = (u8)(nFrag + x);
36967
- return pc;
3696837129
}else{
37130
+ /* The slot remains on the free-list. Reduce its size to account
37131
+ ** for the portion used by the new allocation. */
3696937132
put2byte(&data[pc+2], x);
36970
- return pc + x;
3697137133
}
37134
+ return pc + x;
3697237135
}
36973
- addr = pc;
3697437136
}
3697537137
}
3697637138
3697737139
/* Allocate memory from the gap in between the cell pointer array
3697837140
** and the cell content area.
3697937141
*/
36980
- top = get2byte(&data[hdr+5]);
36981
- nCell = get2byte(&data[hdr+3]);
36982
- cellOffset = pPage->cellOffset;
36983
- if( nFrag>=60 || cellOffset + 2*nCell > top - nByte ){
36984
- defragmentPage(pPage);
36985
- top = get2byte(&data[hdr+5]);
36986
- }
36987
- top -= nByte;
36988
- assert( cellOffset + 2*nCell <= top );
37142
+ top = get2byte(&data[hdr+5]) - nByte;
3698937143
put2byte(&data[hdr+5], top);
36990
- assert( sqlite3PagerIswriteable(pPage->pDbPage) );
3699137144
return top;
3699237145
}
3699337146
3699437147
/*
3699537148
** Return a section of the pPage->aData to the freelist.
@@ -37373,14 +37526,15 @@
3737337526
** page to agree with the restored data.
3737437527
*/
3737537528
static void pageReinit(DbPage *pData){
3737637529
MemPage *pPage;
3737737530
pPage = (MemPage *)sqlite3PagerGetExtra(pData);
37531
+ assert( sqlite3PagerPageRefcount(pData)>0 );
3737837532
if( pPage->isInit ){
3737937533
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
3738037534
pPage->isInit = 0;
37381
- if( sqlite3PagerPageRefcount(pData)>0 ){
37535
+ if( sqlite3PagerPageRefcount(pData)>1 ){
3738237536
/* pPage might not be a btree page; it might be an overflow page
3738337537
** or ptrmap page or a free page. In those cases, the following
3738437538
** call to sqlite3BtreeInitPage() will likely return SQLITE_CORRUPT.
3738537539
** But no harm is done by this. And it is very important that
3738637540
** sqlite3BtreeInitPage() be called on every btree page so we make
@@ -37451,14 +37605,11 @@
3745137605
#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)
3745237606
/*
3745337607
** If this Btree is a candidate for shared cache, try to find an
3745437608
** existing BtShared object that we can share with
3745537609
*/
37456
- if( isMemdb==0
37457
- && (db->flags & SQLITE_Vtab)==0
37458
- && zFilename && zFilename[0]
37459
- ){
37610
+ if( isMemdb==0 && zFilename && zFilename[0] ){
3746037611
if( sqlite3GlobalConfig.sharedCacheEnabled ){
3746137612
int nFullPathname = pVfs->mxPathname+1;
3746237613
char *zFullPathname = sqlite3Malloc(nFullPathname);
3746337614
sqlite3_mutex *mutexShared;
3746437615
p->sharable = 1;
@@ -37519,10 +37670,11 @@
3751937670
rc = sqlite3PagerReadFileheader(pBt->pPager,sizeof(zDbHeader),zDbHeader);
3752037671
}
3752137672
if( rc!=SQLITE_OK ){
3752237673
goto btree_open_out;
3752337674
}
37675
+ pBt->db = db;
3752437676
sqlite3PagerSetBusyhandler(pBt->pPager, btreeInvokeBusyHandler, pBt);
3752537677
p->pBt = pBt;
3752637678
3752737679
sqlite3PagerSetReiniter(pBt->pPager, pageReinit);
3752837680
pBt->pCursor = 0;
@@ -37696,11 +37848,10 @@
3769637848
BtCursor *pCur;
3769737849
3769837850
/* Close all cursors opened via this handle. */
3769937851
assert( sqlite3_mutex_held(p->db->mutex) );
3770037852
sqlite3BtreeEnter(p);
37701
- pBt->db = p->db;
3770237853
pCur = pBt->pCursor;
3770337854
while( pCur ){
3770437855
BtCursor *pTmp = pCur;
3770537856
pCur = pCur->pNext;
3770637857
if( pTmp->pBtree==p ){
@@ -37806,10 +37957,12 @@
3780637957
}
3780737958
3780837959
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) || !defined(SQLITE_OMIT_VACUUM)
3780937960
/*
3781037961
** Change the default pages size and the number of reserved bytes per page.
37962
+** Or, if the page size has already been fixed, return SQLITE_READONLY
37963
+** without changing anything.
3781137964
**
3781237965
** The page size must be a power of 2 between 512 and 65536. If the page
3781337966
** size supplied does not meet this constraint then the page size is not
3781437967
** changed.
3781537968
**
@@ -37818,12 +37971,15 @@
3781837971
** the first byte past the 1GB boundary, 0x40000000) needs to occur
3781937972
** at the beginning of a page.
3782037973
**
3782137974
** If parameter nReserve is less than zero, then the number of reserved
3782237975
** bytes per page is left unchanged.
37976
+**
37977
+** If the iFix!=0 then the pageSizeFixed flag is set so that the page size
37978
+** and autovacuum mode can no longer be changed.
3782337979
*/
37824
-SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int pageSize, int nReserve){
37980
+SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int pageSize, int nReserve, int iFix){
3782537981
int rc = SQLITE_OK;
3782637982
BtShared *pBt = p->pBt;
3782737983
assert( nReserve>=-1 && nReserve<=255 );
3782837984
sqlite3BtreeEnter(p);
3782937985
if( pBt->pageSizeFixed ){
@@ -37841,10 +37997,11 @@
3784137997
pBt->pageSize = (u16)pageSize;
3784237998
freeTempSpace(pBt);
3784337999
rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize);
3784438000
}
3784538001
pBt->usableSize = pBt->pageSize - (u16)nReserve;
38002
+ if( iFix ) pBt->pageSizeFixed = 1;
3784638003
sqlite3BtreeLeave(p);
3784738004
return rc;
3784838005
}
3784938006
3785038007
/*
@@ -37941,11 +38098,11 @@
3794138098
int rc;
3794238099
MemPage *pPage1;
3794338100
int nPage;
3794438101
3794538102
assert( sqlite3_mutex_held(pBt->mutex) );
37946
- if( pBt->pPage1 ) return SQLITE_OK;
38103
+ assert( pBt->pPage1==0 );
3794738104
rc = sqlite3BtreeGetPage(pBt, 1, &pPage1, 0);
3794838105
if( rc!=SQLITE_OK ) return rc;
3794938106
3795038107
/* Do some checking to help insure the file we opened really is
3795138108
** a valid database file.
@@ -38169,11 +38326,10 @@
3816938326
sqlite3 *pBlock = 0;
3817038327
BtShared *pBt = p->pBt;
3817138328
int rc = SQLITE_OK;
3817238329
3817338330
sqlite3BtreeEnter(p);
38174
- pBt->db = p->db;
3817538331
btreeIntegrity(p);
3817638332
3817738333
/* If the btree is already in a write-transaction, or it
3817838334
** is already in a read-transaction and a read-transaction
3817938335
** is requested, this is a no-op.
@@ -38210,15 +38366,18 @@
3821038366
goto trans_begun;
3821138367
}
3821238368
#endif
3821338369
3821438370
do {
38215
- if( pBt->pPage1==0 ){
38216
- do{
38217
- rc = lockBtree(pBt);
38218
- }while( pBt->pPage1==0 && rc==SQLITE_OK );
38219
- }
38371
+ /* Call lockBtree() until either pBt->pPage1 is populated or
38372
+ ** lockBtree() returns something other than SQLITE_OK. lockBtree()
38373
+ ** may return SQLITE_OK but leave pBt->pPage1 set to 0 if after
38374
+ ** reading page 1 it discovers that the page-size of the database
38375
+ ** file is not pBt->pageSize. In this case lockBtree() will update
38376
+ ** pBt->pageSize to the page-size of the file on disk.
38377
+ */
38378
+ while( pBt->pPage1==0 && SQLITE_OK==(rc = lockBtree(pBt)) );
3822038379
3822138380
if( rc==SQLITE_OK && wrflag ){
3822238381
if( pBt->readOnly ){
3822338382
rc = SQLITE_READONLY;
3822438383
}else{
@@ -38313,11 +38472,11 @@
3831338472
pPage->isInit = isInitOrig;
3831438473
return rc;
3831538474
}
3831638475
3831738476
/*
38318
-** Somewhere on pPage, which is guarenteed to be a btree page, not an overflow
38477
+** Somewhere on pPage, which is guaranteed to be a btree page, not an overflow
3831938478
** page, is a pointer to page iFrom. Modify this pointer so that it points to
3832038479
** iTo. Parameter eType describes the type of pointer to be modified, as
3832138480
** follows:
3832238481
**
3832338482
** PTRMAP_BTREE: pPage is a btree-page. The pointer points at a child
@@ -38476,18 +38635,19 @@
3847638635
*/
3847738636
static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg){
3847838637
Pgno nFreeList; /* Number of pages still on the free-list */
3847938638
3848038639
assert( sqlite3_mutex_held(pBt->mutex) );
38640
+ assert( iLastPg>nFin );
3848138641
3848238642
if( !PTRMAP_ISPAGE(pBt, iLastPg) && iLastPg!=PENDING_BYTE_PAGE(pBt) ){
3848338643
int rc;
3848438644
u8 eType;
3848538645
Pgno iPtrPage;
3848638646
3848738647
nFreeList = get4byte(&pBt->pPage1->aData[36]);
38488
- if( nFreeList==0 || nFin==iLastPg ){
38648
+ if( nFreeList==0 ){
3848938649
return SQLITE_DONE;
3849038650
}
3849138651
3849238652
rc = ptrmapGet(pBt, iLastPg, &eType, &iPtrPage);
3849338653
if( rc!=SQLITE_OK ){
@@ -38584,11 +38744,10 @@
3858438744
SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *p){
3858538745
int rc;
3858638746
BtShared *pBt = p->pBt;
3858738747
3858838748
sqlite3BtreeEnter(p);
38589
- pBt->db = p->db;
3859038749
assert( pBt->inTransaction==TRANS_WRITE && p->inTrans==TRANS_WRITE );
3859138750
if( !pBt->autoVacuum ){
3859238751
rc = SQLITE_DONE;
3859338752
}else{
3859438753
invalidateAllOverflowCache(pBt);
@@ -38621,20 +38780,22 @@
3862138780
Pgno nPtrmap;
3862238781
Pgno iFree;
3862338782
const int pgsz = pBt->pageSize;
3862438783
Pgno nOrig = pagerPagecount(pBt);
3862538784
38626
- if( PTRMAP_ISPAGE(pBt, nOrig) ){
38785
+ if( PTRMAP_ISPAGE(pBt, nOrig) || nOrig==PENDING_BYTE_PAGE(pBt) ){
38786
+ /* It is not possible to create a database for which the final page
38787
+ ** is either a pointer-map page or the pending-byte page. If one
38788
+ ** is encountered, this indicates corruption.
38789
+ */
3862738790
return SQLITE_CORRUPT_BKPT;
3862838791
}
38629
- if( nOrig==PENDING_BYTE_PAGE(pBt) ){
38630
- nOrig--;
38631
- }
38792
+
3863238793
nFree = get4byte(&pBt->pPage1->aData[36]);
3863338794
nPtrmap = (nFree-nOrig+PTRMAP_PAGENO(pBt, nOrig)+pgsz/5)/(pgsz/5);
3863438795
nFin = nOrig - nFree - nPtrmap;
38635
- if( nOrig>PENDING_BYTE_PAGE(pBt) && nFin<=PENDING_BYTE_PAGE(pBt) ){
38796
+ if( nOrig>PENDING_BYTE_PAGE(pBt) && nFin<PENDING_BYTE_PAGE(pBt) ){
3863638797
nFin--;
3863738798
}
3863838799
while( PTRMAP_ISPAGE(pBt, nFin) || nFin==PENDING_BYTE_PAGE(pBt) ){
3863938800
nFin--;
3864038801
}
@@ -38689,11 +38850,10 @@
3868938850
SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree *p, const char *zMaster){
3869038851
int rc = SQLITE_OK;
3869138852
if( p->inTrans==TRANS_WRITE ){
3869238853
BtShared *pBt = p->pBt;
3869338854
sqlite3BtreeEnter(p);
38694
- pBt->db = p->db;
3869538855
#ifndef SQLITE_OMIT_AUTOVACUUM
3869638856
if( pBt->autoVacuum ){
3869738857
rc = autoVacuumCommit(pBt);
3869838858
if( rc!=SQLITE_OK ){
3869938859
sqlite3BtreeLeave(p);
@@ -38723,11 +38883,10 @@
3872338883
*/
3872438884
SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree *p){
3872538885
BtShared *pBt = p->pBt;
3872638886
3872738887
sqlite3BtreeEnter(p);
38728
- pBt->db = p->db;
3872938888
btreeIntegrity(p);
3873038889
3873138890
/* If the handle has a write-transaction open, commit the shared-btrees
3873238891
** transaction and set the shared state to TRANS_READ.
3873338892
*/
@@ -38740,18 +38899,18 @@
3874038899
sqlite3BtreeLeave(p);
3874138900
return rc;
3874238901
}
3874338902
pBt->inTransaction = TRANS_READ;
3874438903
}
38745
- clearAllSharedCacheTableLocks(p);
3874638904
3874738905
/* If the handle has any kind of transaction open, decrement the transaction
3874838906
** count of the shared btree. If the transaction count reaches 0, set
3874938907
** the shared state to TRANS_NONE. The unlockBtreeIfUnused() call below
3875038908
** will unlock the pager.
3875138909
*/
3875238910
if( p->inTrans!=TRANS_NONE ){
38911
+ clearAllSharedCacheTableLocks(p);
3875338912
pBt->nTransaction--;
3875438913
if( 0==pBt->nTransaction ){
3875538914
pBt->inTransaction = TRANS_NONE;
3875638915
}
3875738916
}
@@ -38849,11 +39008,10 @@
3884939008
int rc;
3885039009
BtShared *pBt = p->pBt;
3885139010
MemPage *pPage1;
3885239011
3885339012
sqlite3BtreeEnter(p);
38854
- pBt->db = p->db;
3885539013
rc = saveAllCursors(pBt, 0, 0);
3885639014
#ifndef SQLITE_OMIT_SHARED_CACHE
3885739015
if( rc!=SQLITE_OK ){
3885839016
/* This is a horrible situation. An IO or malloc() error occurred whilst
3885939017
** trying to save cursor positions. If this is an automatic rollback (as
@@ -38864,11 +39022,10 @@
3886439022
*/
3886539023
sqlite3BtreeTripAllCursors(p, rc);
3886639024
}
3886739025
#endif
3886839026
btreeIntegrity(p);
38869
- clearAllSharedCacheTableLocks(p);
3887039027
3887139028
if( p->inTrans==TRANS_WRITE ){
3887239029
int rc2;
3887339030
3887439031
assert( TRANS_WRITE==pBt->inTransaction );
@@ -38886,10 +39043,11 @@
3888639043
assert( countWriteCursors(pBt)==0 );
3888739044
pBt->inTransaction = TRANS_READ;
3888839045
}
3888939046
3889039047
if( p->inTrans!=TRANS_NONE ){
39048
+ clearAllSharedCacheTableLocks(p);
3889139049
assert( pBt->nTransaction>0 );
3889239050
pBt->nTransaction--;
3889339051
if( 0==pBt->nTransaction ){
3889439052
pBt->inTransaction = TRANS_NONE;
3889539053
}
@@ -38924,11 +39082,10 @@
3892439082
*/
3892539083
SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree *p, int iStatement){
3892639084
int rc;
3892739085
BtShared *pBt = p->pBt;
3892839086
sqlite3BtreeEnter(p);
38929
- pBt->db = p->db;
3893039087
assert( p->inTrans==TRANS_WRITE );
3893139088
assert( pBt->readOnly==0 );
3893239089
assert( iStatement>0 );
3893339090
assert( iStatement>p->db->nSavepoint );
3893439091
if( NEVER(p->inTrans!=TRANS_WRITE || pBt->readOnly) ){
@@ -38963,11 +39120,10 @@
3896339120
if( p && p->inTrans==TRANS_WRITE ){
3896439121
BtShared *pBt = p->pBt;
3896539122
assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );
3896639123
assert( iSavepoint>=0 || (iSavepoint==-1 && op==SAVEPOINT_ROLLBACK) );
3896739124
sqlite3BtreeEnter(p);
38968
- pBt->db = p->db;
3896939125
rc = sqlite3PagerSavepoint(pBt->pPager, op, iSavepoint);
3897039126
if( rc==SQLITE_OK ){
3897139127
rc = newDatabase(pBt);
3897239128
}
3897339129
sqlite3BtreeLeave(p);
@@ -39080,11 +39236,10 @@
3908039236
struct KeyInfo *pKeyInfo, /* First arg to xCompare() */
3908139237
BtCursor *pCur /* Write new cursor here */
3908239238
){
3908339239
int rc;
3908439240
sqlite3BtreeEnter(p);
39085
- p->pBt->db = p->db;
3908639241
rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);
3908739242
sqlite3BtreeLeave(p);
3908839243
return rc;
3908939244
}
3909039245
@@ -39138,11 +39293,10 @@
3913839293
Btree *pBtree = pCur->pBtree;
3913939294
if( pBtree ){
3914039295
int i;
3914139296
BtShared *pBt = pCur->pBt;
3914239297
sqlite3BtreeEnter(pBtree);
39143
- pBt->db = pBtree->db;
3914439298
sqlite3BtreeClearCursor(pCur);
3914539299
if( pCur->pPrev ){
3914639300
pCur->pPrev->pNext = pCur->pNext;
3914739301
}else{
3914839302
pBt->pCursor = pCur->pNext;
@@ -40116,11 +40270,12 @@
4011640270
int bias, /* Bias search to the high end */
4011740271
int *pRes /* Write search results here */
4011840272
){
4011940273
int rc; /* Status code */
4012040274
UnpackedRecord *pIdxKey; /* Unpacked index key */
40121
- UnpackedRecord aSpace[16]; /* Temp space for pIdxKey - to avoid a malloc */
40275
+ char aSpace[150]; /* Temp space for pIdxKey - to avoid a malloc */
40276
+
4012240277
4012340278
if( pKey ){
4012440279
assert( nKey==(i64)(int)nKey );
4012540280
pIdxKey = sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey,
4012640281
aSpace, sizeof(aSpace));
@@ -40717,11 +40872,14 @@
4071740872
nOvfl = (info.nPayload - info.nLocal + ovflPageSize - 1)/ovflPageSize;
4071840873
assert( ovflPgno==0 || nOvfl>0 );
4071940874
while( nOvfl-- ){
4072040875
Pgno iNext = 0;
4072140876
MemPage *pOvfl = 0;
40722
- if( ovflPgno==0 || ovflPgno>pagerPagecount(pBt) ){
40877
+ if( ovflPgno<2 || ovflPgno>pagerPagecount(pBt) ){
40878
+ /* 0 is not a legal page number and page 1 cannot be an
40879
+ ** overflow page. Therefore if ovflPgno<2 or past the end of the
40880
+ ** file the database must be corrupt. */
4072340881
return SQLITE_CORRUPT_BKPT;
4072440882
}
4072540883
if( nOvfl ){
4072640884
rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext);
4072740885
if( rc ) return rc;
@@ -41396,17 +41554,17 @@
4139641554
rc = SQLITE_NOMEM;
4139741555
goto balance_cleanup;
4139841556
}
4139941557
szCell = (u16*)&apCell[nMaxCells];
4140041558
aCopy[0] = (u8*)&szCell[nMaxCells];
41401
- assert( ((aCopy[0] - (u8*)0) & 7)==0 ); /* 8-byte alignment required */
41559
+ assert( EIGHT_BYTE_ALIGNMENT(aCopy[0]) );
4140241560
for(i=1; i<NB; i++){
4140341561
aCopy[i] = &aCopy[i-1][pBt->pageSize+ROUND8(sizeof(MemPage))];
4140441562
assert( ((aCopy[i] - (u8*)0) & 7)==0 ); /* 8-byte alignment required */
4140541563
}
4140641564
aSpace1 = &aCopy[NB-1][pBt->pageSize+ROUND8(sizeof(MemPage))];
41407
- assert( ((aSpace1 - (u8*)0) & 7)==0 ); /* 8-byte alignment required */
41565
+ assert( EIGHT_BYTE_ALIGNMENT(aSpace1) );
4140841566
if( ISAUTOVACUUM ){
4140941567
aFrom = &aSpace1[pBt->pageSize];
4141041568
}
4141141569
aSpace2 = sqlite3PageMalloc(pBt->pageSize);
4141241570
if( aSpace2==0 ){
@@ -42388,12 +42546,12 @@
4238842546
rc = saveCursorPosition(&leafCur);
4238942547
if( rc==SQLITE_OK ){
4239042548
rc = sqlite3BtreeNext(&leafCur, &notUsed);
4239142549
}
4239242550
pLeafPage = leafCur.apPage[leafCur.iPage];
42393
- assert( pLeafPage->pgno==leafPgno );
42394
- assert( leafCur.aiIdx[leafCur.iPage]==0 );
42551
+ assert( rc!=SQLITE_OK || pLeafPage->pgno==leafPgno );
42552
+ assert( rc!=SQLITE_OK || leafCur.aiIdx[leafCur.iPage]==0 );
4239542553
}
4239642554
4239742555
if( SQLITE_OK==rc
4239842556
&& SQLITE_OK==(rc = sqlite3PagerWrite(pLeafPage->pDbPage))
4239942557
){
@@ -42553,11 +42711,10 @@
4255342711
return SQLITE_OK;
4255442712
}
4255542713
SQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree *p, int *piTable, int flags){
4255642714
int rc;
4255742715
sqlite3BtreeEnter(p);
42558
- p->pBt->db = p->db;
4255942716
rc = btreeCreateTable(p, piTable, flags);
4256042717
sqlite3BtreeLeave(p);
4256142718
return rc;
4256242719
}
4256342720
@@ -42625,11 +42782,10 @@
4262542782
*/
4262642783
SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){
4262742784
int rc;
4262842785
BtShared *pBt = p->pBt;
4262942786
sqlite3BtreeEnter(p);
42630
- pBt->db = p->db;
4263142787
assert( p->inTrans==TRANS_WRITE );
4263242788
if( (rc = checkForReadConflicts(p, iTable, 0, 1))!=SQLITE_OK ){
4263342789
/* nothing to do */
4263442790
}else if( SQLITE_OK!=(rc = saveAllCursors(pBt, iTable, 0)) ){
4263542791
/* nothing to do */
@@ -42767,11 +42923,10 @@
4276742923
return rc;
4276842924
}
4276942925
SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree *p, int iTable, int *piMoved){
4277042926
int rc;
4277142927
sqlite3BtreeEnter(p);
42772
- p->pBt->db = p->db;
4277342928
rc = btreeDropTable(p, iTable, piMoved);
4277442929
sqlite3BtreeLeave(p);
4277542930
return rc;
4277642931
}
4277742932
@@ -42791,11 +42946,10 @@
4279142946
int rc;
4279242947
unsigned char *pP1;
4279342948
BtShared *pBt = p->pBt;
4279442949
4279542950
sqlite3BtreeEnter(p);
42796
- pBt->db = p->db;
4279742951
4279842952
/* Reading a meta-data value requires a read-lock on page 1 (and hence
4279942953
** the sqlite_master table. We grab this lock regardless of whether or
4280042954
** not the SQLITE_ReadUncommitted flag is set (the table rooted at page
4280142955
** 1 is treated as a special case by querySharedCacheTableLock()
@@ -42840,12 +42994,18 @@
4284042994
*/
4284142995
#ifdef SQLITE_OMIT_AUTOVACUUM
4284242996
if( idx==4 && *pMeta>0 ) pBt->readOnly = 1;
4284342997
#endif
4284442998
42845
- /* Grab the read-lock on page 1. */
42846
- rc = setSharedCacheTableLock(p, 1, READ_LOCK);
42999
+ /* If there is currently an open transaction, grab a read-lock
43000
+ ** on page 1 of the database file. This is done to make sure that
43001
+ ** no other connection can modify the meta value just read from
43002
+ ** the database until the transaction is concluded.
43003
+ */
43004
+ if( p->inTrans>0 ){
43005
+ rc = setSharedCacheTableLock(p, 1, READ_LOCK);
43006
+ }
4284743007
sqlite3BtreeLeave(p);
4284843008
return rc;
4284943009
}
4285043010
4285143011
/*
@@ -42856,11 +43016,10 @@
4285643016
BtShared *pBt = p->pBt;
4285743017
unsigned char *pP1;
4285843018
int rc;
4285943019
assert( idx>=1 && idx<=15 );
4286043020
sqlite3BtreeEnter(p);
42861
- pBt->db = p->db;
4286243021
assert( p->inTrans==TRANS_WRITE );
4286343022
assert( pBt->pPage1!=0 );
4286443023
pP1 = pBt->pPage1->aData;
4286543024
rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
4286643025
if( rc==SQLITE_OK ){
@@ -43330,11 +43489,10 @@
4333043489
IntegrityCk sCheck;
4333143490
BtShared *pBt = p->pBt;
4333243491
char zErr[100];
4333343492
4333443493
sqlite3BtreeEnter(p);
43335
- pBt->db = p->db;
4333643494
nRef = sqlite3PagerRefcount(pBt->pPager);
4333743495
if( lockBtreeWithRetry(p)!=SQLITE_OK ){
4333843496
*pnErr = 1;
4333943497
sqlite3BtreeLeave(p);
4334043498
return sqlite3DbStrDup(0, "cannot acquire a read lock on the database");
@@ -44240,11 +44398,11 @@
4424044398
** This file contains code use to manipulate "Mem" structure. A "Mem"
4424144399
** stores a single value in the VDBE. Mem is an opaque structure visible
4424244400
** only within the VDBE. Interface routines refer to a Mem using the
4424344401
** name sqlite_value
4424444402
**
44245
-** $Id: vdbemem.c,v 1.139 2009/03/29 15:12:10 drh Exp $
44403
+** $Id: vdbemem.c,v 1.140 2009/04/05 12:22:09 drh Exp $
4424644404
*/
4424744405
4424844406
/*
4424944407
** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem*)
4425044408
** P if required.
@@ -44432,10 +44590,11 @@
4443244590
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
4443344591
assert( !(fg&MEM_Zero) );
4443444592
assert( !(fg&(MEM_Str|MEM_Blob)) );
4443544593
assert( fg&(MEM_Int|MEM_Real) );
4443644594
assert( (pMem->flags&MEM_RowSet)==0 );
44595
+ assert( EIGHT_BYTE_ALIGNMENT(pMem) );
4443744596
4443844597
4443944598
if( sqlite3VdbeMemGrow(pMem, nByte, 0) ){
4444044599
return SQLITE_NOMEM;
4444144600
}
@@ -44568,10 +44727,11 @@
4456844727
** If pMem represents a string value, its encoding might be changed.
4456944728
*/
4457044729
SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){
4457144730
int flags;
4457244731
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
44732
+ assert( EIGHT_BYTE_ALIGNMENT(pMem) );
4457344733
flags = pMem->flags;
4457444734
if( flags & MEM_Int ){
4457544735
return pMem->u.i;
4457644736
}else if( flags & MEM_Real ){
4457744737
return doubleToInt64(pMem->r);
@@ -44596,10 +44756,11 @@
4459644756
** value. If it is a string or blob, try to convert it to a double.
4459744757
** If it is a NULL, return 0.0.
4459844758
*/
4459944759
SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){
4460044760
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
44761
+ assert( EIGHT_BYTE_ALIGNMENT(pMem) );
4460144762
if( pMem->flags & MEM_Real ){
4460244763
return pMem->r;
4460344764
}else if( pMem->flags & MEM_Int ){
4460444765
return (double)pMem->u.i;
4460544766
}else if( pMem->flags & (MEM_Str|MEM_Blob) ){
@@ -44626,10 +44787,11 @@
4462644787
*/
4462744788
SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){
4462844789
assert( pMem->flags & MEM_Real );
4462944790
assert( (pMem->flags & MEM_RowSet)==0 );
4463044791
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
44792
+ assert( EIGHT_BYTE_ALIGNMENT(pMem) );
4463144793
4463244794
pMem->u.i = doubleToInt64(pMem->r);
4463344795
if( pMem->r==(double)pMem->u.i ){
4463444796
pMem->flags |= MEM_Int;
4463544797
}
@@ -44639,10 +44801,12 @@
4463944801
** Convert pMem to type integer. Invalidate any prior representations.
4464044802
*/
4464144803
SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){
4464244804
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
4464344805
assert( (pMem->flags & MEM_RowSet)==0 );
44806
+ assert( EIGHT_BYTE_ALIGNMENT(pMem) );
44807
+
4464444808
pMem->u.i = sqlite3VdbeIntValue(pMem);
4464544809
MemSetTypeFlag(pMem, MEM_Int);
4464644810
return SQLITE_OK;
4464744811
}
4464844812
@@ -44650,10 +44814,12 @@
4465044814
** Convert pMem so that it is of type MEM_Real.
4465144815
** Invalidate any prior representations.
4465244816
*/
4465344817
SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){
4465444818
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
44819
+ assert( EIGHT_BYTE_ALIGNMENT(pMem) );
44820
+
4465544821
pMem->r = sqlite3VdbeRealValue(pMem);
4465644822
MemSetTypeFlag(pMem, MEM_Real);
4465744823
return SQLITE_OK;
4465844824
}
4465944825
@@ -45287,11 +45453,11 @@
4528745453
** This file contains code used for creating, destroying, and populating
4528845454
** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior
4528945455
** to version 2.8.7, all this code was combined into the vdbe.c source file.
4529045456
** But that file was getting too big so this subroutines were split out.
4529145457
**
45292
-** $Id: vdbeaux.c,v 1.446 2009/03/25 15:43:09 danielk1977 Exp $
45458
+** $Id: vdbeaux.c,v 1.451 2009/04/10 15:42:36 shane Exp $
4529345459
*/
4529445460
4529545461
4529645462
4529745463
/*
@@ -46294,10 +46460,11 @@
4629446460
int nByte, /* Number of bytes to allocate */
4629546461
u8 **ppFrom, /* IN/OUT: Allocate from *ppFrom */
4629646462
u8 *pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */
4629746463
int *pnByte /* If allocation cannot be made, increment *pnByte */
4629846464
){
46465
+ assert( EIGHT_BYTE_ALIGNMENT(*ppFrom) );
4629946466
if( (*(void**)pp)==0 ){
4630046467
nByte = ROUND8(nByte);
4630146468
if( (pEnd - *ppFrom)>=nByte ){
4630246469
*(void**)pp = (void *)*ppFrom;
4630346470
*ppFrom += nByte;
@@ -46367,10 +46534,13 @@
4636746534
int nArg; /* Maximum number of args passed to a user function. */
4636846535
resolveP2Values(p, &nArg);
4636946536
if( isExplain && nMem<10 ){
4637046537
nMem = 10;
4637146538
}
46539
+ zCsr += (zCsr - (u8*)0)&7;
46540
+ assert( EIGHT_BYTE_ALIGNMENT(zCsr) );
46541
+ if( zEnd<zCsr ) zEnd = zCsr;
4637246542
4637346543
do {
4637446544
memset(zCsr, 0, zEnd-zCsr);
4637546545
nByte = 0;
4637646546
allocSpace((char*)&p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte);
@@ -46877,10 +47047,37 @@
4687747047
p->iStatement = 0;
4687847048
}
4687947049
return rc;
4688047050
}
4688147051
47052
+/*
47053
+** If SQLite is compiled to support shared-cache mode and to be threadsafe,
47054
+** this routine obtains the mutex associated with each BtShared structure
47055
+** that may be accessed by the VM passed as an argument. In doing so it
47056
+** sets the BtShared.db member of each of the BtShared structures, ensuring
47057
+** that the correct busy-handler callback is invoked if required.
47058
+**
47059
+** If SQLite is not threadsafe but does support shared-cache mode, then
47060
+** sqlite3BtreeEnterAll() is invoked to set the BtShared.db variables
47061
+** of all of BtShared structures accessible via the database handle
47062
+** associated with the VM. Of course only a subset of these structures
47063
+** will be accessed by the VM, and we could use Vdbe.btreeMask to figure
47064
+** that subset out, but there is no advantage to doing so.
47065
+**
47066
+** If SQLite is not threadsafe and does not support shared-cache mode, this
47067
+** function is a no-op.
47068
+*/
47069
+#ifndef SQLITE_OMIT_SHARED_CACHE
47070
+SQLITE_PRIVATE void sqlite3VdbeMutexArrayEnter(Vdbe *p){
47071
+#if SQLITE_THREADSAFE
47072
+ sqlite3BtreeMutexArrayEnter(&p->aMutex);
47073
+#else
47074
+ sqlite3BtreeEnterAll(p->db);
47075
+#endif
47076
+}
47077
+#endif
47078
+
4688247079
/*
4688347080
** This routine is called the when a VDBE tries to halt. If the VDBE
4688447081
** has made changes and is in autocommit mode, then commit those
4688547082
** changes. If a rollback is needed, then do the rollback.
4688647083
**
@@ -46926,11 +47123,11 @@
4692647123
int mrc; /* Primary error code from p->rc */
4692747124
int eStatementOp = 0;
4692847125
int isSpecialError; /* Set to true if a 'special' error */
4692947126
4693047127
/* Lock all btrees used by the statement */
46931
- sqlite3BtreeMutexArrayEnter(&p->aMutex);
47128
+ sqlite3VdbeMutexArrayEnter(p);
4693247129
4693347130
/* Check for one of the special errors */
4693447131
mrc = p->rc & 0xff;
4693547132
isSpecialError = mrc==SQLITE_NOMEM || mrc==SQLITE_IOERR
4693647133
|| mrc==SQLITE_INTERRUPT || mrc==SQLITE_FULL;
@@ -47587,34 +47784,44 @@
4758747784
*/
4758847785
SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeRecordUnpack(
4758947786
KeyInfo *pKeyInfo, /* Information about the record format */
4759047787
int nKey, /* Size of the binary record */
4759147788
const void *pKey, /* The binary record */
47592
- UnpackedRecord *pSpace,/* Space available to hold resulting object */
47789
+ char *pSpace, /* Unaligned space available to hold the object */
4759347790
int szSpace /* Size of pSpace[] in bytes */
4759447791
){
4759547792
const unsigned char *aKey = (const unsigned char *)pKey;
47596
- UnpackedRecord *p;
47597
- int nByte, d;
47793
+ UnpackedRecord *p; /* The unpacked record that we will return */
47794
+ int nByte; /* Memory space needed to hold p, in bytes */
47795
+ int d;
4759847796
u32 idx;
47599
- u16 u; /* Unsigned loop counter */
47797
+ u16 u; /* Unsigned loop counter */
4760047798
u32 szHdr;
4760147799
Mem *pMem;
47800
+ int nOff; /* Increase pSpace by this much to 8-byte align it */
4760247801
47603
- assert( sizeof(Mem)>sizeof(*p) );
47604
- nByte = sizeof(Mem)*(pKeyInfo->nField+2);
47802
+ /*
47803
+ ** We want to shift the pointer pSpace up such that it is 8-byte aligned.
47804
+ ** Thus, we need to calculate a value, nOff, between 0 and 7, to shift
47805
+ ** it by. If pSpace is already 8-byte aligned, nOff should be zero.
47806
+ */
47807
+ nOff = (8 - (SQLITE_PTR_TO_INT(pSpace) & 7)) & 7;
47808
+ pSpace += nOff;
47809
+ szSpace -= nOff;
47810
+ nByte = ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*(pKeyInfo->nField+1);
4760547811
if( nByte>szSpace ){
4760647812
p = sqlite3DbMallocRaw(pKeyInfo->db, nByte);
4760747813
if( p==0 ) return 0;
4760847814
p->flags = UNPACKED_NEED_FREE | UNPACKED_NEED_DESTROY;
4760947815
}else{
47610
- p = pSpace;
47816
+ p = (UnpackedRecord*)pSpace;
4761147817
p->flags = UNPACKED_NEED_DESTROY;
4761247818
}
4761347819
p->pKeyInfo = pKeyInfo;
4761447820
p->nField = pKeyInfo->nField + 1;
47615
- p->aMem = pMem = &((Mem*)p)[1];
47821
+ p->aMem = pMem = (Mem*)&((char*)p)[ROUND8(sizeof(UnpackedRecord))];
47822
+ assert( EIGHT_BYTE_ALIGNMENT(pMem) );
4761647823
idx = getVarint32(aKey, szHdr);
4761747824
d = szHdr;
4761847825
u = 0;
4761947826
while( idx<szHdr && u<p->nField ){
4762047827
u32 serial_type;
@@ -47926,11 +48133,11 @@
4792648133
*************************************************************************
4792748134
**
4792848135
** This file contains code use to implement APIs that are part of the
4792948136
** VDBE.
4793048137
**
47931
-** $Id: vdbeapi.c,v 1.156 2009/03/25 15:43:09 danielk1977 Exp $
48138
+** $Id: vdbeapi.c,v 1.161 2009/04/10 23:11:31 drh Exp $
4793248139
*/
4793348140
4793448141
#if 0 && defined(SQLITE_ENABLE_MEMORY_MANAGEMENT)
4793548142
/*
4793648143
** The following structure contains pointers to the end points of a
@@ -48354,11 +48561,11 @@
4835448561
if( db->mallocFailed ){
4835548562
return SQLITE_NOMEM;
4835648563
}
4835748564
4835848565
if( p->pc<=0 && p->expired ){
48359
- if( p->rc==SQLITE_OK ){
48566
+ if( ALWAYS(p->rc==SQLITE_OK) ){
4836048567
p->rc = SQLITE_SCHEMA;
4836148568
}
4836248569
rc = SQLITE_ERROR;
4836348570
goto end_of_step;
4836448571
}
@@ -48470,11 +48677,11 @@
4847048677
&& cnt++ < 5
4847148678
&& (rc = vdbeReprepare(v))==SQLITE_OK ){
4847248679
sqlite3_reset(pStmt);
4847348680
v->expired = 0;
4847448681
}
48475
- if( rc==SQLITE_SCHEMA && v->isPrepareV2 && db->pErr ){
48682
+ if( rc==SQLITE_SCHEMA && ALWAYS(v->isPrepareV2) && ALWAYS(db->pErr) ){
4847648683
/* This case occurs after failing to recompile an sql statement.
4847748684
** The error message from the SQL compiler has already been loaded
4847848685
** into the database handle. This block copies the error message
4847948686
** from the database handle into the statement and sets the statement
4848048687
** program counter to 0 to ensure that when the statement is
@@ -48529,11 +48736,11 @@
4852948736
sqlite3_value **NotUsed2 /* Value of each argument */
4853048737
){
4853148738
const char *zName = context->pFunc->zName;
4853248739
char *zErr;
4853348740
UNUSED_PARAMETER2(NotUsed, NotUsed2);
48534
- zErr = sqlite3MPrintf(0,
48741
+ zErr = sqlite3_mprintf(
4853548742
"unable to use function %s in the requested context", zName);
4853648743
sqlite3_result_error(context, zErr, -1);
4853748744
sqlite3_free(zErr);
4853848745
}
4853948746
@@ -48675,11 +48882,11 @@
4867548882
vals = sqlite3_data_count(pStmt);
4867648883
pOut = &pVm->pResultSet[i];
4867748884
}else{
4867848885
/* ((double)0) In case of SQLITE_OMIT_FLOATING_POINT... */
4867948886
static const Mem nullMem = {{0}, (double)0, 0, "", 0, MEM_Null, SQLITE_NULL, 0, 0, 0 };
48680
- if( pVm && pVm->db ){
48887
+ if( pVm && ALWAYS(pVm->db) ){
4868148888
sqlite3_mutex_enter(pVm->db->mutex);
4868248889
sqlite3Error(pVm->db, SQLITE_RANGE, 0);
4868348890
}
4868448891
pOut = (Mem*)&nullMem;
4868548892
}
@@ -48815,28 +49022,27 @@
4881549022
int useType
4881649023
){
4881749024
const void *ret = 0;
4881849025
Vdbe *p = (Vdbe *)pStmt;
4881949026
int n;
48820
-
48821
-
48822
- if( p!=0 ){
48823
- n = sqlite3_column_count(pStmt);
48824
- if( N<n && N>=0 ){
48825
- N += useType*n;
48826
- sqlite3_mutex_enter(p->db->mutex);
48827
- ret = xFunc(&p->aColName[N]);
48828
-
48829
- /* A malloc may have failed inside of the xFunc() call. If this
48830
- ** is the case, clear the mallocFailed flag and return NULL.
48831
- */
48832
- if( p->db && p->db->mallocFailed ){
48833
- p->db->mallocFailed = 0;
48834
- ret = 0;
48835
- }
48836
- sqlite3_mutex_leave(p->db->mutex);
48837
- }
49027
+ sqlite3 *db = p->db;
49028
+
49029
+ assert( db!=0 );
49030
+ n = sqlite3_column_count(pStmt);
49031
+ if( N<n && N>=0 ){
49032
+ N += useType*n;
49033
+ sqlite3_mutex_enter(db->mutex);
49034
+ assert( db->mallocFailed==0 );
49035
+ ret = xFunc(&p->aColName[N]);
49036
+ /* A malloc may have failed inside of the xFunc() call. If this
49037
+ ** is the case, clear the mallocFailed flag and return NULL.
49038
+ */
49039
+ if( db->mallocFailed ){
49040
+ db->mallocFailed = 0;
49041
+ ret = 0;
49042
+ }
49043
+ sqlite3_mutex_leave(db->mutex);
4883849044
}
4883949045
return ret;
4884049046
}
4884149047
4884249048
/*
@@ -49072,12 +49278,12 @@
4907249278
rc = sqlite3VdbeMemCopy(&p->aVar[i-1], pValue);
4907349279
if( rc==SQLITE_OK ){
4907449280
rc = sqlite3VdbeChangeEncoding(&p->aVar[i-1], ENC(p->db));
4907549281
}
4907649282
sqlite3_mutex_leave(p->db->mutex);
49283
+ rc = sqlite3ApiExit(p->db, rc);
4907749284
}
49078
- rc = sqlite3ApiExit(p->db, rc);
4907949285
return rc;
4908049286
}
4908149287
SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
4908249288
int rc;
4908349289
Vdbe *p = (Vdbe *)pStmt;
@@ -49103,22 +49309,25 @@
4910349309
** in the Vdbe.azVar[] array, if such a mapping does not already
4910449310
** exist.
4910549311
*/
4910649312
static void createVarMap(Vdbe *p){
4910749313
if( !p->okVar ){
49314
+ int j;
49315
+ Op *pOp;
4910849316
sqlite3_mutex_enter(p->db->mutex);
49109
- if( !p->okVar ){
49110
- int j;
49111
- Op *pOp;
49112
- for(j=0, pOp=p->aOp; j<p->nOp; j++, pOp++){
49113
- if( pOp->opcode==OP_Variable ){
49114
- assert( pOp->p1>0 && pOp->p1<=p->nVar );
49115
- p->azVar[pOp->p1-1] = pOp->p4.z;
49116
- }
49117
- }
49118
- p->okVar = 1;
49119
- }
49317
+ /* The race condition here is harmless. If two threads call this
49318
+ ** routine on the same Vdbe at the same time, they both might end
49319
+ ** up initializing the Vdbe.azVar[] array. That is a little extra
49320
+ ** work but it results in the same answer.
49321
+ */
49322
+ for(j=0, pOp=p->aOp; j<p->nOp; j++, pOp++){
49323
+ if( pOp->opcode==OP_Variable ){
49324
+ assert( pOp->p1>0 && pOp->p1<=p->nVar );
49325
+ p->azVar[pOp->p1-1] = pOp->p4.z;
49326
+ }
49327
+ }
49328
+ p->okVar = 1;
4912049329
sqlite3_mutex_leave(p->db->mutex);
4912149330
}
4912249331
}
4912349332
4912449333
/*
@@ -49159,40 +49368,44 @@
4915949368
return 0;
4916049369
}
4916149370
4916249371
/*
4916349372
** Transfer all bindings from the first statement over to the second.
49164
-** If the two statements contain a different number of bindings, then
49165
-** an SQLITE_ERROR is returned.
4916649373
*/
4916749374
SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
4916849375
Vdbe *pFrom = (Vdbe*)pFromStmt;
4916949376
Vdbe *pTo = (Vdbe*)pToStmt;
49170
- int i, rc = SQLITE_OK;
49171
- if( (pFrom->magic!=VDBE_MAGIC_RUN && pFrom->magic!=VDBE_MAGIC_HALT)
49172
- || (pTo->magic!=VDBE_MAGIC_RUN && pTo->magic!=VDBE_MAGIC_HALT)
49173
- || pTo->db!=pFrom->db ){
49174
- return SQLITE_MISUSE;
49175
- }
49176
- if( pFrom->nVar!=pTo->nVar ){
49177
- return SQLITE_ERROR;
49178
- }
49377
+ int i;
49378
+ assert( pTo->db==pFrom->db );
49379
+ assert( pTo->nVar==pFrom->nVar );
4917949380
sqlite3_mutex_enter(pTo->db->mutex);
49180
- for(i=0; rc==SQLITE_OK && i<pFrom->nVar; i++){
49381
+ for(i=0; i<pFrom->nVar; i++){
4918149382
sqlite3VdbeMemMove(&pTo->aVar[i], &pFrom->aVar[i]);
4918249383
}
4918349384
sqlite3_mutex_leave(pTo->db->mutex);
49184
- assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
49185
- return rc;
49385
+ return SQLITE_OK;
4918649386
}
4918749387
4918849388
#ifndef SQLITE_OMIT_DEPRECATED
4918949389
/*
4919049390
** Deprecated external interface. Internal/core SQLite code
4919149391
** should call sqlite3TransferBindings.
49392
+**
49393
+** Is is misuse to call this routine with statements from different
49394
+** database connections. But as this is a deprecated interface, we
49395
+** will not bother to check for that condition.
49396
+**
49397
+** If the two statements contain a different number of bindings, then
49398
+** an SQLITE_ERROR is returned. Nothing else can go wrong, so otherwise
49399
+** SQLITE_OK is returned.
4919249400
*/
4919349401
SQLITE_API int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
49402
+ Vdbe *pFrom = (Vdbe*)pFromStmt;
49403
+ Vdbe *pTo = (Vdbe*)pToStmt;
49404
+ if( pFrom->nVar!=pTo->nVar ){
49405
+ return SQLITE_ERROR;
49406
+ }
4919449407
return sqlite3TransferBindings(pFromStmt, pToStmt);
4919549408
}
4919649409
#endif
4919749410
4919849411
/*
@@ -49278,11 +49491,11 @@
4927849491
** documentation, headers files, or other derived files. The formatting
4927949492
** of the code in this file is, therefore, important. See other comments
4928049493
** in this file for details. If in doubt, do not deviate from existing
4928149494
** commenting and indentation practices when changing or adding code.
4928249495
**
49283
-** $Id: vdbe.c,v 1.828 2009/03/23 17:11:27 danielk1977 Exp $
49496
+** $Id: vdbe.c,v 1.832 2009/04/10 12:55:17 danielk1977 Exp $
4928449497
*/
4928549498
4928649499
/*
4928749500
** The following global variable is incremented every time a cursor
4928849501
** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes. The test
@@ -49886,15 +50099,17 @@
4988650099
int origPc; /* Program counter at start of opcode */
4988750100
#endif
4988850101
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
4988950102
int nProgressOps = 0; /* Opcodes executed since progress callback. */
4989050103
#endif
49891
- UnpackedRecord aTempRec[16]; /* Space to hold a transient UnpackedRecord */
50104
+
50105
+ /* Temporary space into which to unpack a record. */
50106
+ char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*3 + 7];
4989250107
4989350108
assert( p->magic==VDBE_MAGIC_RUN ); /* sqlite3_step() verifies this */
4989450109
assert( db->magic==SQLITE_MAGIC_BUSY );
49895
- sqlite3BtreeMutexArrayEnter(&p->aMutex);
50110
+ sqlite3VdbeMutexArrayEnter(p);
4989650111
if( p->rc==SQLITE_NOMEM ){
4989750112
/* This happens if a malloc() inside a call to sqlite3_column_text() or
4989850113
** sqlite3_column_text16() failed. */
4989950114
goto no_mem;
4990050115
}
@@ -51689,11 +51904,15 @@
5168951904
*/
5169051905
#ifndef SQLITE_OMIT_BTREECOUNT
5169151906
case OP_Count: { /* out2-prerelease */
5169251907
i64 nEntry;
5169351908
BtCursor *pCrsr = p->apCsr[pOp->p1]->pCursor;
51694
- rc = sqlite3BtreeCount(pCrsr, &nEntry);
51909
+ if( pCrsr ){
51910
+ rc = sqlite3BtreeCount(pCrsr, &nEntry);
51911
+ }else{
51912
+ nEntry = 0;
51913
+ }
5169551914
pOut->flags = MEM_Int;
5169651915
pOut->u.i = nEntry;
5169751916
break;
5169851917
}
5169951918
#endif
@@ -53472,16 +53691,18 @@
5347253691
*/
5347353692
case OP_IdxRowid: { /* out2-prerelease */
5347453693
int i = pOp->p1;
5347553694
BtCursor *pCrsr;
5347653695
VdbeCursor *pC;
53696
+
5347753697
5347853698
assert( i>=0 && i<p->nCursor );
5347953699
assert( p->apCsr[i]!=0 );
5348053700
if( (pCrsr = (pC = p->apCsr[i])->pCursor)!=0 ){
5348153701
i64 rowid;
53482
-
53702
+ rc = sqlite3VdbeCursorMoveto(pC);
53703
+ if( rc ) goto abort_due_to_error;
5348353704
assert( pC->deferredMoveto==0 );
5348453705
assert( pC->isTable==0 );
5348553706
if( !pC->nullRow ){
5348653707
rc = sqlite3VdbeIdxRowid(pCrsr, &rowid);
5348753708
if( rc!=SQLITE_OK ){
@@ -55348,22 +55569,27 @@
5534855569
**
5534955570
** This file contains code use to implement an in-memory rollback journal.
5535055571
** The in-memory rollback journal is used to journal transactions for
5535155572
** ":memory:" databases and when the journal_mode=MEMORY pragma is used.
5535255573
**
55353
-** @(#) $Id: memjournal.c,v 1.8 2008/12/20 02:14:40 drh Exp $
55574
+** @(#) $Id: memjournal.c,v 1.11 2009/04/05 12:22:09 drh Exp $
5535455575
*/
5535555576
5535655577
/* Forward references to internal structures */
5535755578
typedef struct MemJournal MemJournal;
5535855579
typedef struct FilePoint FilePoint;
5535955580
typedef struct FileChunk FileChunk;
5536055581
5536155582
/* Space to hold the rollback journal is allocated in increments of
5536255583
** this many bytes.
55584
+**
55585
+** The size chosen is a little less than a power of two. That way,
55586
+** the FileChunk object will have a size that almost exactly fills
55587
+** a power-of-two allocation. This mimimizes wasted space in power-of-two
55588
+** memory allocators.
5536355589
*/
55364
-#define JOURNAL_CHUNKSIZE 1024
55590
+#define JOURNAL_CHUNKSIZE ((int)(1024-sizeof(FileChunk*)))
5536555591
5536655592
/* Macro to find the minimum of two numeric values.
5536755593
*/
5536855594
#ifndef MIN
5536955595
# define MIN(x,y) ((x)<(y)?(x):(y))
@@ -55396,11 +55622,12 @@
5539655622
FilePoint endpoint; /* Pointer to the end of the file */
5539755623
FilePoint readpoint; /* Pointer to the end of the last xRead() */
5539855624
};
5539955625
5540055626
/*
55401
-** Read data from the file.
55627
+** Read data from the in-memory journal file. This is the implementation
55628
+** of the sqlite3_vfs.xRead method.
5540255629
*/
5540355630
static int memjrnlRead(
5540455631
sqlite3_file *pJfd, /* The journal file from which to read */
5540555632
void *zBuf, /* Put the results here */
5540655633
int iAmt, /* Number of bytes to read */
@@ -55410,16 +55637,17 @@
5541055637
u8 *zOut = zBuf;
5541155638
int nRead = iAmt;
5541255639
int iChunkOffset;
5541355640
FileChunk *pChunk;
5541455641
55642
+ /* SQLite never tries to read past the end of a rollback journal file */
5541555643
assert( iOfst+iAmt<=p->endpoint.iOffset );
5541655644
5541755645
if( p->readpoint.iOffset!=iOfst || iOfst==0 ){
5541855646
sqlite3_int64 iOff = 0;
5541955647
for(pChunk=p->pFirst;
55420
- pChunk && (iOff+JOURNAL_CHUNKSIZE)<=iOfst;
55648
+ ALWAYS(pChunk) && (iOff+JOURNAL_CHUNKSIZE)<=iOfst;
5542155649
pChunk=pChunk->pNext
5542255650
){
5542355651
iOff += JOURNAL_CHUNKSIZE;
5542455652
}
5542555653
}else{
@@ -55518,15 +55746,21 @@
5551855746
}
5551955747
5552055748
5552155749
/*
5552255750
** Sync the file.
55751
+**
55752
+** Syncing an in-memory journal is a no-op. And, in fact, this routine
55753
+** is never called in a working implementation. This implementation
55754
+** exists purely as a contingency, in case some malfunction in some other
55755
+** part of SQLite causes Sync to be called by mistake.
5552355756
*/
55524
-static int memjrnlSync(sqlite3_file *NotUsed, int NotUsed2){
55525
- UNUSED_PARAMETER2(NotUsed, NotUsed2);
55526
- return SQLITE_OK;
55527
-}
55757
+static int memjrnlSync(sqlite3_file *NotUsed, int NotUsed2){ /*NO_TEST*/
55758
+ UNUSED_PARAMETER2(NotUsed, NotUsed2); /*NO_TEST*/
55759
+ assert( 0 ); /*NO_TEST*/
55760
+ return SQLITE_OK; /*NO_TEST*/
55761
+} /*NO_TEST*/
5552855762
5552955763
/*
5553055764
** Query the size of the file in bytes.
5553155765
*/
5553255766
static int memjrnlFileSize(sqlite3_file *pJfd, sqlite_int64 *pSize){
@@ -55557,10 +55791,11 @@
5555755791
/*
5555855792
** Open a journal file.
5555955793
*/
5556055794
SQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *pJfd){
5556155795
MemJournal *p = (MemJournal *)pJfd;
55796
+ assert( EIGHT_BYTE_ALIGNMENT(p) );
5556255797
memset(p, 0, sqlite3MemJournalSize());
5556355798
p->pMethod = &MemJournalMethods;
5556455799
}
5556555800
5556655801
/*
@@ -55593,11 +55828,11 @@
5559355828
**
5559455829
*************************************************************************
5559555830
** This file contains routines used for walking the parser tree for
5559655831
** an SQL statement.
5559755832
**
55598
-** $Id: walker.c,v 1.2 2009/02/19 14:39:25 danielk1977 Exp $
55833
+** $Id: walker.c,v 1.4 2009/04/08 13:51:52 drh Exp $
5559955834
*/
5560055835
5560155836
5560255837
/*
5560355838
** Walk an expression tree. Invoke the callback once for each node
@@ -55619,12 +55854,16 @@
5561955854
** and WRC_Continue to continue.
5562055855
*/
5562155856
SQLITE_PRIVATE int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
5562255857
int rc;
5562355858
if( pExpr==0 ) return WRC_Continue;
55859
+ testcase( ExprHasProperty(pExpr, EP_TokenOnly) );
55860
+ testcase( ExprHasProperty(pExpr, EP_SpanToken) );
55861
+ testcase( ExprHasProperty(pExpr, EP_Reduced) );
5562455862
rc = pWalker->xExprCallback(pWalker, pExpr);
55625
- if( rc==WRC_Continue ){
55863
+ if( rc==WRC_Continue
55864
+ && !ExprHasAnyProperty(pExpr,EP_TokenOnly|EP_SpanToken) ){
5562655865
if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
5562755866
if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
5562855867
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
5562955868
if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
5563055869
}else{
@@ -56900,11 +57139,11 @@
5690057139
**
5690157140
*************************************************************************
5690257141
** This file contains routines used for analyzing expressions and
5690357142
** for generating VDBE code that evaluates expressions in SQLite.
5690457143
**
56905
-** $Id: expr.c,v 1.424 2009/03/25 16:51:43 drh Exp $
57144
+** $Id: expr.c,v 1.426 2009/04/08 13:51:51 drh Exp $
5690657145
*/
5690757146
5690857147
/*
5690957148
** Return the 'affinity' of the expression pExpr if any.
5691057149
**
@@ -57516,19 +57755,22 @@
5751657755
** Clear an expression structure without deleting the structure itself.
5751757756
** Substructure is deleted.
5751857757
*/
5751957758
SQLITE_PRIVATE void sqlite3ExprClear(sqlite3 *db, Expr *p){
5752057759
if( p->token.dyn ) sqlite3DbFree(db, (char*)p->token.z);
57521
- if( !ExprHasAnyProperty(p, EP_TokenOnly|EP_SpanOnly) ){
57760
+ if( !ExprHasAnyProperty(p, EP_TokenOnly|EP_SpanToken) ){
5752257761
if( p->span.dyn ) sqlite3DbFree(db, (char*)p->span.z);
5752357762
if( ExprHasProperty(p, EP_Reduced) ){
57763
+ /* Subtrees are part of the same memory allocation when EP_Reduced set */
5752457764
if( p->pLeft ) sqlite3ExprClear(db, p->pLeft);
5752557765
if( p->pRight ) sqlite3ExprClear(db, p->pRight);
5752657766
}else{
57767
+ /* Subtrees are separate allocations when EP_Reduced is clear */
5752757768
sqlite3ExprDelete(db, p->pLeft);
5752857769
sqlite3ExprDelete(db, p->pRight);
5752957770
}
57771
+ /* x.pSelect and x.pList are always separately allocated */
5753057772
if( ExprHasProperty(p, EP_xIsSelect) ){
5753157773
sqlite3SelectDelete(db, p->x.pSelect);
5753257774
}else{
5753357775
sqlite3ExprListDelete(db, p->x.pList);
5753457776
}
@@ -57561,11 +57803,11 @@
5756157803
** passed as the first argument. This is always one of EXPR_FULLSIZE,
5756257804
** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE.
5756357805
*/
5756457806
static int exprStructSize(Expr *p){
5756557807
if( ExprHasProperty(p, EP_TokenOnly) ) return EXPR_TOKENONLYSIZE;
57566
- if( ExprHasProperty(p, EP_SpanOnly) ) return EXPR_SPANONLYSIZE;
57808
+ if( ExprHasProperty(p, EP_SpanToken) ) return EXPR_SPANTOKENSIZE;
5756757809
if( ExprHasProperty(p, EP_Reduced) ) return EXPR_REDUCEDSIZE;
5756857810
return EXPR_FULLSIZE;
5756957811
}
5757057812
5757157813
/*
@@ -57578,12 +57820,12 @@
5757857820
int nSize;
5757957821
if( 0==(flags&EXPRDUP_REDUCE) ){
5758057822
nSize = EXPR_FULLSIZE;
5758157823
}else if( p->pLeft || p->pRight || p->pColl || p->x.pList ){
5758257824
nSize = EXPR_REDUCEDSIZE;
57583
- }else if( flags&(EXPRDUP_SPAN|EXPRDUP_DISTINCTSPAN) ){
57584
- nSize = EXPR_SPANONLYSIZE;
57825
+ }else if( flags&EXPRDUP_SPAN ){
57826
+ nSize = EXPR_SPANTOKENSIZE;
5758557827
}else{
5758657828
nSize = EXPR_TOKENONLYSIZE;
5758757829
}
5758857830
return nSize;
5758957831
}
@@ -57595,12 +57837,12 @@
5759557837
** and the copies of the Expr.token.z and Expr.span.z (if applicable)
5759657838
** string buffers.
5759757839
*/
5759857840
static int dupedExprNodeSize(Expr *p, int flags){
5759957841
int nByte = dupedExprStructSize(p, flags) + (p->token.z ? p->token.n + 1 : 0);
57600
- if( (flags&EXPRDUP_DISTINCTSPAN)
57601
- || (flags&EXPRDUP_SPAN && (p->token.z!=p->span.z || p->token.n!=p->span.n))
57842
+ if( (flags&EXPRDUP_SPAN)!=0
57843
+ && (p->token.z!=p->span.z || p->token.n!=p->span.n)
5760257844
){
5760357845
nByte += p->span.n;
5760457846
}
5760557847
return ROUND8(nByte);
5760657848
}
@@ -57623,11 +57865,11 @@
5762357865
static int dupedExprSize(Expr *p, int flags){
5762457866
int nByte = 0;
5762557867
if( p ){
5762657868
nByte = dupedExprNodeSize(p, flags);
5762757869
if( flags&EXPRDUP_REDUCE ){
57628
- int f = flags&(~(EXPRDUP_SPAN|EXPRDUP_DISTINCTSPAN));
57870
+ int f = flags&(~EXPRDUP_SPAN);
5762957871
nByte += dupedExprSize(p->pLeft, f) + dupedExprSize(p->pRight, f);
5763057872
}
5763157873
}
5763257874
return nByte;
5763357875
}
@@ -57641,12 +57883,11 @@
5764157883
** portion of the buffer copied into by this function.
5764257884
*/
5764357885
static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){
5764457886
Expr *pNew = 0; /* Value to return */
5764557887
if( p ){
57646
- const int isRequireDistinctSpan = (flags&EXPRDUP_DISTINCTSPAN);
57647
- const int isRequireSpan = (flags&(EXPRDUP_SPAN|EXPRDUP_DISTINCTSPAN));
57888
+ const int isRequireSpan = (flags&EXPRDUP_SPAN);
5764857889
const int isReduced = (flags&EXPRDUP_REDUCE);
5764957890
u8 *zAlloc;
5765057891
5765157892
assert( pzBuffer==0 || isReduced );
5765257893
@@ -57674,15 +57915,15 @@
5767457915
memcpy(zAlloc, p, nSize);
5767557916
memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize);
5767657917
}
5767757918
5767857919
/* Set the EP_Reduced and EP_TokenOnly flags appropriately. */
57679
- pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_SpanOnly);
57920
+ pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_SpanToken);
5768057921
switch( nNewSize ){
5768157922
case EXPR_REDUCEDSIZE: pNew->flags |= EP_Reduced; break;
5768257923
case EXPR_TOKENONLYSIZE: pNew->flags |= EP_TokenOnly; break;
57683
- case EXPR_SPANONLYSIZE: pNew->flags |= EP_SpanOnly; break;
57924
+ case EXPR_SPANTOKENSIZE: pNew->flags |= EP_SpanToken; break;
5768457925
}
5768557926
5768657927
/* Copy the p->token string, if any. */
5768757928
if( nToken ){
5768857929
unsigned char *zToken = &zAlloc[nNewSize];
@@ -57693,13 +57934,11 @@
5769357934
}
5769457935
5769557936
if( 0==((p->flags|pNew->flags) & EP_TokenOnly) ){
5769657937
/* Fill in the pNew->span token, if required. */
5769757938
if( isRequireSpan ){
57698
- if( isRequireDistinctSpan
57699
- || p->token.z!=p->span.z || p->token.n!=p->span.n
57700
- ){
57939
+ if( p->token.z!=p->span.z || p->token.n!=p->span.n ){
5770157940
pNew->span.z = &zAlloc[nNewSize+nToken];
5770257941
memcpy((char *)pNew->span.z, p->span.z, p->span.n);
5770357942
pNew->span.dyn = 0;
5770457943
}else{
5770557944
pNew->span.z = pNew->token.z;
@@ -57709,30 +57948,30 @@
5770957948
pNew->span.z = 0;
5771057949
pNew->span.n = 0;
5771157950
}
5771257951
}
5771357952
57714
- if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_SpanOnly)) ){
57953
+ if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_SpanToken)) ){
5771557954
/* Fill in the pNew->x.pSelect or pNew->x.pList member. */
5771657955
if( ExprHasProperty(p, EP_xIsSelect) ){
5771757956
pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, isReduced);
5771857957
}else{
5771957958
pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, isReduced);
5772057959
}
5772157960
}
5772257961
5772357962
/* Fill in pNew->pLeft and pNew->pRight. */
57724
- if( ExprHasAnyProperty(pNew, EP_Reduced|EP_TokenOnly|EP_SpanOnly) ){
57963
+ if( ExprHasAnyProperty(pNew, EP_Reduced|EP_TokenOnly|EP_SpanToken) ){
5772557964
zAlloc += dupedExprNodeSize(p, flags);
5772657965
if( ExprHasProperty(pNew, EP_Reduced) ){
5772757966
pNew->pLeft = exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc);
5772857967
pNew->pRight = exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc);
5772957968
}
5773057969
if( pzBuffer ){
5773157970
*pzBuffer = zAlloc;
5773257971
}
57733
- }else if( !ExprHasAnyProperty(p, EP_TokenOnly|EP_SpanOnly) ){
57972
+ }else if( !ExprHasAnyProperty(p, EP_TokenOnly|EP_SpanToken) ){
5773457973
pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
5773557974
pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
5773657975
}
5773757976
}
5773857977
}
@@ -58232,26 +58471,30 @@
5823258471
** If this is the case, it may be possible to use an existing table
5823358472
** or index instead of generating an epheremal table.
5823458473
*/
5823558474
p = (ExprHasProperty(pX, EP_xIsSelect) ? pX->x.pSelect : 0);
5823658475
if( isCandidateForInOpt(p) ){
58237
- sqlite3 *db = pParse->db;
58238
- Index *pIdx;
58239
- Expr *pExpr = p->pEList->a[0].pExpr;
58240
- int iCol = pExpr->iColumn;
58241
- Vdbe *v = sqlite3GetVdbe(pParse);
58476
+ sqlite3 *db = pParse->db; /* Database connection */
58477
+ Expr *pExpr = p->pEList->a[0].pExpr; /* Expression <column> */
58478
+ int iCol = pExpr->iColumn; /* Index of column <column> */
58479
+ Vdbe *v = sqlite3GetVdbe(pParse); /* Virtual machine being coded */
58480
+ Table *pTab = p->pSrc->a[0].pTab; /* Table <table>. */
58481
+ int iDb; /* Database idx for pTab */
58482
+
58483
+ /* Code an OP_VerifyCookie and OP_TableLock for <table>. */
58484
+ iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
58485
+ sqlite3CodeVerifySchema(pParse, iDb);
58486
+ sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
5824258487
5824358488
/* This function is only called from two places. In both cases the vdbe
5824458489
** has already been allocated. So assume sqlite3GetVdbe() is always
5824558490
** successful here.
5824658491
*/
5824758492
assert(v);
5824858493
if( iCol<0 ){
5824958494
int iMem = ++pParse->nMem;
5825058495
int iAddr;
58251
- Table *pTab = p->pSrc->a[0].pTab;
58252
- int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
5825358496
sqlite3VdbeUsesBtree(v, iDb);
5825458497
5825558498
iAddr = sqlite3VdbeAddOp1(v, OP_If, iMem);
5825658499
sqlite3VdbeAddOp2(v, OP_Integer, 1, iMem);
5825758500
@@ -58258,30 +58501,29 @@
5825858501
sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
5825958502
eType = IN_INDEX_ROWID;
5826058503
5826158504
sqlite3VdbeJumpHere(v, iAddr);
5826258505
}else{
58506
+ Index *pIdx; /* Iterator variable */
58507
+
5826358508
/* The collation sequence used by the comparison. If an index is to
5826458509
** be used in place of a temp-table, it must be ordered according
58265
- ** to this collation sequence.
58266
- */
58510
+ ** to this collation sequence. */
5826758511
CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pExpr);
5826858512
5826958513
/* Check that the affinity that will be used to perform the
5827058514
** comparison is the same as the affinity of the column. If
5827158515
** it is not, it is not possible to use any index.
5827258516
*/
58273
- Table *pTab = p->pSrc->a[0].pTab;
5827458517
char aff = comparisonAffinity(pX);
5827558518
int affinity_ok = (pTab->aCol[iCol].affinity==aff||aff==SQLITE_AFF_NONE);
5827658519
5827758520
for(pIdx=pTab->pIndex; pIdx && eType==0 && affinity_ok; pIdx=pIdx->pNext){
5827858521
if( (pIdx->aiColumn[0]==iCol)
5827958522
&& (pReq==sqlite3FindCollSeq(db, ENC(db), pIdx->azColl[0], -1, 0))
5828058523
&& (!mustBeUnique || (pIdx->nColumn==1 && pIdx->onError!=OE_None))
5828158524
){
58282
- int iDb;
5828358525
int iMem = ++pParse->nMem;
5828458526
int iAddr;
5828558527
char *pKey;
5828658528
5828758529
pKey = (char *)sqlite3IndexKeyinfo(pParse, pIdx);
@@ -59089,35 +59331,38 @@
5908959331
}
5909059332
break;
5909159333
}
5909259334
case TK_CONST_FUNC:
5909359335
case TK_FUNCTION: {
59094
- ExprList *pList = (
59095
- ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_SpanOnly) ? 0 : pExpr->x.pList
59096
- );
59097
- int nExpr = pList ? pList->nExpr : 0;
59098
- FuncDef *pDef;
59099
- int nId;
59100
- const char *zId;
59101
- int constMask = 0;
59102
- int i;
59103
- u8 enc = ENC(db);
59104
- CollSeq *pColl = 0;
59336
+ ExprList *pFarg; /* List of function arguments */
59337
+ int nFarg; /* Number of function arguments */
59338
+ FuncDef *pDef; /* The function definition object */
59339
+ int nId; /* Length of the function name in bytes */
59340
+ const char *zId; /* The function name */
59341
+ int constMask = 0; /* Mask of function arguments that are constant */
59342
+ int i; /* Loop counter */
59343
+ u8 enc = ENC(db); /* The text encoding used by this database */
59344
+ CollSeq *pColl = 0; /* A collating sequence */
5910559345
5910659346
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
5910759347
testcase( op==TK_CONST_FUNC );
5910859348
testcase( op==TK_FUNCTION );
59349
+ if( ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_SpanToken) ){
59350
+ pFarg = 0;
59351
+ }else{
59352
+ pFarg = pExpr->x.pList;
59353
+ }
59354
+ nFarg = pFarg ? pFarg->nExpr : 0;
5910959355
zId = (char*)pExpr->token.z;
5911059356
nId = pExpr->token.n;
59111
- pDef = sqlite3FindFunction(db, zId, nId, nExpr, enc, 0);
59357
+ pDef = sqlite3FindFunction(db, zId, nId, nFarg, enc, 0);
5911259358
assert( pDef!=0 );
59113
- if( pList ){
59114
- nExpr = pList->nExpr;
59115
- r1 = sqlite3GetTempRange(pParse, nExpr);
59116
- sqlite3ExprCodeExprList(pParse, pList, r1, 1);
59359
+ if( pFarg ){
59360
+ r1 = sqlite3GetTempRange(pParse, nFarg);
59361
+ sqlite3ExprCodeExprList(pParse, pFarg, r1, 1);
5911759362
}else{
59118
- nExpr = r1 = 0;
59363
+ r1 = 0;
5911959364
}
5912059365
#ifndef SQLITE_OMIT_VIRTUALTABLE
5912159366
/* Possibly overload the function if the first argument is
5912259367
** a virtual table column.
5912359368
**
@@ -59128,35 +59373,35 @@
5912859373
** control overloading) ends up as the second argument to the
5912959374
** function. The expression "A glob B" is equivalent to
5913059375
** "glob(B,A). We want to use the A in "A glob B" to test
5913159376
** for function overloading. But we use the B term in "glob(B,A)".
5913259377
*/
59133
- if( nExpr>=2 && (pExpr->flags & EP_InfixFunc) ){
59134
- pDef = sqlite3VtabOverloadFunction(db, pDef, nExpr, pList->a[1].pExpr);
59135
- }else if( nExpr>0 ){
59136
- pDef = sqlite3VtabOverloadFunction(db, pDef, nExpr, pList->a[0].pExpr);
59378
+ if( nFarg>=2 && (pExpr->flags & EP_InfixFunc) ){
59379
+ pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[1].pExpr);
59380
+ }else if( nFarg>0 ){
59381
+ pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[0].pExpr);
5913759382
}
5913859383
#endif
59139
- for(i=0; i<nExpr && i<32; i++){
59140
- if( sqlite3ExprIsConstant(pList->a[i].pExpr) ){
59384
+ for(i=0; i<nFarg && i<32; i++){
59385
+ if( sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){
5914159386
constMask |= (1<<i);
5914259387
}
5914359388
if( (pDef->flags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){
59144
- pColl = sqlite3ExprCollSeq(pParse, pList->a[i].pExpr);
59389
+ pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr);
5914559390
}
5914659391
}
5914759392
if( pDef->flags & SQLITE_FUNC_NEEDCOLL ){
5914859393
if( !pColl ) pColl = db->pDfltColl;
5914959394
sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);
5915059395
}
5915159396
sqlite3VdbeAddOp4(v, OP_Function, constMask, r1, target,
5915259397
(char*)pDef, P4_FUNCDEF);
59153
- sqlite3VdbeChangeP5(v, (u8)nExpr);
59154
- if( nExpr ){
59155
- sqlite3ReleaseTempRange(pParse, r1, nExpr);
59398
+ sqlite3VdbeChangeP5(v, (u8)nFarg);
59399
+ if( nFarg ){
59400
+ sqlite3ReleaseTempRange(pParse, r1, nFarg);
5915659401
}
59157
- sqlite3ExprCacheAffinityChange(pParse, r1, nExpr);
59402
+ sqlite3ExprCacheAffinityChange(pParse, r1, nFarg);
5915859403
break;
5915959404
}
5916059405
#ifndef SQLITE_OMIT_SUBQUERY
5916159406
case TK_EXISTS:
5916259407
case TK_SELECT: {
@@ -61275,11 +61520,11 @@
6127561520
** May you share freely, never taking more than you give.
6127661521
**
6127761522
*************************************************************************
6127861523
** This file contains code used to implement the ATTACH and DETACH commands.
6127961524
**
61280
-** $Id: attach.c,v 1.83 2009/02/19 14:39:25 danielk1977 Exp $
61525
+** $Id: attach.c,v 1.84 2009/04/08 13:51:51 drh Exp $
6128161526
*/
6128261527
6128361528
#ifndef SQLITE_OMIT_ATTACH
6128461529
/*
6128561530
** Resolve an expression that was part of an ATTACH or DETACH statement. This
@@ -61751,11 +61996,11 @@
6175161996
SQLITE_PRIVATE int sqlite3FixExpr(
6175261997
DbFixer *pFix, /* Context of the fixation */
6175361998
Expr *pExpr /* The expression to be fixed to one database */
6175461999
){
6175562000
while( pExpr ){
61756
- if( ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_SpanOnly) ) break;
62001
+ if( ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_SpanToken) ) break;
6175762002
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
6175862003
if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1;
6175962004
}else{
6176062005
if( sqlite3FixExprList(pFix, pExpr->x.pList) ) return 1;
6176162006
}
@@ -62063,11 +62308,11 @@
6206362308
** creating ID lists
6206462309
** BEGIN TRANSACTION
6206562310
** COMMIT
6206662311
** ROLLBACK
6206762312
**
62068
-** $Id: build.c,v 1.527 2009/03/31 03:41:57 shane Exp $
62313
+** $Id: build.c,v 1.528 2009/04/08 13:51:51 drh Exp $
6206962314
*/
6207062315
6207162316
/*
6207262317
** This routine is called when a new SQL statement is beginning to
6207362318
** be parsed. Initialize the pParse structure as needed.
@@ -63152,13 +63397,11 @@
6315263397
/* A copy of pExpr is used instead of the original, as pExpr contains
6315363398
** tokens that point to volatile memory. The 'span' of the expression
6315463399
** is required by pragma table_info.
6315563400
*/
6315663401
sqlite3ExprDelete(db, pCol->pDflt);
63157
- pCol->pDflt = sqlite3ExprDup(
63158
- db, pExpr, EXPRDUP_REDUCE|EXPRDUP_DISTINCTSPAN
63159
- );
63402
+ pCol->pDflt = sqlite3ExprDup(db, pExpr, EXPRDUP_REDUCE|EXPRDUP_SPAN);
6316063403
}
6316163404
}
6316263405
sqlite3ExprDelete(db, pExpr);
6316363406
}
6316463407
@@ -66831,11 +67074,11 @@
6683167074
**
6683267075
** There is only one exported symbol in this file - the function
6683367076
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
6683467077
** All other code has file scope.
6683567078
**
66836
-** $Id: func.c,v 1.225 2009/03/27 15:26:03 danielk1977 Exp $
67079
+** $Id: func.c,v 1.231 2009/04/08 23:04:14 drh Exp $
6683767080
*/
6683867081
6683967082
/*
6684067083
** Return the collating function associated with a function.
6684167084
*/
@@ -67077,20 +67320,26 @@
6707767320
#endif
6707867321
6707967322
/*
6708067323
** Allocate nByte bytes of space using sqlite3_malloc(). If the
6708167324
** allocation fails, call sqlite3_result_error_nomem() to notify
67082
-** the database handle that malloc() has failed.
67325
+** the database handle that malloc() has failed and return NULL.
67326
+** If nByte is larger than the maximum string or blob length, then
67327
+** raise an SQLITE_TOOBIG exception and return NULL.
6708367328
*/
6708467329
static void *contextMalloc(sqlite3_context *context, i64 nByte){
6708567330
char *z;
67086
- if( nByte>sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH] ){
67331
+ sqlite3 *db = sqlite3_context_db_handle(context);
67332
+ assert( nByte>0 );
67333
+ testcase( nByte==db->aLimit[SQLITE_LIMIT_LENGTH] );
67334
+ testcase( nByte==db->aLimit[SQLITE_LIMIT_LENGTH]+1 );
67335
+ if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){
6708767336
sqlite3_result_error_toobig(context);
6708867337
z = 0;
6708967338
}else{
6709067339
z = sqlite3Malloc((int)nByte);
67091
- if( !z && nByte>0 ){
67340
+ if( !z ){
6709267341
sqlite3_result_error_nomem(context);
6709367342
}
6709467343
}
6709567344
return z;
6709667345
}
@@ -67167,12 +67416,21 @@
6716767416
sqlite3_value **NotUsed2
6716867417
){
6716967418
sqlite_int64 r;
6717067419
UNUSED_PARAMETER2(NotUsed, NotUsed2);
6717167420
sqlite3_randomness(sizeof(r), &r);
67172
- if( (r<<1)==0 ) r = 0; /* Prevent 0x8000.... as the result so that we */
67173
- /* can always do abs() of the result */
67421
+ if( r<0 ){
67422
+ /* We need to prevent a random number of 0x8000000000000000
67423
+ ** (or -9223372036854775808) since when you do abs() of that
67424
+ ** number of you get the same value back again. To do this
67425
+ ** in a way that is testable, mask the sign bit off of negative
67426
+ ** values, resulting in a positive value. Then take the
67427
+ ** 2s complement of that positive value. The end result can
67428
+ ** therefore be no less than -9223372036854775807.
67429
+ */
67430
+ r = -(r ^ (((sqlite3_int64)1)<<63));
67431
+ }
6717467432
sqlite3_result_int64(context, r);
6717567433
}
6717667434
6717767435
/*
6717867436
** Implementation of randomblob(N). Return a random blob
@@ -67255,11 +67513,11 @@
6725567513
** character is exactly one byte in size. Also, all characters are
6725667514
** able to participate in upper-case-to-lower-case mappings in EBCDIC
6725767515
** whereas only characters less than 0x80 do in ASCII.
6725867516
*/
6725967517
#if defined(SQLITE_EBCDIC)
67260
-# define sqlite3Utf8Read(A,B,C) (*(A++))
67518
+# define sqlite3Utf8Read(A,C) (*(A++))
6726167519
# define GlogUpperToLower(A) A = sqlite3UpperToLower[A]
6726267520
#else
6726367521
# define GlogUpperToLower(A) if( A<0x80 ){ A = sqlite3UpperToLower[A]; }
6726467522
#endif
6726567523
@@ -67312,22 +67570,22 @@
6731267570
u8 matchAll = pInfo->matchAll;
6731367571
u8 matchSet = pInfo->matchSet;
6731467572
u8 noCase = pInfo->noCase;
6731567573
int prevEscape = 0; /* True if the previous character was 'escape' */
6731667574
67317
- while( (c = sqlite3Utf8Read(zPattern,0,&zPattern))!=0 ){
67575
+ while( (c = sqlite3Utf8Read(zPattern,&zPattern))!=0 ){
6731867576
if( !prevEscape && c==matchAll ){
67319
- while( (c=sqlite3Utf8Read(zPattern,0,&zPattern)) == matchAll
67577
+ while( (c=sqlite3Utf8Read(zPattern,&zPattern)) == matchAll
6732067578
|| c == matchOne ){
67321
- if( c==matchOne && sqlite3Utf8Read(zString, 0, &zString)==0 ){
67579
+ if( c==matchOne && sqlite3Utf8Read(zString, &zString)==0 ){
6732267580
return 0;
6732367581
}
6732467582
}
6732567583
if( c==0 ){
6732667584
return 1;
6732767585
}else if( c==esc ){
67328
- c = sqlite3Utf8Read(zPattern, 0, &zPattern);
67586
+ c = sqlite3Utf8Read(zPattern, &zPattern);
6732967587
if( c==0 ){
6733067588
return 0;
6733167589
}
6733267590
}else if( c==matchSet ){
6733367591
assert( esc==0 ); /* This is GLOB, not LIKE */
@@ -67335,67 +67593,67 @@
6733567593
while( *zString && patternCompare(&zPattern[-1],zString,pInfo,esc)==0 ){
6733667594
SQLITE_SKIP_UTF8(zString);
6733767595
}
6733867596
return *zString!=0;
6733967597
}
67340
- while( (c2 = sqlite3Utf8Read(zString,0,&zString))!=0 ){
67598
+ while( (c2 = sqlite3Utf8Read(zString,&zString))!=0 ){
6734167599
if( noCase ){
6734267600
GlogUpperToLower(c2);
6734367601
GlogUpperToLower(c);
6734467602
while( c2 != 0 && c2 != c ){
67345
- c2 = sqlite3Utf8Read(zString, 0, &zString);
67603
+ c2 = sqlite3Utf8Read(zString, &zString);
6734667604
GlogUpperToLower(c2);
6734767605
}
6734867606
}else{
6734967607
while( c2 != 0 && c2 != c ){
67350
- c2 = sqlite3Utf8Read(zString, 0, &zString);
67608
+ c2 = sqlite3Utf8Read(zString, &zString);
6735167609
}
6735267610
}
6735367611
if( c2==0 ) return 0;
6735467612
if( patternCompare(zPattern,zString,pInfo,esc) ) return 1;
6735567613
}
6735667614
return 0;
6735767615
}else if( !prevEscape && c==matchOne ){
67358
- if( sqlite3Utf8Read(zString, 0, &zString)==0 ){
67616
+ if( sqlite3Utf8Read(zString, &zString)==0 ){
6735967617
return 0;
6736067618
}
6736167619
}else if( c==matchSet ){
6736267620
int prior_c = 0;
6736367621
assert( esc==0 ); /* This only occurs for GLOB, not LIKE */
6736467622
seen = 0;
6736567623
invert = 0;
67366
- c = sqlite3Utf8Read(zString, 0, &zString);
67624
+ c = sqlite3Utf8Read(zString, &zString);
6736767625
if( c==0 ) return 0;
67368
- c2 = sqlite3Utf8Read(zPattern, 0, &zPattern);
67626
+ c2 = sqlite3Utf8Read(zPattern, &zPattern);
6736967627
if( c2=='^' ){
6737067628
invert = 1;
67371
- c2 = sqlite3Utf8Read(zPattern, 0, &zPattern);
67629
+ c2 = sqlite3Utf8Read(zPattern, &zPattern);
6737267630
}
6737367631
if( c2==']' ){
6737467632
if( c==']' ) seen = 1;
67375
- c2 = sqlite3Utf8Read(zPattern, 0, &zPattern);
67633
+ c2 = sqlite3Utf8Read(zPattern, &zPattern);
6737667634
}
6737767635
while( c2 && c2!=']' ){
6737867636
if( c2=='-' && zPattern[0]!=']' && zPattern[0]!=0 && prior_c>0 ){
67379
- c2 = sqlite3Utf8Read(zPattern, 0, &zPattern);
67637
+ c2 = sqlite3Utf8Read(zPattern, &zPattern);
6738067638
if( c>=prior_c && c<=c2 ) seen = 1;
6738167639
prior_c = 0;
6738267640
}else{
6738367641
if( c==c2 ){
6738467642
seen = 1;
6738567643
}
6738667644
prior_c = c2;
6738767645
}
67388
- c2 = sqlite3Utf8Read(zPattern, 0, &zPattern);
67646
+ c2 = sqlite3Utf8Read(zPattern, &zPattern);
6738967647
}
6739067648
if( c2==0 || (seen ^ invert)==0 ){
6739167649
return 0;
6739267650
}
6739367651
}else if( esc==c && !prevEscape ){
6739467652
prevEscape = 1;
6739567653
}else{
67396
- c2 = sqlite3Utf8Read(zString, 0, &zString);
67654
+ c2 = sqlite3Utf8Read(zString, &zString);
6739767655
if( noCase ){
6739867656
GlogUpperToLower(c);
6739967657
GlogUpperToLower(c2);
6740067658
}
6740167659
if( c!=c2 ){
@@ -67434,20 +67692,23 @@
6743467692
int argc,
6743567693
sqlite3_value **argv
6743667694
){
6743767695
const unsigned char *zA, *zB;
6743867696
int escape = 0;
67697
+ int nPat;
6743967698
sqlite3 *db = sqlite3_context_db_handle(context);
6744067699
6744167700
zB = sqlite3_value_text(argv[0]);
6744267701
zA = sqlite3_value_text(argv[1]);
6744367702
6744467703
/* Limit the length of the LIKE or GLOB pattern to avoid problems
6744567704
** of deep recursion and N*N behavior in patternCompare().
6744667705
*/
67447
- if( sqlite3_value_bytes(argv[0]) >
67448
- db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] ){
67706
+ nPat = sqlite3_value_bytes(argv[0]);
67707
+ testcase( nPat==db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] );
67708
+ testcase( nPat==db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]+1 );
67709
+ if( nPat > db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] ){
6744967710
sqlite3_result_error(context, "LIKE or GLOB pattern too complex", -1);
6745067711
return;
6745167712
}
6745267713
assert( zB==sqlite3_value_text(argv[0]) ); /* Encoding did not change */
6745367714
@@ -67460,11 +67721,11 @@
6746067721
if( sqlite3Utf8CharLen((char*)zEsc, -1)!=1 ){
6746167722
sqlite3_result_error(context,
6746267723
"ESCAPE expression must be a single character", -1);
6746367724
return;
6746467725
}
67465
- escape = sqlite3Utf8Read(zEsc, 0, &zEsc);
67726
+ escape = sqlite3Utf8Read(zEsc, &zEsc);
6746667727
}
6746767728
if( zA && zB ){
6746867729
struct compareInfo *pInfo = sqlite3_user_data(context);
6746967730
#ifdef SQLITE_TEST
6747067731
sqlite3_like_count++;
@@ -67619,14 +67880,17 @@
6761967880
sqlite3_context *context,
6762067881
int argc,
6762167882
sqlite3_value **argv
6762267883
){
6762367884
i64 n;
67885
+ sqlite3 *db = sqlite3_context_db_handle(context);
6762467886
assert( argc==1 );
6762567887
UNUSED_PARAMETER(argc);
6762667888
n = sqlite3_value_int64(argv[0]);
67627
- if( n>SQLITE_MAX_LENGTH ){
67889
+ testcase( n==db->aLimit[SQLITE_LIMIT_LENGTH] );
67890
+ testcase( n==db->aLimit[SQLITE_LIMIT_LENGTH]+1 );
67891
+ if( n>db->aLimit[SQLITE_LIMIT_LENGTH] ){
6762867892
sqlite3_result_error_toobig(context);
6762967893
}else{
6763067894
sqlite3_result_zeroblob(context, (int)n);
6763167895
}
6763267896
}
@@ -67688,11 +67952,13 @@
6768867952
zOut[j++] = zStr[i];
6768967953
}else{
6769067954
u8 *zOld;
6769167955
sqlite3 *db = sqlite3_context_db_handle(context);
6769267956
nOut += nRep - nPattern;
67693
- if( nOut>=db->aLimit[SQLITE_LIMIT_LENGTH] ){
67957
+ testcase( nOut-1==db->aLimit[SQLITE_LIMIT_LENGTH] );
67958
+ testcase( nOut-2==db->aLimit[SQLITE_LIMIT_LENGTH] );
67959
+ if( nOut-1>db->aLimit[SQLITE_LIMIT_LENGTH] ){
6769467960
sqlite3_result_error_toobig(context);
6769567961
sqlite3DbFree(db, zOut);
6769667962
return;
6769767963
}
6769867964
zOld = zOut;
@@ -67772,11 +68038,11 @@
6777268038
if( flags & 1 ){
6777368039
while( nIn>0 ){
6777468040
int len = 0;
6777568041
for(i=0; i<nChar; i++){
6777668042
len = aLen[i];
67777
- if( memcmp(zIn, azChar[i], len)==0 ) break;
68043
+ if( len<=nIn && memcmp(zIn, azChar[i], len)==0 ) break;
6777868044
}
6777968045
if( i>=nChar ) break;
6778068046
zIn += len;
6778168047
nIn -= len;
6778268048
}
@@ -67966,10 +68232,17 @@
6796668232
CountCtx *p;
6796768233
p = sqlite3_aggregate_context(context, sizeof(*p));
6796868234
if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0])) && p ){
6796968235
p->n++;
6797068236
}
68237
+
68238
+ /* The sqlite3_aggregate_count() function is deprecated. But just to make
68239
+ ** sure it still operates correctly, verify that its count agrees with our
68240
+ ** internal count when using count(*) and when the total count can be
68241
+ ** expressed as a 32-bit integer. */
68242
+ assert( argc==1 || p==0 || p->n>0x7fffffff
68243
+ || p->n==sqlite3_aggregate_count(context) );
6797168244
}
6797268245
static void countFinalize(sqlite3_context *context){
6797368246
CountCtx *p;
6797468247
p = sqlite3_aggregate_context(context, 0);
6797568248
sqlite3_result_int64(context, p ? p->n : 0);
@@ -68014,11 +68287,11 @@
6801468287
}
6801568288
static void minMaxFinalize(sqlite3_context *context){
6801668289
sqlite3_value *pRes;
6801768290
pRes = (sqlite3_value *)sqlite3_aggregate_context(context, 0);
6801868291
if( pRes ){
68019
- if( pRes->flags ){
68292
+ if( ALWAYS(pRes->flags) ){
6802068293
sqlite3_result_value(context, pRes);
6802168294
}
6802268295
sqlite3VdbeMemRelease(pRes);
6802368296
}
6802468297
}
@@ -68099,11 +68372,11 @@
6809968372
*/
6810068373
static void setLikeOptFlag(sqlite3 *db, const char *zName, u8 flagVal){
6810168374
FuncDef *pDef;
6810268375
pDef = sqlite3FindFunction(db, zName, sqlite3Strlen30(zName),
6810368376
2, SQLITE_UTF8, 0);
68104
- if( pDef ){
68377
+ if( ALWAYS(pDef) ){
6810568378
pDef->flags = flagVal;
6810668379
}
6810768380
}
6810868381
6810968382
/*
@@ -68143,11 +68416,11 @@
6814368416
return 0;
6814468417
}
6814568418
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
6814668419
pDef = sqlite3FindFunction(db, (char*)pExpr->token.z, pExpr->token.n, 2,
6814768420
SQLITE_UTF8, 0);
68148
- if( pDef==0 || (pDef->flags & SQLITE_FUNC_LIKE)==0 ){
68421
+ if( NEVER(pDef==0) || (pDef->flags & SQLITE_FUNC_LIKE)==0 ){
6814968422
return 0;
6815068423
}
6815168424
6815268425
/* The memcpy() statement assumes that the wildcard characters are
6815368426
** the first three statements in the compareInfo structure. The
@@ -71141,11 +71414,11 @@
7114171414
** May you share freely, never taking more than you give.
7114271415
**
7114371416
*************************************************************************
7114471417
** This file contains code used to implement the PRAGMA command.
7114571418
**
71146
-** $Id: pragma.c,v 1.204 2009/02/23 16:52:08 drh Exp $
71419
+** $Id: pragma.c,v 1.209 2009/04/07 22:05:43 drh Exp $
7114771420
*/
7114871421
7114971422
/* Ignore this whole file if pragmas are disabled
7115071423
*/
7115171424
#if !defined(SQLITE_OMIT_PRAGMA) && !defined(SQLITE_OMIT_PARSER)
@@ -71273,18 +71546,20 @@
7127371546
#endif /* SQLITE_PAGER_PRAGMAS */
7127471547
7127571548
/*
7127671549
** Generate code to return a single integer value.
7127771550
*/
71278
-static void returnSingleInt(Parse *pParse, const char *zLabel, int value){
71551
+static void returnSingleInt(Parse *pParse, const char *zLabel, i64 value){
7127971552
Vdbe *v = sqlite3GetVdbe(pParse);
7128071553
int mem = ++pParse->nMem;
71281
- sqlite3VdbeAddOp2(v, OP_Integer, value, mem);
71282
- if( pParse->explain==0 ){
71283
- sqlite3VdbeSetNumCols(v, 1);
71284
- sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC);
71554
+ i64 *pI64 = sqlite3DbMallocRaw(pParse->db, sizeof(value));
71555
+ if( pI64 ){
71556
+ memcpy(pI64, &value, sizeof(value));
7128571557
}
71558
+ sqlite3VdbeAddOp4(v, OP_Int64, 0, mem, 0, (char*)pI64, P4_INT64);
71559
+ sqlite3VdbeSetNumCols(v, 1);
71560
+ sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC);
7128671561
sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);
7128771562
}
7128871563
7128971564
#ifndef SQLITE_OMIT_FLAG_PRAGMAS
7129071565
/*
@@ -71498,11 +71773,11 @@
7149871773
}else{
7149971774
/* Malloc may fail when setting the page-size, as there is an internal
7150071775
** buffer that the pager module resizes using sqlite3_realloc().
7150171776
*/
7150271777
db->nextPagesize = atoi(zRight);
71503
- if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1) ){
71778
+ if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1, 0) ){
7150471779
db->mallocFailed = 1;
7150571780
}
7150671781
}
7150771782
}else
7150871783
@@ -71660,18 +71935,15 @@
7166071935
*/
7166171936
if( sqlite3StrICmp(zLeft,"journal_size_limit")==0 ){
7166271937
Pager *pPager = sqlite3BtreePager(pDb->pBt);
7166371938
i64 iLimit = -2;
7166471939
if( zRight ){
71665
- int iLimit32 = atoi(zRight);
71666
- if( iLimit32<-1 ){
71667
- iLimit32 = -1;
71668
- }
71669
- iLimit = iLimit32;
71940
+ sqlite3Atoi64(zRight, &iLimit);
71941
+ if( iLimit<-1 ) iLimit = -1;
7167071942
}
7167171943
iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit);
71672
- returnSingleInt(pParse, "journal_size_limit", (int)iLimit);
71944
+ returnSingleInt(pParse, "journal_size_limit", iLimit);
7167371945
}else
7167471946
7167571947
#endif /* SQLITE_OMIT_PAGER_PRAGMAS */
7167671948
7167771949
/*
@@ -72208,11 +72480,10 @@
7220872480
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
7220972481
sqlite3VdbeAddOp2(v, OP_Integer, pIdx->tnum, 2+cnt);
7221072482
cnt++;
7221172483
}
7221272484
}
72213
- if( cnt==0 ) continue;
7221472485
7221572486
/* Make sure sufficient number of registers have been allocated */
7221672487
if( pParse->nMem < cnt+4 ){
7221772488
pParse->nMem = cnt+4;
7221872489
}
@@ -72281,11 +72552,10 @@
7228172552
{ OP_String8, 0, 2, 0}, /* 6 */
7228272553
{ OP_String8, 0, 3, 0}, /* 7 */
7228372554
{ OP_Concat, 3, 2, 2},
7228472555
{ OP_ResultRow, 2, 1, 0},
7228572556
};
72286
- if( pIdx->tnum==0 ) continue;
7228772557
addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1);
7228872558
sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
7228972559
sqlite3VdbeJumpHere(v, addr);
7229072560
addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx);
7229172561
sqlite3VdbeChangeP1(v, addr+1, j+2);
@@ -72578,11 +72848,11 @@
7257872848
*************************************************************************
7257972849
** This file contains the implementation of the sqlite3_prepare()
7258072850
** interface, and routines that contribute to loading the database schema
7258172851
** from disk.
7258272852
**
72583
-** $Id: prepare.c,v 1.114 2009/03/24 15:08:10 drh Exp $
72853
+** $Id: prepare.c,v 1.116 2009/04/02 18:32:27 drh Exp $
7258472854
*/
7258572855
7258672856
/*
7258772857
** Fill the InitData structure with an error message that indicates
7258872858
** that the database is corrupt.
@@ -73092,15 +73362,12 @@
7309273362
Parse sParse;
7309373363
char *zErrMsg = 0;
7309473364
int rc = SQLITE_OK;
7309573365
int i;
7309673366
73097
- assert( ppStmt );
73098
- *ppStmt = 0;
73099
- if( sqlite3SafetyOn(db) ){
73100
- return SQLITE_MISUSE;
73101
- }
73367
+ if( sqlite3SafetyOn(db) ) return SQLITE_MISUSE;
73368
+ assert( ppStmt && *ppStmt==0 );
7310273369
assert( !db->mallocFailed );
7310373370
assert( sqlite3_mutex_held(db->mutex) );
7310473371
7310573372
/* Check to verify that it is possible to get a read lock on all
7310673373
** database schemas. The inability to get a read lock indicates that
@@ -73235,10 +73502,12 @@
7323573502
int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */
7323673503
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
7323773504
const char **pzTail /* OUT: End of parsed string */
7323873505
){
7323973506
int rc;
73507
+ assert( ppStmt!=0 );
73508
+ *ppStmt = 0;
7324073509
if( !sqlite3SafetyCheckOk(db) ){
7324173510
return SQLITE_MISUSE;
7324273511
}
7324373512
sqlite3_mutex_enter(db->mutex);
7324473513
sqlite3BtreeEnterAll(db);
@@ -73337,10 +73606,12 @@
7333773606
*/
7333873607
char *zSql8;
7333973608
const char *zTail8 = 0;
7334073609
int rc = SQLITE_OK;
7334173610
73611
+ assert( ppStmt );
73612
+ *ppStmt = 0;
7334273613
if( !sqlite3SafetyCheckOk(db) ){
7334373614
return SQLITE_MISUSE;
7334473615
}
7334573616
sqlite3_mutex_enter(db->mutex);
7334673617
zSql8 = sqlite3Utf16to8(db, zSql, nBytes);
@@ -73412,11 +73683,11 @@
7341273683
**
7341373684
*************************************************************************
7341473685
** This file contains C code routines that are called by the parser
7341573686
** to handle SELECT statements in SQLite.
7341673687
**
73417
-** $Id: select.c,v 1.506 2009/03/31 03:41:57 shane Exp $
73688
+** $Id: select.c,v 1.507 2009/04/02 16:59:47 drh Exp $
7341873689
*/
7341973690
7342073691
7342173692
/*
7342273693
** Delete all the content of a Select structure but do not deallocate
@@ -75953,10 +76224,16 @@
7595376224
** ORDER by clause of the parent must be simple references to
7595476225
** columns of the sub-query.
7595576226
**
7595676227
** (19) The subquery does not use LIMIT or the outer query does not
7595776228
** have a WHERE clause.
76229
+**
76230
+** (20) If the sub-query is a compound select, then it must not use
76231
+** an ORDER BY clause. Ticket #3773. We could relax this constraint
76232
+** somewhat by saying that the terms of the ORDER BY clause must
76233
+** appear as unmodified result columns in the outer query. But
76234
+** have other optimizations in mind to deal with that case.
7595876235
**
7595976236
** In this routine, the "p" parameter is a pointer to the outer query.
7596076237
** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query
7596176238
** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates.
7596276239
**
@@ -76064,10 +76341,13 @@
7606476341
** use only the UNION ALL operator. And none of the simple select queries
7606576342
** that make up the compound SELECT are allowed to be aggregate or distinct
7606676343
** queries.
7606776344
*/
7606876345
if( pSub->pPrior ){
76346
+ if( pSub->pOrderBy ){
76347
+ return 0; /* Restriction 20 */
76348
+ }
7606976349
if( isAgg || (p->selFlags & SF_Distinct)!=0 || pSrc->nSrc!=1 ){
7607076350
return 0;
7607176351
}
7607276352
for(pSub1=pSub; pSub1; pSub1=pSub1->pPrior){
7607376353
if( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))!=0
@@ -77706,52 +77986,51 @@
7770677986
** interface routine of sqlite3_exec().
7770777987
**
7770877988
** These routines are in a separate files so that they will not be linked
7770977989
** if they are not used.
7771077990
**
77711
-** $Id: table.c,v 1.39 2009/01/19 20:49:10 drh Exp $
77991
+** $Id: table.c,v 1.40 2009/04/10 14:28:00 drh Exp $
7771277992
*/
7771377993
7771477994
#ifndef SQLITE_OMIT_GET_TABLE
7771577995
7771677996
/*
7771777997
** This structure is used to pass data from sqlite3_get_table() through
7771877998
** to the callback function is uses to build the result.
7771977999
*/
7772078000
typedef struct TabResult {
77721
- char **azResult;
77722
- char *zErrMsg;
77723
- int nResult;
77724
- int nAlloc;
77725
- int nRow;
77726
- int nColumn;
77727
- int nData;
77728
- int rc;
78001
+ char **azResult; /* Accumulated output */
78002
+ char *zErrMsg; /* Error message text, if an error occurs */
78003
+ int nAlloc; /* Slots allocated for azResult[] */
78004
+ int nRow; /* Number of rows in the result */
78005
+ int nColumn; /* Number of columns in the result */
78006
+ int nData; /* Slots used in azResult[]. (nRow+1)*nColumn */
78007
+ int rc; /* Return code from sqlite3_exec() */
7772978008
} TabResult;
7773078009
7773178010
/*
7773278011
** This routine is called once for each row in the result table. Its job
7773378012
** is to fill in the TabResult structure appropriately, allocating new
7773478013
** memory as necessary.
7773578014
*/
7773678015
static int sqlite3_get_table_cb(void *pArg, int nCol, char **argv, char **colv){
77737
- TabResult *p = (TabResult*)pArg;
77738
- int need;
77739
- int i;
77740
- char *z;
78016
+ TabResult *p = (TabResult*)pArg; /* Result accumulator */
78017
+ int need; /* Slots needed in p->azResult[] */
78018
+ int i; /* Loop counter */
78019
+ char *z; /* A single column of result */
7774178020
7774278021
/* Make sure there is enough space in p->azResult to hold everything
7774378022
** we need to remember from this invocation of the callback.
7774478023
*/
7774578024
if( p->nRow==0 && argv!=0 ){
7774678025
need = nCol*2;
7774778026
}else{
7774878027
need = nCol;
7774978028
}
77750
- if( p->nData + need >= p->nAlloc ){
78029
+ if( p->nData + need > p->nAlloc ){
7775178030
char **azNew;
77752
- p->nAlloc = p->nAlloc*2 + need + 1;
78031
+ p->nAlloc = p->nAlloc*2 + need;
7775378032
azNew = sqlite3_realloc( p->azResult, sizeof(char*)*p->nAlloc );
7775478033
if( azNew==0 ) goto malloc_failed;
7775578034
p->azResult = azNew;
7775678035
}
7775778036
@@ -77821,11 +78100,10 @@
7782178100
*pazResult = 0;
7782278101
if( pnColumn ) *pnColumn = 0;
7782378102
if( pnRow ) *pnRow = 0;
7782478103
if( pzErrMsg ) *pzErrMsg = 0;
7782578104
res.zErrMsg = 0;
77826
- res.nResult = 0;
7782778105
res.nRow = 0;
7782878106
res.nColumn = 0;
7782978107
res.nData = 1;
7783078108
res.nAlloc = 20;
7783178109
res.rc = SQLITE_OK;
@@ -77855,17 +78133,16 @@
7785578133
sqlite3_free_table(&res.azResult[1]);
7785678134
return rc;
7785778135
}
7785878136
if( res.nAlloc>res.nData ){
7785978137
char **azNew;
77860
- azNew = sqlite3_realloc( res.azResult, sizeof(char*)*(res.nData+1) );
78138
+ azNew = sqlite3_realloc( res.azResult, sizeof(char*)*res.nData );
7786178139
if( azNew==0 ){
7786278140
sqlite3_free_table(&res.azResult[1]);
7786378141
db->errCode = SQLITE_NOMEM;
7786478142
return SQLITE_NOMEM;
7786578143
}
77866
- res.nAlloc = res.nData+1;
7786778144
res.azResult = azNew;
7786878145
}
7786978146
*pazResult = &res.azResult[1];
7787078147
if( pnColumn ) *pnColumn = res.nColumn;
7787178148
if( pnRow ) *pnRow = res.nRow;
@@ -79468,11 +79745,11 @@
7946879745
** This file contains code used to implement the VACUUM command.
7946979746
**
7947079747
** Most of the code in this file may be omitted by defining the
7947179748
** SQLITE_OMIT_VACUUM macro.
7947279749
**
79473
-** $Id: vacuum.c,v 1.86 2009/02/03 16:51:25 danielk1977 Exp $
79750
+** $Id: vacuum.c,v 1.87 2009/04/02 20:16:59 drh Exp $
7947479751
*/
7947579752
7947679753
#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)
7947779754
/*
7947879755
** Execute zSql on database db. Return an error code.
@@ -79592,12 +79869,12 @@
7959279869
sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
7959379870
if( nKey ) db->nextPagesize = 0;
7959479871
}
7959579872
#endif
7959679873
79597
- if( sqlite3BtreeSetPageSize(pTemp, sqlite3BtreeGetPageSize(pMain), nRes)
79598
- || (!isMemDb && sqlite3BtreeSetPageSize(pTemp, db->nextPagesize, nRes))
79874
+ if( sqlite3BtreeSetPageSize(pTemp, sqlite3BtreeGetPageSize(pMain), nRes, 0)
79875
+ || (!isMemDb && sqlite3BtreeSetPageSize(pTemp, db->nextPagesize, nRes, 0))
7959979876
|| db->mallocFailed
7960079877
){
7960179878
rc = SQLITE_NOMEM;
7960279879
goto end_of_vacuum;
7960379880
}
@@ -79720,11 +79997,11 @@
7972079997
sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp));
7972179998
#endif
7972279999
}
7972380000
7972480001
if( rc==SQLITE_OK ){
79725
- rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes);
80002
+ rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes,1);
7972680003
}
7972780004
7972880005
end_of_vacuum:
7972980006
/* Restore the original value of db->flags */
7973080007
db->flags = saved_flags;
@@ -79765,14 +80042,19 @@
7976580042
** May you share freely, never taking more than you give.
7976680043
**
7976780044
*************************************************************************
7976880045
** This file contains code used to help implement virtual tables.
7976980046
**
79770
-** $Id: vtab.c,v 1.84 2009/03/24 15:08:10 drh Exp $
80047
+** $Id: vtab.c,v 1.85 2009/04/11 16:27:20 drh Exp $
7977180048
*/
7977280049
#ifndef SQLITE_OMIT_VIRTUALTABLE
7977380050
80051
+/*
80052
+** The actual function that does the work of creating a new module.
80053
+** This function implements the sqlite3_create_module() and
80054
+** sqlite3_create_module_v2() interfaces.
80055
+*/
7977480056
static int createModule(
7977580057
sqlite3 *db, /* Database in which module is registered */
7977680058
const char *zName, /* Name assigned to this module */
7977780059
const sqlite3_module *pModule, /* The definition of the module */
7977880060
void *pAux, /* Context pointer for xCreate/xConnect */
@@ -79850,10 +80132,11 @@
7985080132
/*
7985180133
** Unlock a virtual table. When the last lock is removed,
7985280134
** disconnect the virtual table.
7985380135
*/
7985480136
SQLITE_PRIVATE void sqlite3VtabUnlock(sqlite3 *db, sqlite3_vtab *pVtab){
80137
+ assert( pVtab->nRef>0 );
7985580138
pVtab->nRef--;
7985680139
assert(db);
7985780140
assert( sqlite3SafetyCheckOk(db) );
7985880141
if( pVtab->nRef==0 ){
7985980142
if( db->magic==SQLITE_MAGIC_BUSY ){
@@ -80618,20 +80901,20 @@
8061880901
** generating the code that loops through a table looking for applicable
8061980902
** rows. Indices are selected and used to speed the search when doing
8062080903
** so is applicable. Because this module is responsible for selecting
8062180904
** indices, you might also think of this module as the "query optimizer".
8062280905
**
80623
-** $Id: where.c,v 1.379 2009/03/29 00:15:54 drh Exp $
80906
+** $Id: where.c,v 1.382 2009/04/07 13:48:12 drh Exp $
8062480907
*/
8062580908
8062680909
/*
8062780910
** Trace output macros
8062880911
*/
8062980912
#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
8063080913
SQLITE_PRIVATE int sqlite3WhereTrace = 0;
8063180914
#endif
80632
-#if 0
80915
+#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
8063380916
# define WHERETRACE(X) if(sqlite3WhereTrace) sqlite3DebugPrintf X
8063480917
#else
8063580918
# define WHERETRACE(X)
8063680919
#endif
8063780920
@@ -82363,10 +82646,17 @@
8236382646
*/
8236482647
memset(pCost, 0, sizeof(*pCost));
8236582648
if( pProbe==0 &&
8236682649
findTerm(pWC, iCur, -1, 0, WO_EQ|WO_IN|WO_LT|WO_LE|WO_GT|WO_GE,0)==0 &&
8236782650
(pOrderBy==0 || !sortableByRowid(iCur, pOrderBy, pWC->pMaskSet, &rev)) ){
82651
+ if( pParse->db->flags & SQLITE_ReverseOrder ){
82652
+ /* For application testing, randomly reverse the output order for
82653
+ ** SELECT statements that omit the ORDER BY clause. This will help
82654
+ ** to find cases where
82655
+ */
82656
+ pCost->plan.wsFlags |= WHERE_REVERSE;
82657
+ }
8236882658
return;
8236982659
}
8237082660
pCost->rCost = SQLITE_BIG_DBL;
8237182661
8237282662
/* Check for a rowid=EXPR or rowid IN (...) constraints. If there was
@@ -84205,12 +84495,12 @@
8420584495
#endif
8420684496
#define sqlite3ParserARG_SDECL Parse *pParse;
8420784497
#define sqlite3ParserARG_PDECL ,Parse *pParse
8420884498
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
8420984499
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
84210
-#define YYNSTATE 613
84211
-#define YYNRULE 321
84500
+#define YYNSTATE 616
84501
+#define YYNRULE 323
8421284502
#define YYFALLBACK 1
8421384503
#define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
8421484504
#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
8421584505
#define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
8421684506
@@ -84265,161 +84555,160 @@
8426584555
** yy_reduce_ofst[] For each state, the offset into yy_action for
8426684556
** shifting non-terminals after a reduce.
8426784557
** yy_default[] Default action for each state.
8426884558
*/
8426984559
static const YYACTIONTYPE yy_action[] = {
84270
- /* 0 */ 304, 935, 176, 612, 2, 150, 214, 438, 24, 24,
84271
- /* 10 */ 24, 24, 487, 26, 26, 26, 26, 27, 27, 28,
84272
- /* 20 */ 28, 28, 29, 216, 412, 413, 212, 412, 413, 445,
84273
- /* 30 */ 451, 31, 26, 26, 26, 26, 27, 27, 28, 28,
84274
- /* 40 */ 28, 29, 216, 30, 482, 32, 134, 23, 22, 308,
84275
- /* 50 */ 455, 456, 452, 452, 25, 25, 24, 24, 24, 24,
84276
- /* 60 */ 435, 26, 26, 26, 26, 27, 27, 28, 28, 28,
84277
- /* 70 */ 29, 216, 304, 216, 311, 438, 511, 489, 45, 26,
84560
+ /* 0 */ 304, 940, 176, 615, 2, 150, 214, 439, 24, 24,
84561
+ /* 10 */ 24, 24, 488, 26, 26, 26, 26, 27, 27, 28,
84562
+ /* 20 */ 28, 28, 29, 216, 413, 414, 212, 413, 414, 446,
84563
+ /* 30 */ 452, 31, 26, 26, 26, 26, 27, 27, 28, 28,
84564
+ /* 40 */ 28, 29, 216, 30, 483, 32, 134, 23, 22, 308,
84565
+ /* 50 */ 456, 457, 453, 453, 25, 25, 24, 24, 24, 24,
84566
+ /* 60 */ 436, 26, 26, 26, 26, 27, 27, 28, 28, 28,
84567
+ /* 70 */ 29, 216, 304, 216, 311, 439, 512, 490, 45, 26,
8427884568
/* 80 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 216,
84279
- /* 90 */ 412, 413, 415, 416, 156, 415, 416, 360, 363, 364,
84280
- /* 100 */ 311, 445, 451, 385, 513, 21, 186, 494, 365, 27,
84281
- /* 110 */ 27, 28, 28, 28, 29, 216, 412, 413, 414, 23,
84282
- /* 120 */ 22, 308, 455, 456, 452, 452, 25, 25, 24, 24,
84283
- /* 130 */ 24, 24, 554, 26, 26, 26, 26, 27, 27, 28,
84284
- /* 140 */ 28, 28, 29, 216, 304, 228, 503, 135, 467, 218,
84285
- /* 150 */ 438, 145, 132, 256, 358, 261, 359, 153, 415, 416,
84286
- /* 160 */ 553, 528, 331, 30, 265, 32, 134, 552, 592, 593,
84287
- /* 170 */ 230, 228, 489, 445, 451, 57, 505, 328, 132, 256,
84288
- /* 180 */ 358, 261, 359, 153, 415, 416, 434, 78, 407, 404,
84289
- /* 190 */ 265, 23, 22, 308, 455, 456, 452, 452, 25, 25,
84290
- /* 200 */ 24, 24, 24, 24, 476, 26, 26, 26, 26, 27,
84291
- /* 210 */ 27, 28, 28, 28, 29, 216, 304, 572, 438, 546,
84292
- /* 220 */ 477, 127, 547, 596, 30, 331, 32, 134, 345, 214,
84293
- /* 230 */ 428, 63, 331, 355, 414, 478, 241, 341, 414, 342,
84294
- /* 240 */ 328, 387, 193, 595, 594, 445, 451, 328, 299, 434,
84295
- /* 250 */ 85, 469, 545, 200, 190, 555, 434, 78, 309, 462,
84296
- /* 260 */ 463, 571, 471, 23, 22, 308, 455, 456, 452, 452,
84297
- /* 270 */ 25, 25, 24, 24, 24, 24, 435, 26, 26, 26,
84569
+ /* 90 */ 413, 414, 416, 417, 156, 416, 417, 360, 363, 364,
84570
+ /* 100 */ 311, 446, 452, 385, 514, 21, 186, 495, 365, 27,
84571
+ /* 110 */ 27, 28, 28, 28, 29, 216, 413, 414, 415, 23,
84572
+ /* 120 */ 22, 308, 456, 457, 453, 453, 25, 25, 24, 24,
84573
+ /* 130 */ 24, 24, 555, 26, 26, 26, 26, 27, 27, 28,
84574
+ /* 140 */ 28, 28, 29, 216, 304, 228, 504, 135, 468, 218,
84575
+ /* 150 */ 548, 145, 132, 256, 358, 261, 359, 153, 416, 417,
84576
+ /* 160 */ 241, 598, 331, 30, 265, 32, 134, 439, 596, 597,
84577
+ /* 170 */ 230, 228, 490, 446, 452, 57, 506, 328, 132, 256,
84578
+ /* 180 */ 358, 261, 359, 153, 416, 417, 435, 78, 408, 405,
84579
+ /* 190 */ 265, 23, 22, 308, 456, 457, 453, 453, 25, 25,
84580
+ /* 200 */ 24, 24, 24, 24, 342, 26, 26, 26, 26, 27,
84581
+ /* 210 */ 27, 28, 28, 28, 29, 216, 304, 214, 534, 547,
84582
+ /* 220 */ 307, 127, 489, 595, 30, 331, 32, 134, 345, 387,
84583
+ /* 230 */ 429, 63, 331, 355, 415, 439, 507, 331, 415, 535,
84584
+ /* 240 */ 328, 215, 193, 594, 593, 446, 452, 328, 18, 435,
84585
+ /* 250 */ 85, 16, 328, 183, 190, 556, 435, 78, 309, 463,
84586
+ /* 260 */ 464, 435, 85, 23, 22, 308, 456, 457, 453, 453,
84587
+ /* 270 */ 25, 25, 24, 24, 24, 24, 436, 26, 26, 26,
8429884588
/* 280 */ 26, 27, 27, 28, 28, 28, 29, 216, 304, 347,
84299
- /* 290 */ 221, 191, 512, 429, 544, 331, 440, 234, 345, 430,
84300
- /* 300 */ 324, 409, 541, 344, 591, 217, 213, 541, 112, 331,
84301
- /* 310 */ 328, 388, 282, 281, 211, 29, 216, 445, 451, 434,
84302
- /* 320 */ 79, 217, 214, 334, 328, 458, 458, 442, 442, 442,
84303
- /* 330 */ 571, 270, 4, 434, 85, 23, 22, 308, 455, 456,
84304
- /* 340 */ 452, 452, 25, 25, 24, 24, 24, 24, 435, 26,
84589
+ /* 290 */ 221, 313, 595, 191, 378, 331, 472, 234, 345, 381,
84590
+ /* 300 */ 324, 410, 220, 344, 592, 217, 213, 415, 112, 331,
84591
+ /* 310 */ 328, 4, 594, 399, 211, 554, 529, 446, 452, 435,
84592
+ /* 320 */ 79, 217, 553, 515, 328, 334, 513, 459, 459, 469,
84593
+ /* 330 */ 441, 572, 432, 435, 78, 23, 22, 308, 456, 457,
84594
+ /* 340 */ 453, 453, 25, 25, 24, 24, 24, 24, 436, 26,
8430584595
/* 350 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 216,
84306
- /* 360 */ 304, 514, 156, 331, 488, 360, 363, 364, 331, 353,
84307
- /* 370 */ 431, 247, 395, 274, 220, 272, 365, 352, 328, 331,
84308
- /* 380 */ 388, 282, 281, 328, 412, 413, 307, 434, 93, 445,
84309
- /* 390 */ 451, 214, 434, 93, 328, 530, 150, 1, 438, 403,
84310
- /* 400 */ 468, 412, 413, 434, 78, 40, 210, 23, 22, 308,
84311
- /* 410 */ 455, 456, 452, 452, 25, 25, 24, 24, 24, 24,
84312
- /* 420 */ 194, 26, 26, 26, 26, 27, 27, 28, 28, 28,
84313
- /* 430 */ 29, 216, 304, 319, 331, 596, 507, 535, 320, 179,
84314
- /* 440 */ 435, 489, 467, 156, 192, 349, 360, 363, 364, 328,
84315
- /* 450 */ 414, 536, 415, 416, 435, 595, 546, 365, 434, 71,
84316
- /* 460 */ 378, 445, 451, 208, 240, 381, 438, 556, 63, 415,
84317
- /* 470 */ 416, 414, 28, 28, 28, 29, 216, 43, 435, 23,
84318
- /* 480 */ 22, 308, 455, 456, 452, 452, 25, 25, 24, 24,
84319
- /* 490 */ 24, 24, 276, 26, 26, 26, 26, 27, 27, 28,
84320
- /* 500 */ 28, 28, 29, 216, 304, 354, 209, 414, 510, 412,
84321
- /* 510 */ 413, 135, 426, 331, 412, 413, 398, 217, 66, 333,
84322
- /* 520 */ 328, 564, 412, 413, 30, 563, 32, 134, 328, 434,
84323
- /* 530 */ 8, 546, 484, 445, 451, 400, 489, 434, 72, 377,
84324
- /* 540 */ 435, 485, 603, 63, 598, 494, 414, 372, 469, 337,
84325
- /* 550 */ 200, 23, 22, 308, 455, 456, 452, 452, 25, 25,
84596
+ /* 360 */ 304, 443, 443, 443, 156, 468, 218, 360, 363, 364,
84597
+ /* 370 */ 331, 247, 395, 398, 217, 349, 331, 30, 365, 32,
84598
+ /* 380 */ 134, 388, 282, 281, 39, 328, 41, 430, 545, 446,
84599
+ /* 390 */ 452, 328, 214, 531, 435, 93, 542, 601, 1, 404,
84600
+ /* 400 */ 435, 93, 413, 414, 495, 40, 536, 23, 22, 308,
84601
+ /* 410 */ 456, 457, 453, 453, 25, 25, 24, 24, 24, 24,
84602
+ /* 420 */ 573, 26, 26, 26, 26, 27, 27, 28, 28, 28,
84603
+ /* 430 */ 29, 216, 304, 276, 331, 179, 508, 490, 210, 547,
84604
+ /* 440 */ 319, 413, 414, 222, 192, 385, 320, 240, 415, 328,
84605
+ /* 450 */ 557, 63, 413, 414, 415, 616, 408, 405, 435, 71,
84606
+ /* 460 */ 415, 446, 452, 611, 572, 28, 28, 28, 29, 216,
84607
+ /* 470 */ 416, 417, 436, 336, 463, 464, 401, 43, 436, 23,
84608
+ /* 480 */ 22, 308, 456, 457, 453, 453, 25, 25, 24, 24,
84609
+ /* 490 */ 24, 24, 495, 26, 26, 26, 26, 27, 27, 28,
84610
+ /* 500 */ 28, 28, 29, 216, 304, 612, 209, 135, 511, 416,
84611
+ /* 510 */ 417, 431, 233, 64, 388, 282, 281, 439, 66, 542,
84612
+ /* 520 */ 416, 417, 413, 414, 156, 214, 403, 360, 363, 364,
84613
+ /* 530 */ 547, 252, 490, 446, 452, 491, 217, 8, 365, 495,
84614
+ /* 540 */ 436, 606, 63, 537, 299, 415, 492, 470, 546, 200,
84615
+ /* 550 */ 196, 23, 22, 308, 456, 457, 453, 453, 25, 25,
8432684616
/* 560 */ 24, 24, 24, 24, 386, 26, 26, 26, 26, 27,
84327
- /* 570 */ 27, 28, 28, 28, 29, 216, 304, 415, 416, 476,
84328
- /* 580 */ 527, 60, 415, 416, 222, 402, 389, 498, 185, 331,
84329
- /* 590 */ 415, 416, 385, 242, 331, 477, 331, 506, 453, 336,
84330
- /* 600 */ 462, 463, 414, 490, 328, 445, 451, 414, 491, 328,
84331
- /* 610 */ 478, 328, 518, 434, 67, 613, 407, 404, 434, 76,
84332
- /* 620 */ 434, 97, 519, 23, 22, 308, 455, 456, 452, 452,
84617
+ /* 570 */ 27, 28, 28, 28, 29, 216, 304, 477, 254, 354,
84618
+ /* 580 */ 528, 60, 517, 518, 436, 439, 389, 331, 356, 7,
84619
+ /* 590 */ 416, 417, 331, 478, 328, 208, 197, 137, 460, 499,
84620
+ /* 600 */ 447, 448, 328, 435, 9, 446, 452, 328, 479, 485,
84621
+ /* 610 */ 519, 435, 72, 567, 415, 434, 435, 67, 486, 433,
84622
+ /* 620 */ 520, 450, 451, 23, 22, 308, 456, 457, 453, 453,
8433384623
/* 630 */ 25, 25, 24, 24, 24, 24, 331, 26, 26, 26,
8433484624
/* 640 */ 26, 27, 27, 28, 28, 28, 29, 216, 304, 331,
84335
- /* 650 */ 310, 328, 268, 368, 64, 331, 397, 439, 438, 233,
84336
- /* 660 */ 434, 96, 217, 16, 328, 183, 331, 459, 467, 218,
84337
- /* 670 */ 328, 446, 447, 434, 101, 214, 154, 445, 451, 434,
84338
- /* 680 */ 99, 328, 464, 154, 566, 466, 334, 396, 458, 458,
84339
- /* 690 */ 434, 104, 449, 450, 205, 23, 22, 308, 455, 456,
84340
- /* 700 */ 452, 452, 25, 25, 24, 24, 24, 24, 331, 26,
84625
+ /* 650 */ 449, 328, 268, 390, 461, 331, 65, 331, 368, 434,
84626
+ /* 660 */ 435, 76, 310, 433, 328, 150, 427, 439, 473, 331,
84627
+ /* 670 */ 328, 499, 328, 435, 97, 29, 216, 446, 452, 435,
84628
+ /* 680 */ 96, 435, 101, 353, 328, 372, 415, 334, 154, 459,
84629
+ /* 690 */ 459, 352, 569, 435, 99, 23, 22, 308, 456, 457,
84630
+ /* 700 */ 453, 453, 25, 25, 24, 24, 24, 24, 331, 26,
8434184631
/* 710 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 216,
84342
- /* 720 */ 304, 448, 331, 328, 390, 56, 438, 331, 435, 331,
84343
- /* 730 */ 248, 306, 434, 105, 516, 517, 472, 328, 306, 39,
84344
- /* 740 */ 331, 41, 328, 265, 328, 414, 434, 126, 339, 445,
84345
- /* 750 */ 451, 434, 128, 434, 59, 328, 334, 250, 458, 458,
84346
- /* 760 */ 196, 569, 517, 568, 434, 102, 483, 23, 22, 308,
84347
- /* 770 */ 455, 456, 452, 452, 25, 25, 24, 24, 24, 24,
84632
+ /* 720 */ 304, 331, 248, 328, 264, 56, 334, 331, 459, 459,
84633
+ /* 730 */ 861, 333, 435, 104, 376, 439, 328, 415, 331, 415,
84634
+ /* 740 */ 565, 331, 328, 306, 564, 435, 105, 185, 265, 446,
84635
+ /* 750 */ 452, 435, 126, 328, 570, 518, 328, 334, 377, 459,
84636
+ /* 760 */ 459, 314, 435, 128, 194, 435, 59, 23, 22, 308,
84637
+ /* 770 */ 456, 457, 453, 453, 25, 25, 24, 24, 24, 24,
8434884638
/* 780 */ 331, 26, 26, 26, 26, 27, 27, 28, 28, 28,
84349
- /* 790 */ 29, 216, 304, 331, 435, 328, 562, 375, 562, 331,
84350
- /* 800 */ 264, 858, 606, 303, 434, 77, 197, 137, 328, 406,
84351
- /* 810 */ 2, 331, 178, 215, 328, 414, 486, 434, 100, 136,
84352
- /* 820 */ 18, 445, 451, 434, 68, 334, 328, 458, 458, 610,
84353
- /* 830 */ 926, 460, 926, 65, 414, 434, 98, 314, 528, 23,
84354
- /* 840 */ 22, 308, 455, 456, 452, 452, 25, 25, 24, 24,
84639
+ /* 790 */ 29, 216, 304, 331, 136, 328, 242, 477, 436, 331,
84640
+ /* 800 */ 350, 331, 609, 303, 435, 102, 201, 137, 328, 415,
84641
+ /* 810 */ 454, 178, 331, 478, 328, 415, 328, 435, 77, 440,
84642
+ /* 820 */ 249, 446, 452, 435, 100, 435, 68, 328, 479, 465,
84643
+ /* 830 */ 341, 613, 931, 484, 931, 415, 435, 98, 467, 23,
84644
+ /* 840 */ 22, 308, 456, 457, 453, 453, 25, 25, 24, 24,
8435584645
/* 850 */ 24, 24, 331, 26, 26, 26, 26, 27, 27, 28,
84356
- /* 860 */ 28, 28, 29, 216, 304, 331, 350, 328, 264, 155,
84357
- /* 870 */ 264, 331, 607, 331, 201, 137, 434, 129, 433, 574,
84358
- /* 880 */ 328, 414, 432, 414, 331, 414, 328, 498, 328, 434,
84359
- /* 890 */ 130, 498, 539, 445, 451, 434, 131, 434, 69, 328,
84360
- /* 900 */ 362, 334, 414, 458, 458, 229, 414, 315, 434, 80,
84361
- /* 910 */ 259, 23, 33, 308, 455, 456, 452, 452, 25, 25,
84646
+ /* 860 */ 28, 28, 29, 216, 304, 331, 397, 328, 164, 264,
84647
+ /* 870 */ 205, 331, 264, 332, 610, 339, 435, 129, 407, 2,
84648
+ /* 880 */ 328, 322, 175, 331, 415, 214, 328, 415, 415, 435,
84649
+ /* 890 */ 130, 466, 466, 446, 452, 435, 131, 396, 328, 257,
84650
+ /* 900 */ 334, 487, 459, 459, 436, 154, 229, 435, 69, 315,
84651
+ /* 910 */ 258, 23, 33, 308, 456, 457, 453, 453, 25, 25,
8436284652
/* 920 */ 24, 24, 24, 24, 331, 26, 26, 26, 26, 27,
84363
- /* 930 */ 27, 28, 28, 28, 29, 216, 304, 331, 264, 328,
84364
- /* 940 */ 164, 264, 356, 331, 417, 418, 419, 525, 434, 81,
84365
- /* 950 */ 376, 542, 328, 414, 318, 331, 414, 538, 328, 465,
84366
- /* 960 */ 465, 434, 70, 322, 175, 445, 451, 434, 82, 433,
84367
- /* 970 */ 328, 610, 925, 432, 925, 316, 540, 494, 317, 434,
84368
- /* 980 */ 83, 522, 523, 587, 22, 308, 455, 456, 452, 452,
84653
+ /* 930 */ 27, 28, 28, 28, 29, 216, 304, 331, 497, 328,
84654
+ /* 940 */ 151, 264, 412, 331, 264, 470, 337, 200, 435, 80,
84655
+ /* 950 */ 250, 155, 328, 523, 524, 331, 415, 415, 328, 415,
84656
+ /* 960 */ 306, 435, 81, 533, 532, 446, 452, 435, 70, 47,
84657
+ /* 970 */ 328, 613, 930, 259, 930, 418, 419, 420, 316, 435,
84658
+ /* 980 */ 82, 317, 206, 539, 22, 308, 456, 457, 453, 453,
8436984659
/* 990 */ 25, 25, 24, 24, 24, 24, 331, 26, 26, 26,
8437084660
/* 1000 */ 26, 27, 27, 28, 28, 28, 29, 216, 304, 331,
84371
- /* 1010 */ 209, 328, 257, 249, 607, 331, 252, 202, 203, 204,
84372
- /* 1020 */ 434, 84, 290, 258, 328, 532, 531, 331, 414, 394,
84373
- /* 1030 */ 328, 331, 533, 434, 86, 332, 141, 445, 451, 434,
84374
- /* 1040 */ 87, 47, 328, 496, 435, 151, 328, 537, 410, 155,
84375
- /* 1050 */ 414, 434, 88, 534, 494, 434, 73, 308, 455, 456,
84376
- /* 1060 */ 452, 452, 25, 25, 24, 24, 24, 24, 386, 26,
84661
+ /* 1010 */ 209, 328, 529, 540, 610, 331, 436, 563, 375, 563,
84662
+ /* 1020 */ 435, 83, 362, 538, 328, 155, 541, 331, 499, 526,
84663
+ /* 1030 */ 328, 331, 575, 435, 84, 424, 543, 446, 452, 435,
84664
+ /* 1040 */ 86, 290, 328, 415, 436, 267, 328, 155, 394, 141,
84665
+ /* 1050 */ 415, 435, 87, 588, 411, 435, 88, 308, 456, 457,
84666
+ /* 1060 */ 453, 453, 25, 25, 24, 24, 24, 24, 386, 26,
8437784667
/* 1070 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 216,
84378
- /* 1080 */ 35, 338, 286, 3, 331, 411, 331, 327, 413, 423,
84379
- /* 1090 */ 382, 422, 276, 254, 420, 35, 338, 335, 3, 328,
84380
- /* 1100 */ 414, 328, 327, 413, 414, 313, 276, 414, 434, 74,
84381
- /* 1110 */ 434, 89, 335, 331, 421, 340, 424, 331, 425, 331,
84382
- /* 1120 */ 267, 414, 155, 142, 289, 471, 287, 325, 328, 326,
84383
- /* 1130 */ 340, 414, 328, 414, 328, 581, 276, 434, 90, 144,
84384
- /* 1140 */ 471, 434, 91, 434, 92, 38, 37, 15, 331, 277,
84385
- /* 1150 */ 133, 414, 441, 276, 36, 329, 330, 6, 436, 440,
84386
- /* 1160 */ 38, 37, 504, 328, 206, 414, 47, 414, 414, 36,
84387
- /* 1170 */ 329, 330, 434, 75, 440, 198, 367, 214, 155, 583,
84388
- /* 1180 */ 235, 236, 237, 143, 239, 348, 343, 580, 46, 243,
84389
- /* 1190 */ 442, 442, 442, 443, 444, 9, 584, 276, 435, 7,
84390
- /* 1200 */ 172, 414, 294, 331, 288, 442, 442, 442, 443, 444,
84391
- /* 1210 */ 9, 295, 414, 35, 338, 567, 3, 155, 328, 480,
84392
- /* 1220 */ 327, 413, 331, 170, 276, 571, 244, 434, 17, 169,
84393
- /* 1230 */ 335, 19, 171, 245, 414, 412, 413, 328, 331, 414,
84394
- /* 1240 */ 585, 276, 575, 576, 151, 54, 434, 94, 340, 493,
84395
- /* 1250 */ 497, 499, 346, 328, 276, 262, 414, 529, 471, 263,
84396
- /* 1260 */ 246, 20, 434, 95, 414, 414, 414, 231, 548, 414,
84397
- /* 1270 */ 414, 437, 414, 471, 414, 393, 291, 281, 38, 37,
84398
- /* 1280 */ 588, 305, 54, 414, 232, 269, 214, 36, 329, 330,
84399
- /* 1290 */ 219, 271, 440, 188, 189, 273, 275, 292, 42, 280,
84400
- /* 1300 */ 414, 380, 383, 512, 384, 283, 414, 440, 149, 399,
84401
- /* 1310 */ 414, 414, 608, 605, 414, 302, 414, 414, 284, 414,
84402
- /* 1320 */ 414, 285, 579, 442, 442, 442, 443, 444, 9, 48,
84403
- /* 1330 */ 590, 293, 296, 414, 297, 602, 414, 414, 442, 442,
84404
- /* 1340 */ 442, 251, 351, 481, 177, 414, 414, 414, 495, 414,
84405
- /* 1350 */ 414, 501, 253, 255, 609, 502, 357, 312, 521, 515,
84406
- /* 1360 */ 107, 525, 226, 225, 520, 260, 369, 158, 227, 524,
84407
- /* 1370 */ 557, 526, 300, 549, 550, 551, 373, 278, 159, 301,
84408
- /* 1380 */ 543, 371, 160, 51, 207, 559, 560, 161, 140, 379,
84409
- /* 1390 */ 570, 163, 117, 391, 181, 392, 118, 119, 120, 121,
84410
- /* 1400 */ 321, 123, 577, 599, 600, 55, 58, 586, 601, 604,
84411
- /* 1410 */ 62, 323, 408, 103, 224, 111, 174, 238, 427, 199,
84412
- /* 1420 */ 654, 655, 656, 146, 147, 454, 457, 34, 182, 180,
84413
- /* 1430 */ 461, 470, 473, 474, 195, 5, 492, 475, 148, 479,
84414
- /* 1440 */ 44, 106, 10, 11, 138, 508, 509, 500, 223, 49,
84415
- /* 1450 */ 361, 108, 152, 266, 109, 50, 110, 157, 258, 370,
84416
- /* 1460 */ 184, 558, 139, 113, 151, 162, 279, 115, 374, 14,
84417
- /* 1470 */ 573, 116, 165, 52, 12, 366, 166, 53, 578, 167,
84418
- /* 1480 */ 582, 168, 114, 124, 122, 561, 565, 13, 61, 125,
84419
- /* 1490 */ 597, 173, 298, 187, 589, 405, 936, 611, 936, 936,
84420
- /* 1500 */ 401,
84668
+ /* 1080 */ 35, 338, 286, 3, 331, 270, 331, 327, 414, 421,
84669
+ /* 1090 */ 382, 318, 276, 422, 325, 35, 338, 335, 3, 328,
84670
+ /* 1100 */ 423, 328, 327, 414, 142, 144, 276, 415, 435, 73,
84671
+ /* 1110 */ 435, 74, 335, 331, 6, 340, 425, 331, 326, 331,
84672
+ /* 1120 */ 367, 415, 155, 437, 289, 472, 287, 274, 328, 272,
84673
+ /* 1130 */ 340, 415, 328, 47, 328, 277, 276, 435, 89, 348,
84674
+ /* 1140 */ 472, 435, 90, 435, 91, 38, 37, 243, 331, 582,
84675
+ /* 1150 */ 244, 415, 426, 276, 36, 329, 330, 46, 245, 441,
84676
+ /* 1160 */ 38, 37, 505, 328, 202, 203, 204, 415, 415, 36,
84677
+ /* 1170 */ 329, 330, 435, 92, 441, 198, 568, 214, 155, 584,
84678
+ /* 1180 */ 235, 236, 237, 143, 239, 346, 133, 581, 438, 246,
84679
+ /* 1190 */ 443, 443, 443, 444, 445, 10, 585, 276, 20, 42,
84680
+ /* 1200 */ 172, 415, 294, 331, 288, 443, 443, 443, 444, 445,
84681
+ /* 1210 */ 10, 295, 415, 35, 338, 219, 3, 149, 328, 482,
84682
+ /* 1220 */ 327, 414, 331, 170, 276, 572, 48, 435, 75, 169,
84683
+ /* 1230 */ 335, 19, 171, 251, 442, 413, 414, 328, 331, 415,
84684
+ /* 1240 */ 586, 343, 276, 177, 351, 496, 435, 17, 340, 415,
84685
+ /* 1250 */ 481, 253, 255, 328, 276, 502, 415, 415, 472, 331,
84686
+ /* 1260 */ 503, 357, 435, 94, 576, 415, 151, 231, 312, 415,
84687
+ /* 1270 */ 577, 516, 54, 472, 328, 393, 291, 281, 38, 37,
84688
+ /* 1280 */ 494, 305, 521, 435, 95, 232, 214, 36, 329, 330,
84689
+ /* 1290 */ 526, 498, 441, 188, 189, 415, 500, 292, 522, 262,
84690
+ /* 1300 */ 530, 260, 263, 513, 549, 269, 415, 441, 589, 400,
84691
+ /* 1310 */ 54, 415, 525, 527, 415, 415, 271, 415, 273, 415,
84692
+ /* 1320 */ 415, 275, 280, 443, 443, 443, 444, 445, 10, 107,
84693
+ /* 1330 */ 380, 415, 383, 415, 384, 283, 415, 415, 443, 443,
84694
+ /* 1340 */ 443, 284, 285, 580, 300, 415, 591, 415, 293, 415,
84695
+ /* 1350 */ 415, 296, 297, 605, 226, 550, 415, 415, 415, 225,
84696
+ /* 1360 */ 608, 415, 302, 415, 551, 227, 415, 415, 415, 301,
84697
+ /* 1370 */ 544, 552, 369, 158, 373, 558, 159, 278, 371, 160,
84698
+ /* 1380 */ 51, 207, 560, 561, 161, 140, 379, 117, 571, 163,
84699
+ /* 1390 */ 391, 392, 181, 180, 321, 602, 578, 118, 119, 120,
84700
+ /* 1400 */ 121, 123, 55, 587, 58, 603, 604, 607, 62, 174,
84701
+ /* 1410 */ 103, 224, 111, 409, 238, 428, 199, 323, 657, 658,
84702
+ /* 1420 */ 659, 146, 147, 455, 458, 34, 474, 462, 471, 182,
84703
+ /* 1430 */ 195, 148, 475, 476, 480, 5, 12, 493, 44, 11,
84704
+ /* 1440 */ 106, 138, 509, 510, 501, 223, 49, 361, 108, 109,
84705
+ /* 1450 */ 152, 266, 50, 110, 157, 258, 370, 184, 559, 139,
84706
+ /* 1460 */ 151, 113, 279, 162, 115, 374, 15, 574, 116, 165,
84707
+ /* 1470 */ 52, 13, 366, 579, 53, 167, 168, 166, 583, 124,
84708
+ /* 1480 */ 114, 122, 562, 566, 14, 61, 599, 600, 125, 173,
84709
+ /* 1490 */ 298, 590, 187, 406, 941, 614, 941, 402,
8442184710
};
8442284711
static const YYCODETYPE yy_lookahead[] = {
8442384712
/* 0 */ 19, 142, 143, 144, 145, 24, 116, 26, 75, 76,
8442484713
/* 10 */ 77, 78, 25, 80, 81, 82, 83, 84, 85, 86,
8442584714
/* 20 */ 87, 88, 89, 90, 26, 27, 160, 26, 27, 48,
@@ -84433,290 +84722,289 @@
8443384722
/* 100 */ 19, 48, 49, 150, 174, 52, 119, 166, 110, 84,
8443484723
/* 110 */ 85, 86, 87, 88, 89, 90, 26, 27, 165, 66,
8443584724
/* 120 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
8443684725
/* 130 */ 77, 78, 186, 80, 81, 82, 83, 84, 85, 86,
8443784726
/* 140 */ 87, 88, 89, 90, 19, 90, 205, 95, 84, 85,
84438
- /* 150 */ 26, 96, 97, 98, 99, 100, 101, 102, 94, 95,
84439
- /* 160 */ 181, 182, 150, 222, 109, 224, 225, 188, 104, 105,
84727
+ /* 150 */ 186, 96, 97, 98, 99, 100, 101, 102, 94, 95,
84728
+ /* 160 */ 195, 97, 150, 222, 109, 224, 225, 26, 104, 105,
8444084729
/* 170 */ 217, 90, 120, 48, 49, 50, 86, 165, 97, 98,
8444184730
/* 180 */ 99, 100, 101, 102, 94, 95, 174, 175, 1, 2,
8444284731
/* 190 */ 109, 66, 67, 68, 69, 70, 71, 72, 73, 74,
84443
- /* 200 */ 75, 76, 77, 78, 12, 80, 81, 82, 83, 84,
84444
- /* 210 */ 85, 86, 87, 88, 89, 90, 19, 11, 94, 150,
84445
- /* 220 */ 28, 24, 186, 150, 222, 150, 224, 225, 216, 116,
84446
- /* 230 */ 161, 162, 150, 221, 165, 43, 195, 45, 165, 191,
84447
- /* 240 */ 165, 128, 160, 170, 171, 48, 49, 165, 163, 174,
84448
- /* 250 */ 175, 166, 167, 168, 185, 186, 174, 175, 169, 170,
84449
- /* 260 */ 171, 55, 64, 66, 67, 68, 69, 70, 71, 72,
84732
+ /* 200 */ 75, 76, 77, 78, 191, 80, 81, 82, 83, 84,
84733
+ /* 210 */ 85, 86, 87, 88, 89, 90, 19, 116, 35, 150,
84734
+ /* 220 */ 155, 24, 208, 150, 222, 150, 224, 225, 216, 128,
84735
+ /* 230 */ 161, 162, 150, 221, 165, 94, 23, 150, 165, 56,
84736
+ /* 240 */ 165, 197, 160, 170, 171, 48, 49, 165, 204, 174,
84737
+ /* 250 */ 175, 22, 165, 24, 185, 186, 174, 175, 169, 170,
84738
+ /* 260 */ 171, 174, 175, 66, 67, 68, 69, 70, 71, 72,
8445084739
/* 270 */ 73, 74, 75, 76, 77, 78, 194, 80, 81, 82,
8445184740
/* 280 */ 83, 84, 85, 86, 87, 88, 89, 90, 19, 214,
84452
- /* 290 */ 215, 25, 94, 172, 173, 150, 98, 148, 216, 173,
84453
- /* 300 */ 146, 147, 181, 221, 231, 232, 152, 181, 154, 150,
84454
- /* 310 */ 165, 105, 106, 107, 160, 89, 90, 48, 49, 174,
84455
- /* 320 */ 175, 232, 116, 112, 165, 114, 115, 129, 130, 131,
84456
- /* 330 */ 55, 16, 196, 174, 175, 66, 67, 68, 69, 70,
84741
+ /* 290 */ 215, 108, 150, 25, 229, 150, 64, 148, 216, 234,
84742
+ /* 300 */ 146, 147, 215, 221, 231, 232, 152, 165, 154, 150,
84743
+ /* 310 */ 165, 196, 170, 171, 160, 181, 182, 48, 49, 174,
84744
+ /* 320 */ 175, 232, 188, 165, 165, 112, 94, 114, 115, 166,
84745
+ /* 330 */ 98, 55, 174, 174, 175, 66, 67, 68, 69, 70,
8445784746
/* 340 */ 71, 72, 73, 74, 75, 76, 77, 78, 194, 80,
8445884747
/* 350 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
84459
- /* 360 */ 19, 165, 96, 150, 208, 99, 100, 101, 150, 19,
84460
- /* 370 */ 174, 226, 218, 58, 215, 60, 110, 27, 165, 150,
84461
- /* 380 */ 105, 106, 107, 165, 26, 27, 155, 174, 175, 48,
84462
- /* 390 */ 49, 116, 174, 175, 165, 183, 24, 22, 26, 245,
84463
- /* 400 */ 166, 26, 27, 174, 175, 136, 160, 66, 67, 68,
84748
+ /* 360 */ 19, 129, 130, 131, 96, 84, 85, 99, 100, 101,
84749
+ /* 370 */ 150, 226, 218, 231, 232, 216, 150, 222, 110, 224,
84750
+ /* 380 */ 225, 105, 106, 107, 135, 165, 137, 172, 173, 48,
84751
+ /* 390 */ 49, 165, 116, 183, 174, 175, 181, 242, 22, 245,
84752
+ /* 400 */ 174, 175, 26, 27, 166, 136, 183, 66, 67, 68,
8446484753
/* 410 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
84465
- /* 420 */ 160, 80, 81, 82, 83, 84, 85, 86, 87, 88,
84466
- /* 430 */ 89, 90, 19, 220, 150, 150, 23, 183, 220, 23,
84467
- /* 440 */ 194, 25, 84, 96, 160, 216, 99, 100, 101, 165,
84468
- /* 450 */ 165, 183, 94, 95, 194, 170, 150, 110, 174, 175,
84469
- /* 460 */ 229, 48, 49, 236, 158, 234, 94, 161, 162, 94,
84470
- /* 470 */ 95, 165, 86, 87, 88, 89, 90, 136, 194, 66,
84754
+ /* 420 */ 11, 80, 81, 82, 83, 84, 85, 86, 87, 88,
84755
+ /* 430 */ 89, 90, 19, 150, 150, 23, 23, 25, 160, 150,
84756
+ /* 440 */ 220, 26, 27, 205, 160, 150, 220, 158, 165, 165,
84757
+ /* 450 */ 161, 162, 26, 27, 165, 0, 1, 2, 174, 175,
84758
+ /* 460 */ 165, 48, 49, 23, 55, 86, 87, 88, 89, 90,
84759
+ /* 470 */ 94, 95, 194, 169, 170, 171, 193, 136, 194, 66,
8447184760
/* 480 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
84472
- /* 490 */ 77, 78, 150, 80, 81, 82, 83, 84, 85, 86,
84473
- /* 500 */ 87, 88, 89, 90, 19, 150, 160, 165, 23, 26,
84474
- /* 510 */ 27, 95, 153, 150, 26, 27, 231, 232, 22, 19,
84475
- /* 520 */ 165, 29, 26, 27, 222, 33, 224, 225, 165, 174,
84476
- /* 530 */ 175, 150, 31, 48, 49, 193, 120, 174, 175, 47,
84477
- /* 540 */ 194, 40, 161, 162, 242, 166, 165, 237, 166, 167,
84478
- /* 550 */ 168, 66, 67, 68, 69, 70, 71, 72, 73, 74,
84761
+ /* 490 */ 77, 78, 166, 80, 81, 82, 83, 84, 85, 86,
84762
+ /* 500 */ 87, 88, 89, 90, 19, 65, 160, 95, 23, 94,
84763
+ /* 510 */ 95, 173, 217, 22, 105, 106, 107, 26, 22, 181,
84764
+ /* 520 */ 94, 95, 26, 27, 96, 116, 243, 99, 100, 101,
84765
+ /* 530 */ 150, 205, 120, 48, 49, 120, 232, 22, 110, 166,
84766
+ /* 540 */ 194, 161, 162, 183, 163, 165, 120, 166, 167, 168,
84767
+ /* 550 */ 160, 66, 67, 68, 69, 70, 71, 72, 73, 74,
8447984768
/* 560 */ 75, 76, 77, 78, 218, 80, 81, 82, 83, 84,
84480
- /* 570 */ 85, 86, 87, 88, 89, 90, 19, 94, 95, 12,
84481
- /* 580 */ 23, 235, 94, 95, 205, 243, 240, 150, 196, 150,
84482
- /* 590 */ 94, 95, 150, 198, 150, 28, 150, 23, 98, 169,
84483
- /* 600 */ 170, 171, 165, 120, 165, 48, 49, 165, 120, 165,
84484
- /* 610 */ 43, 165, 45, 174, 175, 0, 1, 2, 174, 175,
84485
- /* 620 */ 174, 175, 55, 66, 67, 68, 69, 70, 71, 72,
84769
+ /* 570 */ 85, 86, 87, 88, 89, 90, 19, 12, 205, 150,
84770
+ /* 580 */ 23, 235, 190, 191, 194, 94, 240, 150, 86, 74,
84771
+ /* 590 */ 94, 95, 150, 28, 165, 236, 206, 207, 23, 150,
84772
+ /* 600 */ 48, 49, 165, 174, 175, 48, 49, 165, 43, 31,
84773
+ /* 610 */ 45, 174, 175, 21, 165, 113, 174, 175, 40, 117,
84774
+ /* 620 */ 55, 69, 70, 66, 67, 68, 69, 70, 71, 72,
8448684775
/* 630 */ 73, 74, 75, 76, 77, 78, 150, 80, 81, 82,
8448784776
/* 640 */ 83, 84, 85, 86, 87, 88, 89, 90, 19, 150,
84488
- /* 650 */ 213, 165, 23, 19, 22, 150, 97, 166, 26, 217,
84489
- /* 660 */ 174, 175, 232, 22, 165, 24, 150, 23, 84, 85,
84490
- /* 670 */ 165, 48, 49, 174, 175, 116, 49, 48, 49, 174,
84491
- /* 680 */ 175, 165, 233, 49, 21, 233, 112, 128, 114, 115,
84492
- /* 690 */ 174, 175, 69, 70, 160, 66, 67, 68, 69, 70,
84777
+ /* 650 */ 98, 165, 23, 61, 23, 150, 25, 150, 19, 113,
84778
+ /* 660 */ 174, 175, 213, 117, 165, 24, 153, 26, 23, 150,
84779
+ /* 670 */ 165, 150, 165, 174, 175, 89, 90, 48, 49, 174,
84780
+ /* 680 */ 175, 174, 175, 19, 165, 237, 165, 112, 49, 114,
84781
+ /* 690 */ 115, 27, 100, 174, 175, 66, 67, 68, 69, 70,
8449384782
/* 700 */ 71, 72, 73, 74, 75, 76, 77, 78, 150, 80,
8449484783
/* 710 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
84495
- /* 720 */ 19, 98, 150, 165, 61, 24, 94, 150, 194, 150,
84496
- /* 730 */ 150, 104, 174, 175, 190, 191, 23, 165, 104, 135,
84497
- /* 740 */ 150, 137, 165, 109, 165, 165, 174, 175, 228, 48,
84498
- /* 750 */ 49, 174, 175, 174, 175, 165, 112, 209, 114, 115,
84499
- /* 760 */ 160, 190, 191, 100, 174, 175, 177, 66, 67, 68,
84784
+ /* 720 */ 19, 150, 150, 165, 150, 24, 112, 150, 114, 115,
84785
+ /* 730 */ 138, 19, 174, 175, 213, 94, 165, 165, 150, 165,
84786
+ /* 740 */ 29, 150, 165, 104, 33, 174, 175, 196, 109, 48,
84787
+ /* 750 */ 49, 174, 175, 165, 190, 191, 165, 112, 47, 114,
84788
+ /* 760 */ 115, 187, 174, 175, 160, 174, 175, 66, 67, 68,
8450084789
/* 770 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
8450184790
/* 780 */ 150, 80, 81, 82, 83, 84, 85, 86, 87, 88,
84502
- /* 790 */ 89, 90, 19, 150, 194, 165, 105, 106, 107, 150,
84503
- /* 800 */ 150, 138, 248, 249, 174, 175, 206, 207, 165, 144,
84504
- /* 810 */ 145, 150, 23, 197, 165, 165, 177, 174, 175, 150,
84505
- /* 820 */ 204, 48, 49, 174, 175, 112, 165, 114, 115, 22,
84506
- /* 830 */ 23, 23, 25, 25, 165, 174, 175, 187, 182, 66,
84791
+ /* 790 */ 89, 90, 19, 150, 150, 165, 198, 12, 194, 150,
84792
+ /* 800 */ 150, 150, 248, 249, 174, 175, 206, 207, 165, 165,
84793
+ /* 810 */ 98, 23, 150, 28, 165, 165, 165, 174, 175, 166,
84794
+ /* 820 */ 150, 48, 49, 174, 175, 174, 175, 165, 43, 233,
84795
+ /* 830 */ 45, 22, 23, 177, 25, 165, 174, 175, 233, 66,
8450784796
/* 840 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
8450884797
/* 850 */ 77, 78, 150, 80, 81, 82, 83, 84, 85, 86,
84509
- /* 860 */ 87, 88, 89, 90, 19, 150, 150, 165, 150, 25,
84510
- /* 870 */ 150, 150, 65, 150, 206, 207, 174, 175, 113, 199,
84511
- /* 880 */ 165, 165, 117, 165, 150, 165, 165, 150, 165, 174,
84512
- /* 890 */ 175, 150, 166, 48, 49, 174, 175, 174, 175, 165,
84513
- /* 900 */ 178, 112, 165, 114, 115, 187, 165, 187, 174, 175,
84514
- /* 910 */ 177, 66, 67, 68, 69, 70, 71, 72, 73, 74,
84798
+ /* 860 */ 87, 88, 89, 90, 19, 150, 97, 165, 25, 150,
84799
+ /* 870 */ 160, 150, 150, 150, 65, 228, 174, 175, 144, 145,
84800
+ /* 880 */ 165, 246, 247, 150, 165, 116, 165, 165, 165, 174,
84801
+ /* 890 */ 175, 129, 130, 48, 49, 174, 175, 128, 165, 98,
84802
+ /* 900 */ 112, 177, 114, 115, 194, 49, 187, 174, 175, 187,
84803
+ /* 910 */ 109, 66, 67, 68, 69, 70, 71, 72, 73, 74,
8451584804
/* 920 */ 75, 76, 77, 78, 150, 80, 81, 82, 83, 84,
84516
- /* 930 */ 85, 86, 87, 88, 89, 90, 19, 150, 150, 165,
84517
- /* 940 */ 25, 150, 86, 150, 7, 8, 9, 103, 174, 175,
84518
- /* 950 */ 213, 166, 165, 165, 213, 150, 165, 177, 165, 129,
84519
- /* 960 */ 130, 174, 175, 246, 247, 48, 49, 174, 175, 113,
84520
- /* 970 */ 165, 22, 23, 117, 25, 187, 177, 166, 187, 174,
84521
- /* 980 */ 175, 7, 8, 199, 67, 68, 69, 70, 71, 72,
84805
+ /* 930 */ 85, 86, 87, 88, 89, 90, 19, 150, 23, 165,
84806
+ /* 940 */ 25, 150, 150, 150, 150, 166, 167, 168, 174, 175,
84807
+ /* 950 */ 209, 25, 165, 7, 8, 150, 165, 165, 165, 165,
84808
+ /* 960 */ 104, 174, 175, 97, 98, 48, 49, 174, 175, 126,
84809
+ /* 970 */ 165, 22, 23, 177, 25, 7, 8, 9, 187, 174,
84810
+ /* 980 */ 175, 187, 160, 177, 67, 68, 69, 70, 71, 72,
8452284811
/* 990 */ 73, 74, 75, 76, 77, 78, 150, 80, 81, 82,
8452384812
/* 1000 */ 83, 84, 85, 86, 87, 88, 89, 90, 19, 150,
84524
- /* 1010 */ 160, 165, 98, 150, 65, 150, 205, 105, 106, 107,
84525
- /* 1020 */ 174, 175, 209, 109, 165, 97, 98, 150, 165, 209,
84526
- /* 1030 */ 165, 150, 35, 174, 175, 150, 6, 48, 49, 174,
84527
- /* 1040 */ 175, 126, 165, 23, 194, 25, 165, 23, 149, 25,
84528
- /* 1050 */ 165, 174, 175, 56, 166, 174, 175, 68, 69, 70,
84813
+ /* 1010 */ 160, 165, 182, 166, 65, 150, 194, 105, 106, 107,
84814
+ /* 1020 */ 174, 175, 178, 23, 165, 25, 177, 150, 150, 103,
84815
+ /* 1030 */ 165, 150, 199, 174, 175, 150, 166, 48, 49, 174,
84816
+ /* 1040 */ 175, 209, 165, 165, 194, 23, 165, 25, 209, 6,
84817
+ /* 1050 */ 165, 174, 175, 199, 149, 174, 175, 68, 69, 70,
8452984818
/* 1060 */ 71, 72, 73, 74, 75, 76, 77, 78, 218, 80,
8453084819
/* 1070 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
84531
- /* 1080 */ 19, 20, 16, 22, 150, 150, 150, 26, 27, 150,
84532
- /* 1090 */ 240, 13, 150, 205, 149, 19, 20, 36, 22, 165,
84533
- /* 1100 */ 165, 165, 26, 27, 165, 108, 150, 165, 174, 175,
84534
- /* 1110 */ 174, 175, 36, 150, 149, 54, 150, 150, 150, 150,
84535
- /* 1120 */ 23, 165, 25, 151, 58, 64, 60, 149, 165, 159,
84536
- /* 1130 */ 54, 165, 165, 165, 165, 193, 150, 174, 175, 151,
84537
- /* 1140 */ 64, 174, 175, 174, 175, 84, 85, 22, 150, 193,
84538
- /* 1150 */ 150, 165, 150, 150, 93, 94, 95, 25, 194, 98,
84539
- /* 1160 */ 84, 85, 86, 165, 160, 165, 126, 165, 165, 93,
84820
+ /* 1080 */ 19, 20, 16, 22, 150, 16, 150, 26, 27, 149,
84821
+ /* 1090 */ 240, 213, 150, 149, 149, 19, 20, 36, 22, 165,
84822
+ /* 1100 */ 13, 165, 26, 27, 151, 151, 150, 165, 174, 175,
84823
+ /* 1110 */ 174, 175, 36, 150, 25, 54, 150, 150, 159, 150,
84824
+ /* 1120 */ 23, 165, 25, 194, 58, 64, 60, 58, 165, 60,
84825
+ /* 1130 */ 54, 165, 165, 126, 165, 193, 150, 174, 175, 123,
84826
+ /* 1140 */ 64, 174, 175, 174, 175, 84, 85, 199, 150, 193,
84827
+ /* 1150 */ 200, 165, 150, 150, 93, 94, 95, 124, 201, 98,
84828
+ /* 1160 */ 84, 85, 86, 165, 105, 106, 107, 165, 165, 93,
8454084829
/* 1170 */ 94, 95, 174, 175, 98, 5, 23, 116, 25, 193,
84541
- /* 1180 */ 10, 11, 12, 13, 14, 123, 150, 17, 124, 199,
84542
- /* 1190 */ 129, 130, 131, 132, 133, 134, 193, 150, 194, 74,
84830
+ /* 1180 */ 10, 11, 12, 13, 14, 122, 150, 17, 203, 202,
84831
+ /* 1190 */ 129, 130, 131, 132, 133, 134, 193, 150, 125, 135,
8454384832
/* 1200 */ 30, 165, 32, 150, 138, 129, 130, 131, 132, 133,
84544
- /* 1210 */ 134, 41, 165, 19, 20, 23, 22, 25, 165, 150,
84545
- /* 1220 */ 26, 27, 150, 53, 150, 55, 200, 174, 175, 59,
84546
- /* 1230 */ 36, 22, 62, 201, 165, 26, 27, 165, 150, 165,
84547
- /* 1240 */ 193, 150, 23, 23, 25, 25, 174, 175, 54, 150,
84548
- /* 1250 */ 150, 150, 122, 165, 150, 150, 165, 150, 64, 150,
84549
- /* 1260 */ 202, 125, 174, 175, 165, 165, 165, 193, 150, 165,
84550
- /* 1270 */ 165, 203, 165, 64, 165, 105, 106, 107, 84, 85,
84551
- /* 1280 */ 23, 111, 25, 165, 193, 150, 116, 93, 94, 95,
84552
- /* 1290 */ 227, 150, 98, 84, 85, 150, 150, 193, 135, 150,
84553
- /* 1300 */ 165, 150, 150, 94, 150, 150, 165, 98, 118, 139,
84554
- /* 1310 */ 165, 165, 23, 23, 165, 25, 165, 165, 150, 165,
84555
- /* 1320 */ 165, 150, 150, 129, 130, 131, 132, 133, 134, 104,
84556
- /* 1330 */ 150, 150, 150, 165, 150, 150, 165, 165, 129, 130,
84557
- /* 1340 */ 131, 210, 121, 157, 157, 165, 165, 165, 211, 165,
84558
- /* 1350 */ 165, 211, 210, 210, 65, 211, 104, 46, 184, 176,
84559
- /* 1360 */ 22, 103, 90, 230, 176, 176, 18, 156, 230, 178,
84560
- /* 1370 */ 157, 176, 179, 176, 176, 176, 44, 238, 156, 179,
84561
- /* 1380 */ 184, 157, 156, 135, 157, 157, 239, 156, 66, 157,
84562
- /* 1390 */ 189, 189, 22, 157, 219, 18, 192, 192, 192, 192,
84563
- /* 1400 */ 157, 189, 199, 39, 157, 241, 241, 199, 157, 37,
84564
- /* 1410 */ 244, 250, 1, 164, 180, 180, 247, 15, 23, 22,
84565
- /* 1420 */ 118, 118, 118, 118, 118, 98, 113, 22, 22, 219,
84566
- /* 1430 */ 23, 23, 11, 23, 22, 34, 120, 23, 25, 23,
84567
- /* 1440 */ 25, 22, 25, 34, 118, 23, 23, 27, 50, 22,
84568
- /* 1450 */ 50, 22, 34, 23, 22, 22, 22, 102, 109, 19,
84569
- /* 1460 */ 24, 20, 38, 104, 25, 104, 138, 22, 42, 5,
84570
- /* 1470 */ 1, 108, 127, 74, 22, 50, 119, 74, 1, 16,
84571
- /* 1480 */ 20, 121, 51, 108, 119, 57, 51, 22, 16, 127,
84572
- /* 1490 */ 23, 15, 140, 22, 128, 3, 251, 4, 251, 251,
84573
- /* 1500 */ 63,
84833
+ /* 1210 */ 134, 41, 165, 19, 20, 227, 22, 118, 165, 157,
84834
+ /* 1220 */ 26, 27, 150, 53, 150, 55, 104, 174, 175, 59,
84835
+ /* 1230 */ 36, 22, 62, 210, 150, 26, 27, 165, 150, 165,
84836
+ /* 1240 */ 193, 150, 150, 157, 121, 211, 174, 175, 54, 165,
84837
+ /* 1250 */ 150, 210, 210, 165, 150, 211, 165, 165, 64, 150,
84838
+ /* 1260 */ 211, 104, 174, 175, 23, 165, 25, 193, 46, 165,
84839
+ /* 1270 */ 23, 176, 25, 64, 165, 105, 106, 107, 84, 85,
84840
+ /* 1280 */ 150, 111, 176, 174, 175, 193, 116, 93, 94, 95,
84841
+ /* 1290 */ 103, 150, 98, 84, 85, 165, 150, 193, 184, 150,
84842
+ /* 1300 */ 150, 176, 150, 94, 150, 150, 165, 98, 23, 139,
84843
+ /* 1310 */ 25, 165, 178, 176, 165, 165, 150, 165, 150, 165,
84844
+ /* 1320 */ 165, 150, 150, 129, 130, 131, 132, 133, 134, 22,
84845
+ /* 1330 */ 150, 165, 150, 165, 150, 150, 165, 165, 129, 130,
84846
+ /* 1340 */ 131, 150, 150, 150, 179, 165, 150, 165, 150, 165,
84847
+ /* 1350 */ 165, 150, 150, 150, 90, 176, 165, 165, 165, 230,
84848
+ /* 1360 */ 23, 165, 25, 165, 176, 230, 165, 165, 165, 179,
84849
+ /* 1370 */ 184, 176, 18, 156, 44, 157, 156, 238, 157, 156,
84850
+ /* 1380 */ 135, 157, 157, 239, 156, 66, 157, 22, 189, 189,
84851
+ /* 1390 */ 157, 18, 219, 219, 157, 39, 199, 192, 192, 192,
84852
+ /* 1400 */ 192, 189, 241, 199, 241, 157, 157, 37, 244, 247,
84853
+ /* 1410 */ 164, 180, 180, 1, 15, 23, 22, 250, 118, 118,
84854
+ /* 1420 */ 118, 118, 118, 98, 113, 22, 11, 23, 23, 22,
84855
+ /* 1430 */ 22, 25, 23, 23, 23, 34, 34, 120, 25, 25,
84856
+ /* 1440 */ 22, 118, 23, 23, 27, 50, 22, 50, 22, 22,
84857
+ /* 1450 */ 34, 23, 22, 22, 102, 109, 19, 24, 20, 38,
84858
+ /* 1460 */ 25, 104, 138, 104, 22, 42, 5, 1, 108, 127,
84859
+ /* 1470 */ 74, 22, 50, 1, 74, 16, 121, 119, 20, 108,
84860
+ /* 1480 */ 51, 119, 57, 51, 22, 16, 23, 23, 127, 15,
84861
+ /* 1490 */ 140, 128, 22, 3, 251, 4, 251, 63,
8457484862
};
8457584863
#define YY_SHIFT_USE_DFLT (-111)
84576
-#define YY_SHIFT_MAX 405
84864
+#define YY_SHIFT_MAX 406
8457784865
static const short yy_shift_ofst[] = {
84578
- /* 0 */ 187, 1061, 1170, 1061, 1194, 1194, -2, 64, -19, 1194,
84579
- /* 10 */ 1194, 1194, 1194, 1194, 275, 358, 1, 125, 1076, 1194,
84866
+ /* 0 */ 187, 1061, 1170, 1061, 1194, 1194, -2, 64, 64, -19,
84867
+ /* 10 */ 1194, 1194, 1194, 1194, 1194, 276, 1, 125, 1076, 1194,
8458084868
/* 20 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194,
8458184869
/* 30 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194,
8458284870
/* 40 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194,
8458384871
/* 50 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, -48,
84584
- /* 60 */ 206, 1, 1, 124, 584, 584, -110, 53, 197, 269,
84872
+ /* 60 */ 409, 1, 1, 141, 281, 281, -110, 53, 197, 269,
8458584873
/* 70 */ 341, 413, 485, 557, 629, 701, 773, 845, 773, 773,
8458684874
/* 80 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773,
8458784875
/* 90 */ 773, 773, 773, 773, 773, 773, 917, 989, 989, -67,
84588
- /* 100 */ -67, -1, -1, 55, 25, 386, 1, 1, 1, 1,
84589
- /* 110 */ 1, 634, 663, 1, 1, 1, 1, 1, 1, 1,
84590
- /* 120 */ 1, 1, 1, 1, 1, 1, 226, 124, -17, -111,
84591
- /* 130 */ -111, -111, 1209, 81, 375, 483, 488, 496, 90, 567,
84592
- /* 140 */ 567, 1, 1, 1, 1, 1, 1, 1, 1, 1,
84876
+ /* 100 */ -67, -1, -1, 55, 25, 379, 1, 1, 1, 1,
84877
+ /* 110 */ 1, 639, 592, 1, 1, 1, 1, 1, 1, 1,
84878
+ /* 120 */ 1, 1, 1, 1, 1, 1, 586, 141, -17, -111,
84879
+ /* 130 */ -111, -111, 1209, 81, 376, 415, 426, 496, 90, 565,
84880
+ /* 140 */ 565, 1, 1, 1, 1, 1, 1, 1, 1, 1,
8459384881
/* 150 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
8459484882
/* 160 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
84595
- /* 170 */ 1, 1, 1, 1, 807, 949, 615, 372, 372, 372,
84596
- /* 180 */ 559, 113, -110, -110, -110, -111, -111, -111, 198, 198,
84597
- /* 190 */ 266, 347, 574, 644, 713, 192, 789, 416, 937, 856,
84598
- /* 200 */ 632, 52, 997, 997, 997, 211, 211, 492, 691, 211,
84599
- /* 210 */ 211, 211, 211, 641, 765, -13, 124, 830, 830, 604,
84600
- /* 220 */ 501, 501, 350, 501, 627, 501, 124, 501, 124, 844,
84601
- /* 230 */ 915, 350, 350, 915, 1030, 1030, 1030, 1030, 1078, 1078,
84602
- /* 240 */ 1132, -110, 1040, 1062, 1064, 1130, 1136, 1163, 1190, 1190,
84603
- /* 250 */ 1225, 1221, 1225, 1221, 1225, 1221, 1252, 1252, 1311, 1252,
84604
- /* 260 */ 1258, 1252, 1338, 1272, 1272, 1311, 1252, 1252, 1252, 1338,
84605
- /* 270 */ 1348, 1190, 1348, 1190, 1348, 1190, 1190, 1332, 1248, 1348,
84606
- /* 280 */ 1190, 1322, 1322, 1370, 1040, 1190, 1377, 1377, 1377, 1377,
84607
- /* 290 */ 1040, 1322, 1370, 1190, 1364, 1364, 1190, 1190, 1372, -111,
84608
- /* 300 */ -111, -111, -111, -111, 623, 1066, 912, 315, 500, 808,
84609
- /* 310 */ 1020, 914, 974, 928, 1024, 1097, 1153, 1192, 1219, 1220,
84610
- /* 320 */ 1257, 1125, 1290, 1289, 1411, 1402, 1395, 1397, 1302, 1303,
84611
- /* 330 */ 1304, 1305, 1306, 1327, 1313, 1405, 1407, 1408, 1406, 1421,
84612
- /* 340 */ 1412, 1410, 1413, 1414, 1416, 1415, 1401, 1417, 1409, 1415,
84613
- /* 350 */ 1316, 1419, 1418, 1420, 1326, 1422, 1423, 1424, 1398, 1427,
84614
- /* 360 */ 1400, 1429, 1430, 1432, 1433, 1425, 1434, 1355, 1349, 1440,
84615
- /* 370 */ 1441, 1436, 1359, 1426, 1428, 1431, 1439, 1435, 1328, 1361,
84616
- /* 380 */ 1445, 1464, 1469, 1363, 1399, 1403, 1345, 1452, 1357, 1477,
84617
- /* 390 */ 1463, 1360, 1460, 1365, 1375, 1362, 1465, 1366, 1467, 1472,
84618
- /* 400 */ 1437, 1476, 1352, 1471, 1492, 1493,
84883
+ /* 170 */ 1, 1, 1, 1, 809, 949, 455, 641, 641, 641,
84884
+ /* 180 */ 769, 101, -110, -110, -110, -111, -111, -111, 232, 232,
84885
+ /* 190 */ 268, 428, 213, 575, 645, 785, 788, 412, 968, 502,
84886
+ /* 200 */ 491, 52, 183, 183, 183, 614, 614, 711, 912, 614,
84887
+ /* 210 */ 614, 614, 614, 229, 546, -13, 141, 762, 762, 249,
84888
+ /* 220 */ 578, 578, 664, 578, 856, 578, 141, 578, 141, 926,
84889
+ /* 230 */ 843, 664, 664, 843, 1043, 1043, 1043, 1043, 1087, 1087,
84890
+ /* 240 */ 1089, -110, 1007, 1016, 1033, 1063, 1073, 1064, 1099, 1099,
84891
+ /* 250 */ 1122, 1123, 1122, 1123, 1122, 1123, 1157, 1157, 1222, 1157,
84892
+ /* 260 */ 1187, 1157, 1307, 1264, 1264, 1222, 1157, 1157, 1157, 1307,
84893
+ /* 270 */ 1354, 1099, 1354, 1099, 1354, 1099, 1099, 1330, 1245, 1354,
84894
+ /* 280 */ 1099, 1319, 1319, 1365, 1007, 1099, 1373, 1373, 1373, 1373,
84895
+ /* 290 */ 1007, 1319, 1365, 1099, 1356, 1356, 1099, 1099, 1370, -111,
84896
+ /* 300 */ -111, -111, -111, -111, 552, 1066, 1059, 1069, 712, 631,
84897
+ /* 310 */ 915, 801, 946, 866, 1000, 1022, 1097, 1153, 1241, 1247,
84898
+ /* 320 */ 1285, 515, 1337, 440, 1412, 1399, 1392, 1394, 1300, 1301,
84899
+ /* 330 */ 1302, 1303, 1304, 1325, 1311, 1403, 1404, 1405, 1407, 1415,
84900
+ /* 340 */ 1408, 1409, 1406, 1410, 1411, 1413, 1401, 1414, 1402, 1413,
84901
+ /* 350 */ 1317, 1418, 1416, 1417, 1323, 1419, 1420, 1421, 1395, 1424,
84902
+ /* 360 */ 1397, 1426, 1428, 1427, 1430, 1422, 1431, 1352, 1346, 1437,
84903
+ /* 370 */ 1438, 1433, 1357, 1423, 1425, 1429, 1435, 1432, 1324, 1359,
84904
+ /* 380 */ 1442, 1461, 1466, 1360, 1396, 1400, 1342, 1449, 1358, 1472,
84905
+ /* 390 */ 1459, 1355, 1458, 1362, 1371, 1361, 1462, 1363, 1463, 1464,
84906
+ /* 400 */ 1469, 1434, 1474, 1350, 1470, 1490, 1491,
8461984907
};
8462084908
#define YY_REDUCE_USE_DFLT (-180)
8462184909
#define YY_REDUCE_MAX 303
8462284910
static const short yy_reduce_ofst[] = {
84623
- /* 0 */ -141, 82, 154, 284, 12, 75, 69, 73, -59, 145,
84624
- /* 10 */ 159, 229, 213, 218, 346, 285, 306, 302, 355, 363,
84625
- /* 20 */ 439, 444, 446, 486, 499, 505, 516, 558, 572, 577,
84626
- /* 30 */ 579, 590, 630, 643, 649, 661, 702, 715, 721, 723,
84627
- /* 40 */ 734, 774, 787, 793, 805, 846, 859, 865, 877, 881,
84628
- /* 50 */ 934, 936, 963, 967, 969, 998, 1053, 1072, 1088, -179,
84629
- /* 60 */ 850, 342, 381, 85, 89, 430, 600, 2, 2, 2,
84911
+ /* 0 */ -141, 82, 154, 284, 12, 75, 69, 73, 142, -59,
84912
+ /* 10 */ 145, 87, 159, 220, 226, 346, 289, 155, 429, 437,
84913
+ /* 20 */ 442, 486, 499, 505, 507, 519, 558, 571, 577, 588,
84914
+ /* 30 */ 591, 630, 643, 649, 651, 662, 702, 715, 721, 733,
84915
+ /* 40 */ 774, 787, 793, 805, 846, 859, 865, 877, 881, 934,
84916
+ /* 50 */ 936, 963, 967, 969, 998, 1053, 1072, 1088, 1109, -179,
84917
+ /* 60 */ 850, 283, 380, 381, 89, 304, 390, 2, 2, 2,
8463084918
/* 70 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
8463184919
/* 80 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
8463284920
/* 90 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
84633
- /* 100 */ 2, 2, 2, 121, 2, 2, 437, 650, 718, 720,
84634
- /* 110 */ 788, -21, 231, 956, 737, 791, -47, 741, 942, 986,
84635
- /* 120 */ 1003, 1047, 1074, 1091, 442, 1104, 2, 382, 2, 2,
84636
- /* 130 */ 2, 2, 196, 126, 580, 669, 716, 863, 885, 544,
84637
- /* 140 */ 571, 935, 939, 966, 968, 1000, 885, 1002, 1036, 1069,
84638
- /* 150 */ 1099, 1100, 1101, 1105, 1107, 1109, 1118, 1135, 1141, 1145,
84639
- /* 160 */ 1146, 1149, 1151, 1152, 1154, 1155, 1168, 1171, 1172, 1180,
84640
- /* 170 */ 1181, 1182, 1184, 1185, 554, 554, 665, 379, 811, 888,
84641
- /* 180 */ -134, 246, 260, 534, 1004, 616, 668, 717, -98, -70,
84642
- /* 190 */ -54, 36, 41, 41, 41, 48, 41, 156, 149, 136,
84643
- /* 200 */ 234, 156, 212, 254, 268, 41, 41, 227, 310, 41,
84644
- /* 210 */ 41, 41, 41, 359, 392, 395, 491, 449, 452, 520,
84645
- /* 220 */ 589, 639, 548, 733, 656, 780, 726, 799, 785, 722,
84646
- /* 230 */ 680, 813, 820, 784, 899, 945, 965, 978, 972, 988,
84647
- /* 240 */ 970, 964, 990, 1026, 1032, 1058, 1068, 1063, 1186, 1187,
84648
- /* 250 */ 1131, 1137, 1142, 1140, 1143, 1144, 1183, 1188, 1174, 1189,
84649
- /* 260 */ 1191, 1195, 1193, 1133, 1138, 1196, 1197, 1198, 1199, 1200,
84650
- /* 270 */ 1211, 1213, 1222, 1224, 1226, 1227, 1228, 1139, 1147, 1231,
84651
- /* 280 */ 1232, 1201, 1202, 1175, 1203, 1236, 1204, 1205, 1206, 1207,
84652
- /* 290 */ 1208, 1212, 1210, 1243, 1164, 1165, 1247, 1251, 1166, 1249,
84653
- /* 300 */ 1234, 1235, 1169, 1161,
84921
+ /* 100 */ 2, 2, 2, 215, 2, 2, 449, 574, 719, 722,
84922
+ /* 110 */ 791, 134, 65, 942, 521, 794, -47, 878, 956, 986,
84923
+ /* 120 */ 1003, 1047, 1074, 1092, 295, 1104, 2, 779, 2, 2,
84924
+ /* 130 */ 2, 2, 158, 338, 572, 644, 650, 670, 723, 392,
84925
+ /* 140 */ 564, 792, 885, 966, 1002, 1036, 723, 1084, 1091, 1100,
84926
+ /* 150 */ 1130, 1141, 1146, 1149, 1150, 1152, 1154, 1155, 1166, 1168,
84927
+ /* 160 */ 1171, 1172, 1180, 1182, 1184, 1185, 1191, 1192, 1193, 1196,
84928
+ /* 170 */ 1198, 1201, 1202, 1203, 554, 554, 734, 238, 326, 373,
84929
+ /* 180 */ -134, 278, 604, 710, 822, 44, 600, 635, -98, -70,
84930
+ /* 190 */ -54, -36, -35, -35, -35, 13, -35, 14, 149, 115,
84931
+ /* 200 */ 163, 14, 210, 223, 360, -35, -35, 359, 448, -35,
84932
+ /* 210 */ -35, -35, -35, 513, 551, 598, 653, 596, 605, 647,
84933
+ /* 220 */ 656, 724, 741, 796, 830, 806, 847, 849, 870, 844,
84934
+ /* 230 */ 833, 832, 839, 854, 905, 940, 944, 945, 953, 954,
84935
+ /* 240 */ 959, 929, 948, 950, 957, 987, 985, 988, 1062, 1086,
84936
+ /* 250 */ 1023, 1034, 1041, 1044, 1042, 1049, 1095, 1106, 1114, 1125,
84937
+ /* 260 */ 1134, 1137, 1165, 1129, 1135, 1186, 1179, 1188, 1195, 1190,
84938
+ /* 270 */ 1217, 1218, 1220, 1221, 1223, 1224, 1225, 1139, 1144, 1228,
84939
+ /* 280 */ 1229, 1199, 1200, 1173, 1197, 1233, 1205, 1206, 1207, 1208,
84940
+ /* 290 */ 1204, 1212, 1174, 1237, 1161, 1163, 1248, 1249, 1164, 1246,
84941
+ /* 300 */ 1231, 1232, 1162, 1167,
8465484942
};
8465584943
static const YYACTIONTYPE yy_default[] = {
84656
- /* 0 */ 618, 853, 934, 934, 853, 934, 934, 880, 741, 851,
84657
- /* 10 */ 934, 934, 934, 934, 934, 880, 934, 909, 934, 934,
84658
- /* 20 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84659
- /* 30 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84660
- /* 40 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84661
- /* 50 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 825,
84662
- /* 60 */ 934, 934, 934, 657, 880, 880, 745, 776, 934, 934,
84663
- /* 70 */ 934, 934, 934, 934, 934, 934, 777, 934, 855, 850,
84664
- /* 80 */ 846, 848, 847, 854, 778, 767, 774, 781, 756, 893,
84665
- /* 90 */ 783, 784, 790, 791, 910, 908, 813, 812, 831, 815,
84666
- /* 100 */ 837, 814, 824, 649, 816, 817, 934, 934, 934, 934,
84667
- /* 110 */ 934, 710, 644, 934, 934, 934, 934, 934, 934, 934,
84668
- /* 120 */ 934, 934, 934, 934, 934, 934, 818, 934, 819, 832,
84669
- /* 130 */ 833, 834, 934, 934, 934, 934, 934, 934, 934, 934,
84670
- /* 140 */ 934, 624, 934, 934, 934, 934, 934, 934, 934, 934,
84671
- /* 150 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84672
- /* 160 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 866,
84673
- /* 170 */ 934, 913, 915, 934, 934, 934, 618, 741, 741, 741,
84674
- /* 180 */ 934, 934, 934, 934, 934, 735, 745, 927, 934, 934,
84675
- /* 190 */ 701, 934, 934, 934, 934, 934, 934, 934, 626, 733,
84676
- /* 200 */ 659, 743, 934, 934, 934, 646, 722, 886, 934, 900,
84677
- /* 210 */ 898, 724, 786, 934, 733, 742, 934, 934, 934, 849,
84678
- /* 220 */ 770, 770, 758, 770, 680, 770, 934, 770, 934, 683,
84679
- /* 230 */ 780, 758, 758, 780, 623, 623, 623, 623, 634, 634,
84680
- /* 240 */ 700, 934, 780, 771, 773, 763, 775, 934, 749, 749,
84681
- /* 250 */ 757, 762, 757, 762, 757, 762, 712, 712, 697, 712,
84682
- /* 260 */ 683, 712, 859, 863, 863, 697, 712, 712, 712, 859,
84683
- /* 270 */ 641, 749, 641, 749, 641, 749, 749, 890, 892, 641,
84684
- /* 280 */ 749, 714, 714, 792, 780, 749, 721, 721, 721, 721,
84685
- /* 290 */ 780, 714, 792, 749, 912, 912, 749, 749, 920, 667,
84686
- /* 300 */ 685, 685, 927, 932, 934, 934, 934, 934, 934, 934,
84687
- /* 310 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84688
- /* 320 */ 934, 873, 934, 934, 934, 632, 934, 651, 799, 804,
84689
- /* 330 */ 800, 934, 801, 934, 727, 934, 934, 934, 934, 934,
84690
- /* 340 */ 934, 934, 934, 934, 934, 852, 934, 764, 934, 772,
84691
- /* 350 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84692
- /* 360 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84693
- /* 370 */ 934, 934, 934, 934, 934, 888, 889, 934, 934, 934,
84694
- /* 380 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84695
- /* 390 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84696
- /* 400 */ 919, 934, 934, 922, 619, 934, 614, 616, 617, 621,
84697
- /* 410 */ 622, 625, 651, 652, 654, 655, 656, 627, 628, 629,
84698
- /* 420 */ 630, 631, 633, 637, 635, 636, 638, 645, 647, 666,
84699
- /* 430 */ 668, 670, 731, 732, 796, 725, 726, 730, 653, 807,
84700
- /* 440 */ 798, 802, 803, 805, 806, 820, 821, 823, 829, 836,
84701
- /* 450 */ 839, 822, 827, 828, 830, 835, 838, 728, 729, 842,
84702
- /* 460 */ 660, 661, 664, 665, 876, 878, 877, 879, 663, 662,
84703
- /* 470 */ 808, 811, 844, 845, 901, 902, 903, 904, 905, 840,
84704
- /* 480 */ 750, 843, 826, 765, 768, 769, 766, 734, 744, 752,
84705
- /* 490 */ 753, 754, 755, 739, 740, 746, 761, 794, 795, 759,
84706
- /* 500 */ 760, 747, 748, 736, 737, 738, 841, 797, 809, 810,
84707
- /* 510 */ 671, 672, 804, 673, 674, 675, 713, 716, 717, 718,
84708
- /* 520 */ 676, 695, 698, 699, 677, 684, 678, 679, 686, 687,
84709
- /* 530 */ 688, 691, 692, 693, 694, 689, 690, 860, 861, 864,
84710
- /* 540 */ 862, 681, 682, 696, 669, 658, 650, 702, 705, 706,
84711
- /* 550 */ 707, 708, 709, 711, 703, 704, 648, 639, 642, 751,
84712
- /* 560 */ 882, 891, 887, 883, 884, 885, 643, 856, 857, 715,
84713
- /* 570 */ 788, 789, 881, 894, 896, 793, 897, 899, 895, 924,
84714
- /* 580 */ 640, 719, 720, 723, 865, 906, 779, 782, 785, 787,
84715
- /* 590 */ 867, 868, 869, 870, 871, 874, 875, 872, 907, 911,
84716
- /* 600 */ 914, 916, 917, 918, 921, 923, 928, 929, 930, 933,
84717
- /* 610 */ 931, 620, 615,
84944
+ /* 0 */ 621, 856, 939, 939, 856, 939, 939, 885, 885, 744,
84945
+ /* 10 */ 854, 939, 939, 939, 939, 939, 939, 914, 939, 939,
84946
+ /* 20 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84947
+ /* 30 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84948
+ /* 40 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84949
+ /* 50 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 828,
84950
+ /* 60 */ 939, 939, 939, 660, 885, 885, 748, 779, 939, 939,
84951
+ /* 70 */ 939, 939, 939, 939, 939, 939, 780, 939, 858, 853,
84952
+ /* 80 */ 849, 851, 850, 857, 781, 770, 777, 784, 759, 898,
84953
+ /* 90 */ 786, 787, 793, 794, 915, 913, 816, 815, 834, 818,
84954
+ /* 100 */ 840, 817, 827, 652, 819, 820, 939, 939, 939, 939,
84955
+ /* 110 */ 939, 713, 647, 939, 939, 939, 939, 939, 939, 939,
84956
+ /* 120 */ 939, 939, 939, 939, 939, 939, 821, 939, 822, 835,
84957
+ /* 130 */ 836, 837, 939, 939, 939, 939, 939, 939, 939, 939,
84958
+ /* 140 */ 939, 627, 939, 939, 939, 939, 939, 939, 939, 939,
84959
+ /* 150 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84960
+ /* 160 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 869,
84961
+ /* 170 */ 939, 918, 920, 939, 939, 939, 621, 744, 744, 744,
84962
+ /* 180 */ 939, 939, 939, 939, 939, 738, 748, 932, 939, 939,
84963
+ /* 190 */ 704, 939, 939, 939, 939, 939, 939, 939, 629, 736,
84964
+ /* 200 */ 662, 746, 939, 939, 939, 649, 725, 891, 939, 905,
84965
+ /* 210 */ 903, 727, 789, 939, 736, 745, 939, 939, 939, 852,
84966
+ /* 220 */ 773, 773, 761, 773, 683, 773, 939, 773, 939, 686,
84967
+ /* 230 */ 783, 761, 761, 783, 626, 626, 626, 626, 637, 637,
84968
+ /* 240 */ 703, 939, 783, 774, 776, 766, 778, 939, 752, 752,
84969
+ /* 250 */ 760, 765, 760, 765, 760, 765, 715, 715, 700, 715,
84970
+ /* 260 */ 686, 715, 862, 866, 866, 700, 715, 715, 715, 862,
84971
+ /* 270 */ 644, 752, 644, 752, 644, 752, 752, 895, 897, 644,
84972
+ /* 280 */ 752, 717, 717, 795, 783, 752, 724, 724, 724, 724,
84973
+ /* 290 */ 783, 717, 795, 752, 917, 917, 752, 752, 925, 670,
84974
+ /* 300 */ 688, 688, 932, 937, 939, 939, 939, 939, 939, 939,
84975
+ /* 310 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84976
+ /* 320 */ 939, 871, 939, 939, 939, 635, 939, 654, 802, 807,
84977
+ /* 330 */ 803, 939, 804, 939, 730, 939, 939, 939, 939, 939,
84978
+ /* 340 */ 939, 939, 939, 939, 939, 855, 939, 767, 939, 775,
84979
+ /* 350 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84980
+ /* 360 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84981
+ /* 370 */ 939, 939, 939, 939, 939, 893, 894, 939, 939, 939,
84982
+ /* 380 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84983
+ /* 390 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84984
+ /* 400 */ 939, 924, 939, 939, 927, 622, 939, 617, 619, 620,
84985
+ /* 410 */ 624, 625, 628, 654, 655, 657, 658, 659, 630, 631,
84986
+ /* 420 */ 632, 633, 634, 636, 640, 638, 639, 641, 648, 650,
84987
+ /* 430 */ 669, 671, 673, 734, 735, 799, 728, 729, 733, 656,
84988
+ /* 440 */ 810, 801, 805, 806, 808, 809, 823, 824, 826, 832,
84989
+ /* 450 */ 839, 842, 825, 830, 831, 833, 838, 841, 731, 732,
84990
+ /* 460 */ 845, 663, 664, 667, 668, 881, 883, 882, 884, 666,
84991
+ /* 470 */ 665, 811, 814, 847, 848, 906, 907, 908, 909, 910,
84992
+ /* 480 */ 843, 753, 846, 829, 768, 771, 772, 769, 737, 747,
84993
+ /* 490 */ 755, 756, 757, 758, 742, 743, 749, 764, 797, 798,
84994
+ /* 500 */ 762, 763, 750, 751, 739, 740, 741, 844, 800, 812,
84995
+ /* 510 */ 813, 674, 675, 807, 676, 677, 678, 716, 719, 720,
84996
+ /* 520 */ 721, 679, 698, 701, 702, 680, 687, 681, 682, 689,
84997
+ /* 530 */ 690, 691, 694, 695, 696, 697, 692, 693, 863, 864,
84998
+ /* 540 */ 867, 865, 684, 685, 699, 672, 661, 653, 705, 708,
84999
+ /* 550 */ 709, 710, 711, 712, 714, 706, 707, 651, 642, 645,
85000
+ /* 560 */ 754, 887, 896, 892, 888, 889, 890, 646, 859, 860,
85001
+ /* 570 */ 718, 791, 792, 886, 899, 901, 796, 902, 904, 900,
85002
+ /* 580 */ 929, 643, 722, 723, 726, 868, 911, 782, 785, 788,
85003
+ /* 590 */ 790, 870, 872, 874, 876, 877, 878, 879, 880, 873,
85004
+ /* 600 */ 875, 912, 916, 919, 921, 922, 923, 926, 928, 933,
85005
+ /* 610 */ 934, 935, 938, 936, 623, 618,
8471885006
};
8471985007
#define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))
8472085008
8472185009
/* The next table maps tokens into fallback tokens. If a construct
8472285010
** like the following:
@@ -85271,76 +85559,78 @@
8527185559
/* 250 */ "collate ::=",
8527285560
/* 251 */ "collate ::= COLLATE ids",
8527385561
/* 252 */ "cmd ::= DROP INDEX ifexists fullname",
8527485562
/* 253 */ "cmd ::= VACUUM",
8527585563
/* 254 */ "cmd ::= VACUUM nm",
85276
- /* 255 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
85277
- /* 256 */ "cmd ::= PRAGMA nm dbnm EQ ON",
85278
- /* 257 */ "cmd ::= PRAGMA nm dbnm EQ DELETE",
85564
+ /* 255 */ "cmd ::= PRAGMA nm dbnm",
85565
+ /* 256 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
85566
+ /* 257 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
8527985567
/* 258 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
85280
- /* 259 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
85281
- /* 260 */ "cmd ::= PRAGMA nm dbnm",
85282
- /* 261 */ "nmnum ::= plus_num",
85283
- /* 262 */ "nmnum ::= nm",
85284
- /* 263 */ "plus_num ::= plus_opt number",
85285
- /* 264 */ "minus_num ::= MINUS number",
85286
- /* 265 */ "number ::= INTEGER|FLOAT",
85287
- /* 266 */ "plus_opt ::= PLUS",
85288
- /* 267 */ "plus_opt ::=",
85289
- /* 268 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
85290
- /* 269 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
85291
- /* 270 */ "trigger_time ::= BEFORE",
85292
- /* 271 */ "trigger_time ::= AFTER",
85293
- /* 272 */ "trigger_time ::= INSTEAD OF",
85294
- /* 273 */ "trigger_time ::=",
85295
- /* 274 */ "trigger_event ::= DELETE|INSERT",
85296
- /* 275 */ "trigger_event ::= UPDATE",
85297
- /* 276 */ "trigger_event ::= UPDATE OF inscollist",
85298
- /* 277 */ "foreach_clause ::=",
85299
- /* 278 */ "foreach_clause ::= FOR EACH ROW",
85300
- /* 279 */ "when_clause ::=",
85301
- /* 280 */ "when_clause ::= WHEN expr",
85302
- /* 281 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
85303
- /* 282 */ "trigger_cmd_list ::= trigger_cmd SEMI",
85304
- /* 283 */ "trigger_cmd ::= UPDATE orconf nm SET setlist where_opt",
85305
- /* 284 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP",
85306
- /* 285 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt select",
85307
- /* 286 */ "trigger_cmd ::= DELETE FROM nm where_opt",
85308
- /* 287 */ "trigger_cmd ::= select",
85309
- /* 288 */ "expr ::= RAISE LP IGNORE RP",
85310
- /* 289 */ "expr ::= RAISE LP raisetype COMMA nm RP",
85311
- /* 290 */ "raisetype ::= ROLLBACK",
85312
- /* 291 */ "raisetype ::= ABORT",
85313
- /* 292 */ "raisetype ::= FAIL",
85314
- /* 293 */ "cmd ::= DROP TRIGGER ifexists fullname",
85315
- /* 294 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
85316
- /* 295 */ "cmd ::= DETACH database_kw_opt expr",
85317
- /* 296 */ "key_opt ::=",
85318
- /* 297 */ "key_opt ::= KEY expr",
85319
- /* 298 */ "database_kw_opt ::= DATABASE",
85320
- /* 299 */ "database_kw_opt ::=",
85321
- /* 300 */ "cmd ::= REINDEX",
85322
- /* 301 */ "cmd ::= REINDEX nm dbnm",
85323
- /* 302 */ "cmd ::= ANALYZE",
85324
- /* 303 */ "cmd ::= ANALYZE nm dbnm",
85325
- /* 304 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
85326
- /* 305 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
85327
- /* 306 */ "add_column_fullname ::= fullname",
85328
- /* 307 */ "kwcolumn_opt ::=",
85329
- /* 308 */ "kwcolumn_opt ::= COLUMNKW",
85330
- /* 309 */ "cmd ::= create_vtab",
85331
- /* 310 */ "cmd ::= create_vtab LP vtabarglist RP",
85332
- /* 311 */ "create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm",
85333
- /* 312 */ "vtabarglist ::= vtabarg",
85334
- /* 313 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
85335
- /* 314 */ "vtabarg ::=",
85336
- /* 315 */ "vtabarg ::= vtabarg vtabargtoken",
85337
- /* 316 */ "vtabargtoken ::= ANY",
85338
- /* 317 */ "vtabargtoken ::= lp anylist RP",
85339
- /* 318 */ "lp ::= LP",
85340
- /* 319 */ "anylist ::=",
85341
- /* 320 */ "anylist ::= anylist ANY",
85568
+ /* 259 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
85569
+ /* 260 */ "nmnum ::= plus_num",
85570
+ /* 261 */ "nmnum ::= nm",
85571
+ /* 262 */ "nmnum ::= ON",
85572
+ /* 263 */ "nmnum ::= DELETE",
85573
+ /* 264 */ "nmnum ::= DEFAULT",
85574
+ /* 265 */ "plus_num ::= plus_opt number",
85575
+ /* 266 */ "minus_num ::= MINUS number",
85576
+ /* 267 */ "number ::= INTEGER|FLOAT",
85577
+ /* 268 */ "plus_opt ::= PLUS",
85578
+ /* 269 */ "plus_opt ::=",
85579
+ /* 270 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
85580
+ /* 271 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
85581
+ /* 272 */ "trigger_time ::= BEFORE",
85582
+ /* 273 */ "trigger_time ::= AFTER",
85583
+ /* 274 */ "trigger_time ::= INSTEAD OF",
85584
+ /* 275 */ "trigger_time ::=",
85585
+ /* 276 */ "trigger_event ::= DELETE|INSERT",
85586
+ /* 277 */ "trigger_event ::= UPDATE",
85587
+ /* 278 */ "trigger_event ::= UPDATE OF inscollist",
85588
+ /* 279 */ "foreach_clause ::=",
85589
+ /* 280 */ "foreach_clause ::= FOR EACH ROW",
85590
+ /* 281 */ "when_clause ::=",
85591
+ /* 282 */ "when_clause ::= WHEN expr",
85592
+ /* 283 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
85593
+ /* 284 */ "trigger_cmd_list ::= trigger_cmd SEMI",
85594
+ /* 285 */ "trigger_cmd ::= UPDATE orconf nm SET setlist where_opt",
85595
+ /* 286 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP",
85596
+ /* 287 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt select",
85597
+ /* 288 */ "trigger_cmd ::= DELETE FROM nm where_opt",
85598
+ /* 289 */ "trigger_cmd ::= select",
85599
+ /* 290 */ "expr ::= RAISE LP IGNORE RP",
85600
+ /* 291 */ "expr ::= RAISE LP raisetype COMMA nm RP",
85601
+ /* 292 */ "raisetype ::= ROLLBACK",
85602
+ /* 293 */ "raisetype ::= ABORT",
85603
+ /* 294 */ "raisetype ::= FAIL",
85604
+ /* 295 */ "cmd ::= DROP TRIGGER ifexists fullname",
85605
+ /* 296 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
85606
+ /* 297 */ "cmd ::= DETACH database_kw_opt expr",
85607
+ /* 298 */ "key_opt ::=",
85608
+ /* 299 */ "key_opt ::= KEY expr",
85609
+ /* 300 */ "database_kw_opt ::= DATABASE",
85610
+ /* 301 */ "database_kw_opt ::=",
85611
+ /* 302 */ "cmd ::= REINDEX",
85612
+ /* 303 */ "cmd ::= REINDEX nm dbnm",
85613
+ /* 304 */ "cmd ::= ANALYZE",
85614
+ /* 305 */ "cmd ::= ANALYZE nm dbnm",
85615
+ /* 306 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
85616
+ /* 307 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
85617
+ /* 308 */ "add_column_fullname ::= fullname",
85618
+ /* 309 */ "kwcolumn_opt ::=",
85619
+ /* 310 */ "kwcolumn_opt ::= COLUMNKW",
85620
+ /* 311 */ "cmd ::= create_vtab",
85621
+ /* 312 */ "cmd ::= create_vtab LP vtabarglist RP",
85622
+ /* 313 */ "create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm",
85623
+ /* 314 */ "vtabarglist ::= vtabarg",
85624
+ /* 315 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
85625
+ /* 316 */ "vtabarg ::=",
85626
+ /* 317 */ "vtabarg ::= vtabarg vtabargtoken",
85627
+ /* 318 */ "vtabargtoken ::= ANY",
85628
+ /* 319 */ "vtabargtoken ::= lp anylist RP",
85629
+ /* 320 */ "lp ::= LP",
85630
+ /* 321 */ "anylist ::=",
85631
+ /* 322 */ "anylist ::= anylist ANY",
8534285632
};
8534385633
#endif /* NDEBUG */
8534485634
8534585635
8534685636
#if YYSTACKDEPTH<=0
@@ -85963,16 +86253,18 @@
8596386253
{ 230, 0 },
8596486254
{ 230, 2 },
8596586255
{ 147, 4 },
8596686256
{ 147, 1 },
8596786257
{ 147, 2 },
85968
- { 147, 5 },
86258
+ { 147, 3 },
8596986259
{ 147, 5 },
85970
- { 147, 5 },
86260
+ { 147, 6 },
8597186261
{ 147, 5 },
8597286262
{ 147, 6 },
85973
- { 147, 3 },
86263
+ { 231, 1 },
86264
+ { 231, 1 },
86265
+ { 231, 1 },
8597486266
{ 231, 1 },
8597586267
{ 231, 1 },
8597686268
{ 170, 2 },
8597786269
{ 171, 2 },
8597886270
{ 233, 1 },
@@ -86108,22 +86400,22 @@
8610886400
case 62: /* ccons ::= NULL onconf */
8610986401
case 89: /* conslist ::= conslist COMMA tcons */
8611086402
case 90: /* conslist ::= conslist tcons */
8611186403
case 91: /* conslist ::= tcons */
8611286404
case 92: /* tcons ::= CONSTRAINT nm */
86113
- case 266: /* plus_opt ::= PLUS */
86114
- case 267: /* plus_opt ::= */
86115
- case 277: /* foreach_clause ::= */
86116
- case 278: /* foreach_clause ::= FOR EACH ROW */
86117
- case 298: /* database_kw_opt ::= DATABASE */
86118
- case 299: /* database_kw_opt ::= */
86119
- case 307: /* kwcolumn_opt ::= */
86120
- case 308: /* kwcolumn_opt ::= COLUMNKW */
86121
- case 312: /* vtabarglist ::= vtabarg */
86122
- case 313: /* vtabarglist ::= vtabarglist COMMA vtabarg */
86123
- case 315: /* vtabarg ::= vtabarg vtabargtoken */
86124
- case 319: /* anylist ::= */
86405
+ case 268: /* plus_opt ::= PLUS */
86406
+ case 269: /* plus_opt ::= */
86407
+ case 279: /* foreach_clause ::= */
86408
+ case 280: /* foreach_clause ::= FOR EACH ROW */
86409
+ case 300: /* database_kw_opt ::= DATABASE */
86410
+ case 301: /* database_kw_opt ::= */
86411
+ case 309: /* kwcolumn_opt ::= */
86412
+ case 310: /* kwcolumn_opt ::= COLUMNKW */
86413
+ case 314: /* vtabarglist ::= vtabarg */
86414
+ case 315: /* vtabarglist ::= vtabarglist COMMA vtabarg */
86415
+ case 317: /* vtabarg ::= vtabarg vtabargtoken */
86416
+ case 321: /* anylist ::= */
8612586417
{
8612686418
}
8612786419
break;
8612886420
case 5: /* explain ::= */
8612986421
{ sqlite3BeginParse(pParse, 0); }
@@ -86240,15 +86532,18 @@
8624086532
case 126: /* as ::= AS nm */
8624186533
case 127: /* as ::= ids */
8624286534
case 137: /* dbnm ::= DOT nm */
8624386535
case 146: /* indexed_opt ::= INDEXED BY nm */
8624486536
case 251: /* collate ::= COLLATE ids */
86245
- case 261: /* nmnum ::= plus_num */
86246
- case 262: /* nmnum ::= nm */
86247
- case 263: /* plus_num ::= plus_opt number */
86248
- case 264: /* minus_num ::= MINUS number */
86249
- case 265: /* number ::= INTEGER|FLOAT */
86537
+ case 260: /* nmnum ::= plus_num */
86538
+ case 261: /* nmnum ::= nm */
86539
+ case 262: /* nmnum ::= ON */
86540
+ case 263: /* nmnum ::= DELETE */
86541
+ case 264: /* nmnum ::= DEFAULT */
86542
+ case 265: /* plus_num ::= plus_opt number */
86543
+ case 266: /* minus_num ::= MINUS number */
86544
+ case 267: /* number ::= INTEGER|FLOAT */
8625086545
{yygotominor.yy0 = yymsp[0].minor.yy0;}
8625186546
break;
8625286547
case 45: /* type ::= typetoken */
8625386548
{sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);}
8625486549
break;
@@ -86888,11 +87183,11 @@
8688887183
sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy148, yymsp[-9].minor.yy194,
8688987184
&yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy194);
8689087185
}
8689187186
break;
8689287187
case 244: /* uniqueflag ::= UNIQUE */
86893
- case 291: /* raisetype ::= ABORT */
87188
+ case 293: /* raisetype ::= ABORT */
8689487189
{yygotominor.yy194 = OE_Abort;}
8689587190
break;
8689687191
case 245: /* uniqueflag ::= */
8689787192
{yygotominor.yy194 = OE_None;}
8689887193
break;
@@ -86928,66 +87223,65 @@
8692887223
break;
8692987224
case 253: /* cmd ::= VACUUM */
8693087225
case 254: /* cmd ::= VACUUM nm */
8693187226
{sqlite3Vacuum(pParse);}
8693287227
break;
86933
- case 255: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
86934
- case 256: /* cmd ::= PRAGMA nm dbnm EQ ON */
86935
- case 257: /* cmd ::= PRAGMA nm dbnm EQ DELETE */
87228
+ case 255: /* cmd ::= PRAGMA nm dbnm */
87229
+{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
87230
+ break;
87231
+ case 256: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
8693687232
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
8693787233
break;
86938
- case 258: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
86939
-{
86940
- sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);
86941
-}
86942
- break;
86943
- case 259: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
87234
+ case 257: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
8694487235
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
8694587236
break;
86946
- case 260: /* cmd ::= PRAGMA nm dbnm */
86947
-{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
87237
+ case 258: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
87238
+{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
87239
+ break;
87240
+ case 259: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
87241
+{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
8694887242
break;
86949
- case 268: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
87243
+ case 270: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
8695087244
{
8695187245
Token all;
8695287246
all.z = yymsp[-3].minor.yy0.z;
8695387247
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
8695487248
sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
8695587249
}
8695687250
break;
86957
- case 269: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
87251
+ case 271: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
8695887252
{
8695987253
sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
8696087254
yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
8696187255
}
8696287256
break;
86963
- case 270: /* trigger_time ::= BEFORE */
86964
- case 273: /* trigger_time ::= */
87257
+ case 272: /* trigger_time ::= BEFORE */
87258
+ case 275: /* trigger_time ::= */
8696587259
{ yygotominor.yy194 = TK_BEFORE; }
8696687260
break;
86967
- case 271: /* trigger_time ::= AFTER */
87261
+ case 273: /* trigger_time ::= AFTER */
8696887262
{ yygotominor.yy194 = TK_AFTER; }
8696987263
break;
86970
- case 272: /* trigger_time ::= INSTEAD OF */
87264
+ case 274: /* trigger_time ::= INSTEAD OF */
8697187265
{ yygotominor.yy194 = TK_INSTEAD;}
8697287266
break;
86973
- case 274: /* trigger_event ::= DELETE|INSERT */
86974
- case 275: /* trigger_event ::= UPDATE */
87267
+ case 276: /* trigger_event ::= DELETE|INSERT */
87268
+ case 277: /* trigger_event ::= UPDATE */
8697587269
{yygotominor.yy332.a = yymsp[0].major; yygotominor.yy332.b = 0;}
8697687270
break;
86977
- case 276: /* trigger_event ::= UPDATE OF inscollist */
87271
+ case 278: /* trigger_event ::= UPDATE OF inscollist */
8697887272
{yygotominor.yy332.a = TK_UPDATE; yygotominor.yy332.b = yymsp[0].minor.yy254;}
8697987273
break;
86980
- case 279: /* when_clause ::= */
86981
- case 296: /* key_opt ::= */
87274
+ case 281: /* when_clause ::= */
87275
+ case 298: /* key_opt ::= */
8698287276
{ yygotominor.yy72 = 0; }
8698387277
break;
86984
- case 280: /* when_clause ::= WHEN expr */
86985
- case 297: /* key_opt ::= KEY expr */
87278
+ case 282: /* when_clause ::= WHEN expr */
87279
+ case 299: /* key_opt ::= KEY expr */
8698687280
{ yygotominor.yy72 = yymsp[0].minor.yy72; }
8698787281
break;
86988
- case 281: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
87282
+ case 283: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
8698987283
{
8699087284
/*
8699187285
if( yymsp[-2].minor.yy145 ){
8699287286
yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
8699387287
}else{
@@ -86998,118 +87292,118 @@
8699887292
yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
8699987293
yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
8700087294
yygotominor.yy145 = yymsp[-2].minor.yy145;
8700187295
}
8700287296
break;
87003
- case 282: /* trigger_cmd_list ::= trigger_cmd SEMI */
87297
+ case 284: /* trigger_cmd_list ::= trigger_cmd SEMI */
8700487298
{
8700587299
/* if( yymsp[-1].minor.yy145 ) */
8700687300
assert( yymsp[-1].minor.yy145!=0 );
8700787301
yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
8700887302
yygotominor.yy145 = yymsp[-1].minor.yy145;
8700987303
}
8701087304
break;
87011
- case 283: /* trigger_cmd ::= UPDATE orconf nm SET setlist where_opt */
87305
+ case 285: /* trigger_cmd ::= UPDATE orconf nm SET setlist where_opt */
8701287306
{ yygotominor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-4].minor.yy194); }
8701387307
break;
87014
- case 284: /* trigger_cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP */
87308
+ case 286: /* trigger_cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP */
8701587309
{yygotominor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy254, yymsp[-1].minor.yy148, 0, yymsp[-7].minor.yy194);}
8701687310
break;
87017
- case 285: /* trigger_cmd ::= insert_cmd INTO nm inscollist_opt select */
87311
+ case 287: /* trigger_cmd ::= insert_cmd INTO nm inscollist_opt select */
8701887312
{yygotominor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, 0, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);}
8701987313
break;
87020
- case 286: /* trigger_cmd ::= DELETE FROM nm where_opt */
87314
+ case 288: /* trigger_cmd ::= DELETE FROM nm where_opt */
8702187315
{yygotominor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-1].minor.yy0, yymsp[0].minor.yy72);}
8702287316
break;
87023
- case 287: /* trigger_cmd ::= select */
87317
+ case 289: /* trigger_cmd ::= select */
8702487318
{yygotominor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); }
8702587319
break;
87026
- case 288: /* expr ::= RAISE LP IGNORE RP */
87320
+ case 290: /* expr ::= RAISE LP IGNORE RP */
8702787321
{
8702887322
yygotominor.yy72 = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
8702987323
if( yygotominor.yy72 ){
8703087324
yygotominor.yy72->affinity = OE_Ignore;
8703187325
sqlite3ExprSpan(yygotominor.yy72, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0);
8703287326
}
8703387327
}
8703487328
break;
87035
- case 289: /* expr ::= RAISE LP raisetype COMMA nm RP */
87329
+ case 291: /* expr ::= RAISE LP raisetype COMMA nm RP */
8703687330
{
8703787331
yygotominor.yy72 = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
8703887332
if( yygotominor.yy72 ) {
8703987333
yygotominor.yy72->affinity = (char)yymsp[-3].minor.yy194;
8704087334
sqlite3ExprSpan(yygotominor.yy72, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0);
8704187335
}
8704287336
}
8704387337
break;
87044
- case 290: /* raisetype ::= ROLLBACK */
87338
+ case 292: /* raisetype ::= ROLLBACK */
8704587339
{yygotominor.yy194 = OE_Rollback;}
8704687340
break;
87047
- case 292: /* raisetype ::= FAIL */
87341
+ case 294: /* raisetype ::= FAIL */
8704887342
{yygotominor.yy194 = OE_Fail;}
8704987343
break;
87050
- case 293: /* cmd ::= DROP TRIGGER ifexists fullname */
87344
+ case 295: /* cmd ::= DROP TRIGGER ifexists fullname */
8705187345
{
8705287346
sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
8705387347
}
8705487348
break;
87055
- case 294: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
87349
+ case 296: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
8705687350
{
8705787351
sqlite3Attach(pParse, yymsp[-3].minor.yy72, yymsp[-1].minor.yy72, yymsp[0].minor.yy72);
8705887352
}
8705987353
break;
87060
- case 295: /* cmd ::= DETACH database_kw_opt expr */
87354
+ case 297: /* cmd ::= DETACH database_kw_opt expr */
8706187355
{
8706287356
sqlite3Detach(pParse, yymsp[0].minor.yy72);
8706387357
}
8706487358
break;
87065
- case 300: /* cmd ::= REINDEX */
87359
+ case 302: /* cmd ::= REINDEX */
8706687360
{sqlite3Reindex(pParse, 0, 0);}
8706787361
break;
87068
- case 301: /* cmd ::= REINDEX nm dbnm */
87362
+ case 303: /* cmd ::= REINDEX nm dbnm */
8706987363
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
8707087364
break;
87071
- case 302: /* cmd ::= ANALYZE */
87365
+ case 304: /* cmd ::= ANALYZE */
8707287366
{sqlite3Analyze(pParse, 0, 0);}
8707387367
break;
87074
- case 303: /* cmd ::= ANALYZE nm dbnm */
87368
+ case 305: /* cmd ::= ANALYZE nm dbnm */
8707587369
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
8707687370
break;
87077
- case 304: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
87371
+ case 306: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
8707887372
{
8707987373
sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
8708087374
}
8708187375
break;
87082
- case 305: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
87376
+ case 307: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
8708387377
{
8708487378
sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0);
8708587379
}
8708687380
break;
87087
- case 306: /* add_column_fullname ::= fullname */
87381
+ case 308: /* add_column_fullname ::= fullname */
8708887382
{
8708987383
pParse->db->lookaside.bEnabled = 0;
8709087384
sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
8709187385
}
8709287386
break;
87093
- case 309: /* cmd ::= create_vtab */
87387
+ case 311: /* cmd ::= create_vtab */
8709487388
{sqlite3VtabFinishParse(pParse,0);}
8709587389
break;
87096
- case 310: /* cmd ::= create_vtab LP vtabarglist RP */
87390
+ case 312: /* cmd ::= create_vtab LP vtabarglist RP */
8709787391
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
8709887392
break;
87099
- case 311: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */
87393
+ case 313: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */
8710087394
{
8710187395
sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
8710287396
}
8710387397
break;
87104
- case 314: /* vtabarg ::= */
87398
+ case 316: /* vtabarg ::= */
8710587399
{sqlite3VtabArgInit(pParse);}
8710687400
break;
87107
- case 316: /* vtabargtoken ::= ANY */
87108
- case 317: /* vtabargtoken ::= lp anylist RP */
87109
- case 318: /* lp ::= LP */
87110
- case 320: /* anylist ::= anylist ANY */
87401
+ case 318: /* vtabargtoken ::= ANY */
87402
+ case 319: /* vtabargtoken ::= lp anylist RP */
87403
+ case 320: /* lp ::= LP */
87404
+ case 322: /* anylist ::= anylist ANY */
8711187405
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
8711287406
break;
8711387407
};
8711487408
yygoto = yyRuleInfo[yyruleno].lhs;
8711587409
yysize = yyRuleInfo[yyruleno].nrhs;
@@ -88437,11 +88731,11 @@
8843788731
** Main file for the SQLite library. The routines in this file
8843888732
** implement the programmer interface to the library. Routines in
8843988733
** other files are for internal use by SQLite and should not be
8844088734
** accessed by users of the library.
8844188735
**
88442
-** $Id: main.c,v 1.534 2009/03/23 04:33:32 danielk1977 Exp $
88736
+** $Id: main.c,v 1.536 2009/04/09 01:23:49 drh Exp $
8844388737
*/
8844488738
8844588739
#ifdef SQLITE_ENABLE_FTS3
8844688740
/************** Include fts3.h in the middle of main.c ***********************/
8844788741
/************** Begin file fts3.h ********************************************/
@@ -88729,10 +89023,11 @@
8872989023
sqlite3GlobalConfig.isMallocInit = 0;
8873089024
sqlite3PcacheShutdown();
8873189025
if( sqlite3GlobalConfig.isInit ){
8873289026
sqlite3_os_end();
8873389027
}
89028
+ sqlite3_reset_auto_extension();
8873489029
sqlite3MallocEnd();
8873589030
sqlite3MutexEnd();
8873689031
sqlite3GlobalConfig.isInit = 0;
8873789032
return SQLITE_OK;
8873889033
}
@@ -88928,11 +89223,11 @@
8892889223
db->lookaside.pFree = 0;
8892989224
db->lookaside.sz = (u16)sz;
8893089225
if( pStart ){
8893189226
int i;
8893289227
LookasideSlot *p;
88933
- assert( sz > sizeof(LookasideSlot*) );
89228
+ assert( sz > (int)sizeof(LookasideSlot*) );
8893489229
p = (LookasideSlot*)pStart;
8893589230
for(i=cnt-1; i>=0; i--){
8893689231
p->pNext = db->lookaside.pFree;
8893789232
db->lookaside.pFree = p;
8893889233
p = (LookasideSlot*)&((u8*)p)[sz];
@@ -90705,11 +91000,11 @@
9070591000
*************************************************************************
9070691001
**
9070791002
** This file contains the implementation of the sqlite3_unlock_notify()
9070891003
** API method and its associated functionality.
9070991004
**
90710
-** $Id: notify.c,v 1.2 2009/03/25 16:51:43 drh Exp $
91005
+** $Id: notify.c,v 1.4 2009/04/07 22:06:57 drh Exp $
9071191006
*/
9071291007
9071391008
/* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */
9071491009
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
9071591010
@@ -90802,26 +91097,44 @@
9080291097
}
9080391098
9080491099
/*
9080591100
** Obtain the STATIC_MASTER mutex.
9080691101
*/
90807
-static void enterMutex(){
91102
+static void enterMutex(void){
9080891103
sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
9080991104
checkListProperties(0);
9081091105
}
9081191106
9081291107
/*
9081391108
** Release the STATIC_MASTER mutex.
9081491109
*/
90815
-static void leaveMutex(){
91110
+static void leaveMutex(void){
9081691111
assertMutexHeld();
9081791112
checkListProperties(0);
9081891113
sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
9081991114
}
9082091115
9082191116
/*
9082291117
** Register an unlock-notify callback.
91118
+**
91119
+** This is called after connection "db" has attempted some operation
91120
+** but has received an SQLITE_LOCKED error because another connection
91121
+** (call it pOther) in the same process was busy using the same shared
91122
+** cache. pOther is found by looking at db->pBlockingConnection.
91123
+**
91124
+** If there is no blocking connection, the callback is invoked immediately,
91125
+** before this routine returns.
91126
+**
91127
+** If pOther is already blocked on db, then report SQLITE_LOCKED, to indicate
91128
+** a deadlock.
91129
+**
91130
+** Otherwise, make arrangements to invoke xNotify when pOther drops
91131
+** its locks.
91132
+**
91133
+** Each call to this routine overrides any prior callbacks registered
91134
+** on the same "db". If xNotify==0 then any prior callbacks are immediately
91135
+** cancelled.
9082391136
*/
9082491137
SQLITE_API int sqlite3_unlock_notify(
9082591138
sqlite3 *db,
9082691139
void (*xNotify)(void **, int),
9082791140
void *pArg
@@ -90829,20 +91142,25 @@
9082991142
int rc = SQLITE_OK;
9083091143
9083191144
sqlite3_mutex_enter(db->mutex);
9083291145
enterMutex();
9083391146
90834
- if( 0==db->pBlockingConnection ){
91147
+ if( xNotify==0 ){
91148
+ removeFromBlockedList(db);
91149
+ db->pUnlockConnection = 0;
91150
+ db->xUnlockNotify = 0;
91151
+ db->pUnlockArg = 0;
91152
+ }else if( 0==db->pBlockingConnection ){
9083591153
/* The blocking transaction has been concluded. Or there never was a
9083691154
** blocking transaction. In either case, invoke the notify callback
9083791155
** immediately.
9083891156
*/
9083991157
xNotify(&pArg, 1);
9084091158
}else{
9084191159
sqlite3 *p;
9084291160
90843
- for(p=db->pBlockingConnection; p && p!=db; p=p->pUnlockConnection);
91161
+ for(p=db->pBlockingConnection; p && p!=db; p=p->pUnlockConnection){}
9084491162
if( p ){
9084591163
rc = SQLITE_LOCKED; /* Deadlock detected. */
9084691164
}else{
9084791165
db->pUnlockConnection = db->pBlockingConnection;
9084891166
db->xUnlockNotify = xNotify;
@@ -90873,11 +91191,12 @@
9087391191
db->pBlockingConnection = pBlocker;
9087491192
leaveMutex();
9087591193
}
9087691194
9087791195
/*
90878
-** The transaction opened by database db has just finished. Locks held
91196
+** This function is called when
91197
+** the transaction opened by database db has just finished. Locks held
9087991198
** by database connection db have been released.
9088091199
**
9088191200
** This function loops through each entry in the blocked connections
9088291201
** list and does the following:
9088391202
**
@@ -90894,15 +91213,15 @@
9089491213
*/
9089591214
SQLITE_PRIVATE void sqlite3ConnectionUnlocked(sqlite3 *db){
9089691215
void (*xUnlockNotify)(void **, int) = 0; /* Unlock-notify cb to invoke */
9089791216
int nArg = 0; /* Number of entries in aArg[] */
9089891217
sqlite3 **pp; /* Iterator variable */
91218
+ void **aArg; /* Arguments to the unlock callback */
91219
+ void **aDyn = 0; /* Dynamically allocated space for aArg[] */
91220
+ void *aStatic[16]; /* Starter space for aArg[]. No malloc required */
9089991221
90900
- void *aStatic[16];
90901
- void **aArg = aStatic;
90902
- void **aDyn = 0;
90903
-
91222
+ aArg = aStatic;
9090491223
enterMutex(); /* Enter STATIC_MASTER mutex */
9090591224
9090691225
/* This loop runs once for each entry in the blocked-connections list. */
9090791226
for(pp=&sqlite3BlockedList; *pp; /* no-op */ ){
9090891227
sqlite3 *p = *pp;
9090991228
--- 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.6.12. 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 ** 5487 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 2009-03-31 12:19:59 UTC.
21 */
22 #define SQLITE_CORE 1
23 #define SQLITE_AMALGAMATION 1
24 #ifndef SQLITE_PRIVATE
25 # define SQLITE_PRIVATE static
@@ -39,11 +39,11 @@
39 ** May you share freely, never taking more than you give.
40 **
41 *************************************************************************
42 ** Internal interface definitions for SQLite.
43 **
44 ** @(#) $Id: sqliteInt.h,v 1.848 2009/03/25 16:51:43 drh Exp $
45 */
46 #ifndef _SQLITEINT_H_
47 #define _SQLITEINT_H_
48
49 /*
@@ -530,11 +530,11 @@
530 ** The name of this file under configuration management is "sqlite.h.in".
531 ** The makefile makes some minor changes to this file (such as inserting
532 ** the version number) and changes its name to "sqlite3.h" as
533 ** part of the build process.
534 **
535 ** @(#) $Id: sqlite.h.in,v 1.436 2009/03/20 13:15:30 drh Exp $
536 */
537 #ifndef _SQLITE3_H_
538 #define _SQLITE3_H_
539 #include <stdarg.h> /* Needed for the definition of va_list */
540
@@ -599,12 +599,12 @@
599 **
600 ** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()].
601 **
602 ** Requirements: [H10011] [H10014]
603 */
604 #define SQLITE_VERSION "3.6.12"
605 #define SQLITE_VERSION_NUMBER 3006012
606
607 /*
608 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
609 ** KEYWORDS: sqlite3_version
610 **
@@ -882,11 +882,10 @@
882 #define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8))
883 #define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
884 #define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8))
885 #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
886 #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
887
888 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) )
889
890 /*
891 ** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700>
892 **
@@ -962,12 +961,13 @@
962 ** [sqlite3_io_methods] object it uses a combination of
963 ** these integer values as the second argument.
964 **
965 ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
966 ** sync operation only needs to flush data to mass storage. Inode
967 ** information need not be flushed. The SQLITE_SYNC_NORMAL flag means
968 ** to use normal fsync() semantics. The SQLITE_SYNC_FULL flag means
 
969 ** to use Mac OS X style fullsync instead of fsync().
970 */
971 #define SQLITE_SYNC_NORMAL 0x00002
972 #define SQLITE_SYNC_FULL 0x00003
973 #define SQLITE_SYNC_DATAONLY 0x00010
@@ -2729,11 +2729,12 @@
2729 **
2730 ** To execute an SQL query, it must first be compiled into a byte-code
2731 ** program using one of these routines.
2732 **
2733 ** The first argument, "db", is a [database connection] obtained from a
2734 ** prior call to [sqlite3_open()], [sqlite3_open_v2()] or [sqlite3_open16()].
 
2735 **
2736 ** The second argument, "zSql", is the statement to be compiled, encoded
2737 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
2738 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
2739 ** use UTF-16.
@@ -2746,21 +2747,22 @@
2746 ** that the supplied string is nul-terminated, then there is a small
2747 ** performance advantage to be gained by passing an nByte parameter that
2748 ** is equal to the number of bytes in the input string <i>including</i>
2749 ** the nul-terminator bytes.
2750 **
2751 ** *pzTail is made to point to the first byte past the end of the
2752 ** first SQL statement in zSql. These routines only compile the first
2753 ** statement in zSql, so *pzTail is left pointing to what remains
2754 ** uncompiled.
2755 **
2756 ** *ppStmt is left pointing to a compiled [prepared statement] that can be
2757 ** executed using [sqlite3_step()]. If there is an error, *ppStmt is set
2758 ** to NULL. If the input text contains no SQL (if the input is an empty
2759 ** string or a comment) then *ppStmt is set to NULL.
2760 ** {A13018} The calling procedure is responsible for deleting the compiled
2761 ** SQL statement using [sqlite3_finalize()] after it has finished with it.
 
2762 **
2763 ** On success, [SQLITE_OK] is returned, otherwise an [error code] is returned.
2764 **
2765 ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
2766 ** recommended for all new programs. The two older interfaces are retained
@@ -4130,14 +4132,28 @@
4130 ** the name of a folder (a.k.a. directory), then all temporary files
4131 ** created by SQLite will be placed in that directory. If this variable
4132 ** is a NULL pointer, then SQLite performs a search for an appropriate
4133 ** temporary file directory.
4134 **
4135 ** It is not safe to modify this variable once a [database connection]
4136 ** has been opened. It is intended that this variable be set once
 
 
 
4137 ** as part of process initialization and before any SQLite interface
4138 ** routines have been call and remain unchanged thereafter.
 
 
 
 
 
 
 
 
 
 
 
4139 */
4140 SQLITE_API char *sqlite3_temp_directory;
4141
4142 /*
4143 ** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200>
@@ -6417,10 +6433,15 @@
6417 /*
6418 ** Round down to the nearest multiple of 8
6419 */
6420 #define ROUNDDOWN8(x) ((x)&~7)
6421
 
 
 
 
 
6422 /*
6423 ** An instance of the following structure is used to store the busy-handler
6424 ** callback for a given sqlite handle.
6425 **
6426 ** The sqlite.busyHandler member of the sqlite struct contains the busy
@@ -6571,11 +6592,11 @@
6571 *************************************************************************
6572 ** This header file defines the interface that the sqlite B-Tree file
6573 ** subsystem. See comments in the source code for a detailed description
6574 ** of what each interface routine does.
6575 **
6576 ** @(#) $Id: btree.h,v 1.111 2009/03/18 10:33:01 danielk1977 Exp $
6577 */
6578 #ifndef _BTREE_H_
6579 #define _BTREE_H_
6580
6581 /* TODO: This definition is just included so other modules compile. It
@@ -6638,11 +6659,11 @@
6638
6639 SQLITE_PRIVATE int sqlite3BtreeClose(Btree*);
6640 SQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree*,int);
6641 SQLITE_PRIVATE int sqlite3BtreeSetSafetyLevel(Btree*,int,int);
6642 SQLITE_PRIVATE int sqlite3BtreeSyncDisabled(Btree*);
6643 SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree*,int,int);
6644 SQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree*);
6645 SQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree*,int);
6646 SQLITE_PRIVATE int sqlite3BtreeGetReserve(Btree*);
6647 SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int);
6648 SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *);
@@ -6744,46 +6765,43 @@
6744 /*
6745 ** If we are not using shared cache, then there is no need to
6746 ** use mutexes to access the BtShared structures. So make the
6747 ** Enter and Leave procedures no-ops.
6748 */
6749 #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
6750 SQLITE_PRIVATE void sqlite3BtreeEnter(Btree*);
 
 
 
 
 
 
 
6751 SQLITE_PRIVATE void sqlite3BtreeLeave(Btree*);
6752 #ifndef NDEBUG
6753 /* This routine is used inside assert() statements only. */
6754 SQLITE_PRIVATE int sqlite3BtreeHoldsMutex(Btree*);
6755 #endif
6756 SQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor*);
6757 SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor*);
6758 SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3*);
6759 SQLITE_PRIVATE void sqlite3BtreeLeaveAll(sqlite3*);
6760 #ifndef NDEBUG
6761 /* This routine is used inside assert() statements only. */
6762 SQLITE_PRIVATE int sqlite3BtreeHoldsAllMutexes(sqlite3*);
6763 #endif
6764 SQLITE_PRIVATE void sqlite3BtreeMutexArrayEnter(BtreeMutexArray*);
6765 SQLITE_PRIVATE void sqlite3BtreeMutexArrayLeave(BtreeMutexArray*);
6766 SQLITE_PRIVATE void sqlite3BtreeMutexArrayInsert(BtreeMutexArray*, Btree*);
6767 #else
6768 # define sqlite3BtreeEnter(X)
6769 # define sqlite3BtreeLeave(X)
6770 #ifndef NDEBUG
6771 /* This routine is used inside assert() statements only. */
6772 # define sqlite3BtreeHoldsMutex(X) 1
 
6773 #endif
 
 
 
6774 # define sqlite3BtreeEnterCursor(X)
6775 # define sqlite3BtreeLeaveCursor(X)
6776 # define sqlite3BtreeEnterAll(X)
6777 # define sqlite3BtreeLeaveAll(X)
6778 #ifndef NDEBUG
6779 /* This routine is used inside assert() statements only. */
6780 # define sqlite3BtreeHoldsAllMutexes(X) 1
6781 #endif
6782 # define sqlite3BtreeMutexArrayEnter(X)
6783 # define sqlite3BtreeMutexArrayLeave(X)
6784 # define sqlite3BtreeMutexArrayInsert(X,Y)
 
 
 
6785 #endif
6786
6787
6788 #endif /* _BTREE_H_ */
6789
@@ -6806,11 +6824,11 @@
6806 **
6807 ** This header defines the interface to the virtual database engine
6808 ** or VDBE. The VDBE implements an abstract machine that runs a
6809 ** simple program to access and modify the underlying database.
6810 **
6811 ** $Id: vdbe.h,v 1.140 2009/02/19 14:39:25 danielk1977 Exp $
6812 */
6813 #ifndef _SQLITE_VDBE_H_
6814 #define _SQLITE_VDBE_H_
6815
6816 /*
@@ -7162,12 +7180,11 @@
7162 SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
7163
7164 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
7165 SQLITE_PRIVATE int sqlite3VdbeReleaseMemory(int);
7166 #endif
7167 SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,
7168 UnpackedRecord*,int);
7169 SQLITE_PRIVATE void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord*);
7170 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);
7171
7172
7173 #ifndef NDEBUG
@@ -8097,10 +8114,17 @@
8097 u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
8098
8099 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
8100 /* The following variables are all protected by the STATIC_MASTER
8101 ** mutex, not by sqlite3.mutex. They are used by code in notify.c.
 
 
 
 
 
 
 
8102 */
8103 sqlite3 *pBlockingConnection; /* Connection that caused SQLITE_LOCKED */
8104 sqlite3 *pUnlockConnection; /* Connection to watch for unlock */
8105 void *pUnlockArg; /* Argument to xUnlockNotify */
8106 void (*xUnlockNotify)(void **, int); /* Unlock notify callback */
@@ -8141,11 +8165,10 @@
8141 #define SQLITE_FullFSync 0x00010000 /* Use full fsync on the backend */
8142 #define SQLITE_LoadExtension 0x00020000 /* Enable load_extension */
8143
8144 #define SQLITE_RecoveryMode 0x00040000 /* Ignore schema errors */
8145 #define SQLITE_SharedCache 0x00080000 /* Cache sharing is enabled */
8146 #define SQLITE_Vtab 0x00100000 /* There exists a virtual table */
8147 #define SQLITE_CommitBusy 0x00200000 /* In the process of committing */
8148 #define SQLITE_ReverseOrder 0x00400000 /* Reverse unordered SELECTs */
8149
8150 /*
8151 ** Possible values for the sqlite.magic field.
@@ -8707,23 +8730,22 @@
8707 ** is a disk table or the "old.*" pseudo-table, then pTab points to the
8708 ** corresponding table definition.
8709 **
8710 ** ALLOCATION NOTES:
8711 **
8712 ** Expr structures may be stored as part of the in-memory database schema,
8713 ** for example as part of trigger, view or table definitions. In this case,
8714 ** the amount of memory consumed by complex expressions may be significant.
8715 ** For this reason, less than sizeof(Expr) bytes may be allocated for some
8716 ** Expr structs stored as part of the in-memory database schema.
8717 **
8718 ** If the EP_Reduced flag is set in Expr.flags, then only EXPR_REDUCEDSIZE
8719 ** bytes of space are allocated for the expression structure. This is enough
8720 ** space to store all fields up to and including the "Token span;" field.
8721 **
8722 ** If the EP_TokenOnly flag is set in Expr.flags, then only EXPR_TOKENONLYSIZE
8723 ** bytes of space are allocated for the expression structure. This is enough
8724 ** space to store all fields up to and including the "Token token;" field.
8725 */
8726 struct Expr {
8727 u8 op; /* Operation performed by this node */
8728 char affinity; /* The affinity of the column or 0 if not a column */
8729 VVA_ONLY(u8 vvaFlags;) /* Flags used for VV&A only. EVVA_* below. */
@@ -8735,11 +8757,11 @@
8735 ** access them will result in a segfault or malfunction.
8736 *********************************************************************/
8737
8738 Token span; /* Complete text of the expression */
8739
8740 /* If the EP_SpanOnly flag is set in the Expr.flags mask, then no
8741 ** space is allocated for the fields below this point. An attempt to
8742 ** access them will result in a segfault or malfunction.
8743 *********************************************************************/
8744
8745 Expr *pLeft; /* Left subnode */
@@ -8783,11 +8805,11 @@
8783 #define EP_IntValue 0x0800 /* Integer value contained in iTable */
8784 #define EP_xIsSelect 0x1000 /* x.pSelect is valid (otherwise x.pList is) */
8785
8786 #define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */
8787 #define EP_TokenOnly 0x4000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
8788 #define EP_SpanOnly 0x8000 /* Expr struct is EXPR_SPANONLYSIZE bytes only */
8789
8790 /*
8791 ** The following are the meanings of bits in the Expr.vvaFlags field.
8792 ** This information is only used when SQLite is compiled with
8793 ** SQLITE_DEBUG defined.
@@ -8808,22 +8830,21 @@
8808 /*
8809 ** Macros to determine the number of bytes required by a normal Expr
8810 ** struct, an Expr struct with the EP_Reduced flag set in Expr.flags
8811 ** and an Expr struct with the EP_TokenOnly flag set.
8812 */
8813 #define EXPR_FULLSIZE sizeof(Expr)
8814 #define EXPR_REDUCEDSIZE offsetof(Expr,iTable)
8815 #define EXPR_TOKENONLYSIZE offsetof(Expr,span)
8816 #define EXPR_SPANONLYSIZE offsetof(Expr,pLeft)
8817
8818 /*
8819 ** Flags passed to the sqlite3ExprDup() function. See the header comment
8820 ** above sqlite3ExprDup() for details.
8821 */
8822 #define EXPRDUP_REDUCE 0x0001
8823 #define EXPRDUP_SPAN 0x0002
8824 #define EXPRDUP_DISTINCTSPAN 0x0004
8825
8826 /*
8827 ** A list of expressions. Each expression may optionally have a
8828 ** name. An expr/name combination can be used in several ways, such
8829 ** as the list of "expr AS ID" fields following a "SELECT" or in the
@@ -9799,10 +9820,11 @@
9799 # define sqlite3TriggersExist(B,C,D,E,F) 0
9800 # define sqlite3DeleteTrigger(A,B)
9801 # define sqlite3DropTriggerPtr(A,B)
9802 # define sqlite3UnlinkAndDeleteTrigger(A,B,C)
9803 # define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I,J,K,L) 0
 
9804 #endif
9805
9806 SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*);
9807 SQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);
9808 SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int);
@@ -9830,11 +9852,11 @@
9830 SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*);
9831 SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);
9832 SQLITE_PRIVATE int sqlite3FitsIn64Bits(const char *, int);
9833 SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar);
9834 SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte);
9835 SQLITE_PRIVATE int sqlite3Utf8Read(const u8*, const u8*, const u8**);
9836
9837 /*
9838 ** Routines to read and write variable-length integers. These used to
9839 ** be defined locally, but now we use the varint routines in the util.c
9840 ** file. Code should use the MACRO forms below, as the Varint32 versions
@@ -10427,11 +10449,11 @@
10427 **
10428 ** There is only one exported symbol in this file - the function
10429 ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
10430 ** All other code has file scope.
10431 **
10432 ** $Id: date.c,v 1.103 2009/02/04 03:59:25 shane Exp $
10433 **
10434 ** SQLite processes all times and dates as Julian Day numbers. The
10435 ** dates and times are stored as the number of days since noon
10436 ** in Greenwich on November 24, 4714 B.C. according to the Gregorian
10437 ** calendar system.
@@ -11361,12 +11383,12 @@
11361 break;
11362 }
11363 case 'm': sqlite3_snprintf(3, &z[j],"%02d",x.M); j+=2; break;
11364 case 'M': sqlite3_snprintf(3, &z[j],"%02d",x.m); j+=2; break;
11365 case 's': {
11366 sqlite3_snprintf(30,&z[j],"%d",
11367 (int)(x.iJD/1000.0 - 210866760000.0));
11368 j += sqlite3Strlen30(&z[j]);
11369 break;
11370 }
11371 case 'S': sqlite3_snprintf(3,&z[j],"%02d",(int)x.s); j+=2; break;
11372 case 'w': {
@@ -15655,11 +15677,11 @@
15655 ** the public domain. The original comments are included here for
15656 ** completeness. They are very out-of-date but might be useful as
15657 ** an historical reference. Most of the "enhancements" have been backed
15658 ** out so that the functionality is now the same as standard printf().
15659 **
15660 ** $Id: printf.c,v 1.99 2008/12/10 19:26:24 drh Exp $
15661 **
15662 **************************************************************************
15663 **
15664 ** The following modules is an enhanced replacement for the "printf" subroutines
15665 ** found in the standard C library. The following enhancements are
@@ -15726,10 +15748,12 @@
15726 #define etSRCLIST 13 /* a pointer to a SrcList */
15727 #define etPOINTER 14 /* The %p conversion */
15728 #define etSQLESCAPE3 15 /* %w -> Strings with '\"' doubled */
15729 #define etORDINAL 16 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */
15730
 
 
15731
15732 /*
15733 ** An "etByte" is an 8-bit unsigned value.
15734 */
15735 typedef unsigned char etByte;
@@ -15782,10 +15806,13 @@
15782 #endif
15783 { 'i', 10, 1, etRADIX, 0, 0 },
15784 { 'n', 0, 0, etSIZE, 0, 0 },
15785 { '%', 0, 0, etPERCENT, 0, 0 },
15786 { 'p', 16, 0, etPOINTER, 0, 1 },
 
 
 
15787 { 'T', 0, 2, etTOKEN, 0, 0 },
15788 { 'S', 0, 2, etSRCLIST, 0, 0 },
15789 { 'r', 10, 3, etORDINAL, 0, 0 },
15790 };
15791
@@ -15984,11 +16011,12 @@
15984 }
15985 }else{
15986 flag_long = flag_longlong = 0;
15987 }
15988 /* Fetch the info entry for the field */
15989 infop = 0;
 
15990 for(idx=0; idx<ArraySize(fmtinfo); idx++){
15991 if( c==fmtinfo[idx].fmttype ){
15992 infop = &fmtinfo[idx];
15993 if( useExtended || (infop->flags & FLAG_INTERN)==0 ){
15994 xtype = infop->type;
@@ -15997,13 +16025,10 @@
15997 }
15998 break;
15999 }
16000 }
16001 zExtra = 0;
16002 if( infop==0 ){
16003 return;
16004 }
16005
16006
16007 /* Limit the precision to prevent overflowing buf[] during conversion */
16008 if( precision>etBUFSIZE-40 && (infop->flags & FLAG_STRING)==0 ){
16009 precision = etBUFSIZE-40;
@@ -16336,10 +16361,14 @@
16336 sqlite3StrAccumAppend(pAccum, ".", 1);
16337 }
16338 sqlite3StrAccumAppend(pAccum, pItem->zName, -1);
16339 length = width = 0;
16340 break;
 
 
 
 
16341 }
16342 }/* End switch over the format type */
16343 /*
16344 ** The text of the conversion is pointed to by "bufpt" and is
16345 ** "length" characters long. The field width is "width". Do
@@ -16370,17 +16399,20 @@
16370
16371 /*
16372 ** Append N bytes of text from z to the StrAccum object.
16373 */
16374 SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){
 
16375 if( p->tooBig | p->mallocFailed ){
 
 
16376 return;
16377 }
16378 if( N<0 ){
16379 N = sqlite3Strlen30(z);
16380 }
16381 if( N==0 || z==0 ){
16382 return;
16383 }
16384 if( p->nChar+N >= p->nAlloc ){
16385 char *zNew;
16386 if( !p->useMalloc ){
@@ -16465,16 +16497,17 @@
16465 */
16466 SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){
16467 char *z;
16468 char zBase[SQLITE_PRINT_BUF_SIZE];
16469 StrAccum acc;
 
16470 sqlite3StrAccumInit(&acc, zBase, sizeof(zBase),
16471 db ? db->aLimit[SQLITE_LIMIT_LENGTH] : SQLITE_MAX_LENGTH);
16472 acc.db = db;
16473 sqlite3VXPrintf(&acc, 1, zFormat, ap);
16474 z = sqlite3StrAccumFinish(&acc);
16475 if( acc.mallocFailed && db ){
16476 db->mallocFailed = 1;
16477 }
16478 return z;
16479 }
16480
@@ -16749,11 +16782,11 @@
16749 **
16750 *************************************************************************
16751 ** This file contains routines used to translate between UTF-8,
16752 ** UTF-16, UTF-16BE, and UTF-16LE.
16753 **
16754 ** $Id: utf.c,v 1.71 2009/03/31 03:41:57 shane Exp $
16755 **
16756 ** Notes on UTF-8:
16757 **
16758 ** Byte-0 Byte-1 Byte-2 Byte-3 Value
16759 ** 0xxxxxxx 00000000 00000000 0xxxxxxx
@@ -16791,11 +16824,11 @@
16791 ** VDBE. This information used to all be at the top of the single
16792 ** source code file "vdbe.c". When that file became too big (over
16793 ** 6000 lines long) it was split up into several smaller files and
16794 ** this header information was factored out.
16795 **
16796 ** $Id: vdbeInt.h,v 1.166 2009/03/18 10:33:02 danielk1977 Exp $
16797 */
16798 #ifndef _VDBEINT_H_
16799 #define _VDBEINT_H_
16800
16801 /*
@@ -17154,10 +17187,16 @@
17154 SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
17155 SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);
17156 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
17157 SQLITE_PRIVATE int sqlite3VdbeReleaseBuffers(Vdbe *p);
17158 #endif
 
 
 
 
 
 
17159
17160 SQLITE_PRIVATE int sqlite3VdbeMemTranslate(Mem*, u8);
17161 #ifdef SQLITE_DEBUG
17162 SQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe*);
17163 SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf);
@@ -17244,26 +17283,24 @@
17244 }
17245
17246 #define READ_UTF16LE(zIn, c){ \
17247 c = (*zIn++); \
17248 c += ((*zIn++)<<8); \
17249 if( c>=0xD800 && c<0xE000 ){ \
17250 int c2 = (*zIn++); \
17251 c2 += ((*zIn++)<<8); \
17252 c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \
17253 if( (c & 0xFFFF0000)==0 ) c = 0xFFFD; \
17254 } \
17255 }
17256
17257 #define READ_UTF16BE(zIn, c){ \
17258 c = ((*zIn++)<<8); \
17259 c += (*zIn++); \
17260 if( c>=0xD800 && c<0xE000 ){ \
17261 int c2 = ((*zIn++)<<8); \
17262 c2 += (*zIn++); \
17263 c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \
17264 if( (c & 0xFFFF0000)==0 ) c = 0xFFFD; \
17265 } \
17266 }
17267
17268 /*
17269 ** Translate a single UTF-8 character. Return the unicode value.
@@ -17302,17 +17339,29 @@
17302 if( c<0x80 \
17303 || (c&0xFFFFF800)==0xD800 \
17304 || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \
17305 }
17306 SQLITE_PRIVATE int sqlite3Utf8Read(
17307 const unsigned char *z, /* First byte of UTF-8 character */
17308 const unsigned char *zTerm, /* Pretend this byte is 0x00 */
17309 const unsigned char **pzNext /* Write first byte past UTF-8 char here */
17310 ){
17311 int c;
17312 READ_UTF8(z, zTerm, c);
17313 *pzNext = z;
 
 
 
 
 
 
 
 
 
 
 
 
 
17314 return c;
17315 }
17316
17317
17318
@@ -17475,11 +17524,12 @@
17475 */
17476 SQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem){
17477 int rc = SQLITE_OK;
17478 u8 bom = 0;
17479
17480 if( pMem->n<0 || pMem->n>1 ){
 
17481 u8 b1 = *(u8 *)pMem->z;
17482 u8 b2 = *(((u8 *)pMem->z) + 1);
17483 if( b1==0xFE && b2==0xFF ){
17484 bom = SQLITE_UTF16BE;
17485 }
@@ -17541,15 +17591,14 @@
17541 ** correct UTF-8 encoding to be longer than a malformed encoding).
17542 */
17543 SQLITE_PRIVATE int sqlite3Utf8To8(unsigned char *zIn){
17544 unsigned char *zOut = zIn;
17545 unsigned char *zStart = zIn;
17546 unsigned char *zTerm = &zIn[sqlite3Strlen30((char *)zIn)];
17547 u32 c;
17548
17549 while( zIn[0] ){
17550 c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn);
17551 if( c!=0xfffd ){
17552 WRITE_UTF8(zOut, c);
17553 }
17554 }
17555 *zOut = 0;
@@ -17579,19 +17628,17 @@
17579 assert( (m.flags & MEM_Str)!=0 || db->mallocFailed );
17580 return (m.flags & MEM_Dyn)!=0 ? m.z : sqlite3DbStrDup(db, m.z);
17581 }
17582
17583 /*
17584 ** pZ is a UTF-16 encoded unicode string. If nChar is less than zero,
17585 ** return the number of bytes up to (but not including), the first pair
17586 ** of consecutive 0x00 bytes in pZ. If nChar is not less than zero,
17587 ** then return the number of bytes in the first nChar unicode characters
17588 ** in pZ (or up until the first pair of 0x00 bytes, whichever comes first).
17589 */
17590 SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *zIn, int nChar){
17591 unsigned int c = 1;
17592 char const *z = zIn;
17593 int n = 0;
17594 if( SQLITE_UTF16NATIVE==SQLITE_UTF16BE ){
17595 /* Using an "if (SQLITE_UTF16NATIVE==SQLITE_UTF16BE)" construct here
17596 ** and in other parts of this file means that at one branch will
17597 ** not be covered by coverage testing on any single host. But coverage
@@ -17599,21 +17646,21 @@
17599 ** big-endian host. Because both the UTF16NATIVE and SQLITE_UTF16BE
17600 ** macros are constant at compile time the compiler can determine
17601 ** which branch will be followed. It is therefore assumed that no runtime
17602 ** penalty is paid for this "if" statement.
17603 */
17604 while( c && ((nChar<0) || n<nChar) ){
17605 READ_UTF16BE(z, c);
17606 n++;
17607 }
17608 }else{
17609 while( c && ((nChar<0) || n<nChar) ){
17610 READ_UTF16LE(z, c);
17611 n++;
17612 }
17613 }
17614 return (int)(z-(char const *)zIn)-((c==0)?2:0);
17615 }
17616
17617 #if defined(SQLITE_TEST)
17618 /*
17619 ** This routine is called from the TCL test function "translate_selftest".
@@ -17622,23 +17669,21 @@
17622 */
17623 SQLITE_PRIVATE void sqlite3UtfSelfTest(void){
17624 unsigned int i, t;
17625 unsigned char zBuf[20];
17626 unsigned char *z;
17627 unsigned char *zTerm;
17628 int n;
17629 unsigned int c;
17630
17631 for(i=0; i<0x00110000; i++){
17632 z = zBuf;
17633 WRITE_UTF8(z, i);
17634 n = (int)(z-zBuf);
17635 assert( n>0 && n<=4 );
17636 z[0] = 0;
17637 zTerm = z;
17638 z = zBuf;
17639 c = sqlite3Utf8Read(z, zTerm, (const u8**)&z);
17640 t = i;
17641 if( i>=0xD800 && i<=0xDFFF ) t = 0xFFFD;
17642 if( (i&0xFFFFFFFE)==0xFFFE ) t = 0xFFFD;
17643 assert( c==t );
17644 assert( (z-zBuf)==n );
@@ -20521,11 +20566,11 @@
20521 ** * sqlite3_vfs method implementations.
20522 ** * Locking primitives for the proxy uber-locking-method. (MacOSX only)
20523 ** * Definitions of sqlite3_vfs objects for all locking methods
20524 ** plus implementations of sqlite3_os_init() and sqlite3_os_end().
20525 **
20526 ** $Id: os_unix.c,v 1.248 2009/03/30 07:39:35 danielk1977 Exp $
20527 */
20528 #if SQLITE_OS_UNIX /* This file is used on unix only */
20529
20530 /*
20531 ** There are various methods for file locking used for concurrency
@@ -22911,12 +22956,12 @@
22911 semUnlock(id, NO_LOCK);
22912 assert( pFile );
22913 unixEnterMutex();
22914 releaseLockInfo(pFile->pLock);
22915 releaseOpenCnt(pFile->pOpen);
22916 closeUnixFile(id);
22917 unixLeaveMutex();
 
22918 }
22919 return SQLITE_OK;
22920 }
22921
22922 #endif /* OS_VXWORKS */
@@ -23905,11 +23950,11 @@
23905 dotlockLock, /* xLock method */
23906 dotlockUnlock, /* xUnlock method */
23907 dotlockCheckReservedLock /* xCheckReservedLock method */
23908 )
23909
23910 #if SQLITE_ENABLE_LOCKING_STYLE
23911 IOMETHODS(
23912 flockIoFinder, /* Finder function name */
23913 flockIoMethods, /* sqlite3_io_methods object name */
23914 flockClose, /* xClose method */
23915 flockLock, /* xLock method */
@@ -24029,10 +24074,48 @@
24029 static const sqlite3_io_methods *(*const autolockIoFinder)(const char*,int)
24030 = autolockIoFinderImpl;
24031
24032 #endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */
24033
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24034 /*
24035 ** An abstract type for a pointer to a IO method finder function:
24036 */
24037 typedef const sqlite3_io_methods *(*finder_type)(const char*,int);
24038
@@ -24311,11 +24394,11 @@
24311 const char *zPath, /* Pathname of file to be opened */
24312 sqlite3_file *pFile, /* The file descriptor to be filled in */
24313 int flags, /* Input flags to control the opening */
24314 int *pOutFlags /* Output flags returned to SQLite core */
24315 ){
24316 int fd = 0; /* File descriptor returned by open() */
24317 int dirfd = -1; /* Directory file descriptor */
24318 int openFlags = 0; /* Flags to pass to open() */
24319 int eType = flags&0xFFFFFF00; /* Type of file to open */
24320 int noLock; /* True to omit locking primitives */
24321 int rc = SQLITE_OK;
@@ -24414,11 +24497,11 @@
24414 if( (flags & SQLITE_OPEN_MAIN_DB)!=0 ){
24415 ((unixFile*)pFile)->isLockable = 1;
24416 }
24417 #endif
24418
24419 assert(fd!=0);
24420 if( isOpenDirectory ){
24421 rc = openDirectory(zPath, &dirfd);
24422 if( rc!=SQLITE_OK ){
24423 close(fd); /* silently leak if fail, already in error */
24424 return rc;
@@ -25759,11 +25842,11 @@
25759 ** Note that the sqlite3_vfs.pNext field of the VFS object is modified
25760 ** by the SQLite core when the VFS is registered. So the following
25761 ** array cannot be const.
25762 */
25763 static sqlite3_vfs aVfs[] = {
25764 #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
25765 UNIXVFS("unix", autolockIoFinder ),
25766 #else
25767 UNIXVFS("unix", posixIoFinder ),
25768 #endif
25769 UNIXVFS("unix-none", nolockIoFinder ),
@@ -25771,11 +25854,13 @@
25771 #if OS_VXWORKS
25772 UNIXVFS("unix-namedsem", semIoFinder ),
25773 #endif
25774 #if SQLITE_ENABLE_LOCKING_STYLE
25775 UNIXVFS("unix-posix", posixIoFinder ),
 
25776 UNIXVFS("unix-flock", flockIoFinder ),
 
25777 #endif
25778 #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
25779 UNIXVFS("unix-afp", afpIoFinder ),
25780 UNIXVFS("unix-proxy", proxyIoFinder ),
25781 #endif
@@ -25816,11 +25901,11 @@
25816 **
25817 ******************************************************************************
25818 **
25819 ** This file contains code that is specific to windows.
25820 **
25821 ** $Id: os_win.c,v 1.153 2009/03/31 03:41:57 shane Exp $
25822 */
25823 #if SQLITE_OS_WIN /* This file is used for windows only */
25824
25825
25826 /*
@@ -27612,11 +27697,11 @@
27612 const char *zRelative /* UTF-8 file name */
27613 ){
27614 DWORD bytesPerSector = SQLITE_DEFAULT_SECTOR_SIZE;
27615 char zFullpath[MAX_PATH+1];
27616 int rc;
27617 DWORD dwRet = 0;
27618
27619 /*
27620 ** We need to get the full path name of the file
27621 ** to get the drive letter to look up the sector
27622 ** size.
@@ -27636,14 +27721,14 @@
27636 p[i] = '\0';
27637 break;
27638 }
27639 }
27640 dwRet = GetDiskFreeSpaceW((WCHAR*)zConverted,
27641 NULL,
27642 &bytesPerSector,
27643 NULL,
27644 NULL);
27645 #if SQLITE_OS_WINCE==0
27646 }else{
27647 int i;
27648 /* trim path to just drive reference */
27649 CHAR *p = (CHAR *)zConverted;
@@ -27653,14 +27738,14 @@
27653 p[i] = '\0';
27654 break;
27655 }
27656 }
27657 dwRet = GetDiskFreeSpaceA((CHAR*)zConverted,
27658 NULL,
27659 &bytesPerSector,
27660 NULL,
27661 NULL);
27662 #endif
27663 }
27664 free(zConverted);
27665 }
27666 if( !dwRet ){
@@ -27938,11 +28023,11 @@
27938 ** sometimes grow into tens of thousands or larger. The size of the
27939 ** Bitvec object is the number of pages in the database file at the
27940 ** start of a transaction, and is thus usually less than a few thousand,
27941 ** but can be as large as 2 billion for a really big database.
27942 **
27943 ** @(#) $Id: bitvec.c,v 1.13 2009/01/20 17:06:27 danielk1977 Exp $
27944 */
27945
27946 /* Size of the Bitvec structure in bytes. */
27947 #define BITVEC_SZ 512
27948
@@ -27997,12 +28082,13 @@
27997 ** N*iDivisor+1 and (N+1)*iDivisor. Each subbitmap is normalized
27998 ** to hold deal with values between 1 and iDivisor.
27999 */
28000 struct Bitvec {
28001 u32 iSize; /* Maximum bit index. Max iSize is 4,294,967,296. */
28002 u32 nSet; /* Number of bits that are set - only valid for aHash element */
28003 /* Max nSet is BITVEC_NINT. For BITVEC_SZ of 512, this would be 125. */
 
28004 u32 iDivisor; /* Number of bits handled by each apSub[] entry. */
28005 /* Should >=0 for apSub element. */
28006 /* Max iDivisor is max(u32) / BITVEC_NPTR + 1. */
28007 /* For a BITVEC_SZ of 512, this would be 34,359,739. */
28008 union {
@@ -28280,11 +28366,12 @@
28280 ** Bitvec object. Start with the assumption that they do
28281 ** match (rc==0). Change rc to non-zero if a discrepancy
28282 ** is found.
28283 */
28284 rc = sqlite3BitvecTest(0,0) + sqlite3BitvecTest(pBitvec, sz+1)
28285 + sqlite3BitvecTest(pBitvec, 0);
 
28286 for(i=1; i<=sz; i++){
28287 if( (TESTBIT(pV,i))!=sqlite3BitvecTest(pBitvec,i) ){
28288 rc = i;
28289 break;
28290 }
@@ -29663,11 +29750,11 @@
29663 ** the sort) then returns elements one by one by walking the list.
29664 **
29665 ** Big chunks of rowid/next-ptr pairs are allocated at a time, to
29666 ** reduce the malloc overhead.
29667 **
29668 ** $Id: rowset.c,v 1.3 2009/01/13 20:14:16 drh Exp $
29669 */
29670
29671 /*
29672 ** The number of rowset entries per allocation chunk.
29673 */
@@ -29757,11 +29844,11 @@
29757 ** memory allocation fails.
29758 */
29759 SQLITE_PRIVATE void sqlite3RowSetInsert(RowSet *p, i64 rowid){
29760 struct RowSetEntry *pEntry;
29761 struct RowSetEntry *pLast;
29762 if( p==0 ) return; /* Must have been a malloc failure */
29763 if( p->nFresh==0 ){
29764 struct RowSetChunk *pNew;
29765 pNew = sqlite3DbMallocRaw(p->db, sizeof(*pNew));
29766 if( pNew==0 ){
29767 return;
@@ -29896,11 +29983,11 @@
29896 ** is separate from the database file. The pager also implements file
29897 ** locking to prevent two processes from writing the same database
29898 ** file simultaneously, or one process from reading the database while
29899 ** another is writing.
29900 **
29901 ** @(#) $Id: pager.c,v 1.576 2009/03/31 02:54:40 drh Exp $
29902 */
29903 #ifndef SQLITE_OMIT_DISKIO
29904
29905 /*
29906 ** Macros for troubleshooting. Normally turned off
@@ -31901,15 +31988,15 @@
31901 if( rc==SQLITE_DONE ){
31902 rc = SQLITE_OK;
31903 pPager->journalOff = szJ;
31904 break;
31905 }else{
31906 /* If we are unable to rollback, then the database is probably
31907 ** going to end up being corrupt. It is corrupt to us, anyhow.
31908 ** Perhaps the next process to come along can fix it....
 
31909 */
31910 rc = SQLITE_CORRUPT_BKPT;
31911 goto end_playback;
31912 }
31913 }
31914 }
31915 }
@@ -32991,13 +33078,13 @@
32991 ** may be a wrapper capable of caching the first portion of the journal
32992 ** file in memory to implement the atomic-write optimization (see
32993 ** source file journal.c).
32994 */
32995 if( sqlite3JournalSize(pVfs)>sqlite3MemJournalSize() ){
32996 journalFileSize = sqlite3JournalSize(pVfs);
32997 }else{
32998 journalFileSize = sqlite3MemJournalSize();
32999 }
33000
33001 /* Set the output variable to NULL in case an error occurs. */
33002 *ppPager = 0;
33003
@@ -33049,27 +33136,29 @@
33049 ** Main journal file handle (journalFileSize bytes)
33050 ** Database file name (nPathname+1 bytes)
33051 ** Journal file name (nPathname+8+1 bytes)
33052 */
33053 pPtr = (u8 *)sqlite3MallocZero(
33054 sizeof(*pPager) + /* Pager structure */
33055 pcacheSize + /* PCache object */
33056 pVfs->szOsFile + /* The main db file */
33057 journalFileSize * 2 + /* The two journal files */
33058 nPathname + 1 + /* zFilename */
33059 nPathname + 8 + 1 /* zJournal */
33060 );
 
33061 if( !pPtr ){
33062 sqlite3_free(zPathname);
33063 return SQLITE_NOMEM;
33064 }
33065 pPager = (Pager*)(pPtr);
33066 pPager->pPCache = (PCache*)(pPtr += sizeof(*pPager));
33067 pPager->fd = (sqlite3_file*)(pPtr += pcacheSize);
33068 pPager->sjfd = (sqlite3_file*)(pPtr += pVfs->szOsFile);
33069 pPager->jfd = (sqlite3_file*)(pPtr += journalFileSize);
33070 pPager->zFilename = (char*)(pPtr += journalFileSize);
 
33071
33072 /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */
33073 if( zPathname ){
33074 pPager->zJournal = (char*)(pPtr += nPathname + 1);
33075 memcpy(pPager->zFilename, zPathname, nPathname);
@@ -34951,18 +35040,15 @@
34951 pPg->flags &= ~PGHDR_NEED_SYNC;
34952 pPgOld = pager_lookup(pPager, pgno);
34953 assert( !pPgOld || pPgOld->nRef==1 );
34954 if( pPgOld ){
34955 pPg->flags |= (pPgOld->flags&PGHDR_NEED_SYNC);
 
34956 }
34957
34958 origPgno = pPg->pgno;
34959 sqlite3PcacheMove(pPg, pgno);
34960 if( pPgOld ){
34961 sqlite3PcacheDrop(pPgOld);
34962 }
34963
34964 sqlite3PcacheMakeDirty(pPg);
34965 pPager->dbModified = 1;
34966
34967 if( needSyncPgno ){
34968 /* If needSyncPgno is non-zero, then the journal file needs to be
@@ -35063,34 +35149,37 @@
35063 ** PAGER_JOURNALMODE_PERSIST
35064 ** PAGER_JOURNALMODE_OFF
35065 ** PAGER_JOURNALMODE_MEMORY
35066 **
35067 ** If the parameter is not _QUERY, then the journal-mode is set to the
35068 ** value specified.
 
 
 
35069 **
35070 ** The returned indicate the current (possibly updated) journal-mode.
35071 */
35072 SQLITE_PRIVATE int sqlite3PagerJournalMode(Pager *pPager, int eMode){
35073 if( !MEMDB ){
35074 assert( eMode==PAGER_JOURNALMODE_QUERY
35075 || eMode==PAGER_JOURNALMODE_DELETE
35076 || eMode==PAGER_JOURNALMODE_TRUNCATE
35077 || eMode==PAGER_JOURNALMODE_PERSIST
35078 || eMode==PAGER_JOURNALMODE_OFF
35079 || eMode==PAGER_JOURNALMODE_MEMORY );
35080 assert( PAGER_JOURNALMODE_QUERY<0 );
35081 if( eMode>=0 ){
35082 pPager->journalMode = (u8)eMode;
35083 }else{
35084 assert( eMode==PAGER_JOURNALMODE_QUERY );
35085 }
35086 }
35087 return (int)pPager->journalMode;
35088 }
35089
35090 /*
35091 ** Get/set the size-limit used for persistent journal files.
 
 
 
35092 */
35093 SQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *pPager, i64 iLimit){
35094 if( iLimit>=-1 ){
35095 pPager->journalSizeLimit = iLimit;
35096 }
@@ -35121,11 +35210,11 @@
35121 ** May you find forgiveness for yourself and forgive others.
35122 ** May you share freely, never taking more than you give.
35123 **
35124 *************************************************************************
35125 **
35126 ** $Id: btmutex.c,v 1.13 2009/03/05 04:20:32 shane Exp $
35127 **
35128 ** This file contains code used to implement mutexes on Btree objects.
35129 ** This code really belongs in btree.c. But btree.c is getting too
35130 ** big and we want to break it down some. This packaged seemed like
35131 ** a good breakout.
@@ -35773,12 +35862,41 @@
35773 SQLITE_PRIVATE void sqlite3BtreeReleaseTempCursor(BtCursor *pCur);
35774 SQLITE_PRIVATE void sqlite3BtreeMoveToParent(BtCursor *pCur);
35775
35776 /************** End of btreeInt.h ********************************************/
35777 /************** Continuing where we left off in btmutex.c ********************/
35778 #if SQLITE_THREADSAFE && !defined(SQLITE_OMIT_SHARED_CACHE)
 
35779
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35780
35781 /*
35782 ** Enter a mutex on the given BTree object.
35783 **
35784 ** If the object is not sharable, then no mutex is ever required
@@ -35812,19 +35930,24 @@
35812 assert( p->sharable || p->wantToLock==0 );
35813
35814 /* We should already hold a lock on the database connection */
35815 assert( sqlite3_mutex_held(p->db->mutex) );
35816
 
 
 
 
35817 if( !p->sharable ) return;
35818 p->wantToLock++;
35819 if( p->locked ) return;
35820
35821 /* In most cases, we should be able to acquire the lock we
35822 ** want without having to go throught the ascending lock
35823 ** procedure that follows. Just be sure not to block.
35824 */
35825 if( sqlite3_mutex_try(p->pBt->mutex)==SQLITE_OK ){
 
35826 p->locked = 1;
35827 return;
35828 }
35829
35830 /* To avoid deadlock, first release all locks with a larger
@@ -35835,20 +35958,17 @@
35835 for(pLater=p->pNext; pLater; pLater=pLater->pNext){
35836 assert( pLater->sharable );
35837 assert( pLater->pNext==0 || pLater->pNext->pBt>pLater->pBt );
35838 assert( !pLater->locked || pLater->wantToLock>0 );
35839 if( pLater->locked ){
35840 sqlite3_mutex_leave(pLater->pBt->mutex);
35841 pLater->locked = 0;
35842 }
35843 }
35844 sqlite3_mutex_enter(p->pBt->mutex);
35845 p->locked = 1;
35846 for(pLater=p->pNext; pLater; pLater=pLater->pNext){
35847 if( pLater->wantToLock ){
35848 sqlite3_mutex_enter(pLater->pBt->mutex);
35849 pLater->locked = 1;
35850 }
35851 }
35852 }
35853
35854 /*
@@ -35857,29 +35977,29 @@
35857 SQLITE_PRIVATE void sqlite3BtreeLeave(Btree *p){
35858 if( p->sharable ){
35859 assert( p->wantToLock>0 );
35860 p->wantToLock--;
35861 if( p->wantToLock==0 ){
35862 assert( p->locked );
35863 sqlite3_mutex_leave(p->pBt->mutex);
35864 p->locked = 0;
35865 }
35866 }
35867 }
35868
35869 #ifndef NDEBUG
35870 /*
35871 ** Return true if the BtShared mutex is held on the btree.
35872 **
35873 ** This routine makes no determination one way or another if the
35874 ** database connection mutex is held.
35875 **
35876 ** This routine is used only from within assert() statements.
35877 */
35878 SQLITE_PRIVATE int sqlite3BtreeHoldsMutex(Btree *p){
35879 return (p->sharable==0 ||
35880 (p->locked && p->wantToLock && sqlite3_mutex_held(p->pBt->mutex)));
 
 
 
 
35881 }
35882 #endif
35883
35884
35885 #ifndef SQLITE_OMIT_INCRBLOB
@@ -35915,25 +36035,24 @@
35915 int i;
35916 Btree *p, *pLater;
35917 assert( sqlite3_mutex_held(db->mutex) );
35918 for(i=0; i<db->nDb; i++){
35919 p = db->aDb[i].pBt;
 
35920 if( p && p->sharable ){
35921 p->wantToLock++;
35922 if( !p->locked ){
35923 assert( p->wantToLock==1 );
35924 while( p->pPrev ) p = p->pPrev;
35925 while( p->locked && p->pNext ) p = p->pNext;
35926 for(pLater = p->pNext; pLater; pLater=pLater->pNext){
35927 if( pLater->locked ){
35928 sqlite3_mutex_leave(pLater->pBt->mutex);
35929 pLater->locked = 0;
35930 }
35931 }
35932 while( p ){
35933 sqlite3_mutex_enter(p->pBt->mutex);
35934 p->locked++;
35935 p = p->pNext;
35936 }
35937 }
35938 }
35939 }
@@ -35946,13 +36065,11 @@
35946 p = db->aDb[i].pBt;
35947 if( p && p->sharable ){
35948 assert( p->wantToLock>0 );
35949 p->wantToLock--;
35950 if( p->wantToLock==0 ){
35951 assert( p->locked );
35952 sqlite3_mutex_leave(p->pBt->mutex);
35953 p->locked = 0;
35954 }
35955 }
35956 }
35957 }
35958
@@ -36037,12 +36154,11 @@
36037 /* We should already hold a lock on the database connection */
36038 assert( sqlite3_mutex_held(p->db->mutex) );
36039
36040 p->wantToLock++;
36041 if( !p->locked && p->sharable ){
36042 sqlite3_mutex_enter(p->pBt->mutex);
36043 p->locked = 1;
36044 }
36045 }
36046 }
36047
36048 /*
@@ -36060,18 +36176,30 @@
36060 /* We should already hold a lock on the database connection */
36061 assert( sqlite3_mutex_held(p->db->mutex) );
36062
36063 p->wantToLock--;
36064 if( p->wantToLock==0 && p->locked ){
36065 sqlite3_mutex_leave(p->pBt->mutex);
36066 p->locked = 0;
36067 }
36068 }
36069 }
36070
36071
36072 #endif /* SQLITE_THREADSAFE && !SQLITE_OMIT_SHARED_CACHE */
 
 
 
 
 
 
 
 
 
 
 
 
 
36073
36074 /************** End of btmutex.c *********************************************/
36075 /************** Begin file btree.c *******************************************/
36076 /*
36077 ** 2004 April 6
@@ -36082,11 +36210,11 @@
36082 ** May you do good and not evil.
36083 ** May you find forgiveness for yourself and forgive others.
36084 ** May you share freely, never taking more than you give.
36085 **
36086 *************************************************************************
36087 ** $Id: btree.c,v 1.582 2009/03/30 18:50:05 danielk1977 Exp $
36088 **
36089 ** This file implements a external (disk-based) database using BTrees.
36090 ** See the header comment on "btreeInt.h" for additional information.
36091 ** Including a description of file format and an overview of operation.
36092 */
@@ -36175,10 +36303,17 @@
36175
36176 assert( sqlite3BtreeHoldsMutex(p) );
36177 assert( eLock==READ_LOCK || eLock==WRITE_LOCK );
36178 assert( p->db!=0 );
36179
 
 
 
 
 
 
 
36180 /* This is a no-op if the shared-cache is not enabled */
36181 if( !p->sharable ){
36182 return SQLITE_OK;
36183 }
36184
@@ -36210,12 +36345,22 @@
36210 0==(p->db->flags&SQLITE_ReadUncommitted) ||
36211 eLock==WRITE_LOCK ||
36212 iTab==MASTER_ROOT
36213 ){
36214 for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){
36215 if( pIter->pBtree!=p && pIter->iTable==iTab &&
36216 (pIter->eLock!=eLock || eLock!=READ_LOCK) ){
 
 
 
 
 
 
 
 
 
 
36217 sqlite3ConnectionBlocked(p->db, pIter->pBtree->db);
36218 if( eLock==WRITE_LOCK ){
36219 assert( p==pBt->pWriter );
36220 pBt->isPending = 1;
36221 }
@@ -36303,21 +36448,27 @@
36303
36304 #ifndef SQLITE_OMIT_SHARED_CACHE
36305 /*
36306 ** Release all the table locks (locks obtained via calls to
36307 ** the setSharedCacheTableLock() procedure) held by Btree handle p.
 
 
 
 
36308 */
36309 static void clearAllSharedCacheTableLocks(Btree *p){
36310 BtShared *pBt = p->pBt;
36311 BtLock **ppIter = &pBt->pLock;
36312
36313 assert( sqlite3BtreeHoldsMutex(p) );
36314 assert( p->sharable || 0==*ppIter );
 
36315
36316 while( *ppIter ){
36317 BtLock *pLock = *ppIter;
36318 assert( pBt->isExclusive==0 || pBt->pWriter==pLock->pBtree );
 
36319 if( pLock->pBtree==p ){
36320 *ppIter = pLock->pNext;
36321 sqlite3_free(pLock);
36322 }else{
36323 ppIter = &pLock->pNext;
@@ -36920,76 +37071,78 @@
36920 }
36921 return SQLITE_OK;
36922 }
36923
36924 /*
36925 ** Allocate nByte bytes of space on a page.
36926 **
36927 ** Return the index into pPage->aData[] of the first byte of
36928 ** the new allocation. The caller guarantees that there is enough
36929 ** space. This routine will never fail.
36930 **
36931 ** If the page contains nBytes of free space but does not contain
36932 ** nBytes of contiguous free space, then this routine automatically
36933 ** calls defragmentPage() to consolidate all free space before
36934 ** allocating the new chunk.
 
 
 
36935 */
36936 static int allocateSpace(MemPage *pPage, int nByte){
36937 int addr, pc, hdr;
36938 int size;
36939 int nFrag;
36940 int top;
36941 int nCell;
36942 int cellOffset;
36943 unsigned char *data;
36944
36945 data = pPage->aData;
36946 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
36947 assert( pPage->pBt );
36948 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
36949 assert( nByte>=0 ); /* Minimum cell size is 4 */
36950 assert( pPage->nFree>=nByte );
36951 assert( pPage->nOverflow==0 );
 
 
 
 
 
 
 
 
36952 pPage->nFree -= (u16)nByte;
36953 hdr = pPage->hdrOffset;
36954
36955 nFrag = data[hdr+7];
36956 if( nFrag<60 ){
36957 /* Search the freelist looking for a slot big enough to satisfy the
36958 ** space request. */
36959 addr = hdr+1;
36960 while( (pc = get2byte(&data[addr]))>0 ){
36961 size = get2byte(&data[pc+2]);
 
 
 
 
36962 if( size>=nByte ){
36963 int x = size - nByte;
36964 if( size<nByte+4 ){
 
 
36965 memcpy(&data[addr], &data[pc], 2);
36966 data[hdr+7] = (u8)(nFrag + x);
36967 return pc;
36968 }else{
 
 
36969 put2byte(&data[pc+2], x);
36970 return pc + x;
36971 }
 
36972 }
36973 addr = pc;
36974 }
36975 }
36976
36977 /* Allocate memory from the gap in between the cell pointer array
36978 ** and the cell content area.
36979 */
36980 top = get2byte(&data[hdr+5]);
36981 nCell = get2byte(&data[hdr+3]);
36982 cellOffset = pPage->cellOffset;
36983 if( nFrag>=60 || cellOffset + 2*nCell > top - nByte ){
36984 defragmentPage(pPage);
36985 top = get2byte(&data[hdr+5]);
36986 }
36987 top -= nByte;
36988 assert( cellOffset + 2*nCell <= top );
36989 put2byte(&data[hdr+5], top);
36990 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
36991 return top;
36992 }
36993
36994 /*
36995 ** Return a section of the pPage->aData to the freelist.
@@ -37373,14 +37526,15 @@
37373 ** page to agree with the restored data.
37374 */
37375 static void pageReinit(DbPage *pData){
37376 MemPage *pPage;
37377 pPage = (MemPage *)sqlite3PagerGetExtra(pData);
 
37378 if( pPage->isInit ){
37379 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
37380 pPage->isInit = 0;
37381 if( sqlite3PagerPageRefcount(pData)>0 ){
37382 /* pPage might not be a btree page; it might be an overflow page
37383 ** or ptrmap page or a free page. In those cases, the following
37384 ** call to sqlite3BtreeInitPage() will likely return SQLITE_CORRUPT.
37385 ** But no harm is done by this. And it is very important that
37386 ** sqlite3BtreeInitPage() be called on every btree page so we make
@@ -37451,14 +37605,11 @@
37451 #if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)
37452 /*
37453 ** If this Btree is a candidate for shared cache, try to find an
37454 ** existing BtShared object that we can share with
37455 */
37456 if( isMemdb==0
37457 && (db->flags & SQLITE_Vtab)==0
37458 && zFilename && zFilename[0]
37459 ){
37460 if( sqlite3GlobalConfig.sharedCacheEnabled ){
37461 int nFullPathname = pVfs->mxPathname+1;
37462 char *zFullPathname = sqlite3Malloc(nFullPathname);
37463 sqlite3_mutex *mutexShared;
37464 p->sharable = 1;
@@ -37519,10 +37670,11 @@
37519 rc = sqlite3PagerReadFileheader(pBt->pPager,sizeof(zDbHeader),zDbHeader);
37520 }
37521 if( rc!=SQLITE_OK ){
37522 goto btree_open_out;
37523 }
 
37524 sqlite3PagerSetBusyhandler(pBt->pPager, btreeInvokeBusyHandler, pBt);
37525 p->pBt = pBt;
37526
37527 sqlite3PagerSetReiniter(pBt->pPager, pageReinit);
37528 pBt->pCursor = 0;
@@ -37696,11 +37848,10 @@
37696 BtCursor *pCur;
37697
37698 /* Close all cursors opened via this handle. */
37699 assert( sqlite3_mutex_held(p->db->mutex) );
37700 sqlite3BtreeEnter(p);
37701 pBt->db = p->db;
37702 pCur = pBt->pCursor;
37703 while( pCur ){
37704 BtCursor *pTmp = pCur;
37705 pCur = pCur->pNext;
37706 if( pTmp->pBtree==p ){
@@ -37806,10 +37957,12 @@
37806 }
37807
37808 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) || !defined(SQLITE_OMIT_VACUUM)
37809 /*
37810 ** Change the default pages size and the number of reserved bytes per page.
 
 
37811 **
37812 ** The page size must be a power of 2 between 512 and 65536. If the page
37813 ** size supplied does not meet this constraint then the page size is not
37814 ** changed.
37815 **
@@ -37818,12 +37971,15 @@
37818 ** the first byte past the 1GB boundary, 0x40000000) needs to occur
37819 ** at the beginning of a page.
37820 **
37821 ** If parameter nReserve is less than zero, then the number of reserved
37822 ** bytes per page is left unchanged.
 
 
 
37823 */
37824 SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int pageSize, int nReserve){
37825 int rc = SQLITE_OK;
37826 BtShared *pBt = p->pBt;
37827 assert( nReserve>=-1 && nReserve<=255 );
37828 sqlite3BtreeEnter(p);
37829 if( pBt->pageSizeFixed ){
@@ -37841,10 +37997,11 @@
37841 pBt->pageSize = (u16)pageSize;
37842 freeTempSpace(pBt);
37843 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize);
37844 }
37845 pBt->usableSize = pBt->pageSize - (u16)nReserve;
 
37846 sqlite3BtreeLeave(p);
37847 return rc;
37848 }
37849
37850 /*
@@ -37941,11 +38098,11 @@
37941 int rc;
37942 MemPage *pPage1;
37943 int nPage;
37944
37945 assert( sqlite3_mutex_held(pBt->mutex) );
37946 if( pBt->pPage1 ) return SQLITE_OK;
37947 rc = sqlite3BtreeGetPage(pBt, 1, &pPage1, 0);
37948 if( rc!=SQLITE_OK ) return rc;
37949
37950 /* Do some checking to help insure the file we opened really is
37951 ** a valid database file.
@@ -38169,11 +38326,10 @@
38169 sqlite3 *pBlock = 0;
38170 BtShared *pBt = p->pBt;
38171 int rc = SQLITE_OK;
38172
38173 sqlite3BtreeEnter(p);
38174 pBt->db = p->db;
38175 btreeIntegrity(p);
38176
38177 /* If the btree is already in a write-transaction, or it
38178 ** is already in a read-transaction and a read-transaction
38179 ** is requested, this is a no-op.
@@ -38210,15 +38366,18 @@
38210 goto trans_begun;
38211 }
38212 #endif
38213
38214 do {
38215 if( pBt->pPage1==0 ){
38216 do{
38217 rc = lockBtree(pBt);
38218 }while( pBt->pPage1==0 && rc==SQLITE_OK );
38219 }
 
 
 
38220
38221 if( rc==SQLITE_OK && wrflag ){
38222 if( pBt->readOnly ){
38223 rc = SQLITE_READONLY;
38224 }else{
@@ -38313,11 +38472,11 @@
38313 pPage->isInit = isInitOrig;
38314 return rc;
38315 }
38316
38317 /*
38318 ** Somewhere on pPage, which is guarenteed to be a btree page, not an overflow
38319 ** page, is a pointer to page iFrom. Modify this pointer so that it points to
38320 ** iTo. Parameter eType describes the type of pointer to be modified, as
38321 ** follows:
38322 **
38323 ** PTRMAP_BTREE: pPage is a btree-page. The pointer points at a child
@@ -38476,18 +38635,19 @@
38476 */
38477 static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg){
38478 Pgno nFreeList; /* Number of pages still on the free-list */
38479
38480 assert( sqlite3_mutex_held(pBt->mutex) );
 
38481
38482 if( !PTRMAP_ISPAGE(pBt, iLastPg) && iLastPg!=PENDING_BYTE_PAGE(pBt) ){
38483 int rc;
38484 u8 eType;
38485 Pgno iPtrPage;
38486
38487 nFreeList = get4byte(&pBt->pPage1->aData[36]);
38488 if( nFreeList==0 || nFin==iLastPg ){
38489 return SQLITE_DONE;
38490 }
38491
38492 rc = ptrmapGet(pBt, iLastPg, &eType, &iPtrPage);
38493 if( rc!=SQLITE_OK ){
@@ -38584,11 +38744,10 @@
38584 SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *p){
38585 int rc;
38586 BtShared *pBt = p->pBt;
38587
38588 sqlite3BtreeEnter(p);
38589 pBt->db = p->db;
38590 assert( pBt->inTransaction==TRANS_WRITE && p->inTrans==TRANS_WRITE );
38591 if( !pBt->autoVacuum ){
38592 rc = SQLITE_DONE;
38593 }else{
38594 invalidateAllOverflowCache(pBt);
@@ -38621,20 +38780,22 @@
38621 Pgno nPtrmap;
38622 Pgno iFree;
38623 const int pgsz = pBt->pageSize;
38624 Pgno nOrig = pagerPagecount(pBt);
38625
38626 if( PTRMAP_ISPAGE(pBt, nOrig) ){
 
 
 
 
38627 return SQLITE_CORRUPT_BKPT;
38628 }
38629 if( nOrig==PENDING_BYTE_PAGE(pBt) ){
38630 nOrig--;
38631 }
38632 nFree = get4byte(&pBt->pPage1->aData[36]);
38633 nPtrmap = (nFree-nOrig+PTRMAP_PAGENO(pBt, nOrig)+pgsz/5)/(pgsz/5);
38634 nFin = nOrig - nFree - nPtrmap;
38635 if( nOrig>PENDING_BYTE_PAGE(pBt) && nFin<=PENDING_BYTE_PAGE(pBt) ){
38636 nFin--;
38637 }
38638 while( PTRMAP_ISPAGE(pBt, nFin) || nFin==PENDING_BYTE_PAGE(pBt) ){
38639 nFin--;
38640 }
@@ -38689,11 +38850,10 @@
38689 SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree *p, const char *zMaster){
38690 int rc = SQLITE_OK;
38691 if( p->inTrans==TRANS_WRITE ){
38692 BtShared *pBt = p->pBt;
38693 sqlite3BtreeEnter(p);
38694 pBt->db = p->db;
38695 #ifndef SQLITE_OMIT_AUTOVACUUM
38696 if( pBt->autoVacuum ){
38697 rc = autoVacuumCommit(pBt);
38698 if( rc!=SQLITE_OK ){
38699 sqlite3BtreeLeave(p);
@@ -38723,11 +38883,10 @@
38723 */
38724 SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree *p){
38725 BtShared *pBt = p->pBt;
38726
38727 sqlite3BtreeEnter(p);
38728 pBt->db = p->db;
38729 btreeIntegrity(p);
38730
38731 /* If the handle has a write-transaction open, commit the shared-btrees
38732 ** transaction and set the shared state to TRANS_READ.
38733 */
@@ -38740,18 +38899,18 @@
38740 sqlite3BtreeLeave(p);
38741 return rc;
38742 }
38743 pBt->inTransaction = TRANS_READ;
38744 }
38745 clearAllSharedCacheTableLocks(p);
38746
38747 /* If the handle has any kind of transaction open, decrement the transaction
38748 ** count of the shared btree. If the transaction count reaches 0, set
38749 ** the shared state to TRANS_NONE. The unlockBtreeIfUnused() call below
38750 ** will unlock the pager.
38751 */
38752 if( p->inTrans!=TRANS_NONE ){
 
38753 pBt->nTransaction--;
38754 if( 0==pBt->nTransaction ){
38755 pBt->inTransaction = TRANS_NONE;
38756 }
38757 }
@@ -38849,11 +39008,10 @@
38849 int rc;
38850 BtShared *pBt = p->pBt;
38851 MemPage *pPage1;
38852
38853 sqlite3BtreeEnter(p);
38854 pBt->db = p->db;
38855 rc = saveAllCursors(pBt, 0, 0);
38856 #ifndef SQLITE_OMIT_SHARED_CACHE
38857 if( rc!=SQLITE_OK ){
38858 /* This is a horrible situation. An IO or malloc() error occurred whilst
38859 ** trying to save cursor positions. If this is an automatic rollback (as
@@ -38864,11 +39022,10 @@
38864 */
38865 sqlite3BtreeTripAllCursors(p, rc);
38866 }
38867 #endif
38868 btreeIntegrity(p);
38869 clearAllSharedCacheTableLocks(p);
38870
38871 if( p->inTrans==TRANS_WRITE ){
38872 int rc2;
38873
38874 assert( TRANS_WRITE==pBt->inTransaction );
@@ -38886,10 +39043,11 @@
38886 assert( countWriteCursors(pBt)==0 );
38887 pBt->inTransaction = TRANS_READ;
38888 }
38889
38890 if( p->inTrans!=TRANS_NONE ){
 
38891 assert( pBt->nTransaction>0 );
38892 pBt->nTransaction--;
38893 if( 0==pBt->nTransaction ){
38894 pBt->inTransaction = TRANS_NONE;
38895 }
@@ -38924,11 +39082,10 @@
38924 */
38925 SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree *p, int iStatement){
38926 int rc;
38927 BtShared *pBt = p->pBt;
38928 sqlite3BtreeEnter(p);
38929 pBt->db = p->db;
38930 assert( p->inTrans==TRANS_WRITE );
38931 assert( pBt->readOnly==0 );
38932 assert( iStatement>0 );
38933 assert( iStatement>p->db->nSavepoint );
38934 if( NEVER(p->inTrans!=TRANS_WRITE || pBt->readOnly) ){
@@ -38963,11 +39120,10 @@
38963 if( p && p->inTrans==TRANS_WRITE ){
38964 BtShared *pBt = p->pBt;
38965 assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );
38966 assert( iSavepoint>=0 || (iSavepoint==-1 && op==SAVEPOINT_ROLLBACK) );
38967 sqlite3BtreeEnter(p);
38968 pBt->db = p->db;
38969 rc = sqlite3PagerSavepoint(pBt->pPager, op, iSavepoint);
38970 if( rc==SQLITE_OK ){
38971 rc = newDatabase(pBt);
38972 }
38973 sqlite3BtreeLeave(p);
@@ -39080,11 +39236,10 @@
39080 struct KeyInfo *pKeyInfo, /* First arg to xCompare() */
39081 BtCursor *pCur /* Write new cursor here */
39082 ){
39083 int rc;
39084 sqlite3BtreeEnter(p);
39085 p->pBt->db = p->db;
39086 rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);
39087 sqlite3BtreeLeave(p);
39088 return rc;
39089 }
39090
@@ -39138,11 +39293,10 @@
39138 Btree *pBtree = pCur->pBtree;
39139 if( pBtree ){
39140 int i;
39141 BtShared *pBt = pCur->pBt;
39142 sqlite3BtreeEnter(pBtree);
39143 pBt->db = pBtree->db;
39144 sqlite3BtreeClearCursor(pCur);
39145 if( pCur->pPrev ){
39146 pCur->pPrev->pNext = pCur->pNext;
39147 }else{
39148 pBt->pCursor = pCur->pNext;
@@ -40116,11 +40270,12 @@
40116 int bias, /* Bias search to the high end */
40117 int *pRes /* Write search results here */
40118 ){
40119 int rc; /* Status code */
40120 UnpackedRecord *pIdxKey; /* Unpacked index key */
40121 UnpackedRecord aSpace[16]; /* Temp space for pIdxKey - to avoid a malloc */
 
40122
40123 if( pKey ){
40124 assert( nKey==(i64)(int)nKey );
40125 pIdxKey = sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey,
40126 aSpace, sizeof(aSpace));
@@ -40717,11 +40872,14 @@
40717 nOvfl = (info.nPayload - info.nLocal + ovflPageSize - 1)/ovflPageSize;
40718 assert( ovflPgno==0 || nOvfl>0 );
40719 while( nOvfl-- ){
40720 Pgno iNext = 0;
40721 MemPage *pOvfl = 0;
40722 if( ovflPgno==0 || ovflPgno>pagerPagecount(pBt) ){
 
 
 
40723 return SQLITE_CORRUPT_BKPT;
40724 }
40725 if( nOvfl ){
40726 rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext);
40727 if( rc ) return rc;
@@ -41396,17 +41554,17 @@
41396 rc = SQLITE_NOMEM;
41397 goto balance_cleanup;
41398 }
41399 szCell = (u16*)&apCell[nMaxCells];
41400 aCopy[0] = (u8*)&szCell[nMaxCells];
41401 assert( ((aCopy[0] - (u8*)0) & 7)==0 ); /* 8-byte alignment required */
41402 for(i=1; i<NB; i++){
41403 aCopy[i] = &aCopy[i-1][pBt->pageSize+ROUND8(sizeof(MemPage))];
41404 assert( ((aCopy[i] - (u8*)0) & 7)==0 ); /* 8-byte alignment required */
41405 }
41406 aSpace1 = &aCopy[NB-1][pBt->pageSize+ROUND8(sizeof(MemPage))];
41407 assert( ((aSpace1 - (u8*)0) & 7)==0 ); /* 8-byte alignment required */
41408 if( ISAUTOVACUUM ){
41409 aFrom = &aSpace1[pBt->pageSize];
41410 }
41411 aSpace2 = sqlite3PageMalloc(pBt->pageSize);
41412 if( aSpace2==0 ){
@@ -42388,12 +42546,12 @@
42388 rc = saveCursorPosition(&leafCur);
42389 if( rc==SQLITE_OK ){
42390 rc = sqlite3BtreeNext(&leafCur, &notUsed);
42391 }
42392 pLeafPage = leafCur.apPage[leafCur.iPage];
42393 assert( pLeafPage->pgno==leafPgno );
42394 assert( leafCur.aiIdx[leafCur.iPage]==0 );
42395 }
42396
42397 if( SQLITE_OK==rc
42398 && SQLITE_OK==(rc = sqlite3PagerWrite(pLeafPage->pDbPage))
42399 ){
@@ -42553,11 +42711,10 @@
42553 return SQLITE_OK;
42554 }
42555 SQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree *p, int *piTable, int flags){
42556 int rc;
42557 sqlite3BtreeEnter(p);
42558 p->pBt->db = p->db;
42559 rc = btreeCreateTable(p, piTable, flags);
42560 sqlite3BtreeLeave(p);
42561 return rc;
42562 }
42563
@@ -42625,11 +42782,10 @@
42625 */
42626 SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){
42627 int rc;
42628 BtShared *pBt = p->pBt;
42629 sqlite3BtreeEnter(p);
42630 pBt->db = p->db;
42631 assert( p->inTrans==TRANS_WRITE );
42632 if( (rc = checkForReadConflicts(p, iTable, 0, 1))!=SQLITE_OK ){
42633 /* nothing to do */
42634 }else if( SQLITE_OK!=(rc = saveAllCursors(pBt, iTable, 0)) ){
42635 /* nothing to do */
@@ -42767,11 +42923,10 @@
42767 return rc;
42768 }
42769 SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree *p, int iTable, int *piMoved){
42770 int rc;
42771 sqlite3BtreeEnter(p);
42772 p->pBt->db = p->db;
42773 rc = btreeDropTable(p, iTable, piMoved);
42774 sqlite3BtreeLeave(p);
42775 return rc;
42776 }
42777
@@ -42791,11 +42946,10 @@
42791 int rc;
42792 unsigned char *pP1;
42793 BtShared *pBt = p->pBt;
42794
42795 sqlite3BtreeEnter(p);
42796 pBt->db = p->db;
42797
42798 /* Reading a meta-data value requires a read-lock on page 1 (and hence
42799 ** the sqlite_master table. We grab this lock regardless of whether or
42800 ** not the SQLITE_ReadUncommitted flag is set (the table rooted at page
42801 ** 1 is treated as a special case by querySharedCacheTableLock()
@@ -42840,12 +42994,18 @@
42840 */
42841 #ifdef SQLITE_OMIT_AUTOVACUUM
42842 if( idx==4 && *pMeta>0 ) pBt->readOnly = 1;
42843 #endif
42844
42845 /* Grab the read-lock on page 1. */
42846 rc = setSharedCacheTableLock(p, 1, READ_LOCK);
 
 
 
 
 
 
42847 sqlite3BtreeLeave(p);
42848 return rc;
42849 }
42850
42851 /*
@@ -42856,11 +43016,10 @@
42856 BtShared *pBt = p->pBt;
42857 unsigned char *pP1;
42858 int rc;
42859 assert( idx>=1 && idx<=15 );
42860 sqlite3BtreeEnter(p);
42861 pBt->db = p->db;
42862 assert( p->inTrans==TRANS_WRITE );
42863 assert( pBt->pPage1!=0 );
42864 pP1 = pBt->pPage1->aData;
42865 rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
42866 if( rc==SQLITE_OK ){
@@ -43330,11 +43489,10 @@
43330 IntegrityCk sCheck;
43331 BtShared *pBt = p->pBt;
43332 char zErr[100];
43333
43334 sqlite3BtreeEnter(p);
43335 pBt->db = p->db;
43336 nRef = sqlite3PagerRefcount(pBt->pPager);
43337 if( lockBtreeWithRetry(p)!=SQLITE_OK ){
43338 *pnErr = 1;
43339 sqlite3BtreeLeave(p);
43340 return sqlite3DbStrDup(0, "cannot acquire a read lock on the database");
@@ -44240,11 +44398,11 @@
44240 ** This file contains code use to manipulate "Mem" structure. A "Mem"
44241 ** stores a single value in the VDBE. Mem is an opaque structure visible
44242 ** only within the VDBE. Interface routines refer to a Mem using the
44243 ** name sqlite_value
44244 **
44245 ** $Id: vdbemem.c,v 1.139 2009/03/29 15:12:10 drh Exp $
44246 */
44247
44248 /*
44249 ** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem*)
44250 ** P if required.
@@ -44432,10 +44590,11 @@
44432 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
44433 assert( !(fg&MEM_Zero) );
44434 assert( !(fg&(MEM_Str|MEM_Blob)) );
44435 assert( fg&(MEM_Int|MEM_Real) );
44436 assert( (pMem->flags&MEM_RowSet)==0 );
 
44437
44438
44439 if( sqlite3VdbeMemGrow(pMem, nByte, 0) ){
44440 return SQLITE_NOMEM;
44441 }
@@ -44568,10 +44727,11 @@
44568 ** If pMem represents a string value, its encoding might be changed.
44569 */
44570 SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){
44571 int flags;
44572 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
 
44573 flags = pMem->flags;
44574 if( flags & MEM_Int ){
44575 return pMem->u.i;
44576 }else if( flags & MEM_Real ){
44577 return doubleToInt64(pMem->r);
@@ -44596,10 +44756,11 @@
44596 ** value. If it is a string or blob, try to convert it to a double.
44597 ** If it is a NULL, return 0.0.
44598 */
44599 SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){
44600 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
 
44601 if( pMem->flags & MEM_Real ){
44602 return pMem->r;
44603 }else if( pMem->flags & MEM_Int ){
44604 return (double)pMem->u.i;
44605 }else if( pMem->flags & (MEM_Str|MEM_Blob) ){
@@ -44626,10 +44787,11 @@
44626 */
44627 SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){
44628 assert( pMem->flags & MEM_Real );
44629 assert( (pMem->flags & MEM_RowSet)==0 );
44630 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
 
44631
44632 pMem->u.i = doubleToInt64(pMem->r);
44633 if( pMem->r==(double)pMem->u.i ){
44634 pMem->flags |= MEM_Int;
44635 }
@@ -44639,10 +44801,12 @@
44639 ** Convert pMem to type integer. Invalidate any prior representations.
44640 */
44641 SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){
44642 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
44643 assert( (pMem->flags & MEM_RowSet)==0 );
 
 
44644 pMem->u.i = sqlite3VdbeIntValue(pMem);
44645 MemSetTypeFlag(pMem, MEM_Int);
44646 return SQLITE_OK;
44647 }
44648
@@ -44650,10 +44814,12 @@
44650 ** Convert pMem so that it is of type MEM_Real.
44651 ** Invalidate any prior representations.
44652 */
44653 SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){
44654 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
 
 
44655 pMem->r = sqlite3VdbeRealValue(pMem);
44656 MemSetTypeFlag(pMem, MEM_Real);
44657 return SQLITE_OK;
44658 }
44659
@@ -45287,11 +45453,11 @@
45287 ** This file contains code used for creating, destroying, and populating
45288 ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior
45289 ** to version 2.8.7, all this code was combined into the vdbe.c source file.
45290 ** But that file was getting too big so this subroutines were split out.
45291 **
45292 ** $Id: vdbeaux.c,v 1.446 2009/03/25 15:43:09 danielk1977 Exp $
45293 */
45294
45295
45296
45297 /*
@@ -46294,10 +46460,11 @@
46294 int nByte, /* Number of bytes to allocate */
46295 u8 **ppFrom, /* IN/OUT: Allocate from *ppFrom */
46296 u8 *pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */
46297 int *pnByte /* If allocation cannot be made, increment *pnByte */
46298 ){
 
46299 if( (*(void**)pp)==0 ){
46300 nByte = ROUND8(nByte);
46301 if( (pEnd - *ppFrom)>=nByte ){
46302 *(void**)pp = (void *)*ppFrom;
46303 *ppFrom += nByte;
@@ -46367,10 +46534,13 @@
46367 int nArg; /* Maximum number of args passed to a user function. */
46368 resolveP2Values(p, &nArg);
46369 if( isExplain && nMem<10 ){
46370 nMem = 10;
46371 }
 
 
 
46372
46373 do {
46374 memset(zCsr, 0, zEnd-zCsr);
46375 nByte = 0;
46376 allocSpace((char*)&p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte);
@@ -46877,10 +47047,37 @@
46877 p->iStatement = 0;
46878 }
46879 return rc;
46880 }
46881
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46882 /*
46883 ** This routine is called the when a VDBE tries to halt. If the VDBE
46884 ** has made changes and is in autocommit mode, then commit those
46885 ** changes. If a rollback is needed, then do the rollback.
46886 **
@@ -46926,11 +47123,11 @@
46926 int mrc; /* Primary error code from p->rc */
46927 int eStatementOp = 0;
46928 int isSpecialError; /* Set to true if a 'special' error */
46929
46930 /* Lock all btrees used by the statement */
46931 sqlite3BtreeMutexArrayEnter(&p->aMutex);
46932
46933 /* Check for one of the special errors */
46934 mrc = p->rc & 0xff;
46935 isSpecialError = mrc==SQLITE_NOMEM || mrc==SQLITE_IOERR
46936 || mrc==SQLITE_INTERRUPT || mrc==SQLITE_FULL;
@@ -47587,34 +47784,44 @@
47587 */
47588 SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeRecordUnpack(
47589 KeyInfo *pKeyInfo, /* Information about the record format */
47590 int nKey, /* Size of the binary record */
47591 const void *pKey, /* The binary record */
47592 UnpackedRecord *pSpace,/* Space available to hold resulting object */
47593 int szSpace /* Size of pSpace[] in bytes */
47594 ){
47595 const unsigned char *aKey = (const unsigned char *)pKey;
47596 UnpackedRecord *p;
47597 int nByte, d;
 
47598 u32 idx;
47599 u16 u; /* Unsigned loop counter */
47600 u32 szHdr;
47601 Mem *pMem;
 
47602
47603 assert( sizeof(Mem)>sizeof(*p) );
47604 nByte = sizeof(Mem)*(pKeyInfo->nField+2);
 
 
 
 
 
 
 
47605 if( nByte>szSpace ){
47606 p = sqlite3DbMallocRaw(pKeyInfo->db, nByte);
47607 if( p==0 ) return 0;
47608 p->flags = UNPACKED_NEED_FREE | UNPACKED_NEED_DESTROY;
47609 }else{
47610 p = pSpace;
47611 p->flags = UNPACKED_NEED_DESTROY;
47612 }
47613 p->pKeyInfo = pKeyInfo;
47614 p->nField = pKeyInfo->nField + 1;
47615 p->aMem = pMem = &((Mem*)p)[1];
 
47616 idx = getVarint32(aKey, szHdr);
47617 d = szHdr;
47618 u = 0;
47619 while( idx<szHdr && u<p->nField ){
47620 u32 serial_type;
@@ -47926,11 +48133,11 @@
47926 *************************************************************************
47927 **
47928 ** This file contains code use to implement APIs that are part of the
47929 ** VDBE.
47930 **
47931 ** $Id: vdbeapi.c,v 1.156 2009/03/25 15:43:09 danielk1977 Exp $
47932 */
47933
47934 #if 0 && defined(SQLITE_ENABLE_MEMORY_MANAGEMENT)
47935 /*
47936 ** The following structure contains pointers to the end points of a
@@ -48354,11 +48561,11 @@
48354 if( db->mallocFailed ){
48355 return SQLITE_NOMEM;
48356 }
48357
48358 if( p->pc<=0 && p->expired ){
48359 if( p->rc==SQLITE_OK ){
48360 p->rc = SQLITE_SCHEMA;
48361 }
48362 rc = SQLITE_ERROR;
48363 goto end_of_step;
48364 }
@@ -48470,11 +48677,11 @@
48470 && cnt++ < 5
48471 && (rc = vdbeReprepare(v))==SQLITE_OK ){
48472 sqlite3_reset(pStmt);
48473 v->expired = 0;
48474 }
48475 if( rc==SQLITE_SCHEMA && v->isPrepareV2 && db->pErr ){
48476 /* This case occurs after failing to recompile an sql statement.
48477 ** The error message from the SQL compiler has already been loaded
48478 ** into the database handle. This block copies the error message
48479 ** from the database handle into the statement and sets the statement
48480 ** program counter to 0 to ensure that when the statement is
@@ -48529,11 +48736,11 @@
48529 sqlite3_value **NotUsed2 /* Value of each argument */
48530 ){
48531 const char *zName = context->pFunc->zName;
48532 char *zErr;
48533 UNUSED_PARAMETER2(NotUsed, NotUsed2);
48534 zErr = sqlite3MPrintf(0,
48535 "unable to use function %s in the requested context", zName);
48536 sqlite3_result_error(context, zErr, -1);
48537 sqlite3_free(zErr);
48538 }
48539
@@ -48675,11 +48882,11 @@
48675 vals = sqlite3_data_count(pStmt);
48676 pOut = &pVm->pResultSet[i];
48677 }else{
48678 /* ((double)0) In case of SQLITE_OMIT_FLOATING_POINT... */
48679 static const Mem nullMem = {{0}, (double)0, 0, "", 0, MEM_Null, SQLITE_NULL, 0, 0, 0 };
48680 if( pVm && pVm->db ){
48681 sqlite3_mutex_enter(pVm->db->mutex);
48682 sqlite3Error(pVm->db, SQLITE_RANGE, 0);
48683 }
48684 pOut = (Mem*)&nullMem;
48685 }
@@ -48815,28 +49022,27 @@
48815 int useType
48816 ){
48817 const void *ret = 0;
48818 Vdbe *p = (Vdbe *)pStmt;
48819 int n;
48820
48821
48822 if( p!=0 ){
48823 n = sqlite3_column_count(pStmt);
48824 if( N<n && N>=0 ){
48825 N += useType*n;
48826 sqlite3_mutex_enter(p->db->mutex);
48827 ret = xFunc(&p->aColName[N]);
48828
48829 /* A malloc may have failed inside of the xFunc() call. If this
48830 ** is the case, clear the mallocFailed flag and return NULL.
48831 */
48832 if( p->db && p->db->mallocFailed ){
48833 p->db->mallocFailed = 0;
48834 ret = 0;
48835 }
48836 sqlite3_mutex_leave(p->db->mutex);
48837 }
48838 }
48839 return ret;
48840 }
48841
48842 /*
@@ -49072,12 +49278,12 @@
49072 rc = sqlite3VdbeMemCopy(&p->aVar[i-1], pValue);
49073 if( rc==SQLITE_OK ){
49074 rc = sqlite3VdbeChangeEncoding(&p->aVar[i-1], ENC(p->db));
49075 }
49076 sqlite3_mutex_leave(p->db->mutex);
 
49077 }
49078 rc = sqlite3ApiExit(p->db, rc);
49079 return rc;
49080 }
49081 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
49082 int rc;
49083 Vdbe *p = (Vdbe *)pStmt;
@@ -49103,22 +49309,25 @@
49103 ** in the Vdbe.azVar[] array, if such a mapping does not already
49104 ** exist.
49105 */
49106 static void createVarMap(Vdbe *p){
49107 if( !p->okVar ){
 
 
49108 sqlite3_mutex_enter(p->db->mutex);
49109 if( !p->okVar ){
49110 int j;
49111 Op *pOp;
49112 for(j=0, pOp=p->aOp; j<p->nOp; j++, pOp++){
49113 if( pOp->opcode==OP_Variable ){
49114 assert( pOp->p1>0 && pOp->p1<=p->nVar );
49115 p->azVar[pOp->p1-1] = pOp->p4.z;
49116 }
49117 }
49118 p->okVar = 1;
49119 }
 
49120 sqlite3_mutex_leave(p->db->mutex);
49121 }
49122 }
49123
49124 /*
@@ -49159,40 +49368,44 @@
49159 return 0;
49160 }
49161
49162 /*
49163 ** Transfer all bindings from the first statement over to the second.
49164 ** If the two statements contain a different number of bindings, then
49165 ** an SQLITE_ERROR is returned.
49166 */
49167 SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
49168 Vdbe *pFrom = (Vdbe*)pFromStmt;
49169 Vdbe *pTo = (Vdbe*)pToStmt;
49170 int i, rc = SQLITE_OK;
49171 if( (pFrom->magic!=VDBE_MAGIC_RUN && pFrom->magic!=VDBE_MAGIC_HALT)
49172 || (pTo->magic!=VDBE_MAGIC_RUN && pTo->magic!=VDBE_MAGIC_HALT)
49173 || pTo->db!=pFrom->db ){
49174 return SQLITE_MISUSE;
49175 }
49176 if( pFrom->nVar!=pTo->nVar ){
49177 return SQLITE_ERROR;
49178 }
49179 sqlite3_mutex_enter(pTo->db->mutex);
49180 for(i=0; rc==SQLITE_OK && i<pFrom->nVar; i++){
49181 sqlite3VdbeMemMove(&pTo->aVar[i], &pFrom->aVar[i]);
49182 }
49183 sqlite3_mutex_leave(pTo->db->mutex);
49184 assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
49185 return rc;
49186 }
49187
49188 #ifndef SQLITE_OMIT_DEPRECATED
49189 /*
49190 ** Deprecated external interface. Internal/core SQLite code
49191 ** should call sqlite3TransferBindings.
 
 
 
 
 
 
 
 
49192 */
49193 SQLITE_API int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
 
 
 
 
 
49194 return sqlite3TransferBindings(pFromStmt, pToStmt);
49195 }
49196 #endif
49197
49198 /*
@@ -49278,11 +49491,11 @@
49278 ** documentation, headers files, or other derived files. The formatting
49279 ** of the code in this file is, therefore, important. See other comments
49280 ** in this file for details. If in doubt, do not deviate from existing
49281 ** commenting and indentation practices when changing or adding code.
49282 **
49283 ** $Id: vdbe.c,v 1.828 2009/03/23 17:11:27 danielk1977 Exp $
49284 */
49285
49286 /*
49287 ** The following global variable is incremented every time a cursor
49288 ** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes. The test
@@ -49886,15 +50099,17 @@
49886 int origPc; /* Program counter at start of opcode */
49887 #endif
49888 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
49889 int nProgressOps = 0; /* Opcodes executed since progress callback. */
49890 #endif
49891 UnpackedRecord aTempRec[16]; /* Space to hold a transient UnpackedRecord */
 
 
49892
49893 assert( p->magic==VDBE_MAGIC_RUN ); /* sqlite3_step() verifies this */
49894 assert( db->magic==SQLITE_MAGIC_BUSY );
49895 sqlite3BtreeMutexArrayEnter(&p->aMutex);
49896 if( p->rc==SQLITE_NOMEM ){
49897 /* This happens if a malloc() inside a call to sqlite3_column_text() or
49898 ** sqlite3_column_text16() failed. */
49899 goto no_mem;
49900 }
@@ -51689,11 +51904,15 @@
51689 */
51690 #ifndef SQLITE_OMIT_BTREECOUNT
51691 case OP_Count: { /* out2-prerelease */
51692 i64 nEntry;
51693 BtCursor *pCrsr = p->apCsr[pOp->p1]->pCursor;
51694 rc = sqlite3BtreeCount(pCrsr, &nEntry);
 
 
 
 
51695 pOut->flags = MEM_Int;
51696 pOut->u.i = nEntry;
51697 break;
51698 }
51699 #endif
@@ -53472,16 +53691,18 @@
53472 */
53473 case OP_IdxRowid: { /* out2-prerelease */
53474 int i = pOp->p1;
53475 BtCursor *pCrsr;
53476 VdbeCursor *pC;
 
53477
53478 assert( i>=0 && i<p->nCursor );
53479 assert( p->apCsr[i]!=0 );
53480 if( (pCrsr = (pC = p->apCsr[i])->pCursor)!=0 ){
53481 i64 rowid;
53482
 
53483 assert( pC->deferredMoveto==0 );
53484 assert( pC->isTable==0 );
53485 if( !pC->nullRow ){
53486 rc = sqlite3VdbeIdxRowid(pCrsr, &rowid);
53487 if( rc!=SQLITE_OK ){
@@ -55348,22 +55569,27 @@
55348 **
55349 ** This file contains code use to implement an in-memory rollback journal.
55350 ** The in-memory rollback journal is used to journal transactions for
55351 ** ":memory:" databases and when the journal_mode=MEMORY pragma is used.
55352 **
55353 ** @(#) $Id: memjournal.c,v 1.8 2008/12/20 02:14:40 drh Exp $
55354 */
55355
55356 /* Forward references to internal structures */
55357 typedef struct MemJournal MemJournal;
55358 typedef struct FilePoint FilePoint;
55359 typedef struct FileChunk FileChunk;
55360
55361 /* Space to hold the rollback journal is allocated in increments of
55362 ** this many bytes.
 
 
 
 
 
55363 */
55364 #define JOURNAL_CHUNKSIZE 1024
55365
55366 /* Macro to find the minimum of two numeric values.
55367 */
55368 #ifndef MIN
55369 # define MIN(x,y) ((x)<(y)?(x):(y))
@@ -55396,11 +55622,12 @@
55396 FilePoint endpoint; /* Pointer to the end of the file */
55397 FilePoint readpoint; /* Pointer to the end of the last xRead() */
55398 };
55399
55400 /*
55401 ** Read data from the file.
 
55402 */
55403 static int memjrnlRead(
55404 sqlite3_file *pJfd, /* The journal file from which to read */
55405 void *zBuf, /* Put the results here */
55406 int iAmt, /* Number of bytes to read */
@@ -55410,16 +55637,17 @@
55410 u8 *zOut = zBuf;
55411 int nRead = iAmt;
55412 int iChunkOffset;
55413 FileChunk *pChunk;
55414
 
55415 assert( iOfst+iAmt<=p->endpoint.iOffset );
55416
55417 if( p->readpoint.iOffset!=iOfst || iOfst==0 ){
55418 sqlite3_int64 iOff = 0;
55419 for(pChunk=p->pFirst;
55420 pChunk && (iOff+JOURNAL_CHUNKSIZE)<=iOfst;
55421 pChunk=pChunk->pNext
55422 ){
55423 iOff += JOURNAL_CHUNKSIZE;
55424 }
55425 }else{
@@ -55518,15 +55746,21 @@
55518 }
55519
55520
55521 /*
55522 ** Sync the file.
 
 
 
 
 
55523 */
55524 static int memjrnlSync(sqlite3_file *NotUsed, int NotUsed2){
55525 UNUSED_PARAMETER2(NotUsed, NotUsed2);
55526 return SQLITE_OK;
55527 }
 
55528
55529 /*
55530 ** Query the size of the file in bytes.
55531 */
55532 static int memjrnlFileSize(sqlite3_file *pJfd, sqlite_int64 *pSize){
@@ -55557,10 +55791,11 @@
55557 /*
55558 ** Open a journal file.
55559 */
55560 SQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *pJfd){
55561 MemJournal *p = (MemJournal *)pJfd;
 
55562 memset(p, 0, sqlite3MemJournalSize());
55563 p->pMethod = &MemJournalMethods;
55564 }
55565
55566 /*
@@ -55593,11 +55828,11 @@
55593 **
55594 *************************************************************************
55595 ** This file contains routines used for walking the parser tree for
55596 ** an SQL statement.
55597 **
55598 ** $Id: walker.c,v 1.2 2009/02/19 14:39:25 danielk1977 Exp $
55599 */
55600
55601
55602 /*
55603 ** Walk an expression tree. Invoke the callback once for each node
@@ -55619,12 +55854,16 @@
55619 ** and WRC_Continue to continue.
55620 */
55621 SQLITE_PRIVATE int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
55622 int rc;
55623 if( pExpr==0 ) return WRC_Continue;
 
 
 
55624 rc = pWalker->xExprCallback(pWalker, pExpr);
55625 if( rc==WRC_Continue ){
 
55626 if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
55627 if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
55628 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
55629 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
55630 }else{
@@ -56900,11 +57139,11 @@
56900 **
56901 *************************************************************************
56902 ** This file contains routines used for analyzing expressions and
56903 ** for generating VDBE code that evaluates expressions in SQLite.
56904 **
56905 ** $Id: expr.c,v 1.424 2009/03/25 16:51:43 drh Exp $
56906 */
56907
56908 /*
56909 ** Return the 'affinity' of the expression pExpr if any.
56910 **
@@ -57516,19 +57755,22 @@
57516 ** Clear an expression structure without deleting the structure itself.
57517 ** Substructure is deleted.
57518 */
57519 SQLITE_PRIVATE void sqlite3ExprClear(sqlite3 *db, Expr *p){
57520 if( p->token.dyn ) sqlite3DbFree(db, (char*)p->token.z);
57521 if( !ExprHasAnyProperty(p, EP_TokenOnly|EP_SpanOnly) ){
57522 if( p->span.dyn ) sqlite3DbFree(db, (char*)p->span.z);
57523 if( ExprHasProperty(p, EP_Reduced) ){
 
57524 if( p->pLeft ) sqlite3ExprClear(db, p->pLeft);
57525 if( p->pRight ) sqlite3ExprClear(db, p->pRight);
57526 }else{
 
57527 sqlite3ExprDelete(db, p->pLeft);
57528 sqlite3ExprDelete(db, p->pRight);
57529 }
 
57530 if( ExprHasProperty(p, EP_xIsSelect) ){
57531 sqlite3SelectDelete(db, p->x.pSelect);
57532 }else{
57533 sqlite3ExprListDelete(db, p->x.pList);
57534 }
@@ -57561,11 +57803,11 @@
57561 ** passed as the first argument. This is always one of EXPR_FULLSIZE,
57562 ** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE.
57563 */
57564 static int exprStructSize(Expr *p){
57565 if( ExprHasProperty(p, EP_TokenOnly) ) return EXPR_TOKENONLYSIZE;
57566 if( ExprHasProperty(p, EP_SpanOnly) ) return EXPR_SPANONLYSIZE;
57567 if( ExprHasProperty(p, EP_Reduced) ) return EXPR_REDUCEDSIZE;
57568 return EXPR_FULLSIZE;
57569 }
57570
57571 /*
@@ -57578,12 +57820,12 @@
57578 int nSize;
57579 if( 0==(flags&EXPRDUP_REDUCE) ){
57580 nSize = EXPR_FULLSIZE;
57581 }else if( p->pLeft || p->pRight || p->pColl || p->x.pList ){
57582 nSize = EXPR_REDUCEDSIZE;
57583 }else if( flags&(EXPRDUP_SPAN|EXPRDUP_DISTINCTSPAN) ){
57584 nSize = EXPR_SPANONLYSIZE;
57585 }else{
57586 nSize = EXPR_TOKENONLYSIZE;
57587 }
57588 return nSize;
57589 }
@@ -57595,12 +57837,12 @@
57595 ** and the copies of the Expr.token.z and Expr.span.z (if applicable)
57596 ** string buffers.
57597 */
57598 static int dupedExprNodeSize(Expr *p, int flags){
57599 int nByte = dupedExprStructSize(p, flags) + (p->token.z ? p->token.n + 1 : 0);
57600 if( (flags&EXPRDUP_DISTINCTSPAN)
57601 || (flags&EXPRDUP_SPAN && (p->token.z!=p->span.z || p->token.n!=p->span.n))
57602 ){
57603 nByte += p->span.n;
57604 }
57605 return ROUND8(nByte);
57606 }
@@ -57623,11 +57865,11 @@
57623 static int dupedExprSize(Expr *p, int flags){
57624 int nByte = 0;
57625 if( p ){
57626 nByte = dupedExprNodeSize(p, flags);
57627 if( flags&EXPRDUP_REDUCE ){
57628 int f = flags&(~(EXPRDUP_SPAN|EXPRDUP_DISTINCTSPAN));
57629 nByte += dupedExprSize(p->pLeft, f) + dupedExprSize(p->pRight, f);
57630 }
57631 }
57632 return nByte;
57633 }
@@ -57641,12 +57883,11 @@
57641 ** portion of the buffer copied into by this function.
57642 */
57643 static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){
57644 Expr *pNew = 0; /* Value to return */
57645 if( p ){
57646 const int isRequireDistinctSpan = (flags&EXPRDUP_DISTINCTSPAN);
57647 const int isRequireSpan = (flags&(EXPRDUP_SPAN|EXPRDUP_DISTINCTSPAN));
57648 const int isReduced = (flags&EXPRDUP_REDUCE);
57649 u8 *zAlloc;
57650
57651 assert( pzBuffer==0 || isReduced );
57652
@@ -57674,15 +57915,15 @@
57674 memcpy(zAlloc, p, nSize);
57675 memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize);
57676 }
57677
57678 /* Set the EP_Reduced and EP_TokenOnly flags appropriately. */
57679 pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_SpanOnly);
57680 switch( nNewSize ){
57681 case EXPR_REDUCEDSIZE: pNew->flags |= EP_Reduced; break;
57682 case EXPR_TOKENONLYSIZE: pNew->flags |= EP_TokenOnly; break;
57683 case EXPR_SPANONLYSIZE: pNew->flags |= EP_SpanOnly; break;
57684 }
57685
57686 /* Copy the p->token string, if any. */
57687 if( nToken ){
57688 unsigned char *zToken = &zAlloc[nNewSize];
@@ -57693,13 +57934,11 @@
57693 }
57694
57695 if( 0==((p->flags|pNew->flags) & EP_TokenOnly) ){
57696 /* Fill in the pNew->span token, if required. */
57697 if( isRequireSpan ){
57698 if( isRequireDistinctSpan
57699 || p->token.z!=p->span.z || p->token.n!=p->span.n
57700 ){
57701 pNew->span.z = &zAlloc[nNewSize+nToken];
57702 memcpy((char *)pNew->span.z, p->span.z, p->span.n);
57703 pNew->span.dyn = 0;
57704 }else{
57705 pNew->span.z = pNew->token.z;
@@ -57709,30 +57948,30 @@
57709 pNew->span.z = 0;
57710 pNew->span.n = 0;
57711 }
57712 }
57713
57714 if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_SpanOnly)) ){
57715 /* Fill in the pNew->x.pSelect or pNew->x.pList member. */
57716 if( ExprHasProperty(p, EP_xIsSelect) ){
57717 pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, isReduced);
57718 }else{
57719 pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, isReduced);
57720 }
57721 }
57722
57723 /* Fill in pNew->pLeft and pNew->pRight. */
57724 if( ExprHasAnyProperty(pNew, EP_Reduced|EP_TokenOnly|EP_SpanOnly) ){
57725 zAlloc += dupedExprNodeSize(p, flags);
57726 if( ExprHasProperty(pNew, EP_Reduced) ){
57727 pNew->pLeft = exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc);
57728 pNew->pRight = exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc);
57729 }
57730 if( pzBuffer ){
57731 *pzBuffer = zAlloc;
57732 }
57733 }else if( !ExprHasAnyProperty(p, EP_TokenOnly|EP_SpanOnly) ){
57734 pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
57735 pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
57736 }
57737 }
57738 }
@@ -58232,26 +58471,30 @@
58232 ** If this is the case, it may be possible to use an existing table
58233 ** or index instead of generating an epheremal table.
58234 */
58235 p = (ExprHasProperty(pX, EP_xIsSelect) ? pX->x.pSelect : 0);
58236 if( isCandidateForInOpt(p) ){
58237 sqlite3 *db = pParse->db;
58238 Index *pIdx;
58239 Expr *pExpr = p->pEList->a[0].pExpr;
58240 int iCol = pExpr->iColumn;
58241 Vdbe *v = sqlite3GetVdbe(pParse);
 
 
 
 
 
 
58242
58243 /* This function is only called from two places. In both cases the vdbe
58244 ** has already been allocated. So assume sqlite3GetVdbe() is always
58245 ** successful here.
58246 */
58247 assert(v);
58248 if( iCol<0 ){
58249 int iMem = ++pParse->nMem;
58250 int iAddr;
58251 Table *pTab = p->pSrc->a[0].pTab;
58252 int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
58253 sqlite3VdbeUsesBtree(v, iDb);
58254
58255 iAddr = sqlite3VdbeAddOp1(v, OP_If, iMem);
58256 sqlite3VdbeAddOp2(v, OP_Integer, 1, iMem);
58257
@@ -58258,30 +58501,29 @@
58258 sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
58259 eType = IN_INDEX_ROWID;
58260
58261 sqlite3VdbeJumpHere(v, iAddr);
58262 }else{
 
 
58263 /* The collation sequence used by the comparison. If an index is to
58264 ** be used in place of a temp-table, it must be ordered according
58265 ** to this collation sequence.
58266 */
58267 CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pExpr);
58268
58269 /* Check that the affinity that will be used to perform the
58270 ** comparison is the same as the affinity of the column. If
58271 ** it is not, it is not possible to use any index.
58272 */
58273 Table *pTab = p->pSrc->a[0].pTab;
58274 char aff = comparisonAffinity(pX);
58275 int affinity_ok = (pTab->aCol[iCol].affinity==aff||aff==SQLITE_AFF_NONE);
58276
58277 for(pIdx=pTab->pIndex; pIdx && eType==0 && affinity_ok; pIdx=pIdx->pNext){
58278 if( (pIdx->aiColumn[0]==iCol)
58279 && (pReq==sqlite3FindCollSeq(db, ENC(db), pIdx->azColl[0], -1, 0))
58280 && (!mustBeUnique || (pIdx->nColumn==1 && pIdx->onError!=OE_None))
58281 ){
58282 int iDb;
58283 int iMem = ++pParse->nMem;
58284 int iAddr;
58285 char *pKey;
58286
58287 pKey = (char *)sqlite3IndexKeyinfo(pParse, pIdx);
@@ -59089,35 +59331,38 @@
59089 }
59090 break;
59091 }
59092 case TK_CONST_FUNC:
59093 case TK_FUNCTION: {
59094 ExprList *pList = (
59095 ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_SpanOnly) ? 0 : pExpr->x.pList
59096 );
59097 int nExpr = pList ? pList->nExpr : 0;
59098 FuncDef *pDef;
59099 int nId;
59100 const char *zId;
59101 int constMask = 0;
59102 int i;
59103 u8 enc = ENC(db);
59104 CollSeq *pColl = 0;
59105
59106 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
59107 testcase( op==TK_CONST_FUNC );
59108 testcase( op==TK_FUNCTION );
 
 
 
 
 
 
59109 zId = (char*)pExpr->token.z;
59110 nId = pExpr->token.n;
59111 pDef = sqlite3FindFunction(db, zId, nId, nExpr, enc, 0);
59112 assert( pDef!=0 );
59113 if( pList ){
59114 nExpr = pList->nExpr;
59115 r1 = sqlite3GetTempRange(pParse, nExpr);
59116 sqlite3ExprCodeExprList(pParse, pList, r1, 1);
59117 }else{
59118 nExpr = r1 = 0;
59119 }
59120 #ifndef SQLITE_OMIT_VIRTUALTABLE
59121 /* Possibly overload the function if the first argument is
59122 ** a virtual table column.
59123 **
@@ -59128,35 +59373,35 @@
59128 ** control overloading) ends up as the second argument to the
59129 ** function. The expression "A glob B" is equivalent to
59130 ** "glob(B,A). We want to use the A in "A glob B" to test
59131 ** for function overloading. But we use the B term in "glob(B,A)".
59132 */
59133 if( nExpr>=2 && (pExpr->flags & EP_InfixFunc) ){
59134 pDef = sqlite3VtabOverloadFunction(db, pDef, nExpr, pList->a[1].pExpr);
59135 }else if( nExpr>0 ){
59136 pDef = sqlite3VtabOverloadFunction(db, pDef, nExpr, pList->a[0].pExpr);
59137 }
59138 #endif
59139 for(i=0; i<nExpr && i<32; i++){
59140 if( sqlite3ExprIsConstant(pList->a[i].pExpr) ){
59141 constMask |= (1<<i);
59142 }
59143 if( (pDef->flags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){
59144 pColl = sqlite3ExprCollSeq(pParse, pList->a[i].pExpr);
59145 }
59146 }
59147 if( pDef->flags & SQLITE_FUNC_NEEDCOLL ){
59148 if( !pColl ) pColl = db->pDfltColl;
59149 sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);
59150 }
59151 sqlite3VdbeAddOp4(v, OP_Function, constMask, r1, target,
59152 (char*)pDef, P4_FUNCDEF);
59153 sqlite3VdbeChangeP5(v, (u8)nExpr);
59154 if( nExpr ){
59155 sqlite3ReleaseTempRange(pParse, r1, nExpr);
59156 }
59157 sqlite3ExprCacheAffinityChange(pParse, r1, nExpr);
59158 break;
59159 }
59160 #ifndef SQLITE_OMIT_SUBQUERY
59161 case TK_EXISTS:
59162 case TK_SELECT: {
@@ -61275,11 +61520,11 @@
61275 ** May you share freely, never taking more than you give.
61276 **
61277 *************************************************************************
61278 ** This file contains code used to implement the ATTACH and DETACH commands.
61279 **
61280 ** $Id: attach.c,v 1.83 2009/02/19 14:39:25 danielk1977 Exp $
61281 */
61282
61283 #ifndef SQLITE_OMIT_ATTACH
61284 /*
61285 ** Resolve an expression that was part of an ATTACH or DETACH statement. This
@@ -61751,11 +61996,11 @@
61751 SQLITE_PRIVATE int sqlite3FixExpr(
61752 DbFixer *pFix, /* Context of the fixation */
61753 Expr *pExpr /* The expression to be fixed to one database */
61754 ){
61755 while( pExpr ){
61756 if( ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_SpanOnly) ) break;
61757 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
61758 if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1;
61759 }else{
61760 if( sqlite3FixExprList(pFix, pExpr->x.pList) ) return 1;
61761 }
@@ -62063,11 +62308,11 @@
62063 ** creating ID lists
62064 ** BEGIN TRANSACTION
62065 ** COMMIT
62066 ** ROLLBACK
62067 **
62068 ** $Id: build.c,v 1.527 2009/03/31 03:41:57 shane Exp $
62069 */
62070
62071 /*
62072 ** This routine is called when a new SQL statement is beginning to
62073 ** be parsed. Initialize the pParse structure as needed.
@@ -63152,13 +63397,11 @@
63152 /* A copy of pExpr is used instead of the original, as pExpr contains
63153 ** tokens that point to volatile memory. The 'span' of the expression
63154 ** is required by pragma table_info.
63155 */
63156 sqlite3ExprDelete(db, pCol->pDflt);
63157 pCol->pDflt = sqlite3ExprDup(
63158 db, pExpr, EXPRDUP_REDUCE|EXPRDUP_DISTINCTSPAN
63159 );
63160 }
63161 }
63162 sqlite3ExprDelete(db, pExpr);
63163 }
63164
@@ -66831,11 +67074,11 @@
66831 **
66832 ** There is only one exported symbol in this file - the function
66833 ** sqliteRegisterBuildinFunctions() found at the bottom of the file.
66834 ** All other code has file scope.
66835 **
66836 ** $Id: func.c,v 1.225 2009/03/27 15:26:03 danielk1977 Exp $
66837 */
66838
66839 /*
66840 ** Return the collating function associated with a function.
66841 */
@@ -67077,20 +67320,26 @@
67077 #endif
67078
67079 /*
67080 ** Allocate nByte bytes of space using sqlite3_malloc(). If the
67081 ** allocation fails, call sqlite3_result_error_nomem() to notify
67082 ** the database handle that malloc() has failed.
 
 
67083 */
67084 static void *contextMalloc(sqlite3_context *context, i64 nByte){
67085 char *z;
67086 if( nByte>sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH] ){
 
 
 
 
67087 sqlite3_result_error_toobig(context);
67088 z = 0;
67089 }else{
67090 z = sqlite3Malloc((int)nByte);
67091 if( !z && nByte>0 ){
67092 sqlite3_result_error_nomem(context);
67093 }
67094 }
67095 return z;
67096 }
@@ -67167,12 +67416,21 @@
67167 sqlite3_value **NotUsed2
67168 ){
67169 sqlite_int64 r;
67170 UNUSED_PARAMETER2(NotUsed, NotUsed2);
67171 sqlite3_randomness(sizeof(r), &r);
67172 if( (r<<1)==0 ) r = 0; /* Prevent 0x8000.... as the result so that we */
67173 /* can always do abs() of the result */
 
 
 
 
 
 
 
 
 
67174 sqlite3_result_int64(context, r);
67175 }
67176
67177 /*
67178 ** Implementation of randomblob(N). Return a random blob
@@ -67255,11 +67513,11 @@
67255 ** character is exactly one byte in size. Also, all characters are
67256 ** able to participate in upper-case-to-lower-case mappings in EBCDIC
67257 ** whereas only characters less than 0x80 do in ASCII.
67258 */
67259 #if defined(SQLITE_EBCDIC)
67260 # define sqlite3Utf8Read(A,B,C) (*(A++))
67261 # define GlogUpperToLower(A) A = sqlite3UpperToLower[A]
67262 #else
67263 # define GlogUpperToLower(A) if( A<0x80 ){ A = sqlite3UpperToLower[A]; }
67264 #endif
67265
@@ -67312,22 +67570,22 @@
67312 u8 matchAll = pInfo->matchAll;
67313 u8 matchSet = pInfo->matchSet;
67314 u8 noCase = pInfo->noCase;
67315 int prevEscape = 0; /* True if the previous character was 'escape' */
67316
67317 while( (c = sqlite3Utf8Read(zPattern,0,&zPattern))!=0 ){
67318 if( !prevEscape && c==matchAll ){
67319 while( (c=sqlite3Utf8Read(zPattern,0,&zPattern)) == matchAll
67320 || c == matchOne ){
67321 if( c==matchOne && sqlite3Utf8Read(zString, 0, &zString)==0 ){
67322 return 0;
67323 }
67324 }
67325 if( c==0 ){
67326 return 1;
67327 }else if( c==esc ){
67328 c = sqlite3Utf8Read(zPattern, 0, &zPattern);
67329 if( c==0 ){
67330 return 0;
67331 }
67332 }else if( c==matchSet ){
67333 assert( esc==0 ); /* This is GLOB, not LIKE */
@@ -67335,67 +67593,67 @@
67335 while( *zString && patternCompare(&zPattern[-1],zString,pInfo,esc)==0 ){
67336 SQLITE_SKIP_UTF8(zString);
67337 }
67338 return *zString!=0;
67339 }
67340 while( (c2 = sqlite3Utf8Read(zString,0,&zString))!=0 ){
67341 if( noCase ){
67342 GlogUpperToLower(c2);
67343 GlogUpperToLower(c);
67344 while( c2 != 0 && c2 != c ){
67345 c2 = sqlite3Utf8Read(zString, 0, &zString);
67346 GlogUpperToLower(c2);
67347 }
67348 }else{
67349 while( c2 != 0 && c2 != c ){
67350 c2 = sqlite3Utf8Read(zString, 0, &zString);
67351 }
67352 }
67353 if( c2==0 ) return 0;
67354 if( patternCompare(zPattern,zString,pInfo,esc) ) return 1;
67355 }
67356 return 0;
67357 }else if( !prevEscape && c==matchOne ){
67358 if( sqlite3Utf8Read(zString, 0, &zString)==0 ){
67359 return 0;
67360 }
67361 }else if( c==matchSet ){
67362 int prior_c = 0;
67363 assert( esc==0 ); /* This only occurs for GLOB, not LIKE */
67364 seen = 0;
67365 invert = 0;
67366 c = sqlite3Utf8Read(zString, 0, &zString);
67367 if( c==0 ) return 0;
67368 c2 = sqlite3Utf8Read(zPattern, 0, &zPattern);
67369 if( c2=='^' ){
67370 invert = 1;
67371 c2 = sqlite3Utf8Read(zPattern, 0, &zPattern);
67372 }
67373 if( c2==']' ){
67374 if( c==']' ) seen = 1;
67375 c2 = sqlite3Utf8Read(zPattern, 0, &zPattern);
67376 }
67377 while( c2 && c2!=']' ){
67378 if( c2=='-' && zPattern[0]!=']' && zPattern[0]!=0 && prior_c>0 ){
67379 c2 = sqlite3Utf8Read(zPattern, 0, &zPattern);
67380 if( c>=prior_c && c<=c2 ) seen = 1;
67381 prior_c = 0;
67382 }else{
67383 if( c==c2 ){
67384 seen = 1;
67385 }
67386 prior_c = c2;
67387 }
67388 c2 = sqlite3Utf8Read(zPattern, 0, &zPattern);
67389 }
67390 if( c2==0 || (seen ^ invert)==0 ){
67391 return 0;
67392 }
67393 }else if( esc==c && !prevEscape ){
67394 prevEscape = 1;
67395 }else{
67396 c2 = sqlite3Utf8Read(zString, 0, &zString);
67397 if( noCase ){
67398 GlogUpperToLower(c);
67399 GlogUpperToLower(c2);
67400 }
67401 if( c!=c2 ){
@@ -67434,20 +67692,23 @@
67434 int argc,
67435 sqlite3_value **argv
67436 ){
67437 const unsigned char *zA, *zB;
67438 int escape = 0;
 
67439 sqlite3 *db = sqlite3_context_db_handle(context);
67440
67441 zB = sqlite3_value_text(argv[0]);
67442 zA = sqlite3_value_text(argv[1]);
67443
67444 /* Limit the length of the LIKE or GLOB pattern to avoid problems
67445 ** of deep recursion and N*N behavior in patternCompare().
67446 */
67447 if( sqlite3_value_bytes(argv[0]) >
67448 db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] ){
 
 
67449 sqlite3_result_error(context, "LIKE or GLOB pattern too complex", -1);
67450 return;
67451 }
67452 assert( zB==sqlite3_value_text(argv[0]) ); /* Encoding did not change */
67453
@@ -67460,11 +67721,11 @@
67460 if( sqlite3Utf8CharLen((char*)zEsc, -1)!=1 ){
67461 sqlite3_result_error(context,
67462 "ESCAPE expression must be a single character", -1);
67463 return;
67464 }
67465 escape = sqlite3Utf8Read(zEsc, 0, &zEsc);
67466 }
67467 if( zA && zB ){
67468 struct compareInfo *pInfo = sqlite3_user_data(context);
67469 #ifdef SQLITE_TEST
67470 sqlite3_like_count++;
@@ -67619,14 +67880,17 @@
67619 sqlite3_context *context,
67620 int argc,
67621 sqlite3_value **argv
67622 ){
67623 i64 n;
 
67624 assert( argc==1 );
67625 UNUSED_PARAMETER(argc);
67626 n = sqlite3_value_int64(argv[0]);
67627 if( n>SQLITE_MAX_LENGTH ){
 
 
67628 sqlite3_result_error_toobig(context);
67629 }else{
67630 sqlite3_result_zeroblob(context, (int)n);
67631 }
67632 }
@@ -67688,11 +67952,13 @@
67688 zOut[j++] = zStr[i];
67689 }else{
67690 u8 *zOld;
67691 sqlite3 *db = sqlite3_context_db_handle(context);
67692 nOut += nRep - nPattern;
67693 if( nOut>=db->aLimit[SQLITE_LIMIT_LENGTH] ){
 
 
67694 sqlite3_result_error_toobig(context);
67695 sqlite3DbFree(db, zOut);
67696 return;
67697 }
67698 zOld = zOut;
@@ -67772,11 +68038,11 @@
67772 if( flags & 1 ){
67773 while( nIn>0 ){
67774 int len = 0;
67775 for(i=0; i<nChar; i++){
67776 len = aLen[i];
67777 if( memcmp(zIn, azChar[i], len)==0 ) break;
67778 }
67779 if( i>=nChar ) break;
67780 zIn += len;
67781 nIn -= len;
67782 }
@@ -67966,10 +68232,17 @@
67966 CountCtx *p;
67967 p = sqlite3_aggregate_context(context, sizeof(*p));
67968 if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0])) && p ){
67969 p->n++;
67970 }
 
 
 
 
 
 
 
67971 }
67972 static void countFinalize(sqlite3_context *context){
67973 CountCtx *p;
67974 p = sqlite3_aggregate_context(context, 0);
67975 sqlite3_result_int64(context, p ? p->n : 0);
@@ -68014,11 +68287,11 @@
68014 }
68015 static void minMaxFinalize(sqlite3_context *context){
68016 sqlite3_value *pRes;
68017 pRes = (sqlite3_value *)sqlite3_aggregate_context(context, 0);
68018 if( pRes ){
68019 if( pRes->flags ){
68020 sqlite3_result_value(context, pRes);
68021 }
68022 sqlite3VdbeMemRelease(pRes);
68023 }
68024 }
@@ -68099,11 +68372,11 @@
68099 */
68100 static void setLikeOptFlag(sqlite3 *db, const char *zName, u8 flagVal){
68101 FuncDef *pDef;
68102 pDef = sqlite3FindFunction(db, zName, sqlite3Strlen30(zName),
68103 2, SQLITE_UTF8, 0);
68104 if( pDef ){
68105 pDef->flags = flagVal;
68106 }
68107 }
68108
68109 /*
@@ -68143,11 +68416,11 @@
68143 return 0;
68144 }
68145 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
68146 pDef = sqlite3FindFunction(db, (char*)pExpr->token.z, pExpr->token.n, 2,
68147 SQLITE_UTF8, 0);
68148 if( pDef==0 || (pDef->flags & SQLITE_FUNC_LIKE)==0 ){
68149 return 0;
68150 }
68151
68152 /* The memcpy() statement assumes that the wildcard characters are
68153 ** the first three statements in the compareInfo structure. The
@@ -71141,11 +71414,11 @@
71141 ** May you share freely, never taking more than you give.
71142 **
71143 *************************************************************************
71144 ** This file contains code used to implement the PRAGMA command.
71145 **
71146 ** $Id: pragma.c,v 1.204 2009/02/23 16:52:08 drh Exp $
71147 */
71148
71149 /* Ignore this whole file if pragmas are disabled
71150 */
71151 #if !defined(SQLITE_OMIT_PRAGMA) && !defined(SQLITE_OMIT_PARSER)
@@ -71273,18 +71546,20 @@
71273 #endif /* SQLITE_PAGER_PRAGMAS */
71274
71275 /*
71276 ** Generate code to return a single integer value.
71277 */
71278 static void returnSingleInt(Parse *pParse, const char *zLabel, int value){
71279 Vdbe *v = sqlite3GetVdbe(pParse);
71280 int mem = ++pParse->nMem;
71281 sqlite3VdbeAddOp2(v, OP_Integer, value, mem);
71282 if( pParse->explain==0 ){
71283 sqlite3VdbeSetNumCols(v, 1);
71284 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC);
71285 }
 
 
 
71286 sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);
71287 }
71288
71289 #ifndef SQLITE_OMIT_FLAG_PRAGMAS
71290 /*
@@ -71498,11 +71773,11 @@
71498 }else{
71499 /* Malloc may fail when setting the page-size, as there is an internal
71500 ** buffer that the pager module resizes using sqlite3_realloc().
71501 */
71502 db->nextPagesize = atoi(zRight);
71503 if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1) ){
71504 db->mallocFailed = 1;
71505 }
71506 }
71507 }else
71508
@@ -71660,18 +71935,15 @@
71660 */
71661 if( sqlite3StrICmp(zLeft,"journal_size_limit")==0 ){
71662 Pager *pPager = sqlite3BtreePager(pDb->pBt);
71663 i64 iLimit = -2;
71664 if( zRight ){
71665 int iLimit32 = atoi(zRight);
71666 if( iLimit32<-1 ){
71667 iLimit32 = -1;
71668 }
71669 iLimit = iLimit32;
71670 }
71671 iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit);
71672 returnSingleInt(pParse, "journal_size_limit", (int)iLimit);
71673 }else
71674
71675 #endif /* SQLITE_OMIT_PAGER_PRAGMAS */
71676
71677 /*
@@ -72208,11 +72480,10 @@
72208 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
72209 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->tnum, 2+cnt);
72210 cnt++;
72211 }
72212 }
72213 if( cnt==0 ) continue;
72214
72215 /* Make sure sufficient number of registers have been allocated */
72216 if( pParse->nMem < cnt+4 ){
72217 pParse->nMem = cnt+4;
72218 }
@@ -72281,11 +72552,10 @@
72281 { OP_String8, 0, 2, 0}, /* 6 */
72282 { OP_String8, 0, 3, 0}, /* 7 */
72283 { OP_Concat, 3, 2, 2},
72284 { OP_ResultRow, 2, 1, 0},
72285 };
72286 if( pIdx->tnum==0 ) continue;
72287 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1);
72288 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
72289 sqlite3VdbeJumpHere(v, addr);
72290 addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx);
72291 sqlite3VdbeChangeP1(v, addr+1, j+2);
@@ -72578,11 +72848,11 @@
72578 *************************************************************************
72579 ** This file contains the implementation of the sqlite3_prepare()
72580 ** interface, and routines that contribute to loading the database schema
72581 ** from disk.
72582 **
72583 ** $Id: prepare.c,v 1.114 2009/03/24 15:08:10 drh Exp $
72584 */
72585
72586 /*
72587 ** Fill the InitData structure with an error message that indicates
72588 ** that the database is corrupt.
@@ -73092,15 +73362,12 @@
73092 Parse sParse;
73093 char *zErrMsg = 0;
73094 int rc = SQLITE_OK;
73095 int i;
73096
73097 assert( ppStmt );
73098 *ppStmt = 0;
73099 if( sqlite3SafetyOn(db) ){
73100 return SQLITE_MISUSE;
73101 }
73102 assert( !db->mallocFailed );
73103 assert( sqlite3_mutex_held(db->mutex) );
73104
73105 /* Check to verify that it is possible to get a read lock on all
73106 ** database schemas. The inability to get a read lock indicates that
@@ -73235,10 +73502,12 @@
73235 int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */
73236 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
73237 const char **pzTail /* OUT: End of parsed string */
73238 ){
73239 int rc;
 
 
73240 if( !sqlite3SafetyCheckOk(db) ){
73241 return SQLITE_MISUSE;
73242 }
73243 sqlite3_mutex_enter(db->mutex);
73244 sqlite3BtreeEnterAll(db);
@@ -73337,10 +73606,12 @@
73337 */
73338 char *zSql8;
73339 const char *zTail8 = 0;
73340 int rc = SQLITE_OK;
73341
 
 
73342 if( !sqlite3SafetyCheckOk(db) ){
73343 return SQLITE_MISUSE;
73344 }
73345 sqlite3_mutex_enter(db->mutex);
73346 zSql8 = sqlite3Utf16to8(db, zSql, nBytes);
@@ -73412,11 +73683,11 @@
73412 **
73413 *************************************************************************
73414 ** This file contains C code routines that are called by the parser
73415 ** to handle SELECT statements in SQLite.
73416 **
73417 ** $Id: select.c,v 1.506 2009/03/31 03:41:57 shane Exp $
73418 */
73419
73420
73421 /*
73422 ** Delete all the content of a Select structure but do not deallocate
@@ -75953,10 +76224,16 @@
75953 ** ORDER by clause of the parent must be simple references to
75954 ** columns of the sub-query.
75955 **
75956 ** (19) The subquery does not use LIMIT or the outer query does not
75957 ** have a WHERE clause.
 
 
 
 
 
 
75958 **
75959 ** In this routine, the "p" parameter is a pointer to the outer query.
75960 ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query
75961 ** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates.
75962 **
@@ -76064,10 +76341,13 @@
76064 ** use only the UNION ALL operator. And none of the simple select queries
76065 ** that make up the compound SELECT are allowed to be aggregate or distinct
76066 ** queries.
76067 */
76068 if( pSub->pPrior ){
 
 
 
76069 if( isAgg || (p->selFlags & SF_Distinct)!=0 || pSrc->nSrc!=1 ){
76070 return 0;
76071 }
76072 for(pSub1=pSub; pSub1; pSub1=pSub1->pPrior){
76073 if( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))!=0
@@ -77706,52 +77986,51 @@
77706 ** interface routine of sqlite3_exec().
77707 **
77708 ** These routines are in a separate files so that they will not be linked
77709 ** if they are not used.
77710 **
77711 ** $Id: table.c,v 1.39 2009/01/19 20:49:10 drh Exp $
77712 */
77713
77714 #ifndef SQLITE_OMIT_GET_TABLE
77715
77716 /*
77717 ** This structure is used to pass data from sqlite3_get_table() through
77718 ** to the callback function is uses to build the result.
77719 */
77720 typedef struct TabResult {
77721 char **azResult;
77722 char *zErrMsg;
77723 int nResult;
77724 int nAlloc;
77725 int nRow;
77726 int nColumn;
77727 int nData;
77728 int rc;
77729 } TabResult;
77730
77731 /*
77732 ** This routine is called once for each row in the result table. Its job
77733 ** is to fill in the TabResult structure appropriately, allocating new
77734 ** memory as necessary.
77735 */
77736 static int sqlite3_get_table_cb(void *pArg, int nCol, char **argv, char **colv){
77737 TabResult *p = (TabResult*)pArg;
77738 int need;
77739 int i;
77740 char *z;
77741
77742 /* Make sure there is enough space in p->azResult to hold everything
77743 ** we need to remember from this invocation of the callback.
77744 */
77745 if( p->nRow==0 && argv!=0 ){
77746 need = nCol*2;
77747 }else{
77748 need = nCol;
77749 }
77750 if( p->nData + need >= p->nAlloc ){
77751 char **azNew;
77752 p->nAlloc = p->nAlloc*2 + need + 1;
77753 azNew = sqlite3_realloc( p->azResult, sizeof(char*)*p->nAlloc );
77754 if( azNew==0 ) goto malloc_failed;
77755 p->azResult = azNew;
77756 }
77757
@@ -77821,11 +78100,10 @@
77821 *pazResult = 0;
77822 if( pnColumn ) *pnColumn = 0;
77823 if( pnRow ) *pnRow = 0;
77824 if( pzErrMsg ) *pzErrMsg = 0;
77825 res.zErrMsg = 0;
77826 res.nResult = 0;
77827 res.nRow = 0;
77828 res.nColumn = 0;
77829 res.nData = 1;
77830 res.nAlloc = 20;
77831 res.rc = SQLITE_OK;
@@ -77855,17 +78133,16 @@
77855 sqlite3_free_table(&res.azResult[1]);
77856 return rc;
77857 }
77858 if( res.nAlloc>res.nData ){
77859 char **azNew;
77860 azNew = sqlite3_realloc( res.azResult, sizeof(char*)*(res.nData+1) );
77861 if( azNew==0 ){
77862 sqlite3_free_table(&res.azResult[1]);
77863 db->errCode = SQLITE_NOMEM;
77864 return SQLITE_NOMEM;
77865 }
77866 res.nAlloc = res.nData+1;
77867 res.azResult = azNew;
77868 }
77869 *pazResult = &res.azResult[1];
77870 if( pnColumn ) *pnColumn = res.nColumn;
77871 if( pnRow ) *pnRow = res.nRow;
@@ -79468,11 +79745,11 @@
79468 ** This file contains code used to implement the VACUUM command.
79469 **
79470 ** Most of the code in this file may be omitted by defining the
79471 ** SQLITE_OMIT_VACUUM macro.
79472 **
79473 ** $Id: vacuum.c,v 1.86 2009/02/03 16:51:25 danielk1977 Exp $
79474 */
79475
79476 #if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)
79477 /*
79478 ** Execute zSql on database db. Return an error code.
@@ -79592,12 +79869,12 @@
79592 sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
79593 if( nKey ) db->nextPagesize = 0;
79594 }
79595 #endif
79596
79597 if( sqlite3BtreeSetPageSize(pTemp, sqlite3BtreeGetPageSize(pMain), nRes)
79598 || (!isMemDb && sqlite3BtreeSetPageSize(pTemp, db->nextPagesize, nRes))
79599 || db->mallocFailed
79600 ){
79601 rc = SQLITE_NOMEM;
79602 goto end_of_vacuum;
79603 }
@@ -79720,11 +79997,11 @@
79720 sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp));
79721 #endif
79722 }
79723
79724 if( rc==SQLITE_OK ){
79725 rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes);
79726 }
79727
79728 end_of_vacuum:
79729 /* Restore the original value of db->flags */
79730 db->flags = saved_flags;
@@ -79765,14 +80042,19 @@
79765 ** May you share freely, never taking more than you give.
79766 **
79767 *************************************************************************
79768 ** This file contains code used to help implement virtual tables.
79769 **
79770 ** $Id: vtab.c,v 1.84 2009/03/24 15:08:10 drh Exp $
79771 */
79772 #ifndef SQLITE_OMIT_VIRTUALTABLE
79773
 
 
 
 
 
79774 static int createModule(
79775 sqlite3 *db, /* Database in which module is registered */
79776 const char *zName, /* Name assigned to this module */
79777 const sqlite3_module *pModule, /* The definition of the module */
79778 void *pAux, /* Context pointer for xCreate/xConnect */
@@ -79850,10 +80132,11 @@
79850 /*
79851 ** Unlock a virtual table. When the last lock is removed,
79852 ** disconnect the virtual table.
79853 */
79854 SQLITE_PRIVATE void sqlite3VtabUnlock(sqlite3 *db, sqlite3_vtab *pVtab){
 
79855 pVtab->nRef--;
79856 assert(db);
79857 assert( sqlite3SafetyCheckOk(db) );
79858 if( pVtab->nRef==0 ){
79859 if( db->magic==SQLITE_MAGIC_BUSY ){
@@ -80618,20 +80901,20 @@
80618 ** generating the code that loops through a table looking for applicable
80619 ** rows. Indices are selected and used to speed the search when doing
80620 ** so is applicable. Because this module is responsible for selecting
80621 ** indices, you might also think of this module as the "query optimizer".
80622 **
80623 ** $Id: where.c,v 1.379 2009/03/29 00:15:54 drh Exp $
80624 */
80625
80626 /*
80627 ** Trace output macros
80628 */
80629 #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
80630 SQLITE_PRIVATE int sqlite3WhereTrace = 0;
80631 #endif
80632 #if 0
80633 # define WHERETRACE(X) if(sqlite3WhereTrace) sqlite3DebugPrintf X
80634 #else
80635 # define WHERETRACE(X)
80636 #endif
80637
@@ -82363,10 +82646,17 @@
82363 */
82364 memset(pCost, 0, sizeof(*pCost));
82365 if( pProbe==0 &&
82366 findTerm(pWC, iCur, -1, 0, WO_EQ|WO_IN|WO_LT|WO_LE|WO_GT|WO_GE,0)==0 &&
82367 (pOrderBy==0 || !sortableByRowid(iCur, pOrderBy, pWC->pMaskSet, &rev)) ){
 
 
 
 
 
 
 
82368 return;
82369 }
82370 pCost->rCost = SQLITE_BIG_DBL;
82371
82372 /* Check for a rowid=EXPR or rowid IN (...) constraints. If there was
@@ -84205,12 +84495,12 @@
84205 #endif
84206 #define sqlite3ParserARG_SDECL Parse *pParse;
84207 #define sqlite3ParserARG_PDECL ,Parse *pParse
84208 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
84209 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
84210 #define YYNSTATE 613
84211 #define YYNRULE 321
84212 #define YYFALLBACK 1
84213 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
84214 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
84215 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
84216
@@ -84265,161 +84555,160 @@
84265 ** yy_reduce_ofst[] For each state, the offset into yy_action for
84266 ** shifting non-terminals after a reduce.
84267 ** yy_default[] Default action for each state.
84268 */
84269 static const YYACTIONTYPE yy_action[] = {
84270 /* 0 */ 304, 935, 176, 612, 2, 150, 214, 438, 24, 24,
84271 /* 10 */ 24, 24, 487, 26, 26, 26, 26, 27, 27, 28,
84272 /* 20 */ 28, 28, 29, 216, 412, 413, 212, 412, 413, 445,
84273 /* 30 */ 451, 31, 26, 26, 26, 26, 27, 27, 28, 28,
84274 /* 40 */ 28, 29, 216, 30, 482, 32, 134, 23, 22, 308,
84275 /* 50 */ 455, 456, 452, 452, 25, 25, 24, 24, 24, 24,
84276 /* 60 */ 435, 26, 26, 26, 26, 27, 27, 28, 28, 28,
84277 /* 70 */ 29, 216, 304, 216, 311, 438, 511, 489, 45, 26,
84278 /* 80 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 216,
84279 /* 90 */ 412, 413, 415, 416, 156, 415, 416, 360, 363, 364,
84280 /* 100 */ 311, 445, 451, 385, 513, 21, 186, 494, 365, 27,
84281 /* 110 */ 27, 28, 28, 28, 29, 216, 412, 413, 414, 23,
84282 /* 120 */ 22, 308, 455, 456, 452, 452, 25, 25, 24, 24,
84283 /* 130 */ 24, 24, 554, 26, 26, 26, 26, 27, 27, 28,
84284 /* 140 */ 28, 28, 29, 216, 304, 228, 503, 135, 467, 218,
84285 /* 150 */ 438, 145, 132, 256, 358, 261, 359, 153, 415, 416,
84286 /* 160 */ 553, 528, 331, 30, 265, 32, 134, 552, 592, 593,
84287 /* 170 */ 230, 228, 489, 445, 451, 57, 505, 328, 132, 256,
84288 /* 180 */ 358, 261, 359, 153, 415, 416, 434, 78, 407, 404,
84289 /* 190 */ 265, 23, 22, 308, 455, 456, 452, 452, 25, 25,
84290 /* 200 */ 24, 24, 24, 24, 476, 26, 26, 26, 26, 27,
84291 /* 210 */ 27, 28, 28, 28, 29, 216, 304, 572, 438, 546,
84292 /* 220 */ 477, 127, 547, 596, 30, 331, 32, 134, 345, 214,
84293 /* 230 */ 428, 63, 331, 355, 414, 478, 241, 341, 414, 342,
84294 /* 240 */ 328, 387, 193, 595, 594, 445, 451, 328, 299, 434,
84295 /* 250 */ 85, 469, 545, 200, 190, 555, 434, 78, 309, 462,
84296 /* 260 */ 463, 571, 471, 23, 22, 308, 455, 456, 452, 452,
84297 /* 270 */ 25, 25, 24, 24, 24, 24, 435, 26, 26, 26,
84298 /* 280 */ 26, 27, 27, 28, 28, 28, 29, 216, 304, 347,
84299 /* 290 */ 221, 191, 512, 429, 544, 331, 440, 234, 345, 430,
84300 /* 300 */ 324, 409, 541, 344, 591, 217, 213, 541, 112, 331,
84301 /* 310 */ 328, 388, 282, 281, 211, 29, 216, 445, 451, 434,
84302 /* 320 */ 79, 217, 214, 334, 328, 458, 458, 442, 442, 442,
84303 /* 330 */ 571, 270, 4, 434, 85, 23, 22, 308, 455, 456,
84304 /* 340 */ 452, 452, 25, 25, 24, 24, 24, 24, 435, 26,
84305 /* 350 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 216,
84306 /* 360 */ 304, 514, 156, 331, 488, 360, 363, 364, 331, 353,
84307 /* 370 */ 431, 247, 395, 274, 220, 272, 365, 352, 328, 331,
84308 /* 380 */ 388, 282, 281, 328, 412, 413, 307, 434, 93, 445,
84309 /* 390 */ 451, 214, 434, 93, 328, 530, 150, 1, 438, 403,
84310 /* 400 */ 468, 412, 413, 434, 78, 40, 210, 23, 22, 308,
84311 /* 410 */ 455, 456, 452, 452, 25, 25, 24, 24, 24, 24,
84312 /* 420 */ 194, 26, 26, 26, 26, 27, 27, 28, 28, 28,
84313 /* 430 */ 29, 216, 304, 319, 331, 596, 507, 535, 320, 179,
84314 /* 440 */ 435, 489, 467, 156, 192, 349, 360, 363, 364, 328,
84315 /* 450 */ 414, 536, 415, 416, 435, 595, 546, 365, 434, 71,
84316 /* 460 */ 378, 445, 451, 208, 240, 381, 438, 556, 63, 415,
84317 /* 470 */ 416, 414, 28, 28, 28, 29, 216, 43, 435, 23,
84318 /* 480 */ 22, 308, 455, 456, 452, 452, 25, 25, 24, 24,
84319 /* 490 */ 24, 24, 276, 26, 26, 26, 26, 27, 27, 28,
84320 /* 500 */ 28, 28, 29, 216, 304, 354, 209, 414, 510, 412,
84321 /* 510 */ 413, 135, 426, 331, 412, 413, 398, 217, 66, 333,
84322 /* 520 */ 328, 564, 412, 413, 30, 563, 32, 134, 328, 434,
84323 /* 530 */ 8, 546, 484, 445, 451, 400, 489, 434, 72, 377,
84324 /* 540 */ 435, 485, 603, 63, 598, 494, 414, 372, 469, 337,
84325 /* 550 */ 200, 23, 22, 308, 455, 456, 452, 452, 25, 25,
84326 /* 560 */ 24, 24, 24, 24, 386, 26, 26, 26, 26, 27,
84327 /* 570 */ 27, 28, 28, 28, 29, 216, 304, 415, 416, 476,
84328 /* 580 */ 527, 60, 415, 416, 222, 402, 389, 498, 185, 331,
84329 /* 590 */ 415, 416, 385, 242, 331, 477, 331, 506, 453, 336,
84330 /* 600 */ 462, 463, 414, 490, 328, 445, 451, 414, 491, 328,
84331 /* 610 */ 478, 328, 518, 434, 67, 613, 407, 404, 434, 76,
84332 /* 620 */ 434, 97, 519, 23, 22, 308, 455, 456, 452, 452,
84333 /* 630 */ 25, 25, 24, 24, 24, 24, 331, 26, 26, 26,
84334 /* 640 */ 26, 27, 27, 28, 28, 28, 29, 216, 304, 331,
84335 /* 650 */ 310, 328, 268, 368, 64, 331, 397, 439, 438, 233,
84336 /* 660 */ 434, 96, 217, 16, 328, 183, 331, 459, 467, 218,
84337 /* 670 */ 328, 446, 447, 434, 101, 214, 154, 445, 451, 434,
84338 /* 680 */ 99, 328, 464, 154, 566, 466, 334, 396, 458, 458,
84339 /* 690 */ 434, 104, 449, 450, 205, 23, 22, 308, 455, 456,
84340 /* 700 */ 452, 452, 25, 25, 24, 24, 24, 24, 331, 26,
84341 /* 710 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 216,
84342 /* 720 */ 304, 448, 331, 328, 390, 56, 438, 331, 435, 331,
84343 /* 730 */ 248, 306, 434, 105, 516, 517, 472, 328, 306, 39,
84344 /* 740 */ 331, 41, 328, 265, 328, 414, 434, 126, 339, 445,
84345 /* 750 */ 451, 434, 128, 434, 59, 328, 334, 250, 458, 458,
84346 /* 760 */ 196, 569, 517, 568, 434, 102, 483, 23, 22, 308,
84347 /* 770 */ 455, 456, 452, 452, 25, 25, 24, 24, 24, 24,
84348 /* 780 */ 331, 26, 26, 26, 26, 27, 27, 28, 28, 28,
84349 /* 790 */ 29, 216, 304, 331, 435, 328, 562, 375, 562, 331,
84350 /* 800 */ 264, 858, 606, 303, 434, 77, 197, 137, 328, 406,
84351 /* 810 */ 2, 331, 178, 215, 328, 414, 486, 434, 100, 136,
84352 /* 820 */ 18, 445, 451, 434, 68, 334, 328, 458, 458, 610,
84353 /* 830 */ 926, 460, 926, 65, 414, 434, 98, 314, 528, 23,
84354 /* 840 */ 22, 308, 455, 456, 452, 452, 25, 25, 24, 24,
84355 /* 850 */ 24, 24, 331, 26, 26, 26, 26, 27, 27, 28,
84356 /* 860 */ 28, 28, 29, 216, 304, 331, 350, 328, 264, 155,
84357 /* 870 */ 264, 331, 607, 331, 201, 137, 434, 129, 433, 574,
84358 /* 880 */ 328, 414, 432, 414, 331, 414, 328, 498, 328, 434,
84359 /* 890 */ 130, 498, 539, 445, 451, 434, 131, 434, 69, 328,
84360 /* 900 */ 362, 334, 414, 458, 458, 229, 414, 315, 434, 80,
84361 /* 910 */ 259, 23, 33, 308, 455, 456, 452, 452, 25, 25,
84362 /* 920 */ 24, 24, 24, 24, 331, 26, 26, 26, 26, 27,
84363 /* 930 */ 27, 28, 28, 28, 29, 216, 304, 331, 264, 328,
84364 /* 940 */ 164, 264, 356, 331, 417, 418, 419, 525, 434, 81,
84365 /* 950 */ 376, 542, 328, 414, 318, 331, 414, 538, 328, 465,
84366 /* 960 */ 465, 434, 70, 322, 175, 445, 451, 434, 82, 433,
84367 /* 970 */ 328, 610, 925, 432, 925, 316, 540, 494, 317, 434,
84368 /* 980 */ 83, 522, 523, 587, 22, 308, 455, 456, 452, 452,
84369 /* 990 */ 25, 25, 24, 24, 24, 24, 331, 26, 26, 26,
84370 /* 1000 */ 26, 27, 27, 28, 28, 28, 29, 216, 304, 331,
84371 /* 1010 */ 209, 328, 257, 249, 607, 331, 252, 202, 203, 204,
84372 /* 1020 */ 434, 84, 290, 258, 328, 532, 531, 331, 414, 394,
84373 /* 1030 */ 328, 331, 533, 434, 86, 332, 141, 445, 451, 434,
84374 /* 1040 */ 87, 47, 328, 496, 435, 151, 328, 537, 410, 155,
84375 /* 1050 */ 414, 434, 88, 534, 494, 434, 73, 308, 455, 456,
84376 /* 1060 */ 452, 452, 25, 25, 24, 24, 24, 24, 386, 26,
84377 /* 1070 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 216,
84378 /* 1080 */ 35, 338, 286, 3, 331, 411, 331, 327, 413, 423,
84379 /* 1090 */ 382, 422, 276, 254, 420, 35, 338, 335, 3, 328,
84380 /* 1100 */ 414, 328, 327, 413, 414, 313, 276, 414, 434, 74,
84381 /* 1110 */ 434, 89, 335, 331, 421, 340, 424, 331, 425, 331,
84382 /* 1120 */ 267, 414, 155, 142, 289, 471, 287, 325, 328, 326,
84383 /* 1130 */ 340, 414, 328, 414, 328, 581, 276, 434, 90, 144,
84384 /* 1140 */ 471, 434, 91, 434, 92, 38, 37, 15, 331, 277,
84385 /* 1150 */ 133, 414, 441, 276, 36, 329, 330, 6, 436, 440,
84386 /* 1160 */ 38, 37, 504, 328, 206, 414, 47, 414, 414, 36,
84387 /* 1170 */ 329, 330, 434, 75, 440, 198, 367, 214, 155, 583,
84388 /* 1180 */ 235, 236, 237, 143, 239, 348, 343, 580, 46, 243,
84389 /* 1190 */ 442, 442, 442, 443, 444, 9, 584, 276, 435, 7,
84390 /* 1200 */ 172, 414, 294, 331, 288, 442, 442, 442, 443, 444,
84391 /* 1210 */ 9, 295, 414, 35, 338, 567, 3, 155, 328, 480,
84392 /* 1220 */ 327, 413, 331, 170, 276, 571, 244, 434, 17, 169,
84393 /* 1230 */ 335, 19, 171, 245, 414, 412, 413, 328, 331, 414,
84394 /* 1240 */ 585, 276, 575, 576, 151, 54, 434, 94, 340, 493,
84395 /* 1250 */ 497, 499, 346, 328, 276, 262, 414, 529, 471, 263,
84396 /* 1260 */ 246, 20, 434, 95, 414, 414, 414, 231, 548, 414,
84397 /* 1270 */ 414, 437, 414, 471, 414, 393, 291, 281, 38, 37,
84398 /* 1280 */ 588, 305, 54, 414, 232, 269, 214, 36, 329, 330,
84399 /* 1290 */ 219, 271, 440, 188, 189, 273, 275, 292, 42, 280,
84400 /* 1300 */ 414, 380, 383, 512, 384, 283, 414, 440, 149, 399,
84401 /* 1310 */ 414, 414, 608, 605, 414, 302, 414, 414, 284, 414,
84402 /* 1320 */ 414, 285, 579, 442, 442, 442, 443, 444, 9, 48,
84403 /* 1330 */ 590, 293, 296, 414, 297, 602, 414, 414, 442, 442,
84404 /* 1340 */ 442, 251, 351, 481, 177, 414, 414, 414, 495, 414,
84405 /* 1350 */ 414, 501, 253, 255, 609, 502, 357, 312, 521, 515,
84406 /* 1360 */ 107, 525, 226, 225, 520, 260, 369, 158, 227, 524,
84407 /* 1370 */ 557, 526, 300, 549, 550, 551, 373, 278, 159, 301,
84408 /* 1380 */ 543, 371, 160, 51, 207, 559, 560, 161, 140, 379,
84409 /* 1390 */ 570, 163, 117, 391, 181, 392, 118, 119, 120, 121,
84410 /* 1400 */ 321, 123, 577, 599, 600, 55, 58, 586, 601, 604,
84411 /* 1410 */ 62, 323, 408, 103, 224, 111, 174, 238, 427, 199,
84412 /* 1420 */ 654, 655, 656, 146, 147, 454, 457, 34, 182, 180,
84413 /* 1430 */ 461, 470, 473, 474, 195, 5, 492, 475, 148, 479,
84414 /* 1440 */ 44, 106, 10, 11, 138, 508, 509, 500, 223, 49,
84415 /* 1450 */ 361, 108, 152, 266, 109, 50, 110, 157, 258, 370,
84416 /* 1460 */ 184, 558, 139, 113, 151, 162, 279, 115, 374, 14,
84417 /* 1470 */ 573, 116, 165, 52, 12, 366, 166, 53, 578, 167,
84418 /* 1480 */ 582, 168, 114, 124, 122, 561, 565, 13, 61, 125,
84419 /* 1490 */ 597, 173, 298, 187, 589, 405, 936, 611, 936, 936,
84420 /* 1500 */ 401,
84421 };
84422 static const YYCODETYPE yy_lookahead[] = {
84423 /* 0 */ 19, 142, 143, 144, 145, 24, 116, 26, 75, 76,
84424 /* 10 */ 77, 78, 25, 80, 81, 82, 83, 84, 85, 86,
84425 /* 20 */ 87, 88, 89, 90, 26, 27, 160, 26, 27, 48,
@@ -84433,290 +84722,289 @@
84433 /* 100 */ 19, 48, 49, 150, 174, 52, 119, 166, 110, 84,
84434 /* 110 */ 85, 86, 87, 88, 89, 90, 26, 27, 165, 66,
84435 /* 120 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
84436 /* 130 */ 77, 78, 186, 80, 81, 82, 83, 84, 85, 86,
84437 /* 140 */ 87, 88, 89, 90, 19, 90, 205, 95, 84, 85,
84438 /* 150 */ 26, 96, 97, 98, 99, 100, 101, 102, 94, 95,
84439 /* 160 */ 181, 182, 150, 222, 109, 224, 225, 188, 104, 105,
84440 /* 170 */ 217, 90, 120, 48, 49, 50, 86, 165, 97, 98,
84441 /* 180 */ 99, 100, 101, 102, 94, 95, 174, 175, 1, 2,
84442 /* 190 */ 109, 66, 67, 68, 69, 70, 71, 72, 73, 74,
84443 /* 200 */ 75, 76, 77, 78, 12, 80, 81, 82, 83, 84,
84444 /* 210 */ 85, 86, 87, 88, 89, 90, 19, 11, 94, 150,
84445 /* 220 */ 28, 24, 186, 150, 222, 150, 224, 225, 216, 116,
84446 /* 230 */ 161, 162, 150, 221, 165, 43, 195, 45, 165, 191,
84447 /* 240 */ 165, 128, 160, 170, 171, 48, 49, 165, 163, 174,
84448 /* 250 */ 175, 166, 167, 168, 185, 186, 174, 175, 169, 170,
84449 /* 260 */ 171, 55, 64, 66, 67, 68, 69, 70, 71, 72,
84450 /* 270 */ 73, 74, 75, 76, 77, 78, 194, 80, 81, 82,
84451 /* 280 */ 83, 84, 85, 86, 87, 88, 89, 90, 19, 214,
84452 /* 290 */ 215, 25, 94, 172, 173, 150, 98, 148, 216, 173,
84453 /* 300 */ 146, 147, 181, 221, 231, 232, 152, 181, 154, 150,
84454 /* 310 */ 165, 105, 106, 107, 160, 89, 90, 48, 49, 174,
84455 /* 320 */ 175, 232, 116, 112, 165, 114, 115, 129, 130, 131,
84456 /* 330 */ 55, 16, 196, 174, 175, 66, 67, 68, 69, 70,
84457 /* 340 */ 71, 72, 73, 74, 75, 76, 77, 78, 194, 80,
84458 /* 350 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
84459 /* 360 */ 19, 165, 96, 150, 208, 99, 100, 101, 150, 19,
84460 /* 370 */ 174, 226, 218, 58, 215, 60, 110, 27, 165, 150,
84461 /* 380 */ 105, 106, 107, 165, 26, 27, 155, 174, 175, 48,
84462 /* 390 */ 49, 116, 174, 175, 165, 183, 24, 22, 26, 245,
84463 /* 400 */ 166, 26, 27, 174, 175, 136, 160, 66, 67, 68,
84464 /* 410 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
84465 /* 420 */ 160, 80, 81, 82, 83, 84, 85, 86, 87, 88,
84466 /* 430 */ 89, 90, 19, 220, 150, 150, 23, 183, 220, 23,
84467 /* 440 */ 194, 25, 84, 96, 160, 216, 99, 100, 101, 165,
84468 /* 450 */ 165, 183, 94, 95, 194, 170, 150, 110, 174, 175,
84469 /* 460 */ 229, 48, 49, 236, 158, 234, 94, 161, 162, 94,
84470 /* 470 */ 95, 165, 86, 87, 88, 89, 90, 136, 194, 66,
84471 /* 480 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
84472 /* 490 */ 77, 78, 150, 80, 81, 82, 83, 84, 85, 86,
84473 /* 500 */ 87, 88, 89, 90, 19, 150, 160, 165, 23, 26,
84474 /* 510 */ 27, 95, 153, 150, 26, 27, 231, 232, 22, 19,
84475 /* 520 */ 165, 29, 26, 27, 222, 33, 224, 225, 165, 174,
84476 /* 530 */ 175, 150, 31, 48, 49, 193, 120, 174, 175, 47,
84477 /* 540 */ 194, 40, 161, 162, 242, 166, 165, 237, 166, 167,
84478 /* 550 */ 168, 66, 67, 68, 69, 70, 71, 72, 73, 74,
84479 /* 560 */ 75, 76, 77, 78, 218, 80, 81, 82, 83, 84,
84480 /* 570 */ 85, 86, 87, 88, 89, 90, 19, 94, 95, 12,
84481 /* 580 */ 23, 235, 94, 95, 205, 243, 240, 150, 196, 150,
84482 /* 590 */ 94, 95, 150, 198, 150, 28, 150, 23, 98, 169,
84483 /* 600 */ 170, 171, 165, 120, 165, 48, 49, 165, 120, 165,
84484 /* 610 */ 43, 165, 45, 174, 175, 0, 1, 2, 174, 175,
84485 /* 620 */ 174, 175, 55, 66, 67, 68, 69, 70, 71, 72,
84486 /* 630 */ 73, 74, 75, 76, 77, 78, 150, 80, 81, 82,
84487 /* 640 */ 83, 84, 85, 86, 87, 88, 89, 90, 19, 150,
84488 /* 650 */ 213, 165, 23, 19, 22, 150, 97, 166, 26, 217,
84489 /* 660 */ 174, 175, 232, 22, 165, 24, 150, 23, 84, 85,
84490 /* 670 */ 165, 48, 49, 174, 175, 116, 49, 48, 49, 174,
84491 /* 680 */ 175, 165, 233, 49, 21, 233, 112, 128, 114, 115,
84492 /* 690 */ 174, 175, 69, 70, 160, 66, 67, 68, 69, 70,
84493 /* 700 */ 71, 72, 73, 74, 75, 76, 77, 78, 150, 80,
84494 /* 710 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
84495 /* 720 */ 19, 98, 150, 165, 61, 24, 94, 150, 194, 150,
84496 /* 730 */ 150, 104, 174, 175, 190, 191, 23, 165, 104, 135,
84497 /* 740 */ 150, 137, 165, 109, 165, 165, 174, 175, 228, 48,
84498 /* 750 */ 49, 174, 175, 174, 175, 165, 112, 209, 114, 115,
84499 /* 760 */ 160, 190, 191, 100, 174, 175, 177, 66, 67, 68,
84500 /* 770 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
84501 /* 780 */ 150, 80, 81, 82, 83, 84, 85, 86, 87, 88,
84502 /* 790 */ 89, 90, 19, 150, 194, 165, 105, 106, 107, 150,
84503 /* 800 */ 150, 138, 248, 249, 174, 175, 206, 207, 165, 144,
84504 /* 810 */ 145, 150, 23, 197, 165, 165, 177, 174, 175, 150,
84505 /* 820 */ 204, 48, 49, 174, 175, 112, 165, 114, 115, 22,
84506 /* 830 */ 23, 23, 25, 25, 165, 174, 175, 187, 182, 66,
84507 /* 840 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
84508 /* 850 */ 77, 78, 150, 80, 81, 82, 83, 84, 85, 86,
84509 /* 860 */ 87, 88, 89, 90, 19, 150, 150, 165, 150, 25,
84510 /* 870 */ 150, 150, 65, 150, 206, 207, 174, 175, 113, 199,
84511 /* 880 */ 165, 165, 117, 165, 150, 165, 165, 150, 165, 174,
84512 /* 890 */ 175, 150, 166, 48, 49, 174, 175, 174, 175, 165,
84513 /* 900 */ 178, 112, 165, 114, 115, 187, 165, 187, 174, 175,
84514 /* 910 */ 177, 66, 67, 68, 69, 70, 71, 72, 73, 74,
84515 /* 920 */ 75, 76, 77, 78, 150, 80, 81, 82, 83, 84,
84516 /* 930 */ 85, 86, 87, 88, 89, 90, 19, 150, 150, 165,
84517 /* 940 */ 25, 150, 86, 150, 7, 8, 9, 103, 174, 175,
84518 /* 950 */ 213, 166, 165, 165, 213, 150, 165, 177, 165, 129,
84519 /* 960 */ 130, 174, 175, 246, 247, 48, 49, 174, 175, 113,
84520 /* 970 */ 165, 22, 23, 117, 25, 187, 177, 166, 187, 174,
84521 /* 980 */ 175, 7, 8, 199, 67, 68, 69, 70, 71, 72,
84522 /* 990 */ 73, 74, 75, 76, 77, 78, 150, 80, 81, 82,
84523 /* 1000 */ 83, 84, 85, 86, 87, 88, 89, 90, 19, 150,
84524 /* 1010 */ 160, 165, 98, 150, 65, 150, 205, 105, 106, 107,
84525 /* 1020 */ 174, 175, 209, 109, 165, 97, 98, 150, 165, 209,
84526 /* 1030 */ 165, 150, 35, 174, 175, 150, 6, 48, 49, 174,
84527 /* 1040 */ 175, 126, 165, 23, 194, 25, 165, 23, 149, 25,
84528 /* 1050 */ 165, 174, 175, 56, 166, 174, 175, 68, 69, 70,
84529 /* 1060 */ 71, 72, 73, 74, 75, 76, 77, 78, 218, 80,
84530 /* 1070 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
84531 /* 1080 */ 19, 20, 16, 22, 150, 150, 150, 26, 27, 150,
84532 /* 1090 */ 240, 13, 150, 205, 149, 19, 20, 36, 22, 165,
84533 /* 1100 */ 165, 165, 26, 27, 165, 108, 150, 165, 174, 175,
84534 /* 1110 */ 174, 175, 36, 150, 149, 54, 150, 150, 150, 150,
84535 /* 1120 */ 23, 165, 25, 151, 58, 64, 60, 149, 165, 159,
84536 /* 1130 */ 54, 165, 165, 165, 165, 193, 150, 174, 175, 151,
84537 /* 1140 */ 64, 174, 175, 174, 175, 84, 85, 22, 150, 193,
84538 /* 1150 */ 150, 165, 150, 150, 93, 94, 95, 25, 194, 98,
84539 /* 1160 */ 84, 85, 86, 165, 160, 165, 126, 165, 165, 93,
84540 /* 1170 */ 94, 95, 174, 175, 98, 5, 23, 116, 25, 193,
84541 /* 1180 */ 10, 11, 12, 13, 14, 123, 150, 17, 124, 199,
84542 /* 1190 */ 129, 130, 131, 132, 133, 134, 193, 150, 194, 74,
84543 /* 1200 */ 30, 165, 32, 150, 138, 129, 130, 131, 132, 133,
84544 /* 1210 */ 134, 41, 165, 19, 20, 23, 22, 25, 165, 150,
84545 /* 1220 */ 26, 27, 150, 53, 150, 55, 200, 174, 175, 59,
84546 /* 1230 */ 36, 22, 62, 201, 165, 26, 27, 165, 150, 165,
84547 /* 1240 */ 193, 150, 23, 23, 25, 25, 174, 175, 54, 150,
84548 /* 1250 */ 150, 150, 122, 165, 150, 150, 165, 150, 64, 150,
84549 /* 1260 */ 202, 125, 174, 175, 165, 165, 165, 193, 150, 165,
84550 /* 1270 */ 165, 203, 165, 64, 165, 105, 106, 107, 84, 85,
84551 /* 1280 */ 23, 111, 25, 165, 193, 150, 116, 93, 94, 95,
84552 /* 1290 */ 227, 150, 98, 84, 85, 150, 150, 193, 135, 150,
84553 /* 1300 */ 165, 150, 150, 94, 150, 150, 165, 98, 118, 139,
84554 /* 1310 */ 165, 165, 23, 23, 165, 25, 165, 165, 150, 165,
84555 /* 1320 */ 165, 150, 150, 129, 130, 131, 132, 133, 134, 104,
84556 /* 1330 */ 150, 150, 150, 165, 150, 150, 165, 165, 129, 130,
84557 /* 1340 */ 131, 210, 121, 157, 157, 165, 165, 165, 211, 165,
84558 /* 1350 */ 165, 211, 210, 210, 65, 211, 104, 46, 184, 176,
84559 /* 1360 */ 22, 103, 90, 230, 176, 176, 18, 156, 230, 178,
84560 /* 1370 */ 157, 176, 179, 176, 176, 176, 44, 238, 156, 179,
84561 /* 1380 */ 184, 157, 156, 135, 157, 157, 239, 156, 66, 157,
84562 /* 1390 */ 189, 189, 22, 157, 219, 18, 192, 192, 192, 192,
84563 /* 1400 */ 157, 189, 199, 39, 157, 241, 241, 199, 157, 37,
84564 /* 1410 */ 244, 250, 1, 164, 180, 180, 247, 15, 23, 22,
84565 /* 1420 */ 118, 118, 118, 118, 118, 98, 113, 22, 22, 219,
84566 /* 1430 */ 23, 23, 11, 23, 22, 34, 120, 23, 25, 23,
84567 /* 1440 */ 25, 22, 25, 34, 118, 23, 23, 27, 50, 22,
84568 /* 1450 */ 50, 22, 34, 23, 22, 22, 22, 102, 109, 19,
84569 /* 1460 */ 24, 20, 38, 104, 25, 104, 138, 22, 42, 5,
84570 /* 1470 */ 1, 108, 127, 74, 22, 50, 119, 74, 1, 16,
84571 /* 1480 */ 20, 121, 51, 108, 119, 57, 51, 22, 16, 127,
84572 /* 1490 */ 23, 15, 140, 22, 128, 3, 251, 4, 251, 251,
84573 /* 1500 */ 63,
84574 };
84575 #define YY_SHIFT_USE_DFLT (-111)
84576 #define YY_SHIFT_MAX 405
84577 static const short yy_shift_ofst[] = {
84578 /* 0 */ 187, 1061, 1170, 1061, 1194, 1194, -2, 64, -19, 1194,
84579 /* 10 */ 1194, 1194, 1194, 1194, 275, 358, 1, 125, 1076, 1194,
84580 /* 20 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194,
84581 /* 30 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194,
84582 /* 40 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194,
84583 /* 50 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, -48,
84584 /* 60 */ 206, 1, 1, 124, 584, 584, -110, 53, 197, 269,
84585 /* 70 */ 341, 413, 485, 557, 629, 701, 773, 845, 773, 773,
84586 /* 80 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773,
84587 /* 90 */ 773, 773, 773, 773, 773, 773, 917, 989, 989, -67,
84588 /* 100 */ -67, -1, -1, 55, 25, 386, 1, 1, 1, 1,
84589 /* 110 */ 1, 634, 663, 1, 1, 1, 1, 1, 1, 1,
84590 /* 120 */ 1, 1, 1, 1, 1, 1, 226, 124, -17, -111,
84591 /* 130 */ -111, -111, 1209, 81, 375, 483, 488, 496, 90, 567,
84592 /* 140 */ 567, 1, 1, 1, 1, 1, 1, 1, 1, 1,
84593 /* 150 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
84594 /* 160 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
84595 /* 170 */ 1, 1, 1, 1, 807, 949, 615, 372, 372, 372,
84596 /* 180 */ 559, 113, -110, -110, -110, -111, -111, -111, 198, 198,
84597 /* 190 */ 266, 347, 574, 644, 713, 192, 789, 416, 937, 856,
84598 /* 200 */ 632, 52, 997, 997, 997, 211, 211, 492, 691, 211,
84599 /* 210 */ 211, 211, 211, 641, 765, -13, 124, 830, 830, 604,
84600 /* 220 */ 501, 501, 350, 501, 627, 501, 124, 501, 124, 844,
84601 /* 230 */ 915, 350, 350, 915, 1030, 1030, 1030, 1030, 1078, 1078,
84602 /* 240 */ 1132, -110, 1040, 1062, 1064, 1130, 1136, 1163, 1190, 1190,
84603 /* 250 */ 1225, 1221, 1225, 1221, 1225, 1221, 1252, 1252, 1311, 1252,
84604 /* 260 */ 1258, 1252, 1338, 1272, 1272, 1311, 1252, 1252, 1252, 1338,
84605 /* 270 */ 1348, 1190, 1348, 1190, 1348, 1190, 1190, 1332, 1248, 1348,
84606 /* 280 */ 1190, 1322, 1322, 1370, 1040, 1190, 1377, 1377, 1377, 1377,
84607 /* 290 */ 1040, 1322, 1370, 1190, 1364, 1364, 1190, 1190, 1372, -111,
84608 /* 300 */ -111, -111, -111, -111, 623, 1066, 912, 315, 500, 808,
84609 /* 310 */ 1020, 914, 974, 928, 1024, 1097, 1153, 1192, 1219, 1220,
84610 /* 320 */ 1257, 1125, 1290, 1289, 1411, 1402, 1395, 1397, 1302, 1303,
84611 /* 330 */ 1304, 1305, 1306, 1327, 1313, 1405, 1407, 1408, 1406, 1421,
84612 /* 340 */ 1412, 1410, 1413, 1414, 1416, 1415, 1401, 1417, 1409, 1415,
84613 /* 350 */ 1316, 1419, 1418, 1420, 1326, 1422, 1423, 1424, 1398, 1427,
84614 /* 360 */ 1400, 1429, 1430, 1432, 1433, 1425, 1434, 1355, 1349, 1440,
84615 /* 370 */ 1441, 1436, 1359, 1426, 1428, 1431, 1439, 1435, 1328, 1361,
84616 /* 380 */ 1445, 1464, 1469, 1363, 1399, 1403, 1345, 1452, 1357, 1477,
84617 /* 390 */ 1463, 1360, 1460, 1365, 1375, 1362, 1465, 1366, 1467, 1472,
84618 /* 400 */ 1437, 1476, 1352, 1471, 1492, 1493,
84619 };
84620 #define YY_REDUCE_USE_DFLT (-180)
84621 #define YY_REDUCE_MAX 303
84622 static const short yy_reduce_ofst[] = {
84623 /* 0 */ -141, 82, 154, 284, 12, 75, 69, 73, -59, 145,
84624 /* 10 */ 159, 229, 213, 218, 346, 285, 306, 302, 355, 363,
84625 /* 20 */ 439, 444, 446, 486, 499, 505, 516, 558, 572, 577,
84626 /* 30 */ 579, 590, 630, 643, 649, 661, 702, 715, 721, 723,
84627 /* 40 */ 734, 774, 787, 793, 805, 846, 859, 865, 877, 881,
84628 /* 50 */ 934, 936, 963, 967, 969, 998, 1053, 1072, 1088, -179,
84629 /* 60 */ 850, 342, 381, 85, 89, 430, 600, 2, 2, 2,
84630 /* 70 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
84631 /* 80 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
84632 /* 90 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
84633 /* 100 */ 2, 2, 2, 121, 2, 2, 437, 650, 718, 720,
84634 /* 110 */ 788, -21, 231, 956, 737, 791, -47, 741, 942, 986,
84635 /* 120 */ 1003, 1047, 1074, 1091, 442, 1104, 2, 382, 2, 2,
84636 /* 130 */ 2, 2, 196, 126, 580, 669, 716, 863, 885, 544,
84637 /* 140 */ 571, 935, 939, 966, 968, 1000, 885, 1002, 1036, 1069,
84638 /* 150 */ 1099, 1100, 1101, 1105, 1107, 1109, 1118, 1135, 1141, 1145,
84639 /* 160 */ 1146, 1149, 1151, 1152, 1154, 1155, 1168, 1171, 1172, 1180,
84640 /* 170 */ 1181, 1182, 1184, 1185, 554, 554, 665, 379, 811, 888,
84641 /* 180 */ -134, 246, 260, 534, 1004, 616, 668, 717, -98, -70,
84642 /* 190 */ -54, 36, 41, 41, 41, 48, 41, 156, 149, 136,
84643 /* 200 */ 234, 156, 212, 254, 268, 41, 41, 227, 310, 41,
84644 /* 210 */ 41, 41, 41, 359, 392, 395, 491, 449, 452, 520,
84645 /* 220 */ 589, 639, 548, 733, 656, 780, 726, 799, 785, 722,
84646 /* 230 */ 680, 813, 820, 784, 899, 945, 965, 978, 972, 988,
84647 /* 240 */ 970, 964, 990, 1026, 1032, 1058, 1068, 1063, 1186, 1187,
84648 /* 250 */ 1131, 1137, 1142, 1140, 1143, 1144, 1183, 1188, 1174, 1189,
84649 /* 260 */ 1191, 1195, 1193, 1133, 1138, 1196, 1197, 1198, 1199, 1200,
84650 /* 270 */ 1211, 1213, 1222, 1224, 1226, 1227, 1228, 1139, 1147, 1231,
84651 /* 280 */ 1232, 1201, 1202, 1175, 1203, 1236, 1204, 1205, 1206, 1207,
84652 /* 290 */ 1208, 1212, 1210, 1243, 1164, 1165, 1247, 1251, 1166, 1249,
84653 /* 300 */ 1234, 1235, 1169, 1161,
84654 };
84655 static const YYACTIONTYPE yy_default[] = {
84656 /* 0 */ 618, 853, 934, 934, 853, 934, 934, 880, 741, 851,
84657 /* 10 */ 934, 934, 934, 934, 934, 880, 934, 909, 934, 934,
84658 /* 20 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84659 /* 30 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84660 /* 40 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84661 /* 50 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 825,
84662 /* 60 */ 934, 934, 934, 657, 880, 880, 745, 776, 934, 934,
84663 /* 70 */ 934, 934, 934, 934, 934, 934, 777, 934, 855, 850,
84664 /* 80 */ 846, 848, 847, 854, 778, 767, 774, 781, 756, 893,
84665 /* 90 */ 783, 784, 790, 791, 910, 908, 813, 812, 831, 815,
84666 /* 100 */ 837, 814, 824, 649, 816, 817, 934, 934, 934, 934,
84667 /* 110 */ 934, 710, 644, 934, 934, 934, 934, 934, 934, 934,
84668 /* 120 */ 934, 934, 934, 934, 934, 934, 818, 934, 819, 832,
84669 /* 130 */ 833, 834, 934, 934, 934, 934, 934, 934, 934, 934,
84670 /* 140 */ 934, 624, 934, 934, 934, 934, 934, 934, 934, 934,
84671 /* 150 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84672 /* 160 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 866,
84673 /* 170 */ 934, 913, 915, 934, 934, 934, 618, 741, 741, 741,
84674 /* 180 */ 934, 934, 934, 934, 934, 735, 745, 927, 934, 934,
84675 /* 190 */ 701, 934, 934, 934, 934, 934, 934, 934, 626, 733,
84676 /* 200 */ 659, 743, 934, 934, 934, 646, 722, 886, 934, 900,
84677 /* 210 */ 898, 724, 786, 934, 733, 742, 934, 934, 934, 849,
84678 /* 220 */ 770, 770, 758, 770, 680, 770, 934, 770, 934, 683,
84679 /* 230 */ 780, 758, 758, 780, 623, 623, 623, 623, 634, 634,
84680 /* 240 */ 700, 934, 780, 771, 773, 763, 775, 934, 749, 749,
84681 /* 250 */ 757, 762, 757, 762, 757, 762, 712, 712, 697, 712,
84682 /* 260 */ 683, 712, 859, 863, 863, 697, 712, 712, 712, 859,
84683 /* 270 */ 641, 749, 641, 749, 641, 749, 749, 890, 892, 641,
84684 /* 280 */ 749, 714, 714, 792, 780, 749, 721, 721, 721, 721,
84685 /* 290 */ 780, 714, 792, 749, 912, 912, 749, 749, 920, 667,
84686 /* 300 */ 685, 685, 927, 932, 934, 934, 934, 934, 934, 934,
84687 /* 310 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84688 /* 320 */ 934, 873, 934, 934, 934, 632, 934, 651, 799, 804,
84689 /* 330 */ 800, 934, 801, 934, 727, 934, 934, 934, 934, 934,
84690 /* 340 */ 934, 934, 934, 934, 934, 852, 934, 764, 934, 772,
84691 /* 350 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84692 /* 360 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84693 /* 370 */ 934, 934, 934, 934, 934, 888, 889, 934, 934, 934,
84694 /* 380 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84695 /* 390 */ 934, 934, 934, 934, 934, 934, 934, 934, 934, 934,
84696 /* 400 */ 919, 934, 934, 922, 619, 934, 614, 616, 617, 621,
84697 /* 410 */ 622, 625, 651, 652, 654, 655, 656, 627, 628, 629,
84698 /* 420 */ 630, 631, 633, 637, 635, 636, 638, 645, 647, 666,
84699 /* 430 */ 668, 670, 731, 732, 796, 725, 726, 730, 653, 807,
84700 /* 440 */ 798, 802, 803, 805, 806, 820, 821, 823, 829, 836,
84701 /* 450 */ 839, 822, 827, 828, 830, 835, 838, 728, 729, 842,
84702 /* 460 */ 660, 661, 664, 665, 876, 878, 877, 879, 663, 662,
84703 /* 470 */ 808, 811, 844, 845, 901, 902, 903, 904, 905, 840,
84704 /* 480 */ 750, 843, 826, 765, 768, 769, 766, 734, 744, 752,
84705 /* 490 */ 753, 754, 755, 739, 740, 746, 761, 794, 795, 759,
84706 /* 500 */ 760, 747, 748, 736, 737, 738, 841, 797, 809, 810,
84707 /* 510 */ 671, 672, 804, 673, 674, 675, 713, 716, 717, 718,
84708 /* 520 */ 676, 695, 698, 699, 677, 684, 678, 679, 686, 687,
84709 /* 530 */ 688, 691, 692, 693, 694, 689, 690, 860, 861, 864,
84710 /* 540 */ 862, 681, 682, 696, 669, 658, 650, 702, 705, 706,
84711 /* 550 */ 707, 708, 709, 711, 703, 704, 648, 639, 642, 751,
84712 /* 560 */ 882, 891, 887, 883, 884, 885, 643, 856, 857, 715,
84713 /* 570 */ 788, 789, 881, 894, 896, 793, 897, 899, 895, 924,
84714 /* 580 */ 640, 719, 720, 723, 865, 906, 779, 782, 785, 787,
84715 /* 590 */ 867, 868, 869, 870, 871, 874, 875, 872, 907, 911,
84716 /* 600 */ 914, 916, 917, 918, 921, 923, 928, 929, 930, 933,
84717 /* 610 */ 931, 620, 615,
84718 };
84719 #define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))
84720
84721 /* The next table maps tokens into fallback tokens. If a construct
84722 ** like the following:
@@ -85271,76 +85559,78 @@
85271 /* 250 */ "collate ::=",
85272 /* 251 */ "collate ::= COLLATE ids",
85273 /* 252 */ "cmd ::= DROP INDEX ifexists fullname",
85274 /* 253 */ "cmd ::= VACUUM",
85275 /* 254 */ "cmd ::= VACUUM nm",
85276 /* 255 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
85277 /* 256 */ "cmd ::= PRAGMA nm dbnm EQ ON",
85278 /* 257 */ "cmd ::= PRAGMA nm dbnm EQ DELETE",
85279 /* 258 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
85280 /* 259 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
85281 /* 260 */ "cmd ::= PRAGMA nm dbnm",
85282 /* 261 */ "nmnum ::= plus_num",
85283 /* 262 */ "nmnum ::= nm",
85284 /* 263 */ "plus_num ::= plus_opt number",
85285 /* 264 */ "minus_num ::= MINUS number",
85286 /* 265 */ "number ::= INTEGER|FLOAT",
85287 /* 266 */ "plus_opt ::= PLUS",
85288 /* 267 */ "plus_opt ::=",
85289 /* 268 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
85290 /* 269 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
85291 /* 270 */ "trigger_time ::= BEFORE",
85292 /* 271 */ "trigger_time ::= AFTER",
85293 /* 272 */ "trigger_time ::= INSTEAD OF",
85294 /* 273 */ "trigger_time ::=",
85295 /* 274 */ "trigger_event ::= DELETE|INSERT",
85296 /* 275 */ "trigger_event ::= UPDATE",
85297 /* 276 */ "trigger_event ::= UPDATE OF inscollist",
85298 /* 277 */ "foreach_clause ::=",
85299 /* 278 */ "foreach_clause ::= FOR EACH ROW",
85300 /* 279 */ "when_clause ::=",
85301 /* 280 */ "when_clause ::= WHEN expr",
85302 /* 281 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
85303 /* 282 */ "trigger_cmd_list ::= trigger_cmd SEMI",
85304 /* 283 */ "trigger_cmd ::= UPDATE orconf nm SET setlist where_opt",
85305 /* 284 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP",
85306 /* 285 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt select",
85307 /* 286 */ "trigger_cmd ::= DELETE FROM nm where_opt",
85308 /* 287 */ "trigger_cmd ::= select",
85309 /* 288 */ "expr ::= RAISE LP IGNORE RP",
85310 /* 289 */ "expr ::= RAISE LP raisetype COMMA nm RP",
85311 /* 290 */ "raisetype ::= ROLLBACK",
85312 /* 291 */ "raisetype ::= ABORT",
85313 /* 292 */ "raisetype ::= FAIL",
85314 /* 293 */ "cmd ::= DROP TRIGGER ifexists fullname",
85315 /* 294 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
85316 /* 295 */ "cmd ::= DETACH database_kw_opt expr",
85317 /* 296 */ "key_opt ::=",
85318 /* 297 */ "key_opt ::= KEY expr",
85319 /* 298 */ "database_kw_opt ::= DATABASE",
85320 /* 299 */ "database_kw_opt ::=",
85321 /* 300 */ "cmd ::= REINDEX",
85322 /* 301 */ "cmd ::= REINDEX nm dbnm",
85323 /* 302 */ "cmd ::= ANALYZE",
85324 /* 303 */ "cmd ::= ANALYZE nm dbnm",
85325 /* 304 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
85326 /* 305 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
85327 /* 306 */ "add_column_fullname ::= fullname",
85328 /* 307 */ "kwcolumn_opt ::=",
85329 /* 308 */ "kwcolumn_opt ::= COLUMNKW",
85330 /* 309 */ "cmd ::= create_vtab",
85331 /* 310 */ "cmd ::= create_vtab LP vtabarglist RP",
85332 /* 311 */ "create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm",
85333 /* 312 */ "vtabarglist ::= vtabarg",
85334 /* 313 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
85335 /* 314 */ "vtabarg ::=",
85336 /* 315 */ "vtabarg ::= vtabarg vtabargtoken",
85337 /* 316 */ "vtabargtoken ::= ANY",
85338 /* 317 */ "vtabargtoken ::= lp anylist RP",
85339 /* 318 */ "lp ::= LP",
85340 /* 319 */ "anylist ::=",
85341 /* 320 */ "anylist ::= anylist ANY",
 
 
85342 };
85343 #endif /* NDEBUG */
85344
85345
85346 #if YYSTACKDEPTH<=0
@@ -85963,16 +86253,18 @@
85963 { 230, 0 },
85964 { 230, 2 },
85965 { 147, 4 },
85966 { 147, 1 },
85967 { 147, 2 },
85968 { 147, 5 },
85969 { 147, 5 },
85970 { 147, 5 },
85971 { 147, 5 },
85972 { 147, 6 },
85973 { 147, 3 },
 
 
85974 { 231, 1 },
85975 { 231, 1 },
85976 { 170, 2 },
85977 { 171, 2 },
85978 { 233, 1 },
@@ -86108,22 +86400,22 @@
86108 case 62: /* ccons ::= NULL onconf */
86109 case 89: /* conslist ::= conslist COMMA tcons */
86110 case 90: /* conslist ::= conslist tcons */
86111 case 91: /* conslist ::= tcons */
86112 case 92: /* tcons ::= CONSTRAINT nm */
86113 case 266: /* plus_opt ::= PLUS */
86114 case 267: /* plus_opt ::= */
86115 case 277: /* foreach_clause ::= */
86116 case 278: /* foreach_clause ::= FOR EACH ROW */
86117 case 298: /* database_kw_opt ::= DATABASE */
86118 case 299: /* database_kw_opt ::= */
86119 case 307: /* kwcolumn_opt ::= */
86120 case 308: /* kwcolumn_opt ::= COLUMNKW */
86121 case 312: /* vtabarglist ::= vtabarg */
86122 case 313: /* vtabarglist ::= vtabarglist COMMA vtabarg */
86123 case 315: /* vtabarg ::= vtabarg vtabargtoken */
86124 case 319: /* anylist ::= */
86125 {
86126 }
86127 break;
86128 case 5: /* explain ::= */
86129 { sqlite3BeginParse(pParse, 0); }
@@ -86240,15 +86532,18 @@
86240 case 126: /* as ::= AS nm */
86241 case 127: /* as ::= ids */
86242 case 137: /* dbnm ::= DOT nm */
86243 case 146: /* indexed_opt ::= INDEXED BY nm */
86244 case 251: /* collate ::= COLLATE ids */
86245 case 261: /* nmnum ::= plus_num */
86246 case 262: /* nmnum ::= nm */
86247 case 263: /* plus_num ::= plus_opt number */
86248 case 264: /* minus_num ::= MINUS number */
86249 case 265: /* number ::= INTEGER|FLOAT */
 
 
 
86250 {yygotominor.yy0 = yymsp[0].minor.yy0;}
86251 break;
86252 case 45: /* type ::= typetoken */
86253 {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);}
86254 break;
@@ -86888,11 +87183,11 @@
86888 sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy148, yymsp[-9].minor.yy194,
86889 &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy194);
86890 }
86891 break;
86892 case 244: /* uniqueflag ::= UNIQUE */
86893 case 291: /* raisetype ::= ABORT */
86894 {yygotominor.yy194 = OE_Abort;}
86895 break;
86896 case 245: /* uniqueflag ::= */
86897 {yygotominor.yy194 = OE_None;}
86898 break;
@@ -86928,66 +87223,65 @@
86928 break;
86929 case 253: /* cmd ::= VACUUM */
86930 case 254: /* cmd ::= VACUUM nm */
86931 {sqlite3Vacuum(pParse);}
86932 break;
86933 case 255: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
86934 case 256: /* cmd ::= PRAGMA nm dbnm EQ ON */
86935 case 257: /* cmd ::= PRAGMA nm dbnm EQ DELETE */
 
86936 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
86937 break;
86938 case 258: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
86939 {
86940 sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);
86941 }
86942 break;
86943 case 259: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
86944 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
86945 break;
86946 case 260: /* cmd ::= PRAGMA nm dbnm */
86947 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
 
 
 
86948 break;
86949 case 268: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
86950 {
86951 Token all;
86952 all.z = yymsp[-3].minor.yy0.z;
86953 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
86954 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
86955 }
86956 break;
86957 case 269: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
86958 {
86959 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
86960 yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
86961 }
86962 break;
86963 case 270: /* trigger_time ::= BEFORE */
86964 case 273: /* trigger_time ::= */
86965 { yygotominor.yy194 = TK_BEFORE; }
86966 break;
86967 case 271: /* trigger_time ::= AFTER */
86968 { yygotominor.yy194 = TK_AFTER; }
86969 break;
86970 case 272: /* trigger_time ::= INSTEAD OF */
86971 { yygotominor.yy194 = TK_INSTEAD;}
86972 break;
86973 case 274: /* trigger_event ::= DELETE|INSERT */
86974 case 275: /* trigger_event ::= UPDATE */
86975 {yygotominor.yy332.a = yymsp[0].major; yygotominor.yy332.b = 0;}
86976 break;
86977 case 276: /* trigger_event ::= UPDATE OF inscollist */
86978 {yygotominor.yy332.a = TK_UPDATE; yygotominor.yy332.b = yymsp[0].minor.yy254;}
86979 break;
86980 case 279: /* when_clause ::= */
86981 case 296: /* key_opt ::= */
86982 { yygotominor.yy72 = 0; }
86983 break;
86984 case 280: /* when_clause ::= WHEN expr */
86985 case 297: /* key_opt ::= KEY expr */
86986 { yygotominor.yy72 = yymsp[0].minor.yy72; }
86987 break;
86988 case 281: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
86989 {
86990 /*
86991 if( yymsp[-2].minor.yy145 ){
86992 yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
86993 }else{
@@ -86998,118 +87292,118 @@
86998 yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
86999 yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
87000 yygotominor.yy145 = yymsp[-2].minor.yy145;
87001 }
87002 break;
87003 case 282: /* trigger_cmd_list ::= trigger_cmd SEMI */
87004 {
87005 /* if( yymsp[-1].minor.yy145 ) */
87006 assert( yymsp[-1].minor.yy145!=0 );
87007 yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
87008 yygotominor.yy145 = yymsp[-1].minor.yy145;
87009 }
87010 break;
87011 case 283: /* trigger_cmd ::= UPDATE orconf nm SET setlist where_opt */
87012 { yygotominor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-4].minor.yy194); }
87013 break;
87014 case 284: /* trigger_cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP */
87015 {yygotominor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy254, yymsp[-1].minor.yy148, 0, yymsp[-7].minor.yy194);}
87016 break;
87017 case 285: /* trigger_cmd ::= insert_cmd INTO nm inscollist_opt select */
87018 {yygotominor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, 0, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);}
87019 break;
87020 case 286: /* trigger_cmd ::= DELETE FROM nm where_opt */
87021 {yygotominor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-1].minor.yy0, yymsp[0].minor.yy72);}
87022 break;
87023 case 287: /* trigger_cmd ::= select */
87024 {yygotominor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); }
87025 break;
87026 case 288: /* expr ::= RAISE LP IGNORE RP */
87027 {
87028 yygotominor.yy72 = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
87029 if( yygotominor.yy72 ){
87030 yygotominor.yy72->affinity = OE_Ignore;
87031 sqlite3ExprSpan(yygotominor.yy72, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0);
87032 }
87033 }
87034 break;
87035 case 289: /* expr ::= RAISE LP raisetype COMMA nm RP */
87036 {
87037 yygotominor.yy72 = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
87038 if( yygotominor.yy72 ) {
87039 yygotominor.yy72->affinity = (char)yymsp[-3].minor.yy194;
87040 sqlite3ExprSpan(yygotominor.yy72, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0);
87041 }
87042 }
87043 break;
87044 case 290: /* raisetype ::= ROLLBACK */
87045 {yygotominor.yy194 = OE_Rollback;}
87046 break;
87047 case 292: /* raisetype ::= FAIL */
87048 {yygotominor.yy194 = OE_Fail;}
87049 break;
87050 case 293: /* cmd ::= DROP TRIGGER ifexists fullname */
87051 {
87052 sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
87053 }
87054 break;
87055 case 294: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
87056 {
87057 sqlite3Attach(pParse, yymsp[-3].minor.yy72, yymsp[-1].minor.yy72, yymsp[0].minor.yy72);
87058 }
87059 break;
87060 case 295: /* cmd ::= DETACH database_kw_opt expr */
87061 {
87062 sqlite3Detach(pParse, yymsp[0].minor.yy72);
87063 }
87064 break;
87065 case 300: /* cmd ::= REINDEX */
87066 {sqlite3Reindex(pParse, 0, 0);}
87067 break;
87068 case 301: /* cmd ::= REINDEX nm dbnm */
87069 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
87070 break;
87071 case 302: /* cmd ::= ANALYZE */
87072 {sqlite3Analyze(pParse, 0, 0);}
87073 break;
87074 case 303: /* cmd ::= ANALYZE nm dbnm */
87075 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
87076 break;
87077 case 304: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
87078 {
87079 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
87080 }
87081 break;
87082 case 305: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
87083 {
87084 sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0);
87085 }
87086 break;
87087 case 306: /* add_column_fullname ::= fullname */
87088 {
87089 pParse->db->lookaside.bEnabled = 0;
87090 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
87091 }
87092 break;
87093 case 309: /* cmd ::= create_vtab */
87094 {sqlite3VtabFinishParse(pParse,0);}
87095 break;
87096 case 310: /* cmd ::= create_vtab LP vtabarglist RP */
87097 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
87098 break;
87099 case 311: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */
87100 {
87101 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
87102 }
87103 break;
87104 case 314: /* vtabarg ::= */
87105 {sqlite3VtabArgInit(pParse);}
87106 break;
87107 case 316: /* vtabargtoken ::= ANY */
87108 case 317: /* vtabargtoken ::= lp anylist RP */
87109 case 318: /* lp ::= LP */
87110 case 320: /* anylist ::= anylist ANY */
87111 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
87112 break;
87113 };
87114 yygoto = yyRuleInfo[yyruleno].lhs;
87115 yysize = yyRuleInfo[yyruleno].nrhs;
@@ -88437,11 +88731,11 @@
88437 ** Main file for the SQLite library. The routines in this file
88438 ** implement the programmer interface to the library. Routines in
88439 ** other files are for internal use by SQLite and should not be
88440 ** accessed by users of the library.
88441 **
88442 ** $Id: main.c,v 1.534 2009/03/23 04:33:32 danielk1977 Exp $
88443 */
88444
88445 #ifdef SQLITE_ENABLE_FTS3
88446 /************** Include fts3.h in the middle of main.c ***********************/
88447 /************** Begin file fts3.h ********************************************/
@@ -88729,10 +89023,11 @@
88729 sqlite3GlobalConfig.isMallocInit = 0;
88730 sqlite3PcacheShutdown();
88731 if( sqlite3GlobalConfig.isInit ){
88732 sqlite3_os_end();
88733 }
 
88734 sqlite3MallocEnd();
88735 sqlite3MutexEnd();
88736 sqlite3GlobalConfig.isInit = 0;
88737 return SQLITE_OK;
88738 }
@@ -88928,11 +89223,11 @@
88928 db->lookaside.pFree = 0;
88929 db->lookaside.sz = (u16)sz;
88930 if( pStart ){
88931 int i;
88932 LookasideSlot *p;
88933 assert( sz > sizeof(LookasideSlot*) );
88934 p = (LookasideSlot*)pStart;
88935 for(i=cnt-1; i>=0; i--){
88936 p->pNext = db->lookaside.pFree;
88937 db->lookaside.pFree = p;
88938 p = (LookasideSlot*)&((u8*)p)[sz];
@@ -90705,11 +91000,11 @@
90705 *************************************************************************
90706 **
90707 ** This file contains the implementation of the sqlite3_unlock_notify()
90708 ** API method and its associated functionality.
90709 **
90710 ** $Id: notify.c,v 1.2 2009/03/25 16:51:43 drh Exp $
90711 */
90712
90713 /* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */
90714 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
90715
@@ -90802,26 +91097,44 @@
90802 }
90803
90804 /*
90805 ** Obtain the STATIC_MASTER mutex.
90806 */
90807 static void enterMutex(){
90808 sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
90809 checkListProperties(0);
90810 }
90811
90812 /*
90813 ** Release the STATIC_MASTER mutex.
90814 */
90815 static void leaveMutex(){
90816 assertMutexHeld();
90817 checkListProperties(0);
90818 sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
90819 }
90820
90821 /*
90822 ** Register an unlock-notify callback.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90823 */
90824 SQLITE_API int sqlite3_unlock_notify(
90825 sqlite3 *db,
90826 void (*xNotify)(void **, int),
90827 void *pArg
@@ -90829,20 +91142,25 @@
90829 int rc = SQLITE_OK;
90830
90831 sqlite3_mutex_enter(db->mutex);
90832 enterMutex();
90833
90834 if( 0==db->pBlockingConnection ){
 
 
 
 
 
90835 /* The blocking transaction has been concluded. Or there never was a
90836 ** blocking transaction. In either case, invoke the notify callback
90837 ** immediately.
90838 */
90839 xNotify(&pArg, 1);
90840 }else{
90841 sqlite3 *p;
90842
90843 for(p=db->pBlockingConnection; p && p!=db; p=p->pUnlockConnection);
90844 if( p ){
90845 rc = SQLITE_LOCKED; /* Deadlock detected. */
90846 }else{
90847 db->pUnlockConnection = db->pBlockingConnection;
90848 db->xUnlockNotify = xNotify;
@@ -90873,11 +91191,12 @@
90873 db->pBlockingConnection = pBlocker;
90874 leaveMutex();
90875 }
90876
90877 /*
90878 ** The transaction opened by database db has just finished. Locks held
 
90879 ** by database connection db have been released.
90880 **
90881 ** This function loops through each entry in the blocked connections
90882 ** list and does the following:
90883 **
@@ -90894,15 +91213,15 @@
90894 */
90895 SQLITE_PRIVATE void sqlite3ConnectionUnlocked(sqlite3 *db){
90896 void (*xUnlockNotify)(void **, int) = 0; /* Unlock-notify cb to invoke */
90897 int nArg = 0; /* Number of entries in aArg[] */
90898 sqlite3 **pp; /* Iterator variable */
 
 
 
90899
90900 void *aStatic[16];
90901 void **aArg = aStatic;
90902 void **aDyn = 0;
90903
90904 enterMutex(); /* Enter STATIC_MASTER mutex */
90905
90906 /* This loop runs once for each entry in the blocked-connections list. */
90907 for(pp=&sqlite3BlockedList; *pp; /* no-op */ ){
90908 sqlite3 *p = *pp;
90909
--- 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.6.13. 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 ** 5503 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 2009-04-13 09:47:15 UTC.
21 */
22 #define SQLITE_CORE 1
23 #define SQLITE_AMALGAMATION 1
24 #ifndef SQLITE_PRIVATE
25 # define SQLITE_PRIVATE static
@@ -39,11 +39,11 @@
39 ** May you share freely, never taking more than you give.
40 **
41 *************************************************************************
42 ** Internal interface definitions for SQLite.
43 **
44 ** @(#) $Id: sqliteInt.h,v 1.854 2009/04/08 13:51:51 drh Exp $
45 */
46 #ifndef _SQLITEINT_H_
47 #define _SQLITEINT_H_
48
49 /*
@@ -530,11 +530,11 @@
530 ** The name of this file under configuration management is "sqlite.h.in".
531 ** The makefile makes some minor changes to this file (such as inserting
532 ** the version number) and changes its name to "sqlite3.h" as
533 ** part of the build process.
534 **
535 ** @(#) $Id: sqlite.h.in,v 1.440 2009/04/06 15:55:04 drh Exp $
536 */
537 #ifndef _SQLITE3_H_
538 #define _SQLITE3_H_
539 #include <stdarg.h> /* Needed for the definition of va_list */
540
@@ -599,12 +599,12 @@
599 **
600 ** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()].
601 **
602 ** Requirements: [H10011] [H10014]
603 */
604 #define SQLITE_VERSION "3.6.13"
605 #define SQLITE_VERSION_NUMBER 3006013
606
607 /*
608 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
609 ** KEYWORDS: sqlite3_version
610 **
@@ -882,11 +882,10 @@
882 #define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8))
883 #define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
884 #define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8))
885 #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
886 #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
 
887 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) )
888
889 /*
890 ** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700>
891 **
@@ -962,12 +961,13 @@
961 ** [sqlite3_io_methods] object it uses a combination of
962 ** these integer values as the second argument.
963 **
964 ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
965 ** sync operation only needs to flush data to mass storage. Inode
966 ** information need not be flushed. If the lower four bits of the flag
967 ** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.
968 ** If the lower four bits equal SQLITE_SYNC_FULL, that means
969 ** to use Mac OS X style fullsync instead of fsync().
970 */
971 #define SQLITE_SYNC_NORMAL 0x00002
972 #define SQLITE_SYNC_FULL 0x00003
973 #define SQLITE_SYNC_DATAONLY 0x00010
@@ -2729,11 +2729,12 @@
2729 **
2730 ** To execute an SQL query, it must first be compiled into a byte-code
2731 ** program using one of these routines.
2732 **
2733 ** The first argument, "db", is a [database connection] obtained from a
2734 ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
2735 ** [sqlite3_open16()]. The database connection must not have been closed.
2736 **
2737 ** The second argument, "zSql", is the statement to be compiled, encoded
2738 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
2739 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
2740 ** use UTF-16.
@@ -2746,21 +2747,22 @@
2747 ** that the supplied string is nul-terminated, then there is a small
2748 ** performance advantage to be gained by passing an nByte parameter that
2749 ** is equal to the number of bytes in the input string <i>including</i>
2750 ** the nul-terminator bytes.
2751 **
2752 ** If pzTail is not NULL then *pzTail is made to point to the first byte
2753 ** past the end of the first SQL statement in zSql. These routines only
2754 ** compile the first statement in zSql, so *pzTail is left pointing to
2755 ** what remains uncompiled.
2756 **
2757 ** *ppStmt is left pointing to a compiled [prepared statement] that can be
2758 ** executed using [sqlite3_step()]. If there is an error, *ppStmt is set
2759 ** to NULL. If the input text contains no SQL (if the input is an empty
2760 ** string or a comment) then *ppStmt is set to NULL.
2761 ** The calling procedure is responsible for deleting the compiled
2762 ** SQL statement using [sqlite3_finalize()] after it has finished with it.
2763 ** ppStmt may not be NULL.
2764 **
2765 ** On success, [SQLITE_OK] is returned, otherwise an [error code] is returned.
2766 **
2767 ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
2768 ** recommended for all new programs. The two older interfaces are retained
@@ -4130,14 +4132,28 @@
4132 ** the name of a folder (a.k.a. directory), then all temporary files
4133 ** created by SQLite will be placed in that directory. If this variable
4134 ** is a NULL pointer, then SQLite performs a search for an appropriate
4135 ** temporary file directory.
4136 **
4137 ** It is not safe to read or modify this variable in more than one
4138 ** thread at a time. It is not safe to read or modify this variable
4139 ** if a [database connection] is being used at the same time in a separate
4140 ** thread.
4141 ** It is intended that this variable be set once
4142 ** as part of process initialization and before any SQLite interface
4143 ** routines have been called and that this variable remain unchanged
4144 ** thereafter.
4145 **
4146 ** The [temp_store_directory pragma] may modify this variable and cause
4147 ** it to point to memory obtained from [sqlite3_malloc]. Furthermore,
4148 ** the [temp_store_directory pragma] always assumes that any string
4149 ** that this variable points to is held in memory obtained from
4150 ** [sqlite3_malloc] and the pragma may attempt to free that memory
4151 ** using [sqlite3_free].
4152 ** Hence, if this variable is modified directly, either it should be
4153 ** made NULL or made to point to memory obtained from [sqlite3_malloc]
4154 ** or else the use of the [temp_store_directory pragma] should be avoided.
4155 */
4156 SQLITE_API char *sqlite3_temp_directory;
4157
4158 /*
4159 ** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200>
@@ -6417,10 +6433,15 @@
6433 /*
6434 ** Round down to the nearest multiple of 8
6435 */
6436 #define ROUNDDOWN8(x) ((x)&~7)
6437
6438 /*
6439 ** Assert that the pointer X is aligned to an 8-byte boundary.
6440 */
6441 #define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&7)==0)
6442
6443 /*
6444 ** An instance of the following structure is used to store the busy-handler
6445 ** callback for a given sqlite handle.
6446 **
6447 ** The sqlite.busyHandler member of the sqlite struct contains the busy
@@ -6571,11 +6592,11 @@
6592 *************************************************************************
6593 ** This header file defines the interface that the sqlite B-Tree file
6594 ** subsystem. See comments in the source code for a detailed description
6595 ** of what each interface routine does.
6596 **
6597 ** @(#) $Id: btree.h,v 1.113 2009/04/10 12:55:17 danielk1977 Exp $
6598 */
6599 #ifndef _BTREE_H_
6600 #define _BTREE_H_
6601
6602 /* TODO: This definition is just included so other modules compile. It
@@ -6638,11 +6659,11 @@
6659
6660 SQLITE_PRIVATE int sqlite3BtreeClose(Btree*);
6661 SQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree*,int);
6662 SQLITE_PRIVATE int sqlite3BtreeSetSafetyLevel(Btree*,int,int);
6663 SQLITE_PRIVATE int sqlite3BtreeSyncDisabled(Btree*);
6664 SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree*,int,int,int);
6665 SQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree*);
6666 SQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree*,int);
6667 SQLITE_PRIVATE int sqlite3BtreeGetReserve(Btree*);
6668 SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int);
6669 SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *);
@@ -6744,46 +6765,43 @@
6765 /*
6766 ** If we are not using shared cache, then there is no need to
6767 ** use mutexes to access the BtShared structures. So make the
6768 ** Enter and Leave procedures no-ops.
6769 */
6770 #ifndef SQLITE_OMIT_SHARED_CACHE
6771 SQLITE_PRIVATE void sqlite3BtreeEnter(Btree*);
6772 SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3*);
6773 #else
6774 # define sqlite3BtreeEnter(X)
6775 # define sqlite3BtreeEnterAll(X)
6776 #endif
6777
6778 #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE
6779 SQLITE_PRIVATE void sqlite3BtreeLeave(Btree*);
 
 
 
 
6780 SQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor*);
6781 SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor*);
 
6782 SQLITE_PRIVATE void sqlite3BtreeLeaveAll(sqlite3*);
 
 
 
 
6783 SQLITE_PRIVATE void sqlite3BtreeMutexArrayEnter(BtreeMutexArray*);
6784 SQLITE_PRIVATE void sqlite3BtreeMutexArrayLeave(BtreeMutexArray*);
6785 SQLITE_PRIVATE void sqlite3BtreeMutexArrayInsert(BtreeMutexArray*, Btree*);
 
 
 
6786 #ifndef NDEBUG
6787 /* These routines are used inside assert() statements only. */
6788 SQLITE_PRIVATE int sqlite3BtreeHoldsMutex(Btree*);
6789 SQLITE_PRIVATE int sqlite3BtreeHoldsAllMutexes(sqlite3*);
6790 #endif
6791 #else
6792
6793 # define sqlite3BtreeLeave(X)
6794 # define sqlite3BtreeEnterCursor(X)
6795 # define sqlite3BtreeLeaveCursor(X)
 
6796 # define sqlite3BtreeLeaveAll(X)
 
 
 
 
6797 # define sqlite3BtreeMutexArrayEnter(X)
6798 # define sqlite3BtreeMutexArrayLeave(X)
6799 # define sqlite3BtreeMutexArrayInsert(X,Y)
6800
6801 # define sqlite3BtreeHoldsMutex(X) 1
6802 # define sqlite3BtreeHoldsAllMutexes(X) 1
6803 #endif
6804
6805
6806 #endif /* _BTREE_H_ */
6807
@@ -6806,11 +6824,11 @@
6824 **
6825 ** This header defines the interface to the virtual database engine
6826 ** or VDBE. The VDBE implements an abstract machine that runs a
6827 ** simple program to access and modify the underlying database.
6828 **
6829 ** $Id: vdbe.h,v 1.141 2009/04/10 00:56:29 drh Exp $
6830 */
6831 #ifndef _SQLITE_VDBE_H_
6832 #define _SQLITE_VDBE_H_
6833
6834 /*
@@ -7162,12 +7180,11 @@
7180 SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
7181
7182 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
7183 SQLITE_PRIVATE int sqlite3VdbeReleaseMemory(int);
7184 #endif
7185 SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,char*,int);
 
7186 SQLITE_PRIVATE void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord*);
7187 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);
7188
7189
7190 #ifndef NDEBUG
@@ -8097,10 +8114,17 @@
8114 u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
8115
8116 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
8117 /* The following variables are all protected by the STATIC_MASTER
8118 ** mutex, not by sqlite3.mutex. They are used by code in notify.c.
8119 **
8120 ** When X.pUnlockConnection==Y, that means that X is waiting for Y to
8121 ** unlock so that it can proceed.
8122 **
8123 ** When X.pBlockingConnection==Y, that means that something that X tried
8124 ** tried to do recently failed with an SQLITE_LOCKED error due to locks
8125 ** held by Y.
8126 */
8127 sqlite3 *pBlockingConnection; /* Connection that caused SQLITE_LOCKED */
8128 sqlite3 *pUnlockConnection; /* Connection to watch for unlock */
8129 void *pUnlockArg; /* Argument to xUnlockNotify */
8130 void (*xUnlockNotify)(void **, int); /* Unlock notify callback */
@@ -8141,11 +8165,10 @@
8165 #define SQLITE_FullFSync 0x00010000 /* Use full fsync on the backend */
8166 #define SQLITE_LoadExtension 0x00020000 /* Enable load_extension */
8167
8168 #define SQLITE_RecoveryMode 0x00040000 /* Ignore schema errors */
8169 #define SQLITE_SharedCache 0x00080000 /* Cache sharing is enabled */
 
8170 #define SQLITE_CommitBusy 0x00200000 /* In the process of committing */
8171 #define SQLITE_ReverseOrder 0x00400000 /* Reverse unordered SELECTs */
8172
8173 /*
8174 ** Possible values for the sqlite.magic field.
@@ -8707,23 +8730,22 @@
8730 ** is a disk table or the "old.*" pseudo-table, then pTab points to the
8731 ** corresponding table definition.
8732 **
8733 ** ALLOCATION NOTES:
8734 **
8735 ** Expr objects can use a lot of memory space in database schema. To
8736 ** help reduce memory requirements, sometimes an Expr object will be
8737 ** truncated. And to reduce the number of memory allocations, sometimes
8738 ** two or more Expr objects will be stored in a single memory allocation,
8739 ** together with Expr.token and/or Expr.span strings.
8740 **
8741 ** If the EP_Reduced, EP_SpanToken, and EP_TokenOnly flags are set when
8742 ** an Expr object is truncated. When EP_Reduced is set, then all
8743 ** the child Expr objects in the Expr.pLeft and Expr.pRight subtrees
8744 ** are contained within the same memory allocation. Note, however, that
8745 ** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately
8746 ** allocated, regardless of whether or not EP_Reduced is set.
 
8747 */
8748 struct Expr {
8749 u8 op; /* Operation performed by this node */
8750 char affinity; /* The affinity of the column or 0 if not a column */
8751 VVA_ONLY(u8 vvaFlags;) /* Flags used for VV&A only. EVVA_* below. */
@@ -8735,11 +8757,11 @@
8757 ** access them will result in a segfault or malfunction.
8758 *********************************************************************/
8759
8760 Token span; /* Complete text of the expression */
8761
8762 /* If the EP_SpanToken flag is set in the Expr.flags mask, then no
8763 ** space is allocated for the fields below this point. An attempt to
8764 ** access them will result in a segfault or malfunction.
8765 *********************************************************************/
8766
8767 Expr *pLeft; /* Left subnode */
@@ -8783,11 +8805,11 @@
8805 #define EP_IntValue 0x0800 /* Integer value contained in iTable */
8806 #define EP_xIsSelect 0x1000 /* x.pSelect is valid (otherwise x.pList is) */
8807
8808 #define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */
8809 #define EP_TokenOnly 0x4000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
8810 #define EP_SpanToken 0x8000 /* Expr size is EXPR_SPANTOKENSIZE bytes */
8811
8812 /*
8813 ** The following are the meanings of bits in the Expr.vvaFlags field.
8814 ** This information is only used when SQLite is compiled with
8815 ** SQLITE_DEBUG defined.
@@ -8808,22 +8830,21 @@
8830 /*
8831 ** Macros to determine the number of bytes required by a normal Expr
8832 ** struct, an Expr struct with the EP_Reduced flag set in Expr.flags
8833 ** and an Expr struct with the EP_TokenOnly flag set.
8834 */
8835 #define EXPR_FULLSIZE sizeof(Expr) /* Full size */
8836 #define EXPR_REDUCEDSIZE offsetof(Expr,iTable) /* Common features */
8837 #define EXPR_SPANTOKENSIZE offsetof(Expr,pLeft) /* Fewer features */
8838 #define EXPR_TOKENONLYSIZE offsetof(Expr,span) /* Smallest possible */
8839
8840 /*
8841 ** Flags passed to the sqlite3ExprDup() function. See the header comment
8842 ** above sqlite3ExprDup() for details.
8843 */
8844 #define EXPRDUP_REDUCE 0x0001 /* Used reduced-size Expr nodes */
8845 #define EXPRDUP_SPAN 0x0002 /* Make a copy of Expr.span */
 
8846
8847 /*
8848 ** A list of expressions. Each expression may optionally have a
8849 ** name. An expr/name combination can be used in several ways, such
8850 ** as the list of "expr AS ID" fields following a "SELECT" or in the
@@ -9799,10 +9820,11 @@
9820 # define sqlite3TriggersExist(B,C,D,E,F) 0
9821 # define sqlite3DeleteTrigger(A,B)
9822 # define sqlite3DropTriggerPtr(A,B)
9823 # define sqlite3UnlinkAndDeleteTrigger(A,B,C)
9824 # define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I,J,K,L) 0
9825 # define sqlite3TriggerList(X, Y) 0
9826 #endif
9827
9828 SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*);
9829 SQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);
9830 SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int);
@@ -9830,11 +9852,11 @@
9852 SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*);
9853 SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);
9854 SQLITE_PRIVATE int sqlite3FitsIn64Bits(const char *, int);
9855 SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar);
9856 SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte);
9857 SQLITE_PRIVATE int sqlite3Utf8Read(const u8*, const u8**);
9858
9859 /*
9860 ** Routines to read and write variable-length integers. These used to
9861 ** be defined locally, but now we use the varint routines in the util.c
9862 ** file. Code should use the MACRO forms below, as the Varint32 versions
@@ -10427,11 +10449,11 @@
10449 **
10450 ** There is only one exported symbol in this file - the function
10451 ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
10452 ** All other code has file scope.
10453 **
10454 ** $Id: date.c,v 1.105 2009/04/03 12:04:37 drh Exp $
10455 **
10456 ** SQLite processes all times and dates as Julian Day numbers. The
10457 ** dates and times are stored as the number of days since noon
10458 ** in Greenwich on November 24, 4714 B.C. according to the Gregorian
10459 ** calendar system.
@@ -11361,12 +11383,12 @@
11383 break;
11384 }
11385 case 'm': sqlite3_snprintf(3, &z[j],"%02d",x.M); j+=2; break;
11386 case 'M': sqlite3_snprintf(3, &z[j],"%02d",x.m); j+=2; break;
11387 case 's': {
11388 sqlite3_snprintf(30,&z[j],"%lld",
11389 (i64)(x.iJD/1000 - 21086676*(i64)10000));
11390 j += sqlite3Strlen30(&z[j]);
11391 break;
11392 }
11393 case 'S': sqlite3_snprintf(3,&z[j],"%02d",(int)x.s); j+=2; break;
11394 case 'w': {
@@ -15655,11 +15677,11 @@
15677 ** the public domain. The original comments are included here for
15678 ** completeness. They are very out-of-date but might be useful as
15679 ** an historical reference. Most of the "enhancements" have been backed
15680 ** out so that the functionality is now the same as standard printf().
15681 **
15682 ** $Id: printf.c,v 1.102 2009/04/08 16:10:04 drh Exp $
15683 **
15684 **************************************************************************
15685 **
15686 ** The following modules is an enhanced replacement for the "printf" subroutines
15687 ** found in the standard C library. The following enhancements are
@@ -15726,10 +15748,12 @@
15748 #define etSRCLIST 13 /* a pointer to a SrcList */
15749 #define etPOINTER 14 /* The %p conversion */
15750 #define etSQLESCAPE3 15 /* %w -> Strings with '\"' doubled */
15751 #define etORDINAL 16 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */
15752
15753 #define etINVALID 0 /* Any unrecognized conversion type */
15754
15755
15756 /*
15757 ** An "etByte" is an 8-bit unsigned value.
15758 */
15759 typedef unsigned char etByte;
@@ -15782,10 +15806,13 @@
15806 #endif
15807 { 'i', 10, 1, etRADIX, 0, 0 },
15808 { 'n', 0, 0, etSIZE, 0, 0 },
15809 { '%', 0, 0, etPERCENT, 0, 0 },
15810 { 'p', 16, 0, etPOINTER, 0, 1 },
15811
15812 /* All the rest have the FLAG_INTERN bit set and are thus for internal
15813 ** use only */
15814 { 'T', 0, 2, etTOKEN, 0, 0 },
15815 { 'S', 0, 2, etSRCLIST, 0, 0 },
15816 { 'r', 10, 3, etORDINAL, 0, 0 },
15817 };
15818
@@ -15984,11 +16011,12 @@
16011 }
16012 }else{
16013 flag_long = flag_longlong = 0;
16014 }
16015 /* Fetch the info entry for the field */
16016 infop = &fmtinfo[0];
16017 xtype = etINVALID;
16018 for(idx=0; idx<ArraySize(fmtinfo); idx++){
16019 if( c==fmtinfo[idx].fmttype ){
16020 infop = &fmtinfo[idx];
16021 if( useExtended || (infop->flags & FLAG_INTERN)==0 ){
16022 xtype = infop->type;
@@ -15997,13 +16025,10 @@
16025 }
16026 break;
16027 }
16028 }
16029 zExtra = 0;
 
 
 
16030
16031
16032 /* Limit the precision to prevent overflowing buf[] during conversion */
16033 if( precision>etBUFSIZE-40 && (infop->flags & FLAG_STRING)==0 ){
16034 precision = etBUFSIZE-40;
@@ -16336,10 +16361,14 @@
16361 sqlite3StrAccumAppend(pAccum, ".", 1);
16362 }
16363 sqlite3StrAccumAppend(pAccum, pItem->zName, -1);
16364 length = width = 0;
16365 break;
16366 }
16367 default: {
16368 assert( xtype==etINVALID );
16369 return;
16370 }
16371 }/* End switch over the format type */
16372 /*
16373 ** The text of the conversion is pointed to by "bufpt" and is
16374 ** "length" characters long. The field width is "width". Do
@@ -16370,17 +16399,20 @@
16399
16400 /*
16401 ** Append N bytes of text from z to the StrAccum object.
16402 */
16403 SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){
16404 assert( z!=0 || N==0 );
16405 if( p->tooBig | p->mallocFailed ){
16406 testcase(p->tooBig);
16407 testcase(p->mallocFailed);
16408 return;
16409 }
16410 if( N<0 ){
16411 N = sqlite3Strlen30(z);
16412 }
16413 if( N==0 || NEVER(z==0) ){
16414 return;
16415 }
16416 if( p->nChar+N >= p->nAlloc ){
16417 char *zNew;
16418 if( !p->useMalloc ){
@@ -16465,16 +16497,17 @@
16497 */
16498 SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){
16499 char *z;
16500 char zBase[SQLITE_PRINT_BUF_SIZE];
16501 StrAccum acc;
16502 assert( db!=0 );
16503 sqlite3StrAccumInit(&acc, zBase, sizeof(zBase),
16504 db->aLimit[SQLITE_LIMIT_LENGTH]);
16505 acc.db = db;
16506 sqlite3VXPrintf(&acc, 1, zFormat, ap);
16507 z = sqlite3StrAccumFinish(&acc);
16508 if( acc.mallocFailed ){
16509 db->mallocFailed = 1;
16510 }
16511 return z;
16512 }
16513
@@ -16749,11 +16782,11 @@
16782 **
16783 *************************************************************************
16784 ** This file contains routines used to translate between UTF-8,
16785 ** UTF-16, UTF-16BE, and UTF-16LE.
16786 **
16787 ** $Id: utf.c,v 1.73 2009/04/01 18:40:32 drh Exp $
16788 **
16789 ** Notes on UTF-8:
16790 **
16791 ** Byte-0 Byte-1 Byte-2 Byte-3 Value
16792 ** 0xxxxxxx 00000000 00000000 0xxxxxxx
@@ -16791,11 +16824,11 @@
16824 ** VDBE. This information used to all be at the top of the single
16825 ** source code file "vdbe.c". When that file became too big (over
16826 ** 6000 lines long) it was split up into several smaller files and
16827 ** this header information was factored out.
16828 **
16829 ** $Id: vdbeInt.h,v 1.167 2009/04/10 12:55:17 danielk1977 Exp $
16830 */
16831 #ifndef _VDBEINT_H_
16832 #define _VDBEINT_H_
16833
16834 /*
@@ -17154,10 +17187,16 @@
17187 SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
17188 SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);
17189 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
17190 SQLITE_PRIVATE int sqlite3VdbeReleaseBuffers(Vdbe *p);
17191 #endif
17192
17193 #ifndef SQLITE_OMIT_SHARED_CACHE
17194 SQLITE_PRIVATE void sqlite3VdbeMutexArrayEnter(Vdbe *p);
17195 #else
17196 # define sqlite3VdbeMutexArrayEnter(p)
17197 #endif
17198
17199 SQLITE_PRIVATE int sqlite3VdbeMemTranslate(Mem*, u8);
17200 #ifdef SQLITE_DEBUG
17201 SQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe*);
17202 SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf);
@@ -17244,26 +17283,24 @@
17283 }
17284
17285 #define READ_UTF16LE(zIn, c){ \
17286 c = (*zIn++); \
17287 c += ((*zIn++)<<8); \
17288 if( c>=0xD800 && c<0xE000 ){ \
17289 int c2 = (*zIn++); \
17290 c2 += ((*zIn++)<<8); \
17291 c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \
 
17292 } \
17293 }
17294
17295 #define READ_UTF16BE(zIn, c){ \
17296 c = ((*zIn++)<<8); \
17297 c += (*zIn++); \
17298 if( c>=0xD800 && c<0xE000 ){ \
17299 int c2 = ((*zIn++)<<8); \
17300 c2 += (*zIn++); \
17301 c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \
 
17302 } \
17303 }
17304
17305 /*
17306 ** Translate a single UTF-8 character. Return the unicode value.
@@ -17302,17 +17339,29 @@
17339 if( c<0x80 \
17340 || (c&0xFFFFF800)==0xD800 \
17341 || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \
17342 }
17343 SQLITE_PRIVATE int sqlite3Utf8Read(
17344 const unsigned char *zIn, /* First byte of UTF-8 character */
 
17345 const unsigned char **pzNext /* Write first byte past UTF-8 char here */
17346 ){
17347 int c;
17348
17349 /* Same as READ_UTF8() above but without the zTerm parameter.
17350 ** For this routine, we assume the UTF8 string is always zero-terminated.
17351 */
17352 c = *(zIn++);
17353 if( c>=0xc0 ){
17354 c = sqlite3Utf8Trans1[c-0xc0];
17355 while( (*zIn & 0xc0)==0x80 ){
17356 c = (c<<6) + (0x3f & *(zIn++));
17357 }
17358 if( c<0x80
17359 || (c&0xFFFFF800)==0xD800
17360 || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; }
17361 }
17362 *pzNext = zIn;
17363 return c;
17364 }
17365
17366
17367
@@ -17475,11 +17524,12 @@
17524 */
17525 SQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem){
17526 int rc = SQLITE_OK;
17527 u8 bom = 0;
17528
17529 assert( pMem->n>=0 );
17530 if( pMem->n>1 ){
17531 u8 b1 = *(u8 *)pMem->z;
17532 u8 b2 = *(((u8 *)pMem->z) + 1);
17533 if( b1==0xFE && b2==0xFF ){
17534 bom = SQLITE_UTF16BE;
17535 }
@@ -17541,15 +17591,14 @@
17591 ** correct UTF-8 encoding to be longer than a malformed encoding).
17592 */
17593 SQLITE_PRIVATE int sqlite3Utf8To8(unsigned char *zIn){
17594 unsigned char *zOut = zIn;
17595 unsigned char *zStart = zIn;
 
17596 u32 c;
17597
17598 while( zIn[0] ){
17599 c = sqlite3Utf8Read(zIn, (const u8**)&zIn);
17600 if( c!=0xfffd ){
17601 WRITE_UTF8(zOut, c);
17602 }
17603 }
17604 *zOut = 0;
@@ -17579,19 +17628,17 @@
17628 assert( (m.flags & MEM_Str)!=0 || db->mallocFailed );
17629 return (m.flags & MEM_Dyn)!=0 ? m.z : sqlite3DbStrDup(db, m.z);
17630 }
17631
17632 /*
17633 ** pZ is a UTF-16 encoded unicode string at least nChar characters long.
17634 ** Return the number of bytes in the first nChar unicode characters
17635 ** in pZ. nChar must be non-negative.
 
 
17636 */
17637 SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *zIn, int nChar){
17638 int c;
17639 unsigned char const *z = zIn;
17640 int n = 0;
17641 if( SQLITE_UTF16NATIVE==SQLITE_UTF16BE ){
17642 /* Using an "if (SQLITE_UTF16NATIVE==SQLITE_UTF16BE)" construct here
17643 ** and in other parts of this file means that at one branch will
17644 ** not be covered by coverage testing on any single host. But coverage
@@ -17599,21 +17646,21 @@
17646 ** big-endian host. Because both the UTF16NATIVE and SQLITE_UTF16BE
17647 ** macros are constant at compile time the compiler can determine
17648 ** which branch will be followed. It is therefore assumed that no runtime
17649 ** penalty is paid for this "if" statement.
17650 */
17651 while( n<nChar ){
17652 READ_UTF16BE(z, c);
17653 n++;
17654 }
17655 }else{
17656 while( n<nChar ){
17657 READ_UTF16LE(z, c);
17658 n++;
17659 }
17660 }
17661 return (int)(z-(unsigned char const *)zIn);
17662 }
17663
17664 #if defined(SQLITE_TEST)
17665 /*
17666 ** This routine is called from the TCL test function "translate_selftest".
@@ -17622,23 +17669,21 @@
17669 */
17670 SQLITE_PRIVATE void sqlite3UtfSelfTest(void){
17671 unsigned int i, t;
17672 unsigned char zBuf[20];
17673 unsigned char *z;
 
17674 int n;
17675 unsigned int c;
17676
17677 for(i=0; i<0x00110000; i++){
17678 z = zBuf;
17679 WRITE_UTF8(z, i);
17680 n = (int)(z-zBuf);
17681 assert( n>0 && n<=4 );
17682 z[0] = 0;
 
17683 z = zBuf;
17684 c = sqlite3Utf8Read(z, (const u8**)&z);
17685 t = i;
17686 if( i>=0xD800 && i<=0xDFFF ) t = 0xFFFD;
17687 if( (i&0xFFFFFFFE)==0xFFFE ) t = 0xFFFD;
17688 assert( c==t );
17689 assert( (z-zBuf)==n );
@@ -20521,11 +20566,11 @@
20566 ** * sqlite3_vfs method implementations.
20567 ** * Locking primitives for the proxy uber-locking-method. (MacOSX only)
20568 ** * Definitions of sqlite3_vfs objects for all locking methods
20569 ** plus implementations of sqlite3_os_init() and sqlite3_os_end().
20570 **
20571 ** $Id: os_unix.c,v 1.250 2009/04/07 05:35:04 chw Exp $
20572 */
20573 #if SQLITE_OS_UNIX /* This file is used on unix only */
20574
20575 /*
20576 ** There are various methods for file locking used for concurrency
@@ -22911,12 +22956,12 @@
22956 semUnlock(id, NO_LOCK);
22957 assert( pFile );
22958 unixEnterMutex();
22959 releaseLockInfo(pFile->pLock);
22960 releaseOpenCnt(pFile->pOpen);
 
22961 unixLeaveMutex();
22962 closeUnixFile(id);
22963 }
22964 return SQLITE_OK;
22965 }
22966
22967 #endif /* OS_VXWORKS */
@@ -23905,11 +23950,11 @@
23950 dotlockLock, /* xLock method */
23951 dotlockUnlock, /* xUnlock method */
23952 dotlockCheckReservedLock /* xCheckReservedLock method */
23953 )
23954
23955 #if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS
23956 IOMETHODS(
23957 flockIoFinder, /* Finder function name */
23958 flockIoMethods, /* sqlite3_io_methods object name */
23959 flockClose, /* xClose method */
23960 flockLock, /* xLock method */
@@ -24029,10 +24074,48 @@
24074 static const sqlite3_io_methods *(*const autolockIoFinder)(const char*,int)
24075 = autolockIoFinderImpl;
24076
24077 #endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */
24078
24079 #if OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE
24080 /*
24081 ** This "finder" function attempts to determine the best locking strategy
24082 ** for the database file "filePath". It then returns the sqlite3_io_methods
24083 ** object that implements that strategy.
24084 **
24085 ** This is for VXWorks only.
24086 */
24087 static const sqlite3_io_methods *autolockIoFinderImpl(
24088 const char *filePath, /* name of the database file */
24089 int fd /* file descriptor open on the database file */
24090 ){
24091 struct flock lockInfo;
24092
24093 if( !filePath ){
24094 /* If filePath==NULL that means we are dealing with a transient file
24095 ** that does not need to be locked. */
24096 return &nolockIoMethods;
24097 }
24098
24099 /* Test if fcntl() is supported and use POSIX style locks.
24100 ** Otherwise fall back to the named semaphore method.
24101 */
24102 lockInfo.l_len = 1;
24103 lockInfo.l_start = 0;
24104 lockInfo.l_whence = SEEK_SET;
24105 lockInfo.l_type = F_RDLCK;
24106 if( fcntl(fd, F_GETLK, &lockInfo)!=-1 ) {
24107 return &posixIoMethods;
24108 }else{
24109 return &semIoMethods;
24110 }
24111 }
24112 static const sqlite3_io_methods *(*const autolockIoFinder)(const char*,int)
24113 = autolockIoFinderImpl;
24114
24115 #endif /* OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE */
24116
24117 /*
24118 ** An abstract type for a pointer to a IO method finder function:
24119 */
24120 typedef const sqlite3_io_methods *(*finder_type)(const char*,int);
24121
@@ -24311,11 +24394,11 @@
24394 const char *zPath, /* Pathname of file to be opened */
24395 sqlite3_file *pFile, /* The file descriptor to be filled in */
24396 int flags, /* Input flags to control the opening */
24397 int *pOutFlags /* Output flags returned to SQLite core */
24398 ){
24399 int fd = -1; /* File descriptor returned by open() */
24400 int dirfd = -1; /* Directory file descriptor */
24401 int openFlags = 0; /* Flags to pass to open() */
24402 int eType = flags&0xFFFFFF00; /* Type of file to open */
24403 int noLock; /* True to omit locking primitives */
24404 int rc = SQLITE_OK;
@@ -24414,11 +24497,11 @@
24497 if( (flags & SQLITE_OPEN_MAIN_DB)!=0 ){
24498 ((unixFile*)pFile)->isLockable = 1;
24499 }
24500 #endif
24501
24502 assert( fd>=0 );
24503 if( isOpenDirectory ){
24504 rc = openDirectory(zPath, &dirfd);
24505 if( rc!=SQLITE_OK ){
24506 close(fd); /* silently leak if fail, already in error */
24507 return rc;
@@ -25759,11 +25842,11 @@
25842 ** Note that the sqlite3_vfs.pNext field of the VFS object is modified
25843 ** by the SQLite core when the VFS is registered. So the following
25844 ** array cannot be const.
25845 */
25846 static sqlite3_vfs aVfs[] = {
25847 #if SQLITE_ENABLE_LOCKING_STYLE && (OS_VXWORKS || defined(__APPLE__))
25848 UNIXVFS("unix", autolockIoFinder ),
25849 #else
25850 UNIXVFS("unix", posixIoFinder ),
25851 #endif
25852 UNIXVFS("unix-none", nolockIoFinder ),
@@ -25771,11 +25854,13 @@
25854 #if OS_VXWORKS
25855 UNIXVFS("unix-namedsem", semIoFinder ),
25856 #endif
25857 #if SQLITE_ENABLE_LOCKING_STYLE
25858 UNIXVFS("unix-posix", posixIoFinder ),
25859 #if !OS_VXWORKS
25860 UNIXVFS("unix-flock", flockIoFinder ),
25861 #endif
25862 #endif
25863 #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
25864 UNIXVFS("unix-afp", afpIoFinder ),
25865 UNIXVFS("unix-proxy", proxyIoFinder ),
25866 #endif
@@ -25816,11 +25901,11 @@
25901 **
25902 ******************************************************************************
25903 **
25904 ** This file contains code that is specific to windows.
25905 **
25906 ** $Id: os_win.c,v 1.154 2009/04/09 14:27:07 chw Exp $
25907 */
25908 #if SQLITE_OS_WIN /* This file is used for windows only */
25909
25910
25911 /*
@@ -27612,11 +27697,11 @@
27697 const char *zRelative /* UTF-8 file name */
27698 ){
27699 DWORD bytesPerSector = SQLITE_DEFAULT_SECTOR_SIZE;
27700 char zFullpath[MAX_PATH+1];
27701 int rc;
27702 DWORD dwRet = 0, dwDummy;
27703
27704 /*
27705 ** We need to get the full path name of the file
27706 ** to get the drive letter to look up the sector
27707 ** size.
@@ -27636,14 +27721,14 @@
27721 p[i] = '\0';
27722 break;
27723 }
27724 }
27725 dwRet = GetDiskFreeSpaceW((WCHAR*)zConverted,
27726 &dwDummy,
27727 &bytesPerSector,
27728 &dwDummy,
27729 &dwDummy);
27730 #if SQLITE_OS_WINCE==0
27731 }else{
27732 int i;
27733 /* trim path to just drive reference */
27734 CHAR *p = (CHAR *)zConverted;
@@ -27653,14 +27738,14 @@
27738 p[i] = '\0';
27739 break;
27740 }
27741 }
27742 dwRet = GetDiskFreeSpaceA((CHAR*)zConverted,
27743 &dwDummy,
27744 &bytesPerSector,
27745 &dwDummy,
27746 &dwDummy);
27747 #endif
27748 }
27749 free(zConverted);
27750 }
27751 if( !dwRet ){
@@ -27938,11 +28023,11 @@
28023 ** sometimes grow into tens of thousands or larger. The size of the
28024 ** Bitvec object is the number of pages in the database file at the
28025 ** start of a transaction, and is thus usually less than a few thousand,
28026 ** but can be as large as 2 billion for a really big database.
28027 **
28028 ** @(#) $Id: bitvec.c,v 1.14 2009/04/01 23:49:04 drh Exp $
28029 */
28030
28031 /* Size of the Bitvec structure in bytes. */
28032 #define BITVEC_SZ 512
28033
@@ -27997,12 +28082,13 @@
28082 ** N*iDivisor+1 and (N+1)*iDivisor. Each subbitmap is normalized
28083 ** to hold deal with values between 1 and iDivisor.
28084 */
28085 struct Bitvec {
28086 u32 iSize; /* Maximum bit index. Max iSize is 4,294,967,296. */
28087 u32 nSet; /* Number of bits that are set - only valid for aHash
28088 ** element. Max is BITVEC_NINT. For BITVEC_SZ of 512,
28089 ** this would be 125. */
28090 u32 iDivisor; /* Number of bits handled by each apSub[] entry. */
28091 /* Should >=0 for apSub element. */
28092 /* Max iDivisor is max(u32) / BITVEC_NPTR + 1. */
28093 /* For a BITVEC_SZ of 512, this would be 34,359,739. */
28094 union {
@@ -28280,11 +28366,12 @@
28366 ** Bitvec object. Start with the assumption that they do
28367 ** match (rc==0). Change rc to non-zero if a discrepancy
28368 ** is found.
28369 */
28370 rc = sqlite3BitvecTest(0,0) + sqlite3BitvecTest(pBitvec, sz+1)
28371 + sqlite3BitvecTest(pBitvec, 0)
28372 + (sqlite3BitvecSize(pBitvec) - sz);
28373 for(i=1; i<=sz; i++){
28374 if( (TESTBIT(pV,i))!=sqlite3BitvecTest(pBitvec,i) ){
28375 rc = i;
28376 break;
28377 }
@@ -29663,11 +29750,11 @@
29750 ** the sort) then returns elements one by one by walking the list.
29751 **
29752 ** Big chunks of rowid/next-ptr pairs are allocated at a time, to
29753 ** reduce the malloc overhead.
29754 **
29755 ** $Id: rowset.c,v 1.4 2009/04/01 19:35:55 drh Exp $
29756 */
29757
29758 /*
29759 ** The number of rowset entries per allocation chunk.
29760 */
@@ -29757,11 +29844,11 @@
29844 ** memory allocation fails.
29845 */
29846 SQLITE_PRIVATE void sqlite3RowSetInsert(RowSet *p, i64 rowid){
29847 struct RowSetEntry *pEntry;
29848 struct RowSetEntry *pLast;
29849 assert( p!=0 );
29850 if( p->nFresh==0 ){
29851 struct RowSetChunk *pNew;
29852 pNew = sqlite3DbMallocRaw(p->db, sizeof(*pNew));
29853 if( pNew==0 ){
29854 return;
@@ -29896,11 +29983,11 @@
29983 ** is separate from the database file. The pager also implements file
29984 ** locking to prevent two processes from writing the same database
29985 ** file simultaneously, or one process from reading the database while
29986 ** another is writing.
29987 **
29988 ** @(#) $Id: pager.c,v 1.580 2009/04/11 16:27:50 drh Exp $
29989 */
29990 #ifndef SQLITE_OMIT_DISKIO
29991
29992 /*
29993 ** Macros for troubleshooting. Normally turned off
@@ -31901,15 +31988,15 @@
31988 if( rc==SQLITE_DONE ){
31989 rc = SQLITE_OK;
31990 pPager->journalOff = szJ;
31991 break;
31992 }else{
31993 /* If we are unable to rollback, quit and return the error
31994 ** code. This will cause the pager to enter the error state
31995 ** so that no further harm will be done. Perhaps the next
31996 ** process to come along will be able to rollback the database.
31997 */
 
31998 goto end_playback;
31999 }
32000 }
32001 }
32002 }
@@ -32991,13 +33078,13 @@
33078 ** may be a wrapper capable of caching the first portion of the journal
33079 ** file in memory to implement the atomic-write optimization (see
33080 ** source file journal.c).
33081 */
33082 if( sqlite3JournalSize(pVfs)>sqlite3MemJournalSize() ){
33083 journalFileSize = ROUND8(sqlite3JournalSize(pVfs));
33084 }else{
33085 journalFileSize = ROUND8(sqlite3MemJournalSize());
33086 }
33087
33088 /* Set the output variable to NULL in case an error occurs. */
33089 *ppPager = 0;
33090
@@ -33049,27 +33136,29 @@
33136 ** Main journal file handle (journalFileSize bytes)
33137 ** Database file name (nPathname+1 bytes)
33138 ** Journal file name (nPathname+8+1 bytes)
33139 */
33140 pPtr = (u8 *)sqlite3MallocZero(
33141 ROUND8(sizeof(*pPager)) + /* Pager structure */
33142 ROUND8(pcacheSize) + /* PCache object */
33143 ROUND8(pVfs->szOsFile) + /* The main db file */
33144 journalFileSize * 2 + /* The two journal files */
33145 nPathname + 1 + /* zFilename */
33146 nPathname + 8 + 1 /* zJournal */
33147 );
33148 assert( EIGHT_BYTE_ALIGNMENT(journalFileSize) );
33149 if( !pPtr ){
33150 sqlite3_free(zPathname);
33151 return SQLITE_NOMEM;
33152 }
33153 pPager = (Pager*)(pPtr);
33154 pPager->pPCache = (PCache*)(pPtr += ROUND8(sizeof(*pPager)));
33155 pPager->fd = (sqlite3_file*)(pPtr += ROUND8(pcacheSize));
33156 pPager->sjfd = (sqlite3_file*)(pPtr += ROUND8(pVfs->szOsFile));
33157 pPager->jfd = (sqlite3_file*)(pPtr += journalFileSize);
33158 pPager->zFilename = (char*)(pPtr += journalFileSize);
33159 assert( EIGHT_BYTE_ALIGNMENT(pPager->jfd) );
33160
33161 /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */
33162 if( zPathname ){
33163 pPager->zJournal = (char*)(pPtr += nPathname + 1);
33164 memcpy(pPager->zFilename, zPathname, nPathname);
@@ -34951,18 +35040,15 @@
35040 pPg->flags &= ~PGHDR_NEED_SYNC;
35041 pPgOld = pager_lookup(pPager, pgno);
35042 assert( !pPgOld || pPgOld->nRef==1 );
35043 if( pPgOld ){
35044 pPg->flags |= (pPgOld->flags&PGHDR_NEED_SYNC);
35045 sqlite3PcacheDrop(pPgOld);
35046 }
35047
35048 origPgno = pPg->pgno;
35049 sqlite3PcacheMove(pPg, pgno);
 
 
 
 
35050 sqlite3PcacheMakeDirty(pPg);
35051 pPager->dbModified = 1;
35052
35053 if( needSyncPgno ){
35054 /* If needSyncPgno is non-zero, then the journal file needs to be
@@ -35063,34 +35149,37 @@
35149 ** PAGER_JOURNALMODE_PERSIST
35150 ** PAGER_JOURNALMODE_OFF
35151 ** PAGER_JOURNALMODE_MEMORY
35152 **
35153 ** If the parameter is not _QUERY, then the journal-mode is set to the
35154 ** value specified. Except, an in-memory database can only have its
35155 ** journal mode set to _OFF or _MEMORY. Attempts to change the journal
35156 ** mode of an in-memory database to something other than _OFF or _MEMORY
35157 ** are silently ignored.
35158 **
35159 ** The returned indicate the current (possibly updated) journal-mode.
35160 */
35161 SQLITE_PRIVATE int sqlite3PagerJournalMode(Pager *pPager, int eMode){
35162 assert( eMode==PAGER_JOURNALMODE_QUERY
35163 || eMode==PAGER_JOURNALMODE_DELETE
35164 || eMode==PAGER_JOURNALMODE_TRUNCATE
35165 || eMode==PAGER_JOURNALMODE_PERSIST
35166 || eMode==PAGER_JOURNALMODE_OFF
35167 || eMode==PAGER_JOURNALMODE_MEMORY );
35168 assert( PAGER_JOURNALMODE_QUERY<0 );
35169 if( eMode>=0 && (!MEMDB || eMode==PAGER_JOURNALMODE_MEMORY
35170 || eMode==PAGER_JOURNALMODE_OFF) ){
35171 pPager->journalMode = (u8)eMode;
 
 
 
35172 }
35173 return (int)pPager->journalMode;
35174 }
35175
35176 /*
35177 ** Get/set the size-limit used for persistent journal files.
35178 **
35179 ** Setting the size limit to -1 means no limit is enforced.
35180 ** An attempt to set a limit smaller than -1 is a no-op.
35181 */
35182 SQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *pPager, i64 iLimit){
35183 if( iLimit>=-1 ){
35184 pPager->journalSizeLimit = iLimit;
35185 }
@@ -35121,11 +35210,11 @@
35210 ** May you find forgiveness for yourself and forgive others.
35211 ** May you share freely, never taking more than you give.
35212 **
35213 *************************************************************************
35214 **
35215 ** $Id: btmutex.c,v 1.15 2009/04/10 12:55:17 danielk1977 Exp $
35216 **
35217 ** This file contains code used to implement mutexes on Btree objects.
35218 ** This code really belongs in btree.c. But btree.c is getting too
35219 ** big and we want to break it down some. This packaged seemed like
35220 ** a good breakout.
@@ -35773,12 +35862,41 @@
35862 SQLITE_PRIVATE void sqlite3BtreeReleaseTempCursor(BtCursor *pCur);
35863 SQLITE_PRIVATE void sqlite3BtreeMoveToParent(BtCursor *pCur);
35864
35865 /************** End of btreeInt.h ********************************************/
35866 /************** Continuing where we left off in btmutex.c ********************/
35867 #ifndef SQLITE_OMIT_SHARED_CACHE
35868 #if SQLITE_THREADSAFE
35869
35870 /*
35871 ** Obtain the BtShared mutex associated with B-Tree handle p. Also,
35872 ** set BtShared.db to the database handle associated with p and the
35873 ** p->locked boolean to true.
35874 */
35875 static void lockBtreeMutex(Btree *p){
35876 assert( p->locked==0 );
35877 assert( sqlite3_mutex_notheld(p->pBt->mutex) );
35878 assert( sqlite3_mutex_held(p->db->mutex) );
35879
35880 sqlite3_mutex_enter(p->pBt->mutex);
35881 p->pBt->db = p->db;
35882 p->locked = 1;
35883 }
35884
35885 /*
35886 ** Release the BtShared mutex associated with B-Tree handle p and
35887 ** clear the p->locked boolean.
35888 */
35889 static void unlockBtreeMutex(Btree *p){
35890 assert( p->locked==1 );
35891 assert( sqlite3_mutex_held(p->pBt->mutex) );
35892 assert( sqlite3_mutex_held(p->db->mutex) );
35893 assert( p->db==p->pBt->db );
35894
35895 sqlite3_mutex_leave(p->pBt->mutex);
35896 p->locked = 0;
35897 }
35898
35899 /*
35900 ** Enter a mutex on the given BTree object.
35901 **
35902 ** If the object is not sharable, then no mutex is ever required
@@ -35812,19 +35930,24 @@
35930 assert( p->sharable || p->wantToLock==0 );
35931
35932 /* We should already hold a lock on the database connection */
35933 assert( sqlite3_mutex_held(p->db->mutex) );
35934
35935 /* Unless the database is sharable and unlocked, then BtShared.db
35936 ** should already be set correctly. */
35937 assert( (p->locked==0 && p->sharable) || p->pBt->db==p->db );
35938
35939 if( !p->sharable ) return;
35940 p->wantToLock++;
35941 if( p->locked ) return;
35942
35943 /* In most cases, we should be able to acquire the lock we
35944 ** want without having to go throught the ascending lock
35945 ** procedure that follows. Just be sure not to block.
35946 */
35947 if( sqlite3_mutex_try(p->pBt->mutex)==SQLITE_OK ){
35948 p->pBt->db = p->db;
35949 p->locked = 1;
35950 return;
35951 }
35952
35953 /* To avoid deadlock, first release all locks with a larger
@@ -35835,20 +35958,17 @@
35958 for(pLater=p->pNext; pLater; pLater=pLater->pNext){
35959 assert( pLater->sharable );
35960 assert( pLater->pNext==0 || pLater->pNext->pBt>pLater->pBt );
35961 assert( !pLater->locked || pLater->wantToLock>0 );
35962 if( pLater->locked ){
35963 unlockBtreeMutex(pLater);
 
35964 }
35965 }
35966 lockBtreeMutex(p);
 
35967 for(pLater=p->pNext; pLater; pLater=pLater->pNext){
35968 if( pLater->wantToLock ){
35969 lockBtreeMutex(pLater);
 
35970 }
35971 }
35972 }
35973
35974 /*
@@ -35857,29 +35977,29 @@
35977 SQLITE_PRIVATE void sqlite3BtreeLeave(Btree *p){
35978 if( p->sharable ){
35979 assert( p->wantToLock>0 );
35980 p->wantToLock--;
35981 if( p->wantToLock==0 ){
35982 unlockBtreeMutex(p);
 
 
35983 }
35984 }
35985 }
35986
35987 #ifndef NDEBUG
35988 /*
35989 ** Return true if the BtShared mutex is held on the btree, or if the
35990 ** B-Tree is not marked as sharable.
 
 
35991 **
35992 ** This routine is used only from within assert() statements.
35993 */
35994 SQLITE_PRIVATE int sqlite3BtreeHoldsMutex(Btree *p){
35995 assert( p->sharable==0 || p->locked==0 || p->wantToLock>0 );
35996 assert( p->sharable==0 || p->locked==0 || p->db==p->pBt->db );
35997 assert( p->sharable==0 || p->locked==0 || sqlite3_mutex_held(p->pBt->mutex) );
35998 assert( p->sharable==0 || p->locked==0 || sqlite3_mutex_held(p->db->mutex) );
35999
36000 return (p->sharable==0 || p->locked);
36001 }
36002 #endif
36003
36004
36005 #ifndef SQLITE_OMIT_INCRBLOB
@@ -35915,25 +36035,24 @@
36035 int i;
36036 Btree *p, *pLater;
36037 assert( sqlite3_mutex_held(db->mutex) );
36038 for(i=0; i<db->nDb; i++){
36039 p = db->aDb[i].pBt;
36040 assert( !p || (p->locked==0 && p->sharable) || p->pBt->db==p->db );
36041 if( p && p->sharable ){
36042 p->wantToLock++;
36043 if( !p->locked ){
36044 assert( p->wantToLock==1 );
36045 while( p->pPrev ) p = p->pPrev;
36046 while( p->locked && p->pNext ) p = p->pNext;
36047 for(pLater = p->pNext; pLater; pLater=pLater->pNext){
36048 if( pLater->locked ){
36049 unlockBtreeMutex(pLater);
 
36050 }
36051 }
36052 while( p ){
36053 lockBtreeMutex(p);
 
36054 p = p->pNext;
36055 }
36056 }
36057 }
36058 }
@@ -35946,13 +36065,11 @@
36065 p = db->aDb[i].pBt;
36066 if( p && p->sharable ){
36067 assert( p->wantToLock>0 );
36068 p->wantToLock--;
36069 if( p->wantToLock==0 ){
36070 unlockBtreeMutex(p);
 
 
36071 }
36072 }
36073 }
36074 }
36075
@@ -36037,12 +36154,11 @@
36154 /* We should already hold a lock on the database connection */
36155 assert( sqlite3_mutex_held(p->db->mutex) );
36156
36157 p->wantToLock++;
36158 if( !p->locked && p->sharable ){
36159 lockBtreeMutex(p);
 
36160 }
36161 }
36162 }
36163
36164 /*
@@ -36060,18 +36176,30 @@
36176 /* We should already hold a lock on the database connection */
36177 assert( sqlite3_mutex_held(p->db->mutex) );
36178
36179 p->wantToLock--;
36180 if( p->wantToLock==0 && p->locked ){
36181 unlockBtreeMutex(p);
 
36182 }
36183 }
36184 }
36185
36186 #else
36187 SQLITE_PRIVATE void sqlite3BtreeEnter(Btree *p){
36188 p->pBt->db = p->db;
36189 }
36190 SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3 *db){
36191 int i;
36192 for(i=0; i<db->nDb; i++){
36193 Btree *p = db->aDb[i].pBt;
36194 if( p ){
36195 p->pBt->db = p->db;
36196 }
36197 }
36198 }
36199 #endif /* if SQLITE_THREADSAFE */
36200 #endif /* ifndef SQLITE_OMIT_SHARED_CACHE */
36201
36202 /************** End of btmutex.c *********************************************/
36203 /************** Begin file btree.c *******************************************/
36204 /*
36205 ** 2004 April 6
@@ -36082,11 +36210,11 @@
36210 ** May you do good and not evil.
36211 ** May you find forgiveness for yourself and forgive others.
36212 ** May you share freely, never taking more than you give.
36213 **
36214 *************************************************************************
36215 ** $Id: btree.c,v 1.595 2009/04/11 16:06:15 danielk1977 Exp $
36216 **
36217 ** This file implements a external (disk-based) database using BTrees.
36218 ** See the header comment on "btreeInt.h" for additional information.
36219 ** Including a description of file format and an overview of operation.
36220 */
@@ -36175,10 +36303,17 @@
36303
36304 assert( sqlite3BtreeHoldsMutex(p) );
36305 assert( eLock==READ_LOCK || eLock==WRITE_LOCK );
36306 assert( p->db!=0 );
36307
36308 /* If requesting a write-lock, then the Btree must have an open write
36309 ** transaction on this file. And, obviously, for this to be so there
36310 ** must be an open write transaction on the file itself.
36311 */
36312 assert( eLock==READ_LOCK || (p==pBt->pWriter && p->inTrans==TRANS_WRITE) );
36313 assert( eLock==READ_LOCK || pBt->inTransaction==TRANS_WRITE );
36314
36315 /* This is a no-op if the shared-cache is not enabled */
36316 if( !p->sharable ){
36317 return SQLITE_OK;
36318 }
36319
@@ -36210,12 +36345,22 @@
36345 0==(p->db->flags&SQLITE_ReadUncommitted) ||
36346 eLock==WRITE_LOCK ||
36347 iTab==MASTER_ROOT
36348 ){
36349 for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){
36350 /* The condition (pIter->eLock!=eLock) in the following if(...)
36351 ** statement is a simplification of:
36352 **
36353 ** (eLock==WRITE_LOCK || pIter->eLock==WRITE_LOCK)
36354 **
36355 ** since we know that if eLock==WRITE_LOCK, then no other connection
36356 ** may hold a WRITE_LOCK on any table in this file (since there can
36357 ** only be a single writer).
36358 */
36359 assert( pIter->eLock==READ_LOCK || pIter->eLock==WRITE_LOCK );
36360 assert( eLock==READ_LOCK || pIter->pBtree==p || pIter->eLock==READ_LOCK);
36361 if( pIter->pBtree!=p && pIter->iTable==iTab && pIter->eLock!=eLock ){
36362 sqlite3ConnectionBlocked(p->db, pIter->pBtree->db);
36363 if( eLock==WRITE_LOCK ){
36364 assert( p==pBt->pWriter );
36365 pBt->isPending = 1;
36366 }
@@ -36303,21 +36448,27 @@
36448
36449 #ifndef SQLITE_OMIT_SHARED_CACHE
36450 /*
36451 ** Release all the table locks (locks obtained via calls to
36452 ** the setSharedCacheTableLock() procedure) held by Btree handle p.
36453 **
36454 ** This function assumes that handle p has an open read or write
36455 ** transaction. If it does not, then the BtShared.isPending variable
36456 ** may be incorrectly cleared.
36457 */
36458 static void clearAllSharedCacheTableLocks(Btree *p){
36459 BtShared *pBt = p->pBt;
36460 BtLock **ppIter = &pBt->pLock;
36461
36462 assert( sqlite3BtreeHoldsMutex(p) );
36463 assert( p->sharable || 0==*ppIter );
36464 assert( p->inTrans>0 );
36465
36466 while( *ppIter ){
36467 BtLock *pLock = *ppIter;
36468 assert( pBt->isExclusive==0 || pBt->pWriter==pLock->pBtree );
36469 assert( pLock->pBtree->inTrans>=pLock->eLock );
36470 if( pLock->pBtree==p ){
36471 *ppIter = pLock->pNext;
36472 sqlite3_free(pLock);
36473 }else{
36474 ppIter = &pLock->pNext;
@@ -36920,76 +37071,78 @@
37071 }
37072 return SQLITE_OK;
37073 }
37074
37075 /*
37076 ** Allocate nByte bytes of space from within the B-Tree page passed
37077 ** as the first argument. Return the index into pPage->aData[] of the
37078 ** first byte of allocated space.
37079 **
37080 ** The caller guarantees that the space between the end of the cell-offset
37081 ** array and the start of the cell-content area is at least nByte bytes
37082 ** in size. So this routine can never fail.
37083 **
37084 ** If there are already 60 or more bytes of fragments within the page,
37085 ** the page is defragmented before returning. If this were not done there
37086 ** is a chance that the number of fragmented bytes could eventually
37087 ** overflow the single-byte field of the page-header in which this value
37088 ** is stored.
37089 */
37090 static int allocateSpace(MemPage *pPage, int nByte){
37091 const int hdr = pPage->hdrOffset; /* Local cache of pPage->hdrOffset */
37092 u8 * const data = pPage->aData; /* Local cache of pPage->aData */
37093 int nFrag; /* Number of fragmented bytes on pPage */
37094 int top;
 
 
 
37095
 
37096 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
37097 assert( pPage->pBt );
37098 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
37099 assert( nByte>=0 ); /* Minimum cell size is 4 */
37100 assert( pPage->nFree>=nByte );
37101 assert( pPage->nOverflow==0 );
37102
37103 /* Assert that the space between the cell-offset array and the
37104 ** cell-content area is greater than nByte bytes.
37105 */
37106 assert( nByte <= (
37107 get2byte(&data[hdr+5])-(hdr+8+(pPage->leaf?0:4)+2*get2byte(&data[hdr+3]))
37108 ));
37109
37110 pPage->nFree -= (u16)nByte;
 
 
37111 nFrag = data[hdr+7];
37112 if( nFrag>=60 ){
37113 defragmentPage(pPage);
37114 }else{
37115 /* Search the freelist looking for a free slot big enough to satisfy
37116 ** the request. The allocation is made from the first free slot in
37117 ** the list that is large enough to accomadate it.
37118 */
37119 int pc, addr;
37120 for(addr=hdr+1; (pc = get2byte(&data[addr]))>0; addr=pc){
37121 int size = get2byte(&data[pc+2]); /* Size of free slot */
37122 if( size>=nByte ){
37123 int x = size - nByte;
37124 if( x<4 ){
37125 /* Remove the slot from the free-list. Update the number of
37126 ** fragmented bytes within the page. */
37127 memcpy(&data[addr], &data[pc], 2);
37128 data[hdr+7] = (u8)(nFrag + x);
 
37129 }else{
37130 /* The slot remains on the free-list. Reduce its size to account
37131 ** for the portion used by the new allocation. */
37132 put2byte(&data[pc+2], x);
 
37133 }
37134 return pc + x;
37135 }
 
37136 }
37137 }
37138
37139 /* Allocate memory from the gap in between the cell pointer array
37140 ** and the cell content area.
37141 */
37142 top = get2byte(&data[hdr+5]) - nByte;
 
 
 
 
 
 
 
 
37143 put2byte(&data[hdr+5], top);
 
37144 return top;
37145 }
37146
37147 /*
37148 ** Return a section of the pPage->aData to the freelist.
@@ -37373,14 +37526,15 @@
37526 ** page to agree with the restored data.
37527 */
37528 static void pageReinit(DbPage *pData){
37529 MemPage *pPage;
37530 pPage = (MemPage *)sqlite3PagerGetExtra(pData);
37531 assert( sqlite3PagerPageRefcount(pData)>0 );
37532 if( pPage->isInit ){
37533 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
37534 pPage->isInit = 0;
37535 if( sqlite3PagerPageRefcount(pData)>1 ){
37536 /* pPage might not be a btree page; it might be an overflow page
37537 ** or ptrmap page or a free page. In those cases, the following
37538 ** call to sqlite3BtreeInitPage() will likely return SQLITE_CORRUPT.
37539 ** But no harm is done by this. And it is very important that
37540 ** sqlite3BtreeInitPage() be called on every btree page so we make
@@ -37451,14 +37605,11 @@
37605 #if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)
37606 /*
37607 ** If this Btree is a candidate for shared cache, try to find an
37608 ** existing BtShared object that we can share with
37609 */
37610 if( isMemdb==0 && zFilename && zFilename[0] ){
 
 
 
37611 if( sqlite3GlobalConfig.sharedCacheEnabled ){
37612 int nFullPathname = pVfs->mxPathname+1;
37613 char *zFullPathname = sqlite3Malloc(nFullPathname);
37614 sqlite3_mutex *mutexShared;
37615 p->sharable = 1;
@@ -37519,10 +37670,11 @@
37670 rc = sqlite3PagerReadFileheader(pBt->pPager,sizeof(zDbHeader),zDbHeader);
37671 }
37672 if( rc!=SQLITE_OK ){
37673 goto btree_open_out;
37674 }
37675 pBt->db = db;
37676 sqlite3PagerSetBusyhandler(pBt->pPager, btreeInvokeBusyHandler, pBt);
37677 p->pBt = pBt;
37678
37679 sqlite3PagerSetReiniter(pBt->pPager, pageReinit);
37680 pBt->pCursor = 0;
@@ -37696,11 +37848,10 @@
37848 BtCursor *pCur;
37849
37850 /* Close all cursors opened via this handle. */
37851 assert( sqlite3_mutex_held(p->db->mutex) );
37852 sqlite3BtreeEnter(p);
 
37853 pCur = pBt->pCursor;
37854 while( pCur ){
37855 BtCursor *pTmp = pCur;
37856 pCur = pCur->pNext;
37857 if( pTmp->pBtree==p ){
@@ -37806,10 +37957,12 @@
37957 }
37958
37959 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) || !defined(SQLITE_OMIT_VACUUM)
37960 /*
37961 ** Change the default pages size and the number of reserved bytes per page.
37962 ** Or, if the page size has already been fixed, return SQLITE_READONLY
37963 ** without changing anything.
37964 **
37965 ** The page size must be a power of 2 between 512 and 65536. If the page
37966 ** size supplied does not meet this constraint then the page size is not
37967 ** changed.
37968 **
@@ -37818,12 +37971,15 @@
37971 ** the first byte past the 1GB boundary, 0x40000000) needs to occur
37972 ** at the beginning of a page.
37973 **
37974 ** If parameter nReserve is less than zero, then the number of reserved
37975 ** bytes per page is left unchanged.
37976 **
37977 ** If the iFix!=0 then the pageSizeFixed flag is set so that the page size
37978 ** and autovacuum mode can no longer be changed.
37979 */
37980 SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int pageSize, int nReserve, int iFix){
37981 int rc = SQLITE_OK;
37982 BtShared *pBt = p->pBt;
37983 assert( nReserve>=-1 && nReserve<=255 );
37984 sqlite3BtreeEnter(p);
37985 if( pBt->pageSizeFixed ){
@@ -37841,10 +37997,11 @@
37997 pBt->pageSize = (u16)pageSize;
37998 freeTempSpace(pBt);
37999 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize);
38000 }
38001 pBt->usableSize = pBt->pageSize - (u16)nReserve;
38002 if( iFix ) pBt->pageSizeFixed = 1;
38003 sqlite3BtreeLeave(p);
38004 return rc;
38005 }
38006
38007 /*
@@ -37941,11 +38098,11 @@
38098 int rc;
38099 MemPage *pPage1;
38100 int nPage;
38101
38102 assert( sqlite3_mutex_held(pBt->mutex) );
38103 assert( pBt->pPage1==0 );
38104 rc = sqlite3BtreeGetPage(pBt, 1, &pPage1, 0);
38105 if( rc!=SQLITE_OK ) return rc;
38106
38107 /* Do some checking to help insure the file we opened really is
38108 ** a valid database file.
@@ -38169,11 +38326,10 @@
38326 sqlite3 *pBlock = 0;
38327 BtShared *pBt = p->pBt;
38328 int rc = SQLITE_OK;
38329
38330 sqlite3BtreeEnter(p);
 
38331 btreeIntegrity(p);
38332
38333 /* If the btree is already in a write-transaction, or it
38334 ** is already in a read-transaction and a read-transaction
38335 ** is requested, this is a no-op.
@@ -38210,15 +38366,18 @@
38366 goto trans_begun;
38367 }
38368 #endif
38369
38370 do {
38371 /* Call lockBtree() until either pBt->pPage1 is populated or
38372 ** lockBtree() returns something other than SQLITE_OK. lockBtree()
38373 ** may return SQLITE_OK but leave pBt->pPage1 set to 0 if after
38374 ** reading page 1 it discovers that the page-size of the database
38375 ** file is not pBt->pageSize. In this case lockBtree() will update
38376 ** pBt->pageSize to the page-size of the file on disk.
38377 */
38378 while( pBt->pPage1==0 && SQLITE_OK==(rc = lockBtree(pBt)) );
38379
38380 if( rc==SQLITE_OK && wrflag ){
38381 if( pBt->readOnly ){
38382 rc = SQLITE_READONLY;
38383 }else{
@@ -38313,11 +38472,11 @@
38472 pPage->isInit = isInitOrig;
38473 return rc;
38474 }
38475
38476 /*
38477 ** Somewhere on pPage, which is guaranteed to be a btree page, not an overflow
38478 ** page, is a pointer to page iFrom. Modify this pointer so that it points to
38479 ** iTo. Parameter eType describes the type of pointer to be modified, as
38480 ** follows:
38481 **
38482 ** PTRMAP_BTREE: pPage is a btree-page. The pointer points at a child
@@ -38476,18 +38635,19 @@
38635 */
38636 static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg){
38637 Pgno nFreeList; /* Number of pages still on the free-list */
38638
38639 assert( sqlite3_mutex_held(pBt->mutex) );
38640 assert( iLastPg>nFin );
38641
38642 if( !PTRMAP_ISPAGE(pBt, iLastPg) && iLastPg!=PENDING_BYTE_PAGE(pBt) ){
38643 int rc;
38644 u8 eType;
38645 Pgno iPtrPage;
38646
38647 nFreeList = get4byte(&pBt->pPage1->aData[36]);
38648 if( nFreeList==0 ){
38649 return SQLITE_DONE;
38650 }
38651
38652 rc = ptrmapGet(pBt, iLastPg, &eType, &iPtrPage);
38653 if( rc!=SQLITE_OK ){
@@ -38584,11 +38744,10 @@
38744 SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *p){
38745 int rc;
38746 BtShared *pBt = p->pBt;
38747
38748 sqlite3BtreeEnter(p);
 
38749 assert( pBt->inTransaction==TRANS_WRITE && p->inTrans==TRANS_WRITE );
38750 if( !pBt->autoVacuum ){
38751 rc = SQLITE_DONE;
38752 }else{
38753 invalidateAllOverflowCache(pBt);
@@ -38621,20 +38780,22 @@
38780 Pgno nPtrmap;
38781 Pgno iFree;
38782 const int pgsz = pBt->pageSize;
38783 Pgno nOrig = pagerPagecount(pBt);
38784
38785 if( PTRMAP_ISPAGE(pBt, nOrig) || nOrig==PENDING_BYTE_PAGE(pBt) ){
38786 /* It is not possible to create a database for which the final page
38787 ** is either a pointer-map page or the pending-byte page. If one
38788 ** is encountered, this indicates corruption.
38789 */
38790 return SQLITE_CORRUPT_BKPT;
38791 }
38792
 
 
38793 nFree = get4byte(&pBt->pPage1->aData[36]);
38794 nPtrmap = (nFree-nOrig+PTRMAP_PAGENO(pBt, nOrig)+pgsz/5)/(pgsz/5);
38795 nFin = nOrig - nFree - nPtrmap;
38796 if( nOrig>PENDING_BYTE_PAGE(pBt) && nFin<PENDING_BYTE_PAGE(pBt) ){
38797 nFin--;
38798 }
38799 while( PTRMAP_ISPAGE(pBt, nFin) || nFin==PENDING_BYTE_PAGE(pBt) ){
38800 nFin--;
38801 }
@@ -38689,11 +38850,10 @@
38850 SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree *p, const char *zMaster){
38851 int rc = SQLITE_OK;
38852 if( p->inTrans==TRANS_WRITE ){
38853 BtShared *pBt = p->pBt;
38854 sqlite3BtreeEnter(p);
 
38855 #ifndef SQLITE_OMIT_AUTOVACUUM
38856 if( pBt->autoVacuum ){
38857 rc = autoVacuumCommit(pBt);
38858 if( rc!=SQLITE_OK ){
38859 sqlite3BtreeLeave(p);
@@ -38723,11 +38883,10 @@
38883 */
38884 SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree *p){
38885 BtShared *pBt = p->pBt;
38886
38887 sqlite3BtreeEnter(p);
 
38888 btreeIntegrity(p);
38889
38890 /* If the handle has a write-transaction open, commit the shared-btrees
38891 ** transaction and set the shared state to TRANS_READ.
38892 */
@@ -38740,18 +38899,18 @@
38899 sqlite3BtreeLeave(p);
38900 return rc;
38901 }
38902 pBt->inTransaction = TRANS_READ;
38903 }
 
38904
38905 /* If the handle has any kind of transaction open, decrement the transaction
38906 ** count of the shared btree. If the transaction count reaches 0, set
38907 ** the shared state to TRANS_NONE. The unlockBtreeIfUnused() call below
38908 ** will unlock the pager.
38909 */
38910 if( p->inTrans!=TRANS_NONE ){
38911 clearAllSharedCacheTableLocks(p);
38912 pBt->nTransaction--;
38913 if( 0==pBt->nTransaction ){
38914 pBt->inTransaction = TRANS_NONE;
38915 }
38916 }
@@ -38849,11 +39008,10 @@
39008 int rc;
39009 BtShared *pBt = p->pBt;
39010 MemPage *pPage1;
39011
39012 sqlite3BtreeEnter(p);
 
39013 rc = saveAllCursors(pBt, 0, 0);
39014 #ifndef SQLITE_OMIT_SHARED_CACHE
39015 if( rc!=SQLITE_OK ){
39016 /* This is a horrible situation. An IO or malloc() error occurred whilst
39017 ** trying to save cursor positions. If this is an automatic rollback (as
@@ -38864,11 +39022,10 @@
39022 */
39023 sqlite3BtreeTripAllCursors(p, rc);
39024 }
39025 #endif
39026 btreeIntegrity(p);
 
39027
39028 if( p->inTrans==TRANS_WRITE ){
39029 int rc2;
39030
39031 assert( TRANS_WRITE==pBt->inTransaction );
@@ -38886,10 +39043,11 @@
39043 assert( countWriteCursors(pBt)==0 );
39044 pBt->inTransaction = TRANS_READ;
39045 }
39046
39047 if( p->inTrans!=TRANS_NONE ){
39048 clearAllSharedCacheTableLocks(p);
39049 assert( pBt->nTransaction>0 );
39050 pBt->nTransaction--;
39051 if( 0==pBt->nTransaction ){
39052 pBt->inTransaction = TRANS_NONE;
39053 }
@@ -38924,11 +39082,10 @@
39082 */
39083 SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree *p, int iStatement){
39084 int rc;
39085 BtShared *pBt = p->pBt;
39086 sqlite3BtreeEnter(p);
 
39087 assert( p->inTrans==TRANS_WRITE );
39088 assert( pBt->readOnly==0 );
39089 assert( iStatement>0 );
39090 assert( iStatement>p->db->nSavepoint );
39091 if( NEVER(p->inTrans!=TRANS_WRITE || pBt->readOnly) ){
@@ -38963,11 +39120,10 @@
39120 if( p && p->inTrans==TRANS_WRITE ){
39121 BtShared *pBt = p->pBt;
39122 assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );
39123 assert( iSavepoint>=0 || (iSavepoint==-1 && op==SAVEPOINT_ROLLBACK) );
39124 sqlite3BtreeEnter(p);
 
39125 rc = sqlite3PagerSavepoint(pBt->pPager, op, iSavepoint);
39126 if( rc==SQLITE_OK ){
39127 rc = newDatabase(pBt);
39128 }
39129 sqlite3BtreeLeave(p);
@@ -39080,11 +39236,10 @@
39236 struct KeyInfo *pKeyInfo, /* First arg to xCompare() */
39237 BtCursor *pCur /* Write new cursor here */
39238 ){
39239 int rc;
39240 sqlite3BtreeEnter(p);
 
39241 rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);
39242 sqlite3BtreeLeave(p);
39243 return rc;
39244 }
39245
@@ -39138,11 +39293,10 @@
39293 Btree *pBtree = pCur->pBtree;
39294 if( pBtree ){
39295 int i;
39296 BtShared *pBt = pCur->pBt;
39297 sqlite3BtreeEnter(pBtree);
 
39298 sqlite3BtreeClearCursor(pCur);
39299 if( pCur->pPrev ){
39300 pCur->pPrev->pNext = pCur->pNext;
39301 }else{
39302 pBt->pCursor = pCur->pNext;
@@ -40116,11 +40270,12 @@
40270 int bias, /* Bias search to the high end */
40271 int *pRes /* Write search results here */
40272 ){
40273 int rc; /* Status code */
40274 UnpackedRecord *pIdxKey; /* Unpacked index key */
40275 char aSpace[150]; /* Temp space for pIdxKey - to avoid a malloc */
40276
40277
40278 if( pKey ){
40279 assert( nKey==(i64)(int)nKey );
40280 pIdxKey = sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey,
40281 aSpace, sizeof(aSpace));
@@ -40717,11 +40872,14 @@
40872 nOvfl = (info.nPayload - info.nLocal + ovflPageSize - 1)/ovflPageSize;
40873 assert( ovflPgno==0 || nOvfl>0 );
40874 while( nOvfl-- ){
40875 Pgno iNext = 0;
40876 MemPage *pOvfl = 0;
40877 if( ovflPgno<2 || ovflPgno>pagerPagecount(pBt) ){
40878 /* 0 is not a legal page number and page 1 cannot be an
40879 ** overflow page. Therefore if ovflPgno<2 or past the end of the
40880 ** file the database must be corrupt. */
40881 return SQLITE_CORRUPT_BKPT;
40882 }
40883 if( nOvfl ){
40884 rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext);
40885 if( rc ) return rc;
@@ -41396,17 +41554,17 @@
41554 rc = SQLITE_NOMEM;
41555 goto balance_cleanup;
41556 }
41557 szCell = (u16*)&apCell[nMaxCells];
41558 aCopy[0] = (u8*)&szCell[nMaxCells];
41559 assert( EIGHT_BYTE_ALIGNMENT(aCopy[0]) );
41560 for(i=1; i<NB; i++){
41561 aCopy[i] = &aCopy[i-1][pBt->pageSize+ROUND8(sizeof(MemPage))];
41562 assert( ((aCopy[i] - (u8*)0) & 7)==0 ); /* 8-byte alignment required */
41563 }
41564 aSpace1 = &aCopy[NB-1][pBt->pageSize+ROUND8(sizeof(MemPage))];
41565 assert( EIGHT_BYTE_ALIGNMENT(aSpace1) );
41566 if( ISAUTOVACUUM ){
41567 aFrom = &aSpace1[pBt->pageSize];
41568 }
41569 aSpace2 = sqlite3PageMalloc(pBt->pageSize);
41570 if( aSpace2==0 ){
@@ -42388,12 +42546,12 @@
42546 rc = saveCursorPosition(&leafCur);
42547 if( rc==SQLITE_OK ){
42548 rc = sqlite3BtreeNext(&leafCur, &notUsed);
42549 }
42550 pLeafPage = leafCur.apPage[leafCur.iPage];
42551 assert( rc!=SQLITE_OK || pLeafPage->pgno==leafPgno );
42552 assert( rc!=SQLITE_OK || leafCur.aiIdx[leafCur.iPage]==0 );
42553 }
42554
42555 if( SQLITE_OK==rc
42556 && SQLITE_OK==(rc = sqlite3PagerWrite(pLeafPage->pDbPage))
42557 ){
@@ -42553,11 +42711,10 @@
42711 return SQLITE_OK;
42712 }
42713 SQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree *p, int *piTable, int flags){
42714 int rc;
42715 sqlite3BtreeEnter(p);
 
42716 rc = btreeCreateTable(p, piTable, flags);
42717 sqlite3BtreeLeave(p);
42718 return rc;
42719 }
42720
@@ -42625,11 +42782,10 @@
42782 */
42783 SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){
42784 int rc;
42785 BtShared *pBt = p->pBt;
42786 sqlite3BtreeEnter(p);
 
42787 assert( p->inTrans==TRANS_WRITE );
42788 if( (rc = checkForReadConflicts(p, iTable, 0, 1))!=SQLITE_OK ){
42789 /* nothing to do */
42790 }else if( SQLITE_OK!=(rc = saveAllCursors(pBt, iTable, 0)) ){
42791 /* nothing to do */
@@ -42767,11 +42923,10 @@
42923 return rc;
42924 }
42925 SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree *p, int iTable, int *piMoved){
42926 int rc;
42927 sqlite3BtreeEnter(p);
 
42928 rc = btreeDropTable(p, iTable, piMoved);
42929 sqlite3BtreeLeave(p);
42930 return rc;
42931 }
42932
@@ -42791,11 +42946,10 @@
42946 int rc;
42947 unsigned char *pP1;
42948 BtShared *pBt = p->pBt;
42949
42950 sqlite3BtreeEnter(p);
 
42951
42952 /* Reading a meta-data value requires a read-lock on page 1 (and hence
42953 ** the sqlite_master table. We grab this lock regardless of whether or
42954 ** not the SQLITE_ReadUncommitted flag is set (the table rooted at page
42955 ** 1 is treated as a special case by querySharedCacheTableLock()
@@ -42840,12 +42994,18 @@
42994 */
42995 #ifdef SQLITE_OMIT_AUTOVACUUM
42996 if( idx==4 && *pMeta>0 ) pBt->readOnly = 1;
42997 #endif
42998
42999 /* If there is currently an open transaction, grab a read-lock
43000 ** on page 1 of the database file. This is done to make sure that
43001 ** no other connection can modify the meta value just read from
43002 ** the database until the transaction is concluded.
43003 */
43004 if( p->inTrans>0 ){
43005 rc = setSharedCacheTableLock(p, 1, READ_LOCK);
43006 }
43007 sqlite3BtreeLeave(p);
43008 return rc;
43009 }
43010
43011 /*
@@ -42856,11 +43016,10 @@
43016 BtShared *pBt = p->pBt;
43017 unsigned char *pP1;
43018 int rc;
43019 assert( idx>=1 && idx<=15 );
43020 sqlite3BtreeEnter(p);
 
43021 assert( p->inTrans==TRANS_WRITE );
43022 assert( pBt->pPage1!=0 );
43023 pP1 = pBt->pPage1->aData;
43024 rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
43025 if( rc==SQLITE_OK ){
@@ -43330,11 +43489,10 @@
43489 IntegrityCk sCheck;
43490 BtShared *pBt = p->pBt;
43491 char zErr[100];
43492
43493 sqlite3BtreeEnter(p);
 
43494 nRef = sqlite3PagerRefcount(pBt->pPager);
43495 if( lockBtreeWithRetry(p)!=SQLITE_OK ){
43496 *pnErr = 1;
43497 sqlite3BtreeLeave(p);
43498 return sqlite3DbStrDup(0, "cannot acquire a read lock on the database");
@@ -44240,11 +44398,11 @@
44398 ** This file contains code use to manipulate "Mem" structure. A "Mem"
44399 ** stores a single value in the VDBE. Mem is an opaque structure visible
44400 ** only within the VDBE. Interface routines refer to a Mem using the
44401 ** name sqlite_value
44402 **
44403 ** $Id: vdbemem.c,v 1.140 2009/04/05 12:22:09 drh Exp $
44404 */
44405
44406 /*
44407 ** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem*)
44408 ** P if required.
@@ -44432,10 +44590,11 @@
44590 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
44591 assert( !(fg&MEM_Zero) );
44592 assert( !(fg&(MEM_Str|MEM_Blob)) );
44593 assert( fg&(MEM_Int|MEM_Real) );
44594 assert( (pMem->flags&MEM_RowSet)==0 );
44595 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
44596
44597
44598 if( sqlite3VdbeMemGrow(pMem, nByte, 0) ){
44599 return SQLITE_NOMEM;
44600 }
@@ -44568,10 +44727,11 @@
44727 ** If pMem represents a string value, its encoding might be changed.
44728 */
44729 SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){
44730 int flags;
44731 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
44732 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
44733 flags = pMem->flags;
44734 if( flags & MEM_Int ){
44735 return pMem->u.i;
44736 }else if( flags & MEM_Real ){
44737 return doubleToInt64(pMem->r);
@@ -44596,10 +44756,11 @@
44756 ** value. If it is a string or blob, try to convert it to a double.
44757 ** If it is a NULL, return 0.0.
44758 */
44759 SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){
44760 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
44761 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
44762 if( pMem->flags & MEM_Real ){
44763 return pMem->r;
44764 }else if( pMem->flags & MEM_Int ){
44765 return (double)pMem->u.i;
44766 }else if( pMem->flags & (MEM_Str|MEM_Blob) ){
@@ -44626,10 +44787,11 @@
44787 */
44788 SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){
44789 assert( pMem->flags & MEM_Real );
44790 assert( (pMem->flags & MEM_RowSet)==0 );
44791 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
44792 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
44793
44794 pMem->u.i = doubleToInt64(pMem->r);
44795 if( pMem->r==(double)pMem->u.i ){
44796 pMem->flags |= MEM_Int;
44797 }
@@ -44639,10 +44801,12 @@
44801 ** Convert pMem to type integer. Invalidate any prior representations.
44802 */
44803 SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){
44804 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
44805 assert( (pMem->flags & MEM_RowSet)==0 );
44806 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
44807
44808 pMem->u.i = sqlite3VdbeIntValue(pMem);
44809 MemSetTypeFlag(pMem, MEM_Int);
44810 return SQLITE_OK;
44811 }
44812
@@ -44650,10 +44814,12 @@
44814 ** Convert pMem so that it is of type MEM_Real.
44815 ** Invalidate any prior representations.
44816 */
44817 SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){
44818 assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
44819 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
44820
44821 pMem->r = sqlite3VdbeRealValue(pMem);
44822 MemSetTypeFlag(pMem, MEM_Real);
44823 return SQLITE_OK;
44824 }
44825
@@ -45287,11 +45453,11 @@
45453 ** This file contains code used for creating, destroying, and populating
45454 ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior
45455 ** to version 2.8.7, all this code was combined into the vdbe.c source file.
45456 ** But that file was getting too big so this subroutines were split out.
45457 **
45458 ** $Id: vdbeaux.c,v 1.451 2009/04/10 15:42:36 shane Exp $
45459 */
45460
45461
45462
45463 /*
@@ -46294,10 +46460,11 @@
46460 int nByte, /* Number of bytes to allocate */
46461 u8 **ppFrom, /* IN/OUT: Allocate from *ppFrom */
46462 u8 *pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */
46463 int *pnByte /* If allocation cannot be made, increment *pnByte */
46464 ){
46465 assert( EIGHT_BYTE_ALIGNMENT(*ppFrom) );
46466 if( (*(void**)pp)==0 ){
46467 nByte = ROUND8(nByte);
46468 if( (pEnd - *ppFrom)>=nByte ){
46469 *(void**)pp = (void *)*ppFrom;
46470 *ppFrom += nByte;
@@ -46367,10 +46534,13 @@
46534 int nArg; /* Maximum number of args passed to a user function. */
46535 resolveP2Values(p, &nArg);
46536 if( isExplain && nMem<10 ){
46537 nMem = 10;
46538 }
46539 zCsr += (zCsr - (u8*)0)&7;
46540 assert( EIGHT_BYTE_ALIGNMENT(zCsr) );
46541 if( zEnd<zCsr ) zEnd = zCsr;
46542
46543 do {
46544 memset(zCsr, 0, zEnd-zCsr);
46545 nByte = 0;
46546 allocSpace((char*)&p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte);
@@ -46877,10 +47047,37 @@
47047 p->iStatement = 0;
47048 }
47049 return rc;
47050 }
47051
47052 /*
47053 ** If SQLite is compiled to support shared-cache mode and to be threadsafe,
47054 ** this routine obtains the mutex associated with each BtShared structure
47055 ** that may be accessed by the VM passed as an argument. In doing so it
47056 ** sets the BtShared.db member of each of the BtShared structures, ensuring
47057 ** that the correct busy-handler callback is invoked if required.
47058 **
47059 ** If SQLite is not threadsafe but does support shared-cache mode, then
47060 ** sqlite3BtreeEnterAll() is invoked to set the BtShared.db variables
47061 ** of all of BtShared structures accessible via the database handle
47062 ** associated with the VM. Of course only a subset of these structures
47063 ** will be accessed by the VM, and we could use Vdbe.btreeMask to figure
47064 ** that subset out, but there is no advantage to doing so.
47065 **
47066 ** If SQLite is not threadsafe and does not support shared-cache mode, this
47067 ** function is a no-op.
47068 */
47069 #ifndef SQLITE_OMIT_SHARED_CACHE
47070 SQLITE_PRIVATE void sqlite3VdbeMutexArrayEnter(Vdbe *p){
47071 #if SQLITE_THREADSAFE
47072 sqlite3BtreeMutexArrayEnter(&p->aMutex);
47073 #else
47074 sqlite3BtreeEnterAll(p->db);
47075 #endif
47076 }
47077 #endif
47078
47079 /*
47080 ** This routine is called the when a VDBE tries to halt. If the VDBE
47081 ** has made changes and is in autocommit mode, then commit those
47082 ** changes. If a rollback is needed, then do the rollback.
47083 **
@@ -46926,11 +47123,11 @@
47123 int mrc; /* Primary error code from p->rc */
47124 int eStatementOp = 0;
47125 int isSpecialError; /* Set to true if a 'special' error */
47126
47127 /* Lock all btrees used by the statement */
47128 sqlite3VdbeMutexArrayEnter(p);
47129
47130 /* Check for one of the special errors */
47131 mrc = p->rc & 0xff;
47132 isSpecialError = mrc==SQLITE_NOMEM || mrc==SQLITE_IOERR
47133 || mrc==SQLITE_INTERRUPT || mrc==SQLITE_FULL;
@@ -47587,34 +47784,44 @@
47784 */
47785 SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeRecordUnpack(
47786 KeyInfo *pKeyInfo, /* Information about the record format */
47787 int nKey, /* Size of the binary record */
47788 const void *pKey, /* The binary record */
47789 char *pSpace, /* Unaligned space available to hold the object */
47790 int szSpace /* Size of pSpace[] in bytes */
47791 ){
47792 const unsigned char *aKey = (const unsigned char *)pKey;
47793 UnpackedRecord *p; /* The unpacked record that we will return */
47794 int nByte; /* Memory space needed to hold p, in bytes */
47795 int d;
47796 u32 idx;
47797 u16 u; /* Unsigned loop counter */
47798 u32 szHdr;
47799 Mem *pMem;
47800 int nOff; /* Increase pSpace by this much to 8-byte align it */
47801
47802 /*
47803 ** We want to shift the pointer pSpace up such that it is 8-byte aligned.
47804 ** Thus, we need to calculate a value, nOff, between 0 and 7, to shift
47805 ** it by. If pSpace is already 8-byte aligned, nOff should be zero.
47806 */
47807 nOff = (8 - (SQLITE_PTR_TO_INT(pSpace) & 7)) & 7;
47808 pSpace += nOff;
47809 szSpace -= nOff;
47810 nByte = ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*(pKeyInfo->nField+1);
47811 if( nByte>szSpace ){
47812 p = sqlite3DbMallocRaw(pKeyInfo->db, nByte);
47813 if( p==0 ) return 0;
47814 p->flags = UNPACKED_NEED_FREE | UNPACKED_NEED_DESTROY;
47815 }else{
47816 p = (UnpackedRecord*)pSpace;
47817 p->flags = UNPACKED_NEED_DESTROY;
47818 }
47819 p->pKeyInfo = pKeyInfo;
47820 p->nField = pKeyInfo->nField + 1;
47821 p->aMem = pMem = (Mem*)&((char*)p)[ROUND8(sizeof(UnpackedRecord))];
47822 assert( EIGHT_BYTE_ALIGNMENT(pMem) );
47823 idx = getVarint32(aKey, szHdr);
47824 d = szHdr;
47825 u = 0;
47826 while( idx<szHdr && u<p->nField ){
47827 u32 serial_type;
@@ -47926,11 +48133,11 @@
48133 *************************************************************************
48134 **
48135 ** This file contains code use to implement APIs that are part of the
48136 ** VDBE.
48137 **
48138 ** $Id: vdbeapi.c,v 1.161 2009/04/10 23:11:31 drh Exp $
48139 */
48140
48141 #if 0 && defined(SQLITE_ENABLE_MEMORY_MANAGEMENT)
48142 /*
48143 ** The following structure contains pointers to the end points of a
@@ -48354,11 +48561,11 @@
48561 if( db->mallocFailed ){
48562 return SQLITE_NOMEM;
48563 }
48564
48565 if( p->pc<=0 && p->expired ){
48566 if( ALWAYS(p->rc==SQLITE_OK) ){
48567 p->rc = SQLITE_SCHEMA;
48568 }
48569 rc = SQLITE_ERROR;
48570 goto end_of_step;
48571 }
@@ -48470,11 +48677,11 @@
48677 && cnt++ < 5
48678 && (rc = vdbeReprepare(v))==SQLITE_OK ){
48679 sqlite3_reset(pStmt);
48680 v->expired = 0;
48681 }
48682 if( rc==SQLITE_SCHEMA && ALWAYS(v->isPrepareV2) && ALWAYS(db->pErr) ){
48683 /* This case occurs after failing to recompile an sql statement.
48684 ** The error message from the SQL compiler has already been loaded
48685 ** into the database handle. This block copies the error message
48686 ** from the database handle into the statement and sets the statement
48687 ** program counter to 0 to ensure that when the statement is
@@ -48529,11 +48736,11 @@
48736 sqlite3_value **NotUsed2 /* Value of each argument */
48737 ){
48738 const char *zName = context->pFunc->zName;
48739 char *zErr;
48740 UNUSED_PARAMETER2(NotUsed, NotUsed2);
48741 zErr = sqlite3_mprintf(
48742 "unable to use function %s in the requested context", zName);
48743 sqlite3_result_error(context, zErr, -1);
48744 sqlite3_free(zErr);
48745 }
48746
@@ -48675,11 +48882,11 @@
48882 vals = sqlite3_data_count(pStmt);
48883 pOut = &pVm->pResultSet[i];
48884 }else{
48885 /* ((double)0) In case of SQLITE_OMIT_FLOATING_POINT... */
48886 static const Mem nullMem = {{0}, (double)0, 0, "", 0, MEM_Null, SQLITE_NULL, 0, 0, 0 };
48887 if( pVm && ALWAYS(pVm->db) ){
48888 sqlite3_mutex_enter(pVm->db->mutex);
48889 sqlite3Error(pVm->db, SQLITE_RANGE, 0);
48890 }
48891 pOut = (Mem*)&nullMem;
48892 }
@@ -48815,28 +49022,27 @@
49022 int useType
49023 ){
49024 const void *ret = 0;
49025 Vdbe *p = (Vdbe *)pStmt;
49026 int n;
49027 sqlite3 *db = p->db;
49028
49029 assert( db!=0 );
49030 n = sqlite3_column_count(pStmt);
49031 if( N<n && N>=0 ){
49032 N += useType*n;
49033 sqlite3_mutex_enter(db->mutex);
49034 assert( db->mallocFailed==0 );
49035 ret = xFunc(&p->aColName[N]);
49036 /* A malloc may have failed inside of the xFunc() call. If this
49037 ** is the case, clear the mallocFailed flag and return NULL.
49038 */
49039 if( db->mallocFailed ){
49040 db->mallocFailed = 0;
49041 ret = 0;
49042 }
49043 sqlite3_mutex_leave(db->mutex);
 
49044 }
49045 return ret;
49046 }
49047
49048 /*
@@ -49072,12 +49278,12 @@
49278 rc = sqlite3VdbeMemCopy(&p->aVar[i-1], pValue);
49279 if( rc==SQLITE_OK ){
49280 rc = sqlite3VdbeChangeEncoding(&p->aVar[i-1], ENC(p->db));
49281 }
49282 sqlite3_mutex_leave(p->db->mutex);
49283 rc = sqlite3ApiExit(p->db, rc);
49284 }
 
49285 return rc;
49286 }
49287 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
49288 int rc;
49289 Vdbe *p = (Vdbe *)pStmt;
@@ -49103,22 +49309,25 @@
49309 ** in the Vdbe.azVar[] array, if such a mapping does not already
49310 ** exist.
49311 */
49312 static void createVarMap(Vdbe *p){
49313 if( !p->okVar ){
49314 int j;
49315 Op *pOp;
49316 sqlite3_mutex_enter(p->db->mutex);
49317 /* The race condition here is harmless. If two threads call this
49318 ** routine on the same Vdbe at the same time, they both might end
49319 ** up initializing the Vdbe.azVar[] array. That is a little extra
49320 ** work but it results in the same answer.
49321 */
49322 for(j=0, pOp=p->aOp; j<p->nOp; j++, pOp++){
49323 if( pOp->opcode==OP_Variable ){
49324 assert( pOp->p1>0 && pOp->p1<=p->nVar );
49325 p->azVar[pOp->p1-1] = pOp->p4.z;
49326 }
49327 }
49328 p->okVar = 1;
49329 sqlite3_mutex_leave(p->db->mutex);
49330 }
49331 }
49332
49333 /*
@@ -49159,40 +49368,44 @@
49368 return 0;
49369 }
49370
49371 /*
49372 ** Transfer all bindings from the first statement over to the second.
 
 
49373 */
49374 SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
49375 Vdbe *pFrom = (Vdbe*)pFromStmt;
49376 Vdbe *pTo = (Vdbe*)pToStmt;
49377 int i;
49378 assert( pTo->db==pFrom->db );
49379 assert( pTo->nVar==pFrom->nVar );
 
 
 
 
 
 
49380 sqlite3_mutex_enter(pTo->db->mutex);
49381 for(i=0; i<pFrom->nVar; i++){
49382 sqlite3VdbeMemMove(&pTo->aVar[i], &pFrom->aVar[i]);
49383 }
49384 sqlite3_mutex_leave(pTo->db->mutex);
49385 return SQLITE_OK;
 
49386 }
49387
49388 #ifndef SQLITE_OMIT_DEPRECATED
49389 /*
49390 ** Deprecated external interface. Internal/core SQLite code
49391 ** should call sqlite3TransferBindings.
49392 **
49393 ** Is is misuse to call this routine with statements from different
49394 ** database connections. But as this is a deprecated interface, we
49395 ** will not bother to check for that condition.
49396 **
49397 ** If the two statements contain a different number of bindings, then
49398 ** an SQLITE_ERROR is returned. Nothing else can go wrong, so otherwise
49399 ** SQLITE_OK is returned.
49400 */
49401 SQLITE_API int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
49402 Vdbe *pFrom = (Vdbe*)pFromStmt;
49403 Vdbe *pTo = (Vdbe*)pToStmt;
49404 if( pFrom->nVar!=pTo->nVar ){
49405 return SQLITE_ERROR;
49406 }
49407 return sqlite3TransferBindings(pFromStmt, pToStmt);
49408 }
49409 #endif
49410
49411 /*
@@ -49278,11 +49491,11 @@
49491 ** documentation, headers files, or other derived files. The formatting
49492 ** of the code in this file is, therefore, important. See other comments
49493 ** in this file for details. If in doubt, do not deviate from existing
49494 ** commenting and indentation practices when changing or adding code.
49495 **
49496 ** $Id: vdbe.c,v 1.832 2009/04/10 12:55:17 danielk1977 Exp $
49497 */
49498
49499 /*
49500 ** The following global variable is incremented every time a cursor
49501 ** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes. The test
@@ -49886,15 +50099,17 @@
50099 int origPc; /* Program counter at start of opcode */
50100 #endif
50101 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
50102 int nProgressOps = 0; /* Opcodes executed since progress callback. */
50103 #endif
50104
50105 /* Temporary space into which to unpack a record. */
50106 char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*3 + 7];
50107
50108 assert( p->magic==VDBE_MAGIC_RUN ); /* sqlite3_step() verifies this */
50109 assert( db->magic==SQLITE_MAGIC_BUSY );
50110 sqlite3VdbeMutexArrayEnter(p);
50111 if( p->rc==SQLITE_NOMEM ){
50112 /* This happens if a malloc() inside a call to sqlite3_column_text() or
50113 ** sqlite3_column_text16() failed. */
50114 goto no_mem;
50115 }
@@ -51689,11 +51904,15 @@
51904 */
51905 #ifndef SQLITE_OMIT_BTREECOUNT
51906 case OP_Count: { /* out2-prerelease */
51907 i64 nEntry;
51908 BtCursor *pCrsr = p->apCsr[pOp->p1]->pCursor;
51909 if( pCrsr ){
51910 rc = sqlite3BtreeCount(pCrsr, &nEntry);
51911 }else{
51912 nEntry = 0;
51913 }
51914 pOut->flags = MEM_Int;
51915 pOut->u.i = nEntry;
51916 break;
51917 }
51918 #endif
@@ -53472,16 +53691,18 @@
53691 */
53692 case OP_IdxRowid: { /* out2-prerelease */
53693 int i = pOp->p1;
53694 BtCursor *pCrsr;
53695 VdbeCursor *pC;
53696
53697
53698 assert( i>=0 && i<p->nCursor );
53699 assert( p->apCsr[i]!=0 );
53700 if( (pCrsr = (pC = p->apCsr[i])->pCursor)!=0 ){
53701 i64 rowid;
53702 rc = sqlite3VdbeCursorMoveto(pC);
53703 if( rc ) goto abort_due_to_error;
53704 assert( pC->deferredMoveto==0 );
53705 assert( pC->isTable==0 );
53706 if( !pC->nullRow ){
53707 rc = sqlite3VdbeIdxRowid(pCrsr, &rowid);
53708 if( rc!=SQLITE_OK ){
@@ -55348,22 +55569,27 @@
55569 **
55570 ** This file contains code use to implement an in-memory rollback journal.
55571 ** The in-memory rollback journal is used to journal transactions for
55572 ** ":memory:" databases and when the journal_mode=MEMORY pragma is used.
55573 **
55574 ** @(#) $Id: memjournal.c,v 1.11 2009/04/05 12:22:09 drh Exp $
55575 */
55576
55577 /* Forward references to internal structures */
55578 typedef struct MemJournal MemJournal;
55579 typedef struct FilePoint FilePoint;
55580 typedef struct FileChunk FileChunk;
55581
55582 /* Space to hold the rollback journal is allocated in increments of
55583 ** this many bytes.
55584 **
55585 ** The size chosen is a little less than a power of two. That way,
55586 ** the FileChunk object will have a size that almost exactly fills
55587 ** a power-of-two allocation. This mimimizes wasted space in power-of-two
55588 ** memory allocators.
55589 */
55590 #define JOURNAL_CHUNKSIZE ((int)(1024-sizeof(FileChunk*)))
55591
55592 /* Macro to find the minimum of two numeric values.
55593 */
55594 #ifndef MIN
55595 # define MIN(x,y) ((x)<(y)?(x):(y))
@@ -55396,11 +55622,12 @@
55622 FilePoint endpoint; /* Pointer to the end of the file */
55623 FilePoint readpoint; /* Pointer to the end of the last xRead() */
55624 };
55625
55626 /*
55627 ** Read data from the in-memory journal file. This is the implementation
55628 ** of the sqlite3_vfs.xRead method.
55629 */
55630 static int memjrnlRead(
55631 sqlite3_file *pJfd, /* The journal file from which to read */
55632 void *zBuf, /* Put the results here */
55633 int iAmt, /* Number of bytes to read */
@@ -55410,16 +55637,17 @@
55637 u8 *zOut = zBuf;
55638 int nRead = iAmt;
55639 int iChunkOffset;
55640 FileChunk *pChunk;
55641
55642 /* SQLite never tries to read past the end of a rollback journal file */
55643 assert( iOfst+iAmt<=p->endpoint.iOffset );
55644
55645 if( p->readpoint.iOffset!=iOfst || iOfst==0 ){
55646 sqlite3_int64 iOff = 0;
55647 for(pChunk=p->pFirst;
55648 ALWAYS(pChunk) && (iOff+JOURNAL_CHUNKSIZE)<=iOfst;
55649 pChunk=pChunk->pNext
55650 ){
55651 iOff += JOURNAL_CHUNKSIZE;
55652 }
55653 }else{
@@ -55518,15 +55746,21 @@
55746 }
55747
55748
55749 /*
55750 ** Sync the file.
55751 **
55752 ** Syncing an in-memory journal is a no-op. And, in fact, this routine
55753 ** is never called in a working implementation. This implementation
55754 ** exists purely as a contingency, in case some malfunction in some other
55755 ** part of SQLite causes Sync to be called by mistake.
55756 */
55757 static int memjrnlSync(sqlite3_file *NotUsed, int NotUsed2){ /*NO_TEST*/
55758 UNUSED_PARAMETER2(NotUsed, NotUsed2); /*NO_TEST*/
55759 assert( 0 ); /*NO_TEST*/
55760 return SQLITE_OK; /*NO_TEST*/
55761 } /*NO_TEST*/
55762
55763 /*
55764 ** Query the size of the file in bytes.
55765 */
55766 static int memjrnlFileSize(sqlite3_file *pJfd, sqlite_int64 *pSize){
@@ -55557,10 +55791,11 @@
55791 /*
55792 ** Open a journal file.
55793 */
55794 SQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *pJfd){
55795 MemJournal *p = (MemJournal *)pJfd;
55796 assert( EIGHT_BYTE_ALIGNMENT(p) );
55797 memset(p, 0, sqlite3MemJournalSize());
55798 p->pMethod = &MemJournalMethods;
55799 }
55800
55801 /*
@@ -55593,11 +55828,11 @@
55828 **
55829 *************************************************************************
55830 ** This file contains routines used for walking the parser tree for
55831 ** an SQL statement.
55832 **
55833 ** $Id: walker.c,v 1.4 2009/04/08 13:51:52 drh Exp $
55834 */
55835
55836
55837 /*
55838 ** Walk an expression tree. Invoke the callback once for each node
@@ -55619,12 +55854,16 @@
55854 ** and WRC_Continue to continue.
55855 */
55856 SQLITE_PRIVATE int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
55857 int rc;
55858 if( pExpr==0 ) return WRC_Continue;
55859 testcase( ExprHasProperty(pExpr, EP_TokenOnly) );
55860 testcase( ExprHasProperty(pExpr, EP_SpanToken) );
55861 testcase( ExprHasProperty(pExpr, EP_Reduced) );
55862 rc = pWalker->xExprCallback(pWalker, pExpr);
55863 if( rc==WRC_Continue
55864 && !ExprHasAnyProperty(pExpr,EP_TokenOnly|EP_SpanToken) ){
55865 if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
55866 if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
55867 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
55868 if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
55869 }else{
@@ -56900,11 +57139,11 @@
57139 **
57140 *************************************************************************
57141 ** This file contains routines used for analyzing expressions and
57142 ** for generating VDBE code that evaluates expressions in SQLite.
57143 **
57144 ** $Id: expr.c,v 1.426 2009/04/08 13:51:51 drh Exp $
57145 */
57146
57147 /*
57148 ** Return the 'affinity' of the expression pExpr if any.
57149 **
@@ -57516,19 +57755,22 @@
57755 ** Clear an expression structure without deleting the structure itself.
57756 ** Substructure is deleted.
57757 */
57758 SQLITE_PRIVATE void sqlite3ExprClear(sqlite3 *db, Expr *p){
57759 if( p->token.dyn ) sqlite3DbFree(db, (char*)p->token.z);
57760 if( !ExprHasAnyProperty(p, EP_TokenOnly|EP_SpanToken) ){
57761 if( p->span.dyn ) sqlite3DbFree(db, (char*)p->span.z);
57762 if( ExprHasProperty(p, EP_Reduced) ){
57763 /* Subtrees are part of the same memory allocation when EP_Reduced set */
57764 if( p->pLeft ) sqlite3ExprClear(db, p->pLeft);
57765 if( p->pRight ) sqlite3ExprClear(db, p->pRight);
57766 }else{
57767 /* Subtrees are separate allocations when EP_Reduced is clear */
57768 sqlite3ExprDelete(db, p->pLeft);
57769 sqlite3ExprDelete(db, p->pRight);
57770 }
57771 /* x.pSelect and x.pList are always separately allocated */
57772 if( ExprHasProperty(p, EP_xIsSelect) ){
57773 sqlite3SelectDelete(db, p->x.pSelect);
57774 }else{
57775 sqlite3ExprListDelete(db, p->x.pList);
57776 }
@@ -57561,11 +57803,11 @@
57803 ** passed as the first argument. This is always one of EXPR_FULLSIZE,
57804 ** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE.
57805 */
57806 static int exprStructSize(Expr *p){
57807 if( ExprHasProperty(p, EP_TokenOnly) ) return EXPR_TOKENONLYSIZE;
57808 if( ExprHasProperty(p, EP_SpanToken) ) return EXPR_SPANTOKENSIZE;
57809 if( ExprHasProperty(p, EP_Reduced) ) return EXPR_REDUCEDSIZE;
57810 return EXPR_FULLSIZE;
57811 }
57812
57813 /*
@@ -57578,12 +57820,12 @@
57820 int nSize;
57821 if( 0==(flags&EXPRDUP_REDUCE) ){
57822 nSize = EXPR_FULLSIZE;
57823 }else if( p->pLeft || p->pRight || p->pColl || p->x.pList ){
57824 nSize = EXPR_REDUCEDSIZE;
57825 }else if( flags&EXPRDUP_SPAN ){
57826 nSize = EXPR_SPANTOKENSIZE;
57827 }else{
57828 nSize = EXPR_TOKENONLYSIZE;
57829 }
57830 return nSize;
57831 }
@@ -57595,12 +57837,12 @@
57837 ** and the copies of the Expr.token.z and Expr.span.z (if applicable)
57838 ** string buffers.
57839 */
57840 static int dupedExprNodeSize(Expr *p, int flags){
57841 int nByte = dupedExprStructSize(p, flags) + (p->token.z ? p->token.n + 1 : 0);
57842 if( (flags&EXPRDUP_SPAN)!=0
57843 && (p->token.z!=p->span.z || p->token.n!=p->span.n)
57844 ){
57845 nByte += p->span.n;
57846 }
57847 return ROUND8(nByte);
57848 }
@@ -57623,11 +57865,11 @@
57865 static int dupedExprSize(Expr *p, int flags){
57866 int nByte = 0;
57867 if( p ){
57868 nByte = dupedExprNodeSize(p, flags);
57869 if( flags&EXPRDUP_REDUCE ){
57870 int f = flags&(~EXPRDUP_SPAN);
57871 nByte += dupedExprSize(p->pLeft, f) + dupedExprSize(p->pRight, f);
57872 }
57873 }
57874 return nByte;
57875 }
@@ -57641,12 +57883,11 @@
57883 ** portion of the buffer copied into by this function.
57884 */
57885 static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){
57886 Expr *pNew = 0; /* Value to return */
57887 if( p ){
57888 const int isRequireSpan = (flags&EXPRDUP_SPAN);
 
57889 const int isReduced = (flags&EXPRDUP_REDUCE);
57890 u8 *zAlloc;
57891
57892 assert( pzBuffer==0 || isReduced );
57893
@@ -57674,15 +57915,15 @@
57915 memcpy(zAlloc, p, nSize);
57916 memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize);
57917 }
57918
57919 /* Set the EP_Reduced and EP_TokenOnly flags appropriately. */
57920 pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_SpanToken);
57921 switch( nNewSize ){
57922 case EXPR_REDUCEDSIZE: pNew->flags |= EP_Reduced; break;
57923 case EXPR_TOKENONLYSIZE: pNew->flags |= EP_TokenOnly; break;
57924 case EXPR_SPANTOKENSIZE: pNew->flags |= EP_SpanToken; break;
57925 }
57926
57927 /* Copy the p->token string, if any. */
57928 if( nToken ){
57929 unsigned char *zToken = &zAlloc[nNewSize];
@@ -57693,13 +57934,11 @@
57934 }
57935
57936 if( 0==((p->flags|pNew->flags) & EP_TokenOnly) ){
57937 /* Fill in the pNew->span token, if required. */
57938 if( isRequireSpan ){
57939 if( p->token.z!=p->span.z || p->token.n!=p->span.n ){
 
 
57940 pNew->span.z = &zAlloc[nNewSize+nToken];
57941 memcpy((char *)pNew->span.z, p->span.z, p->span.n);
57942 pNew->span.dyn = 0;
57943 }else{
57944 pNew->span.z = pNew->token.z;
@@ -57709,30 +57948,30 @@
57948 pNew->span.z = 0;
57949 pNew->span.n = 0;
57950 }
57951 }
57952
57953 if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_SpanToken)) ){
57954 /* Fill in the pNew->x.pSelect or pNew->x.pList member. */
57955 if( ExprHasProperty(p, EP_xIsSelect) ){
57956 pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, isReduced);
57957 }else{
57958 pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, isReduced);
57959 }
57960 }
57961
57962 /* Fill in pNew->pLeft and pNew->pRight. */
57963 if( ExprHasAnyProperty(pNew, EP_Reduced|EP_TokenOnly|EP_SpanToken) ){
57964 zAlloc += dupedExprNodeSize(p, flags);
57965 if( ExprHasProperty(pNew, EP_Reduced) ){
57966 pNew->pLeft = exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc);
57967 pNew->pRight = exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc);
57968 }
57969 if( pzBuffer ){
57970 *pzBuffer = zAlloc;
57971 }
57972 }else if( !ExprHasAnyProperty(p, EP_TokenOnly|EP_SpanToken) ){
57973 pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
57974 pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
57975 }
57976 }
57977 }
@@ -58232,26 +58471,30 @@
58471 ** If this is the case, it may be possible to use an existing table
58472 ** or index instead of generating an epheremal table.
58473 */
58474 p = (ExprHasProperty(pX, EP_xIsSelect) ? pX->x.pSelect : 0);
58475 if( isCandidateForInOpt(p) ){
58476 sqlite3 *db = pParse->db; /* Database connection */
58477 Expr *pExpr = p->pEList->a[0].pExpr; /* Expression <column> */
58478 int iCol = pExpr->iColumn; /* Index of column <column> */
58479 Vdbe *v = sqlite3GetVdbe(pParse); /* Virtual machine being coded */
58480 Table *pTab = p->pSrc->a[0].pTab; /* Table <table>. */
58481 int iDb; /* Database idx for pTab */
58482
58483 /* Code an OP_VerifyCookie and OP_TableLock for <table>. */
58484 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
58485 sqlite3CodeVerifySchema(pParse, iDb);
58486 sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
58487
58488 /* This function is only called from two places. In both cases the vdbe
58489 ** has already been allocated. So assume sqlite3GetVdbe() is always
58490 ** successful here.
58491 */
58492 assert(v);
58493 if( iCol<0 ){
58494 int iMem = ++pParse->nMem;
58495 int iAddr;
 
 
58496 sqlite3VdbeUsesBtree(v, iDb);
58497
58498 iAddr = sqlite3VdbeAddOp1(v, OP_If, iMem);
58499 sqlite3VdbeAddOp2(v, OP_Integer, 1, iMem);
58500
@@ -58258,30 +58501,29 @@
58501 sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
58502 eType = IN_INDEX_ROWID;
58503
58504 sqlite3VdbeJumpHere(v, iAddr);
58505 }else{
58506 Index *pIdx; /* Iterator variable */
58507
58508 /* The collation sequence used by the comparison. If an index is to
58509 ** be used in place of a temp-table, it must be ordered according
58510 ** to this collation sequence. */
 
58511 CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pExpr);
58512
58513 /* Check that the affinity that will be used to perform the
58514 ** comparison is the same as the affinity of the column. If
58515 ** it is not, it is not possible to use any index.
58516 */
 
58517 char aff = comparisonAffinity(pX);
58518 int affinity_ok = (pTab->aCol[iCol].affinity==aff||aff==SQLITE_AFF_NONE);
58519
58520 for(pIdx=pTab->pIndex; pIdx && eType==0 && affinity_ok; pIdx=pIdx->pNext){
58521 if( (pIdx->aiColumn[0]==iCol)
58522 && (pReq==sqlite3FindCollSeq(db, ENC(db), pIdx->azColl[0], -1, 0))
58523 && (!mustBeUnique || (pIdx->nColumn==1 && pIdx->onError!=OE_None))
58524 ){
 
58525 int iMem = ++pParse->nMem;
58526 int iAddr;
58527 char *pKey;
58528
58529 pKey = (char *)sqlite3IndexKeyinfo(pParse, pIdx);
@@ -59089,35 +59331,38 @@
59331 }
59332 break;
59333 }
59334 case TK_CONST_FUNC:
59335 case TK_FUNCTION: {
59336 ExprList *pFarg; /* List of function arguments */
59337 int nFarg; /* Number of function arguments */
59338 FuncDef *pDef; /* The function definition object */
59339 int nId; /* Length of the function name in bytes */
59340 const char *zId; /* The function name */
59341 int constMask = 0; /* Mask of function arguments that are constant */
59342 int i; /* Loop counter */
59343 u8 enc = ENC(db); /* The text encoding used by this database */
59344 CollSeq *pColl = 0; /* A collating sequence */
 
 
59345
59346 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
59347 testcase( op==TK_CONST_FUNC );
59348 testcase( op==TK_FUNCTION );
59349 if( ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_SpanToken) ){
59350 pFarg = 0;
59351 }else{
59352 pFarg = pExpr->x.pList;
59353 }
59354 nFarg = pFarg ? pFarg->nExpr : 0;
59355 zId = (char*)pExpr->token.z;
59356 nId = pExpr->token.n;
59357 pDef = sqlite3FindFunction(db, zId, nId, nFarg, enc, 0);
59358 assert( pDef!=0 );
59359 if( pFarg ){
59360 r1 = sqlite3GetTempRange(pParse, nFarg);
59361 sqlite3ExprCodeExprList(pParse, pFarg, r1, 1);
 
59362 }else{
59363 r1 = 0;
59364 }
59365 #ifndef SQLITE_OMIT_VIRTUALTABLE
59366 /* Possibly overload the function if the first argument is
59367 ** a virtual table column.
59368 **
@@ -59128,35 +59373,35 @@
59373 ** control overloading) ends up as the second argument to the
59374 ** function. The expression "A glob B" is equivalent to
59375 ** "glob(B,A). We want to use the A in "A glob B" to test
59376 ** for function overloading. But we use the B term in "glob(B,A)".
59377 */
59378 if( nFarg>=2 && (pExpr->flags & EP_InfixFunc) ){
59379 pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[1].pExpr);
59380 }else if( nFarg>0 ){
59381 pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[0].pExpr);
59382 }
59383 #endif
59384 for(i=0; i<nFarg && i<32; i++){
59385 if( sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){
59386 constMask |= (1<<i);
59387 }
59388 if( (pDef->flags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){
59389 pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr);
59390 }
59391 }
59392 if( pDef->flags & SQLITE_FUNC_NEEDCOLL ){
59393 if( !pColl ) pColl = db->pDfltColl;
59394 sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);
59395 }
59396 sqlite3VdbeAddOp4(v, OP_Function, constMask, r1, target,
59397 (char*)pDef, P4_FUNCDEF);
59398 sqlite3VdbeChangeP5(v, (u8)nFarg);
59399 if( nFarg ){
59400 sqlite3ReleaseTempRange(pParse, r1, nFarg);
59401 }
59402 sqlite3ExprCacheAffinityChange(pParse, r1, nFarg);
59403 break;
59404 }
59405 #ifndef SQLITE_OMIT_SUBQUERY
59406 case TK_EXISTS:
59407 case TK_SELECT: {
@@ -61275,11 +61520,11 @@
61520 ** May you share freely, never taking more than you give.
61521 **
61522 *************************************************************************
61523 ** This file contains code used to implement the ATTACH and DETACH commands.
61524 **
61525 ** $Id: attach.c,v 1.84 2009/04/08 13:51:51 drh Exp $
61526 */
61527
61528 #ifndef SQLITE_OMIT_ATTACH
61529 /*
61530 ** Resolve an expression that was part of an ATTACH or DETACH statement. This
@@ -61751,11 +61996,11 @@
61996 SQLITE_PRIVATE int sqlite3FixExpr(
61997 DbFixer *pFix, /* Context of the fixation */
61998 Expr *pExpr /* The expression to be fixed to one database */
61999 ){
62000 while( pExpr ){
62001 if( ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_SpanToken) ) break;
62002 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
62003 if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1;
62004 }else{
62005 if( sqlite3FixExprList(pFix, pExpr->x.pList) ) return 1;
62006 }
@@ -62063,11 +62308,11 @@
62308 ** creating ID lists
62309 ** BEGIN TRANSACTION
62310 ** COMMIT
62311 ** ROLLBACK
62312 **
62313 ** $Id: build.c,v 1.528 2009/04/08 13:51:51 drh Exp $
62314 */
62315
62316 /*
62317 ** This routine is called when a new SQL statement is beginning to
62318 ** be parsed. Initialize the pParse structure as needed.
@@ -63152,13 +63397,11 @@
63397 /* A copy of pExpr is used instead of the original, as pExpr contains
63398 ** tokens that point to volatile memory. The 'span' of the expression
63399 ** is required by pragma table_info.
63400 */
63401 sqlite3ExprDelete(db, pCol->pDflt);
63402 pCol->pDflt = sqlite3ExprDup(db, pExpr, EXPRDUP_REDUCE|EXPRDUP_SPAN);
 
 
63403 }
63404 }
63405 sqlite3ExprDelete(db, pExpr);
63406 }
63407
@@ -66831,11 +67074,11 @@
67074 **
67075 ** There is only one exported symbol in this file - the function
67076 ** sqliteRegisterBuildinFunctions() found at the bottom of the file.
67077 ** All other code has file scope.
67078 **
67079 ** $Id: func.c,v 1.231 2009/04/08 23:04:14 drh Exp $
67080 */
67081
67082 /*
67083 ** Return the collating function associated with a function.
67084 */
@@ -67077,20 +67320,26 @@
67320 #endif
67321
67322 /*
67323 ** Allocate nByte bytes of space using sqlite3_malloc(). If the
67324 ** allocation fails, call sqlite3_result_error_nomem() to notify
67325 ** the database handle that malloc() has failed and return NULL.
67326 ** If nByte is larger than the maximum string or blob length, then
67327 ** raise an SQLITE_TOOBIG exception and return NULL.
67328 */
67329 static void *contextMalloc(sqlite3_context *context, i64 nByte){
67330 char *z;
67331 sqlite3 *db = sqlite3_context_db_handle(context);
67332 assert( nByte>0 );
67333 testcase( nByte==db->aLimit[SQLITE_LIMIT_LENGTH] );
67334 testcase( nByte==db->aLimit[SQLITE_LIMIT_LENGTH]+1 );
67335 if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){
67336 sqlite3_result_error_toobig(context);
67337 z = 0;
67338 }else{
67339 z = sqlite3Malloc((int)nByte);
67340 if( !z ){
67341 sqlite3_result_error_nomem(context);
67342 }
67343 }
67344 return z;
67345 }
@@ -67167,12 +67416,21 @@
67416 sqlite3_value **NotUsed2
67417 ){
67418 sqlite_int64 r;
67419 UNUSED_PARAMETER2(NotUsed, NotUsed2);
67420 sqlite3_randomness(sizeof(r), &r);
67421 if( r<0 ){
67422 /* We need to prevent a random number of 0x8000000000000000
67423 ** (or -9223372036854775808) since when you do abs() of that
67424 ** number of you get the same value back again. To do this
67425 ** in a way that is testable, mask the sign bit off of negative
67426 ** values, resulting in a positive value. Then take the
67427 ** 2s complement of that positive value. The end result can
67428 ** therefore be no less than -9223372036854775807.
67429 */
67430 r = -(r ^ (((sqlite3_int64)1)<<63));
67431 }
67432 sqlite3_result_int64(context, r);
67433 }
67434
67435 /*
67436 ** Implementation of randomblob(N). Return a random blob
@@ -67255,11 +67513,11 @@
67513 ** character is exactly one byte in size. Also, all characters are
67514 ** able to participate in upper-case-to-lower-case mappings in EBCDIC
67515 ** whereas only characters less than 0x80 do in ASCII.
67516 */
67517 #if defined(SQLITE_EBCDIC)
67518 # define sqlite3Utf8Read(A,C) (*(A++))
67519 # define GlogUpperToLower(A) A = sqlite3UpperToLower[A]
67520 #else
67521 # define GlogUpperToLower(A) if( A<0x80 ){ A = sqlite3UpperToLower[A]; }
67522 #endif
67523
@@ -67312,22 +67570,22 @@
67570 u8 matchAll = pInfo->matchAll;
67571 u8 matchSet = pInfo->matchSet;
67572 u8 noCase = pInfo->noCase;
67573 int prevEscape = 0; /* True if the previous character was 'escape' */
67574
67575 while( (c = sqlite3Utf8Read(zPattern,&zPattern))!=0 ){
67576 if( !prevEscape && c==matchAll ){
67577 while( (c=sqlite3Utf8Read(zPattern,&zPattern)) == matchAll
67578 || c == matchOne ){
67579 if( c==matchOne && sqlite3Utf8Read(zString, &zString)==0 ){
67580 return 0;
67581 }
67582 }
67583 if( c==0 ){
67584 return 1;
67585 }else if( c==esc ){
67586 c = sqlite3Utf8Read(zPattern, &zPattern);
67587 if( c==0 ){
67588 return 0;
67589 }
67590 }else if( c==matchSet ){
67591 assert( esc==0 ); /* This is GLOB, not LIKE */
@@ -67335,67 +67593,67 @@
67593 while( *zString && patternCompare(&zPattern[-1],zString,pInfo,esc)==0 ){
67594 SQLITE_SKIP_UTF8(zString);
67595 }
67596 return *zString!=0;
67597 }
67598 while( (c2 = sqlite3Utf8Read(zString,&zString))!=0 ){
67599 if( noCase ){
67600 GlogUpperToLower(c2);
67601 GlogUpperToLower(c);
67602 while( c2 != 0 && c2 != c ){
67603 c2 = sqlite3Utf8Read(zString, &zString);
67604 GlogUpperToLower(c2);
67605 }
67606 }else{
67607 while( c2 != 0 && c2 != c ){
67608 c2 = sqlite3Utf8Read(zString, &zString);
67609 }
67610 }
67611 if( c2==0 ) return 0;
67612 if( patternCompare(zPattern,zString,pInfo,esc) ) return 1;
67613 }
67614 return 0;
67615 }else if( !prevEscape && c==matchOne ){
67616 if( sqlite3Utf8Read(zString, &zString)==0 ){
67617 return 0;
67618 }
67619 }else if( c==matchSet ){
67620 int prior_c = 0;
67621 assert( esc==0 ); /* This only occurs for GLOB, not LIKE */
67622 seen = 0;
67623 invert = 0;
67624 c = sqlite3Utf8Read(zString, &zString);
67625 if( c==0 ) return 0;
67626 c2 = sqlite3Utf8Read(zPattern, &zPattern);
67627 if( c2=='^' ){
67628 invert = 1;
67629 c2 = sqlite3Utf8Read(zPattern, &zPattern);
67630 }
67631 if( c2==']' ){
67632 if( c==']' ) seen = 1;
67633 c2 = sqlite3Utf8Read(zPattern, &zPattern);
67634 }
67635 while( c2 && c2!=']' ){
67636 if( c2=='-' && zPattern[0]!=']' && zPattern[0]!=0 && prior_c>0 ){
67637 c2 = sqlite3Utf8Read(zPattern, &zPattern);
67638 if( c>=prior_c && c<=c2 ) seen = 1;
67639 prior_c = 0;
67640 }else{
67641 if( c==c2 ){
67642 seen = 1;
67643 }
67644 prior_c = c2;
67645 }
67646 c2 = sqlite3Utf8Read(zPattern, &zPattern);
67647 }
67648 if( c2==0 || (seen ^ invert)==0 ){
67649 return 0;
67650 }
67651 }else if( esc==c && !prevEscape ){
67652 prevEscape = 1;
67653 }else{
67654 c2 = sqlite3Utf8Read(zString, &zString);
67655 if( noCase ){
67656 GlogUpperToLower(c);
67657 GlogUpperToLower(c2);
67658 }
67659 if( c!=c2 ){
@@ -67434,20 +67692,23 @@
67692 int argc,
67693 sqlite3_value **argv
67694 ){
67695 const unsigned char *zA, *zB;
67696 int escape = 0;
67697 int nPat;
67698 sqlite3 *db = sqlite3_context_db_handle(context);
67699
67700 zB = sqlite3_value_text(argv[0]);
67701 zA = sqlite3_value_text(argv[1]);
67702
67703 /* Limit the length of the LIKE or GLOB pattern to avoid problems
67704 ** of deep recursion and N*N behavior in patternCompare().
67705 */
67706 nPat = sqlite3_value_bytes(argv[0]);
67707 testcase( nPat==db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] );
67708 testcase( nPat==db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]+1 );
67709 if( nPat > db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] ){
67710 sqlite3_result_error(context, "LIKE or GLOB pattern too complex", -1);
67711 return;
67712 }
67713 assert( zB==sqlite3_value_text(argv[0]) ); /* Encoding did not change */
67714
@@ -67460,11 +67721,11 @@
67721 if( sqlite3Utf8CharLen((char*)zEsc, -1)!=1 ){
67722 sqlite3_result_error(context,
67723 "ESCAPE expression must be a single character", -1);
67724 return;
67725 }
67726 escape = sqlite3Utf8Read(zEsc, &zEsc);
67727 }
67728 if( zA && zB ){
67729 struct compareInfo *pInfo = sqlite3_user_data(context);
67730 #ifdef SQLITE_TEST
67731 sqlite3_like_count++;
@@ -67619,14 +67880,17 @@
67880 sqlite3_context *context,
67881 int argc,
67882 sqlite3_value **argv
67883 ){
67884 i64 n;
67885 sqlite3 *db = sqlite3_context_db_handle(context);
67886 assert( argc==1 );
67887 UNUSED_PARAMETER(argc);
67888 n = sqlite3_value_int64(argv[0]);
67889 testcase( n==db->aLimit[SQLITE_LIMIT_LENGTH] );
67890 testcase( n==db->aLimit[SQLITE_LIMIT_LENGTH]+1 );
67891 if( n>db->aLimit[SQLITE_LIMIT_LENGTH] ){
67892 sqlite3_result_error_toobig(context);
67893 }else{
67894 sqlite3_result_zeroblob(context, (int)n);
67895 }
67896 }
@@ -67688,11 +67952,13 @@
67952 zOut[j++] = zStr[i];
67953 }else{
67954 u8 *zOld;
67955 sqlite3 *db = sqlite3_context_db_handle(context);
67956 nOut += nRep - nPattern;
67957 testcase( nOut-1==db->aLimit[SQLITE_LIMIT_LENGTH] );
67958 testcase( nOut-2==db->aLimit[SQLITE_LIMIT_LENGTH] );
67959 if( nOut-1>db->aLimit[SQLITE_LIMIT_LENGTH] ){
67960 sqlite3_result_error_toobig(context);
67961 sqlite3DbFree(db, zOut);
67962 return;
67963 }
67964 zOld = zOut;
@@ -67772,11 +68038,11 @@
68038 if( flags & 1 ){
68039 while( nIn>0 ){
68040 int len = 0;
68041 for(i=0; i<nChar; i++){
68042 len = aLen[i];
68043 if( len<=nIn && memcmp(zIn, azChar[i], len)==0 ) break;
68044 }
68045 if( i>=nChar ) break;
68046 zIn += len;
68047 nIn -= len;
68048 }
@@ -67966,10 +68232,17 @@
68232 CountCtx *p;
68233 p = sqlite3_aggregate_context(context, sizeof(*p));
68234 if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0])) && p ){
68235 p->n++;
68236 }
68237
68238 /* The sqlite3_aggregate_count() function is deprecated. But just to make
68239 ** sure it still operates correctly, verify that its count agrees with our
68240 ** internal count when using count(*) and when the total count can be
68241 ** expressed as a 32-bit integer. */
68242 assert( argc==1 || p==0 || p->n>0x7fffffff
68243 || p->n==sqlite3_aggregate_count(context) );
68244 }
68245 static void countFinalize(sqlite3_context *context){
68246 CountCtx *p;
68247 p = sqlite3_aggregate_context(context, 0);
68248 sqlite3_result_int64(context, p ? p->n : 0);
@@ -68014,11 +68287,11 @@
68287 }
68288 static void minMaxFinalize(sqlite3_context *context){
68289 sqlite3_value *pRes;
68290 pRes = (sqlite3_value *)sqlite3_aggregate_context(context, 0);
68291 if( pRes ){
68292 if( ALWAYS(pRes->flags) ){
68293 sqlite3_result_value(context, pRes);
68294 }
68295 sqlite3VdbeMemRelease(pRes);
68296 }
68297 }
@@ -68099,11 +68372,11 @@
68372 */
68373 static void setLikeOptFlag(sqlite3 *db, const char *zName, u8 flagVal){
68374 FuncDef *pDef;
68375 pDef = sqlite3FindFunction(db, zName, sqlite3Strlen30(zName),
68376 2, SQLITE_UTF8, 0);
68377 if( ALWAYS(pDef) ){
68378 pDef->flags = flagVal;
68379 }
68380 }
68381
68382 /*
@@ -68143,11 +68416,11 @@
68416 return 0;
68417 }
68418 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
68419 pDef = sqlite3FindFunction(db, (char*)pExpr->token.z, pExpr->token.n, 2,
68420 SQLITE_UTF8, 0);
68421 if( NEVER(pDef==0) || (pDef->flags & SQLITE_FUNC_LIKE)==0 ){
68422 return 0;
68423 }
68424
68425 /* The memcpy() statement assumes that the wildcard characters are
68426 ** the first three statements in the compareInfo structure. The
@@ -71141,11 +71414,11 @@
71414 ** May you share freely, never taking more than you give.
71415 **
71416 *************************************************************************
71417 ** This file contains code used to implement the PRAGMA command.
71418 **
71419 ** $Id: pragma.c,v 1.209 2009/04/07 22:05:43 drh Exp $
71420 */
71421
71422 /* Ignore this whole file if pragmas are disabled
71423 */
71424 #if !defined(SQLITE_OMIT_PRAGMA) && !defined(SQLITE_OMIT_PARSER)
@@ -71273,18 +71546,20 @@
71546 #endif /* SQLITE_PAGER_PRAGMAS */
71547
71548 /*
71549 ** Generate code to return a single integer value.
71550 */
71551 static void returnSingleInt(Parse *pParse, const char *zLabel, i64 value){
71552 Vdbe *v = sqlite3GetVdbe(pParse);
71553 int mem = ++pParse->nMem;
71554 i64 *pI64 = sqlite3DbMallocRaw(pParse->db, sizeof(value));
71555 if( pI64 ){
71556 memcpy(pI64, &value, sizeof(value));
 
71557 }
71558 sqlite3VdbeAddOp4(v, OP_Int64, 0, mem, 0, (char*)pI64, P4_INT64);
71559 sqlite3VdbeSetNumCols(v, 1);
71560 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC);
71561 sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);
71562 }
71563
71564 #ifndef SQLITE_OMIT_FLAG_PRAGMAS
71565 /*
@@ -71498,11 +71773,11 @@
71773 }else{
71774 /* Malloc may fail when setting the page-size, as there is an internal
71775 ** buffer that the pager module resizes using sqlite3_realloc().
71776 */
71777 db->nextPagesize = atoi(zRight);
71778 if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1, 0) ){
71779 db->mallocFailed = 1;
71780 }
71781 }
71782 }else
71783
@@ -71660,18 +71935,15 @@
71935 */
71936 if( sqlite3StrICmp(zLeft,"journal_size_limit")==0 ){
71937 Pager *pPager = sqlite3BtreePager(pDb->pBt);
71938 i64 iLimit = -2;
71939 if( zRight ){
71940 sqlite3Atoi64(zRight, &iLimit);
71941 if( iLimit<-1 ) iLimit = -1;
 
 
 
71942 }
71943 iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit);
71944 returnSingleInt(pParse, "journal_size_limit", iLimit);
71945 }else
71946
71947 #endif /* SQLITE_OMIT_PAGER_PRAGMAS */
71948
71949 /*
@@ -72208,11 +72480,10 @@
72480 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
72481 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->tnum, 2+cnt);
72482 cnt++;
72483 }
72484 }
 
72485
72486 /* Make sure sufficient number of registers have been allocated */
72487 if( pParse->nMem < cnt+4 ){
72488 pParse->nMem = cnt+4;
72489 }
@@ -72281,11 +72552,10 @@
72552 { OP_String8, 0, 2, 0}, /* 6 */
72553 { OP_String8, 0, 3, 0}, /* 7 */
72554 { OP_Concat, 3, 2, 2},
72555 { OP_ResultRow, 2, 1, 0},
72556 };
 
72557 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1);
72558 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
72559 sqlite3VdbeJumpHere(v, addr);
72560 addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx);
72561 sqlite3VdbeChangeP1(v, addr+1, j+2);
@@ -72578,11 +72848,11 @@
72848 *************************************************************************
72849 ** This file contains the implementation of the sqlite3_prepare()
72850 ** interface, and routines that contribute to loading the database schema
72851 ** from disk.
72852 **
72853 ** $Id: prepare.c,v 1.116 2009/04/02 18:32:27 drh Exp $
72854 */
72855
72856 /*
72857 ** Fill the InitData structure with an error message that indicates
72858 ** that the database is corrupt.
@@ -73092,15 +73362,12 @@
73362 Parse sParse;
73363 char *zErrMsg = 0;
73364 int rc = SQLITE_OK;
73365 int i;
73366
73367 if( sqlite3SafetyOn(db) ) return SQLITE_MISUSE;
73368 assert( ppStmt && *ppStmt==0 );
 
 
 
73369 assert( !db->mallocFailed );
73370 assert( sqlite3_mutex_held(db->mutex) );
73371
73372 /* Check to verify that it is possible to get a read lock on all
73373 ** database schemas. The inability to get a read lock indicates that
@@ -73235,10 +73502,12 @@
73502 int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */
73503 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
73504 const char **pzTail /* OUT: End of parsed string */
73505 ){
73506 int rc;
73507 assert( ppStmt!=0 );
73508 *ppStmt = 0;
73509 if( !sqlite3SafetyCheckOk(db) ){
73510 return SQLITE_MISUSE;
73511 }
73512 sqlite3_mutex_enter(db->mutex);
73513 sqlite3BtreeEnterAll(db);
@@ -73337,10 +73606,12 @@
73606 */
73607 char *zSql8;
73608 const char *zTail8 = 0;
73609 int rc = SQLITE_OK;
73610
73611 assert( ppStmt );
73612 *ppStmt = 0;
73613 if( !sqlite3SafetyCheckOk(db) ){
73614 return SQLITE_MISUSE;
73615 }
73616 sqlite3_mutex_enter(db->mutex);
73617 zSql8 = sqlite3Utf16to8(db, zSql, nBytes);
@@ -73412,11 +73683,11 @@
73683 **
73684 *************************************************************************
73685 ** This file contains C code routines that are called by the parser
73686 ** to handle SELECT statements in SQLite.
73687 **
73688 ** $Id: select.c,v 1.507 2009/04/02 16:59:47 drh Exp $
73689 */
73690
73691
73692 /*
73693 ** Delete all the content of a Select structure but do not deallocate
@@ -75953,10 +76224,16 @@
76224 ** ORDER by clause of the parent must be simple references to
76225 ** columns of the sub-query.
76226 **
76227 ** (19) The subquery does not use LIMIT or the outer query does not
76228 ** have a WHERE clause.
76229 **
76230 ** (20) If the sub-query is a compound select, then it must not use
76231 ** an ORDER BY clause. Ticket #3773. We could relax this constraint
76232 ** somewhat by saying that the terms of the ORDER BY clause must
76233 ** appear as unmodified result columns in the outer query. But
76234 ** have other optimizations in mind to deal with that case.
76235 **
76236 ** In this routine, the "p" parameter is a pointer to the outer query.
76237 ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query
76238 ** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates.
76239 **
@@ -76064,10 +76341,13 @@
76341 ** use only the UNION ALL operator. And none of the simple select queries
76342 ** that make up the compound SELECT are allowed to be aggregate or distinct
76343 ** queries.
76344 */
76345 if( pSub->pPrior ){
76346 if( pSub->pOrderBy ){
76347 return 0; /* Restriction 20 */
76348 }
76349 if( isAgg || (p->selFlags & SF_Distinct)!=0 || pSrc->nSrc!=1 ){
76350 return 0;
76351 }
76352 for(pSub1=pSub; pSub1; pSub1=pSub1->pPrior){
76353 if( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))!=0
@@ -77706,52 +77986,51 @@
77986 ** interface routine of sqlite3_exec().
77987 **
77988 ** These routines are in a separate files so that they will not be linked
77989 ** if they are not used.
77990 **
77991 ** $Id: table.c,v 1.40 2009/04/10 14:28:00 drh Exp $
77992 */
77993
77994 #ifndef SQLITE_OMIT_GET_TABLE
77995
77996 /*
77997 ** This structure is used to pass data from sqlite3_get_table() through
77998 ** to the callback function is uses to build the result.
77999 */
78000 typedef struct TabResult {
78001 char **azResult; /* Accumulated output */
78002 char *zErrMsg; /* Error message text, if an error occurs */
78003 int nAlloc; /* Slots allocated for azResult[] */
78004 int nRow; /* Number of rows in the result */
78005 int nColumn; /* Number of columns in the result */
78006 int nData; /* Slots used in azResult[]. (nRow+1)*nColumn */
78007 int rc; /* Return code from sqlite3_exec() */
 
78008 } TabResult;
78009
78010 /*
78011 ** This routine is called once for each row in the result table. Its job
78012 ** is to fill in the TabResult structure appropriately, allocating new
78013 ** memory as necessary.
78014 */
78015 static int sqlite3_get_table_cb(void *pArg, int nCol, char **argv, char **colv){
78016 TabResult *p = (TabResult*)pArg; /* Result accumulator */
78017 int need; /* Slots needed in p->azResult[] */
78018 int i; /* Loop counter */
78019 char *z; /* A single column of result */
78020
78021 /* Make sure there is enough space in p->azResult to hold everything
78022 ** we need to remember from this invocation of the callback.
78023 */
78024 if( p->nRow==0 && argv!=0 ){
78025 need = nCol*2;
78026 }else{
78027 need = nCol;
78028 }
78029 if( p->nData + need > p->nAlloc ){
78030 char **azNew;
78031 p->nAlloc = p->nAlloc*2 + need;
78032 azNew = sqlite3_realloc( p->azResult, sizeof(char*)*p->nAlloc );
78033 if( azNew==0 ) goto malloc_failed;
78034 p->azResult = azNew;
78035 }
78036
@@ -77821,11 +78100,10 @@
78100 *pazResult = 0;
78101 if( pnColumn ) *pnColumn = 0;
78102 if( pnRow ) *pnRow = 0;
78103 if( pzErrMsg ) *pzErrMsg = 0;
78104 res.zErrMsg = 0;
 
78105 res.nRow = 0;
78106 res.nColumn = 0;
78107 res.nData = 1;
78108 res.nAlloc = 20;
78109 res.rc = SQLITE_OK;
@@ -77855,17 +78133,16 @@
78133 sqlite3_free_table(&res.azResult[1]);
78134 return rc;
78135 }
78136 if( res.nAlloc>res.nData ){
78137 char **azNew;
78138 azNew = sqlite3_realloc( res.azResult, sizeof(char*)*res.nData );
78139 if( azNew==0 ){
78140 sqlite3_free_table(&res.azResult[1]);
78141 db->errCode = SQLITE_NOMEM;
78142 return SQLITE_NOMEM;
78143 }
 
78144 res.azResult = azNew;
78145 }
78146 *pazResult = &res.azResult[1];
78147 if( pnColumn ) *pnColumn = res.nColumn;
78148 if( pnRow ) *pnRow = res.nRow;
@@ -79468,11 +79745,11 @@
79745 ** This file contains code used to implement the VACUUM command.
79746 **
79747 ** Most of the code in this file may be omitted by defining the
79748 ** SQLITE_OMIT_VACUUM macro.
79749 **
79750 ** $Id: vacuum.c,v 1.87 2009/04/02 20:16:59 drh Exp $
79751 */
79752
79753 #if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)
79754 /*
79755 ** Execute zSql on database db. Return an error code.
@@ -79592,12 +79869,12 @@
79869 sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
79870 if( nKey ) db->nextPagesize = 0;
79871 }
79872 #endif
79873
79874 if( sqlite3BtreeSetPageSize(pTemp, sqlite3BtreeGetPageSize(pMain), nRes, 0)
79875 || (!isMemDb && sqlite3BtreeSetPageSize(pTemp, db->nextPagesize, nRes, 0))
79876 || db->mallocFailed
79877 ){
79878 rc = SQLITE_NOMEM;
79879 goto end_of_vacuum;
79880 }
@@ -79720,11 +79997,11 @@
79997 sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp));
79998 #endif
79999 }
80000
80001 if( rc==SQLITE_OK ){
80002 rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes,1);
80003 }
80004
80005 end_of_vacuum:
80006 /* Restore the original value of db->flags */
80007 db->flags = saved_flags;
@@ -79765,14 +80042,19 @@
80042 ** May you share freely, never taking more than you give.
80043 **
80044 *************************************************************************
80045 ** This file contains code used to help implement virtual tables.
80046 **
80047 ** $Id: vtab.c,v 1.85 2009/04/11 16:27:20 drh Exp $
80048 */
80049 #ifndef SQLITE_OMIT_VIRTUALTABLE
80050
80051 /*
80052 ** The actual function that does the work of creating a new module.
80053 ** This function implements the sqlite3_create_module() and
80054 ** sqlite3_create_module_v2() interfaces.
80055 */
80056 static int createModule(
80057 sqlite3 *db, /* Database in which module is registered */
80058 const char *zName, /* Name assigned to this module */
80059 const sqlite3_module *pModule, /* The definition of the module */
80060 void *pAux, /* Context pointer for xCreate/xConnect */
@@ -79850,10 +80132,11 @@
80132 /*
80133 ** Unlock a virtual table. When the last lock is removed,
80134 ** disconnect the virtual table.
80135 */
80136 SQLITE_PRIVATE void sqlite3VtabUnlock(sqlite3 *db, sqlite3_vtab *pVtab){
80137 assert( pVtab->nRef>0 );
80138 pVtab->nRef--;
80139 assert(db);
80140 assert( sqlite3SafetyCheckOk(db) );
80141 if( pVtab->nRef==0 ){
80142 if( db->magic==SQLITE_MAGIC_BUSY ){
@@ -80618,20 +80901,20 @@
80901 ** generating the code that loops through a table looking for applicable
80902 ** rows. Indices are selected and used to speed the search when doing
80903 ** so is applicable. Because this module is responsible for selecting
80904 ** indices, you might also think of this module as the "query optimizer".
80905 **
80906 ** $Id: where.c,v 1.382 2009/04/07 13:48:12 drh Exp $
80907 */
80908
80909 /*
80910 ** Trace output macros
80911 */
80912 #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
80913 SQLITE_PRIVATE int sqlite3WhereTrace = 0;
80914 #endif
80915 #if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
80916 # define WHERETRACE(X) if(sqlite3WhereTrace) sqlite3DebugPrintf X
80917 #else
80918 # define WHERETRACE(X)
80919 #endif
80920
@@ -82363,10 +82646,17 @@
82646 */
82647 memset(pCost, 0, sizeof(*pCost));
82648 if( pProbe==0 &&
82649 findTerm(pWC, iCur, -1, 0, WO_EQ|WO_IN|WO_LT|WO_LE|WO_GT|WO_GE,0)==0 &&
82650 (pOrderBy==0 || !sortableByRowid(iCur, pOrderBy, pWC->pMaskSet, &rev)) ){
82651 if( pParse->db->flags & SQLITE_ReverseOrder ){
82652 /* For application testing, randomly reverse the output order for
82653 ** SELECT statements that omit the ORDER BY clause. This will help
82654 ** to find cases where
82655 */
82656 pCost->plan.wsFlags |= WHERE_REVERSE;
82657 }
82658 return;
82659 }
82660 pCost->rCost = SQLITE_BIG_DBL;
82661
82662 /* Check for a rowid=EXPR or rowid IN (...) constraints. If there was
@@ -84205,12 +84495,12 @@
84495 #endif
84496 #define sqlite3ParserARG_SDECL Parse *pParse;
84497 #define sqlite3ParserARG_PDECL ,Parse *pParse
84498 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
84499 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
84500 #define YYNSTATE 616
84501 #define YYNRULE 323
84502 #define YYFALLBACK 1
84503 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
84504 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
84505 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
84506
@@ -84265,161 +84555,160 @@
84555 ** yy_reduce_ofst[] For each state, the offset into yy_action for
84556 ** shifting non-terminals after a reduce.
84557 ** yy_default[] Default action for each state.
84558 */
84559 static const YYACTIONTYPE yy_action[] = {
84560 /* 0 */ 304, 940, 176, 615, 2, 150, 214, 439, 24, 24,
84561 /* 10 */ 24, 24, 488, 26, 26, 26, 26, 27, 27, 28,
84562 /* 20 */ 28, 28, 29, 216, 413, 414, 212, 413, 414, 446,
84563 /* 30 */ 452, 31, 26, 26, 26, 26, 27, 27, 28, 28,
84564 /* 40 */ 28, 29, 216, 30, 483, 32, 134, 23, 22, 308,
84565 /* 50 */ 456, 457, 453, 453, 25, 25, 24, 24, 24, 24,
84566 /* 60 */ 436, 26, 26, 26, 26, 27, 27, 28, 28, 28,
84567 /* 70 */ 29, 216, 304, 216, 311, 439, 512, 490, 45, 26,
84568 /* 80 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 216,
84569 /* 90 */ 413, 414, 416, 417, 156, 416, 417, 360, 363, 364,
84570 /* 100 */ 311, 446, 452, 385, 514, 21, 186, 495, 365, 27,
84571 /* 110 */ 27, 28, 28, 28, 29, 216, 413, 414, 415, 23,
84572 /* 120 */ 22, 308, 456, 457, 453, 453, 25, 25, 24, 24,
84573 /* 130 */ 24, 24, 555, 26, 26, 26, 26, 27, 27, 28,
84574 /* 140 */ 28, 28, 29, 216, 304, 228, 504, 135, 468, 218,
84575 /* 150 */ 548, 145, 132, 256, 358, 261, 359, 153, 416, 417,
84576 /* 160 */ 241, 598, 331, 30, 265, 32, 134, 439, 596, 597,
84577 /* 170 */ 230, 228, 490, 446, 452, 57, 506, 328, 132, 256,
84578 /* 180 */ 358, 261, 359, 153, 416, 417, 435, 78, 408, 405,
84579 /* 190 */ 265, 23, 22, 308, 456, 457, 453, 453, 25, 25,
84580 /* 200 */ 24, 24, 24, 24, 342, 26, 26, 26, 26, 27,
84581 /* 210 */ 27, 28, 28, 28, 29, 216, 304, 214, 534, 547,
84582 /* 220 */ 307, 127, 489, 595, 30, 331, 32, 134, 345, 387,
84583 /* 230 */ 429, 63, 331, 355, 415, 439, 507, 331, 415, 535,
84584 /* 240 */ 328, 215, 193, 594, 593, 446, 452, 328, 18, 435,
84585 /* 250 */ 85, 16, 328, 183, 190, 556, 435, 78, 309, 463,
84586 /* 260 */ 464, 435, 85, 23, 22, 308, 456, 457, 453, 453,
84587 /* 270 */ 25, 25, 24, 24, 24, 24, 436, 26, 26, 26,
84588 /* 280 */ 26, 27, 27, 28, 28, 28, 29, 216, 304, 347,
84589 /* 290 */ 221, 313, 595, 191, 378, 331, 472, 234, 345, 381,
84590 /* 300 */ 324, 410, 220, 344, 592, 217, 213, 415, 112, 331,
84591 /* 310 */ 328, 4, 594, 399, 211, 554, 529, 446, 452, 435,
84592 /* 320 */ 79, 217, 553, 515, 328, 334, 513, 459, 459, 469,
84593 /* 330 */ 441, 572, 432, 435, 78, 23, 22, 308, 456, 457,
84594 /* 340 */ 453, 453, 25, 25, 24, 24, 24, 24, 436, 26,
84595 /* 350 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 216,
84596 /* 360 */ 304, 443, 443, 443, 156, 468, 218, 360, 363, 364,
84597 /* 370 */ 331, 247, 395, 398, 217, 349, 331, 30, 365, 32,
84598 /* 380 */ 134, 388, 282, 281, 39, 328, 41, 430, 545, 446,
84599 /* 390 */ 452, 328, 214, 531, 435, 93, 542, 601, 1, 404,
84600 /* 400 */ 435, 93, 413, 414, 495, 40, 536, 23, 22, 308,
84601 /* 410 */ 456, 457, 453, 453, 25, 25, 24, 24, 24, 24,
84602 /* 420 */ 573, 26, 26, 26, 26, 27, 27, 28, 28, 28,
84603 /* 430 */ 29, 216, 304, 276, 331, 179, 508, 490, 210, 547,
84604 /* 440 */ 319, 413, 414, 222, 192, 385, 320, 240, 415, 328,
84605 /* 450 */ 557, 63, 413, 414, 415, 616, 408, 405, 435, 71,
84606 /* 460 */ 415, 446, 452, 611, 572, 28, 28, 28, 29, 216,
84607 /* 470 */ 416, 417, 436, 336, 463, 464, 401, 43, 436, 23,
84608 /* 480 */ 22, 308, 456, 457, 453, 453, 25, 25, 24, 24,
84609 /* 490 */ 24, 24, 495, 26, 26, 26, 26, 27, 27, 28,
84610 /* 500 */ 28, 28, 29, 216, 304, 612, 209, 135, 511, 416,
84611 /* 510 */ 417, 431, 233, 64, 388, 282, 281, 439, 66, 542,
84612 /* 520 */ 416, 417, 413, 414, 156, 214, 403, 360, 363, 364,
84613 /* 530 */ 547, 252, 490, 446, 452, 491, 217, 8, 365, 495,
84614 /* 540 */ 436, 606, 63, 537, 299, 415, 492, 470, 546, 200,
84615 /* 550 */ 196, 23, 22, 308, 456, 457, 453, 453, 25, 25,
84616 /* 560 */ 24, 24, 24, 24, 386, 26, 26, 26, 26, 27,
84617 /* 570 */ 27, 28, 28, 28, 29, 216, 304, 477, 254, 354,
84618 /* 580 */ 528, 60, 517, 518, 436, 439, 389, 331, 356, 7,
84619 /* 590 */ 416, 417, 331, 478, 328, 208, 197, 137, 460, 499,
84620 /* 600 */ 447, 448, 328, 435, 9, 446, 452, 328, 479, 485,
84621 /* 610 */ 519, 435, 72, 567, 415, 434, 435, 67, 486, 433,
84622 /* 620 */ 520, 450, 451, 23, 22, 308, 456, 457, 453, 453,
84623 /* 630 */ 25, 25, 24, 24, 24, 24, 331, 26, 26, 26,
84624 /* 640 */ 26, 27, 27, 28, 28, 28, 29, 216, 304, 331,
84625 /* 650 */ 449, 328, 268, 390, 461, 331, 65, 331, 368, 434,
84626 /* 660 */ 435, 76, 310, 433, 328, 150, 427, 439, 473, 331,
84627 /* 670 */ 328, 499, 328, 435, 97, 29, 216, 446, 452, 435,
84628 /* 680 */ 96, 435, 101, 353, 328, 372, 415, 334, 154, 459,
84629 /* 690 */ 459, 352, 569, 435, 99, 23, 22, 308, 456, 457,
84630 /* 700 */ 453, 453, 25, 25, 24, 24, 24, 24, 331, 26,
84631 /* 710 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 216,
84632 /* 720 */ 304, 331, 248, 328, 264, 56, 334, 331, 459, 459,
84633 /* 730 */ 861, 333, 435, 104, 376, 439, 328, 415, 331, 415,
84634 /* 740 */ 565, 331, 328, 306, 564, 435, 105, 185, 265, 446,
84635 /* 750 */ 452, 435, 126, 328, 570, 518, 328, 334, 377, 459,
84636 /* 760 */ 459, 314, 435, 128, 194, 435, 59, 23, 22, 308,
84637 /* 770 */ 456, 457, 453, 453, 25, 25, 24, 24, 24, 24,
84638 /* 780 */ 331, 26, 26, 26, 26, 27, 27, 28, 28, 28,
84639 /* 790 */ 29, 216, 304, 331, 136, 328, 242, 477, 436, 331,
84640 /* 800 */ 350, 331, 609, 303, 435, 102, 201, 137, 328, 415,
84641 /* 810 */ 454, 178, 331, 478, 328, 415, 328, 435, 77, 440,
84642 /* 820 */ 249, 446, 452, 435, 100, 435, 68, 328, 479, 465,
84643 /* 830 */ 341, 613, 931, 484, 931, 415, 435, 98, 467, 23,
84644 /* 840 */ 22, 308, 456, 457, 453, 453, 25, 25, 24, 24,
84645 /* 850 */ 24, 24, 331, 26, 26, 26, 26, 27, 27, 28,
84646 /* 860 */ 28, 28, 29, 216, 304, 331, 397, 328, 164, 264,
84647 /* 870 */ 205, 331, 264, 332, 610, 339, 435, 129, 407, 2,
84648 /* 880 */ 328, 322, 175, 331, 415, 214, 328, 415, 415, 435,
84649 /* 890 */ 130, 466, 466, 446, 452, 435, 131, 396, 328, 257,
84650 /* 900 */ 334, 487, 459, 459, 436, 154, 229, 435, 69, 315,
84651 /* 910 */ 258, 23, 33, 308, 456, 457, 453, 453, 25, 25,
84652 /* 920 */ 24, 24, 24, 24, 331, 26, 26, 26, 26, 27,
84653 /* 930 */ 27, 28, 28, 28, 29, 216, 304, 331, 497, 328,
84654 /* 940 */ 151, 264, 412, 331, 264, 470, 337, 200, 435, 80,
84655 /* 950 */ 250, 155, 328, 523, 524, 331, 415, 415, 328, 415,
84656 /* 960 */ 306, 435, 81, 533, 532, 446, 452, 435, 70, 47,
84657 /* 970 */ 328, 613, 930, 259, 930, 418, 419, 420, 316, 435,
84658 /* 980 */ 82, 317, 206, 539, 22, 308, 456, 457, 453, 453,
84659 /* 990 */ 25, 25, 24, 24, 24, 24, 331, 26, 26, 26,
84660 /* 1000 */ 26, 27, 27, 28, 28, 28, 29, 216, 304, 331,
84661 /* 1010 */ 209, 328, 529, 540, 610, 331, 436, 563, 375, 563,
84662 /* 1020 */ 435, 83, 362, 538, 328, 155, 541, 331, 499, 526,
84663 /* 1030 */ 328, 331, 575, 435, 84, 424, 543, 446, 452, 435,
84664 /* 1040 */ 86, 290, 328, 415, 436, 267, 328, 155, 394, 141,
84665 /* 1050 */ 415, 435, 87, 588, 411, 435, 88, 308, 456, 457,
84666 /* 1060 */ 453, 453, 25, 25, 24, 24, 24, 24, 386, 26,
84667 /* 1070 */ 26, 26, 26, 27, 27, 28, 28, 28, 29, 216,
84668 /* 1080 */ 35, 338, 286, 3, 331, 270, 331, 327, 414, 421,
84669 /* 1090 */ 382, 318, 276, 422, 325, 35, 338, 335, 3, 328,
84670 /* 1100 */ 423, 328, 327, 414, 142, 144, 276, 415, 435, 73,
84671 /* 1110 */ 435, 74, 335, 331, 6, 340, 425, 331, 326, 331,
84672 /* 1120 */ 367, 415, 155, 437, 289, 472, 287, 274, 328, 272,
84673 /* 1130 */ 340, 415, 328, 47, 328, 277, 276, 435, 89, 348,
84674 /* 1140 */ 472, 435, 90, 435, 91, 38, 37, 243, 331, 582,
84675 /* 1150 */ 244, 415, 426, 276, 36, 329, 330, 46, 245, 441,
84676 /* 1160 */ 38, 37, 505, 328, 202, 203, 204, 415, 415, 36,
84677 /* 1170 */ 329, 330, 435, 92, 441, 198, 568, 214, 155, 584,
84678 /* 1180 */ 235, 236, 237, 143, 239, 346, 133, 581, 438, 246,
84679 /* 1190 */ 443, 443, 443, 444, 445, 10, 585, 276, 20, 42,
84680 /* 1200 */ 172, 415, 294, 331, 288, 443, 443, 443, 444, 445,
84681 /* 1210 */ 10, 295, 415, 35, 338, 219, 3, 149, 328, 482,
84682 /* 1220 */ 327, 414, 331, 170, 276, 572, 48, 435, 75, 169,
84683 /* 1230 */ 335, 19, 171, 251, 442, 413, 414, 328, 331, 415,
84684 /* 1240 */ 586, 343, 276, 177, 351, 496, 435, 17, 340, 415,
84685 /* 1250 */ 481, 253, 255, 328, 276, 502, 415, 415, 472, 331,
84686 /* 1260 */ 503, 357, 435, 94, 576, 415, 151, 231, 312, 415,
84687 /* 1270 */ 577, 516, 54, 472, 328, 393, 291, 281, 38, 37,
84688 /* 1280 */ 494, 305, 521, 435, 95, 232, 214, 36, 329, 330,
84689 /* 1290 */ 526, 498, 441, 188, 189, 415, 500, 292, 522, 262,
84690 /* 1300 */ 530, 260, 263, 513, 549, 269, 415, 441, 589, 400,
84691 /* 1310 */ 54, 415, 525, 527, 415, 415, 271, 415, 273, 415,
84692 /* 1320 */ 415, 275, 280, 443, 443, 443, 444, 445, 10, 107,
84693 /* 1330 */ 380, 415, 383, 415, 384, 283, 415, 415, 443, 443,
84694 /* 1340 */ 443, 284, 285, 580, 300, 415, 591, 415, 293, 415,
84695 /* 1350 */ 415, 296, 297, 605, 226, 550, 415, 415, 415, 225,
84696 /* 1360 */ 608, 415, 302, 415, 551, 227, 415, 415, 415, 301,
84697 /* 1370 */ 544, 552, 369, 158, 373, 558, 159, 278, 371, 160,
84698 /* 1380 */ 51, 207, 560, 561, 161, 140, 379, 117, 571, 163,
84699 /* 1390 */ 391, 392, 181, 180, 321, 602, 578, 118, 119, 120,
84700 /* 1400 */ 121, 123, 55, 587, 58, 603, 604, 607, 62, 174,
84701 /* 1410 */ 103, 224, 111, 409, 238, 428, 199, 323, 657, 658,
84702 /* 1420 */ 659, 146, 147, 455, 458, 34, 474, 462, 471, 182,
84703 /* 1430 */ 195, 148, 475, 476, 480, 5, 12, 493, 44, 11,
84704 /* 1440 */ 106, 138, 509, 510, 501, 223, 49, 361, 108, 109,
84705 /* 1450 */ 152, 266, 50, 110, 157, 258, 370, 184, 559, 139,
84706 /* 1460 */ 151, 113, 279, 162, 115, 374, 15, 574, 116, 165,
84707 /* 1470 */ 52, 13, 366, 579, 53, 167, 168, 166, 583, 124,
84708 /* 1480 */ 114, 122, 562, 566, 14, 61, 599, 600, 125, 173,
84709 /* 1490 */ 298, 590, 187, 406, 941, 614, 941, 402,
 
84710 };
84711 static const YYCODETYPE yy_lookahead[] = {
84712 /* 0 */ 19, 142, 143, 144, 145, 24, 116, 26, 75, 76,
84713 /* 10 */ 77, 78, 25, 80, 81, 82, 83, 84, 85, 86,
84714 /* 20 */ 87, 88, 89, 90, 26, 27, 160, 26, 27, 48,
@@ -84433,290 +84722,289 @@
84722 /* 100 */ 19, 48, 49, 150, 174, 52, 119, 166, 110, 84,
84723 /* 110 */ 85, 86, 87, 88, 89, 90, 26, 27, 165, 66,
84724 /* 120 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
84725 /* 130 */ 77, 78, 186, 80, 81, 82, 83, 84, 85, 86,
84726 /* 140 */ 87, 88, 89, 90, 19, 90, 205, 95, 84, 85,
84727 /* 150 */ 186, 96, 97, 98, 99, 100, 101, 102, 94, 95,
84728 /* 160 */ 195, 97, 150, 222, 109, 224, 225, 26, 104, 105,
84729 /* 170 */ 217, 90, 120, 48, 49, 50, 86, 165, 97, 98,
84730 /* 180 */ 99, 100, 101, 102, 94, 95, 174, 175, 1, 2,
84731 /* 190 */ 109, 66, 67, 68, 69, 70, 71, 72, 73, 74,
84732 /* 200 */ 75, 76, 77, 78, 191, 80, 81, 82, 83, 84,
84733 /* 210 */ 85, 86, 87, 88, 89, 90, 19, 116, 35, 150,
84734 /* 220 */ 155, 24, 208, 150, 222, 150, 224, 225, 216, 128,
84735 /* 230 */ 161, 162, 150, 221, 165, 94, 23, 150, 165, 56,
84736 /* 240 */ 165, 197, 160, 170, 171, 48, 49, 165, 204, 174,
84737 /* 250 */ 175, 22, 165, 24, 185, 186, 174, 175, 169, 170,
84738 /* 260 */ 171, 174, 175, 66, 67, 68, 69, 70, 71, 72,
84739 /* 270 */ 73, 74, 75, 76, 77, 78, 194, 80, 81, 82,
84740 /* 280 */ 83, 84, 85, 86, 87, 88, 89, 90, 19, 214,
84741 /* 290 */ 215, 108, 150, 25, 229, 150, 64, 148, 216, 234,
84742 /* 300 */ 146, 147, 215, 221, 231, 232, 152, 165, 154, 150,
84743 /* 310 */ 165, 196, 170, 171, 160, 181, 182, 48, 49, 174,
84744 /* 320 */ 175, 232, 188, 165, 165, 112, 94, 114, 115, 166,
84745 /* 330 */ 98, 55, 174, 174, 175, 66, 67, 68, 69, 70,
84746 /* 340 */ 71, 72, 73, 74, 75, 76, 77, 78, 194, 80,
84747 /* 350 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
84748 /* 360 */ 19, 129, 130, 131, 96, 84, 85, 99, 100, 101,
84749 /* 370 */ 150, 226, 218, 231, 232, 216, 150, 222, 110, 224,
84750 /* 380 */ 225, 105, 106, 107, 135, 165, 137, 172, 173, 48,
84751 /* 390 */ 49, 165, 116, 183, 174, 175, 181, 242, 22, 245,
84752 /* 400 */ 174, 175, 26, 27, 166, 136, 183, 66, 67, 68,
84753 /* 410 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
84754 /* 420 */ 11, 80, 81, 82, 83, 84, 85, 86, 87, 88,
84755 /* 430 */ 89, 90, 19, 150, 150, 23, 23, 25, 160, 150,
84756 /* 440 */ 220, 26, 27, 205, 160, 150, 220, 158, 165, 165,
84757 /* 450 */ 161, 162, 26, 27, 165, 0, 1, 2, 174, 175,
84758 /* 460 */ 165, 48, 49, 23, 55, 86, 87, 88, 89, 90,
84759 /* 470 */ 94, 95, 194, 169, 170, 171, 193, 136, 194, 66,
84760 /* 480 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
84761 /* 490 */ 77, 78, 166, 80, 81, 82, 83, 84, 85, 86,
84762 /* 500 */ 87, 88, 89, 90, 19, 65, 160, 95, 23, 94,
84763 /* 510 */ 95, 173, 217, 22, 105, 106, 107, 26, 22, 181,
84764 /* 520 */ 94, 95, 26, 27, 96, 116, 243, 99, 100, 101,
84765 /* 530 */ 150, 205, 120, 48, 49, 120, 232, 22, 110, 166,
84766 /* 540 */ 194, 161, 162, 183, 163, 165, 120, 166, 167, 168,
84767 /* 550 */ 160, 66, 67, 68, 69, 70, 71, 72, 73, 74,
84768 /* 560 */ 75, 76, 77, 78, 218, 80, 81, 82, 83, 84,
84769 /* 570 */ 85, 86, 87, 88, 89, 90, 19, 12, 205, 150,
84770 /* 580 */ 23, 235, 190, 191, 194, 94, 240, 150, 86, 74,
84771 /* 590 */ 94, 95, 150, 28, 165, 236, 206, 207, 23, 150,
84772 /* 600 */ 48, 49, 165, 174, 175, 48, 49, 165, 43, 31,
84773 /* 610 */ 45, 174, 175, 21, 165, 113, 174, 175, 40, 117,
84774 /* 620 */ 55, 69, 70, 66, 67, 68, 69, 70, 71, 72,
84775 /* 630 */ 73, 74, 75, 76, 77, 78, 150, 80, 81, 82,
84776 /* 640 */ 83, 84, 85, 86, 87, 88, 89, 90, 19, 150,
84777 /* 650 */ 98, 165, 23, 61, 23, 150, 25, 150, 19, 113,
84778 /* 660 */ 174, 175, 213, 117, 165, 24, 153, 26, 23, 150,
84779 /* 670 */ 165, 150, 165, 174, 175, 89, 90, 48, 49, 174,
84780 /* 680 */ 175, 174, 175, 19, 165, 237, 165, 112, 49, 114,
84781 /* 690 */ 115, 27, 100, 174, 175, 66, 67, 68, 69, 70,
84782 /* 700 */ 71, 72, 73, 74, 75, 76, 77, 78, 150, 80,
84783 /* 710 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
84784 /* 720 */ 19, 150, 150, 165, 150, 24, 112, 150, 114, 115,
84785 /* 730 */ 138, 19, 174, 175, 213, 94, 165, 165, 150, 165,
84786 /* 740 */ 29, 150, 165, 104, 33, 174, 175, 196, 109, 48,
84787 /* 750 */ 49, 174, 175, 165, 190, 191, 165, 112, 47, 114,
84788 /* 760 */ 115, 187, 174, 175, 160, 174, 175, 66, 67, 68,
84789 /* 770 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
84790 /* 780 */ 150, 80, 81, 82, 83, 84, 85, 86, 87, 88,
84791 /* 790 */ 89, 90, 19, 150, 150, 165, 198, 12, 194, 150,
84792 /* 800 */ 150, 150, 248, 249, 174, 175, 206, 207, 165, 165,
84793 /* 810 */ 98, 23, 150, 28, 165, 165, 165, 174, 175, 166,
84794 /* 820 */ 150, 48, 49, 174, 175, 174, 175, 165, 43, 233,
84795 /* 830 */ 45, 22, 23, 177, 25, 165, 174, 175, 233, 66,
84796 /* 840 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
84797 /* 850 */ 77, 78, 150, 80, 81, 82, 83, 84, 85, 86,
84798 /* 860 */ 87, 88, 89, 90, 19, 150, 97, 165, 25, 150,
84799 /* 870 */ 160, 150, 150, 150, 65, 228, 174, 175, 144, 145,
84800 /* 880 */ 165, 246, 247, 150, 165, 116, 165, 165, 165, 174,
84801 /* 890 */ 175, 129, 130, 48, 49, 174, 175, 128, 165, 98,
84802 /* 900 */ 112, 177, 114, 115, 194, 49, 187, 174, 175, 187,
84803 /* 910 */ 109, 66, 67, 68, 69, 70, 71, 72, 73, 74,
84804 /* 920 */ 75, 76, 77, 78, 150, 80, 81, 82, 83, 84,
84805 /* 930 */ 85, 86, 87, 88, 89, 90, 19, 150, 23, 165,
84806 /* 940 */ 25, 150, 150, 150, 150, 166, 167, 168, 174, 175,
84807 /* 950 */ 209, 25, 165, 7, 8, 150, 165, 165, 165, 165,
84808 /* 960 */ 104, 174, 175, 97, 98, 48, 49, 174, 175, 126,
84809 /* 970 */ 165, 22, 23, 177, 25, 7, 8, 9, 187, 174,
84810 /* 980 */ 175, 187, 160, 177, 67, 68, 69, 70, 71, 72,
84811 /* 990 */ 73, 74, 75, 76, 77, 78, 150, 80, 81, 82,
84812 /* 1000 */ 83, 84, 85, 86, 87, 88, 89, 90, 19, 150,
84813 /* 1010 */ 160, 165, 182, 166, 65, 150, 194, 105, 106, 107,
84814 /* 1020 */ 174, 175, 178, 23, 165, 25, 177, 150, 150, 103,
84815 /* 1030 */ 165, 150, 199, 174, 175, 150, 166, 48, 49, 174,
84816 /* 1040 */ 175, 209, 165, 165, 194, 23, 165, 25, 209, 6,
84817 /* 1050 */ 165, 174, 175, 199, 149, 174, 175, 68, 69, 70,
84818 /* 1060 */ 71, 72, 73, 74, 75, 76, 77, 78, 218, 80,
84819 /* 1070 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
84820 /* 1080 */ 19, 20, 16, 22, 150, 16, 150, 26, 27, 149,
84821 /* 1090 */ 240, 213, 150, 149, 149, 19, 20, 36, 22, 165,
84822 /* 1100 */ 13, 165, 26, 27, 151, 151, 150, 165, 174, 175,
84823 /* 1110 */ 174, 175, 36, 150, 25, 54, 150, 150, 159, 150,
84824 /* 1120 */ 23, 165, 25, 194, 58, 64, 60, 58, 165, 60,
84825 /* 1130 */ 54, 165, 165, 126, 165, 193, 150, 174, 175, 123,
84826 /* 1140 */ 64, 174, 175, 174, 175, 84, 85, 199, 150, 193,
84827 /* 1150 */ 200, 165, 150, 150, 93, 94, 95, 124, 201, 98,
84828 /* 1160 */ 84, 85, 86, 165, 105, 106, 107, 165, 165, 93,
84829 /* 1170 */ 94, 95, 174, 175, 98, 5, 23, 116, 25, 193,
84830 /* 1180 */ 10, 11, 12, 13, 14, 122, 150, 17, 203, 202,
84831 /* 1190 */ 129, 130, 131, 132, 133, 134, 193, 150, 125, 135,
84832 /* 1200 */ 30, 165, 32, 150, 138, 129, 130, 131, 132, 133,
84833 /* 1210 */ 134, 41, 165, 19, 20, 227, 22, 118, 165, 157,
84834 /* 1220 */ 26, 27, 150, 53, 150, 55, 104, 174, 175, 59,
84835 /* 1230 */ 36, 22, 62, 210, 150, 26, 27, 165, 150, 165,
84836 /* 1240 */ 193, 150, 150, 157, 121, 211, 174, 175, 54, 165,
84837 /* 1250 */ 150, 210, 210, 165, 150, 211, 165, 165, 64, 150,
84838 /* 1260 */ 211, 104, 174, 175, 23, 165, 25, 193, 46, 165,
84839 /* 1270 */ 23, 176, 25, 64, 165, 105, 106, 107, 84, 85,
84840 /* 1280 */ 150, 111, 176, 174, 175, 193, 116, 93, 94, 95,
84841 /* 1290 */ 103, 150, 98, 84, 85, 165, 150, 193, 184, 150,
84842 /* 1300 */ 150, 176, 150, 94, 150, 150, 165, 98, 23, 139,
84843 /* 1310 */ 25, 165, 178, 176, 165, 165, 150, 165, 150, 165,
84844 /* 1320 */ 165, 150, 150, 129, 130, 131, 132, 133, 134, 22,
84845 /* 1330 */ 150, 165, 150, 165, 150, 150, 165, 165, 129, 130,
84846 /* 1340 */ 131, 150, 150, 150, 179, 165, 150, 165, 150, 165,
84847 /* 1350 */ 165, 150, 150, 150, 90, 176, 165, 165, 165, 230,
84848 /* 1360 */ 23, 165, 25, 165, 176, 230, 165, 165, 165, 179,
84849 /* 1370 */ 184, 176, 18, 156, 44, 157, 156, 238, 157, 156,
84850 /* 1380 */ 135, 157, 157, 239, 156, 66, 157, 22, 189, 189,
84851 /* 1390 */ 157, 18, 219, 219, 157, 39, 199, 192, 192, 192,
84852 /* 1400 */ 192, 189, 241, 199, 241, 157, 157, 37, 244, 247,
84853 /* 1410 */ 164, 180, 180, 1, 15, 23, 22, 250, 118, 118,
84854 /* 1420 */ 118, 118, 118, 98, 113, 22, 11, 23, 23, 22,
84855 /* 1430 */ 22, 25, 23, 23, 23, 34, 34, 120, 25, 25,
84856 /* 1440 */ 22, 118, 23, 23, 27, 50, 22, 50, 22, 22,
84857 /* 1450 */ 34, 23, 22, 22, 102, 109, 19, 24, 20, 38,
84858 /* 1460 */ 25, 104, 138, 104, 22, 42, 5, 1, 108, 127,
84859 /* 1470 */ 74, 22, 50, 1, 74, 16, 121, 119, 20, 108,
84860 /* 1480 */ 51, 119, 57, 51, 22, 16, 23, 23, 127, 15,
84861 /* 1490 */ 140, 128, 22, 3, 251, 4, 251, 63,
 
84862 };
84863 #define YY_SHIFT_USE_DFLT (-111)
84864 #define YY_SHIFT_MAX 406
84865 static const short yy_shift_ofst[] = {
84866 /* 0 */ 187, 1061, 1170, 1061, 1194, 1194, -2, 64, 64, -19,
84867 /* 10 */ 1194, 1194, 1194, 1194, 1194, 276, 1, 125, 1076, 1194,
84868 /* 20 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194,
84869 /* 30 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194,
84870 /* 40 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194,
84871 /* 50 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, -48,
84872 /* 60 */ 409, 1, 1, 141, 281, 281, -110, 53, 197, 269,
84873 /* 70 */ 341, 413, 485, 557, 629, 701, 773, 845, 773, 773,
84874 /* 80 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773,
84875 /* 90 */ 773, 773, 773, 773, 773, 773, 917, 989, 989, -67,
84876 /* 100 */ -67, -1, -1, 55, 25, 379, 1, 1, 1, 1,
84877 /* 110 */ 1, 639, 592, 1, 1, 1, 1, 1, 1, 1,
84878 /* 120 */ 1, 1, 1, 1, 1, 1, 586, 141, -17, -111,
84879 /* 130 */ -111, -111, 1209, 81, 376, 415, 426, 496, 90, 565,
84880 /* 140 */ 565, 1, 1, 1, 1, 1, 1, 1, 1, 1,
84881 /* 150 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
84882 /* 160 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
84883 /* 170 */ 1, 1, 1, 1, 809, 949, 455, 641, 641, 641,
84884 /* 180 */ 769, 101, -110, -110, -110, -111, -111, -111, 232, 232,
84885 /* 190 */ 268, 428, 213, 575, 645, 785, 788, 412, 968, 502,
84886 /* 200 */ 491, 52, 183, 183, 183, 614, 614, 711, 912, 614,
84887 /* 210 */ 614, 614, 614, 229, 546, -13, 141, 762, 762, 249,
84888 /* 220 */ 578, 578, 664, 578, 856, 578, 141, 578, 141, 926,
84889 /* 230 */ 843, 664, 664, 843, 1043, 1043, 1043, 1043, 1087, 1087,
84890 /* 240 */ 1089, -110, 1007, 1016, 1033, 1063, 1073, 1064, 1099, 1099,
84891 /* 250 */ 1122, 1123, 1122, 1123, 1122, 1123, 1157, 1157, 1222, 1157,
84892 /* 260 */ 1187, 1157, 1307, 1264, 1264, 1222, 1157, 1157, 1157, 1307,
84893 /* 270 */ 1354, 1099, 1354, 1099, 1354, 1099, 1099, 1330, 1245, 1354,
84894 /* 280 */ 1099, 1319, 1319, 1365, 1007, 1099, 1373, 1373, 1373, 1373,
84895 /* 290 */ 1007, 1319, 1365, 1099, 1356, 1356, 1099, 1099, 1370, -111,
84896 /* 300 */ -111, -111, -111, -111, 552, 1066, 1059, 1069, 712, 631,
84897 /* 310 */ 915, 801, 946, 866, 1000, 1022, 1097, 1153, 1241, 1247,
84898 /* 320 */ 1285, 515, 1337, 440, 1412, 1399, 1392, 1394, 1300, 1301,
84899 /* 330 */ 1302, 1303, 1304, 1325, 1311, 1403, 1404, 1405, 1407, 1415,
84900 /* 340 */ 1408, 1409, 1406, 1410, 1411, 1413, 1401, 1414, 1402, 1413,
84901 /* 350 */ 1317, 1418, 1416, 1417, 1323, 1419, 1420, 1421, 1395, 1424,
84902 /* 360 */ 1397, 1426, 1428, 1427, 1430, 1422, 1431, 1352, 1346, 1437,
84903 /* 370 */ 1438, 1433, 1357, 1423, 1425, 1429, 1435, 1432, 1324, 1359,
84904 /* 380 */ 1442, 1461, 1466, 1360, 1396, 1400, 1342, 1449, 1358, 1472,
84905 /* 390 */ 1459, 1355, 1458, 1362, 1371, 1361, 1462, 1363, 1463, 1464,
84906 /* 400 */ 1469, 1434, 1474, 1350, 1470, 1490, 1491,
84907 };
84908 #define YY_REDUCE_USE_DFLT (-180)
84909 #define YY_REDUCE_MAX 303
84910 static const short yy_reduce_ofst[] = {
84911 /* 0 */ -141, 82, 154, 284, 12, 75, 69, 73, 142, -59,
84912 /* 10 */ 145, 87, 159, 220, 226, 346, 289, 155, 429, 437,
84913 /* 20 */ 442, 486, 499, 505, 507, 519, 558, 571, 577, 588,
84914 /* 30 */ 591, 630, 643, 649, 651, 662, 702, 715, 721, 733,
84915 /* 40 */ 774, 787, 793, 805, 846, 859, 865, 877, 881, 934,
84916 /* 50 */ 936, 963, 967, 969, 998, 1053, 1072, 1088, 1109, -179,
84917 /* 60 */ 850, 283, 380, 381, 89, 304, 390, 2, 2, 2,
84918 /* 70 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
84919 /* 80 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
84920 /* 90 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
84921 /* 100 */ 2, 2, 2, 215, 2, 2, 449, 574, 719, 722,
84922 /* 110 */ 791, 134, 65, 942, 521, 794, -47, 878, 956, 986,
84923 /* 120 */ 1003, 1047, 1074, 1092, 295, 1104, 2, 779, 2, 2,
84924 /* 130 */ 2, 2, 158, 338, 572, 644, 650, 670, 723, 392,
84925 /* 140 */ 564, 792, 885, 966, 1002, 1036, 723, 1084, 1091, 1100,
84926 /* 150 */ 1130, 1141, 1146, 1149, 1150, 1152, 1154, 1155, 1166, 1168,
84927 /* 160 */ 1171, 1172, 1180, 1182, 1184, 1185, 1191, 1192, 1193, 1196,
84928 /* 170 */ 1198, 1201, 1202, 1203, 554, 554, 734, 238, 326, 373,
84929 /* 180 */ -134, 278, 604, 710, 822, 44, 600, 635, -98, -70,
84930 /* 190 */ -54, -36, -35, -35, -35, 13, -35, 14, 149, 115,
84931 /* 200 */ 163, 14, 210, 223, 360, -35, -35, 359, 448, -35,
84932 /* 210 */ -35, -35, -35, 513, 551, 598, 653, 596, 605, 647,
84933 /* 220 */ 656, 724, 741, 796, 830, 806, 847, 849, 870, 844,
84934 /* 230 */ 833, 832, 839, 854, 905, 940, 944, 945, 953, 954,
84935 /* 240 */ 959, 929, 948, 950, 957, 987, 985, 988, 1062, 1086,
84936 /* 250 */ 1023, 1034, 1041, 1044, 1042, 1049, 1095, 1106, 1114, 1125,
84937 /* 260 */ 1134, 1137, 1165, 1129, 1135, 1186, 1179, 1188, 1195, 1190,
84938 /* 270 */ 1217, 1218, 1220, 1221, 1223, 1224, 1225, 1139, 1144, 1228,
84939 /* 280 */ 1229, 1199, 1200, 1173, 1197, 1233, 1205, 1206, 1207, 1208,
84940 /* 290 */ 1204, 1212, 1174, 1237, 1161, 1163, 1248, 1249, 1164, 1246,
84941 /* 300 */ 1231, 1232, 1162, 1167,
84942 };
84943 static const YYACTIONTYPE yy_default[] = {
84944 /* 0 */ 621, 856, 939, 939, 856, 939, 939, 885, 885, 744,
84945 /* 10 */ 854, 939, 939, 939, 939, 939, 939, 914, 939, 939,
84946 /* 20 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84947 /* 30 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84948 /* 40 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84949 /* 50 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 828,
84950 /* 60 */ 939, 939, 939, 660, 885, 885, 748, 779, 939, 939,
84951 /* 70 */ 939, 939, 939, 939, 939, 939, 780, 939, 858, 853,
84952 /* 80 */ 849, 851, 850, 857, 781, 770, 777, 784, 759, 898,
84953 /* 90 */ 786, 787, 793, 794, 915, 913, 816, 815, 834, 818,
84954 /* 100 */ 840, 817, 827, 652, 819, 820, 939, 939, 939, 939,
84955 /* 110 */ 939, 713, 647, 939, 939, 939, 939, 939, 939, 939,
84956 /* 120 */ 939, 939, 939, 939, 939, 939, 821, 939, 822, 835,
84957 /* 130 */ 836, 837, 939, 939, 939, 939, 939, 939, 939, 939,
84958 /* 140 */ 939, 627, 939, 939, 939, 939, 939, 939, 939, 939,
84959 /* 150 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84960 /* 160 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 869,
84961 /* 170 */ 939, 918, 920, 939, 939, 939, 621, 744, 744, 744,
84962 /* 180 */ 939, 939, 939, 939, 939, 738, 748, 932, 939, 939,
84963 /* 190 */ 704, 939, 939, 939, 939, 939, 939, 939, 629, 736,
84964 /* 200 */ 662, 746, 939, 939, 939, 649, 725, 891, 939, 905,
84965 /* 210 */ 903, 727, 789, 939, 736, 745, 939, 939, 939, 852,
84966 /* 220 */ 773, 773, 761, 773, 683, 773, 939, 773, 939, 686,
84967 /* 230 */ 783, 761, 761, 783, 626, 626, 626, 626, 637, 637,
84968 /* 240 */ 703, 939, 783, 774, 776, 766, 778, 939, 752, 752,
84969 /* 250 */ 760, 765, 760, 765, 760, 765, 715, 715, 700, 715,
84970 /* 260 */ 686, 715, 862, 866, 866, 700, 715, 715, 715, 862,
84971 /* 270 */ 644, 752, 644, 752, 644, 752, 752, 895, 897, 644,
84972 /* 280 */ 752, 717, 717, 795, 783, 752, 724, 724, 724, 724,
84973 /* 290 */ 783, 717, 795, 752, 917, 917, 752, 752, 925, 670,
84974 /* 300 */ 688, 688, 932, 937, 939, 939, 939, 939, 939, 939,
84975 /* 310 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84976 /* 320 */ 939, 871, 939, 939, 939, 635, 939, 654, 802, 807,
84977 /* 330 */ 803, 939, 804, 939, 730, 939, 939, 939, 939, 939,
84978 /* 340 */ 939, 939, 939, 939, 939, 855, 939, 767, 939, 775,
84979 /* 350 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84980 /* 360 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84981 /* 370 */ 939, 939, 939, 939, 939, 893, 894, 939, 939, 939,
84982 /* 380 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84983 /* 390 */ 939, 939, 939, 939, 939, 939, 939, 939, 939, 939,
84984 /* 400 */ 939, 924, 939, 939, 927, 622, 939, 617, 619, 620,
84985 /* 410 */ 624, 625, 628, 654, 655, 657, 658, 659, 630, 631,
84986 /* 420 */ 632, 633, 634, 636, 640, 638, 639, 641, 648, 650,
84987 /* 430 */ 669, 671, 673, 734, 735, 799, 728, 729, 733, 656,
84988 /* 440 */ 810, 801, 805, 806, 808, 809, 823, 824, 826, 832,
84989 /* 450 */ 839, 842, 825, 830, 831, 833, 838, 841, 731, 732,
84990 /* 460 */ 845, 663, 664, 667, 668, 881, 883, 882, 884, 666,
84991 /* 470 */ 665, 811, 814, 847, 848, 906, 907, 908, 909, 910,
84992 /* 480 */ 843, 753, 846, 829, 768, 771, 772, 769, 737, 747,
84993 /* 490 */ 755, 756, 757, 758, 742, 743, 749, 764, 797, 798,
84994 /* 500 */ 762, 763, 750, 751, 739, 740, 741, 844, 800, 812,
84995 /* 510 */ 813, 674, 675, 807, 676, 677, 678, 716, 719, 720,
84996 /* 520 */ 721, 679, 698, 701, 702, 680, 687, 681, 682, 689,
84997 /* 530 */ 690, 691, 694, 695, 696, 697, 692, 693, 863, 864,
84998 /* 540 */ 867, 865, 684, 685, 699, 672, 661, 653, 705, 708,
84999 /* 550 */ 709, 710, 711, 712, 714, 706, 707, 651, 642, 645,
85000 /* 560 */ 754, 887, 896, 892, 888, 889, 890, 646, 859, 860,
85001 /* 570 */ 718, 791, 792, 886, 899, 901, 796, 902, 904, 900,
85002 /* 580 */ 929, 643, 722, 723, 726, 868, 911, 782, 785, 788,
85003 /* 590 */ 790, 870, 872, 874, 876, 877, 878, 879, 880, 873,
85004 /* 600 */ 875, 912, 916, 919, 921, 922, 923, 926, 928, 933,
85005 /* 610 */ 934, 935, 938, 936, 623, 618,
85006 };
85007 #define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))
85008
85009 /* The next table maps tokens into fallback tokens. If a construct
85010 ** like the following:
@@ -85271,76 +85559,78 @@
85559 /* 250 */ "collate ::=",
85560 /* 251 */ "collate ::= COLLATE ids",
85561 /* 252 */ "cmd ::= DROP INDEX ifexists fullname",
85562 /* 253 */ "cmd ::= VACUUM",
85563 /* 254 */ "cmd ::= VACUUM nm",
85564 /* 255 */ "cmd ::= PRAGMA nm dbnm",
85565 /* 256 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
85566 /* 257 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
85567 /* 258 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
85568 /* 259 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
85569 /* 260 */ "nmnum ::= plus_num",
85570 /* 261 */ "nmnum ::= nm",
85571 /* 262 */ "nmnum ::= ON",
85572 /* 263 */ "nmnum ::= DELETE",
85573 /* 264 */ "nmnum ::= DEFAULT",
85574 /* 265 */ "plus_num ::= plus_opt number",
85575 /* 266 */ "minus_num ::= MINUS number",
85576 /* 267 */ "number ::= INTEGER|FLOAT",
85577 /* 268 */ "plus_opt ::= PLUS",
85578 /* 269 */ "plus_opt ::=",
85579 /* 270 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
85580 /* 271 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
85581 /* 272 */ "trigger_time ::= BEFORE",
85582 /* 273 */ "trigger_time ::= AFTER",
85583 /* 274 */ "trigger_time ::= INSTEAD OF",
85584 /* 275 */ "trigger_time ::=",
85585 /* 276 */ "trigger_event ::= DELETE|INSERT",
85586 /* 277 */ "trigger_event ::= UPDATE",
85587 /* 278 */ "trigger_event ::= UPDATE OF inscollist",
85588 /* 279 */ "foreach_clause ::=",
85589 /* 280 */ "foreach_clause ::= FOR EACH ROW",
85590 /* 281 */ "when_clause ::=",
85591 /* 282 */ "when_clause ::= WHEN expr",
85592 /* 283 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
85593 /* 284 */ "trigger_cmd_list ::= trigger_cmd SEMI",
85594 /* 285 */ "trigger_cmd ::= UPDATE orconf nm SET setlist where_opt",
85595 /* 286 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP",
85596 /* 287 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt select",
85597 /* 288 */ "trigger_cmd ::= DELETE FROM nm where_opt",
85598 /* 289 */ "trigger_cmd ::= select",
85599 /* 290 */ "expr ::= RAISE LP IGNORE RP",
85600 /* 291 */ "expr ::= RAISE LP raisetype COMMA nm RP",
85601 /* 292 */ "raisetype ::= ROLLBACK",
85602 /* 293 */ "raisetype ::= ABORT",
85603 /* 294 */ "raisetype ::= FAIL",
85604 /* 295 */ "cmd ::= DROP TRIGGER ifexists fullname",
85605 /* 296 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
85606 /* 297 */ "cmd ::= DETACH database_kw_opt expr",
85607 /* 298 */ "key_opt ::=",
85608 /* 299 */ "key_opt ::= KEY expr",
85609 /* 300 */ "database_kw_opt ::= DATABASE",
85610 /* 301 */ "database_kw_opt ::=",
85611 /* 302 */ "cmd ::= REINDEX",
85612 /* 303 */ "cmd ::= REINDEX nm dbnm",
85613 /* 304 */ "cmd ::= ANALYZE",
85614 /* 305 */ "cmd ::= ANALYZE nm dbnm",
85615 /* 306 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
85616 /* 307 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
85617 /* 308 */ "add_column_fullname ::= fullname",
85618 /* 309 */ "kwcolumn_opt ::=",
85619 /* 310 */ "kwcolumn_opt ::= COLUMNKW",
85620 /* 311 */ "cmd ::= create_vtab",
85621 /* 312 */ "cmd ::= create_vtab LP vtabarglist RP",
85622 /* 313 */ "create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm",
85623 /* 314 */ "vtabarglist ::= vtabarg",
85624 /* 315 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
85625 /* 316 */ "vtabarg ::=",
85626 /* 317 */ "vtabarg ::= vtabarg vtabargtoken",
85627 /* 318 */ "vtabargtoken ::= ANY",
85628 /* 319 */ "vtabargtoken ::= lp anylist RP",
85629 /* 320 */ "lp ::= LP",
85630 /* 321 */ "anylist ::=",
85631 /* 322 */ "anylist ::= anylist ANY",
85632 };
85633 #endif /* NDEBUG */
85634
85635
85636 #if YYSTACKDEPTH<=0
@@ -85963,16 +86253,18 @@
86253 { 230, 0 },
86254 { 230, 2 },
86255 { 147, 4 },
86256 { 147, 1 },
86257 { 147, 2 },
86258 { 147, 3 },
86259 { 147, 5 },
86260 { 147, 6 },
86261 { 147, 5 },
86262 { 147, 6 },
86263 { 231, 1 },
86264 { 231, 1 },
86265 { 231, 1 },
86266 { 231, 1 },
86267 { 231, 1 },
86268 { 170, 2 },
86269 { 171, 2 },
86270 { 233, 1 },
@@ -86108,22 +86400,22 @@
86400 case 62: /* ccons ::= NULL onconf */
86401 case 89: /* conslist ::= conslist COMMA tcons */
86402 case 90: /* conslist ::= conslist tcons */
86403 case 91: /* conslist ::= tcons */
86404 case 92: /* tcons ::= CONSTRAINT nm */
86405 case 268: /* plus_opt ::= PLUS */
86406 case 269: /* plus_opt ::= */
86407 case 279: /* foreach_clause ::= */
86408 case 280: /* foreach_clause ::= FOR EACH ROW */
86409 case 300: /* database_kw_opt ::= DATABASE */
86410 case 301: /* database_kw_opt ::= */
86411 case 309: /* kwcolumn_opt ::= */
86412 case 310: /* kwcolumn_opt ::= COLUMNKW */
86413 case 314: /* vtabarglist ::= vtabarg */
86414 case 315: /* vtabarglist ::= vtabarglist COMMA vtabarg */
86415 case 317: /* vtabarg ::= vtabarg vtabargtoken */
86416 case 321: /* anylist ::= */
86417 {
86418 }
86419 break;
86420 case 5: /* explain ::= */
86421 { sqlite3BeginParse(pParse, 0); }
@@ -86240,15 +86532,18 @@
86532 case 126: /* as ::= AS nm */
86533 case 127: /* as ::= ids */
86534 case 137: /* dbnm ::= DOT nm */
86535 case 146: /* indexed_opt ::= INDEXED BY nm */
86536 case 251: /* collate ::= COLLATE ids */
86537 case 260: /* nmnum ::= plus_num */
86538 case 261: /* nmnum ::= nm */
86539 case 262: /* nmnum ::= ON */
86540 case 263: /* nmnum ::= DELETE */
86541 case 264: /* nmnum ::= DEFAULT */
86542 case 265: /* plus_num ::= plus_opt number */
86543 case 266: /* minus_num ::= MINUS number */
86544 case 267: /* number ::= INTEGER|FLOAT */
86545 {yygotominor.yy0 = yymsp[0].minor.yy0;}
86546 break;
86547 case 45: /* type ::= typetoken */
86548 {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);}
86549 break;
@@ -86888,11 +87183,11 @@
87183 sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy148, yymsp[-9].minor.yy194,
87184 &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy194);
87185 }
87186 break;
87187 case 244: /* uniqueflag ::= UNIQUE */
87188 case 293: /* raisetype ::= ABORT */
87189 {yygotominor.yy194 = OE_Abort;}
87190 break;
87191 case 245: /* uniqueflag ::= */
87192 {yygotominor.yy194 = OE_None;}
87193 break;
@@ -86928,66 +87223,65 @@
87223 break;
87224 case 253: /* cmd ::= VACUUM */
87225 case 254: /* cmd ::= VACUUM nm */
87226 {sqlite3Vacuum(pParse);}
87227 break;
87228 case 255: /* cmd ::= PRAGMA nm dbnm */
87229 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
87230 break;
87231 case 256: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
87232 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
87233 break;
87234 case 257: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
 
 
 
 
 
87235 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
87236 break;
87237 case 258: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
87238 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
87239 break;
87240 case 259: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
87241 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
87242 break;
87243 case 270: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
87244 {
87245 Token all;
87246 all.z = yymsp[-3].minor.yy0.z;
87247 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
87248 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
87249 }
87250 break;
87251 case 271: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
87252 {
87253 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
87254 yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
87255 }
87256 break;
87257 case 272: /* trigger_time ::= BEFORE */
87258 case 275: /* trigger_time ::= */
87259 { yygotominor.yy194 = TK_BEFORE; }
87260 break;
87261 case 273: /* trigger_time ::= AFTER */
87262 { yygotominor.yy194 = TK_AFTER; }
87263 break;
87264 case 274: /* trigger_time ::= INSTEAD OF */
87265 { yygotominor.yy194 = TK_INSTEAD;}
87266 break;
87267 case 276: /* trigger_event ::= DELETE|INSERT */
87268 case 277: /* trigger_event ::= UPDATE */
87269 {yygotominor.yy332.a = yymsp[0].major; yygotominor.yy332.b = 0;}
87270 break;
87271 case 278: /* trigger_event ::= UPDATE OF inscollist */
87272 {yygotominor.yy332.a = TK_UPDATE; yygotominor.yy332.b = yymsp[0].minor.yy254;}
87273 break;
87274 case 281: /* when_clause ::= */
87275 case 298: /* key_opt ::= */
87276 { yygotominor.yy72 = 0; }
87277 break;
87278 case 282: /* when_clause ::= WHEN expr */
87279 case 299: /* key_opt ::= KEY expr */
87280 { yygotominor.yy72 = yymsp[0].minor.yy72; }
87281 break;
87282 case 283: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
87283 {
87284 /*
87285 if( yymsp[-2].minor.yy145 ){
87286 yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
87287 }else{
@@ -86998,118 +87292,118 @@
87292 yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
87293 yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
87294 yygotominor.yy145 = yymsp[-2].minor.yy145;
87295 }
87296 break;
87297 case 284: /* trigger_cmd_list ::= trigger_cmd SEMI */
87298 {
87299 /* if( yymsp[-1].minor.yy145 ) */
87300 assert( yymsp[-1].minor.yy145!=0 );
87301 yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
87302 yygotominor.yy145 = yymsp[-1].minor.yy145;
87303 }
87304 break;
87305 case 285: /* trigger_cmd ::= UPDATE orconf nm SET setlist where_opt */
87306 { yygotominor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-4].minor.yy194); }
87307 break;
87308 case 286: /* trigger_cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP */
87309 {yygotominor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy254, yymsp[-1].minor.yy148, 0, yymsp[-7].minor.yy194);}
87310 break;
87311 case 287: /* trigger_cmd ::= insert_cmd INTO nm inscollist_opt select */
87312 {yygotominor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, 0, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);}
87313 break;
87314 case 288: /* trigger_cmd ::= DELETE FROM nm where_opt */
87315 {yygotominor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-1].minor.yy0, yymsp[0].minor.yy72);}
87316 break;
87317 case 289: /* trigger_cmd ::= select */
87318 {yygotominor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); }
87319 break;
87320 case 290: /* expr ::= RAISE LP IGNORE RP */
87321 {
87322 yygotominor.yy72 = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
87323 if( yygotominor.yy72 ){
87324 yygotominor.yy72->affinity = OE_Ignore;
87325 sqlite3ExprSpan(yygotominor.yy72, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0);
87326 }
87327 }
87328 break;
87329 case 291: /* expr ::= RAISE LP raisetype COMMA nm RP */
87330 {
87331 yygotominor.yy72 = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
87332 if( yygotominor.yy72 ) {
87333 yygotominor.yy72->affinity = (char)yymsp[-3].minor.yy194;
87334 sqlite3ExprSpan(yygotominor.yy72, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0);
87335 }
87336 }
87337 break;
87338 case 292: /* raisetype ::= ROLLBACK */
87339 {yygotominor.yy194 = OE_Rollback;}
87340 break;
87341 case 294: /* raisetype ::= FAIL */
87342 {yygotominor.yy194 = OE_Fail;}
87343 break;
87344 case 295: /* cmd ::= DROP TRIGGER ifexists fullname */
87345 {
87346 sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
87347 }
87348 break;
87349 case 296: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
87350 {
87351 sqlite3Attach(pParse, yymsp[-3].minor.yy72, yymsp[-1].minor.yy72, yymsp[0].minor.yy72);
87352 }
87353 break;
87354 case 297: /* cmd ::= DETACH database_kw_opt expr */
87355 {
87356 sqlite3Detach(pParse, yymsp[0].minor.yy72);
87357 }
87358 break;
87359 case 302: /* cmd ::= REINDEX */
87360 {sqlite3Reindex(pParse, 0, 0);}
87361 break;
87362 case 303: /* cmd ::= REINDEX nm dbnm */
87363 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
87364 break;
87365 case 304: /* cmd ::= ANALYZE */
87366 {sqlite3Analyze(pParse, 0, 0);}
87367 break;
87368 case 305: /* cmd ::= ANALYZE nm dbnm */
87369 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
87370 break;
87371 case 306: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
87372 {
87373 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
87374 }
87375 break;
87376 case 307: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
87377 {
87378 sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0);
87379 }
87380 break;
87381 case 308: /* add_column_fullname ::= fullname */
87382 {
87383 pParse->db->lookaside.bEnabled = 0;
87384 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
87385 }
87386 break;
87387 case 311: /* cmd ::= create_vtab */
87388 {sqlite3VtabFinishParse(pParse,0);}
87389 break;
87390 case 312: /* cmd ::= create_vtab LP vtabarglist RP */
87391 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
87392 break;
87393 case 313: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */
87394 {
87395 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
87396 }
87397 break;
87398 case 316: /* vtabarg ::= */
87399 {sqlite3VtabArgInit(pParse);}
87400 break;
87401 case 318: /* vtabargtoken ::= ANY */
87402 case 319: /* vtabargtoken ::= lp anylist RP */
87403 case 320: /* lp ::= LP */
87404 case 322: /* anylist ::= anylist ANY */
87405 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
87406 break;
87407 };
87408 yygoto = yyRuleInfo[yyruleno].lhs;
87409 yysize = yyRuleInfo[yyruleno].nrhs;
@@ -88437,11 +88731,11 @@
88731 ** Main file for the SQLite library. The routines in this file
88732 ** implement the programmer interface to the library. Routines in
88733 ** other files are for internal use by SQLite and should not be
88734 ** accessed by users of the library.
88735 **
88736 ** $Id: main.c,v 1.536 2009/04/09 01:23:49 drh Exp $
88737 */
88738
88739 #ifdef SQLITE_ENABLE_FTS3
88740 /************** Include fts3.h in the middle of main.c ***********************/
88741 /************** Begin file fts3.h ********************************************/
@@ -88729,10 +89023,11 @@
89023 sqlite3GlobalConfig.isMallocInit = 0;
89024 sqlite3PcacheShutdown();
89025 if( sqlite3GlobalConfig.isInit ){
89026 sqlite3_os_end();
89027 }
89028 sqlite3_reset_auto_extension();
89029 sqlite3MallocEnd();
89030 sqlite3MutexEnd();
89031 sqlite3GlobalConfig.isInit = 0;
89032 return SQLITE_OK;
89033 }
@@ -88928,11 +89223,11 @@
89223 db->lookaside.pFree = 0;
89224 db->lookaside.sz = (u16)sz;
89225 if( pStart ){
89226 int i;
89227 LookasideSlot *p;
89228 assert( sz > (int)sizeof(LookasideSlot*) );
89229 p = (LookasideSlot*)pStart;
89230 for(i=cnt-1; i>=0; i--){
89231 p->pNext = db->lookaside.pFree;
89232 db->lookaside.pFree = p;
89233 p = (LookasideSlot*)&((u8*)p)[sz];
@@ -90705,11 +91000,11 @@
91000 *************************************************************************
91001 **
91002 ** This file contains the implementation of the sqlite3_unlock_notify()
91003 ** API method and its associated functionality.
91004 **
91005 ** $Id: notify.c,v 1.4 2009/04/07 22:06:57 drh Exp $
91006 */
91007
91008 /* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */
91009 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
91010
@@ -90802,26 +91097,44 @@
91097 }
91098
91099 /*
91100 ** Obtain the STATIC_MASTER mutex.
91101 */
91102 static void enterMutex(void){
91103 sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
91104 checkListProperties(0);
91105 }
91106
91107 /*
91108 ** Release the STATIC_MASTER mutex.
91109 */
91110 static void leaveMutex(void){
91111 assertMutexHeld();
91112 checkListProperties(0);
91113 sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
91114 }
91115
91116 /*
91117 ** Register an unlock-notify callback.
91118 **
91119 ** This is called after connection "db" has attempted some operation
91120 ** but has received an SQLITE_LOCKED error because another connection
91121 ** (call it pOther) in the same process was busy using the same shared
91122 ** cache. pOther is found by looking at db->pBlockingConnection.
91123 **
91124 ** If there is no blocking connection, the callback is invoked immediately,
91125 ** before this routine returns.
91126 **
91127 ** If pOther is already blocked on db, then report SQLITE_LOCKED, to indicate
91128 ** a deadlock.
91129 **
91130 ** Otherwise, make arrangements to invoke xNotify when pOther drops
91131 ** its locks.
91132 **
91133 ** Each call to this routine overrides any prior callbacks registered
91134 ** on the same "db". If xNotify==0 then any prior callbacks are immediately
91135 ** cancelled.
91136 */
91137 SQLITE_API int sqlite3_unlock_notify(
91138 sqlite3 *db,
91139 void (*xNotify)(void **, int),
91140 void *pArg
@@ -90829,20 +91142,25 @@
91142 int rc = SQLITE_OK;
91143
91144 sqlite3_mutex_enter(db->mutex);
91145 enterMutex();
91146
91147 if( xNotify==0 ){
91148 removeFromBlockedList(db);
91149 db->pUnlockConnection = 0;
91150 db->xUnlockNotify = 0;
91151 db->pUnlockArg = 0;
91152 }else if( 0==db->pBlockingConnection ){
91153 /* The blocking transaction has been concluded. Or there never was a
91154 ** blocking transaction. In either case, invoke the notify callback
91155 ** immediately.
91156 */
91157 xNotify(&pArg, 1);
91158 }else{
91159 sqlite3 *p;
91160
91161 for(p=db->pBlockingConnection; p && p!=db; p=p->pUnlockConnection){}
91162 if( p ){
91163 rc = SQLITE_LOCKED; /* Deadlock detected. */
91164 }else{
91165 db->pUnlockConnection = db->pBlockingConnection;
91166 db->xUnlockNotify = xNotify;
@@ -90873,11 +91191,12 @@
91191 db->pBlockingConnection = pBlocker;
91192 leaveMutex();
91193 }
91194
91195 /*
91196 ** This function is called when
91197 ** the transaction opened by database db has just finished. Locks held
91198 ** by database connection db have been released.
91199 **
91200 ** This function loops through each entry in the blocked connections
91201 ** list and does the following:
91202 **
@@ -90894,15 +91213,15 @@
91213 */
91214 SQLITE_PRIVATE void sqlite3ConnectionUnlocked(sqlite3 *db){
91215 void (*xUnlockNotify)(void **, int) = 0; /* Unlock-notify cb to invoke */
91216 int nArg = 0; /* Number of entries in aArg[] */
91217 sqlite3 **pp; /* Iterator variable */
91218 void **aArg; /* Arguments to the unlock callback */
91219 void **aDyn = 0; /* Dynamically allocated space for aArg[] */
91220 void *aStatic[16]; /* Starter space for aArg[]. No malloc required */
91221
91222 aArg = aStatic;
 
 
 
91223 enterMutex(); /* Enter STATIC_MASTER mutex */
91224
91225 /* This loop runs once for each entry in the blocked-connections list. */
91226 for(pp=&sqlite3BlockedList; *pp; /* no-op */ ){
91227 sqlite3 *p = *pp;
91228
+31 -15
--- 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.436 2009/03/20 13:15:30 drh Exp $
33
+** @(#) $Id: sqlite.h.in,v 1.440 2009/04/06 15:55:04 drh Exp $
3434
*/
3535
#ifndef _SQLITE3_H_
3636
#define _SQLITE3_H_
3737
#include <stdarg.h> /* Needed for the definition of va_list */
3838
@@ -97,12 +97,12 @@
9797
**
9898
** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()].
9999
**
100100
** Requirements: [H10011] [H10014]
101101
*/
102
-#define SQLITE_VERSION "3.6.12"
103
-#define SQLITE_VERSION_NUMBER 3006012
102
+#define SQLITE_VERSION "3.6.13"
103
+#define SQLITE_VERSION_NUMBER 3006013
104104
105105
/*
106106
** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
107107
** KEYWORDS: sqlite3_version
108108
**
@@ -380,11 +380,10 @@
380380
#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8))
381381
#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
382382
#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8))
383383
#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
384384
#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
385
-
386385
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) )
387386
388387
/*
389388
** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700>
390389
**
@@ -460,12 +459,13 @@
460459
** [sqlite3_io_methods] object it uses a combination of
461460
** these integer values as the second argument.
462461
**
463462
** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
464463
** sync operation only needs to flush data to mass storage. Inode
465
-** information need not be flushed. The SQLITE_SYNC_NORMAL flag means
466
-** to use normal fsync() semantics. The SQLITE_SYNC_FULL flag means
464
+** information need not be flushed. If the lower four bits of the flag
465
+** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.
466
+** If the lower four bits equal SQLITE_SYNC_FULL, that means
467467
** to use Mac OS X style fullsync instead of fsync().
468468
*/
469469
#define SQLITE_SYNC_NORMAL 0x00002
470470
#define SQLITE_SYNC_FULL 0x00003
471471
#define SQLITE_SYNC_DATAONLY 0x00010
@@ -2227,11 +2227,12 @@
22272227
**
22282228
** To execute an SQL query, it must first be compiled into a byte-code
22292229
** program using one of these routines.
22302230
**
22312231
** The first argument, "db", is a [database connection] obtained from a
2232
-** prior call to [sqlite3_open()], [sqlite3_open_v2()] or [sqlite3_open16()].
2232
+** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
2233
+** [sqlite3_open16()]. The database connection must not have been closed.
22332234
**
22342235
** The second argument, "zSql", is the statement to be compiled, encoded
22352236
** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
22362237
** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
22372238
** use UTF-16.
@@ -2244,21 +2245,22 @@
22442245
** that the supplied string is nul-terminated, then there is a small
22452246
** performance advantage to be gained by passing an nByte parameter that
22462247
** is equal to the number of bytes in the input string <i>including</i>
22472248
** the nul-terminator bytes.
22482249
**
2249
-** *pzTail is made to point to the first byte past the end of the
2250
-** first SQL statement in zSql. These routines only compile the first
2251
-** statement in zSql, so *pzTail is left pointing to what remains
2252
-** uncompiled.
2250
+** If pzTail is not NULL then *pzTail is made to point to the first byte
2251
+** past the end of the first SQL statement in zSql. These routines only
2252
+** compile the first statement in zSql, so *pzTail is left pointing to
2253
+** what remains uncompiled.
22532254
**
22542255
** *ppStmt is left pointing to a compiled [prepared statement] that can be
22552256
** executed using [sqlite3_step()]. If there is an error, *ppStmt is set
22562257
** to NULL. If the input text contains no SQL (if the input is an empty
22572258
** string or a comment) then *ppStmt is set to NULL.
2258
-** {A13018} The calling procedure is responsible for deleting the compiled
2259
+** The calling procedure is responsible for deleting the compiled
22592260
** SQL statement using [sqlite3_finalize()] after it has finished with it.
2261
+** ppStmt may not be NULL.
22602262
**
22612263
** On success, [SQLITE_OK] is returned, otherwise an [error code] is returned.
22622264
**
22632265
** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
22642266
** recommended for all new programs. The two older interfaces are retained
@@ -3628,14 +3630,28 @@
36283630
** the name of a folder (a.k.a. directory), then all temporary files
36293631
** created by SQLite will be placed in that directory. If this variable
36303632
** is a NULL pointer, then SQLite performs a search for an appropriate
36313633
** temporary file directory.
36323634
**
3633
-** It is not safe to modify this variable once a [database connection]
3634
-** has been opened. It is intended that this variable be set once
3635
+** It is not safe to read or modify this variable in more than one
3636
+** thread at a time. It is not safe to read or modify this variable
3637
+** if a [database connection] is being used at the same time in a separate
3638
+** thread.
3639
+** It is intended that this variable be set once
36353640
** as part of process initialization and before any SQLite interface
3636
-** routines have been call and remain unchanged thereafter.
3641
+** routines have been called and that this variable remain unchanged
3642
+** thereafter.
3643
+**
3644
+** The [temp_store_directory pragma] may modify this variable and cause
3645
+** it to point to memory obtained from [sqlite3_malloc]. Furthermore,
3646
+** the [temp_store_directory pragma] always assumes that any string
3647
+** that this variable points to is held in memory obtained from
3648
+** [sqlite3_malloc] and the pragma may attempt to free that memory
3649
+** using [sqlite3_free].
3650
+** Hence, if this variable is modified directly, either it should be
3651
+** made NULL or made to point to memory obtained from [sqlite3_malloc]
3652
+** or else the use of the [temp_store_directory pragma] should be avoided.
36373653
*/
36383654
SQLITE_EXTERN char *sqlite3_temp_directory;
36393655
36403656
/*
36413657
** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200>
36423658
--- 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.436 2009/03/20 13:15:30 drh Exp $
34 */
35 #ifndef _SQLITE3_H_
36 #define _SQLITE3_H_
37 #include <stdarg.h> /* Needed for the definition of va_list */
38
@@ -97,12 +97,12 @@
97 **
98 ** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()].
99 **
100 ** Requirements: [H10011] [H10014]
101 */
102 #define SQLITE_VERSION "3.6.12"
103 #define SQLITE_VERSION_NUMBER 3006012
104
105 /*
106 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
107 ** KEYWORDS: sqlite3_version
108 **
@@ -380,11 +380,10 @@
380 #define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8))
381 #define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
382 #define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8))
383 #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
384 #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
385
386 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) )
387
388 /*
389 ** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700>
390 **
@@ -460,12 +459,13 @@
460 ** [sqlite3_io_methods] object it uses a combination of
461 ** these integer values as the second argument.
462 **
463 ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
464 ** sync operation only needs to flush data to mass storage. Inode
465 ** information need not be flushed. The SQLITE_SYNC_NORMAL flag means
466 ** to use normal fsync() semantics. The SQLITE_SYNC_FULL flag means
 
467 ** to use Mac OS X style fullsync instead of fsync().
468 */
469 #define SQLITE_SYNC_NORMAL 0x00002
470 #define SQLITE_SYNC_FULL 0x00003
471 #define SQLITE_SYNC_DATAONLY 0x00010
@@ -2227,11 +2227,12 @@
2227 **
2228 ** To execute an SQL query, it must first be compiled into a byte-code
2229 ** program using one of these routines.
2230 **
2231 ** The first argument, "db", is a [database connection] obtained from a
2232 ** prior call to [sqlite3_open()], [sqlite3_open_v2()] or [sqlite3_open16()].
 
2233 **
2234 ** The second argument, "zSql", is the statement to be compiled, encoded
2235 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
2236 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
2237 ** use UTF-16.
@@ -2244,21 +2245,22 @@
2244 ** that the supplied string is nul-terminated, then there is a small
2245 ** performance advantage to be gained by passing an nByte parameter that
2246 ** is equal to the number of bytes in the input string <i>including</i>
2247 ** the nul-terminator bytes.
2248 **
2249 ** *pzTail is made to point to the first byte past the end of the
2250 ** first SQL statement in zSql. These routines only compile the first
2251 ** statement in zSql, so *pzTail is left pointing to what remains
2252 ** uncompiled.
2253 **
2254 ** *ppStmt is left pointing to a compiled [prepared statement] that can be
2255 ** executed using [sqlite3_step()]. If there is an error, *ppStmt is set
2256 ** to NULL. If the input text contains no SQL (if the input is an empty
2257 ** string or a comment) then *ppStmt is set to NULL.
2258 ** {A13018} The calling procedure is responsible for deleting the compiled
2259 ** SQL statement using [sqlite3_finalize()] after it has finished with it.
 
2260 **
2261 ** On success, [SQLITE_OK] is returned, otherwise an [error code] is returned.
2262 **
2263 ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
2264 ** recommended for all new programs. The two older interfaces are retained
@@ -3628,14 +3630,28 @@
3628 ** the name of a folder (a.k.a. directory), then all temporary files
3629 ** created by SQLite will be placed in that directory. If this variable
3630 ** is a NULL pointer, then SQLite performs a search for an appropriate
3631 ** temporary file directory.
3632 **
3633 ** It is not safe to modify this variable once a [database connection]
3634 ** has been opened. It is intended that this variable be set once
 
 
 
3635 ** as part of process initialization and before any SQLite interface
3636 ** routines have been call and remain unchanged thereafter.
 
 
 
 
 
 
 
 
 
 
 
3637 */
3638 SQLITE_EXTERN char *sqlite3_temp_directory;
3639
3640 /*
3641 ** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200>
3642
--- 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.440 2009/04/06 15:55:04 drh Exp $
34 */
35 #ifndef _SQLITE3_H_
36 #define _SQLITE3_H_
37 #include <stdarg.h> /* Needed for the definition of va_list */
38
@@ -97,12 +97,12 @@
97 **
98 ** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()].
99 **
100 ** Requirements: [H10011] [H10014]
101 */
102 #define SQLITE_VERSION "3.6.13"
103 #define SQLITE_VERSION_NUMBER 3006013
104
105 /*
106 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
107 ** KEYWORDS: sqlite3_version
108 **
@@ -380,11 +380,10 @@
380 #define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8))
381 #define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
382 #define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8))
383 #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
384 #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
 
385 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) )
386
387 /*
388 ** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700>
389 **
@@ -460,12 +459,13 @@
459 ** [sqlite3_io_methods] object it uses a combination of
460 ** these integer values as the second argument.
461 **
462 ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
463 ** sync operation only needs to flush data to mass storage. Inode
464 ** information need not be flushed. If the lower four bits of the flag
465 ** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.
466 ** If the lower four bits equal SQLITE_SYNC_FULL, that means
467 ** to use Mac OS X style fullsync instead of fsync().
468 */
469 #define SQLITE_SYNC_NORMAL 0x00002
470 #define SQLITE_SYNC_FULL 0x00003
471 #define SQLITE_SYNC_DATAONLY 0x00010
@@ -2227,11 +2227,12 @@
2227 **
2228 ** To execute an SQL query, it must first be compiled into a byte-code
2229 ** program using one of these routines.
2230 **
2231 ** The first argument, "db", is a [database connection] obtained from a
2232 ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
2233 ** [sqlite3_open16()]. The database connection must not have been closed.
2234 **
2235 ** The second argument, "zSql", is the statement to be compiled, encoded
2236 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
2237 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
2238 ** use UTF-16.
@@ -2244,21 +2245,22 @@
2245 ** that the supplied string is nul-terminated, then there is a small
2246 ** performance advantage to be gained by passing an nByte parameter that
2247 ** is equal to the number of bytes in the input string <i>including</i>
2248 ** the nul-terminator bytes.
2249 **
2250 ** If pzTail is not NULL then *pzTail is made to point to the first byte
2251 ** past the end of the first SQL statement in zSql. These routines only
2252 ** compile the first statement in zSql, so *pzTail is left pointing to
2253 ** what remains uncompiled.
2254 **
2255 ** *ppStmt is left pointing to a compiled [prepared statement] that can be
2256 ** executed using [sqlite3_step()]. If there is an error, *ppStmt is set
2257 ** to NULL. If the input text contains no SQL (if the input is an empty
2258 ** string or a comment) then *ppStmt is set to NULL.
2259 ** The calling procedure is responsible for deleting the compiled
2260 ** SQL statement using [sqlite3_finalize()] after it has finished with it.
2261 ** ppStmt may not be NULL.
2262 **
2263 ** On success, [SQLITE_OK] is returned, otherwise an [error code] is returned.
2264 **
2265 ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
2266 ** recommended for all new programs. The two older interfaces are retained
@@ -3628,14 +3630,28 @@
3630 ** the name of a folder (a.k.a. directory), then all temporary files
3631 ** created by SQLite will be placed in that directory. If this variable
3632 ** is a NULL pointer, then SQLite performs a search for an appropriate
3633 ** temporary file directory.
3634 **
3635 ** It is not safe to read or modify this variable in more than one
3636 ** thread at a time. It is not safe to read or modify this variable
3637 ** if a [database connection] is being used at the same time in a separate
3638 ** thread.
3639 ** It is intended that this variable be set once
3640 ** as part of process initialization and before any SQLite interface
3641 ** routines have been called and that this variable remain unchanged
3642 ** thereafter.
3643 **
3644 ** The [temp_store_directory pragma] may modify this variable and cause
3645 ** it to point to memory obtained from [sqlite3_malloc]. Furthermore,
3646 ** the [temp_store_directory pragma] always assumes that any string
3647 ** that this variable points to is held in memory obtained from
3648 ** [sqlite3_malloc] and the pragma may attempt to free that memory
3649 ** using [sqlite3_free].
3650 ** Hence, if this variable is modified directly, either it should be
3651 ** made NULL or made to point to memory obtained from [sqlite3_malloc]
3652 ** or else the use of the [temp_store_directory pragma] should be avoided.
3653 */
3654 SQLITE_EXTERN char *sqlite3_temp_directory;
3655
3656 /*
3657 ** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200>
3658

Keyboard Shortcuts

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