Fossil SCM
Update to version SQLite 3.6.13
Commit
879e8c5f32be016d3c9cd7fb3f98e787aa823424
Parent
a742cfa29254d81…
2 files changed
+1336
-1017
+31
-15
+1336
-1017
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | -** version 3.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 | |
| 4 | 4 | ** single large file, the entire code can be compiled as a one translation |
| 5 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | 7 | ** of 5% are more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| @@ -9,17 +9,17 @@ | ||
| 9 | 9 | ** |
| 10 | 10 | ** This file is all you need to compile SQLite. To use SQLite in other |
| 11 | 11 | ** programs, you need this file and the "sqlite3.h" header file that defines |
| 12 | 12 | ** the programming interface to the SQLite library. (If you do not have |
| 13 | 13 | ** the "sqlite3.h" header file at hand, you will find a copy in the first |
| 14 | -** 5487 lines past this header comment.) Additional code files may be | |
| 14 | +** 5503 lines past this header comment.) Additional code files may be | |
| 15 | 15 | ** needed if you want a wrapper to interface SQLite with your choice of |
| 16 | 16 | ** programming language. The code for the "sqlite3" command-line shell |
| 17 | 17 | ** is also in a separate file. This file contains only code for the core |
| 18 | 18 | ** SQLite library. |
| 19 | 19 | ** |
| 20 | -** This amalgamation was generated on 2009-03-31 12:19:59 UTC. | |
| 20 | +** This amalgamation was generated on 2009-04-13 09:47:15 UTC. | |
| 21 | 21 | */ |
| 22 | 22 | #define SQLITE_CORE 1 |
| 23 | 23 | #define SQLITE_AMALGAMATION 1 |
| 24 | 24 | #ifndef SQLITE_PRIVATE |
| 25 | 25 | # define SQLITE_PRIVATE static |
| @@ -39,11 +39,11 @@ | ||
| 39 | 39 | ** May you share freely, never taking more than you give. |
| 40 | 40 | ** |
| 41 | 41 | ************************************************************************* |
| 42 | 42 | ** Internal interface definitions for SQLite. |
| 43 | 43 | ** |
| 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 $ | |
| 45 | 45 | */ |
| 46 | 46 | #ifndef _SQLITEINT_H_ |
| 47 | 47 | #define _SQLITEINT_H_ |
| 48 | 48 | |
| 49 | 49 | /* |
| @@ -530,11 +530,11 @@ | ||
| 530 | 530 | ** The name of this file under configuration management is "sqlite.h.in". |
| 531 | 531 | ** The makefile makes some minor changes to this file (such as inserting |
| 532 | 532 | ** the version number) and changes its name to "sqlite3.h" as |
| 533 | 533 | ** part of the build process. |
| 534 | 534 | ** |
| 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 $ | |
| 536 | 536 | */ |
| 537 | 537 | #ifndef _SQLITE3_H_ |
| 538 | 538 | #define _SQLITE3_H_ |
| 539 | 539 | #include <stdarg.h> /* Needed for the definition of va_list */ |
| 540 | 540 | |
| @@ -599,12 +599,12 @@ | ||
| 599 | 599 | ** |
| 600 | 600 | ** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()]. |
| 601 | 601 | ** |
| 602 | 602 | ** Requirements: [H10011] [H10014] |
| 603 | 603 | */ |
| 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 | |
| 606 | 606 | |
| 607 | 607 | /* |
| 608 | 608 | ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100> |
| 609 | 609 | ** KEYWORDS: sqlite3_version |
| 610 | 610 | ** |
| @@ -882,11 +882,10 @@ | ||
| 882 | 882 | #define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8)) |
| 883 | 883 | #define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) |
| 884 | 884 | #define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8)) |
| 885 | 885 | #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) |
| 886 | 886 | #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) |
| 887 | - | |
| 888 | 887 | #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) ) |
| 889 | 888 | |
| 890 | 889 | /* |
| 891 | 890 | ** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700> |
| 892 | 891 | ** |
| @@ -962,12 +961,13 @@ | ||
| 962 | 961 | ** [sqlite3_io_methods] object it uses a combination of |
| 963 | 962 | ** these integer values as the second argument. |
| 964 | 963 | ** |
| 965 | 964 | ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the |
| 966 | 965 | ** 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 | |
| 969 | 969 | ** to use Mac OS X style fullsync instead of fsync(). |
| 970 | 970 | */ |
| 971 | 971 | #define SQLITE_SYNC_NORMAL 0x00002 |
| 972 | 972 | #define SQLITE_SYNC_FULL 0x00003 |
| 973 | 973 | #define SQLITE_SYNC_DATAONLY 0x00010 |
| @@ -2729,11 +2729,12 @@ | ||
| 2729 | 2729 | ** |
| 2730 | 2730 | ** To execute an SQL query, it must first be compiled into a byte-code |
| 2731 | 2731 | ** program using one of these routines. |
| 2732 | 2732 | ** |
| 2733 | 2733 | ** 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. | |
| 2735 | 2736 | ** |
| 2736 | 2737 | ** The second argument, "zSql", is the statement to be compiled, encoded |
| 2737 | 2738 | ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() |
| 2738 | 2739 | ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2() |
| 2739 | 2740 | ** use UTF-16. |
| @@ -2746,21 +2747,22 @@ | ||
| 2746 | 2747 | ** that the supplied string is nul-terminated, then there is a small |
| 2747 | 2748 | ** performance advantage to be gained by passing an nByte parameter that |
| 2748 | 2749 | ** is equal to the number of bytes in the input string <i>including</i> |
| 2749 | 2750 | ** the nul-terminator bytes. |
| 2750 | 2751 | ** |
| 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. | |
| 2755 | 2756 | ** |
| 2756 | 2757 | ** *ppStmt is left pointing to a compiled [prepared statement] that can be |
| 2757 | 2758 | ** executed using [sqlite3_step()]. If there is an error, *ppStmt is set |
| 2758 | 2759 | ** to NULL. If the input text contains no SQL (if the input is an empty |
| 2759 | 2760 | ** 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 | |
| 2761 | 2762 | ** SQL statement using [sqlite3_finalize()] after it has finished with it. |
| 2763 | +** ppStmt may not be NULL. | |
| 2762 | 2764 | ** |
| 2763 | 2765 | ** On success, [SQLITE_OK] is returned, otherwise an [error code] is returned. |
| 2764 | 2766 | ** |
| 2765 | 2767 | ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are |
| 2766 | 2768 | ** recommended for all new programs. The two older interfaces are retained |
| @@ -4130,14 +4132,28 @@ | ||
| 4130 | 4132 | ** the name of a folder (a.k.a. directory), then all temporary files |
| 4131 | 4133 | ** created by SQLite will be placed in that directory. If this variable |
| 4132 | 4134 | ** is a NULL pointer, then SQLite performs a search for an appropriate |
| 4133 | 4135 | ** temporary file directory. |
| 4134 | 4136 | ** |
| 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 | |
| 4137 | 4142 | ** 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. | |
| 4139 | 4155 | */ |
| 4140 | 4156 | SQLITE_API char *sqlite3_temp_directory; |
| 4141 | 4157 | |
| 4142 | 4158 | /* |
| 4143 | 4159 | ** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200> |
| @@ -6417,10 +6433,15 @@ | ||
| 6417 | 6433 | /* |
| 6418 | 6434 | ** Round down to the nearest multiple of 8 |
| 6419 | 6435 | */ |
| 6420 | 6436 | #define ROUNDDOWN8(x) ((x)&~7) |
| 6421 | 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 | + | |
| 6422 | 6443 | /* |
| 6423 | 6444 | ** An instance of the following structure is used to store the busy-handler |
| 6424 | 6445 | ** callback for a given sqlite handle. |
| 6425 | 6446 | ** |
| 6426 | 6447 | ** The sqlite.busyHandler member of the sqlite struct contains the busy |
| @@ -6571,11 +6592,11 @@ | ||
| 6571 | 6592 | ************************************************************************* |
| 6572 | 6593 | ** This header file defines the interface that the sqlite B-Tree file |
| 6573 | 6594 | ** subsystem. See comments in the source code for a detailed description |
| 6574 | 6595 | ** of what each interface routine does. |
| 6575 | 6596 | ** |
| 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 $ | |
| 6577 | 6598 | */ |
| 6578 | 6599 | #ifndef _BTREE_H_ |
| 6579 | 6600 | #define _BTREE_H_ |
| 6580 | 6601 | |
| 6581 | 6602 | /* TODO: This definition is just included so other modules compile. It |
| @@ -6638,11 +6659,11 @@ | ||
| 6638 | 6659 | |
| 6639 | 6660 | SQLITE_PRIVATE int sqlite3BtreeClose(Btree*); |
| 6640 | 6661 | SQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree*,int); |
| 6641 | 6662 | SQLITE_PRIVATE int sqlite3BtreeSetSafetyLevel(Btree*,int,int); |
| 6642 | 6663 | SQLITE_PRIVATE int sqlite3BtreeSyncDisabled(Btree*); |
| 6643 | -SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree*,int,int); | |
| 6664 | +SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree*,int,int,int); | |
| 6644 | 6665 | SQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree*); |
| 6645 | 6666 | SQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree*,int); |
| 6646 | 6667 | SQLITE_PRIVATE int sqlite3BtreeGetReserve(Btree*); |
| 6647 | 6668 | SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int); |
| 6648 | 6669 | SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *); |
| @@ -6744,46 +6765,43 @@ | ||
| 6744 | 6765 | /* |
| 6745 | 6766 | ** If we are not using shared cache, then there is no need to |
| 6746 | 6767 | ** use mutexes to access the BtShared structures. So make the |
| 6747 | 6768 | ** Enter and Leave procedures no-ops. |
| 6748 | 6769 | */ |
| 6749 | -#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE | |
| 6770 | +#ifndef SQLITE_OMIT_SHARED_CACHE | |
| 6750 | 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 | |
| 6751 | 6779 | 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 | 6780 | SQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor*); |
| 6757 | 6781 | SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor*); |
| 6758 | -SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3*); | |
| 6759 | 6782 | 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 | 6783 | SQLITE_PRIVATE void sqlite3BtreeMutexArrayEnter(BtreeMutexArray*); |
| 6765 | 6784 | SQLITE_PRIVATE void sqlite3BtreeMutexArrayLeave(BtreeMutexArray*); |
| 6766 | 6785 | SQLITE_PRIVATE void sqlite3BtreeMutexArrayInsert(BtreeMutexArray*, Btree*); |
| 6767 | -#else | |
| 6768 | -# define sqlite3BtreeEnter(X) | |
| 6769 | -# define sqlite3BtreeLeave(X) | |
| 6770 | 6786 | #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*); | |
| 6773 | 6790 | #endif |
| 6791 | +#else | |
| 6792 | + | |
| 6793 | +# define sqlite3BtreeLeave(X) | |
| 6774 | 6794 | # define sqlite3BtreeEnterCursor(X) |
| 6775 | 6795 | # define sqlite3BtreeLeaveCursor(X) |
| 6776 | -# define sqlite3BtreeEnterAll(X) | |
| 6777 | 6796 | # define sqlite3BtreeLeaveAll(X) |
| 6778 | -#ifndef NDEBUG | |
| 6779 | - /* This routine is used inside assert() statements only. */ | |
| 6780 | -# define sqlite3BtreeHoldsAllMutexes(X) 1 | |
| 6781 | -#endif | |
| 6782 | 6797 | # define sqlite3BtreeMutexArrayEnter(X) |
| 6783 | 6798 | # define sqlite3BtreeMutexArrayLeave(X) |
| 6784 | 6799 | # define sqlite3BtreeMutexArrayInsert(X,Y) |
| 6800 | + | |
| 6801 | +# define sqlite3BtreeHoldsMutex(X) 1 | |
| 6802 | +# define sqlite3BtreeHoldsAllMutexes(X) 1 | |
| 6785 | 6803 | #endif |
| 6786 | 6804 | |
| 6787 | 6805 | |
| 6788 | 6806 | #endif /* _BTREE_H_ */ |
| 6789 | 6807 | |
| @@ -6806,11 +6824,11 @@ | ||
| 6806 | 6824 | ** |
| 6807 | 6825 | ** This header defines the interface to the virtual database engine |
| 6808 | 6826 | ** or VDBE. The VDBE implements an abstract machine that runs a |
| 6809 | 6827 | ** simple program to access and modify the underlying database. |
| 6810 | 6828 | ** |
| 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 $ | |
| 6812 | 6830 | */ |
| 6813 | 6831 | #ifndef _SQLITE_VDBE_H_ |
| 6814 | 6832 | #define _SQLITE_VDBE_H_ |
| 6815 | 6833 | |
| 6816 | 6834 | /* |
| @@ -7162,12 +7180,11 @@ | ||
| 7162 | 7180 | SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*); |
| 7163 | 7181 | |
| 7164 | 7182 | #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT |
| 7165 | 7183 | SQLITE_PRIVATE int sqlite3VdbeReleaseMemory(int); |
| 7166 | 7184 | #endif |
| 7167 | -SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*, | |
| 7168 | - UnpackedRecord*,int); | |
| 7185 | +SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,char*,int); | |
| 7169 | 7186 | SQLITE_PRIVATE void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord*); |
| 7170 | 7187 | SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*); |
| 7171 | 7188 | |
| 7172 | 7189 | |
| 7173 | 7190 | #ifndef NDEBUG |
| @@ -8097,10 +8114,17 @@ | ||
| 8097 | 8114 | u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */ |
| 8098 | 8115 | |
| 8099 | 8116 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| 8100 | 8117 | /* The following variables are all protected by the STATIC_MASTER |
| 8101 | 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. | |
| 8102 | 8126 | */ |
| 8103 | 8127 | sqlite3 *pBlockingConnection; /* Connection that caused SQLITE_LOCKED */ |
| 8104 | 8128 | sqlite3 *pUnlockConnection; /* Connection to watch for unlock */ |
| 8105 | 8129 | void *pUnlockArg; /* Argument to xUnlockNotify */ |
| 8106 | 8130 | void (*xUnlockNotify)(void **, int); /* Unlock notify callback */ |
| @@ -8141,11 +8165,10 @@ | ||
| 8141 | 8165 | #define SQLITE_FullFSync 0x00010000 /* Use full fsync on the backend */ |
| 8142 | 8166 | #define SQLITE_LoadExtension 0x00020000 /* Enable load_extension */ |
| 8143 | 8167 | |
| 8144 | 8168 | #define SQLITE_RecoveryMode 0x00040000 /* Ignore schema errors */ |
| 8145 | 8169 | #define SQLITE_SharedCache 0x00080000 /* Cache sharing is enabled */ |
| 8146 | -#define SQLITE_Vtab 0x00100000 /* There exists a virtual table */ | |
| 8147 | 8170 | #define SQLITE_CommitBusy 0x00200000 /* In the process of committing */ |
| 8148 | 8171 | #define SQLITE_ReverseOrder 0x00400000 /* Reverse unordered SELECTs */ |
| 8149 | 8172 | |
| 8150 | 8173 | /* |
| 8151 | 8174 | ** Possible values for the sqlite.magic field. |
| @@ -8707,23 +8730,22 @@ | ||
| 8707 | 8730 | ** is a disk table or the "old.*" pseudo-table, then pTab points to the |
| 8708 | 8731 | ** corresponding table definition. |
| 8709 | 8732 | ** |
| 8710 | 8733 | ** ALLOCATION NOTES: |
| 8711 | 8734 | ** |
| 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. | |
| 8725 | 8747 | */ |
| 8726 | 8748 | struct Expr { |
| 8727 | 8749 | u8 op; /* Operation performed by this node */ |
| 8728 | 8750 | char affinity; /* The affinity of the column or 0 if not a column */ |
| 8729 | 8751 | VVA_ONLY(u8 vvaFlags;) /* Flags used for VV&A only. EVVA_* below. */ |
| @@ -8735,11 +8757,11 @@ | ||
| 8735 | 8757 | ** access them will result in a segfault or malfunction. |
| 8736 | 8758 | *********************************************************************/ |
| 8737 | 8759 | |
| 8738 | 8760 | Token span; /* Complete text of the expression */ |
| 8739 | 8761 | |
| 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 | |
| 8741 | 8763 | ** space is allocated for the fields below this point. An attempt to |
| 8742 | 8764 | ** access them will result in a segfault or malfunction. |
| 8743 | 8765 | *********************************************************************/ |
| 8744 | 8766 | |
| 8745 | 8767 | Expr *pLeft; /* Left subnode */ |
| @@ -8783,11 +8805,11 @@ | ||
| 8783 | 8805 | #define EP_IntValue 0x0800 /* Integer value contained in iTable */ |
| 8784 | 8806 | #define EP_xIsSelect 0x1000 /* x.pSelect is valid (otherwise x.pList is) */ |
| 8785 | 8807 | |
| 8786 | 8808 | #define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */ |
| 8787 | 8809 | #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 */ | |
| 8789 | 8811 | |
| 8790 | 8812 | /* |
| 8791 | 8813 | ** The following are the meanings of bits in the Expr.vvaFlags field. |
| 8792 | 8814 | ** This information is only used when SQLite is compiled with |
| 8793 | 8815 | ** SQLITE_DEBUG defined. |
| @@ -8808,22 +8830,21 @@ | ||
| 8808 | 8830 | /* |
| 8809 | 8831 | ** Macros to determine the number of bytes required by a normal Expr |
| 8810 | 8832 | ** struct, an Expr struct with the EP_Reduced flag set in Expr.flags |
| 8811 | 8833 | ** and an Expr struct with the EP_TokenOnly flag set. |
| 8812 | 8834 | */ |
| 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 */ | |
| 8817 | 8839 | |
| 8818 | 8840 | /* |
| 8819 | 8841 | ** Flags passed to the sqlite3ExprDup() function. See the header comment |
| 8820 | 8842 | ** above sqlite3ExprDup() for details. |
| 8821 | 8843 | */ |
| 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 */ | |
| 8825 | 8846 | |
| 8826 | 8847 | /* |
| 8827 | 8848 | ** A list of expressions. Each expression may optionally have a |
| 8828 | 8849 | ** name. An expr/name combination can be used in several ways, such |
| 8829 | 8850 | ** as the list of "expr AS ID" fields following a "SELECT" or in the |
| @@ -9799,10 +9820,11 @@ | ||
| 9799 | 9820 | # define sqlite3TriggersExist(B,C,D,E,F) 0 |
| 9800 | 9821 | # define sqlite3DeleteTrigger(A,B) |
| 9801 | 9822 | # define sqlite3DropTriggerPtr(A,B) |
| 9802 | 9823 | # define sqlite3UnlinkAndDeleteTrigger(A,B,C) |
| 9803 | 9824 | # define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I,J,K,L) 0 |
| 9825 | +# define sqlite3TriggerList(X, Y) 0 | |
| 9804 | 9826 | #endif |
| 9805 | 9827 | |
| 9806 | 9828 | SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*); |
| 9807 | 9829 | SQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int); |
| 9808 | 9830 | SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int); |
| @@ -9830,11 +9852,11 @@ | ||
| 9830 | 9852 | SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*); |
| 9831 | 9853 | SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*); |
| 9832 | 9854 | SQLITE_PRIVATE int sqlite3FitsIn64Bits(const char *, int); |
| 9833 | 9855 | SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar); |
| 9834 | 9856 | 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**); | |
| 9836 | 9858 | |
| 9837 | 9859 | /* |
| 9838 | 9860 | ** Routines to read and write variable-length integers. These used to |
| 9839 | 9861 | ** be defined locally, but now we use the varint routines in the util.c |
| 9840 | 9862 | ** file. Code should use the MACRO forms below, as the Varint32 versions |
| @@ -10427,11 +10449,11 @@ | ||
| 10427 | 10449 | ** |
| 10428 | 10450 | ** There is only one exported symbol in this file - the function |
| 10429 | 10451 | ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. |
| 10430 | 10452 | ** All other code has file scope. |
| 10431 | 10453 | ** |
| 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 $ | |
| 10433 | 10455 | ** |
| 10434 | 10456 | ** SQLite processes all times and dates as Julian Day numbers. The |
| 10435 | 10457 | ** dates and times are stored as the number of days since noon |
| 10436 | 10458 | ** in Greenwich on November 24, 4714 B.C. according to the Gregorian |
| 10437 | 10459 | ** calendar system. |
| @@ -11361,12 +11383,12 @@ | ||
| 11361 | 11383 | break; |
| 11362 | 11384 | } |
| 11363 | 11385 | case 'm': sqlite3_snprintf(3, &z[j],"%02d",x.M); j+=2; break; |
| 11364 | 11386 | case 'M': sqlite3_snprintf(3, &z[j],"%02d",x.m); j+=2; break; |
| 11365 | 11387 | 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)); | |
| 11368 | 11390 | j += sqlite3Strlen30(&z[j]); |
| 11369 | 11391 | break; |
| 11370 | 11392 | } |
| 11371 | 11393 | case 'S': sqlite3_snprintf(3,&z[j],"%02d",(int)x.s); j+=2; break; |
| 11372 | 11394 | case 'w': { |
| @@ -15655,11 +15677,11 @@ | ||
| 15655 | 15677 | ** the public domain. The original comments are included here for |
| 15656 | 15678 | ** completeness. They are very out-of-date but might be useful as |
| 15657 | 15679 | ** an historical reference. Most of the "enhancements" have been backed |
| 15658 | 15680 | ** out so that the functionality is now the same as standard printf(). |
| 15659 | 15681 | ** |
| 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 $ | |
| 15661 | 15683 | ** |
| 15662 | 15684 | ************************************************************************** |
| 15663 | 15685 | ** |
| 15664 | 15686 | ** The following modules is an enhanced replacement for the "printf" subroutines |
| 15665 | 15687 | ** found in the standard C library. The following enhancements are |
| @@ -15726,10 +15748,12 @@ | ||
| 15726 | 15748 | #define etSRCLIST 13 /* a pointer to a SrcList */ |
| 15727 | 15749 | #define etPOINTER 14 /* The %p conversion */ |
| 15728 | 15750 | #define etSQLESCAPE3 15 /* %w -> Strings with '\"' doubled */ |
| 15729 | 15751 | #define etORDINAL 16 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */ |
| 15730 | 15752 | |
| 15753 | +#define etINVALID 0 /* Any unrecognized conversion type */ | |
| 15754 | + | |
| 15731 | 15755 | |
| 15732 | 15756 | /* |
| 15733 | 15757 | ** An "etByte" is an 8-bit unsigned value. |
| 15734 | 15758 | */ |
| 15735 | 15759 | typedef unsigned char etByte; |
| @@ -15782,10 +15806,13 @@ | ||
| 15782 | 15806 | #endif |
| 15783 | 15807 | { 'i', 10, 1, etRADIX, 0, 0 }, |
| 15784 | 15808 | { 'n', 0, 0, etSIZE, 0, 0 }, |
| 15785 | 15809 | { '%', 0, 0, etPERCENT, 0, 0 }, |
| 15786 | 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 */ | |
| 15787 | 15814 | { 'T', 0, 2, etTOKEN, 0, 0 }, |
| 15788 | 15815 | { 'S', 0, 2, etSRCLIST, 0, 0 }, |
| 15789 | 15816 | { 'r', 10, 3, etORDINAL, 0, 0 }, |
| 15790 | 15817 | }; |
| 15791 | 15818 | |
| @@ -15984,11 +16011,12 @@ | ||
| 15984 | 16011 | } |
| 15985 | 16012 | }else{ |
| 15986 | 16013 | flag_long = flag_longlong = 0; |
| 15987 | 16014 | } |
| 15988 | 16015 | /* Fetch the info entry for the field */ |
| 15989 | - infop = 0; | |
| 16016 | + infop = &fmtinfo[0]; | |
| 16017 | + xtype = etINVALID; | |
| 15990 | 16018 | for(idx=0; idx<ArraySize(fmtinfo); idx++){ |
| 15991 | 16019 | if( c==fmtinfo[idx].fmttype ){ |
| 15992 | 16020 | infop = &fmtinfo[idx]; |
| 15993 | 16021 | if( useExtended || (infop->flags & FLAG_INTERN)==0 ){ |
| 15994 | 16022 | xtype = infop->type; |
| @@ -15997,13 +16025,10 @@ | ||
| 15997 | 16025 | } |
| 15998 | 16026 | break; |
| 15999 | 16027 | } |
| 16000 | 16028 | } |
| 16001 | 16029 | zExtra = 0; |
| 16002 | - if( infop==0 ){ | |
| 16003 | - return; | |
| 16004 | - } | |
| 16005 | 16030 | |
| 16006 | 16031 | |
| 16007 | 16032 | /* Limit the precision to prevent overflowing buf[] during conversion */ |
| 16008 | 16033 | if( precision>etBUFSIZE-40 && (infop->flags & FLAG_STRING)==0 ){ |
| 16009 | 16034 | precision = etBUFSIZE-40; |
| @@ -16336,10 +16361,14 @@ | ||
| 16336 | 16361 | sqlite3StrAccumAppend(pAccum, ".", 1); |
| 16337 | 16362 | } |
| 16338 | 16363 | sqlite3StrAccumAppend(pAccum, pItem->zName, -1); |
| 16339 | 16364 | length = width = 0; |
| 16340 | 16365 | break; |
| 16366 | + } | |
| 16367 | + default: { | |
| 16368 | + assert( xtype==etINVALID ); | |
| 16369 | + return; | |
| 16341 | 16370 | } |
| 16342 | 16371 | }/* End switch over the format type */ |
| 16343 | 16372 | /* |
| 16344 | 16373 | ** The text of the conversion is pointed to by "bufpt" and is |
| 16345 | 16374 | ** "length" characters long. The field width is "width". Do |
| @@ -16370,17 +16399,20 @@ | ||
| 16370 | 16399 | |
| 16371 | 16400 | /* |
| 16372 | 16401 | ** Append N bytes of text from z to the StrAccum object. |
| 16373 | 16402 | */ |
| 16374 | 16403 | SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){ |
| 16404 | + assert( z!=0 || N==0 ); | |
| 16375 | 16405 | if( p->tooBig | p->mallocFailed ){ |
| 16406 | + testcase(p->tooBig); | |
| 16407 | + testcase(p->mallocFailed); | |
| 16376 | 16408 | return; |
| 16377 | 16409 | } |
| 16378 | 16410 | if( N<0 ){ |
| 16379 | 16411 | N = sqlite3Strlen30(z); |
| 16380 | 16412 | } |
| 16381 | - if( N==0 || z==0 ){ | |
| 16413 | + if( N==0 || NEVER(z==0) ){ | |
| 16382 | 16414 | return; |
| 16383 | 16415 | } |
| 16384 | 16416 | if( p->nChar+N >= p->nAlloc ){ |
| 16385 | 16417 | char *zNew; |
| 16386 | 16418 | if( !p->useMalloc ){ |
| @@ -16465,16 +16497,17 @@ | ||
| 16465 | 16497 | */ |
| 16466 | 16498 | SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){ |
| 16467 | 16499 | char *z; |
| 16468 | 16500 | char zBase[SQLITE_PRINT_BUF_SIZE]; |
| 16469 | 16501 | StrAccum acc; |
| 16502 | + assert( db!=0 ); | |
| 16470 | 16503 | sqlite3StrAccumInit(&acc, zBase, sizeof(zBase), |
| 16471 | - db ? db->aLimit[SQLITE_LIMIT_LENGTH] : SQLITE_MAX_LENGTH); | |
| 16504 | + db->aLimit[SQLITE_LIMIT_LENGTH]); | |
| 16472 | 16505 | acc.db = db; |
| 16473 | 16506 | sqlite3VXPrintf(&acc, 1, zFormat, ap); |
| 16474 | 16507 | z = sqlite3StrAccumFinish(&acc); |
| 16475 | - if( acc.mallocFailed && db ){ | |
| 16508 | + if( acc.mallocFailed ){ | |
| 16476 | 16509 | db->mallocFailed = 1; |
| 16477 | 16510 | } |
| 16478 | 16511 | return z; |
| 16479 | 16512 | } |
| 16480 | 16513 | |
| @@ -16749,11 +16782,11 @@ | ||
| 16749 | 16782 | ** |
| 16750 | 16783 | ************************************************************************* |
| 16751 | 16784 | ** This file contains routines used to translate between UTF-8, |
| 16752 | 16785 | ** UTF-16, UTF-16BE, and UTF-16LE. |
| 16753 | 16786 | ** |
| 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 $ | |
| 16755 | 16788 | ** |
| 16756 | 16789 | ** Notes on UTF-8: |
| 16757 | 16790 | ** |
| 16758 | 16791 | ** Byte-0 Byte-1 Byte-2 Byte-3 Value |
| 16759 | 16792 | ** 0xxxxxxx 00000000 00000000 0xxxxxxx |
| @@ -16791,11 +16824,11 @@ | ||
| 16791 | 16824 | ** VDBE. This information used to all be at the top of the single |
| 16792 | 16825 | ** source code file "vdbe.c". When that file became too big (over |
| 16793 | 16826 | ** 6000 lines long) it was split up into several smaller files and |
| 16794 | 16827 | ** this header information was factored out. |
| 16795 | 16828 | ** |
| 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 $ | |
| 16797 | 16830 | */ |
| 16798 | 16831 | #ifndef _VDBEINT_H_ |
| 16799 | 16832 | #define _VDBEINT_H_ |
| 16800 | 16833 | |
| 16801 | 16834 | /* |
| @@ -17154,10 +17187,16 @@ | ||
| 17154 | 17187 | SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve); |
| 17155 | 17188 | SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int); |
| 17156 | 17189 | #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT |
| 17157 | 17190 | SQLITE_PRIVATE int sqlite3VdbeReleaseBuffers(Vdbe *p); |
| 17158 | 17191 | #endif |
| 17192 | + | |
| 17193 | +#ifndef SQLITE_OMIT_SHARED_CACHE | |
| 17194 | +SQLITE_PRIVATE void sqlite3VdbeMutexArrayEnter(Vdbe *p); | |
| 17195 | +#else | |
| 17196 | +# define sqlite3VdbeMutexArrayEnter(p) | |
| 17197 | +#endif | |
| 17159 | 17198 | |
| 17160 | 17199 | SQLITE_PRIVATE int sqlite3VdbeMemTranslate(Mem*, u8); |
| 17161 | 17200 | #ifdef SQLITE_DEBUG |
| 17162 | 17201 | SQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe*); |
| 17163 | 17202 | SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf); |
| @@ -17244,26 +17283,24 @@ | ||
| 17244 | 17283 | } |
| 17245 | 17284 | |
| 17246 | 17285 | #define READ_UTF16LE(zIn, c){ \ |
| 17247 | 17286 | c = (*zIn++); \ |
| 17248 | 17287 | c += ((*zIn++)<<8); \ |
| 17249 | - if( c>=0xD800 && c<0xE000 ){ \ | |
| 17288 | + if( c>=0xD800 && c<0xE000 ){ \ | |
| 17250 | 17289 | int c2 = (*zIn++); \ |
| 17251 | 17290 | c2 += ((*zIn++)<<8); \ |
| 17252 | 17291 | c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \ |
| 17253 | - if( (c & 0xFFFF0000)==0 ) c = 0xFFFD; \ | |
| 17254 | 17292 | } \ |
| 17255 | 17293 | } |
| 17256 | 17294 | |
| 17257 | 17295 | #define READ_UTF16BE(zIn, c){ \ |
| 17258 | 17296 | c = ((*zIn++)<<8); \ |
| 17259 | 17297 | c += (*zIn++); \ |
| 17260 | - if( c>=0xD800 && c<0xE000 ){ \ | |
| 17298 | + if( c>=0xD800 && c<0xE000 ){ \ | |
| 17261 | 17299 | int c2 = ((*zIn++)<<8); \ |
| 17262 | 17300 | c2 += (*zIn++); \ |
| 17263 | 17301 | c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10); \ |
| 17264 | - if( (c & 0xFFFF0000)==0 ) c = 0xFFFD; \ | |
| 17265 | 17302 | } \ |
| 17266 | 17303 | } |
| 17267 | 17304 | |
| 17268 | 17305 | /* |
| 17269 | 17306 | ** Translate a single UTF-8 character. Return the unicode value. |
| @@ -17302,17 +17339,29 @@ | ||
| 17302 | 17339 | if( c<0x80 \ |
| 17303 | 17340 | || (c&0xFFFFF800)==0xD800 \ |
| 17304 | 17341 | || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \ |
| 17305 | 17342 | } |
| 17306 | 17343 | 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 */ | |
| 17309 | 17345 | const unsigned char **pzNext /* Write first byte past UTF-8 char here */ |
| 17310 | 17346 | ){ |
| 17311 | 17347 | 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; | |
| 17314 | 17363 | return c; |
| 17315 | 17364 | } |
| 17316 | 17365 | |
| 17317 | 17366 | |
| 17318 | 17367 | |
| @@ -17475,11 +17524,12 @@ | ||
| 17475 | 17524 | */ |
| 17476 | 17525 | SQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem){ |
| 17477 | 17526 | int rc = SQLITE_OK; |
| 17478 | 17527 | u8 bom = 0; |
| 17479 | 17528 | |
| 17480 | - if( pMem->n<0 || pMem->n>1 ){ | |
| 17529 | + assert( pMem->n>=0 ); | |
| 17530 | + if( pMem->n>1 ){ | |
| 17481 | 17531 | u8 b1 = *(u8 *)pMem->z; |
| 17482 | 17532 | u8 b2 = *(((u8 *)pMem->z) + 1); |
| 17483 | 17533 | if( b1==0xFE && b2==0xFF ){ |
| 17484 | 17534 | bom = SQLITE_UTF16BE; |
| 17485 | 17535 | } |
| @@ -17541,15 +17591,14 @@ | ||
| 17541 | 17591 | ** correct UTF-8 encoding to be longer than a malformed encoding). |
| 17542 | 17592 | */ |
| 17543 | 17593 | SQLITE_PRIVATE int sqlite3Utf8To8(unsigned char *zIn){ |
| 17544 | 17594 | unsigned char *zOut = zIn; |
| 17545 | 17595 | unsigned char *zStart = zIn; |
| 17546 | - unsigned char *zTerm = &zIn[sqlite3Strlen30((char *)zIn)]; | |
| 17547 | 17596 | u32 c; |
| 17548 | 17597 | |
| 17549 | 17598 | while( zIn[0] ){ |
| 17550 | - c = sqlite3Utf8Read(zIn, zTerm, (const u8**)&zIn); | |
| 17599 | + c = sqlite3Utf8Read(zIn, (const u8**)&zIn); | |
| 17551 | 17600 | if( c!=0xfffd ){ |
| 17552 | 17601 | WRITE_UTF8(zOut, c); |
| 17553 | 17602 | } |
| 17554 | 17603 | } |
| 17555 | 17604 | *zOut = 0; |
| @@ -17579,19 +17628,17 @@ | ||
| 17579 | 17628 | assert( (m.flags & MEM_Str)!=0 || db->mallocFailed ); |
| 17580 | 17629 | return (m.flags & MEM_Dyn)!=0 ? m.z : sqlite3DbStrDup(db, m.z); |
| 17581 | 17630 | } |
| 17582 | 17631 | |
| 17583 | 17632 | /* |
| 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. | |
| 17589 | 17636 | */ |
| 17590 | 17637 | 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; | |
| 17593 | 17640 | int n = 0; |
| 17594 | 17641 | if( SQLITE_UTF16NATIVE==SQLITE_UTF16BE ){ |
| 17595 | 17642 | /* Using an "if (SQLITE_UTF16NATIVE==SQLITE_UTF16BE)" construct here |
| 17596 | 17643 | ** and in other parts of this file means that at one branch will |
| 17597 | 17644 | ** not be covered by coverage testing on any single host. But coverage |
| @@ -17599,21 +17646,21 @@ | ||
| 17599 | 17646 | ** big-endian host. Because both the UTF16NATIVE and SQLITE_UTF16BE |
| 17600 | 17647 | ** macros are constant at compile time the compiler can determine |
| 17601 | 17648 | ** which branch will be followed. It is therefore assumed that no runtime |
| 17602 | 17649 | ** penalty is paid for this "if" statement. |
| 17603 | 17650 | */ |
| 17604 | - while( c && ((nChar<0) || n<nChar) ){ | |
| 17651 | + while( n<nChar ){ | |
| 17605 | 17652 | READ_UTF16BE(z, c); |
| 17606 | 17653 | n++; |
| 17607 | 17654 | } |
| 17608 | 17655 | }else{ |
| 17609 | - while( c && ((nChar<0) || n<nChar) ){ | |
| 17656 | + while( n<nChar ){ | |
| 17610 | 17657 | READ_UTF16LE(z, c); |
| 17611 | 17658 | n++; |
| 17612 | 17659 | } |
| 17613 | 17660 | } |
| 17614 | - return (int)(z-(char const *)zIn)-((c==0)?2:0); | |
| 17661 | + return (int)(z-(unsigned char const *)zIn); | |
| 17615 | 17662 | } |
| 17616 | 17663 | |
| 17617 | 17664 | #if defined(SQLITE_TEST) |
| 17618 | 17665 | /* |
| 17619 | 17666 | ** This routine is called from the TCL test function "translate_selftest". |
| @@ -17622,23 +17669,21 @@ | ||
| 17622 | 17669 | */ |
| 17623 | 17670 | SQLITE_PRIVATE void sqlite3UtfSelfTest(void){ |
| 17624 | 17671 | unsigned int i, t; |
| 17625 | 17672 | unsigned char zBuf[20]; |
| 17626 | 17673 | unsigned char *z; |
| 17627 | - unsigned char *zTerm; | |
| 17628 | 17674 | int n; |
| 17629 | 17675 | unsigned int c; |
| 17630 | 17676 | |
| 17631 | 17677 | for(i=0; i<0x00110000; i++){ |
| 17632 | 17678 | z = zBuf; |
| 17633 | 17679 | WRITE_UTF8(z, i); |
| 17634 | 17680 | n = (int)(z-zBuf); |
| 17635 | 17681 | assert( n>0 && n<=4 ); |
| 17636 | 17682 | z[0] = 0; |
| 17637 | - zTerm = z; | |
| 17638 | 17683 | z = zBuf; |
| 17639 | - c = sqlite3Utf8Read(z, zTerm, (const u8**)&z); | |
| 17684 | + c = sqlite3Utf8Read(z, (const u8**)&z); | |
| 17640 | 17685 | t = i; |
| 17641 | 17686 | if( i>=0xD800 && i<=0xDFFF ) t = 0xFFFD; |
| 17642 | 17687 | if( (i&0xFFFFFFFE)==0xFFFE ) t = 0xFFFD; |
| 17643 | 17688 | assert( c==t ); |
| 17644 | 17689 | assert( (z-zBuf)==n ); |
| @@ -20521,11 +20566,11 @@ | ||
| 20521 | 20566 | ** * sqlite3_vfs method implementations. |
| 20522 | 20567 | ** * Locking primitives for the proxy uber-locking-method. (MacOSX only) |
| 20523 | 20568 | ** * Definitions of sqlite3_vfs objects for all locking methods |
| 20524 | 20569 | ** plus implementations of sqlite3_os_init() and sqlite3_os_end(). |
| 20525 | 20570 | ** |
| 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 $ | |
| 20527 | 20572 | */ |
| 20528 | 20573 | #if SQLITE_OS_UNIX /* This file is used on unix only */ |
| 20529 | 20574 | |
| 20530 | 20575 | /* |
| 20531 | 20576 | ** There are various methods for file locking used for concurrency |
| @@ -22911,12 +22956,12 @@ | ||
| 22911 | 22956 | semUnlock(id, NO_LOCK); |
| 22912 | 22957 | assert( pFile ); |
| 22913 | 22958 | unixEnterMutex(); |
| 22914 | 22959 | releaseLockInfo(pFile->pLock); |
| 22915 | 22960 | releaseOpenCnt(pFile->pOpen); |
| 22916 | - closeUnixFile(id); | |
| 22917 | 22961 | unixLeaveMutex(); |
| 22962 | + closeUnixFile(id); | |
| 22918 | 22963 | } |
| 22919 | 22964 | return SQLITE_OK; |
| 22920 | 22965 | } |
| 22921 | 22966 | |
| 22922 | 22967 | #endif /* OS_VXWORKS */ |
| @@ -23905,11 +23950,11 @@ | ||
| 23905 | 23950 | dotlockLock, /* xLock method */ |
| 23906 | 23951 | dotlockUnlock, /* xUnlock method */ |
| 23907 | 23952 | dotlockCheckReservedLock /* xCheckReservedLock method */ |
| 23908 | 23953 | ) |
| 23909 | 23954 | |
| 23910 | -#if SQLITE_ENABLE_LOCKING_STYLE | |
| 23955 | +#if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS | |
| 23911 | 23956 | IOMETHODS( |
| 23912 | 23957 | flockIoFinder, /* Finder function name */ |
| 23913 | 23958 | flockIoMethods, /* sqlite3_io_methods object name */ |
| 23914 | 23959 | flockClose, /* xClose method */ |
| 23915 | 23960 | flockLock, /* xLock method */ |
| @@ -24029,10 +24074,48 @@ | ||
| 24029 | 24074 | static const sqlite3_io_methods *(*const autolockIoFinder)(const char*,int) |
| 24030 | 24075 | = autolockIoFinderImpl; |
| 24031 | 24076 | |
| 24032 | 24077 | #endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */ |
| 24033 | 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 | + | |
| 24034 | 24117 | /* |
| 24035 | 24118 | ** An abstract type for a pointer to a IO method finder function: |
| 24036 | 24119 | */ |
| 24037 | 24120 | typedef const sqlite3_io_methods *(*finder_type)(const char*,int); |
| 24038 | 24121 | |
| @@ -24311,11 +24394,11 @@ | ||
| 24311 | 24394 | const char *zPath, /* Pathname of file to be opened */ |
| 24312 | 24395 | sqlite3_file *pFile, /* The file descriptor to be filled in */ |
| 24313 | 24396 | int flags, /* Input flags to control the opening */ |
| 24314 | 24397 | int *pOutFlags /* Output flags returned to SQLite core */ |
| 24315 | 24398 | ){ |
| 24316 | - int fd = 0; /* File descriptor returned by open() */ | |
| 24399 | + int fd = -1; /* File descriptor returned by open() */ | |
| 24317 | 24400 | int dirfd = -1; /* Directory file descriptor */ |
| 24318 | 24401 | int openFlags = 0; /* Flags to pass to open() */ |
| 24319 | 24402 | int eType = flags&0xFFFFFF00; /* Type of file to open */ |
| 24320 | 24403 | int noLock; /* True to omit locking primitives */ |
| 24321 | 24404 | int rc = SQLITE_OK; |
| @@ -24414,11 +24497,11 @@ | ||
| 24414 | 24497 | if( (flags & SQLITE_OPEN_MAIN_DB)!=0 ){ |
| 24415 | 24498 | ((unixFile*)pFile)->isLockable = 1; |
| 24416 | 24499 | } |
| 24417 | 24500 | #endif |
| 24418 | 24501 | |
| 24419 | - assert(fd!=0); | |
| 24502 | + assert( fd>=0 ); | |
| 24420 | 24503 | if( isOpenDirectory ){ |
| 24421 | 24504 | rc = openDirectory(zPath, &dirfd); |
| 24422 | 24505 | if( rc!=SQLITE_OK ){ |
| 24423 | 24506 | close(fd); /* silently leak if fail, already in error */ |
| 24424 | 24507 | return rc; |
| @@ -25759,11 +25842,11 @@ | ||
| 25759 | 25842 | ** Note that the sqlite3_vfs.pNext field of the VFS object is modified |
| 25760 | 25843 | ** by the SQLite core when the VFS is registered. So the following |
| 25761 | 25844 | ** array cannot be const. |
| 25762 | 25845 | */ |
| 25763 | 25846 | static sqlite3_vfs aVfs[] = { |
| 25764 | -#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) | |
| 25847 | +#if SQLITE_ENABLE_LOCKING_STYLE && (OS_VXWORKS || defined(__APPLE__)) | |
| 25765 | 25848 | UNIXVFS("unix", autolockIoFinder ), |
| 25766 | 25849 | #else |
| 25767 | 25850 | UNIXVFS("unix", posixIoFinder ), |
| 25768 | 25851 | #endif |
| 25769 | 25852 | UNIXVFS("unix-none", nolockIoFinder ), |
| @@ -25771,11 +25854,13 @@ | ||
| 25771 | 25854 | #if OS_VXWORKS |
| 25772 | 25855 | UNIXVFS("unix-namedsem", semIoFinder ), |
| 25773 | 25856 | #endif |
| 25774 | 25857 | #if SQLITE_ENABLE_LOCKING_STYLE |
| 25775 | 25858 | UNIXVFS("unix-posix", posixIoFinder ), |
| 25859 | +#if !OS_VXWORKS | |
| 25776 | 25860 | UNIXVFS("unix-flock", flockIoFinder ), |
| 25861 | +#endif | |
| 25777 | 25862 | #endif |
| 25778 | 25863 | #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) |
| 25779 | 25864 | UNIXVFS("unix-afp", afpIoFinder ), |
| 25780 | 25865 | UNIXVFS("unix-proxy", proxyIoFinder ), |
| 25781 | 25866 | #endif |
| @@ -25816,11 +25901,11 @@ | ||
| 25816 | 25901 | ** |
| 25817 | 25902 | ****************************************************************************** |
| 25818 | 25903 | ** |
| 25819 | 25904 | ** This file contains code that is specific to windows. |
| 25820 | 25905 | ** |
| 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 $ | |
| 25822 | 25907 | */ |
| 25823 | 25908 | #if SQLITE_OS_WIN /* This file is used for windows only */ |
| 25824 | 25909 | |
| 25825 | 25910 | |
| 25826 | 25911 | /* |
| @@ -27612,11 +27697,11 @@ | ||
| 27612 | 27697 | const char *zRelative /* UTF-8 file name */ |
| 27613 | 27698 | ){ |
| 27614 | 27699 | DWORD bytesPerSector = SQLITE_DEFAULT_SECTOR_SIZE; |
| 27615 | 27700 | char zFullpath[MAX_PATH+1]; |
| 27616 | 27701 | int rc; |
| 27617 | - DWORD dwRet = 0; | |
| 27702 | + DWORD dwRet = 0, dwDummy; | |
| 27618 | 27703 | |
| 27619 | 27704 | /* |
| 27620 | 27705 | ** We need to get the full path name of the file |
| 27621 | 27706 | ** to get the drive letter to look up the sector |
| 27622 | 27707 | ** size. |
| @@ -27636,14 +27721,14 @@ | ||
| 27636 | 27721 | p[i] = '\0'; |
| 27637 | 27722 | break; |
| 27638 | 27723 | } |
| 27639 | 27724 | } |
| 27640 | 27725 | dwRet = GetDiskFreeSpaceW((WCHAR*)zConverted, |
| 27641 | - NULL, | |
| 27726 | + &dwDummy, | |
| 27642 | 27727 | &bytesPerSector, |
| 27643 | - NULL, | |
| 27644 | - NULL); | |
| 27728 | + &dwDummy, | |
| 27729 | + &dwDummy); | |
| 27645 | 27730 | #if SQLITE_OS_WINCE==0 |
| 27646 | 27731 | }else{ |
| 27647 | 27732 | int i; |
| 27648 | 27733 | /* trim path to just drive reference */ |
| 27649 | 27734 | CHAR *p = (CHAR *)zConverted; |
| @@ -27653,14 +27738,14 @@ | ||
| 27653 | 27738 | p[i] = '\0'; |
| 27654 | 27739 | break; |
| 27655 | 27740 | } |
| 27656 | 27741 | } |
| 27657 | 27742 | dwRet = GetDiskFreeSpaceA((CHAR*)zConverted, |
| 27658 | - NULL, | |
| 27743 | + &dwDummy, | |
| 27659 | 27744 | &bytesPerSector, |
| 27660 | - NULL, | |
| 27661 | - NULL); | |
| 27745 | + &dwDummy, | |
| 27746 | + &dwDummy); | |
| 27662 | 27747 | #endif |
| 27663 | 27748 | } |
| 27664 | 27749 | free(zConverted); |
| 27665 | 27750 | } |
| 27666 | 27751 | if( !dwRet ){ |
| @@ -27938,11 +28023,11 @@ | ||
| 27938 | 28023 | ** sometimes grow into tens of thousands or larger. The size of the |
| 27939 | 28024 | ** Bitvec object is the number of pages in the database file at the |
| 27940 | 28025 | ** start of a transaction, and is thus usually less than a few thousand, |
| 27941 | 28026 | ** but can be as large as 2 billion for a really big database. |
| 27942 | 28027 | ** |
| 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 $ | |
| 27944 | 28029 | */ |
| 27945 | 28030 | |
| 27946 | 28031 | /* Size of the Bitvec structure in bytes. */ |
| 27947 | 28032 | #define BITVEC_SZ 512 |
| 27948 | 28033 | |
| @@ -27997,12 +28082,13 @@ | ||
| 27997 | 28082 | ** N*iDivisor+1 and (N+1)*iDivisor. Each subbitmap is normalized |
| 27998 | 28083 | ** to hold deal with values between 1 and iDivisor. |
| 27999 | 28084 | */ |
| 28000 | 28085 | struct Bitvec { |
| 28001 | 28086 | 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. */ | |
| 28004 | 28090 | u32 iDivisor; /* Number of bits handled by each apSub[] entry. */ |
| 28005 | 28091 | /* Should >=0 for apSub element. */ |
| 28006 | 28092 | /* Max iDivisor is max(u32) / BITVEC_NPTR + 1. */ |
| 28007 | 28093 | /* For a BITVEC_SZ of 512, this would be 34,359,739. */ |
| 28008 | 28094 | union { |
| @@ -28280,11 +28366,12 @@ | ||
| 28280 | 28366 | ** Bitvec object. Start with the assumption that they do |
| 28281 | 28367 | ** match (rc==0). Change rc to non-zero if a discrepancy |
| 28282 | 28368 | ** is found. |
| 28283 | 28369 | */ |
| 28284 | 28370 | rc = sqlite3BitvecTest(0,0) + sqlite3BitvecTest(pBitvec, sz+1) |
| 28285 | - + sqlite3BitvecTest(pBitvec, 0); | |
| 28371 | + + sqlite3BitvecTest(pBitvec, 0) | |
| 28372 | + + (sqlite3BitvecSize(pBitvec) - sz); | |
| 28286 | 28373 | for(i=1; i<=sz; i++){ |
| 28287 | 28374 | if( (TESTBIT(pV,i))!=sqlite3BitvecTest(pBitvec,i) ){ |
| 28288 | 28375 | rc = i; |
| 28289 | 28376 | break; |
| 28290 | 28377 | } |
| @@ -29663,11 +29750,11 @@ | ||
| 29663 | 29750 | ** the sort) then returns elements one by one by walking the list. |
| 29664 | 29751 | ** |
| 29665 | 29752 | ** Big chunks of rowid/next-ptr pairs are allocated at a time, to |
| 29666 | 29753 | ** reduce the malloc overhead. |
| 29667 | 29754 | ** |
| 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 $ | |
| 29669 | 29756 | */ |
| 29670 | 29757 | |
| 29671 | 29758 | /* |
| 29672 | 29759 | ** The number of rowset entries per allocation chunk. |
| 29673 | 29760 | */ |
| @@ -29757,11 +29844,11 @@ | ||
| 29757 | 29844 | ** memory allocation fails. |
| 29758 | 29845 | */ |
| 29759 | 29846 | SQLITE_PRIVATE void sqlite3RowSetInsert(RowSet *p, i64 rowid){ |
| 29760 | 29847 | struct RowSetEntry *pEntry; |
| 29761 | 29848 | struct RowSetEntry *pLast; |
| 29762 | - if( p==0 ) return; /* Must have been a malloc failure */ | |
| 29849 | + assert( p!=0 ); | |
| 29763 | 29850 | if( p->nFresh==0 ){ |
| 29764 | 29851 | struct RowSetChunk *pNew; |
| 29765 | 29852 | pNew = sqlite3DbMallocRaw(p->db, sizeof(*pNew)); |
| 29766 | 29853 | if( pNew==0 ){ |
| 29767 | 29854 | return; |
| @@ -29896,11 +29983,11 @@ | ||
| 29896 | 29983 | ** is separate from the database file. The pager also implements file |
| 29897 | 29984 | ** locking to prevent two processes from writing the same database |
| 29898 | 29985 | ** file simultaneously, or one process from reading the database while |
| 29899 | 29986 | ** another is writing. |
| 29900 | 29987 | ** |
| 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 $ | |
| 29902 | 29989 | */ |
| 29903 | 29990 | #ifndef SQLITE_OMIT_DISKIO |
| 29904 | 29991 | |
| 29905 | 29992 | /* |
| 29906 | 29993 | ** Macros for troubleshooting. Normally turned off |
| @@ -31901,15 +31988,15 @@ | ||
| 31901 | 31988 | if( rc==SQLITE_DONE ){ |
| 31902 | 31989 | rc = SQLITE_OK; |
| 31903 | 31990 | pPager->journalOff = szJ; |
| 31904 | 31991 | break; |
| 31905 | 31992 | }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. | |
| 31909 | 31997 | */ |
| 31910 | - rc = SQLITE_CORRUPT_BKPT; | |
| 31911 | 31998 | goto end_playback; |
| 31912 | 31999 | } |
| 31913 | 32000 | } |
| 31914 | 32001 | } |
| 31915 | 32002 | } |
| @@ -32991,13 +33078,13 @@ | ||
| 32991 | 33078 | ** may be a wrapper capable of caching the first portion of the journal |
| 32992 | 33079 | ** file in memory to implement the atomic-write optimization (see |
| 32993 | 33080 | ** source file journal.c). |
| 32994 | 33081 | */ |
| 32995 | 33082 | if( sqlite3JournalSize(pVfs)>sqlite3MemJournalSize() ){ |
| 32996 | - journalFileSize = sqlite3JournalSize(pVfs); | |
| 33083 | + journalFileSize = ROUND8(sqlite3JournalSize(pVfs)); | |
| 32997 | 33084 | }else{ |
| 32998 | - journalFileSize = sqlite3MemJournalSize(); | |
| 33085 | + journalFileSize = ROUND8(sqlite3MemJournalSize()); | |
| 32999 | 33086 | } |
| 33000 | 33087 | |
| 33001 | 33088 | /* Set the output variable to NULL in case an error occurs. */ |
| 33002 | 33089 | *ppPager = 0; |
| 33003 | 33090 | |
| @@ -33049,27 +33136,29 @@ | ||
| 33049 | 33136 | ** Main journal file handle (journalFileSize bytes) |
| 33050 | 33137 | ** Database file name (nPathname+1 bytes) |
| 33051 | 33138 | ** Journal file name (nPathname+8+1 bytes) |
| 33052 | 33139 | */ |
| 33053 | 33140 | 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 */ | |
| 33060 | 33147 | ); |
| 33148 | + assert( EIGHT_BYTE_ALIGNMENT(journalFileSize) ); | |
| 33061 | 33149 | if( !pPtr ){ |
| 33062 | 33150 | sqlite3_free(zPathname); |
| 33063 | 33151 | return SQLITE_NOMEM; |
| 33064 | 33152 | } |
| 33065 | 33153 | 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)); | |
| 33069 | 33157 | pPager->jfd = (sqlite3_file*)(pPtr += journalFileSize); |
| 33070 | 33158 | pPager->zFilename = (char*)(pPtr += journalFileSize); |
| 33159 | + assert( EIGHT_BYTE_ALIGNMENT(pPager->jfd) ); | |
| 33071 | 33160 | |
| 33072 | 33161 | /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */ |
| 33073 | 33162 | if( zPathname ){ |
| 33074 | 33163 | pPager->zJournal = (char*)(pPtr += nPathname + 1); |
| 33075 | 33164 | memcpy(pPager->zFilename, zPathname, nPathname); |
| @@ -34951,18 +35040,15 @@ | ||
| 34951 | 35040 | pPg->flags &= ~PGHDR_NEED_SYNC; |
| 34952 | 35041 | pPgOld = pager_lookup(pPager, pgno); |
| 34953 | 35042 | assert( !pPgOld || pPgOld->nRef==1 ); |
| 34954 | 35043 | if( pPgOld ){ |
| 34955 | 35044 | pPg->flags |= (pPgOld->flags&PGHDR_NEED_SYNC); |
| 35045 | + sqlite3PcacheDrop(pPgOld); | |
| 34956 | 35046 | } |
| 34957 | 35047 | |
| 34958 | 35048 | origPgno = pPg->pgno; |
| 34959 | 35049 | sqlite3PcacheMove(pPg, pgno); |
| 34960 | - if( pPgOld ){ | |
| 34961 | - sqlite3PcacheDrop(pPgOld); | |
| 34962 | - } | |
| 34963 | - | |
| 34964 | 35050 | sqlite3PcacheMakeDirty(pPg); |
| 34965 | 35051 | pPager->dbModified = 1; |
| 34966 | 35052 | |
| 34967 | 35053 | if( needSyncPgno ){ |
| 34968 | 35054 | /* If needSyncPgno is non-zero, then the journal file needs to be |
| @@ -35063,34 +35149,37 @@ | ||
| 35063 | 35149 | ** PAGER_JOURNALMODE_PERSIST |
| 35064 | 35150 | ** PAGER_JOURNALMODE_OFF |
| 35065 | 35151 | ** PAGER_JOURNALMODE_MEMORY |
| 35066 | 35152 | ** |
| 35067 | 35153 | ** 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. | |
| 35069 | 35158 | ** |
| 35070 | 35159 | ** The returned indicate the current (possibly updated) journal-mode. |
| 35071 | 35160 | */ |
| 35072 | 35161 | 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; | |
| 35086 | 35172 | } |
| 35087 | 35173 | return (int)pPager->journalMode; |
| 35088 | 35174 | } |
| 35089 | 35175 | |
| 35090 | 35176 | /* |
| 35091 | 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. | |
| 35092 | 35181 | */ |
| 35093 | 35182 | SQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *pPager, i64 iLimit){ |
| 35094 | 35183 | if( iLimit>=-1 ){ |
| 35095 | 35184 | pPager->journalSizeLimit = iLimit; |
| 35096 | 35185 | } |
| @@ -35121,11 +35210,11 @@ | ||
| 35121 | 35210 | ** May you find forgiveness for yourself and forgive others. |
| 35122 | 35211 | ** May you share freely, never taking more than you give. |
| 35123 | 35212 | ** |
| 35124 | 35213 | ************************************************************************* |
| 35125 | 35214 | ** |
| 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 $ | |
| 35127 | 35216 | ** |
| 35128 | 35217 | ** This file contains code used to implement mutexes on Btree objects. |
| 35129 | 35218 | ** This code really belongs in btree.c. But btree.c is getting too |
| 35130 | 35219 | ** big and we want to break it down some. This packaged seemed like |
| 35131 | 35220 | ** a good breakout. |
| @@ -35773,12 +35862,41 @@ | ||
| 35773 | 35862 | SQLITE_PRIVATE void sqlite3BtreeReleaseTempCursor(BtCursor *pCur); |
| 35774 | 35863 | SQLITE_PRIVATE void sqlite3BtreeMoveToParent(BtCursor *pCur); |
| 35775 | 35864 | |
| 35776 | 35865 | /************** End of btreeInt.h ********************************************/ |
| 35777 | 35866 | /************** 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 | |
| 35779 | 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 | +} | |
| 35780 | 35898 | |
| 35781 | 35899 | /* |
| 35782 | 35900 | ** Enter a mutex on the given BTree object. |
| 35783 | 35901 | ** |
| 35784 | 35902 | ** If the object is not sharable, then no mutex is ever required |
| @@ -35812,19 +35930,24 @@ | ||
| 35812 | 35930 | assert( p->sharable || p->wantToLock==0 ); |
| 35813 | 35931 | |
| 35814 | 35932 | /* We should already hold a lock on the database connection */ |
| 35815 | 35933 | assert( sqlite3_mutex_held(p->db->mutex) ); |
| 35816 | 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 | + | |
| 35817 | 35939 | if( !p->sharable ) return; |
| 35818 | 35940 | p->wantToLock++; |
| 35819 | 35941 | if( p->locked ) return; |
| 35820 | 35942 | |
| 35821 | 35943 | /* In most cases, we should be able to acquire the lock we |
| 35822 | 35944 | ** want without having to go throught the ascending lock |
| 35823 | 35945 | ** procedure that follows. Just be sure not to block. |
| 35824 | 35946 | */ |
| 35825 | 35947 | if( sqlite3_mutex_try(p->pBt->mutex)==SQLITE_OK ){ |
| 35948 | + p->pBt->db = p->db; | |
| 35826 | 35949 | p->locked = 1; |
| 35827 | 35950 | return; |
| 35828 | 35951 | } |
| 35829 | 35952 | |
| 35830 | 35953 | /* To avoid deadlock, first release all locks with a larger |
| @@ -35835,20 +35958,17 @@ | ||
| 35835 | 35958 | for(pLater=p->pNext; pLater; pLater=pLater->pNext){ |
| 35836 | 35959 | assert( pLater->sharable ); |
| 35837 | 35960 | assert( pLater->pNext==0 || pLater->pNext->pBt>pLater->pBt ); |
| 35838 | 35961 | assert( !pLater->locked || pLater->wantToLock>0 ); |
| 35839 | 35962 | if( pLater->locked ){ |
| 35840 | - sqlite3_mutex_leave(pLater->pBt->mutex); | |
| 35841 | - pLater->locked = 0; | |
| 35963 | + unlockBtreeMutex(pLater); | |
| 35842 | 35964 | } |
| 35843 | 35965 | } |
| 35844 | - sqlite3_mutex_enter(p->pBt->mutex); | |
| 35845 | - p->locked = 1; | |
| 35966 | + lockBtreeMutex(p); | |
| 35846 | 35967 | for(pLater=p->pNext; pLater; pLater=pLater->pNext){ |
| 35847 | 35968 | if( pLater->wantToLock ){ |
| 35848 | - sqlite3_mutex_enter(pLater->pBt->mutex); | |
| 35849 | - pLater->locked = 1; | |
| 35969 | + lockBtreeMutex(pLater); | |
| 35850 | 35970 | } |
| 35851 | 35971 | } |
| 35852 | 35972 | } |
| 35853 | 35973 | |
| 35854 | 35974 | /* |
| @@ -35857,29 +35977,29 @@ | ||
| 35857 | 35977 | SQLITE_PRIVATE void sqlite3BtreeLeave(Btree *p){ |
| 35858 | 35978 | if( p->sharable ){ |
| 35859 | 35979 | assert( p->wantToLock>0 ); |
| 35860 | 35980 | p->wantToLock--; |
| 35861 | 35981 | if( p->wantToLock==0 ){ |
| 35862 | - assert( p->locked ); | |
| 35863 | - sqlite3_mutex_leave(p->pBt->mutex); | |
| 35864 | - p->locked = 0; | |
| 35982 | + unlockBtreeMutex(p); | |
| 35865 | 35983 | } |
| 35866 | 35984 | } |
| 35867 | 35985 | } |
| 35868 | 35986 | |
| 35869 | 35987 | #ifndef NDEBUG |
| 35870 | 35988 | /* |
| 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. | |
| 35875 | 35991 | ** |
| 35876 | 35992 | ** This routine is used only from within assert() statements. |
| 35877 | 35993 | */ |
| 35878 | 35994 | 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); | |
| 35881 | 36001 | } |
| 35882 | 36002 | #endif |
| 35883 | 36003 | |
| 35884 | 36004 | |
| 35885 | 36005 | #ifndef SQLITE_OMIT_INCRBLOB |
| @@ -35915,25 +36035,24 @@ | ||
| 35915 | 36035 | int i; |
| 35916 | 36036 | Btree *p, *pLater; |
| 35917 | 36037 | assert( sqlite3_mutex_held(db->mutex) ); |
| 35918 | 36038 | for(i=0; i<db->nDb; i++){ |
| 35919 | 36039 | p = db->aDb[i].pBt; |
| 36040 | + assert( !p || (p->locked==0 && p->sharable) || p->pBt->db==p->db ); | |
| 35920 | 36041 | if( p && p->sharable ){ |
| 35921 | 36042 | p->wantToLock++; |
| 35922 | 36043 | if( !p->locked ){ |
| 35923 | 36044 | assert( p->wantToLock==1 ); |
| 35924 | 36045 | while( p->pPrev ) p = p->pPrev; |
| 35925 | 36046 | while( p->locked && p->pNext ) p = p->pNext; |
| 35926 | 36047 | for(pLater = p->pNext; pLater; pLater=pLater->pNext){ |
| 35927 | 36048 | if( pLater->locked ){ |
| 35928 | - sqlite3_mutex_leave(pLater->pBt->mutex); | |
| 35929 | - pLater->locked = 0; | |
| 36049 | + unlockBtreeMutex(pLater); | |
| 35930 | 36050 | } |
| 35931 | 36051 | } |
| 35932 | 36052 | while( p ){ |
| 35933 | - sqlite3_mutex_enter(p->pBt->mutex); | |
| 35934 | - p->locked++; | |
| 36053 | + lockBtreeMutex(p); | |
| 35935 | 36054 | p = p->pNext; |
| 35936 | 36055 | } |
| 35937 | 36056 | } |
| 35938 | 36057 | } |
| 35939 | 36058 | } |
| @@ -35946,13 +36065,11 @@ | ||
| 35946 | 36065 | p = db->aDb[i].pBt; |
| 35947 | 36066 | if( p && p->sharable ){ |
| 35948 | 36067 | assert( p->wantToLock>0 ); |
| 35949 | 36068 | p->wantToLock--; |
| 35950 | 36069 | if( p->wantToLock==0 ){ |
| 35951 | - assert( p->locked ); | |
| 35952 | - sqlite3_mutex_leave(p->pBt->mutex); | |
| 35953 | - p->locked = 0; | |
| 36070 | + unlockBtreeMutex(p); | |
| 35954 | 36071 | } |
| 35955 | 36072 | } |
| 35956 | 36073 | } |
| 35957 | 36074 | } |
| 35958 | 36075 | |
| @@ -36037,12 +36154,11 @@ | ||
| 36037 | 36154 | /* We should already hold a lock on the database connection */ |
| 36038 | 36155 | assert( sqlite3_mutex_held(p->db->mutex) ); |
| 36039 | 36156 | |
| 36040 | 36157 | p->wantToLock++; |
| 36041 | 36158 | if( !p->locked && p->sharable ){ |
| 36042 | - sqlite3_mutex_enter(p->pBt->mutex); | |
| 36043 | - p->locked = 1; | |
| 36159 | + lockBtreeMutex(p); | |
| 36044 | 36160 | } |
| 36045 | 36161 | } |
| 36046 | 36162 | } |
| 36047 | 36163 | |
| 36048 | 36164 | /* |
| @@ -36060,18 +36176,30 @@ | ||
| 36060 | 36176 | /* We should already hold a lock on the database connection */ |
| 36061 | 36177 | assert( sqlite3_mutex_held(p->db->mutex) ); |
| 36062 | 36178 | |
| 36063 | 36179 | p->wantToLock--; |
| 36064 | 36180 | if( p->wantToLock==0 && p->locked ){ |
| 36065 | - sqlite3_mutex_leave(p->pBt->mutex); | |
| 36066 | - p->locked = 0; | |
| 36181 | + unlockBtreeMutex(p); | |
| 36067 | 36182 | } |
| 36068 | 36183 | } |
| 36069 | 36184 | } |
| 36070 | 36185 | |
| 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 */ | |
| 36073 | 36201 | |
| 36074 | 36202 | /************** End of btmutex.c *********************************************/ |
| 36075 | 36203 | /************** Begin file btree.c *******************************************/ |
| 36076 | 36204 | /* |
| 36077 | 36205 | ** 2004 April 6 |
| @@ -36082,11 +36210,11 @@ | ||
| 36082 | 36210 | ** May you do good and not evil. |
| 36083 | 36211 | ** May you find forgiveness for yourself and forgive others. |
| 36084 | 36212 | ** May you share freely, never taking more than you give. |
| 36085 | 36213 | ** |
| 36086 | 36214 | ************************************************************************* |
| 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 $ | |
| 36088 | 36216 | ** |
| 36089 | 36217 | ** This file implements a external (disk-based) database using BTrees. |
| 36090 | 36218 | ** See the header comment on "btreeInt.h" for additional information. |
| 36091 | 36219 | ** Including a description of file format and an overview of operation. |
| 36092 | 36220 | */ |
| @@ -36175,10 +36303,17 @@ | ||
| 36175 | 36303 | |
| 36176 | 36304 | assert( sqlite3BtreeHoldsMutex(p) ); |
| 36177 | 36305 | assert( eLock==READ_LOCK || eLock==WRITE_LOCK ); |
| 36178 | 36306 | assert( p->db!=0 ); |
| 36179 | 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 | + | |
| 36180 | 36315 | /* This is a no-op if the shared-cache is not enabled */ |
| 36181 | 36316 | if( !p->sharable ){ |
| 36182 | 36317 | return SQLITE_OK; |
| 36183 | 36318 | } |
| 36184 | 36319 | |
| @@ -36210,12 +36345,22 @@ | ||
| 36210 | 36345 | 0==(p->db->flags&SQLITE_ReadUncommitted) || |
| 36211 | 36346 | eLock==WRITE_LOCK || |
| 36212 | 36347 | iTab==MASTER_ROOT |
| 36213 | 36348 | ){ |
| 36214 | 36349 | 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 ){ | |
| 36217 | 36362 | sqlite3ConnectionBlocked(p->db, pIter->pBtree->db); |
| 36218 | 36363 | if( eLock==WRITE_LOCK ){ |
| 36219 | 36364 | assert( p==pBt->pWriter ); |
| 36220 | 36365 | pBt->isPending = 1; |
| 36221 | 36366 | } |
| @@ -36303,21 +36448,27 @@ | ||
| 36303 | 36448 | |
| 36304 | 36449 | #ifndef SQLITE_OMIT_SHARED_CACHE |
| 36305 | 36450 | /* |
| 36306 | 36451 | ** Release all the table locks (locks obtained via calls to |
| 36307 | 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. | |
| 36308 | 36457 | */ |
| 36309 | 36458 | static void clearAllSharedCacheTableLocks(Btree *p){ |
| 36310 | 36459 | BtShared *pBt = p->pBt; |
| 36311 | 36460 | BtLock **ppIter = &pBt->pLock; |
| 36312 | 36461 | |
| 36313 | 36462 | assert( sqlite3BtreeHoldsMutex(p) ); |
| 36314 | 36463 | assert( p->sharable || 0==*ppIter ); |
| 36464 | + assert( p->inTrans>0 ); | |
| 36315 | 36465 | |
| 36316 | 36466 | while( *ppIter ){ |
| 36317 | 36467 | BtLock *pLock = *ppIter; |
| 36318 | 36468 | assert( pBt->isExclusive==0 || pBt->pWriter==pLock->pBtree ); |
| 36469 | + assert( pLock->pBtree->inTrans>=pLock->eLock ); | |
| 36319 | 36470 | if( pLock->pBtree==p ){ |
| 36320 | 36471 | *ppIter = pLock->pNext; |
| 36321 | 36472 | sqlite3_free(pLock); |
| 36322 | 36473 | }else{ |
| 36323 | 36474 | ppIter = &pLock->pNext; |
| @@ -36920,76 +37071,78 @@ | ||
| 36920 | 37071 | } |
| 36921 | 37072 | return SQLITE_OK; |
| 36922 | 37073 | } |
| 36923 | 37074 | |
| 36924 | 37075 | /* |
| 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. | |
| 36935 | 37089 | */ |
| 36936 | 37090 | 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 */ | |
| 36940 | 37094 | int top; |
| 36941 | - int nCell; | |
| 36942 | - int cellOffset; | |
| 36943 | - unsigned char *data; | |
| 36944 | 37095 | |
| 36945 | - data = pPage->aData; | |
| 36946 | 37096 | assert( sqlite3PagerIswriteable(pPage->pDbPage) ); |
| 36947 | 37097 | assert( pPage->pBt ); |
| 36948 | 37098 | assert( sqlite3_mutex_held(pPage->pBt->mutex) ); |
| 36949 | 37099 | assert( nByte>=0 ); /* Minimum cell size is 4 */ |
| 36950 | 37100 | assert( pPage->nFree>=nByte ); |
| 36951 | 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 | + | |
| 36952 | 37110 | pPage->nFree -= (u16)nByte; |
| 36953 | - hdr = pPage->hdrOffset; | |
| 36954 | - | |
| 36955 | 37111 | 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 */ | |
| 36962 | 37122 | if( size>=nByte ){ |
| 36963 | 37123 | 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. */ | |
| 36965 | 37127 | memcpy(&data[addr], &data[pc], 2); |
| 36966 | 37128 | data[hdr+7] = (u8)(nFrag + x); |
| 36967 | - return pc; | |
| 36968 | 37129 | }else{ |
| 37130 | + /* The slot remains on the free-list. Reduce its size to account | |
| 37131 | + ** for the portion used by the new allocation. */ | |
| 36969 | 37132 | put2byte(&data[pc+2], x); |
| 36970 | - return pc + x; | |
| 36971 | 37133 | } |
| 37134 | + return pc + x; | |
| 36972 | 37135 | } |
| 36973 | - addr = pc; | |
| 36974 | 37136 | } |
| 36975 | 37137 | } |
| 36976 | 37138 | |
| 36977 | 37139 | /* Allocate memory from the gap in between the cell pointer array |
| 36978 | 37140 | ** and the cell content area. |
| 36979 | 37141 | */ |
| 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; | |
| 36989 | 37143 | put2byte(&data[hdr+5], top); |
| 36990 | - assert( sqlite3PagerIswriteable(pPage->pDbPage) ); | |
| 36991 | 37144 | return top; |
| 36992 | 37145 | } |
| 36993 | 37146 | |
| 36994 | 37147 | /* |
| 36995 | 37148 | ** Return a section of the pPage->aData to the freelist. |
| @@ -37373,14 +37526,15 @@ | ||
| 37373 | 37526 | ** page to agree with the restored data. |
| 37374 | 37527 | */ |
| 37375 | 37528 | static void pageReinit(DbPage *pData){ |
| 37376 | 37529 | MemPage *pPage; |
| 37377 | 37530 | pPage = (MemPage *)sqlite3PagerGetExtra(pData); |
| 37531 | + assert( sqlite3PagerPageRefcount(pData)>0 ); | |
| 37378 | 37532 | if( pPage->isInit ){ |
| 37379 | 37533 | assert( sqlite3_mutex_held(pPage->pBt->mutex) ); |
| 37380 | 37534 | pPage->isInit = 0; |
| 37381 | - if( sqlite3PagerPageRefcount(pData)>0 ){ | |
| 37535 | + if( sqlite3PagerPageRefcount(pData)>1 ){ | |
| 37382 | 37536 | /* pPage might not be a btree page; it might be an overflow page |
| 37383 | 37537 | ** or ptrmap page or a free page. In those cases, the following |
| 37384 | 37538 | ** call to sqlite3BtreeInitPage() will likely return SQLITE_CORRUPT. |
| 37385 | 37539 | ** But no harm is done by this. And it is very important that |
| 37386 | 37540 | ** sqlite3BtreeInitPage() be called on every btree page so we make |
| @@ -37451,14 +37605,11 @@ | ||
| 37451 | 37605 | #if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO) |
| 37452 | 37606 | /* |
| 37453 | 37607 | ** If this Btree is a candidate for shared cache, try to find an |
| 37454 | 37608 | ** existing BtShared object that we can share with |
| 37455 | 37609 | */ |
| 37456 | - if( isMemdb==0 | |
| 37457 | - && (db->flags & SQLITE_Vtab)==0 | |
| 37458 | - && zFilename && zFilename[0] | |
| 37459 | - ){ | |
| 37610 | + if( isMemdb==0 && zFilename && zFilename[0] ){ | |
| 37460 | 37611 | if( sqlite3GlobalConfig.sharedCacheEnabled ){ |
| 37461 | 37612 | int nFullPathname = pVfs->mxPathname+1; |
| 37462 | 37613 | char *zFullPathname = sqlite3Malloc(nFullPathname); |
| 37463 | 37614 | sqlite3_mutex *mutexShared; |
| 37464 | 37615 | p->sharable = 1; |
| @@ -37519,10 +37670,11 @@ | ||
| 37519 | 37670 | rc = sqlite3PagerReadFileheader(pBt->pPager,sizeof(zDbHeader),zDbHeader); |
| 37520 | 37671 | } |
| 37521 | 37672 | if( rc!=SQLITE_OK ){ |
| 37522 | 37673 | goto btree_open_out; |
| 37523 | 37674 | } |
| 37675 | + pBt->db = db; | |
| 37524 | 37676 | sqlite3PagerSetBusyhandler(pBt->pPager, btreeInvokeBusyHandler, pBt); |
| 37525 | 37677 | p->pBt = pBt; |
| 37526 | 37678 | |
| 37527 | 37679 | sqlite3PagerSetReiniter(pBt->pPager, pageReinit); |
| 37528 | 37680 | pBt->pCursor = 0; |
| @@ -37696,11 +37848,10 @@ | ||
| 37696 | 37848 | BtCursor *pCur; |
| 37697 | 37849 | |
| 37698 | 37850 | /* Close all cursors opened via this handle. */ |
| 37699 | 37851 | assert( sqlite3_mutex_held(p->db->mutex) ); |
| 37700 | 37852 | sqlite3BtreeEnter(p); |
| 37701 | - pBt->db = p->db; | |
| 37702 | 37853 | pCur = pBt->pCursor; |
| 37703 | 37854 | while( pCur ){ |
| 37704 | 37855 | BtCursor *pTmp = pCur; |
| 37705 | 37856 | pCur = pCur->pNext; |
| 37706 | 37857 | if( pTmp->pBtree==p ){ |
| @@ -37806,10 +37957,12 @@ | ||
| 37806 | 37957 | } |
| 37807 | 37958 | |
| 37808 | 37959 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) || !defined(SQLITE_OMIT_VACUUM) |
| 37809 | 37960 | /* |
| 37810 | 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. | |
| 37811 | 37964 | ** |
| 37812 | 37965 | ** The page size must be a power of 2 between 512 and 65536. If the page |
| 37813 | 37966 | ** size supplied does not meet this constraint then the page size is not |
| 37814 | 37967 | ** changed. |
| 37815 | 37968 | ** |
| @@ -37818,12 +37971,15 @@ | ||
| 37818 | 37971 | ** the first byte past the 1GB boundary, 0x40000000) needs to occur |
| 37819 | 37972 | ** at the beginning of a page. |
| 37820 | 37973 | ** |
| 37821 | 37974 | ** If parameter nReserve is less than zero, then the number of reserved |
| 37822 | 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. | |
| 37823 | 37979 | */ |
| 37824 | -SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int pageSize, int nReserve){ | |
| 37980 | +SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int pageSize, int nReserve, int iFix){ | |
| 37825 | 37981 | int rc = SQLITE_OK; |
| 37826 | 37982 | BtShared *pBt = p->pBt; |
| 37827 | 37983 | assert( nReserve>=-1 && nReserve<=255 ); |
| 37828 | 37984 | sqlite3BtreeEnter(p); |
| 37829 | 37985 | if( pBt->pageSizeFixed ){ |
| @@ -37841,10 +37997,11 @@ | ||
| 37841 | 37997 | pBt->pageSize = (u16)pageSize; |
| 37842 | 37998 | freeTempSpace(pBt); |
| 37843 | 37999 | rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize); |
| 37844 | 38000 | } |
| 37845 | 38001 | pBt->usableSize = pBt->pageSize - (u16)nReserve; |
| 38002 | + if( iFix ) pBt->pageSizeFixed = 1; | |
| 37846 | 38003 | sqlite3BtreeLeave(p); |
| 37847 | 38004 | return rc; |
| 37848 | 38005 | } |
| 37849 | 38006 | |
| 37850 | 38007 | /* |
| @@ -37941,11 +38098,11 @@ | ||
| 37941 | 38098 | int rc; |
| 37942 | 38099 | MemPage *pPage1; |
| 37943 | 38100 | int nPage; |
| 37944 | 38101 | |
| 37945 | 38102 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 37946 | - if( pBt->pPage1 ) return SQLITE_OK; | |
| 38103 | + assert( pBt->pPage1==0 ); | |
| 37947 | 38104 | rc = sqlite3BtreeGetPage(pBt, 1, &pPage1, 0); |
| 37948 | 38105 | if( rc!=SQLITE_OK ) return rc; |
| 37949 | 38106 | |
| 37950 | 38107 | /* Do some checking to help insure the file we opened really is |
| 37951 | 38108 | ** a valid database file. |
| @@ -38169,11 +38326,10 @@ | ||
| 38169 | 38326 | sqlite3 *pBlock = 0; |
| 38170 | 38327 | BtShared *pBt = p->pBt; |
| 38171 | 38328 | int rc = SQLITE_OK; |
| 38172 | 38329 | |
| 38173 | 38330 | sqlite3BtreeEnter(p); |
| 38174 | - pBt->db = p->db; | |
| 38175 | 38331 | btreeIntegrity(p); |
| 38176 | 38332 | |
| 38177 | 38333 | /* If the btree is already in a write-transaction, or it |
| 38178 | 38334 | ** is already in a read-transaction and a read-transaction |
| 38179 | 38335 | ** is requested, this is a no-op. |
| @@ -38210,15 +38366,18 @@ | ||
| 38210 | 38366 | goto trans_begun; |
| 38211 | 38367 | } |
| 38212 | 38368 | #endif |
| 38213 | 38369 | |
| 38214 | 38370 | 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)) ); | |
| 38220 | 38379 | |
| 38221 | 38380 | if( rc==SQLITE_OK && wrflag ){ |
| 38222 | 38381 | if( pBt->readOnly ){ |
| 38223 | 38382 | rc = SQLITE_READONLY; |
| 38224 | 38383 | }else{ |
| @@ -38313,11 +38472,11 @@ | ||
| 38313 | 38472 | pPage->isInit = isInitOrig; |
| 38314 | 38473 | return rc; |
| 38315 | 38474 | } |
| 38316 | 38475 | |
| 38317 | 38476 | /* |
| 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 | |
| 38319 | 38478 | ** page, is a pointer to page iFrom. Modify this pointer so that it points to |
| 38320 | 38479 | ** iTo. Parameter eType describes the type of pointer to be modified, as |
| 38321 | 38480 | ** follows: |
| 38322 | 38481 | ** |
| 38323 | 38482 | ** PTRMAP_BTREE: pPage is a btree-page. The pointer points at a child |
| @@ -38476,18 +38635,19 @@ | ||
| 38476 | 38635 | */ |
| 38477 | 38636 | static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg){ |
| 38478 | 38637 | Pgno nFreeList; /* Number of pages still on the free-list */ |
| 38479 | 38638 | |
| 38480 | 38639 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 38640 | + assert( iLastPg>nFin ); | |
| 38481 | 38641 | |
| 38482 | 38642 | if( !PTRMAP_ISPAGE(pBt, iLastPg) && iLastPg!=PENDING_BYTE_PAGE(pBt) ){ |
| 38483 | 38643 | int rc; |
| 38484 | 38644 | u8 eType; |
| 38485 | 38645 | Pgno iPtrPage; |
| 38486 | 38646 | |
| 38487 | 38647 | nFreeList = get4byte(&pBt->pPage1->aData[36]); |
| 38488 | - if( nFreeList==0 || nFin==iLastPg ){ | |
| 38648 | + if( nFreeList==0 ){ | |
| 38489 | 38649 | return SQLITE_DONE; |
| 38490 | 38650 | } |
| 38491 | 38651 | |
| 38492 | 38652 | rc = ptrmapGet(pBt, iLastPg, &eType, &iPtrPage); |
| 38493 | 38653 | if( rc!=SQLITE_OK ){ |
| @@ -38584,11 +38744,10 @@ | ||
| 38584 | 38744 | SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *p){ |
| 38585 | 38745 | int rc; |
| 38586 | 38746 | BtShared *pBt = p->pBt; |
| 38587 | 38747 | |
| 38588 | 38748 | sqlite3BtreeEnter(p); |
| 38589 | - pBt->db = p->db; | |
| 38590 | 38749 | assert( pBt->inTransaction==TRANS_WRITE && p->inTrans==TRANS_WRITE ); |
| 38591 | 38750 | if( !pBt->autoVacuum ){ |
| 38592 | 38751 | rc = SQLITE_DONE; |
| 38593 | 38752 | }else{ |
| 38594 | 38753 | invalidateAllOverflowCache(pBt); |
| @@ -38621,20 +38780,22 @@ | ||
| 38621 | 38780 | Pgno nPtrmap; |
| 38622 | 38781 | Pgno iFree; |
| 38623 | 38782 | const int pgsz = pBt->pageSize; |
| 38624 | 38783 | Pgno nOrig = pagerPagecount(pBt); |
| 38625 | 38784 | |
| 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 | + */ | |
| 38627 | 38790 | return SQLITE_CORRUPT_BKPT; |
| 38628 | 38791 | } |
| 38629 | - if( nOrig==PENDING_BYTE_PAGE(pBt) ){ | |
| 38630 | - nOrig--; | |
| 38631 | - } | |
| 38792 | + | |
| 38632 | 38793 | nFree = get4byte(&pBt->pPage1->aData[36]); |
| 38633 | 38794 | nPtrmap = (nFree-nOrig+PTRMAP_PAGENO(pBt, nOrig)+pgsz/5)/(pgsz/5); |
| 38634 | 38795 | 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) ){ | |
| 38636 | 38797 | nFin--; |
| 38637 | 38798 | } |
| 38638 | 38799 | while( PTRMAP_ISPAGE(pBt, nFin) || nFin==PENDING_BYTE_PAGE(pBt) ){ |
| 38639 | 38800 | nFin--; |
| 38640 | 38801 | } |
| @@ -38689,11 +38850,10 @@ | ||
| 38689 | 38850 | SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree *p, const char *zMaster){ |
| 38690 | 38851 | int rc = SQLITE_OK; |
| 38691 | 38852 | if( p->inTrans==TRANS_WRITE ){ |
| 38692 | 38853 | BtShared *pBt = p->pBt; |
| 38693 | 38854 | sqlite3BtreeEnter(p); |
| 38694 | - pBt->db = p->db; | |
| 38695 | 38855 | #ifndef SQLITE_OMIT_AUTOVACUUM |
| 38696 | 38856 | if( pBt->autoVacuum ){ |
| 38697 | 38857 | rc = autoVacuumCommit(pBt); |
| 38698 | 38858 | if( rc!=SQLITE_OK ){ |
| 38699 | 38859 | sqlite3BtreeLeave(p); |
| @@ -38723,11 +38883,10 @@ | ||
| 38723 | 38883 | */ |
| 38724 | 38884 | SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree *p){ |
| 38725 | 38885 | BtShared *pBt = p->pBt; |
| 38726 | 38886 | |
| 38727 | 38887 | sqlite3BtreeEnter(p); |
| 38728 | - pBt->db = p->db; | |
| 38729 | 38888 | btreeIntegrity(p); |
| 38730 | 38889 | |
| 38731 | 38890 | /* If the handle has a write-transaction open, commit the shared-btrees |
| 38732 | 38891 | ** transaction and set the shared state to TRANS_READ. |
| 38733 | 38892 | */ |
| @@ -38740,18 +38899,18 @@ | ||
| 38740 | 38899 | sqlite3BtreeLeave(p); |
| 38741 | 38900 | return rc; |
| 38742 | 38901 | } |
| 38743 | 38902 | pBt->inTransaction = TRANS_READ; |
| 38744 | 38903 | } |
| 38745 | - clearAllSharedCacheTableLocks(p); | |
| 38746 | 38904 | |
| 38747 | 38905 | /* If the handle has any kind of transaction open, decrement the transaction |
| 38748 | 38906 | ** count of the shared btree. If the transaction count reaches 0, set |
| 38749 | 38907 | ** the shared state to TRANS_NONE. The unlockBtreeIfUnused() call below |
| 38750 | 38908 | ** will unlock the pager. |
| 38751 | 38909 | */ |
| 38752 | 38910 | if( p->inTrans!=TRANS_NONE ){ |
| 38911 | + clearAllSharedCacheTableLocks(p); | |
| 38753 | 38912 | pBt->nTransaction--; |
| 38754 | 38913 | if( 0==pBt->nTransaction ){ |
| 38755 | 38914 | pBt->inTransaction = TRANS_NONE; |
| 38756 | 38915 | } |
| 38757 | 38916 | } |
| @@ -38849,11 +39008,10 @@ | ||
| 38849 | 39008 | int rc; |
| 38850 | 39009 | BtShared *pBt = p->pBt; |
| 38851 | 39010 | MemPage *pPage1; |
| 38852 | 39011 | |
| 38853 | 39012 | sqlite3BtreeEnter(p); |
| 38854 | - pBt->db = p->db; | |
| 38855 | 39013 | rc = saveAllCursors(pBt, 0, 0); |
| 38856 | 39014 | #ifndef SQLITE_OMIT_SHARED_CACHE |
| 38857 | 39015 | if( rc!=SQLITE_OK ){ |
| 38858 | 39016 | /* This is a horrible situation. An IO or malloc() error occurred whilst |
| 38859 | 39017 | ** trying to save cursor positions. If this is an automatic rollback (as |
| @@ -38864,11 +39022,10 @@ | ||
| 38864 | 39022 | */ |
| 38865 | 39023 | sqlite3BtreeTripAllCursors(p, rc); |
| 38866 | 39024 | } |
| 38867 | 39025 | #endif |
| 38868 | 39026 | btreeIntegrity(p); |
| 38869 | - clearAllSharedCacheTableLocks(p); | |
| 38870 | 39027 | |
| 38871 | 39028 | if( p->inTrans==TRANS_WRITE ){ |
| 38872 | 39029 | int rc2; |
| 38873 | 39030 | |
| 38874 | 39031 | assert( TRANS_WRITE==pBt->inTransaction ); |
| @@ -38886,10 +39043,11 @@ | ||
| 38886 | 39043 | assert( countWriteCursors(pBt)==0 ); |
| 38887 | 39044 | pBt->inTransaction = TRANS_READ; |
| 38888 | 39045 | } |
| 38889 | 39046 | |
| 38890 | 39047 | if( p->inTrans!=TRANS_NONE ){ |
| 39048 | + clearAllSharedCacheTableLocks(p); | |
| 38891 | 39049 | assert( pBt->nTransaction>0 ); |
| 38892 | 39050 | pBt->nTransaction--; |
| 38893 | 39051 | if( 0==pBt->nTransaction ){ |
| 38894 | 39052 | pBt->inTransaction = TRANS_NONE; |
| 38895 | 39053 | } |
| @@ -38924,11 +39082,10 @@ | ||
| 38924 | 39082 | */ |
| 38925 | 39083 | SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree *p, int iStatement){ |
| 38926 | 39084 | int rc; |
| 38927 | 39085 | BtShared *pBt = p->pBt; |
| 38928 | 39086 | sqlite3BtreeEnter(p); |
| 38929 | - pBt->db = p->db; | |
| 38930 | 39087 | assert( p->inTrans==TRANS_WRITE ); |
| 38931 | 39088 | assert( pBt->readOnly==0 ); |
| 38932 | 39089 | assert( iStatement>0 ); |
| 38933 | 39090 | assert( iStatement>p->db->nSavepoint ); |
| 38934 | 39091 | if( NEVER(p->inTrans!=TRANS_WRITE || pBt->readOnly) ){ |
| @@ -38963,11 +39120,10 @@ | ||
| 38963 | 39120 | if( p && p->inTrans==TRANS_WRITE ){ |
| 38964 | 39121 | BtShared *pBt = p->pBt; |
| 38965 | 39122 | assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK ); |
| 38966 | 39123 | assert( iSavepoint>=0 || (iSavepoint==-1 && op==SAVEPOINT_ROLLBACK) ); |
| 38967 | 39124 | sqlite3BtreeEnter(p); |
| 38968 | - pBt->db = p->db; | |
| 38969 | 39125 | rc = sqlite3PagerSavepoint(pBt->pPager, op, iSavepoint); |
| 38970 | 39126 | if( rc==SQLITE_OK ){ |
| 38971 | 39127 | rc = newDatabase(pBt); |
| 38972 | 39128 | } |
| 38973 | 39129 | sqlite3BtreeLeave(p); |
| @@ -39080,11 +39236,10 @@ | ||
| 39080 | 39236 | struct KeyInfo *pKeyInfo, /* First arg to xCompare() */ |
| 39081 | 39237 | BtCursor *pCur /* Write new cursor here */ |
| 39082 | 39238 | ){ |
| 39083 | 39239 | int rc; |
| 39084 | 39240 | sqlite3BtreeEnter(p); |
| 39085 | - p->pBt->db = p->db; | |
| 39086 | 39241 | rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur); |
| 39087 | 39242 | sqlite3BtreeLeave(p); |
| 39088 | 39243 | return rc; |
| 39089 | 39244 | } |
| 39090 | 39245 | |
| @@ -39138,11 +39293,10 @@ | ||
| 39138 | 39293 | Btree *pBtree = pCur->pBtree; |
| 39139 | 39294 | if( pBtree ){ |
| 39140 | 39295 | int i; |
| 39141 | 39296 | BtShared *pBt = pCur->pBt; |
| 39142 | 39297 | sqlite3BtreeEnter(pBtree); |
| 39143 | - pBt->db = pBtree->db; | |
| 39144 | 39298 | sqlite3BtreeClearCursor(pCur); |
| 39145 | 39299 | if( pCur->pPrev ){ |
| 39146 | 39300 | pCur->pPrev->pNext = pCur->pNext; |
| 39147 | 39301 | }else{ |
| 39148 | 39302 | pBt->pCursor = pCur->pNext; |
| @@ -40116,11 +40270,12 @@ | ||
| 40116 | 40270 | int bias, /* Bias search to the high end */ |
| 40117 | 40271 | int *pRes /* Write search results here */ |
| 40118 | 40272 | ){ |
| 40119 | 40273 | int rc; /* Status code */ |
| 40120 | 40274 | 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 | + | |
| 40122 | 40277 | |
| 40123 | 40278 | if( pKey ){ |
| 40124 | 40279 | assert( nKey==(i64)(int)nKey ); |
| 40125 | 40280 | pIdxKey = sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey, |
| 40126 | 40281 | aSpace, sizeof(aSpace)); |
| @@ -40717,11 +40872,14 @@ | ||
| 40717 | 40872 | nOvfl = (info.nPayload - info.nLocal + ovflPageSize - 1)/ovflPageSize; |
| 40718 | 40873 | assert( ovflPgno==0 || nOvfl>0 ); |
| 40719 | 40874 | while( nOvfl-- ){ |
| 40720 | 40875 | Pgno iNext = 0; |
| 40721 | 40876 | 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. */ | |
| 40723 | 40881 | return SQLITE_CORRUPT_BKPT; |
| 40724 | 40882 | } |
| 40725 | 40883 | if( nOvfl ){ |
| 40726 | 40884 | rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext); |
| 40727 | 40885 | if( rc ) return rc; |
| @@ -41396,17 +41554,17 @@ | ||
| 41396 | 41554 | rc = SQLITE_NOMEM; |
| 41397 | 41555 | goto balance_cleanup; |
| 41398 | 41556 | } |
| 41399 | 41557 | szCell = (u16*)&apCell[nMaxCells]; |
| 41400 | 41558 | aCopy[0] = (u8*)&szCell[nMaxCells]; |
| 41401 | - assert( ((aCopy[0] - (u8*)0) & 7)==0 ); /* 8-byte alignment required */ | |
| 41559 | + assert( EIGHT_BYTE_ALIGNMENT(aCopy[0]) ); | |
| 41402 | 41560 | for(i=1; i<NB; i++){ |
| 41403 | 41561 | aCopy[i] = &aCopy[i-1][pBt->pageSize+ROUND8(sizeof(MemPage))]; |
| 41404 | 41562 | assert( ((aCopy[i] - (u8*)0) & 7)==0 ); /* 8-byte alignment required */ |
| 41405 | 41563 | } |
| 41406 | 41564 | 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) ); | |
| 41408 | 41566 | if( ISAUTOVACUUM ){ |
| 41409 | 41567 | aFrom = &aSpace1[pBt->pageSize]; |
| 41410 | 41568 | } |
| 41411 | 41569 | aSpace2 = sqlite3PageMalloc(pBt->pageSize); |
| 41412 | 41570 | if( aSpace2==0 ){ |
| @@ -42388,12 +42546,12 @@ | ||
| 42388 | 42546 | rc = saveCursorPosition(&leafCur); |
| 42389 | 42547 | if( rc==SQLITE_OK ){ |
| 42390 | 42548 | rc = sqlite3BtreeNext(&leafCur, ¬Used); |
| 42391 | 42549 | } |
| 42392 | 42550 | 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 ); | |
| 42395 | 42553 | } |
| 42396 | 42554 | |
| 42397 | 42555 | if( SQLITE_OK==rc |
| 42398 | 42556 | && SQLITE_OK==(rc = sqlite3PagerWrite(pLeafPage->pDbPage)) |
| 42399 | 42557 | ){ |
| @@ -42553,11 +42711,10 @@ | ||
| 42553 | 42711 | return SQLITE_OK; |
| 42554 | 42712 | } |
| 42555 | 42713 | SQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree *p, int *piTable, int flags){ |
| 42556 | 42714 | int rc; |
| 42557 | 42715 | sqlite3BtreeEnter(p); |
| 42558 | - p->pBt->db = p->db; | |
| 42559 | 42716 | rc = btreeCreateTable(p, piTable, flags); |
| 42560 | 42717 | sqlite3BtreeLeave(p); |
| 42561 | 42718 | return rc; |
| 42562 | 42719 | } |
| 42563 | 42720 | |
| @@ -42625,11 +42782,10 @@ | ||
| 42625 | 42782 | */ |
| 42626 | 42783 | SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){ |
| 42627 | 42784 | int rc; |
| 42628 | 42785 | BtShared *pBt = p->pBt; |
| 42629 | 42786 | sqlite3BtreeEnter(p); |
| 42630 | - pBt->db = p->db; | |
| 42631 | 42787 | assert( p->inTrans==TRANS_WRITE ); |
| 42632 | 42788 | if( (rc = checkForReadConflicts(p, iTable, 0, 1))!=SQLITE_OK ){ |
| 42633 | 42789 | /* nothing to do */ |
| 42634 | 42790 | }else if( SQLITE_OK!=(rc = saveAllCursors(pBt, iTable, 0)) ){ |
| 42635 | 42791 | /* nothing to do */ |
| @@ -42767,11 +42923,10 @@ | ||
| 42767 | 42923 | return rc; |
| 42768 | 42924 | } |
| 42769 | 42925 | SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree *p, int iTable, int *piMoved){ |
| 42770 | 42926 | int rc; |
| 42771 | 42927 | sqlite3BtreeEnter(p); |
| 42772 | - p->pBt->db = p->db; | |
| 42773 | 42928 | rc = btreeDropTable(p, iTable, piMoved); |
| 42774 | 42929 | sqlite3BtreeLeave(p); |
| 42775 | 42930 | return rc; |
| 42776 | 42931 | } |
| 42777 | 42932 | |
| @@ -42791,11 +42946,10 @@ | ||
| 42791 | 42946 | int rc; |
| 42792 | 42947 | unsigned char *pP1; |
| 42793 | 42948 | BtShared *pBt = p->pBt; |
| 42794 | 42949 | |
| 42795 | 42950 | sqlite3BtreeEnter(p); |
| 42796 | - pBt->db = p->db; | |
| 42797 | 42951 | |
| 42798 | 42952 | /* Reading a meta-data value requires a read-lock on page 1 (and hence |
| 42799 | 42953 | ** the sqlite_master table. We grab this lock regardless of whether or |
| 42800 | 42954 | ** not the SQLITE_ReadUncommitted flag is set (the table rooted at page |
| 42801 | 42955 | ** 1 is treated as a special case by querySharedCacheTableLock() |
| @@ -42840,12 +42994,18 @@ | ||
| 42840 | 42994 | */ |
| 42841 | 42995 | #ifdef SQLITE_OMIT_AUTOVACUUM |
| 42842 | 42996 | if( idx==4 && *pMeta>0 ) pBt->readOnly = 1; |
| 42843 | 42997 | #endif |
| 42844 | 42998 | |
| 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 | + } | |
| 42847 | 43007 | sqlite3BtreeLeave(p); |
| 42848 | 43008 | return rc; |
| 42849 | 43009 | } |
| 42850 | 43010 | |
| 42851 | 43011 | /* |
| @@ -42856,11 +43016,10 @@ | ||
| 42856 | 43016 | BtShared *pBt = p->pBt; |
| 42857 | 43017 | unsigned char *pP1; |
| 42858 | 43018 | int rc; |
| 42859 | 43019 | assert( idx>=1 && idx<=15 ); |
| 42860 | 43020 | sqlite3BtreeEnter(p); |
| 42861 | - pBt->db = p->db; | |
| 42862 | 43021 | assert( p->inTrans==TRANS_WRITE ); |
| 42863 | 43022 | assert( pBt->pPage1!=0 ); |
| 42864 | 43023 | pP1 = pBt->pPage1->aData; |
| 42865 | 43024 | rc = sqlite3PagerWrite(pBt->pPage1->pDbPage); |
| 42866 | 43025 | if( rc==SQLITE_OK ){ |
| @@ -43330,11 +43489,10 @@ | ||
| 43330 | 43489 | IntegrityCk sCheck; |
| 43331 | 43490 | BtShared *pBt = p->pBt; |
| 43332 | 43491 | char zErr[100]; |
| 43333 | 43492 | |
| 43334 | 43493 | sqlite3BtreeEnter(p); |
| 43335 | - pBt->db = p->db; | |
| 43336 | 43494 | nRef = sqlite3PagerRefcount(pBt->pPager); |
| 43337 | 43495 | if( lockBtreeWithRetry(p)!=SQLITE_OK ){ |
| 43338 | 43496 | *pnErr = 1; |
| 43339 | 43497 | sqlite3BtreeLeave(p); |
| 43340 | 43498 | return sqlite3DbStrDup(0, "cannot acquire a read lock on the database"); |
| @@ -44240,11 +44398,11 @@ | ||
| 44240 | 44398 | ** This file contains code use to manipulate "Mem" structure. A "Mem" |
| 44241 | 44399 | ** stores a single value in the VDBE. Mem is an opaque structure visible |
| 44242 | 44400 | ** only within the VDBE. Interface routines refer to a Mem using the |
| 44243 | 44401 | ** name sqlite_value |
| 44244 | 44402 | ** |
| 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 $ | |
| 44246 | 44404 | */ |
| 44247 | 44405 | |
| 44248 | 44406 | /* |
| 44249 | 44407 | ** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem*) |
| 44250 | 44408 | ** P if required. |
| @@ -44432,10 +44590,11 @@ | ||
| 44432 | 44590 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 44433 | 44591 | assert( !(fg&MEM_Zero) ); |
| 44434 | 44592 | assert( !(fg&(MEM_Str|MEM_Blob)) ); |
| 44435 | 44593 | assert( fg&(MEM_Int|MEM_Real) ); |
| 44436 | 44594 | assert( (pMem->flags&MEM_RowSet)==0 ); |
| 44595 | + assert( EIGHT_BYTE_ALIGNMENT(pMem) ); | |
| 44437 | 44596 | |
| 44438 | 44597 | |
| 44439 | 44598 | if( sqlite3VdbeMemGrow(pMem, nByte, 0) ){ |
| 44440 | 44599 | return SQLITE_NOMEM; |
| 44441 | 44600 | } |
| @@ -44568,10 +44727,11 @@ | ||
| 44568 | 44727 | ** If pMem represents a string value, its encoding might be changed. |
| 44569 | 44728 | */ |
| 44570 | 44729 | SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){ |
| 44571 | 44730 | int flags; |
| 44572 | 44731 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 44732 | + assert( EIGHT_BYTE_ALIGNMENT(pMem) ); | |
| 44573 | 44733 | flags = pMem->flags; |
| 44574 | 44734 | if( flags & MEM_Int ){ |
| 44575 | 44735 | return pMem->u.i; |
| 44576 | 44736 | }else if( flags & MEM_Real ){ |
| 44577 | 44737 | return doubleToInt64(pMem->r); |
| @@ -44596,10 +44756,11 @@ | ||
| 44596 | 44756 | ** value. If it is a string or blob, try to convert it to a double. |
| 44597 | 44757 | ** If it is a NULL, return 0.0. |
| 44598 | 44758 | */ |
| 44599 | 44759 | SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){ |
| 44600 | 44760 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 44761 | + assert( EIGHT_BYTE_ALIGNMENT(pMem) ); | |
| 44601 | 44762 | if( pMem->flags & MEM_Real ){ |
| 44602 | 44763 | return pMem->r; |
| 44603 | 44764 | }else if( pMem->flags & MEM_Int ){ |
| 44604 | 44765 | return (double)pMem->u.i; |
| 44605 | 44766 | }else if( pMem->flags & (MEM_Str|MEM_Blob) ){ |
| @@ -44626,10 +44787,11 @@ | ||
| 44626 | 44787 | */ |
| 44627 | 44788 | SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){ |
| 44628 | 44789 | assert( pMem->flags & MEM_Real ); |
| 44629 | 44790 | assert( (pMem->flags & MEM_RowSet)==0 ); |
| 44630 | 44791 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 44792 | + assert( EIGHT_BYTE_ALIGNMENT(pMem) ); | |
| 44631 | 44793 | |
| 44632 | 44794 | pMem->u.i = doubleToInt64(pMem->r); |
| 44633 | 44795 | if( pMem->r==(double)pMem->u.i ){ |
| 44634 | 44796 | pMem->flags |= MEM_Int; |
| 44635 | 44797 | } |
| @@ -44639,10 +44801,12 @@ | ||
| 44639 | 44801 | ** Convert pMem to type integer. Invalidate any prior representations. |
| 44640 | 44802 | */ |
| 44641 | 44803 | SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){ |
| 44642 | 44804 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 44643 | 44805 | assert( (pMem->flags & MEM_RowSet)==0 ); |
| 44806 | + assert( EIGHT_BYTE_ALIGNMENT(pMem) ); | |
| 44807 | + | |
| 44644 | 44808 | pMem->u.i = sqlite3VdbeIntValue(pMem); |
| 44645 | 44809 | MemSetTypeFlag(pMem, MEM_Int); |
| 44646 | 44810 | return SQLITE_OK; |
| 44647 | 44811 | } |
| 44648 | 44812 | |
| @@ -44650,10 +44814,12 @@ | ||
| 44650 | 44814 | ** Convert pMem so that it is of type MEM_Real. |
| 44651 | 44815 | ** Invalidate any prior representations. |
| 44652 | 44816 | */ |
| 44653 | 44817 | SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){ |
| 44654 | 44818 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 44819 | + assert( EIGHT_BYTE_ALIGNMENT(pMem) ); | |
| 44820 | + | |
| 44655 | 44821 | pMem->r = sqlite3VdbeRealValue(pMem); |
| 44656 | 44822 | MemSetTypeFlag(pMem, MEM_Real); |
| 44657 | 44823 | return SQLITE_OK; |
| 44658 | 44824 | } |
| 44659 | 44825 | |
| @@ -45287,11 +45453,11 @@ | ||
| 45287 | 45453 | ** This file contains code used for creating, destroying, and populating |
| 45288 | 45454 | ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior |
| 45289 | 45455 | ** to version 2.8.7, all this code was combined into the vdbe.c source file. |
| 45290 | 45456 | ** But that file was getting too big so this subroutines were split out. |
| 45291 | 45457 | ** |
| 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 $ | |
| 45293 | 45459 | */ |
| 45294 | 45460 | |
| 45295 | 45461 | |
| 45296 | 45462 | |
| 45297 | 45463 | /* |
| @@ -46294,10 +46460,11 @@ | ||
| 46294 | 46460 | int nByte, /* Number of bytes to allocate */ |
| 46295 | 46461 | u8 **ppFrom, /* IN/OUT: Allocate from *ppFrom */ |
| 46296 | 46462 | u8 *pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */ |
| 46297 | 46463 | int *pnByte /* If allocation cannot be made, increment *pnByte */ |
| 46298 | 46464 | ){ |
| 46465 | + assert( EIGHT_BYTE_ALIGNMENT(*ppFrom) ); | |
| 46299 | 46466 | if( (*(void**)pp)==0 ){ |
| 46300 | 46467 | nByte = ROUND8(nByte); |
| 46301 | 46468 | if( (pEnd - *ppFrom)>=nByte ){ |
| 46302 | 46469 | *(void**)pp = (void *)*ppFrom; |
| 46303 | 46470 | *ppFrom += nByte; |
| @@ -46367,10 +46534,13 @@ | ||
| 46367 | 46534 | int nArg; /* Maximum number of args passed to a user function. */ |
| 46368 | 46535 | resolveP2Values(p, &nArg); |
| 46369 | 46536 | if( isExplain && nMem<10 ){ |
| 46370 | 46537 | nMem = 10; |
| 46371 | 46538 | } |
| 46539 | + zCsr += (zCsr - (u8*)0)&7; | |
| 46540 | + assert( EIGHT_BYTE_ALIGNMENT(zCsr) ); | |
| 46541 | + if( zEnd<zCsr ) zEnd = zCsr; | |
| 46372 | 46542 | |
| 46373 | 46543 | do { |
| 46374 | 46544 | memset(zCsr, 0, zEnd-zCsr); |
| 46375 | 46545 | nByte = 0; |
| 46376 | 46546 | allocSpace((char*)&p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte); |
| @@ -46877,10 +47047,37 @@ | ||
| 46877 | 47047 | p->iStatement = 0; |
| 46878 | 47048 | } |
| 46879 | 47049 | return rc; |
| 46880 | 47050 | } |
| 46881 | 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 | + | |
| 46882 | 47079 | /* |
| 46883 | 47080 | ** This routine is called the when a VDBE tries to halt. If the VDBE |
| 46884 | 47081 | ** has made changes and is in autocommit mode, then commit those |
| 46885 | 47082 | ** changes. If a rollback is needed, then do the rollback. |
| 46886 | 47083 | ** |
| @@ -46926,11 +47123,11 @@ | ||
| 46926 | 47123 | int mrc; /* Primary error code from p->rc */ |
| 46927 | 47124 | int eStatementOp = 0; |
| 46928 | 47125 | int isSpecialError; /* Set to true if a 'special' error */ |
| 46929 | 47126 | |
| 46930 | 47127 | /* Lock all btrees used by the statement */ |
| 46931 | - sqlite3BtreeMutexArrayEnter(&p->aMutex); | |
| 47128 | + sqlite3VdbeMutexArrayEnter(p); | |
| 46932 | 47129 | |
| 46933 | 47130 | /* Check for one of the special errors */ |
| 46934 | 47131 | mrc = p->rc & 0xff; |
| 46935 | 47132 | isSpecialError = mrc==SQLITE_NOMEM || mrc==SQLITE_IOERR |
| 46936 | 47133 | || mrc==SQLITE_INTERRUPT || mrc==SQLITE_FULL; |
| @@ -47587,34 +47784,44 @@ | ||
| 47587 | 47784 | */ |
| 47588 | 47785 | SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeRecordUnpack( |
| 47589 | 47786 | KeyInfo *pKeyInfo, /* Information about the record format */ |
| 47590 | 47787 | int nKey, /* Size of the binary record */ |
| 47591 | 47788 | 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 */ | |
| 47593 | 47790 | int szSpace /* Size of pSpace[] in bytes */ |
| 47594 | 47791 | ){ |
| 47595 | 47792 | 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; | |
| 47598 | 47796 | u32 idx; |
| 47599 | - u16 u; /* Unsigned loop counter */ | |
| 47797 | + u16 u; /* Unsigned loop counter */ | |
| 47600 | 47798 | u32 szHdr; |
| 47601 | 47799 | Mem *pMem; |
| 47800 | + int nOff; /* Increase pSpace by this much to 8-byte align it */ | |
| 47602 | 47801 | |
| 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); | |
| 47605 | 47811 | if( nByte>szSpace ){ |
| 47606 | 47812 | p = sqlite3DbMallocRaw(pKeyInfo->db, nByte); |
| 47607 | 47813 | if( p==0 ) return 0; |
| 47608 | 47814 | p->flags = UNPACKED_NEED_FREE | UNPACKED_NEED_DESTROY; |
| 47609 | 47815 | }else{ |
| 47610 | - p = pSpace; | |
| 47816 | + p = (UnpackedRecord*)pSpace; | |
| 47611 | 47817 | p->flags = UNPACKED_NEED_DESTROY; |
| 47612 | 47818 | } |
| 47613 | 47819 | p->pKeyInfo = pKeyInfo; |
| 47614 | 47820 | 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) ); | |
| 47616 | 47823 | idx = getVarint32(aKey, szHdr); |
| 47617 | 47824 | d = szHdr; |
| 47618 | 47825 | u = 0; |
| 47619 | 47826 | while( idx<szHdr && u<p->nField ){ |
| 47620 | 47827 | u32 serial_type; |
| @@ -47926,11 +48133,11 @@ | ||
| 47926 | 48133 | ************************************************************************* |
| 47927 | 48134 | ** |
| 47928 | 48135 | ** This file contains code use to implement APIs that are part of the |
| 47929 | 48136 | ** VDBE. |
| 47930 | 48137 | ** |
| 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 $ | |
| 47932 | 48139 | */ |
| 47933 | 48140 | |
| 47934 | 48141 | #if 0 && defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) |
| 47935 | 48142 | /* |
| 47936 | 48143 | ** The following structure contains pointers to the end points of a |
| @@ -48354,11 +48561,11 @@ | ||
| 48354 | 48561 | if( db->mallocFailed ){ |
| 48355 | 48562 | return SQLITE_NOMEM; |
| 48356 | 48563 | } |
| 48357 | 48564 | |
| 48358 | 48565 | if( p->pc<=0 && p->expired ){ |
| 48359 | - if( p->rc==SQLITE_OK ){ | |
| 48566 | + if( ALWAYS(p->rc==SQLITE_OK) ){ | |
| 48360 | 48567 | p->rc = SQLITE_SCHEMA; |
| 48361 | 48568 | } |
| 48362 | 48569 | rc = SQLITE_ERROR; |
| 48363 | 48570 | goto end_of_step; |
| 48364 | 48571 | } |
| @@ -48470,11 +48677,11 @@ | ||
| 48470 | 48677 | && cnt++ < 5 |
| 48471 | 48678 | && (rc = vdbeReprepare(v))==SQLITE_OK ){ |
| 48472 | 48679 | sqlite3_reset(pStmt); |
| 48473 | 48680 | v->expired = 0; |
| 48474 | 48681 | } |
| 48475 | - if( rc==SQLITE_SCHEMA && v->isPrepareV2 && db->pErr ){ | |
| 48682 | + if( rc==SQLITE_SCHEMA && ALWAYS(v->isPrepareV2) && ALWAYS(db->pErr) ){ | |
| 48476 | 48683 | /* This case occurs after failing to recompile an sql statement. |
| 48477 | 48684 | ** The error message from the SQL compiler has already been loaded |
| 48478 | 48685 | ** into the database handle. This block copies the error message |
| 48479 | 48686 | ** from the database handle into the statement and sets the statement |
| 48480 | 48687 | ** program counter to 0 to ensure that when the statement is |
| @@ -48529,11 +48736,11 @@ | ||
| 48529 | 48736 | sqlite3_value **NotUsed2 /* Value of each argument */ |
| 48530 | 48737 | ){ |
| 48531 | 48738 | const char *zName = context->pFunc->zName; |
| 48532 | 48739 | char *zErr; |
| 48533 | 48740 | UNUSED_PARAMETER2(NotUsed, NotUsed2); |
| 48534 | - zErr = sqlite3MPrintf(0, | |
| 48741 | + zErr = sqlite3_mprintf( | |
| 48535 | 48742 | "unable to use function %s in the requested context", zName); |
| 48536 | 48743 | sqlite3_result_error(context, zErr, -1); |
| 48537 | 48744 | sqlite3_free(zErr); |
| 48538 | 48745 | } |
| 48539 | 48746 | |
| @@ -48675,11 +48882,11 @@ | ||
| 48675 | 48882 | vals = sqlite3_data_count(pStmt); |
| 48676 | 48883 | pOut = &pVm->pResultSet[i]; |
| 48677 | 48884 | }else{ |
| 48678 | 48885 | /* ((double)0) In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 48679 | 48886 | 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) ){ | |
| 48681 | 48888 | sqlite3_mutex_enter(pVm->db->mutex); |
| 48682 | 48889 | sqlite3Error(pVm->db, SQLITE_RANGE, 0); |
| 48683 | 48890 | } |
| 48684 | 48891 | pOut = (Mem*)&nullMem; |
| 48685 | 48892 | } |
| @@ -48815,28 +49022,27 @@ | ||
| 48815 | 49022 | int useType |
| 48816 | 49023 | ){ |
| 48817 | 49024 | const void *ret = 0; |
| 48818 | 49025 | Vdbe *p = (Vdbe *)pStmt; |
| 48819 | 49026 | 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); | |
| 48838 | 49044 | } |
| 48839 | 49045 | return ret; |
| 48840 | 49046 | } |
| 48841 | 49047 | |
| 48842 | 49048 | /* |
| @@ -49072,12 +49278,12 @@ | ||
| 49072 | 49278 | rc = sqlite3VdbeMemCopy(&p->aVar[i-1], pValue); |
| 49073 | 49279 | if( rc==SQLITE_OK ){ |
| 49074 | 49280 | rc = sqlite3VdbeChangeEncoding(&p->aVar[i-1], ENC(p->db)); |
| 49075 | 49281 | } |
| 49076 | 49282 | sqlite3_mutex_leave(p->db->mutex); |
| 49283 | + rc = sqlite3ApiExit(p->db, rc); | |
| 49077 | 49284 | } |
| 49078 | - rc = sqlite3ApiExit(p->db, rc); | |
| 49079 | 49285 | return rc; |
| 49080 | 49286 | } |
| 49081 | 49287 | SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){ |
| 49082 | 49288 | int rc; |
| 49083 | 49289 | Vdbe *p = (Vdbe *)pStmt; |
| @@ -49103,22 +49309,25 @@ | ||
| 49103 | 49309 | ** in the Vdbe.azVar[] array, if such a mapping does not already |
| 49104 | 49310 | ** exist. |
| 49105 | 49311 | */ |
| 49106 | 49312 | static void createVarMap(Vdbe *p){ |
| 49107 | 49313 | if( !p->okVar ){ |
| 49314 | + int j; | |
| 49315 | + Op *pOp; | |
| 49108 | 49316 | 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; | |
| 49120 | 49329 | sqlite3_mutex_leave(p->db->mutex); |
| 49121 | 49330 | } |
| 49122 | 49331 | } |
| 49123 | 49332 | |
| 49124 | 49333 | /* |
| @@ -49159,40 +49368,44 @@ | ||
| 49159 | 49368 | return 0; |
| 49160 | 49369 | } |
| 49161 | 49370 | |
| 49162 | 49371 | /* |
| 49163 | 49372 | ** 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 | 49373 | */ |
| 49167 | 49374 | SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){ |
| 49168 | 49375 | Vdbe *pFrom = (Vdbe*)pFromStmt; |
| 49169 | 49376 | 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 ); | |
| 49179 | 49380 | 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++){ | |
| 49181 | 49382 | sqlite3VdbeMemMove(&pTo->aVar[i], &pFrom->aVar[i]); |
| 49182 | 49383 | } |
| 49183 | 49384 | sqlite3_mutex_leave(pTo->db->mutex); |
| 49184 | - assert( rc==SQLITE_OK || rc==SQLITE_NOMEM ); | |
| 49185 | - return rc; | |
| 49385 | + return SQLITE_OK; | |
| 49186 | 49386 | } |
| 49187 | 49387 | |
| 49188 | 49388 | #ifndef SQLITE_OMIT_DEPRECATED |
| 49189 | 49389 | /* |
| 49190 | 49390 | ** Deprecated external interface. Internal/core SQLite code |
| 49191 | 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. | |
| 49192 | 49400 | */ |
| 49193 | 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 | + } | |
| 49194 | 49407 | return sqlite3TransferBindings(pFromStmt, pToStmt); |
| 49195 | 49408 | } |
| 49196 | 49409 | #endif |
| 49197 | 49410 | |
| 49198 | 49411 | /* |
| @@ -49278,11 +49491,11 @@ | ||
| 49278 | 49491 | ** documentation, headers files, or other derived files. The formatting |
| 49279 | 49492 | ** of the code in this file is, therefore, important. See other comments |
| 49280 | 49493 | ** in this file for details. If in doubt, do not deviate from existing |
| 49281 | 49494 | ** commenting and indentation practices when changing or adding code. |
| 49282 | 49495 | ** |
| 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 $ | |
| 49284 | 49497 | */ |
| 49285 | 49498 | |
| 49286 | 49499 | /* |
| 49287 | 49500 | ** The following global variable is incremented every time a cursor |
| 49288 | 49501 | ** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes. The test |
| @@ -49886,15 +50099,17 @@ | ||
| 49886 | 50099 | int origPc; /* Program counter at start of opcode */ |
| 49887 | 50100 | #endif |
| 49888 | 50101 | #ifndef SQLITE_OMIT_PROGRESS_CALLBACK |
| 49889 | 50102 | int nProgressOps = 0; /* Opcodes executed since progress callback. */ |
| 49890 | 50103 | #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]; | |
| 49892 | 50107 | |
| 49893 | 50108 | assert( p->magic==VDBE_MAGIC_RUN ); /* sqlite3_step() verifies this */ |
| 49894 | 50109 | assert( db->magic==SQLITE_MAGIC_BUSY ); |
| 49895 | - sqlite3BtreeMutexArrayEnter(&p->aMutex); | |
| 50110 | + sqlite3VdbeMutexArrayEnter(p); | |
| 49896 | 50111 | if( p->rc==SQLITE_NOMEM ){ |
| 49897 | 50112 | /* This happens if a malloc() inside a call to sqlite3_column_text() or |
| 49898 | 50113 | ** sqlite3_column_text16() failed. */ |
| 49899 | 50114 | goto no_mem; |
| 49900 | 50115 | } |
| @@ -51689,11 +51904,15 @@ | ||
| 51689 | 51904 | */ |
| 51690 | 51905 | #ifndef SQLITE_OMIT_BTREECOUNT |
| 51691 | 51906 | case OP_Count: { /* out2-prerelease */ |
| 51692 | 51907 | i64 nEntry; |
| 51693 | 51908 | 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 | + } | |
| 51695 | 51914 | pOut->flags = MEM_Int; |
| 51696 | 51915 | pOut->u.i = nEntry; |
| 51697 | 51916 | break; |
| 51698 | 51917 | } |
| 51699 | 51918 | #endif |
| @@ -53472,16 +53691,18 @@ | ||
| 53472 | 53691 | */ |
| 53473 | 53692 | case OP_IdxRowid: { /* out2-prerelease */ |
| 53474 | 53693 | int i = pOp->p1; |
| 53475 | 53694 | BtCursor *pCrsr; |
| 53476 | 53695 | VdbeCursor *pC; |
| 53696 | + | |
| 53477 | 53697 | |
| 53478 | 53698 | assert( i>=0 && i<p->nCursor ); |
| 53479 | 53699 | assert( p->apCsr[i]!=0 ); |
| 53480 | 53700 | if( (pCrsr = (pC = p->apCsr[i])->pCursor)!=0 ){ |
| 53481 | 53701 | i64 rowid; |
| 53482 | - | |
| 53702 | + rc = sqlite3VdbeCursorMoveto(pC); | |
| 53703 | + if( rc ) goto abort_due_to_error; | |
| 53483 | 53704 | assert( pC->deferredMoveto==0 ); |
| 53484 | 53705 | assert( pC->isTable==0 ); |
| 53485 | 53706 | if( !pC->nullRow ){ |
| 53486 | 53707 | rc = sqlite3VdbeIdxRowid(pCrsr, &rowid); |
| 53487 | 53708 | if( rc!=SQLITE_OK ){ |
| @@ -55348,22 +55569,27 @@ | ||
| 55348 | 55569 | ** |
| 55349 | 55570 | ** This file contains code use to implement an in-memory rollback journal. |
| 55350 | 55571 | ** The in-memory rollback journal is used to journal transactions for |
| 55351 | 55572 | ** ":memory:" databases and when the journal_mode=MEMORY pragma is used. |
| 55352 | 55573 | ** |
| 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 $ | |
| 55354 | 55575 | */ |
| 55355 | 55576 | |
| 55356 | 55577 | /* Forward references to internal structures */ |
| 55357 | 55578 | typedef struct MemJournal MemJournal; |
| 55358 | 55579 | typedef struct FilePoint FilePoint; |
| 55359 | 55580 | typedef struct FileChunk FileChunk; |
| 55360 | 55581 | |
| 55361 | 55582 | /* Space to hold the rollback journal is allocated in increments of |
| 55362 | 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. | |
| 55363 | 55589 | */ |
| 55364 | -#define JOURNAL_CHUNKSIZE 1024 | |
| 55590 | +#define JOURNAL_CHUNKSIZE ((int)(1024-sizeof(FileChunk*))) | |
| 55365 | 55591 | |
| 55366 | 55592 | /* Macro to find the minimum of two numeric values. |
| 55367 | 55593 | */ |
| 55368 | 55594 | #ifndef MIN |
| 55369 | 55595 | # define MIN(x,y) ((x)<(y)?(x):(y)) |
| @@ -55396,11 +55622,12 @@ | ||
| 55396 | 55622 | FilePoint endpoint; /* Pointer to the end of the file */ |
| 55397 | 55623 | FilePoint readpoint; /* Pointer to the end of the last xRead() */ |
| 55398 | 55624 | }; |
| 55399 | 55625 | |
| 55400 | 55626 | /* |
| 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. | |
| 55402 | 55629 | */ |
| 55403 | 55630 | static int memjrnlRead( |
| 55404 | 55631 | sqlite3_file *pJfd, /* The journal file from which to read */ |
| 55405 | 55632 | void *zBuf, /* Put the results here */ |
| 55406 | 55633 | int iAmt, /* Number of bytes to read */ |
| @@ -55410,16 +55637,17 @@ | ||
| 55410 | 55637 | u8 *zOut = zBuf; |
| 55411 | 55638 | int nRead = iAmt; |
| 55412 | 55639 | int iChunkOffset; |
| 55413 | 55640 | FileChunk *pChunk; |
| 55414 | 55641 | |
| 55642 | + /* SQLite never tries to read past the end of a rollback journal file */ | |
| 55415 | 55643 | assert( iOfst+iAmt<=p->endpoint.iOffset ); |
| 55416 | 55644 | |
| 55417 | 55645 | if( p->readpoint.iOffset!=iOfst || iOfst==0 ){ |
| 55418 | 55646 | sqlite3_int64 iOff = 0; |
| 55419 | 55647 | for(pChunk=p->pFirst; |
| 55420 | - pChunk && (iOff+JOURNAL_CHUNKSIZE)<=iOfst; | |
| 55648 | + ALWAYS(pChunk) && (iOff+JOURNAL_CHUNKSIZE)<=iOfst; | |
| 55421 | 55649 | pChunk=pChunk->pNext |
| 55422 | 55650 | ){ |
| 55423 | 55651 | iOff += JOURNAL_CHUNKSIZE; |
| 55424 | 55652 | } |
| 55425 | 55653 | }else{ |
| @@ -55518,15 +55746,21 @@ | ||
| 55518 | 55746 | } |
| 55519 | 55747 | |
| 55520 | 55748 | |
| 55521 | 55749 | /* |
| 55522 | 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. | |
| 55523 | 55756 | */ |
| 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*/ | |
| 55528 | 55762 | |
| 55529 | 55763 | /* |
| 55530 | 55764 | ** Query the size of the file in bytes. |
| 55531 | 55765 | */ |
| 55532 | 55766 | static int memjrnlFileSize(sqlite3_file *pJfd, sqlite_int64 *pSize){ |
| @@ -55557,10 +55791,11 @@ | ||
| 55557 | 55791 | /* |
| 55558 | 55792 | ** Open a journal file. |
| 55559 | 55793 | */ |
| 55560 | 55794 | SQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *pJfd){ |
| 55561 | 55795 | MemJournal *p = (MemJournal *)pJfd; |
| 55796 | + assert( EIGHT_BYTE_ALIGNMENT(p) ); | |
| 55562 | 55797 | memset(p, 0, sqlite3MemJournalSize()); |
| 55563 | 55798 | p->pMethod = &MemJournalMethods; |
| 55564 | 55799 | } |
| 55565 | 55800 | |
| 55566 | 55801 | /* |
| @@ -55593,11 +55828,11 @@ | ||
| 55593 | 55828 | ** |
| 55594 | 55829 | ************************************************************************* |
| 55595 | 55830 | ** This file contains routines used for walking the parser tree for |
| 55596 | 55831 | ** an SQL statement. |
| 55597 | 55832 | ** |
| 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 $ | |
| 55599 | 55834 | */ |
| 55600 | 55835 | |
| 55601 | 55836 | |
| 55602 | 55837 | /* |
| 55603 | 55838 | ** Walk an expression tree. Invoke the callback once for each node |
| @@ -55619,12 +55854,16 @@ | ||
| 55619 | 55854 | ** and WRC_Continue to continue. |
| 55620 | 55855 | */ |
| 55621 | 55856 | SQLITE_PRIVATE int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){ |
| 55622 | 55857 | int rc; |
| 55623 | 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) ); | |
| 55624 | 55862 | rc = pWalker->xExprCallback(pWalker, pExpr); |
| 55625 | - if( rc==WRC_Continue ){ | |
| 55863 | + if( rc==WRC_Continue | |
| 55864 | + && !ExprHasAnyProperty(pExpr,EP_TokenOnly|EP_SpanToken) ){ | |
| 55626 | 55865 | if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort; |
| 55627 | 55866 | if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort; |
| 55628 | 55867 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 55629 | 55868 | if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort; |
| 55630 | 55869 | }else{ |
| @@ -56900,11 +57139,11 @@ | ||
| 56900 | 57139 | ** |
| 56901 | 57140 | ************************************************************************* |
| 56902 | 57141 | ** This file contains routines used for analyzing expressions and |
| 56903 | 57142 | ** for generating VDBE code that evaluates expressions in SQLite. |
| 56904 | 57143 | ** |
| 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 $ | |
| 56906 | 57145 | */ |
| 56907 | 57146 | |
| 56908 | 57147 | /* |
| 56909 | 57148 | ** Return the 'affinity' of the expression pExpr if any. |
| 56910 | 57149 | ** |
| @@ -57516,19 +57755,22 @@ | ||
| 57516 | 57755 | ** Clear an expression structure without deleting the structure itself. |
| 57517 | 57756 | ** Substructure is deleted. |
| 57518 | 57757 | */ |
| 57519 | 57758 | SQLITE_PRIVATE void sqlite3ExprClear(sqlite3 *db, Expr *p){ |
| 57520 | 57759 | 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) ){ | |
| 57522 | 57761 | if( p->span.dyn ) sqlite3DbFree(db, (char*)p->span.z); |
| 57523 | 57762 | if( ExprHasProperty(p, EP_Reduced) ){ |
| 57763 | + /* Subtrees are part of the same memory allocation when EP_Reduced set */ | |
| 57524 | 57764 | if( p->pLeft ) sqlite3ExprClear(db, p->pLeft); |
| 57525 | 57765 | if( p->pRight ) sqlite3ExprClear(db, p->pRight); |
| 57526 | 57766 | }else{ |
| 57767 | + /* Subtrees are separate allocations when EP_Reduced is clear */ | |
| 57527 | 57768 | sqlite3ExprDelete(db, p->pLeft); |
| 57528 | 57769 | sqlite3ExprDelete(db, p->pRight); |
| 57529 | 57770 | } |
| 57771 | + /* x.pSelect and x.pList are always separately allocated */ | |
| 57530 | 57772 | if( ExprHasProperty(p, EP_xIsSelect) ){ |
| 57531 | 57773 | sqlite3SelectDelete(db, p->x.pSelect); |
| 57532 | 57774 | }else{ |
| 57533 | 57775 | sqlite3ExprListDelete(db, p->x.pList); |
| 57534 | 57776 | } |
| @@ -57561,11 +57803,11 @@ | ||
| 57561 | 57803 | ** passed as the first argument. This is always one of EXPR_FULLSIZE, |
| 57562 | 57804 | ** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE. |
| 57563 | 57805 | */ |
| 57564 | 57806 | static int exprStructSize(Expr *p){ |
| 57565 | 57807 | 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; | |
| 57567 | 57809 | if( ExprHasProperty(p, EP_Reduced) ) return EXPR_REDUCEDSIZE; |
| 57568 | 57810 | return EXPR_FULLSIZE; |
| 57569 | 57811 | } |
| 57570 | 57812 | |
| 57571 | 57813 | /* |
| @@ -57578,12 +57820,12 @@ | ||
| 57578 | 57820 | int nSize; |
| 57579 | 57821 | if( 0==(flags&EXPRDUP_REDUCE) ){ |
| 57580 | 57822 | nSize = EXPR_FULLSIZE; |
| 57581 | 57823 | }else if( p->pLeft || p->pRight || p->pColl || p->x.pList ){ |
| 57582 | 57824 | 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; | |
| 57585 | 57827 | }else{ |
| 57586 | 57828 | nSize = EXPR_TOKENONLYSIZE; |
| 57587 | 57829 | } |
| 57588 | 57830 | return nSize; |
| 57589 | 57831 | } |
| @@ -57595,12 +57837,12 @@ | ||
| 57595 | 57837 | ** and the copies of the Expr.token.z and Expr.span.z (if applicable) |
| 57596 | 57838 | ** string buffers. |
| 57597 | 57839 | */ |
| 57598 | 57840 | static int dupedExprNodeSize(Expr *p, int flags){ |
| 57599 | 57841 | 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) | |
| 57602 | 57844 | ){ |
| 57603 | 57845 | nByte += p->span.n; |
| 57604 | 57846 | } |
| 57605 | 57847 | return ROUND8(nByte); |
| 57606 | 57848 | } |
| @@ -57623,11 +57865,11 @@ | ||
| 57623 | 57865 | static int dupedExprSize(Expr *p, int flags){ |
| 57624 | 57866 | int nByte = 0; |
| 57625 | 57867 | if( p ){ |
| 57626 | 57868 | nByte = dupedExprNodeSize(p, flags); |
| 57627 | 57869 | if( flags&EXPRDUP_REDUCE ){ |
| 57628 | - int f = flags&(~(EXPRDUP_SPAN|EXPRDUP_DISTINCTSPAN)); | |
| 57870 | + int f = flags&(~EXPRDUP_SPAN); | |
| 57629 | 57871 | nByte += dupedExprSize(p->pLeft, f) + dupedExprSize(p->pRight, f); |
| 57630 | 57872 | } |
| 57631 | 57873 | } |
| 57632 | 57874 | return nByte; |
| 57633 | 57875 | } |
| @@ -57641,12 +57883,11 @@ | ||
| 57641 | 57883 | ** portion of the buffer copied into by this function. |
| 57642 | 57884 | */ |
| 57643 | 57885 | static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){ |
| 57644 | 57886 | Expr *pNew = 0; /* Value to return */ |
| 57645 | 57887 | 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); | |
| 57648 | 57889 | const int isReduced = (flags&EXPRDUP_REDUCE); |
| 57649 | 57890 | u8 *zAlloc; |
| 57650 | 57891 | |
| 57651 | 57892 | assert( pzBuffer==0 || isReduced ); |
| 57652 | 57893 | |
| @@ -57674,15 +57915,15 @@ | ||
| 57674 | 57915 | memcpy(zAlloc, p, nSize); |
| 57675 | 57916 | memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize); |
| 57676 | 57917 | } |
| 57677 | 57918 | |
| 57678 | 57919 | /* 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); | |
| 57680 | 57921 | switch( nNewSize ){ |
| 57681 | 57922 | case EXPR_REDUCEDSIZE: pNew->flags |= EP_Reduced; break; |
| 57682 | 57923 | 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; | |
| 57684 | 57925 | } |
| 57685 | 57926 | |
| 57686 | 57927 | /* Copy the p->token string, if any. */ |
| 57687 | 57928 | if( nToken ){ |
| 57688 | 57929 | unsigned char *zToken = &zAlloc[nNewSize]; |
| @@ -57693,13 +57934,11 @@ | ||
| 57693 | 57934 | } |
| 57694 | 57935 | |
| 57695 | 57936 | if( 0==((p->flags|pNew->flags) & EP_TokenOnly) ){ |
| 57696 | 57937 | /* Fill in the pNew->span token, if required. */ |
| 57697 | 57938 | 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 ){ | |
| 57701 | 57940 | pNew->span.z = &zAlloc[nNewSize+nToken]; |
| 57702 | 57941 | memcpy((char *)pNew->span.z, p->span.z, p->span.n); |
| 57703 | 57942 | pNew->span.dyn = 0; |
| 57704 | 57943 | }else{ |
| 57705 | 57944 | pNew->span.z = pNew->token.z; |
| @@ -57709,30 +57948,30 @@ | ||
| 57709 | 57948 | pNew->span.z = 0; |
| 57710 | 57949 | pNew->span.n = 0; |
| 57711 | 57950 | } |
| 57712 | 57951 | } |
| 57713 | 57952 | |
| 57714 | - if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_SpanOnly)) ){ | |
| 57953 | + if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_SpanToken)) ){ | |
| 57715 | 57954 | /* Fill in the pNew->x.pSelect or pNew->x.pList member. */ |
| 57716 | 57955 | if( ExprHasProperty(p, EP_xIsSelect) ){ |
| 57717 | 57956 | pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, isReduced); |
| 57718 | 57957 | }else{ |
| 57719 | 57958 | pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, isReduced); |
| 57720 | 57959 | } |
| 57721 | 57960 | } |
| 57722 | 57961 | |
| 57723 | 57962 | /* 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) ){ | |
| 57725 | 57964 | zAlloc += dupedExprNodeSize(p, flags); |
| 57726 | 57965 | if( ExprHasProperty(pNew, EP_Reduced) ){ |
| 57727 | 57966 | pNew->pLeft = exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc); |
| 57728 | 57967 | pNew->pRight = exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc); |
| 57729 | 57968 | } |
| 57730 | 57969 | if( pzBuffer ){ |
| 57731 | 57970 | *pzBuffer = zAlloc; |
| 57732 | 57971 | } |
| 57733 | - }else if( !ExprHasAnyProperty(p, EP_TokenOnly|EP_SpanOnly) ){ | |
| 57972 | + }else if( !ExprHasAnyProperty(p, EP_TokenOnly|EP_SpanToken) ){ | |
| 57734 | 57973 | pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0); |
| 57735 | 57974 | pNew->pRight = sqlite3ExprDup(db, p->pRight, 0); |
| 57736 | 57975 | } |
| 57737 | 57976 | } |
| 57738 | 57977 | } |
| @@ -58232,26 +58471,30 @@ | ||
| 58232 | 58471 | ** If this is the case, it may be possible to use an existing table |
| 58233 | 58472 | ** or index instead of generating an epheremal table. |
| 58234 | 58473 | */ |
| 58235 | 58474 | p = (ExprHasProperty(pX, EP_xIsSelect) ? pX->x.pSelect : 0); |
| 58236 | 58475 | 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); | |
| 58242 | 58487 | |
| 58243 | 58488 | /* This function is only called from two places. In both cases the vdbe |
| 58244 | 58489 | ** has already been allocated. So assume sqlite3GetVdbe() is always |
| 58245 | 58490 | ** successful here. |
| 58246 | 58491 | */ |
| 58247 | 58492 | assert(v); |
| 58248 | 58493 | if( iCol<0 ){ |
| 58249 | 58494 | int iMem = ++pParse->nMem; |
| 58250 | 58495 | int iAddr; |
| 58251 | - Table *pTab = p->pSrc->a[0].pTab; | |
| 58252 | - int iDb = sqlite3SchemaToIndex(db, pTab->pSchema); | |
| 58253 | 58496 | sqlite3VdbeUsesBtree(v, iDb); |
| 58254 | 58497 | |
| 58255 | 58498 | iAddr = sqlite3VdbeAddOp1(v, OP_If, iMem); |
| 58256 | 58499 | sqlite3VdbeAddOp2(v, OP_Integer, 1, iMem); |
| 58257 | 58500 | |
| @@ -58258,30 +58501,29 @@ | ||
| 58258 | 58501 | sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead); |
| 58259 | 58502 | eType = IN_INDEX_ROWID; |
| 58260 | 58503 | |
| 58261 | 58504 | sqlite3VdbeJumpHere(v, iAddr); |
| 58262 | 58505 | }else{ |
| 58506 | + Index *pIdx; /* Iterator variable */ | |
| 58507 | + | |
| 58263 | 58508 | /* The collation sequence used by the comparison. If an index is to |
| 58264 | 58509 | ** be used in place of a temp-table, it must be ordered according |
| 58265 | - ** to this collation sequence. | |
| 58266 | - */ | |
| 58510 | + ** to this collation sequence. */ | |
| 58267 | 58511 | CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pExpr); |
| 58268 | 58512 | |
| 58269 | 58513 | /* Check that the affinity that will be used to perform the |
| 58270 | 58514 | ** comparison is the same as the affinity of the column. If |
| 58271 | 58515 | ** it is not, it is not possible to use any index. |
| 58272 | 58516 | */ |
| 58273 | - Table *pTab = p->pSrc->a[0].pTab; | |
| 58274 | 58517 | char aff = comparisonAffinity(pX); |
| 58275 | 58518 | int affinity_ok = (pTab->aCol[iCol].affinity==aff||aff==SQLITE_AFF_NONE); |
| 58276 | 58519 | |
| 58277 | 58520 | for(pIdx=pTab->pIndex; pIdx && eType==0 && affinity_ok; pIdx=pIdx->pNext){ |
| 58278 | 58521 | if( (pIdx->aiColumn[0]==iCol) |
| 58279 | 58522 | && (pReq==sqlite3FindCollSeq(db, ENC(db), pIdx->azColl[0], -1, 0)) |
| 58280 | 58523 | && (!mustBeUnique || (pIdx->nColumn==1 && pIdx->onError!=OE_None)) |
| 58281 | 58524 | ){ |
| 58282 | - int iDb; | |
| 58283 | 58525 | int iMem = ++pParse->nMem; |
| 58284 | 58526 | int iAddr; |
| 58285 | 58527 | char *pKey; |
| 58286 | 58528 | |
| 58287 | 58529 | pKey = (char *)sqlite3IndexKeyinfo(pParse, pIdx); |
| @@ -59089,35 +59331,38 @@ | ||
| 59089 | 59331 | } |
| 59090 | 59332 | break; |
| 59091 | 59333 | } |
| 59092 | 59334 | case TK_CONST_FUNC: |
| 59093 | 59335 | 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 */ | |
| 59105 | 59345 | |
| 59106 | 59346 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 59107 | 59347 | testcase( op==TK_CONST_FUNC ); |
| 59108 | 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; | |
| 59109 | 59355 | zId = (char*)pExpr->token.z; |
| 59110 | 59356 | nId = pExpr->token.n; |
| 59111 | - pDef = sqlite3FindFunction(db, zId, nId, nExpr, enc, 0); | |
| 59357 | + pDef = sqlite3FindFunction(db, zId, nId, nFarg, enc, 0); | |
| 59112 | 59358 | 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); | |
| 59117 | 59362 | }else{ |
| 59118 | - nExpr = r1 = 0; | |
| 59363 | + r1 = 0; | |
| 59119 | 59364 | } |
| 59120 | 59365 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 59121 | 59366 | /* Possibly overload the function if the first argument is |
| 59122 | 59367 | ** a virtual table column. |
| 59123 | 59368 | ** |
| @@ -59128,35 +59373,35 @@ | ||
| 59128 | 59373 | ** control overloading) ends up as the second argument to the |
| 59129 | 59374 | ** function. The expression "A glob B" is equivalent to |
| 59130 | 59375 | ** "glob(B,A). We want to use the A in "A glob B" to test |
| 59131 | 59376 | ** for function overloading. But we use the B term in "glob(B,A)". |
| 59132 | 59377 | */ |
| 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); | |
| 59137 | 59382 | } |
| 59138 | 59383 | #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) ){ | |
| 59141 | 59386 | constMask |= (1<<i); |
| 59142 | 59387 | } |
| 59143 | 59388 | if( (pDef->flags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){ |
| 59144 | - pColl = sqlite3ExprCollSeq(pParse, pList->a[i].pExpr); | |
| 59389 | + pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr); | |
| 59145 | 59390 | } |
| 59146 | 59391 | } |
| 59147 | 59392 | if( pDef->flags & SQLITE_FUNC_NEEDCOLL ){ |
| 59148 | 59393 | if( !pColl ) pColl = db->pDfltColl; |
| 59149 | 59394 | sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ); |
| 59150 | 59395 | } |
| 59151 | 59396 | sqlite3VdbeAddOp4(v, OP_Function, constMask, r1, target, |
| 59152 | 59397 | (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); | |
| 59156 | 59401 | } |
| 59157 | - sqlite3ExprCacheAffinityChange(pParse, r1, nExpr); | |
| 59402 | + sqlite3ExprCacheAffinityChange(pParse, r1, nFarg); | |
| 59158 | 59403 | break; |
| 59159 | 59404 | } |
| 59160 | 59405 | #ifndef SQLITE_OMIT_SUBQUERY |
| 59161 | 59406 | case TK_EXISTS: |
| 59162 | 59407 | case TK_SELECT: { |
| @@ -61275,11 +61520,11 @@ | ||
| 61275 | 61520 | ** May you share freely, never taking more than you give. |
| 61276 | 61521 | ** |
| 61277 | 61522 | ************************************************************************* |
| 61278 | 61523 | ** This file contains code used to implement the ATTACH and DETACH commands. |
| 61279 | 61524 | ** |
| 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 $ | |
| 61281 | 61526 | */ |
| 61282 | 61527 | |
| 61283 | 61528 | #ifndef SQLITE_OMIT_ATTACH |
| 61284 | 61529 | /* |
| 61285 | 61530 | ** Resolve an expression that was part of an ATTACH or DETACH statement. This |
| @@ -61751,11 +61996,11 @@ | ||
| 61751 | 61996 | SQLITE_PRIVATE int sqlite3FixExpr( |
| 61752 | 61997 | DbFixer *pFix, /* Context of the fixation */ |
| 61753 | 61998 | Expr *pExpr /* The expression to be fixed to one database */ |
| 61754 | 61999 | ){ |
| 61755 | 62000 | while( pExpr ){ |
| 61756 | - if( ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_SpanOnly) ) break; | |
| 62001 | + if( ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_SpanToken) ) break; | |
| 61757 | 62002 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 61758 | 62003 | if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1; |
| 61759 | 62004 | }else{ |
| 61760 | 62005 | if( sqlite3FixExprList(pFix, pExpr->x.pList) ) return 1; |
| 61761 | 62006 | } |
| @@ -62063,11 +62308,11 @@ | ||
| 62063 | 62308 | ** creating ID lists |
| 62064 | 62309 | ** BEGIN TRANSACTION |
| 62065 | 62310 | ** COMMIT |
| 62066 | 62311 | ** ROLLBACK |
| 62067 | 62312 | ** |
| 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 $ | |
| 62069 | 62314 | */ |
| 62070 | 62315 | |
| 62071 | 62316 | /* |
| 62072 | 62317 | ** This routine is called when a new SQL statement is beginning to |
| 62073 | 62318 | ** be parsed. Initialize the pParse structure as needed. |
| @@ -63152,13 +63397,11 @@ | ||
| 63152 | 63397 | /* A copy of pExpr is used instead of the original, as pExpr contains |
| 63153 | 63398 | ** tokens that point to volatile memory. The 'span' of the expression |
| 63154 | 63399 | ** is required by pragma table_info. |
| 63155 | 63400 | */ |
| 63156 | 63401 | 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); | |
| 63160 | 63403 | } |
| 63161 | 63404 | } |
| 63162 | 63405 | sqlite3ExprDelete(db, pExpr); |
| 63163 | 63406 | } |
| 63164 | 63407 | |
| @@ -66831,11 +67074,11 @@ | ||
| 66831 | 67074 | ** |
| 66832 | 67075 | ** There is only one exported symbol in this file - the function |
| 66833 | 67076 | ** sqliteRegisterBuildinFunctions() found at the bottom of the file. |
| 66834 | 67077 | ** All other code has file scope. |
| 66835 | 67078 | ** |
| 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 $ | |
| 66837 | 67080 | */ |
| 66838 | 67081 | |
| 66839 | 67082 | /* |
| 66840 | 67083 | ** Return the collating function associated with a function. |
| 66841 | 67084 | */ |
| @@ -67077,20 +67320,26 @@ | ||
| 67077 | 67320 | #endif |
| 67078 | 67321 | |
| 67079 | 67322 | /* |
| 67080 | 67323 | ** Allocate nByte bytes of space using sqlite3_malloc(). If the |
| 67081 | 67324 | ** 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. | |
| 67083 | 67328 | */ |
| 67084 | 67329 | static void *contextMalloc(sqlite3_context *context, i64 nByte){ |
| 67085 | 67330 | 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] ){ | |
| 67087 | 67336 | sqlite3_result_error_toobig(context); |
| 67088 | 67337 | z = 0; |
| 67089 | 67338 | }else{ |
| 67090 | 67339 | z = sqlite3Malloc((int)nByte); |
| 67091 | - if( !z && nByte>0 ){ | |
| 67340 | + if( !z ){ | |
| 67092 | 67341 | sqlite3_result_error_nomem(context); |
| 67093 | 67342 | } |
| 67094 | 67343 | } |
| 67095 | 67344 | return z; |
| 67096 | 67345 | } |
| @@ -67167,12 +67416,21 @@ | ||
| 67167 | 67416 | sqlite3_value **NotUsed2 |
| 67168 | 67417 | ){ |
| 67169 | 67418 | sqlite_int64 r; |
| 67170 | 67419 | UNUSED_PARAMETER2(NotUsed, NotUsed2); |
| 67171 | 67420 | 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 | + } | |
| 67174 | 67432 | sqlite3_result_int64(context, r); |
| 67175 | 67433 | } |
| 67176 | 67434 | |
| 67177 | 67435 | /* |
| 67178 | 67436 | ** Implementation of randomblob(N). Return a random blob |
| @@ -67255,11 +67513,11 @@ | ||
| 67255 | 67513 | ** character is exactly one byte in size. Also, all characters are |
| 67256 | 67514 | ** able to participate in upper-case-to-lower-case mappings in EBCDIC |
| 67257 | 67515 | ** whereas only characters less than 0x80 do in ASCII. |
| 67258 | 67516 | */ |
| 67259 | 67517 | #if defined(SQLITE_EBCDIC) |
| 67260 | -# define sqlite3Utf8Read(A,B,C) (*(A++)) | |
| 67518 | +# define sqlite3Utf8Read(A,C) (*(A++)) | |
| 67261 | 67519 | # define GlogUpperToLower(A) A = sqlite3UpperToLower[A] |
| 67262 | 67520 | #else |
| 67263 | 67521 | # define GlogUpperToLower(A) if( A<0x80 ){ A = sqlite3UpperToLower[A]; } |
| 67264 | 67522 | #endif |
| 67265 | 67523 | |
| @@ -67312,22 +67570,22 @@ | ||
| 67312 | 67570 | u8 matchAll = pInfo->matchAll; |
| 67313 | 67571 | u8 matchSet = pInfo->matchSet; |
| 67314 | 67572 | u8 noCase = pInfo->noCase; |
| 67315 | 67573 | int prevEscape = 0; /* True if the previous character was 'escape' */ |
| 67316 | 67574 | |
| 67317 | - while( (c = sqlite3Utf8Read(zPattern,0,&zPattern))!=0 ){ | |
| 67575 | + while( (c = sqlite3Utf8Read(zPattern,&zPattern))!=0 ){ | |
| 67318 | 67576 | if( !prevEscape && c==matchAll ){ |
| 67319 | - while( (c=sqlite3Utf8Read(zPattern,0,&zPattern)) == matchAll | |
| 67577 | + while( (c=sqlite3Utf8Read(zPattern,&zPattern)) == matchAll | |
| 67320 | 67578 | || c == matchOne ){ |
| 67321 | - if( c==matchOne && sqlite3Utf8Read(zString, 0, &zString)==0 ){ | |
| 67579 | + if( c==matchOne && sqlite3Utf8Read(zString, &zString)==0 ){ | |
| 67322 | 67580 | return 0; |
| 67323 | 67581 | } |
| 67324 | 67582 | } |
| 67325 | 67583 | if( c==0 ){ |
| 67326 | 67584 | return 1; |
| 67327 | 67585 | }else if( c==esc ){ |
| 67328 | - c = sqlite3Utf8Read(zPattern, 0, &zPattern); | |
| 67586 | + c = sqlite3Utf8Read(zPattern, &zPattern); | |
| 67329 | 67587 | if( c==0 ){ |
| 67330 | 67588 | return 0; |
| 67331 | 67589 | } |
| 67332 | 67590 | }else if( c==matchSet ){ |
| 67333 | 67591 | assert( esc==0 ); /* This is GLOB, not LIKE */ |
| @@ -67335,67 +67593,67 @@ | ||
| 67335 | 67593 | while( *zString && patternCompare(&zPattern[-1],zString,pInfo,esc)==0 ){ |
| 67336 | 67594 | SQLITE_SKIP_UTF8(zString); |
| 67337 | 67595 | } |
| 67338 | 67596 | return *zString!=0; |
| 67339 | 67597 | } |
| 67340 | - while( (c2 = sqlite3Utf8Read(zString,0,&zString))!=0 ){ | |
| 67598 | + while( (c2 = sqlite3Utf8Read(zString,&zString))!=0 ){ | |
| 67341 | 67599 | if( noCase ){ |
| 67342 | 67600 | GlogUpperToLower(c2); |
| 67343 | 67601 | GlogUpperToLower(c); |
| 67344 | 67602 | while( c2 != 0 && c2 != c ){ |
| 67345 | - c2 = sqlite3Utf8Read(zString, 0, &zString); | |
| 67603 | + c2 = sqlite3Utf8Read(zString, &zString); | |
| 67346 | 67604 | GlogUpperToLower(c2); |
| 67347 | 67605 | } |
| 67348 | 67606 | }else{ |
| 67349 | 67607 | while( c2 != 0 && c2 != c ){ |
| 67350 | - c2 = sqlite3Utf8Read(zString, 0, &zString); | |
| 67608 | + c2 = sqlite3Utf8Read(zString, &zString); | |
| 67351 | 67609 | } |
| 67352 | 67610 | } |
| 67353 | 67611 | if( c2==0 ) return 0; |
| 67354 | 67612 | if( patternCompare(zPattern,zString,pInfo,esc) ) return 1; |
| 67355 | 67613 | } |
| 67356 | 67614 | return 0; |
| 67357 | 67615 | }else if( !prevEscape && c==matchOne ){ |
| 67358 | - if( sqlite3Utf8Read(zString, 0, &zString)==0 ){ | |
| 67616 | + if( sqlite3Utf8Read(zString, &zString)==0 ){ | |
| 67359 | 67617 | return 0; |
| 67360 | 67618 | } |
| 67361 | 67619 | }else if( c==matchSet ){ |
| 67362 | 67620 | int prior_c = 0; |
| 67363 | 67621 | assert( esc==0 ); /* This only occurs for GLOB, not LIKE */ |
| 67364 | 67622 | seen = 0; |
| 67365 | 67623 | invert = 0; |
| 67366 | - c = sqlite3Utf8Read(zString, 0, &zString); | |
| 67624 | + c = sqlite3Utf8Read(zString, &zString); | |
| 67367 | 67625 | if( c==0 ) return 0; |
| 67368 | - c2 = sqlite3Utf8Read(zPattern, 0, &zPattern); | |
| 67626 | + c2 = sqlite3Utf8Read(zPattern, &zPattern); | |
| 67369 | 67627 | if( c2=='^' ){ |
| 67370 | 67628 | invert = 1; |
| 67371 | - c2 = sqlite3Utf8Read(zPattern, 0, &zPattern); | |
| 67629 | + c2 = sqlite3Utf8Read(zPattern, &zPattern); | |
| 67372 | 67630 | } |
| 67373 | 67631 | if( c2==']' ){ |
| 67374 | 67632 | if( c==']' ) seen = 1; |
| 67375 | - c2 = sqlite3Utf8Read(zPattern, 0, &zPattern); | |
| 67633 | + c2 = sqlite3Utf8Read(zPattern, &zPattern); | |
| 67376 | 67634 | } |
| 67377 | 67635 | while( c2 && c2!=']' ){ |
| 67378 | 67636 | if( c2=='-' && zPattern[0]!=']' && zPattern[0]!=0 && prior_c>0 ){ |
| 67379 | - c2 = sqlite3Utf8Read(zPattern, 0, &zPattern); | |
| 67637 | + c2 = sqlite3Utf8Read(zPattern, &zPattern); | |
| 67380 | 67638 | if( c>=prior_c && c<=c2 ) seen = 1; |
| 67381 | 67639 | prior_c = 0; |
| 67382 | 67640 | }else{ |
| 67383 | 67641 | if( c==c2 ){ |
| 67384 | 67642 | seen = 1; |
| 67385 | 67643 | } |
| 67386 | 67644 | prior_c = c2; |
| 67387 | 67645 | } |
| 67388 | - c2 = sqlite3Utf8Read(zPattern, 0, &zPattern); | |
| 67646 | + c2 = sqlite3Utf8Read(zPattern, &zPattern); | |
| 67389 | 67647 | } |
| 67390 | 67648 | if( c2==0 || (seen ^ invert)==0 ){ |
| 67391 | 67649 | return 0; |
| 67392 | 67650 | } |
| 67393 | 67651 | }else if( esc==c && !prevEscape ){ |
| 67394 | 67652 | prevEscape = 1; |
| 67395 | 67653 | }else{ |
| 67396 | - c2 = sqlite3Utf8Read(zString, 0, &zString); | |
| 67654 | + c2 = sqlite3Utf8Read(zString, &zString); | |
| 67397 | 67655 | if( noCase ){ |
| 67398 | 67656 | GlogUpperToLower(c); |
| 67399 | 67657 | GlogUpperToLower(c2); |
| 67400 | 67658 | } |
| 67401 | 67659 | if( c!=c2 ){ |
| @@ -67434,20 +67692,23 @@ | ||
| 67434 | 67692 | int argc, |
| 67435 | 67693 | sqlite3_value **argv |
| 67436 | 67694 | ){ |
| 67437 | 67695 | const unsigned char *zA, *zB; |
| 67438 | 67696 | int escape = 0; |
| 67697 | + int nPat; | |
| 67439 | 67698 | sqlite3 *db = sqlite3_context_db_handle(context); |
| 67440 | 67699 | |
| 67441 | 67700 | zB = sqlite3_value_text(argv[0]); |
| 67442 | 67701 | zA = sqlite3_value_text(argv[1]); |
| 67443 | 67702 | |
| 67444 | 67703 | /* Limit the length of the LIKE or GLOB pattern to avoid problems |
| 67445 | 67704 | ** of deep recursion and N*N behavior in patternCompare(). |
| 67446 | 67705 | */ |
| 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] ){ | |
| 67449 | 67710 | sqlite3_result_error(context, "LIKE or GLOB pattern too complex", -1); |
| 67450 | 67711 | return; |
| 67451 | 67712 | } |
| 67452 | 67713 | assert( zB==sqlite3_value_text(argv[0]) ); /* Encoding did not change */ |
| 67453 | 67714 | |
| @@ -67460,11 +67721,11 @@ | ||
| 67460 | 67721 | if( sqlite3Utf8CharLen((char*)zEsc, -1)!=1 ){ |
| 67461 | 67722 | sqlite3_result_error(context, |
| 67462 | 67723 | "ESCAPE expression must be a single character", -1); |
| 67463 | 67724 | return; |
| 67464 | 67725 | } |
| 67465 | - escape = sqlite3Utf8Read(zEsc, 0, &zEsc); | |
| 67726 | + escape = sqlite3Utf8Read(zEsc, &zEsc); | |
| 67466 | 67727 | } |
| 67467 | 67728 | if( zA && zB ){ |
| 67468 | 67729 | struct compareInfo *pInfo = sqlite3_user_data(context); |
| 67469 | 67730 | #ifdef SQLITE_TEST |
| 67470 | 67731 | sqlite3_like_count++; |
| @@ -67619,14 +67880,17 @@ | ||
| 67619 | 67880 | sqlite3_context *context, |
| 67620 | 67881 | int argc, |
| 67621 | 67882 | sqlite3_value **argv |
| 67622 | 67883 | ){ |
| 67623 | 67884 | i64 n; |
| 67885 | + sqlite3 *db = sqlite3_context_db_handle(context); | |
| 67624 | 67886 | assert( argc==1 ); |
| 67625 | 67887 | UNUSED_PARAMETER(argc); |
| 67626 | 67888 | 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] ){ | |
| 67628 | 67892 | sqlite3_result_error_toobig(context); |
| 67629 | 67893 | }else{ |
| 67630 | 67894 | sqlite3_result_zeroblob(context, (int)n); |
| 67631 | 67895 | } |
| 67632 | 67896 | } |
| @@ -67688,11 +67952,13 @@ | ||
| 67688 | 67952 | zOut[j++] = zStr[i]; |
| 67689 | 67953 | }else{ |
| 67690 | 67954 | u8 *zOld; |
| 67691 | 67955 | sqlite3 *db = sqlite3_context_db_handle(context); |
| 67692 | 67956 | 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] ){ | |
| 67694 | 67960 | sqlite3_result_error_toobig(context); |
| 67695 | 67961 | sqlite3DbFree(db, zOut); |
| 67696 | 67962 | return; |
| 67697 | 67963 | } |
| 67698 | 67964 | zOld = zOut; |
| @@ -67772,11 +68038,11 @@ | ||
| 67772 | 68038 | if( flags & 1 ){ |
| 67773 | 68039 | while( nIn>0 ){ |
| 67774 | 68040 | int len = 0; |
| 67775 | 68041 | for(i=0; i<nChar; i++){ |
| 67776 | 68042 | len = aLen[i]; |
| 67777 | - if( memcmp(zIn, azChar[i], len)==0 ) break; | |
| 68043 | + if( len<=nIn && memcmp(zIn, azChar[i], len)==0 ) break; | |
| 67778 | 68044 | } |
| 67779 | 68045 | if( i>=nChar ) break; |
| 67780 | 68046 | zIn += len; |
| 67781 | 68047 | nIn -= len; |
| 67782 | 68048 | } |
| @@ -67966,10 +68232,17 @@ | ||
| 67966 | 68232 | CountCtx *p; |
| 67967 | 68233 | p = sqlite3_aggregate_context(context, sizeof(*p)); |
| 67968 | 68234 | if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0])) && p ){ |
| 67969 | 68235 | p->n++; |
| 67970 | 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) ); | |
| 67971 | 68244 | } |
| 67972 | 68245 | static void countFinalize(sqlite3_context *context){ |
| 67973 | 68246 | CountCtx *p; |
| 67974 | 68247 | p = sqlite3_aggregate_context(context, 0); |
| 67975 | 68248 | sqlite3_result_int64(context, p ? p->n : 0); |
| @@ -68014,11 +68287,11 @@ | ||
| 68014 | 68287 | } |
| 68015 | 68288 | static void minMaxFinalize(sqlite3_context *context){ |
| 68016 | 68289 | sqlite3_value *pRes; |
| 68017 | 68290 | pRes = (sqlite3_value *)sqlite3_aggregate_context(context, 0); |
| 68018 | 68291 | if( pRes ){ |
| 68019 | - if( pRes->flags ){ | |
| 68292 | + if( ALWAYS(pRes->flags) ){ | |
| 68020 | 68293 | sqlite3_result_value(context, pRes); |
| 68021 | 68294 | } |
| 68022 | 68295 | sqlite3VdbeMemRelease(pRes); |
| 68023 | 68296 | } |
| 68024 | 68297 | } |
| @@ -68099,11 +68372,11 @@ | ||
| 68099 | 68372 | */ |
| 68100 | 68373 | static void setLikeOptFlag(sqlite3 *db, const char *zName, u8 flagVal){ |
| 68101 | 68374 | FuncDef *pDef; |
| 68102 | 68375 | pDef = sqlite3FindFunction(db, zName, sqlite3Strlen30(zName), |
| 68103 | 68376 | 2, SQLITE_UTF8, 0); |
| 68104 | - if( pDef ){ | |
| 68377 | + if( ALWAYS(pDef) ){ | |
| 68105 | 68378 | pDef->flags = flagVal; |
| 68106 | 68379 | } |
| 68107 | 68380 | } |
| 68108 | 68381 | |
| 68109 | 68382 | /* |
| @@ -68143,11 +68416,11 @@ | ||
| 68143 | 68416 | return 0; |
| 68144 | 68417 | } |
| 68145 | 68418 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 68146 | 68419 | pDef = sqlite3FindFunction(db, (char*)pExpr->token.z, pExpr->token.n, 2, |
| 68147 | 68420 | SQLITE_UTF8, 0); |
| 68148 | - if( pDef==0 || (pDef->flags & SQLITE_FUNC_LIKE)==0 ){ | |
| 68421 | + if( NEVER(pDef==0) || (pDef->flags & SQLITE_FUNC_LIKE)==0 ){ | |
| 68149 | 68422 | return 0; |
| 68150 | 68423 | } |
| 68151 | 68424 | |
| 68152 | 68425 | /* The memcpy() statement assumes that the wildcard characters are |
| 68153 | 68426 | ** the first three statements in the compareInfo structure. The |
| @@ -71141,11 +71414,11 @@ | ||
| 71141 | 71414 | ** May you share freely, never taking more than you give. |
| 71142 | 71415 | ** |
| 71143 | 71416 | ************************************************************************* |
| 71144 | 71417 | ** This file contains code used to implement the PRAGMA command. |
| 71145 | 71418 | ** |
| 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 $ | |
| 71147 | 71420 | */ |
| 71148 | 71421 | |
| 71149 | 71422 | /* Ignore this whole file if pragmas are disabled |
| 71150 | 71423 | */ |
| 71151 | 71424 | #if !defined(SQLITE_OMIT_PRAGMA) && !defined(SQLITE_OMIT_PARSER) |
| @@ -71273,18 +71546,20 @@ | ||
| 71273 | 71546 | #endif /* SQLITE_PAGER_PRAGMAS */ |
| 71274 | 71547 | |
| 71275 | 71548 | /* |
| 71276 | 71549 | ** Generate code to return a single integer value. |
| 71277 | 71550 | */ |
| 71278 | -static void returnSingleInt(Parse *pParse, const char *zLabel, int value){ | |
| 71551 | +static void returnSingleInt(Parse *pParse, const char *zLabel, i64 value){ | |
| 71279 | 71552 | Vdbe *v = sqlite3GetVdbe(pParse); |
| 71280 | 71553 | 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)); | |
| 71285 | 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); | |
| 71286 | 71561 | sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1); |
| 71287 | 71562 | } |
| 71288 | 71563 | |
| 71289 | 71564 | #ifndef SQLITE_OMIT_FLAG_PRAGMAS |
| 71290 | 71565 | /* |
| @@ -71498,11 +71773,11 @@ | ||
| 71498 | 71773 | }else{ |
| 71499 | 71774 | /* Malloc may fail when setting the page-size, as there is an internal |
| 71500 | 71775 | ** buffer that the pager module resizes using sqlite3_realloc(). |
| 71501 | 71776 | */ |
| 71502 | 71777 | db->nextPagesize = atoi(zRight); |
| 71503 | - if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1) ){ | |
| 71778 | + if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1, 0) ){ | |
| 71504 | 71779 | db->mallocFailed = 1; |
| 71505 | 71780 | } |
| 71506 | 71781 | } |
| 71507 | 71782 | }else |
| 71508 | 71783 | |
| @@ -71660,18 +71935,15 @@ | ||
| 71660 | 71935 | */ |
| 71661 | 71936 | if( sqlite3StrICmp(zLeft,"journal_size_limit")==0 ){ |
| 71662 | 71937 | Pager *pPager = sqlite3BtreePager(pDb->pBt); |
| 71663 | 71938 | i64 iLimit = -2; |
| 71664 | 71939 | 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; | |
| 71670 | 71942 | } |
| 71671 | 71943 | iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit); |
| 71672 | - returnSingleInt(pParse, "journal_size_limit", (int)iLimit); | |
| 71944 | + returnSingleInt(pParse, "journal_size_limit", iLimit); | |
| 71673 | 71945 | }else |
| 71674 | 71946 | |
| 71675 | 71947 | #endif /* SQLITE_OMIT_PAGER_PRAGMAS */ |
| 71676 | 71948 | |
| 71677 | 71949 | /* |
| @@ -72208,11 +72480,10 @@ | ||
| 72208 | 72480 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 72209 | 72481 | sqlite3VdbeAddOp2(v, OP_Integer, pIdx->tnum, 2+cnt); |
| 72210 | 72482 | cnt++; |
| 72211 | 72483 | } |
| 72212 | 72484 | } |
| 72213 | - if( cnt==0 ) continue; | |
| 72214 | 72485 | |
| 72215 | 72486 | /* Make sure sufficient number of registers have been allocated */ |
| 72216 | 72487 | if( pParse->nMem < cnt+4 ){ |
| 72217 | 72488 | pParse->nMem = cnt+4; |
| 72218 | 72489 | } |
| @@ -72281,11 +72552,10 @@ | ||
| 72281 | 72552 | { OP_String8, 0, 2, 0}, /* 6 */ |
| 72282 | 72553 | { OP_String8, 0, 3, 0}, /* 7 */ |
| 72283 | 72554 | { OP_Concat, 3, 2, 2}, |
| 72284 | 72555 | { OP_ResultRow, 2, 1, 0}, |
| 72285 | 72556 | }; |
| 72286 | - if( pIdx->tnum==0 ) continue; | |
| 72287 | 72557 | addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); |
| 72288 | 72558 | sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); |
| 72289 | 72559 | sqlite3VdbeJumpHere(v, addr); |
| 72290 | 72560 | addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx); |
| 72291 | 72561 | sqlite3VdbeChangeP1(v, addr+1, j+2); |
| @@ -72578,11 +72848,11 @@ | ||
| 72578 | 72848 | ************************************************************************* |
| 72579 | 72849 | ** This file contains the implementation of the sqlite3_prepare() |
| 72580 | 72850 | ** interface, and routines that contribute to loading the database schema |
| 72581 | 72851 | ** from disk. |
| 72582 | 72852 | ** |
| 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 $ | |
| 72584 | 72854 | */ |
| 72585 | 72855 | |
| 72586 | 72856 | /* |
| 72587 | 72857 | ** Fill the InitData structure with an error message that indicates |
| 72588 | 72858 | ** that the database is corrupt. |
| @@ -73092,15 +73362,12 @@ | ||
| 73092 | 73362 | Parse sParse; |
| 73093 | 73363 | char *zErrMsg = 0; |
| 73094 | 73364 | int rc = SQLITE_OK; |
| 73095 | 73365 | int i; |
| 73096 | 73366 | |
| 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 ); | |
| 73102 | 73369 | assert( !db->mallocFailed ); |
| 73103 | 73370 | assert( sqlite3_mutex_held(db->mutex) ); |
| 73104 | 73371 | |
| 73105 | 73372 | /* Check to verify that it is possible to get a read lock on all |
| 73106 | 73373 | ** database schemas. The inability to get a read lock indicates that |
| @@ -73235,10 +73502,12 @@ | ||
| 73235 | 73502 | int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ |
| 73236 | 73503 | sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ |
| 73237 | 73504 | const char **pzTail /* OUT: End of parsed string */ |
| 73238 | 73505 | ){ |
| 73239 | 73506 | int rc; |
| 73507 | + assert( ppStmt!=0 ); | |
| 73508 | + *ppStmt = 0; | |
| 73240 | 73509 | if( !sqlite3SafetyCheckOk(db) ){ |
| 73241 | 73510 | return SQLITE_MISUSE; |
| 73242 | 73511 | } |
| 73243 | 73512 | sqlite3_mutex_enter(db->mutex); |
| 73244 | 73513 | sqlite3BtreeEnterAll(db); |
| @@ -73337,10 +73606,12 @@ | ||
| 73337 | 73606 | */ |
| 73338 | 73607 | char *zSql8; |
| 73339 | 73608 | const char *zTail8 = 0; |
| 73340 | 73609 | int rc = SQLITE_OK; |
| 73341 | 73610 | |
| 73611 | + assert( ppStmt ); | |
| 73612 | + *ppStmt = 0; | |
| 73342 | 73613 | if( !sqlite3SafetyCheckOk(db) ){ |
| 73343 | 73614 | return SQLITE_MISUSE; |
| 73344 | 73615 | } |
| 73345 | 73616 | sqlite3_mutex_enter(db->mutex); |
| 73346 | 73617 | zSql8 = sqlite3Utf16to8(db, zSql, nBytes); |
| @@ -73412,11 +73683,11 @@ | ||
| 73412 | 73683 | ** |
| 73413 | 73684 | ************************************************************************* |
| 73414 | 73685 | ** This file contains C code routines that are called by the parser |
| 73415 | 73686 | ** to handle SELECT statements in SQLite. |
| 73416 | 73687 | ** |
| 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 $ | |
| 73418 | 73689 | */ |
| 73419 | 73690 | |
| 73420 | 73691 | |
| 73421 | 73692 | /* |
| 73422 | 73693 | ** Delete all the content of a Select structure but do not deallocate |
| @@ -75953,10 +76224,16 @@ | ||
| 75953 | 76224 | ** ORDER by clause of the parent must be simple references to |
| 75954 | 76225 | ** columns of the sub-query. |
| 75955 | 76226 | ** |
| 75956 | 76227 | ** (19) The subquery does not use LIMIT or the outer query does not |
| 75957 | 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. | |
| 75958 | 76235 | ** |
| 75959 | 76236 | ** In this routine, the "p" parameter is a pointer to the outer query. |
| 75960 | 76237 | ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query |
| 75961 | 76238 | ** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates. |
| 75962 | 76239 | ** |
| @@ -76064,10 +76341,13 @@ | ||
| 76064 | 76341 | ** use only the UNION ALL operator. And none of the simple select queries |
| 76065 | 76342 | ** that make up the compound SELECT are allowed to be aggregate or distinct |
| 76066 | 76343 | ** queries. |
| 76067 | 76344 | */ |
| 76068 | 76345 | if( pSub->pPrior ){ |
| 76346 | + if( pSub->pOrderBy ){ | |
| 76347 | + return 0; /* Restriction 20 */ | |
| 76348 | + } | |
| 76069 | 76349 | if( isAgg || (p->selFlags & SF_Distinct)!=0 || pSrc->nSrc!=1 ){ |
| 76070 | 76350 | return 0; |
| 76071 | 76351 | } |
| 76072 | 76352 | for(pSub1=pSub; pSub1; pSub1=pSub1->pPrior){ |
| 76073 | 76353 | if( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))!=0 |
| @@ -77706,52 +77986,51 @@ | ||
| 77706 | 77986 | ** interface routine of sqlite3_exec(). |
| 77707 | 77987 | ** |
| 77708 | 77988 | ** These routines are in a separate files so that they will not be linked |
| 77709 | 77989 | ** if they are not used. |
| 77710 | 77990 | ** |
| 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 $ | |
| 77712 | 77992 | */ |
| 77713 | 77993 | |
| 77714 | 77994 | #ifndef SQLITE_OMIT_GET_TABLE |
| 77715 | 77995 | |
| 77716 | 77996 | /* |
| 77717 | 77997 | ** This structure is used to pass data from sqlite3_get_table() through |
| 77718 | 77998 | ** to the callback function is uses to build the result. |
| 77719 | 77999 | */ |
| 77720 | 78000 | 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() */ | |
| 77729 | 78008 | } TabResult; |
| 77730 | 78009 | |
| 77731 | 78010 | /* |
| 77732 | 78011 | ** This routine is called once for each row in the result table. Its job |
| 77733 | 78012 | ** is to fill in the TabResult structure appropriately, allocating new |
| 77734 | 78013 | ** memory as necessary. |
| 77735 | 78014 | */ |
| 77736 | 78015 | 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 */ | |
| 77741 | 78020 | |
| 77742 | 78021 | /* Make sure there is enough space in p->azResult to hold everything |
| 77743 | 78022 | ** we need to remember from this invocation of the callback. |
| 77744 | 78023 | */ |
| 77745 | 78024 | if( p->nRow==0 && argv!=0 ){ |
| 77746 | 78025 | need = nCol*2; |
| 77747 | 78026 | }else{ |
| 77748 | 78027 | need = nCol; |
| 77749 | 78028 | } |
| 77750 | - if( p->nData + need >= p->nAlloc ){ | |
| 78029 | + if( p->nData + need > p->nAlloc ){ | |
| 77751 | 78030 | char **azNew; |
| 77752 | - p->nAlloc = p->nAlloc*2 + need + 1; | |
| 78031 | + p->nAlloc = p->nAlloc*2 + need; | |
| 77753 | 78032 | azNew = sqlite3_realloc( p->azResult, sizeof(char*)*p->nAlloc ); |
| 77754 | 78033 | if( azNew==0 ) goto malloc_failed; |
| 77755 | 78034 | p->azResult = azNew; |
| 77756 | 78035 | } |
| 77757 | 78036 | |
| @@ -77821,11 +78100,10 @@ | ||
| 77821 | 78100 | *pazResult = 0; |
| 77822 | 78101 | if( pnColumn ) *pnColumn = 0; |
| 77823 | 78102 | if( pnRow ) *pnRow = 0; |
| 77824 | 78103 | if( pzErrMsg ) *pzErrMsg = 0; |
| 77825 | 78104 | res.zErrMsg = 0; |
| 77826 | - res.nResult = 0; | |
| 77827 | 78105 | res.nRow = 0; |
| 77828 | 78106 | res.nColumn = 0; |
| 77829 | 78107 | res.nData = 1; |
| 77830 | 78108 | res.nAlloc = 20; |
| 77831 | 78109 | res.rc = SQLITE_OK; |
| @@ -77855,17 +78133,16 @@ | ||
| 77855 | 78133 | sqlite3_free_table(&res.azResult[1]); |
| 77856 | 78134 | return rc; |
| 77857 | 78135 | } |
| 77858 | 78136 | if( res.nAlloc>res.nData ){ |
| 77859 | 78137 | char **azNew; |
| 77860 | - azNew = sqlite3_realloc( res.azResult, sizeof(char*)*(res.nData+1) ); | |
| 78138 | + azNew = sqlite3_realloc( res.azResult, sizeof(char*)*res.nData ); | |
| 77861 | 78139 | if( azNew==0 ){ |
| 77862 | 78140 | sqlite3_free_table(&res.azResult[1]); |
| 77863 | 78141 | db->errCode = SQLITE_NOMEM; |
| 77864 | 78142 | return SQLITE_NOMEM; |
| 77865 | 78143 | } |
| 77866 | - res.nAlloc = res.nData+1; | |
| 77867 | 78144 | res.azResult = azNew; |
| 77868 | 78145 | } |
| 77869 | 78146 | *pazResult = &res.azResult[1]; |
| 77870 | 78147 | if( pnColumn ) *pnColumn = res.nColumn; |
| 77871 | 78148 | if( pnRow ) *pnRow = res.nRow; |
| @@ -79468,11 +79745,11 @@ | ||
| 79468 | 79745 | ** This file contains code used to implement the VACUUM command. |
| 79469 | 79746 | ** |
| 79470 | 79747 | ** Most of the code in this file may be omitted by defining the |
| 79471 | 79748 | ** SQLITE_OMIT_VACUUM macro. |
| 79472 | 79749 | ** |
| 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 $ | |
| 79474 | 79751 | */ |
| 79475 | 79752 | |
| 79476 | 79753 | #if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH) |
| 79477 | 79754 | /* |
| 79478 | 79755 | ** Execute zSql on database db. Return an error code. |
| @@ -79592,12 +79869,12 @@ | ||
| 79592 | 79869 | sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey); |
| 79593 | 79870 | if( nKey ) db->nextPagesize = 0; |
| 79594 | 79871 | } |
| 79595 | 79872 | #endif |
| 79596 | 79873 | |
| 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)) | |
| 79599 | 79876 | || db->mallocFailed |
| 79600 | 79877 | ){ |
| 79601 | 79878 | rc = SQLITE_NOMEM; |
| 79602 | 79879 | goto end_of_vacuum; |
| 79603 | 79880 | } |
| @@ -79720,11 +79997,11 @@ | ||
| 79720 | 79997 | sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp)); |
| 79721 | 79998 | #endif |
| 79722 | 79999 | } |
| 79723 | 80000 | |
| 79724 | 80001 | if( rc==SQLITE_OK ){ |
| 79725 | - rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes); | |
| 80002 | + rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes,1); | |
| 79726 | 80003 | } |
| 79727 | 80004 | |
| 79728 | 80005 | end_of_vacuum: |
| 79729 | 80006 | /* Restore the original value of db->flags */ |
| 79730 | 80007 | db->flags = saved_flags; |
| @@ -79765,14 +80042,19 @@ | ||
| 79765 | 80042 | ** May you share freely, never taking more than you give. |
| 79766 | 80043 | ** |
| 79767 | 80044 | ************************************************************************* |
| 79768 | 80045 | ** This file contains code used to help implement virtual tables. |
| 79769 | 80046 | ** |
| 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 $ | |
| 79771 | 80048 | */ |
| 79772 | 80049 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 79773 | 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 | +*/ | |
| 79774 | 80056 | static int createModule( |
| 79775 | 80057 | sqlite3 *db, /* Database in which module is registered */ |
| 79776 | 80058 | const char *zName, /* Name assigned to this module */ |
| 79777 | 80059 | const sqlite3_module *pModule, /* The definition of the module */ |
| 79778 | 80060 | void *pAux, /* Context pointer for xCreate/xConnect */ |
| @@ -79850,10 +80132,11 @@ | ||
| 79850 | 80132 | /* |
| 79851 | 80133 | ** Unlock a virtual table. When the last lock is removed, |
| 79852 | 80134 | ** disconnect the virtual table. |
| 79853 | 80135 | */ |
| 79854 | 80136 | SQLITE_PRIVATE void sqlite3VtabUnlock(sqlite3 *db, sqlite3_vtab *pVtab){ |
| 80137 | + assert( pVtab->nRef>0 ); | |
| 79855 | 80138 | pVtab->nRef--; |
| 79856 | 80139 | assert(db); |
| 79857 | 80140 | assert( sqlite3SafetyCheckOk(db) ); |
| 79858 | 80141 | if( pVtab->nRef==0 ){ |
| 79859 | 80142 | if( db->magic==SQLITE_MAGIC_BUSY ){ |
| @@ -80618,20 +80901,20 @@ | ||
| 80618 | 80901 | ** generating the code that loops through a table looking for applicable |
| 80619 | 80902 | ** rows. Indices are selected and used to speed the search when doing |
| 80620 | 80903 | ** so is applicable. Because this module is responsible for selecting |
| 80621 | 80904 | ** indices, you might also think of this module as the "query optimizer". |
| 80622 | 80905 | ** |
| 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 $ | |
| 80624 | 80907 | */ |
| 80625 | 80908 | |
| 80626 | 80909 | /* |
| 80627 | 80910 | ** Trace output macros |
| 80628 | 80911 | */ |
| 80629 | 80912 | #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG) |
| 80630 | 80913 | SQLITE_PRIVATE int sqlite3WhereTrace = 0; |
| 80631 | 80914 | #endif |
| 80632 | -#if 0 | |
| 80915 | +#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG) | |
| 80633 | 80916 | # define WHERETRACE(X) if(sqlite3WhereTrace) sqlite3DebugPrintf X |
| 80634 | 80917 | #else |
| 80635 | 80918 | # define WHERETRACE(X) |
| 80636 | 80919 | #endif |
| 80637 | 80920 | |
| @@ -82363,10 +82646,17 @@ | ||
| 82363 | 82646 | */ |
| 82364 | 82647 | memset(pCost, 0, sizeof(*pCost)); |
| 82365 | 82648 | if( pProbe==0 && |
| 82366 | 82649 | findTerm(pWC, iCur, -1, 0, WO_EQ|WO_IN|WO_LT|WO_LE|WO_GT|WO_GE,0)==0 && |
| 82367 | 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 | + } | |
| 82368 | 82658 | return; |
| 82369 | 82659 | } |
| 82370 | 82660 | pCost->rCost = SQLITE_BIG_DBL; |
| 82371 | 82661 | |
| 82372 | 82662 | /* Check for a rowid=EXPR or rowid IN (...) constraints. If there was |
| @@ -84205,12 +84495,12 @@ | ||
| 84205 | 84495 | #endif |
| 84206 | 84496 | #define sqlite3ParserARG_SDECL Parse *pParse; |
| 84207 | 84497 | #define sqlite3ParserARG_PDECL ,Parse *pParse |
| 84208 | 84498 | #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse |
| 84209 | 84499 | #define sqlite3ParserARG_STORE yypParser->pParse = pParse |
| 84210 | -#define YYNSTATE 613 | |
| 84211 | -#define YYNRULE 321 | |
| 84500 | +#define YYNSTATE 616 | |
| 84501 | +#define YYNRULE 323 | |
| 84212 | 84502 | #define YYFALLBACK 1 |
| 84213 | 84503 | #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) |
| 84214 | 84504 | #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) |
| 84215 | 84505 | #define YY_ERROR_ACTION (YYNSTATE+YYNRULE) |
| 84216 | 84506 | |
| @@ -84265,161 +84555,160 @@ | ||
| 84265 | 84555 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
| 84266 | 84556 | ** shifting non-terminals after a reduce. |
| 84267 | 84557 | ** yy_default[] Default action for each state. |
| 84268 | 84558 | */ |
| 84269 | 84559 | 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, | |
| 84278 | 84568 | /* 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, | |
| 84298 | 84588 | /* 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, | |
| 84305 | 84595 | /* 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, | |
| 84326 | 84616 | /* 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, | |
| 84333 | 84623 | /* 630 */ 25, 25, 24, 24, 24, 24, 331, 26, 26, 26, |
| 84334 | 84624 | /* 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, | |
| 84341 | 84631 | /* 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, | |
| 84348 | 84638 | /* 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, | |
| 84355 | 84645 | /* 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, | |
| 84362 | 84652 | /* 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, | |
| 84369 | 84659 | /* 990 */ 25, 25, 24, 24, 24, 24, 331, 26, 26, 26, |
| 84370 | 84660 | /* 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, | |
| 84377 | 84667 | /* 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, | |
| 84421 | 84710 | }; |
| 84422 | 84711 | static const YYCODETYPE yy_lookahead[] = { |
| 84423 | 84712 | /* 0 */ 19, 142, 143, 144, 145, 24, 116, 26, 75, 76, |
| 84424 | 84713 | /* 10 */ 77, 78, 25, 80, 81, 82, 83, 84, 85, 86, |
| 84425 | 84714 | /* 20 */ 87, 88, 89, 90, 26, 27, 160, 26, 27, 48, |
| @@ -84433,290 +84722,289 @@ | ||
| 84433 | 84722 | /* 100 */ 19, 48, 49, 150, 174, 52, 119, 166, 110, 84, |
| 84434 | 84723 | /* 110 */ 85, 86, 87, 88, 89, 90, 26, 27, 165, 66, |
| 84435 | 84724 | /* 120 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 84436 | 84725 | /* 130 */ 77, 78, 186, 80, 81, 82, 83, 84, 85, 86, |
| 84437 | 84726 | /* 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, | |
| 84440 | 84729 | /* 170 */ 217, 90, 120, 48, 49, 50, 86, 165, 97, 98, |
| 84441 | 84730 | /* 180 */ 99, 100, 101, 102, 94, 95, 174, 175, 1, 2, |
| 84442 | 84731 | /* 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, | |
| 84450 | 84739 | /* 270 */ 73, 74, 75, 76, 77, 78, 194, 80, 81, 82, |
| 84451 | 84740 | /* 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, | |
| 84457 | 84746 | /* 340 */ 71, 72, 73, 74, 75, 76, 77, 78, 194, 80, |
| 84458 | 84747 | /* 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, | |
| 84464 | 84753 | /* 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, | |
| 84471 | 84760 | /* 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, | |
| 84479 | 84768 | /* 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, | |
| 84486 | 84775 | /* 630 */ 73, 74, 75, 76, 77, 78, 150, 80, 81, 82, |
| 84487 | 84776 | /* 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, | |
| 84493 | 84782 | /* 700 */ 71, 72, 73, 74, 75, 76, 77, 78, 150, 80, |
| 84494 | 84783 | /* 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, | |
| 84500 | 84789 | /* 770 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 84501 | 84790 | /* 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, | |
| 84507 | 84796 | /* 840 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 84508 | 84797 | /* 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, | |
| 84515 | 84804 | /* 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, | |
| 84522 | 84811 | /* 990 */ 73, 74, 75, 76, 77, 78, 150, 80, 81, 82, |
| 84523 | 84812 | /* 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, | |
| 84529 | 84818 | /* 1060 */ 71, 72, 73, 74, 75, 76, 77, 78, 218, 80, |
| 84530 | 84819 | /* 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, | |
| 84540 | 84829 | /* 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, | |
| 84543 | 84832 | /* 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, | |
| 84574 | 84862 | }; |
| 84575 | 84863 | #define YY_SHIFT_USE_DFLT (-111) |
| 84576 | -#define YY_SHIFT_MAX 405 | |
| 84864 | +#define YY_SHIFT_MAX 406 | |
| 84577 | 84865 | 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, | |
| 84580 | 84868 | /* 20 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, |
| 84581 | 84869 | /* 30 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, |
| 84582 | 84870 | /* 40 */ 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, |
| 84583 | 84871 | /* 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, | |
| 84585 | 84873 | /* 70 */ 341, 413, 485, 557, 629, 701, 773, 845, 773, 773, |
| 84586 | 84874 | /* 80 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773, |
| 84587 | 84875 | /* 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, | |
| 84593 | 84881 | /* 150 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 84594 | 84882 | /* 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, | |
| 84619 | 84907 | }; |
| 84620 | 84908 | #define YY_REDUCE_USE_DFLT (-180) |
| 84621 | 84909 | #define YY_REDUCE_MAX 303 |
| 84622 | 84910 | 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, | |
| 84630 | 84918 | /* 70 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 84631 | 84919 | /* 80 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 84632 | 84920 | /* 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, | |
| 84654 | 84942 | }; |
| 84655 | 84943 | 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, | |
| 84718 | 85006 | }; |
| 84719 | 85007 | #define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0])) |
| 84720 | 85008 | |
| 84721 | 85009 | /* The next table maps tokens into fallback tokens. If a construct |
| 84722 | 85010 | ** like the following: |
| @@ -85271,76 +85559,78 @@ | ||
| 85271 | 85559 | /* 250 */ "collate ::=", |
| 85272 | 85560 | /* 251 */ "collate ::= COLLATE ids", |
| 85273 | 85561 | /* 252 */ "cmd ::= DROP INDEX ifexists fullname", |
| 85274 | 85562 | /* 253 */ "cmd ::= VACUUM", |
| 85275 | 85563 | /* 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", | |
| 85279 | 85567 | /* 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", | |
| 85342 | 85632 | }; |
| 85343 | 85633 | #endif /* NDEBUG */ |
| 85344 | 85634 | |
| 85345 | 85635 | |
| 85346 | 85636 | #if YYSTACKDEPTH<=0 |
| @@ -85963,16 +86253,18 @@ | ||
| 85963 | 86253 | { 230, 0 }, |
| 85964 | 86254 | { 230, 2 }, |
| 85965 | 86255 | { 147, 4 }, |
| 85966 | 86256 | { 147, 1 }, |
| 85967 | 86257 | { 147, 2 }, |
| 85968 | - { 147, 5 }, | |
| 86258 | + { 147, 3 }, | |
| 85969 | 86259 | { 147, 5 }, |
| 85970 | - { 147, 5 }, | |
| 86260 | + { 147, 6 }, | |
| 85971 | 86261 | { 147, 5 }, |
| 85972 | 86262 | { 147, 6 }, |
| 85973 | - { 147, 3 }, | |
| 86263 | + { 231, 1 }, | |
| 86264 | + { 231, 1 }, | |
| 86265 | + { 231, 1 }, | |
| 85974 | 86266 | { 231, 1 }, |
| 85975 | 86267 | { 231, 1 }, |
| 85976 | 86268 | { 170, 2 }, |
| 85977 | 86269 | { 171, 2 }, |
| 85978 | 86270 | { 233, 1 }, |
| @@ -86108,22 +86400,22 @@ | ||
| 86108 | 86400 | case 62: /* ccons ::= NULL onconf */ |
| 86109 | 86401 | case 89: /* conslist ::= conslist COMMA tcons */ |
| 86110 | 86402 | case 90: /* conslist ::= conslist tcons */ |
| 86111 | 86403 | case 91: /* conslist ::= tcons */ |
| 86112 | 86404 | 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 ::= */ | |
| 86125 | 86417 | { |
| 86126 | 86418 | } |
| 86127 | 86419 | break; |
| 86128 | 86420 | case 5: /* explain ::= */ |
| 86129 | 86421 | { sqlite3BeginParse(pParse, 0); } |
| @@ -86240,15 +86532,18 @@ | ||
| 86240 | 86532 | case 126: /* as ::= AS nm */ |
| 86241 | 86533 | case 127: /* as ::= ids */ |
| 86242 | 86534 | case 137: /* dbnm ::= DOT nm */ |
| 86243 | 86535 | case 146: /* indexed_opt ::= INDEXED BY nm */ |
| 86244 | 86536 | 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 */ | |
| 86250 | 86545 | {yygotominor.yy0 = yymsp[0].minor.yy0;} |
| 86251 | 86546 | break; |
| 86252 | 86547 | case 45: /* type ::= typetoken */ |
| 86253 | 86548 | {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);} |
| 86254 | 86549 | break; |
| @@ -86888,11 +87183,11 @@ | ||
| 86888 | 87183 | sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy148, yymsp[-9].minor.yy194, |
| 86889 | 87184 | &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy194); |
| 86890 | 87185 | } |
| 86891 | 87186 | break; |
| 86892 | 87187 | case 244: /* uniqueflag ::= UNIQUE */ |
| 86893 | - case 291: /* raisetype ::= ABORT */ | |
| 87188 | + case 293: /* raisetype ::= ABORT */ | |
| 86894 | 87189 | {yygotominor.yy194 = OE_Abort;} |
| 86895 | 87190 | break; |
| 86896 | 87191 | case 245: /* uniqueflag ::= */ |
| 86897 | 87192 | {yygotominor.yy194 = OE_None;} |
| 86898 | 87193 | break; |
| @@ -86928,66 +87223,65 @@ | ||
| 86928 | 87223 | break; |
| 86929 | 87224 | case 253: /* cmd ::= VACUUM */ |
| 86930 | 87225 | case 254: /* cmd ::= VACUUM nm */ |
| 86931 | 87226 | {sqlite3Vacuum(pParse);} |
| 86932 | 87227 | 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 */ | |
| 86936 | 87232 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 86937 | 87233 | 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 */ | |
| 86944 | 87235 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 86945 | 87236 | 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);} | |
| 86948 | 87242 | 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 */ | |
| 86950 | 87244 | { |
| 86951 | 87245 | Token all; |
| 86952 | 87246 | all.z = yymsp[-3].minor.yy0.z; |
| 86953 | 87247 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 86954 | 87248 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all); |
| 86955 | 87249 | } |
| 86956 | 87250 | 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 */ | |
| 86958 | 87252 | { |
| 86959 | 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); |
| 86960 | 87254 | yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); |
| 86961 | 87255 | } |
| 86962 | 87256 | break; |
| 86963 | - case 270: /* trigger_time ::= BEFORE */ | |
| 86964 | - case 273: /* trigger_time ::= */ | |
| 87257 | + case 272: /* trigger_time ::= BEFORE */ | |
| 87258 | + case 275: /* trigger_time ::= */ | |
| 86965 | 87259 | { yygotominor.yy194 = TK_BEFORE; } |
| 86966 | 87260 | break; |
| 86967 | - case 271: /* trigger_time ::= AFTER */ | |
| 87261 | + case 273: /* trigger_time ::= AFTER */ | |
| 86968 | 87262 | { yygotominor.yy194 = TK_AFTER; } |
| 86969 | 87263 | break; |
| 86970 | - case 272: /* trigger_time ::= INSTEAD OF */ | |
| 87264 | + case 274: /* trigger_time ::= INSTEAD OF */ | |
| 86971 | 87265 | { yygotominor.yy194 = TK_INSTEAD;} |
| 86972 | 87266 | 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 */ | |
| 86975 | 87269 | {yygotominor.yy332.a = yymsp[0].major; yygotominor.yy332.b = 0;} |
| 86976 | 87270 | break; |
| 86977 | - case 276: /* trigger_event ::= UPDATE OF inscollist */ | |
| 87271 | + case 278: /* trigger_event ::= UPDATE OF inscollist */ | |
| 86978 | 87272 | {yygotominor.yy332.a = TK_UPDATE; yygotominor.yy332.b = yymsp[0].minor.yy254;} |
| 86979 | 87273 | break; |
| 86980 | - case 279: /* when_clause ::= */ | |
| 86981 | - case 296: /* key_opt ::= */ | |
| 87274 | + case 281: /* when_clause ::= */ | |
| 87275 | + case 298: /* key_opt ::= */ | |
| 86982 | 87276 | { yygotominor.yy72 = 0; } |
| 86983 | 87277 | 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 */ | |
| 86986 | 87280 | { yygotominor.yy72 = yymsp[0].minor.yy72; } |
| 86987 | 87281 | 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 */ | |
| 86989 | 87283 | { |
| 86990 | 87284 | /* |
| 86991 | 87285 | if( yymsp[-2].minor.yy145 ){ |
| 86992 | 87286 | yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145; |
| 86993 | 87287 | }else{ |
| @@ -86998,118 +87292,118 @@ | ||
| 86998 | 87292 | yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145; |
| 86999 | 87293 | yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145; |
| 87000 | 87294 | yygotominor.yy145 = yymsp[-2].minor.yy145; |
| 87001 | 87295 | } |
| 87002 | 87296 | break; |
| 87003 | - case 282: /* trigger_cmd_list ::= trigger_cmd SEMI */ | |
| 87297 | + case 284: /* trigger_cmd_list ::= trigger_cmd SEMI */ | |
| 87004 | 87298 | { |
| 87005 | 87299 | /* if( yymsp[-1].minor.yy145 ) */ |
| 87006 | 87300 | assert( yymsp[-1].minor.yy145!=0 ); |
| 87007 | 87301 | yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145; |
| 87008 | 87302 | yygotominor.yy145 = yymsp[-1].minor.yy145; |
| 87009 | 87303 | } |
| 87010 | 87304 | 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 */ | |
| 87012 | 87306 | { yygotominor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-4].minor.yy194); } |
| 87013 | 87307 | 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 */ | |
| 87015 | 87309 | {yygotominor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy254, yymsp[-1].minor.yy148, 0, yymsp[-7].minor.yy194);} |
| 87016 | 87310 | 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 */ | |
| 87018 | 87312 | {yygotominor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, 0, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);} |
| 87019 | 87313 | break; |
| 87020 | - case 286: /* trigger_cmd ::= DELETE FROM nm where_opt */ | |
| 87314 | + case 288: /* trigger_cmd ::= DELETE FROM nm where_opt */ | |
| 87021 | 87315 | {yygotominor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-1].minor.yy0, yymsp[0].minor.yy72);} |
| 87022 | 87316 | break; |
| 87023 | - case 287: /* trigger_cmd ::= select */ | |
| 87317 | + case 289: /* trigger_cmd ::= select */ | |
| 87024 | 87318 | {yygotominor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); } |
| 87025 | 87319 | break; |
| 87026 | - case 288: /* expr ::= RAISE LP IGNORE RP */ | |
| 87320 | + case 290: /* expr ::= RAISE LP IGNORE RP */ | |
| 87027 | 87321 | { |
| 87028 | 87322 | yygotominor.yy72 = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); |
| 87029 | 87323 | if( yygotominor.yy72 ){ |
| 87030 | 87324 | yygotominor.yy72->affinity = OE_Ignore; |
| 87031 | 87325 | sqlite3ExprSpan(yygotominor.yy72, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0); |
| 87032 | 87326 | } |
| 87033 | 87327 | } |
| 87034 | 87328 | break; |
| 87035 | - case 289: /* expr ::= RAISE LP raisetype COMMA nm RP */ | |
| 87329 | + case 291: /* expr ::= RAISE LP raisetype COMMA nm RP */ | |
| 87036 | 87330 | { |
| 87037 | 87331 | yygotominor.yy72 = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); |
| 87038 | 87332 | if( yygotominor.yy72 ) { |
| 87039 | 87333 | yygotominor.yy72->affinity = (char)yymsp[-3].minor.yy194; |
| 87040 | 87334 | sqlite3ExprSpan(yygotominor.yy72, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0); |
| 87041 | 87335 | } |
| 87042 | 87336 | } |
| 87043 | 87337 | break; |
| 87044 | - case 290: /* raisetype ::= ROLLBACK */ | |
| 87338 | + case 292: /* raisetype ::= ROLLBACK */ | |
| 87045 | 87339 | {yygotominor.yy194 = OE_Rollback;} |
| 87046 | 87340 | break; |
| 87047 | - case 292: /* raisetype ::= FAIL */ | |
| 87341 | + case 294: /* raisetype ::= FAIL */ | |
| 87048 | 87342 | {yygotominor.yy194 = OE_Fail;} |
| 87049 | 87343 | break; |
| 87050 | - case 293: /* cmd ::= DROP TRIGGER ifexists fullname */ | |
| 87344 | + case 295: /* cmd ::= DROP TRIGGER ifexists fullname */ | |
| 87051 | 87345 | { |
| 87052 | 87346 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194); |
| 87053 | 87347 | } |
| 87054 | 87348 | 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 */ | |
| 87056 | 87350 | { |
| 87057 | 87351 | sqlite3Attach(pParse, yymsp[-3].minor.yy72, yymsp[-1].minor.yy72, yymsp[0].minor.yy72); |
| 87058 | 87352 | } |
| 87059 | 87353 | break; |
| 87060 | - case 295: /* cmd ::= DETACH database_kw_opt expr */ | |
| 87354 | + case 297: /* cmd ::= DETACH database_kw_opt expr */ | |
| 87061 | 87355 | { |
| 87062 | 87356 | sqlite3Detach(pParse, yymsp[0].minor.yy72); |
| 87063 | 87357 | } |
| 87064 | 87358 | break; |
| 87065 | - case 300: /* cmd ::= REINDEX */ | |
| 87359 | + case 302: /* cmd ::= REINDEX */ | |
| 87066 | 87360 | {sqlite3Reindex(pParse, 0, 0);} |
| 87067 | 87361 | break; |
| 87068 | - case 301: /* cmd ::= REINDEX nm dbnm */ | |
| 87362 | + case 303: /* cmd ::= REINDEX nm dbnm */ | |
| 87069 | 87363 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 87070 | 87364 | break; |
| 87071 | - case 302: /* cmd ::= ANALYZE */ | |
| 87365 | + case 304: /* cmd ::= ANALYZE */ | |
| 87072 | 87366 | {sqlite3Analyze(pParse, 0, 0);} |
| 87073 | 87367 | break; |
| 87074 | - case 303: /* cmd ::= ANALYZE nm dbnm */ | |
| 87368 | + case 305: /* cmd ::= ANALYZE nm dbnm */ | |
| 87075 | 87369 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 87076 | 87370 | break; |
| 87077 | - case 304: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ | |
| 87371 | + case 306: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ | |
| 87078 | 87372 | { |
| 87079 | 87373 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0); |
| 87080 | 87374 | } |
| 87081 | 87375 | 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 */ | |
| 87083 | 87377 | { |
| 87084 | 87378 | sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0); |
| 87085 | 87379 | } |
| 87086 | 87380 | break; |
| 87087 | - case 306: /* add_column_fullname ::= fullname */ | |
| 87381 | + case 308: /* add_column_fullname ::= fullname */ | |
| 87088 | 87382 | { |
| 87089 | 87383 | pParse->db->lookaside.bEnabled = 0; |
| 87090 | 87384 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185); |
| 87091 | 87385 | } |
| 87092 | 87386 | break; |
| 87093 | - case 309: /* cmd ::= create_vtab */ | |
| 87387 | + case 311: /* cmd ::= create_vtab */ | |
| 87094 | 87388 | {sqlite3VtabFinishParse(pParse,0);} |
| 87095 | 87389 | break; |
| 87096 | - case 310: /* cmd ::= create_vtab LP vtabarglist RP */ | |
| 87390 | + case 312: /* cmd ::= create_vtab LP vtabarglist RP */ | |
| 87097 | 87391 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 87098 | 87392 | 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 */ | |
| 87100 | 87394 | { |
| 87101 | 87395 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); |
| 87102 | 87396 | } |
| 87103 | 87397 | break; |
| 87104 | - case 314: /* vtabarg ::= */ | |
| 87398 | + case 316: /* vtabarg ::= */ | |
| 87105 | 87399 | {sqlite3VtabArgInit(pParse);} |
| 87106 | 87400 | 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 */ | |
| 87111 | 87405 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 87112 | 87406 | break; |
| 87113 | 87407 | }; |
| 87114 | 87408 | yygoto = yyRuleInfo[yyruleno].lhs; |
| 87115 | 87409 | yysize = yyRuleInfo[yyruleno].nrhs; |
| @@ -88437,11 +88731,11 @@ | ||
| 88437 | 88731 | ** Main file for the SQLite library. The routines in this file |
| 88438 | 88732 | ** implement the programmer interface to the library. Routines in |
| 88439 | 88733 | ** other files are for internal use by SQLite and should not be |
| 88440 | 88734 | ** accessed by users of the library. |
| 88441 | 88735 | ** |
| 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 $ | |
| 88443 | 88737 | */ |
| 88444 | 88738 | |
| 88445 | 88739 | #ifdef SQLITE_ENABLE_FTS3 |
| 88446 | 88740 | /************** Include fts3.h in the middle of main.c ***********************/ |
| 88447 | 88741 | /************** Begin file fts3.h ********************************************/ |
| @@ -88729,10 +89023,11 @@ | ||
| 88729 | 89023 | sqlite3GlobalConfig.isMallocInit = 0; |
| 88730 | 89024 | sqlite3PcacheShutdown(); |
| 88731 | 89025 | if( sqlite3GlobalConfig.isInit ){ |
| 88732 | 89026 | sqlite3_os_end(); |
| 88733 | 89027 | } |
| 89028 | + sqlite3_reset_auto_extension(); | |
| 88734 | 89029 | sqlite3MallocEnd(); |
| 88735 | 89030 | sqlite3MutexEnd(); |
| 88736 | 89031 | sqlite3GlobalConfig.isInit = 0; |
| 88737 | 89032 | return SQLITE_OK; |
| 88738 | 89033 | } |
| @@ -88928,11 +89223,11 @@ | ||
| 88928 | 89223 | db->lookaside.pFree = 0; |
| 88929 | 89224 | db->lookaside.sz = (u16)sz; |
| 88930 | 89225 | if( pStart ){ |
| 88931 | 89226 | int i; |
| 88932 | 89227 | LookasideSlot *p; |
| 88933 | - assert( sz > sizeof(LookasideSlot*) ); | |
| 89228 | + assert( sz > (int)sizeof(LookasideSlot*) ); | |
| 88934 | 89229 | p = (LookasideSlot*)pStart; |
| 88935 | 89230 | for(i=cnt-1; i>=0; i--){ |
| 88936 | 89231 | p->pNext = db->lookaside.pFree; |
| 88937 | 89232 | db->lookaside.pFree = p; |
| 88938 | 89233 | p = (LookasideSlot*)&((u8*)p)[sz]; |
| @@ -90705,11 +91000,11 @@ | ||
| 90705 | 91000 | ************************************************************************* |
| 90706 | 91001 | ** |
| 90707 | 91002 | ** This file contains the implementation of the sqlite3_unlock_notify() |
| 90708 | 91003 | ** API method and its associated functionality. |
| 90709 | 91004 | ** |
| 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 $ | |
| 90711 | 91006 | */ |
| 90712 | 91007 | |
| 90713 | 91008 | /* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */ |
| 90714 | 91009 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| 90715 | 91010 | |
| @@ -90802,26 +91097,44 @@ | ||
| 90802 | 91097 | } |
| 90803 | 91098 | |
| 90804 | 91099 | /* |
| 90805 | 91100 | ** Obtain the STATIC_MASTER mutex. |
| 90806 | 91101 | */ |
| 90807 | -static void enterMutex(){ | |
| 91102 | +static void enterMutex(void){ | |
| 90808 | 91103 | sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); |
| 90809 | 91104 | checkListProperties(0); |
| 90810 | 91105 | } |
| 90811 | 91106 | |
| 90812 | 91107 | /* |
| 90813 | 91108 | ** Release the STATIC_MASTER mutex. |
| 90814 | 91109 | */ |
| 90815 | -static void leaveMutex(){ | |
| 91110 | +static void leaveMutex(void){ | |
| 90816 | 91111 | assertMutexHeld(); |
| 90817 | 91112 | checkListProperties(0); |
| 90818 | 91113 | sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); |
| 90819 | 91114 | } |
| 90820 | 91115 | |
| 90821 | 91116 | /* |
| 90822 | 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. | |
| 90823 | 91136 | */ |
| 90824 | 91137 | SQLITE_API int sqlite3_unlock_notify( |
| 90825 | 91138 | sqlite3 *db, |
| 90826 | 91139 | void (*xNotify)(void **, int), |
| 90827 | 91140 | void *pArg |
| @@ -90829,20 +91142,25 @@ | ||
| 90829 | 91142 | int rc = SQLITE_OK; |
| 90830 | 91143 | |
| 90831 | 91144 | sqlite3_mutex_enter(db->mutex); |
| 90832 | 91145 | enterMutex(); |
| 90833 | 91146 | |
| 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 ){ | |
| 90835 | 91153 | /* The blocking transaction has been concluded. Or there never was a |
| 90836 | 91154 | ** blocking transaction. In either case, invoke the notify callback |
| 90837 | 91155 | ** immediately. |
| 90838 | 91156 | */ |
| 90839 | 91157 | xNotify(&pArg, 1); |
| 90840 | 91158 | }else{ |
| 90841 | 91159 | sqlite3 *p; |
| 90842 | 91160 | |
| 90843 | - for(p=db->pBlockingConnection; p && p!=db; p=p->pUnlockConnection); | |
| 91161 | + for(p=db->pBlockingConnection; p && p!=db; p=p->pUnlockConnection){} | |
| 90844 | 91162 | if( p ){ |
| 90845 | 91163 | rc = SQLITE_LOCKED; /* Deadlock detected. */ |
| 90846 | 91164 | }else{ |
| 90847 | 91165 | db->pUnlockConnection = db->pBlockingConnection; |
| 90848 | 91166 | db->xUnlockNotify = xNotify; |
| @@ -90873,11 +91191,12 @@ | ||
| 90873 | 91191 | db->pBlockingConnection = pBlocker; |
| 90874 | 91192 | leaveMutex(); |
| 90875 | 91193 | } |
| 90876 | 91194 | |
| 90877 | 91195 | /* |
| 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 | |
| 90879 | 91198 | ** by database connection db have been released. |
| 90880 | 91199 | ** |
| 90881 | 91200 | ** This function loops through each entry in the blocked connections |
| 90882 | 91201 | ** list and does the following: |
| 90883 | 91202 | ** |
| @@ -90894,15 +91213,15 @@ | ||
| 90894 | 91213 | */ |
| 90895 | 91214 | SQLITE_PRIVATE void sqlite3ConnectionUnlocked(sqlite3 *db){ |
| 90896 | 91215 | void (*xUnlockNotify)(void **, int) = 0; /* Unlock-notify cb to invoke */ |
| 90897 | 91216 | int nArg = 0; /* Number of entries in aArg[] */ |
| 90898 | 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 */ | |
| 90899 | 91221 | |
| 90900 | - void *aStatic[16]; | |
| 90901 | - void **aArg = aStatic; | |
| 90902 | - void **aDyn = 0; | |
| 90903 | - | |
| 91222 | + aArg = aStatic; | |
| 90904 | 91223 | enterMutex(); /* Enter STATIC_MASTER mutex */ |
| 90905 | 91224 | |
| 90906 | 91225 | /* This loop runs once for each entry in the blocked-connections list. */ |
| 90907 | 91226 | for(pp=&sqlite3BlockedList; *pp; /* no-op */ ){ |
| 90908 | 91227 | sqlite3 *p = *pp; |
| 90909 | 91228 |
| --- 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, ¬Used); |
| 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, ¬Used); |
| 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 @@ | ||
| 28 | 28 | ** The name of this file under configuration management is "sqlite.h.in". |
| 29 | 29 | ** The makefile makes some minor changes to this file (such as inserting |
| 30 | 30 | ** the version number) and changes its name to "sqlite3.h" as |
| 31 | 31 | ** part of the build process. |
| 32 | 32 | ** |
| 33 | -** @(#) $Id: sqlite.h.in,v 1.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 $ | |
| 34 | 34 | */ |
| 35 | 35 | #ifndef _SQLITE3_H_ |
| 36 | 36 | #define _SQLITE3_H_ |
| 37 | 37 | #include <stdarg.h> /* Needed for the definition of va_list */ |
| 38 | 38 | |
| @@ -97,12 +97,12 @@ | ||
| 97 | 97 | ** |
| 98 | 98 | ** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()]. |
| 99 | 99 | ** |
| 100 | 100 | ** Requirements: [H10011] [H10014] |
| 101 | 101 | */ |
| 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 | |
| 104 | 104 | |
| 105 | 105 | /* |
| 106 | 106 | ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100> |
| 107 | 107 | ** KEYWORDS: sqlite3_version |
| 108 | 108 | ** |
| @@ -380,11 +380,10 @@ | ||
| 380 | 380 | #define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8)) |
| 381 | 381 | #define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) |
| 382 | 382 | #define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8)) |
| 383 | 383 | #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) |
| 384 | 384 | #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) |
| 385 | - | |
| 386 | 385 | #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) ) |
| 387 | 386 | |
| 388 | 387 | /* |
| 389 | 388 | ** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700> |
| 390 | 389 | ** |
| @@ -460,12 +459,13 @@ | ||
| 460 | 459 | ** [sqlite3_io_methods] object it uses a combination of |
| 461 | 460 | ** these integer values as the second argument. |
| 462 | 461 | ** |
| 463 | 462 | ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the |
| 464 | 463 | ** 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 | |
| 467 | 467 | ** to use Mac OS X style fullsync instead of fsync(). |
| 468 | 468 | */ |
| 469 | 469 | #define SQLITE_SYNC_NORMAL 0x00002 |
| 470 | 470 | #define SQLITE_SYNC_FULL 0x00003 |
| 471 | 471 | #define SQLITE_SYNC_DATAONLY 0x00010 |
| @@ -2227,11 +2227,12 @@ | ||
| 2227 | 2227 | ** |
| 2228 | 2228 | ** To execute an SQL query, it must first be compiled into a byte-code |
| 2229 | 2229 | ** program using one of these routines. |
| 2230 | 2230 | ** |
| 2231 | 2231 | ** 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. | |
| 2233 | 2234 | ** |
| 2234 | 2235 | ** The second argument, "zSql", is the statement to be compiled, encoded |
| 2235 | 2236 | ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() |
| 2236 | 2237 | ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2() |
| 2237 | 2238 | ** use UTF-16. |
| @@ -2244,21 +2245,22 @@ | ||
| 2244 | 2245 | ** that the supplied string is nul-terminated, then there is a small |
| 2245 | 2246 | ** performance advantage to be gained by passing an nByte parameter that |
| 2246 | 2247 | ** is equal to the number of bytes in the input string <i>including</i> |
| 2247 | 2248 | ** the nul-terminator bytes. |
| 2248 | 2249 | ** |
| 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. | |
| 2253 | 2254 | ** |
| 2254 | 2255 | ** *ppStmt is left pointing to a compiled [prepared statement] that can be |
| 2255 | 2256 | ** executed using [sqlite3_step()]. If there is an error, *ppStmt is set |
| 2256 | 2257 | ** to NULL. If the input text contains no SQL (if the input is an empty |
| 2257 | 2258 | ** 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 | |
| 2259 | 2260 | ** SQL statement using [sqlite3_finalize()] after it has finished with it. |
| 2261 | +** ppStmt may not be NULL. | |
| 2260 | 2262 | ** |
| 2261 | 2263 | ** On success, [SQLITE_OK] is returned, otherwise an [error code] is returned. |
| 2262 | 2264 | ** |
| 2263 | 2265 | ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are |
| 2264 | 2266 | ** recommended for all new programs. The two older interfaces are retained |
| @@ -3628,14 +3630,28 @@ | ||
| 3628 | 3630 | ** the name of a folder (a.k.a. directory), then all temporary files |
| 3629 | 3631 | ** created by SQLite will be placed in that directory. If this variable |
| 3630 | 3632 | ** is a NULL pointer, then SQLite performs a search for an appropriate |
| 3631 | 3633 | ** temporary file directory. |
| 3632 | 3634 | ** |
| 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 | |
| 3635 | 3640 | ** 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. | |
| 3637 | 3653 | */ |
| 3638 | 3654 | SQLITE_EXTERN char *sqlite3_temp_directory; |
| 3639 | 3655 | |
| 3640 | 3656 | /* |
| 3641 | 3657 | ** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200> |
| 3642 | 3658 |
| --- 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 |