Fossil SCM

Update the built-in SQLite to the latest 3.25.0 alpha version for testing.

drh 2018-09-06 20:39 trunk
Commit 48171b6618bf4823b7921296cfa8a8cf492a0ac6125ea9d7247d0c85ca9c6d9f
2 files changed +2322 -1332 +4 -3
+2322 -1332
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1156,11 +1156,11 @@
11561156
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11571157
** [sqlite_version()] and [sqlite_source_id()].
11581158
*/
11591159
#define SQLITE_VERSION "3.25.0"
11601160
#define SQLITE_VERSION_NUMBER 3025000
1161
-#define SQLITE_SOURCE_ID "2018-08-30 01:52:10 58078c0d2647a194279fa80e032670441b296ffc3acee692901faa5beca460b7"
1161
+#define SQLITE_SOURCE_ID "2018-09-06 18:56:36 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5d3c3"
11621162
11631163
/*
11641164
** CAPI3REF: Run-Time Library Version Numbers
11651165
** KEYWORDS: sqlite3_version sqlite3_sourceid
11661166
**
@@ -1503,10 +1503,11 @@
15031503
** the most recent error can be obtained using
15041504
** [sqlite3_extended_errcode()].
15051505
*/
15061506
#define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
15071507
#define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
1508
+#define SQLITE_ERROR_SNAPSHOT (SQLITE_ERROR | (3<<8))
15081509
#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
15091510
#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
15101511
#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
15111512
#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
15121513
#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -10084,15 +10085,15 @@
1008410085
** SQLITE_ERROR is returned if either of these conditions is violated, or
1008510086
** if schema S does not exist, or if the snapshot object is invalid.
1008610087
**
1008710088
** ^A call to sqlite3_snapshot_open() will fail to open if the specified
1008810089
** snapshot has been overwritten by a [checkpoint]. In this case
10089
-** SQLITE_BUSY_SNAPSHOT is returned.
10090
+** SQLITE_ERROR_SNAPSHOT is returned.
1009010091
**
1009110092
** If there is already a read transaction open when this function is
1009210093
** invoked, then the same read transaction remains open (on the same
10093
-** database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_BUSY_SNAPSHOT
10094
+** database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_ERROR_SNAPSHOT
1009410095
** is returned. If another error code - for example SQLITE_PROTOCOL or an
1009510096
** SQLITE_IOERR error code - is returned, then the final state of the
1009610097
** read transaction is undefined. If SQLITE_OK is returned, then the
1009710098
** read transaction is now open on database snapshot P.
1009810099
**
@@ -14025,10 +14026,11 @@
1402514026
typedef struct Module Module;
1402614027
typedef struct NameContext NameContext;
1402714028
typedef struct Parse Parse;
1402814029
typedef struct PreUpdate PreUpdate;
1402914030
typedef struct PrintfArguments PrintfArguments;
14031
+typedef struct RenameToken RenameToken;
1403014032
typedef struct RowSet RowSet;
1403114033
typedef struct Savepoint Savepoint;
1403214034
typedef struct Select Select;
1403314035
typedef struct SQLiteThread SQLiteThread;
1403414036
typedef struct SelectDest SelectDest;
@@ -17010,13 +17012,15 @@
1701017012
1701117013
/*
1701217014
** Each token coming out of the lexer is an instance of
1701317015
** this structure. Tokens are also used as part of an expression.
1701417016
**
17015
-** Note if Token.z==0 then Token.dyn and Token.n are undefined and
17016
-** may contain random values. Do not make any assumptions about Token.dyn
17017
-** and Token.n when Token.z==0.
17017
+** The memory that "z" points to is owned by other objects. Take care
17018
+** that the owner of the "z" string does not deallocate the string before
17019
+** the Token goes out of scope! Very often, the "z" points to some place
17020
+** in the middle of the Parse.zSql text. But it might also point to a
17021
+** static string.
1701817022
*/
1701917023
struct Token {
1702017024
const char *z; /* Text of the token. Not NULL-terminated! */
1702117025
unsigned int n; /* Number of characters in this token */
1702217026
};
@@ -17817,12 +17821,14 @@
1781717821
1781817822
Token sLastToken; /* The last token parsed */
1781917823
ynVar nVar; /* Number of '?' variables seen in the SQL so far */
1782017824
u8 iPkSortOrder; /* ASC or DESC for INTEGER PRIMARY KEY */
1782117825
u8 explain; /* True if the EXPLAIN flag is found on the query */
17826
+#if !(defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_OMIT_ALTERTABLE))
17827
+ u8 eParseMode; /* PARSE_MODE_XXX constant */
17828
+#endif
1782217829
#ifndef SQLITE_OMIT_VIRTUALTABLE
17823
- u8 declareVtab; /* True if inside sqlite3_declare_vtab() */
1782417830
int nVtabLock; /* Number of virtual tables to lock */
1782517831
#endif
1782617832
int nHeight; /* Expression tree height of current sub-select */
1782717833
#ifndef SQLITE_OMIT_EXPLAIN
1782817834
int addrExplain; /* Address of current OP_Explain opcode */
@@ -17829,10 +17835,11 @@
1782917835
#endif
1783017836
VList *pVList; /* Mapping between variable names and numbers */
1783117837
Vdbe *pReprepare; /* VM being reprepared (sqlite3Reprepare()) */
1783217838
const char *zTail; /* All SQL text past the last semicolon parsed */
1783317839
Table *pNewTable; /* A table being constructed by CREATE TABLE */
17840
+ Index *pNewIndex; /* An index being constructed by CREATE INDEX */
1783417841
Trigger *pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */
1783517842
const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */
1783617843
#ifndef SQLITE_OMIT_VIRTUALTABLE
1783717844
Token sArg; /* Complete text of a module argument */
1783817845
Table **apVtabLock; /* Pointer to virtual tables needing locking */
@@ -17839,11 +17846,19 @@
1783917846
#endif
1784017847
Table *pZombieTab; /* List of Table objects to delete after code gen */
1784117848
TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
1784217849
With *pWith; /* Current WITH clause, or NULL */
1784317850
With *pWithToFree; /* Free this WITH object at the end of the parse */
17851
+#ifndef SQLITE_OMIT_ALTERTABLE
17852
+ RenameToken *pRename; /* Tokens subject to renaming by ALTER TABLE */
17853
+#endif
1784417854
};
17855
+
17856
+#define PARSE_MODE_NORMAL 0
17857
+#define PARSE_MODE_DECLARE_VTAB 1
17858
+#define PARSE_MODE_RENAME_COLUMN 2
17859
+#define PARSE_MODE_RENAME_TABLE 3
1784517860
1784617861
/*
1784717862
** Sizes and pointers of various parts of the Parse object.
1784817863
*/
1784917864
#define PARSE_HDR_SZ offsetof(Parse,aTempReg) /* Recursive part w/o aColCache*/
@@ -17855,11 +17870,23 @@
1785517870
** Return true if currently inside an sqlite3_declare_vtab() call.
1785617871
*/
1785717872
#ifdef SQLITE_OMIT_VIRTUALTABLE
1785817873
#define IN_DECLARE_VTAB 0
1785917874
#else
17860
- #define IN_DECLARE_VTAB (pParse->declareVtab)
17875
+ #define IN_DECLARE_VTAB (pParse->eParseMode==PARSE_MODE_DECLARE_VTAB)
17876
+#endif
17877
+
17878
+#if defined(SQLITE_OMIT_ALTERTABLE)
17879
+ #define IN_RENAME_OBJECT 0
17880
+#else
17881
+ #define IN_RENAME_OBJECT (pParse->eParseMode>=PARSE_MODE_RENAME_COLUMN)
17882
+#endif
17883
+
17884
+#if defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_OMIT_ALTERTABLE)
17885
+ #define IN_SPECIAL_PARSE 0
17886
+#else
17887
+ #define IN_SPECIAL_PARSE (pParse->eParseMode!=PARSE_MODE_NORMAL)
1786117888
#endif
1786217889
1786317890
/*
1786417891
** An instance of the following structure can be declared on a stack and used
1786517892
** to save the Parse.zAuthContext value so that it can be restored later.
@@ -18034,12 +18061,18 @@
1803418061
typedef struct {
1803518062
sqlite3 *db; /* The database being initialized */
1803618063
char **pzErrMsg; /* Error message stored here */
1803718064
int iDb; /* 0 for main database. 1 for TEMP, 2.. for ATTACHed */
1803818065
int rc; /* Result code stored here */
18066
+ u32 mInitFlags; /* Flags controlling error messages */
1803918067
} InitData;
1804018068
18069
+/*
18070
+** Allowed values for mInitFlags
18071
+*/
18072
+#define INITFLAG_AlterTable 0x0001 /* This is a reparse after ALTER TABLE */
18073
+
1804118074
/*
1804218075
** Structure containing global configuration data for the SQLite library.
1804318076
**
1804418077
** This structure also contains some state information.
1804518078
*/
@@ -18139,10 +18172,11 @@
1813918172
struct IdxExprTrans *pIdxTrans; /* Convert idxed expr to column */
1814018173
ExprList *pGroupBy; /* GROUP BY clause */
1814118174
Select *pSelect; /* HAVING to WHERE clause ctx */
1814218175
struct WindowRewrite *pRewrite; /* Window rewrite context */
1814318176
struct WhereConst *pConst; /* WHERE clause constants */
18177
+ struct RenameCtx *pRename; /* RENAME COLUMN context */
1814418178
} u;
1814518179
};
1814618180
1814718181
/* Forward declarations */
1814818182
SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
@@ -18338,13 +18372,11 @@
1833818372
# define sqlite3Isdigit(x) isdigit((unsigned char)(x))
1833918373
# define sqlite3Isxdigit(x) isxdigit((unsigned char)(x))
1834018374
# define sqlite3Tolower(x) tolower((unsigned char)(x))
1834118375
# define sqlite3Isquote(x) ((x)=='"'||(x)=='\''||(x)=='['||(x)=='`')
1834218376
#endif
18343
-#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
1834418377
SQLITE_PRIVATE int sqlite3IsIdChar(u8);
18345
-#endif
1834618378
1834718379
/*
1834818380
** Internal function prototypes
1834918381
*/
1835018382
SQLITE_PRIVATE int sqlite3StrICmp(const char*,const char*);
@@ -18505,10 +18537,11 @@
1850518537
SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);
1850618538
SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
1850718539
SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
1850818540
SQLITE_PRIVATE int sqlite3Init(sqlite3*, char**);
1850918541
SQLITE_PRIVATE int sqlite3InitCallback(void*, int, char**, char**);
18542
+SQLITE_PRIVATE int sqlite3InitOne(sqlite3*, int, char**, u32);
1851018543
SQLITE_PRIVATE void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);
1851118544
#ifndef SQLITE_OMIT_VIRTUALTABLE
1851218545
SQLITE_PRIVATE Module *sqlite3PragmaVtabRegister(sqlite3*,const char *zName);
1851318546
#endif
1851418547
SQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3*);
@@ -18575,20 +18608,21 @@
1857518608
SQLITE_PRIVATE int sqlite3DbMaskAllZero(yDbMask);
1857618609
#endif
1857718610
SQLITE_PRIVATE void sqlite3DropTable(Parse*, SrcList*, int, int);
1857818611
SQLITE_PRIVATE void sqlite3CodeDropTable(Parse*, Table*, int, int);
1857918612
SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3*, Table*);
18613
+SQLITE_PRIVATE void sqlite3FreeIndex(sqlite3*, Index*);
1858018614
#ifndef SQLITE_OMIT_AUTOINCREMENT
1858118615
SQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse);
1858218616
SQLITE_PRIVATE void sqlite3AutoincrementEnd(Parse *pParse);
1858318617
#else
1858418618
# define sqlite3AutoincrementBegin(X)
1858518619
# define sqlite3AutoincrementEnd(X)
1858618620
#endif
1858718621
SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*);
1858818622
SQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);
18589
-SQLITE_PRIVATE IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token*);
18623
+SQLITE_PRIVATE IdList *sqlite3IdListAppend(Parse*, IdList*, Token*);
1859018624
SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*);
1859118625
SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int);
1859218626
SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*);
1859318627
SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,
1859418628
Token*, Select*, Expr*, IdList*);
@@ -18746,16 +18780,16 @@
1874618780
SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);
1874718781
void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
1874818782
SQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);
1874918783
SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*,
1875018784
const char*,const char*);
18751
-SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*,
18785
+SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(Parse*,Token*, IdList*,
1875218786
Select*,u8,Upsert*,
1875318787
const char*,const char*);
18754
-SQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8,
18788
+SQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(Parse*,Token*,ExprList*, Expr*, u8,
1875518789
const char*,const char*);
18756
-SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*,
18790
+SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(Parse*,Token*, Expr*,
1875718791
const char*,const char*);
1875818792
SQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3*, Trigger*);
1875918793
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
1876018794
SQLITE_PRIVATE u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);
1876118795
# define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))
@@ -18919,10 +18953,11 @@
1891918953
#endif
1892018954
SQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3*, int, int, int);
1892118955
SQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*);
1892218956
SQLITE_PRIVATE void sqlite3AlterFunctions(void);
1892318957
SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
18958
+SQLITE_PRIVATE void sqlite3AlterRenameColumn(Parse*, SrcList*, Token*, Token*);
1892418959
SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);
1892518960
SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
1892618961
SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*, int);
1892718962
SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr *, int, int);
1892818963
SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
@@ -18934,10 +18969,13 @@
1893418969
SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
1893518970
SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
1893618971
SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
1893718972
SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
1893818973
SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
18974
+SQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse*, void*, Token*);
18975
+SQLITE_PRIVATE void sqlite3RenameTokenRemap(Parse*, void *pTo, void *pFrom);
18976
+SQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse*, Expr*);
1893918977
SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
1894018978
SQLITE_PRIVATE char sqlite3AffinityType(const char*, Column*);
1894118979
SQLITE_PRIVATE void sqlite3Analyze(Parse*, Token*, Token*);
1894218980
SQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler*, sqlite3_file*);
1894318981
SQLITE_PRIVATE int sqlite3FindDb(sqlite3*, Token*);
@@ -51028,12 +51066,16 @@
5102851066
** containing the state of the Pager object passed as an argument. This
5102951067
** is intended to be used within debuggers. For example, as an alternative
5103051068
** to "print *pPager" in gdb:
5103151069
**
5103251070
** (gdb) printf "%s", print_pager_state(pPager)
51071
+**
51072
+** This routine has external linkage in order to suppress compiler warnings
51073
+** about an unused function. It is enclosed within SQLITE_DEBUG and so does
51074
+** not appear in normal builds.
5103351075
*/
51034
-static char *print_pager_state(Pager *p){
51076
+char *print_pager_state(Pager *p){
5103551077
static char zRet[1024];
5103651078
5103751079
sqlite3_snprintf(1024, zRet,
5103851080
"Filename: %s\n"
5103951081
"State: %s errCode=%d\n"
@@ -57308,17 +57350,10 @@
5730857350
**
5730957351
** The returned indicate the current (possibly updated) journal-mode.
5731057352
*/
5731157353
SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){
5731257354
u8 eOld = pPager->journalMode; /* Prior journalmode */
57313
-
57314
-#ifdef SQLITE_DEBUG
57315
- /* The print_pager_state() routine is intended to be used by the debugger
57316
- ** only. We invoke it once here to suppress a compiler warning. */
57317
- print_pager_state(pPager);
57318
-#endif
57319
-
5732057355
5732157356
/* The eMode parameter is always valid */
5732257357
assert( eMode==PAGER_JOURNALMODE_DELETE
5732357358
|| eMode==PAGER_JOURNALMODE_TRUNCATE
5732457359
|| eMode==PAGER_JOURNALMODE_PERSIST
@@ -57997,10 +58032,22 @@
5799758032
# define WALTRACE(X) if(sqlite3WalTrace) sqlite3DebugPrintf X
5799858033
#else
5799958034
# define WALTRACE(X)
5800058035
#endif
5800158036
58037
+/*
58038
+** WAL mode depends on atomic aligned 32-bit loads and stores in a few
58039
+** places. The following macros try to make this explicit.
58040
+*/
58041
+#if GCC_VESRION>=5004000
58042
+# define AtomicLoad(PTR) __atomic_load_n((PTR),__ATOMIC_RELAXED)
58043
+# define AtomicStore(PTR,VAL) __atomic_store_n((PTR),(VAL),__ATOMIC_RELAXED)
58044
+#else
58045
+# define AtomicLoad(PTR) (*(PTR))
58046
+# define AtomicStore(PTR,VAL) (*(PTR) = (VAL))
58047
+#endif
58048
+
5800258049
/*
5800358050
** The maximum (and only) versions of the wal and wal-index formats
5800458051
** that may be interpreted by this version of SQLite.
5800558052
**
5800658053
** If a client begins recovering a WAL file and finds that (a) the checksum
@@ -60294,11 +60341,11 @@
6029460341
if( pWal->pSnapshot && pWal->pSnapshot->mxFrame<mxFrame ){
6029560342
mxFrame = pWal->pSnapshot->mxFrame;
6029660343
}
6029760344
#endif
6029860345
for(i=1; i<WAL_NREADER; i++){
60299
- u32 thisMark = pInfo->aReadMark[i];
60346
+ u32 thisMark = AtomicLoad(pInfo->aReadMark+i);
6030060347
if( mxReadMark<=thisMark && thisMark<=mxFrame ){
6030160348
assert( thisMark!=READMARK_NOT_USED );
6030260349
mxReadMark = thisMark;
6030360350
mxI = i;
6030460351
}
@@ -60307,11 +60354,11 @@
6030760354
&& (mxReadMark<mxFrame || mxI==0)
6030860355
){
6030960356
for(i=1; i<WAL_NREADER; i++){
6031060357
rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
6031160358
if( rc==SQLITE_OK ){
60312
- mxReadMark = pInfo->aReadMark[i] = mxFrame;
60359
+ mxReadMark = AtomicStore(pInfo->aReadMark+i,mxFrame);
6031360360
mxI = i;
6031460361
walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
6031560362
break;
6031660363
}else if( rc!=SQLITE_BUSY ){
6031760364
return rc;
@@ -60359,13 +60406,13 @@
6035960406
** frame pWal->hdr.mxFrame - then the client would incorrectly assume
6036060407
** that it can read version A from the database file. However, since
6036160408
** we can guarantee that the checkpointer that set nBackfill could not
6036260409
** see any pages past pWal->hdr.mxFrame, this problem does not come up.
6036360410
*/
60364
- pWal->minFrame = pInfo->nBackfill+1;
60411
+ pWal->minFrame = AtomicLoad(&pInfo->nBackfill)+1;
6036560412
walShmBarrier(pWal);
60366
- if( pInfo->aReadMark[mxI]!=mxReadMark
60413
+ if( AtomicLoad(pInfo->aReadMark+mxI)!=mxReadMark
6036760414
|| memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr))
6036860415
){
6036960416
walUnlockShared(pWal, WAL_READ_LOCK(mxI));
6037060417
return WAL_RETRY;
6037160418
}else{
@@ -60522,21 +60569,21 @@
6052260569
6052360570
if( rc==SQLITE_OK ){
6052460571
/* Check that the wal file has not been wrapped. Assuming that it has
6052560572
** not, also check that no checkpointer has attempted to checkpoint any
6052660573
** frames beyond pSnapshot->mxFrame. If either of these conditions are
60527
- ** true, return SQLITE_BUSY_SNAPSHOT. Otherwise, overwrite pWal->hdr
60574
+ ** true, return SQLITE_ERROR_SNAPSHOT. Otherwise, overwrite pWal->hdr
6052860575
** with *pSnapshot and set *pChanged as appropriate for opening the
6052960576
** snapshot. */
6053060577
if( !memcmp(pSnapshot->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))
6053160578
&& pSnapshot->mxFrame>=pInfo->nBackfillAttempted
6053260579
){
6053360580
assert( pWal->readLock>0 );
6053460581
memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr));
6053560582
*pChanged = bChanged;
6053660583
}else{
60537
- rc = SQLITE_BUSY_SNAPSHOT;
60584
+ rc = SQLITE_ERROR_SNAPSHOT;
6053860585
}
6053960586
6054060587
/* Release the shared CKPT lock obtained above. */
6054160588
walUnlockShared(pWal, WAL_CKPT_LOCK);
6054260589
pWal->minFrame = 1;
@@ -61529,11 +61576,11 @@
6152961576
if( rc==SQLITE_OK ){
6153061577
WalIndexHdr *pNew = (WalIndexHdr*)pSnapshot;
6153161578
if( memcmp(pNew->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))
6153261579
|| pNew->mxFrame<walCkptInfo(pWal)->nBackfillAttempted
6153361580
){
61534
- rc = SQLITE_BUSY_SNAPSHOT;
61581
+ rc = SQLITE_ERROR_SNAPSHOT;
6153561582
walUnlockShared(pWal, WAL_CKPT_LOCK);
6153661583
}
6153761584
}
6153861585
return rc;
6153961586
}
@@ -77145,11 +77192,10 @@
7714577192
** and reset(). Inserts are grouped into a transaction.
7714677193
*/
7714777194
testcase( p->flags & MEM_Agg );
7714877195
testcase( p->flags & MEM_Dyn );
7714977196
testcase( p->xDel==sqlite3VdbeFrameMemDel );
77150
- testcase( p->flags & MEM_RowSet );
7715177197
if( p->flags&(MEM_Agg|MEM_Dyn) ){
7715277198
sqlite3VdbeMemRelease(p);
7715377199
}else if( p->szMalloc ){
7715477200
sqlite3DbFreeNN(db, p->zMalloc);
7715577201
p->szMalloc = 0;
@@ -88319,11 +88365,12 @@
8831988365
}
8832088366
8832188367
/* Opcode: ParseSchema P1 * * P4 *
8832288368
**
8832388369
** Read and parse all entries from the SQLITE_MASTER table of database P1
88324
-** that match the WHERE clause P4.
88370
+** that match the WHERE clause P4. If P4 is a NULL pointer, then the
88371
+** entire schema for P1 is reparsed.
8832588372
**
8832688373
** This opcode invokes the parser to create a new virtual machine,
8832788374
** then runs the new virtual machine. It is thus a re-entrant opcode.
8832888375
*/
8832988376
case OP_ParseSchema: {
@@ -88343,11 +88390,21 @@
8834388390
#endif
8834488391
8834588392
iDb = pOp->p1;
8834688393
assert( iDb>=0 && iDb<db->nDb );
8834788394
assert( DbHasProperty(db, iDb, DB_SchemaLoaded) );
88348
- /* Used to be a conditional */ {
88395
+
88396
+#ifndef SQLITE_OMIT_ALTERTABLE
88397
+ if( pOp->p4.z==0 ){
88398
+ sqlite3SchemaClear(db->aDb[iDb].pSchema);
88399
+ db->mDbFlags &= ~DBFLAG_SchemaKnownOk;
88400
+ rc = sqlite3InitOne(db, iDb, &p->zErrMsg, INITFLAG_AlterTable);
88401
+ db->mDbFlags |= DBFLAG_SchemaChange;
88402
+ p->expired = 0;
88403
+ }else
88404
+#endif
88405
+ {
8834988406
zMaster = MASTER_NAME;
8835088407
initData.db = db;
8835188408
initData.iDb = pOp->p1;
8835288409
initData.pzErrMsg = &p->zErrMsg;
8835388410
zSql = sqlite3MPrintf(db,
@@ -94301,10 +94358,13 @@
9430194358
const char *zTabName = pItem->zAlias ? pItem->zAlias : pTab->zName;
9430294359
assert( zTabName!=0 );
9430394360
if( sqlite3StrICmp(zTabName, zTab)!=0 ){
9430494361
continue;
9430594362
}
94363
+ if( IN_RENAME_OBJECT && pItem->zAlias ){
94364
+ sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->pTab);
94365
+ }
9430694366
}
9430794367
if( 0==(cntTab++) ){
9430894368
pMatch = pItem;
9430994369
}
9431094370
for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){
@@ -94386,13 +94446,19 @@
9438694446
if( iCol<pTab->nCol ){
9438794447
cnt++;
9438894448
#ifndef SQLITE_OMIT_UPSERT
9438994449
if( pExpr->iTable==2 ){
9439094450
testcase( iCol==(-1) );
94391
- pExpr->iTable = pNC->uNC.pUpsert->regData + iCol;
94392
- eNewExprOp = TK_REGISTER;
94393
- ExprSetProperty(pExpr, EP_Alias);
94451
+ if( IN_RENAME_OBJECT ){
94452
+ pExpr->iColumn = iCol;
94453
+ pExpr->pTab = pTab;
94454
+ eNewExprOp = TK_COLUMN;
94455
+ }else{
94456
+ pExpr->iTable = pNC->uNC.pUpsert->regData + iCol;
94457
+ eNewExprOp = TK_REGISTER;
94458
+ ExprSetProperty(pExpr, EP_Alias);
94459
+ }
9439494460
}else
9439594461
#endif /* SQLITE_OMIT_UPSERT */
9439694462
{
9439794463
#ifndef SQLITE_OMIT_TRIGGER
9439894464
if( iCol<0 ){
@@ -94473,10 +94539,13 @@
9447394539
}
9447494540
resolveAlias(pParse, pEList, j, pExpr, "", nSubquery);
9447594541
cnt = 1;
9447694542
pMatch = 0;
9447794543
assert( zTab==0 && zDb==0 );
94544
+ if( IN_RENAME_OBJECT ){
94545
+ sqlite3RenameTokenRemap(pParse, 0, (void*)pExpr);
94546
+ }
9447894547
goto lookupname_end;
9447994548
}
9448094549
}
9448194550
}
9448294551
@@ -94700,21 +94769,28 @@
9470094769
if( pExpr->op==TK_ID ){
9470194770
zDb = 0;
9470294771
zTable = 0;
9470394772
zColumn = pExpr->u.zToken;
9470494773
}else{
94774
+ Expr *pLeft = pExpr->pLeft;
9470594775
notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr);
9470694776
pRight = pExpr->pRight;
9470794777
if( pRight->op==TK_ID ){
9470894778
zDb = 0;
94709
- zTable = pExpr->pLeft->u.zToken;
94710
- zColumn = pRight->u.zToken;
9471194779
}else{
9471294780
assert( pRight->op==TK_DOT );
94713
- zDb = pExpr->pLeft->u.zToken;
94714
- zTable = pRight->pLeft->u.zToken;
94715
- zColumn = pRight->pRight->u.zToken;
94781
+ zDb = pLeft->u.zToken;
94782
+ pLeft = pRight->pLeft;
94783
+ pRight = pRight->pRight;
94784
+ }
94785
+ zTable = pLeft->u.zToken;
94786
+ zColumn = pRight->u.zToken;
94787
+ if( IN_RENAME_OBJECT ){
94788
+ sqlite3RenameTokenRemap(pParse, (void*)pExpr, (void*)pRight);
94789
+ }
94790
+ if( IN_RENAME_OBJECT ){
94791
+ sqlite3RenameTokenRemap(pParse, (void*)&pExpr->pTab, (void*)pLeft);
9471694792
}
9471794793
}
9471894794
return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);
9471994795
}
9472094796
@@ -94794,60 +94870,62 @@
9479494870
notValid(pParse, pNC, "non-deterministic functions",
9479594871
NC_IdxExpr|NC_PartIdx);
9479694872
}
9479794873
}
9479894874
94875
+ if( 0==IN_RENAME_OBJECT ){
9479994876
#ifndef SQLITE_OMIT_WINDOWFUNC
94800
- assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)
94877
+ assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)
9480194878
|| (pDef->xValue==0 && pDef->xInverse==0)
9480294879
|| (pDef->xValue && pDef->xInverse && pDef->xSFunc && pDef->xFinalize)
94803
- );
94804
- if( pDef && pDef->xValue==0 && pExpr->pWin ){
94805
- sqlite3ErrorMsg(pParse,
94806
- "%.*s() may not be used as a window function", nId, zId
94807
- );
94808
- pNC->nErr++;
94809
- }else if(
94810
- (is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
94811
- || (is_agg && (pDef->funcFlags & SQLITE_FUNC_WINDOW) && !pExpr->pWin)
94812
- || (is_agg && pExpr->pWin && (pNC->ncFlags & NC_AllowWin)==0)
94813
- ){
94814
- const char *zType;
94815
- if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pExpr->pWin ){
94816
- zType = "window";
94817
- }else{
94818
- zType = "aggregate";
94819
- }
94820
- sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()", zType, nId,zId);
94821
- pNC->nErr++;
94822
- is_agg = 0;
94823
- }
94824
-#else
94825
- if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){
94826
- sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);
94827
- pNC->nErr++;
94828
- is_agg = 0;
94829
- }
94830
-#endif
94831
- else if( no_such_func && pParse->db->init.busy==0
94880
+ );
94881
+ if( pDef && pDef->xValue==0 && pExpr->pWin ){
94882
+ sqlite3ErrorMsg(pParse,
94883
+ "%.*s() may not be used as a window function", nId, zId
94884
+ );
94885
+ pNC->nErr++;
94886
+ }else if(
94887
+ (is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
94888
+ || (is_agg && (pDef->funcFlags & SQLITE_FUNC_WINDOW) && !pExpr->pWin)
94889
+ || (is_agg && pExpr->pWin && (pNC->ncFlags & NC_AllowWin)==0)
94890
+ ){
94891
+ const char *zType;
94892
+ if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pExpr->pWin ){
94893
+ zType = "window";
94894
+ }else{
94895
+ zType = "aggregate";
94896
+ }
94897
+ sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId);
94898
+ pNC->nErr++;
94899
+ is_agg = 0;
94900
+ }
94901
+#else
94902
+ if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){
94903
+ sqlite3ErrorMsg(pParse,"misuse of aggregate function %.*s()",nId,zId);
94904
+ pNC->nErr++;
94905
+ is_agg = 0;
94906
+ }
94907
+#endif
94908
+ else if( no_such_func && pParse->db->init.busy==0
9483294909
#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
94833
- && pParse->explain==0
94910
+ && pParse->explain==0
9483494911
#endif
94835
- ){
94836
- sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
94837
- pNC->nErr++;
94838
- }else if( wrong_num_args ){
94839
- sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
94840
- nId, zId);
94841
- pNC->nErr++;
94842
- }
94843
- if( is_agg ){
94912
+ ){
94913
+ sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
94914
+ pNC->nErr++;
94915
+ }else if( wrong_num_args ){
94916
+ sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
94917
+ nId, zId);
94918
+ pNC->nErr++;
94919
+ }
94920
+ if( is_agg ){
9484494921
#ifndef SQLITE_OMIT_WINDOWFUNC
94845
- pNC->ncFlags &= ~(pExpr->pWin ? NC_AllowWin : NC_AllowAgg);
94922
+ pNC->ncFlags &= ~(pExpr->pWin ? NC_AllowWin : NC_AllowAgg);
9484694923
#else
94847
- pNC->ncFlags &= ~NC_AllowAgg;
94924
+ pNC->ncFlags &= ~NC_AllowAgg;
9484894925
#endif
94926
+ }
9484994927
}
9485094928
sqlite3WalkExprList(pWalker, pList);
9485194929
if( is_agg ){
9485294930
#ifndef SQLITE_OMIT_WINDOWFUNC
9485394931
if( pExpr->pWin ){
@@ -97358,10 +97436,13 @@
9735897436
assert( pList->nExpr>0 );
9735997437
pItem = &pList->a[pList->nExpr-1];
9736097438
assert( pItem->zName==0 );
9736197439
pItem->zName = sqlite3DbStrNDup(pParse->db, pName->z, pName->n);
9736297440
if( dequote ) sqlite3Dequote(pItem->zName);
97441
+ if( IN_RENAME_OBJECT ){
97442
+ sqlite3RenameTokenMap(pParse, (void*)pItem->zName, pName);
97443
+ }
9736397444
}
9736497445
}
9736597446
9736697447
/*
9736797448
** Set the ExprList.a[].zSpan element of the most recently added item
@@ -101056,356 +101137,10 @@
101056101137
** The code in this file only exists if we are not omitting the
101057101138
** ALTER TABLE logic from the build.
101058101139
*/
101059101140
#ifndef SQLITE_OMIT_ALTERTABLE
101060101141
101061
-
101062
-/*
101063
-** This function is used by SQL generated to implement the
101064
-** ALTER TABLE command. The first argument is the text of a CREATE TABLE or
101065
-** CREATE INDEX command. The second is a table name. The table name in
101066
-** the CREATE TABLE or CREATE INDEX statement is replaced with the third
101067
-** argument and the result returned. Examples:
101068
-**
101069
-** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def')
101070
-** -> 'CREATE TABLE def(a, b, c)'
101071
-**
101072
-** sqlite_rename_table('CREATE INDEX i ON abc(a)', 'def')
101073
-** -> 'CREATE INDEX i ON def(a, b, c)'
101074
-*/
101075
-static void renameTableFunc(
101076
- sqlite3_context *context,
101077
- int NotUsed,
101078
- sqlite3_value **argv
101079
-){
101080
- unsigned char const *zSql = sqlite3_value_text(argv[0]);
101081
- unsigned char const *zTableName = sqlite3_value_text(argv[1]);
101082
-
101083
- int token;
101084
- Token tname;
101085
- unsigned char const *zCsr = zSql;
101086
- int len = 0;
101087
- char *zRet;
101088
-
101089
- sqlite3 *db = sqlite3_context_db_handle(context);
101090
-
101091
- UNUSED_PARAMETER(NotUsed);
101092
-
101093
- /* The principle used to locate the table name in the CREATE TABLE
101094
- ** statement is that the table name is the first non-space token that
101095
- ** is immediately followed by a TK_LP or TK_USING token.
101096
- */
101097
- if( zSql ){
101098
- do {
101099
- if( !*zCsr ){
101100
- /* Ran out of input before finding an opening bracket. Return NULL. */
101101
- return;
101102
- }
101103
-
101104
- /* Store the token that zCsr points to in tname. */
101105
- tname.z = (char*)zCsr;
101106
- tname.n = len;
101107
-
101108
- /* Advance zCsr to the next token. Store that token type in 'token',
101109
- ** and its length in 'len' (to be used next iteration of this loop).
101110
- */
101111
- do {
101112
- zCsr += len;
101113
- len = sqlite3GetToken(zCsr, &token);
101114
- } while( token==TK_SPACE );
101115
- assert( len>0 || !*zCsr );
101116
- } while( token!=TK_LP && token!=TK_USING );
101117
-
101118
- zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", (int)(((u8*)tname.z) - zSql),
101119
- zSql, zTableName, tname.z+tname.n);
101120
- sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);
101121
- }
101122
-}
101123
-
101124
-/*
101125
-** This C function implements an SQL user function that is used by SQL code
101126
-** generated by the ALTER TABLE ... RENAME command to modify the definition
101127
-** of any foreign key constraints that use the table being renamed as the
101128
-** parent table. It is passed three arguments:
101129
-**
101130
-** 1) The complete text of the CREATE TABLE statement being modified,
101131
-** 2) The old name of the table being renamed, and
101132
-** 3) The new name of the table being renamed.
101133
-**
101134
-** It returns the new CREATE TABLE statement. For example:
101135
-**
101136
-** sqlite_rename_parent('CREATE TABLE t1(a REFERENCES t2)', 't2', 't3')
101137
-** -> 'CREATE TABLE t1(a REFERENCES t3)'
101138
-*/
101139
-#ifndef SQLITE_OMIT_FOREIGN_KEY
101140
-static void renameParentFunc(
101141
- sqlite3_context *context,
101142
- int NotUsed,
101143
- sqlite3_value **argv
101144
-){
101145
- sqlite3 *db = sqlite3_context_db_handle(context);
101146
- char *zOutput = 0;
101147
- char *zResult;
101148
- unsigned char const *zInput = sqlite3_value_text(argv[0]);
101149
- unsigned char const *zOld = sqlite3_value_text(argv[1]);
101150
- unsigned char const *zNew = sqlite3_value_text(argv[2]);
101151
-
101152
- unsigned const char *z; /* Pointer to token */
101153
- int n; /* Length of token z */
101154
- int token; /* Type of token */
101155
-
101156
- UNUSED_PARAMETER(NotUsed);
101157
- if( zInput==0 || zOld==0 ) return;
101158
- for(z=zInput; *z; z=z+n){
101159
- n = sqlite3GetToken(z, &token);
101160
- if( token==TK_REFERENCES ){
101161
- char *zParent;
101162
- do {
101163
- z += n;
101164
- n = sqlite3GetToken(z, &token);
101165
- }while( token==TK_SPACE );
101166
-
101167
- if( token==TK_ILLEGAL ) break;
101168
- zParent = sqlite3DbStrNDup(db, (const char *)z, n);
101169
- if( zParent==0 ) break;
101170
- sqlite3Dequote(zParent);
101171
- if( 0==sqlite3StrICmp((const char *)zOld, zParent) ){
101172
- char *zOut = sqlite3MPrintf(db, "%s%.*s\"%w\"",
101173
- (zOutput?zOutput:""), (int)(z-zInput), zInput, (const char *)zNew
101174
- );
101175
- sqlite3DbFree(db, zOutput);
101176
- zOutput = zOut;
101177
- zInput = &z[n];
101178
- }
101179
- sqlite3DbFree(db, zParent);
101180
- }
101181
- }
101182
-
101183
- zResult = sqlite3MPrintf(db, "%s%s", (zOutput?zOutput:""), zInput);
101184
- sqlite3_result_text(context, zResult, -1, SQLITE_DYNAMIC);
101185
- sqlite3DbFree(db, zOutput);
101186
-}
101187
-#endif
101188
-
101189
-#ifndef SQLITE_OMIT_TRIGGER
101190
-/* This function is used by SQL generated to implement the
101191
-** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER
101192
-** statement. The second is a table name. The table name in the CREATE
101193
-** TRIGGER statement is replaced with the third argument and the result
101194
-** returned. This is analagous to renameTableFunc() above, except for CREATE
101195
-** TRIGGER, not CREATE INDEX and CREATE TABLE.
101196
-*/
101197
-static void renameTriggerFunc(
101198
- sqlite3_context *context,
101199
- int NotUsed,
101200
- sqlite3_value **argv
101201
-){
101202
- unsigned char const *zSql = sqlite3_value_text(argv[0]);
101203
- unsigned char const *zTableName = sqlite3_value_text(argv[1]);
101204
-
101205
- int token;
101206
- Token tname;
101207
- int dist = 3;
101208
- unsigned char const *zCsr = zSql;
101209
- int len = 0;
101210
- char *zRet;
101211
- sqlite3 *db = sqlite3_context_db_handle(context);
101212
-
101213
- UNUSED_PARAMETER(NotUsed);
101214
-
101215
- /* The principle used to locate the table name in the CREATE TRIGGER
101216
- ** statement is that the table name is the first token that is immediately
101217
- ** preceded by either TK_ON or TK_DOT and immediately followed by one
101218
- ** of TK_WHEN, TK_BEGIN or TK_FOR.
101219
- */
101220
- if( zSql ){
101221
- do {
101222
-
101223
- if( !*zCsr ){
101224
- /* Ran out of input before finding the table name. Return NULL. */
101225
- return;
101226
- }
101227
-
101228
- /* Store the token that zCsr points to in tname. */
101229
- tname.z = (char*)zCsr;
101230
- tname.n = len;
101231
-
101232
- /* Advance zCsr to the next token. Store that token type in 'token',
101233
- ** and its length in 'len' (to be used next iteration of this loop).
101234
- */
101235
- do {
101236
- zCsr += len;
101237
- len = sqlite3GetToken(zCsr, &token);
101238
- }while( token==TK_SPACE );
101239
- assert( len>0 || !*zCsr );
101240
-
101241
- /* Variable 'dist' stores the number of tokens read since the most
101242
- ** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN
101243
- ** token is read and 'dist' equals 2, the condition stated above
101244
- ** to be met.
101245
- **
101246
- ** Note that ON cannot be a database, table or column name, so
101247
- ** there is no need to worry about syntax like
101248
- ** "CREATE TRIGGER ... ON ON.ON BEGIN ..." etc.
101249
- */
101250
- dist++;
101251
- if( token==TK_DOT || token==TK_ON ){
101252
- dist = 0;
101253
- }
101254
- } while( dist!=2 || (token!=TK_WHEN && token!=TK_FOR && token!=TK_BEGIN) );
101255
-
101256
- /* Variable tname now contains the token that is the old table-name
101257
- ** in the CREATE TRIGGER statement.
101258
- */
101259
- zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", (int)(((u8*)tname.z) - zSql),
101260
- zSql, zTableName, tname.z+tname.n);
101261
- sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);
101262
- }
101263
-}
101264
-#endif /* !SQLITE_OMIT_TRIGGER */
101265
-
101266
-/*
101267
-** Register built-in functions used to help implement ALTER TABLE
101268
-*/
101269
-SQLITE_PRIVATE void sqlite3AlterFunctions(void){
101270
- static FuncDef aAlterTableFuncs[] = {
101271
- FUNCTION(sqlite_rename_table, 2, 0, 0, renameTableFunc),
101272
-#ifndef SQLITE_OMIT_TRIGGER
101273
- FUNCTION(sqlite_rename_trigger, 2, 0, 0, renameTriggerFunc),
101274
-#endif
101275
-#ifndef SQLITE_OMIT_FOREIGN_KEY
101276
- FUNCTION(sqlite_rename_parent, 3, 0, 0, renameParentFunc),
101277
-#endif
101278
- };
101279
- sqlite3InsertBuiltinFuncs(aAlterTableFuncs, ArraySize(aAlterTableFuncs));
101280
-}
101281
-
101282
-/*
101283
-** This function is used to create the text of expressions of the form:
101284
-**
101285
-** name=<constant1> OR name=<constant2> OR ...
101286
-**
101287
-** If argument zWhere is NULL, then a pointer string containing the text
101288
-** "name=<constant>" is returned, where <constant> is the quoted version
101289
-** of the string passed as argument zConstant. The returned buffer is
101290
-** allocated using sqlite3DbMalloc(). It is the responsibility of the
101291
-** caller to ensure that it is eventually freed.
101292
-**
101293
-** If argument zWhere is not NULL, then the string returned is
101294
-** "<where> OR name=<constant>", where <where> is the contents of zWhere.
101295
-** In this case zWhere is passed to sqlite3DbFree() before returning.
101296
-**
101297
-*/
101298
-static char *whereOrName(sqlite3 *db, char *zWhere, char *zConstant){
101299
- char *zNew;
101300
- if( !zWhere ){
101301
- zNew = sqlite3MPrintf(db, "name=%Q", zConstant);
101302
- }else{
101303
- zNew = sqlite3MPrintf(db, "%s OR name=%Q", zWhere, zConstant);
101304
- sqlite3DbFree(db, zWhere);
101305
- }
101306
- return zNew;
101307
-}
101308
-
101309
-#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
101310
-/*
101311
-** Generate the text of a WHERE expression which can be used to select all
101312
-** tables that have foreign key constraints that refer to table pTab (i.e.
101313
-** constraints for which pTab is the parent table) from the sqlite_master
101314
-** table.
101315
-*/
101316
-static char *whereForeignKeys(Parse *pParse, Table *pTab){
101317
- FKey *p;
101318
- char *zWhere = 0;
101319
- for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){
101320
- zWhere = whereOrName(pParse->db, zWhere, p->pFrom->zName);
101321
- }
101322
- return zWhere;
101323
-}
101324
-#endif
101325
-
101326
-/*
101327
-** Generate the text of a WHERE expression which can be used to select all
101328
-** temporary triggers on table pTab from the sqlite_temp_master table. If
101329
-** table pTab has no temporary triggers, or is itself stored in the
101330
-** temporary database, NULL is returned.
101331
-*/
101332
-static char *whereTempTriggers(Parse *pParse, Table *pTab){
101333
- Trigger *pTrig;
101334
- char *zWhere = 0;
101335
- const Schema *pTempSchema = pParse->db->aDb[1].pSchema; /* Temp db schema */
101336
-
101337
- /* If the table is not located in the temp-db (in which case NULL is
101338
- ** returned, loop through the tables list of triggers. For each trigger
101339
- ** that is not part of the temp-db schema, add a clause to the WHERE
101340
- ** expression being built up in zWhere.
101341
- */
101342
- if( pTab->pSchema!=pTempSchema ){
101343
- sqlite3 *db = pParse->db;
101344
- for(pTrig=sqlite3TriggerList(pParse, pTab); pTrig; pTrig=pTrig->pNext){
101345
- if( pTrig->pSchema==pTempSchema ){
101346
- zWhere = whereOrName(db, zWhere, pTrig->zName);
101347
- }
101348
- }
101349
- }
101350
- if( zWhere ){
101351
- char *zNew = sqlite3MPrintf(pParse->db, "type='trigger' AND (%s)", zWhere);
101352
- sqlite3DbFree(pParse->db, zWhere);
101353
- zWhere = zNew;
101354
- }
101355
- return zWhere;
101356
-}
101357
-
101358
-/*
101359
-** Generate code to drop and reload the internal representation of table
101360
-** pTab from the database, including triggers and temporary triggers.
101361
-** Argument zName is the name of the table in the database schema at
101362
-** the time the generated code is executed. This can be different from
101363
-** pTab->zName if this function is being called to code part of an
101364
-** "ALTER TABLE RENAME TO" statement.
101365
-*/
101366
-static void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){
101367
- Vdbe *v;
101368
- char *zWhere;
101369
- int iDb; /* Index of database containing pTab */
101370
-#ifndef SQLITE_OMIT_TRIGGER
101371
- Trigger *pTrig;
101372
-#endif
101373
-
101374
- v = sqlite3GetVdbe(pParse);
101375
- if( NEVER(v==0) ) return;
101376
- assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );
101377
- iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
101378
- assert( iDb>=0 );
101379
-
101380
-#ifndef SQLITE_OMIT_TRIGGER
101381
- /* Drop any table triggers from the internal schema. */
101382
- for(pTrig=sqlite3TriggerList(pParse, pTab); pTrig; pTrig=pTrig->pNext){
101383
- int iTrigDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);
101384
- assert( iTrigDb==iDb || iTrigDb==1 );
101385
- sqlite3VdbeAddOp4(v, OP_DropTrigger, iTrigDb, 0, 0, pTrig->zName, 0);
101386
- }
101387
-#endif
101388
-
101389
- /* Drop the table and index from the internal schema. */
101390
- sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);
101391
-
101392
- /* Reload the table, index and permanent trigger schemas. */
101393
- zWhere = sqlite3MPrintf(pParse->db, "tbl_name=%Q", zName);
101394
- if( !zWhere ) return;
101395
- sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
101396
-
101397
-#ifndef SQLITE_OMIT_TRIGGER
101398
- /* Now, if the table is not stored in the temp database, reload any temp
101399
- ** triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined.
101400
- */
101401
- if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){
101402
- sqlite3VdbeAddParseSchemaOp(v, 1, zWhere);
101403
- }
101404
-#endif
101405
-}
101406
-
101407101142
/*
101408101143
** Parameter zName is the name of a table that is about to be altered
101409101144
** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN).
101410101145
** If the table is a system table, this function leaves an error message
101411101146
** in pParse->zErr (system tables may not be altered) and returns non-zero.
@@ -101417,10 +101152,53 @@
101417101152
sqlite3ErrorMsg(pParse, "table %s may not be altered", zName);
101418101153
return 1;
101419101154
}
101420101155
return 0;
101421101156
}
101157
+
101158
+/*
101159
+** Generate code to verify that the schemas of database zDb and, if
101160
+** bTemp is not true, database "temp", can still be parsed. This is
101161
+** called at the end of the generation of an ALTER TABLE ... RENAME ...
101162
+** statement to ensure that the operation has not rendered any schema
101163
+** objects unusable.
101164
+*/
101165
+void renameTestSchema(Parse *pParse, const char *zDb, int bTemp){
101166
+ sqlite3NestedParse(pParse,
101167
+ "SELECT 1 "
101168
+ "FROM \"%w\".%s "
101169
+ "WHERE name NOT LIKE 'sqlite_%%'"
101170
+ " AND sql NOT LIKE 'create virtual%%'"
101171
+ " AND sqlite_rename_test(%Q, sql, type, name, %d)=NULL ",
101172
+ zDb, MASTER_NAME,
101173
+ zDb, bTemp
101174
+ );
101175
+
101176
+ if( bTemp==0 ){
101177
+ sqlite3NestedParse(pParse,
101178
+ "SELECT 1 "
101179
+ "FROM temp.%s "
101180
+ "WHERE name NOT LIKE 'sqlite_%%'"
101181
+ " AND sql NOT LIKE 'create virtual%%'"
101182
+ " AND sqlite_rename_test(%Q, sql, type, name, 1)=NULL ",
101183
+ MASTER_NAME, zDb
101184
+ );
101185
+ }
101186
+}
101187
+
101188
+/*
101189
+** Generate code to reload the schema for database iDb. And, if iDb!=1, for
101190
+** the temp database as well.
101191
+*/
101192
+void renameReloadSchema(Parse *pParse, int iDb){
101193
+ Vdbe *v = pParse->pVdbe;
101194
+ if( v ){
101195
+ sqlite3ChangeCookie(pParse, iDb);
101196
+ sqlite3VdbeAddParseSchemaOp(pParse->pVdbe, iDb, 0);
101197
+ if( iDb!=1 ) sqlite3VdbeAddParseSchemaOp(pParse->pVdbe, 1, 0);
101198
+ }
101199
+}
101422101200
101423101201
/*
101424101202
** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy"
101425101203
** command.
101426101204
*/
@@ -101435,13 +101213,10 @@
101435101213
char *zName = 0; /* NULL-terminated version of pName */
101436101214
sqlite3 *db = pParse->db; /* Database connection */
101437101215
int nTabName; /* Number of UTF-8 characters in zTabName */
101438101216
const char *zTabName; /* Original name of the table */
101439101217
Vdbe *v;
101440
-#ifndef SQLITE_OMIT_TRIGGER
101441
- char *zWhere = 0; /* Where clause to locate temp triggers */
101442
-#endif
101443101218
VTable *pVTab = 0; /* Non-zero if this is a v-tab with an xRename() */
101444101219
u32 savedDbFlags; /* Saved value of db->mDbFlags */
101445101220
101446101221
savedDbFlags = db->mDbFlags;
101447101222
if( NEVER(db->mallocFailed) ) goto exit_rename_table;
@@ -101510,12 +101285,10 @@
101510101285
*/
101511101286
v = sqlite3GetVdbe(pParse);
101512101287
if( v==0 ){
101513101288
goto exit_rename_table;
101514101289
}
101515
- sqlite3BeginWriteOperation(pParse, pVTab!=0, iDb);
101516
- sqlite3ChangeCookie(pParse, iDb);
101517101290
101518101291
/* If this is a virtual table, invoke the xRename() function if
101519101292
** one is defined. The xRename() callback will modify the names
101520101293
** of any resources used by the v-table implementation (including other
101521101294
** SQLite tables) that are identified by the name of the virtual table.
@@ -101531,48 +101304,35 @@
101531101304
101532101305
/* figure out how many UTF-8 characters are in zName */
101533101306
zTabName = pTab->zName;
101534101307
nTabName = sqlite3Utf8CharLen(zTabName, -1);
101535101308
101536
-#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
101537
- if( db->flags&SQLITE_ForeignKeys ){
101538
- /* If foreign-key support is enabled, rewrite the CREATE TABLE
101539
- ** statements corresponding to all child tables of foreign key constraints
101540
- ** for which the renamed table is the parent table. */
101541
- if( (zWhere=whereForeignKeys(pParse, pTab))!=0 ){
101542
- sqlite3NestedParse(pParse,
101543
- "UPDATE \"%w\".%s SET "
101544
- "sql = sqlite_rename_parent(sql, %Q, %Q) "
101545
- "WHERE %s;", zDb, MASTER_NAME, zTabName, zName, zWhere);
101546
- sqlite3DbFree(db, zWhere);
101547
- }
101548
- }
101549
-#endif
101550
-
101551
- /* Modify the sqlite_master table to use the new table name. */
101309
+ /* Rewrite all CREATE TABLE, INDEX, TRIGGER or VIEW statements in
101310
+ ** the schema to use the new table name. */
101311
+ sqlite3NestedParse(pParse,
101312
+ "UPDATE \"%w\".%s SET "
101313
+ "sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, %d) "
101314
+ "WHERE (type!='index' OR tbl_name=%Q COLLATE nocase)"
101315
+ "AND name NOT LIKE 'sqlite_%%'"
101316
+ , zDb, MASTER_NAME, zDb, zTabName, zName, (iDb==1), zTabName
101317
+ );
101318
+
101319
+ /* Update the tbl_name and name columns of the sqlite_master table
101320
+ ** as required. */
101552101321
sqlite3NestedParse(pParse,
101553101322
"UPDATE %Q.%s SET "
101554
-#ifdef SQLITE_OMIT_TRIGGER
101555
- "sql = sqlite_rename_table(sql, %Q), "
101556
-#else
101557
- "sql = CASE "
101558
- "WHEN type = 'trigger' THEN sqlite_rename_trigger(sql, %Q)"
101559
- "ELSE sqlite_rename_table(sql, %Q) END, "
101560
-#endif
101561101323
"tbl_name = %Q, "
101562101324
"name = CASE "
101563101325
"WHEN type='table' THEN %Q "
101564101326
"WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN "
101565101327
"'sqlite_autoindex_' || %Q || substr(name,%d+18) "
101566101328
"ELSE name END "
101567101329
"WHERE tbl_name=%Q COLLATE nocase AND "
101568101330
"(type='table' OR type='index' OR type='trigger');",
101569
- zDb, MASTER_NAME, zName, zName, zName,
101570
-#ifndef SQLITE_OMIT_TRIGGER
101571
- zName,
101572
-#endif
101573
- zName, nTabName, zTabName
101331
+ zDb, MASTER_NAME,
101332
+ zName, zName, zName,
101333
+ nTabName, zTabName
101574101334
);
101575101335
101576101336
#ifndef SQLITE_OMIT_AUTOINCREMENT
101577101337
/* If the sqlite_sequence table exists in this database, then update
101578101338
** it with the new table name.
@@ -101582,39 +101342,27 @@
101582101342
"UPDATE \"%w\".sqlite_sequence set name = %Q WHERE name = %Q",
101583101343
zDb, zName, pTab->zName);
101584101344
}
101585101345
#endif
101586101346
101587
-#ifndef SQLITE_OMIT_TRIGGER
101588
- /* If there are TEMP triggers on this table, modify the sqlite_temp_master
101589
- ** table. Don't do this if the table being ALTERed is itself located in
101590
- ** the temp database.
101591
- */
101592
- if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){
101347
+ /* If the table being renamed is not itself part of the temp database,
101348
+ ** edit view and trigger definitions within the temp database
101349
+ ** as required. */
101350
+ if( iDb!=1 ){
101593101351
sqlite3NestedParse(pParse,
101594101352
"UPDATE sqlite_temp_master SET "
101595
- "sql = sqlite_rename_trigger(sql, %Q), "
101596
- "tbl_name = %Q "
101597
- "WHERE %s;", zName, zName, zWhere);
101598
- sqlite3DbFree(db, zWhere);
101599
- }
101600
-#endif
101601
-
101602
-#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
101603
- if( db->flags&SQLITE_ForeignKeys ){
101604
- FKey *p;
101605
- for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){
101606
- Table *pFrom = p->pFrom;
101607
- if( pFrom!=pTab ){
101608
- reloadTableSchema(pParse, p->pFrom, pFrom->zName);
101609
- }
101610
- }
101611
- }
101612
-#endif
101613
-
101614
- /* Drop and reload the internal table schema. */
101615
- reloadTableSchema(pParse, pTab, zName);
101353
+ "sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, 1), "
101354
+ "tbl_name = "
101355
+ "CASE WHEN tbl_name=%Q COLLATE nocase AND "
101356
+ " sqlite_rename_test(%Q, sql, type, name, 1) "
101357
+ "THEN %Q ELSE tbl_name END "
101358
+ "WHERE type IN ('view', 'trigger')"
101359
+ , zDb, zTabName, zName, zTabName, zDb, zName);
101360
+ }
101361
+
101362
+ renameReloadSchema(pParse, iDb);
101363
+ renameTestSchema(pParse, zDb, iDb==1);
101616101364
101617101365
exit_rename_table:
101618101366
sqlite3SrcListDelete(db, pSrc);
101619101367
sqlite3DbFree(db, zName);
101620101368
db->mDbFlags = savedDbFlags;
@@ -101636,16 +101384,15 @@
101636101384
const char *zTab; /* Table name */
101637101385
char *zCol; /* Null-terminated column definition */
101638101386
Column *pCol; /* The new column */
101639101387
Expr *pDflt; /* Default value for the new column */
101640101388
sqlite3 *db; /* The database connection; */
101641
- Vdbe *v = pParse->pVdbe; /* The prepared statement under construction */
101389
+ Vdbe *v; /* The prepared statement under construction */
101642101390
int r1; /* Temporary registers */
101643101391
101644101392
db = pParse->db;
101645101393
if( pParse->nErr || db->mallocFailed ) return;
101646
- assert( v!=0 );
101647101394
pNew = pParse->pNewTable;
101648101395
assert( pNew );
101649101396
101650101397
assert( sqlite3BtreeHoldsAllMutexes(db) );
101651101398
iDb = sqlite3SchemaToIndex(db, pNew->pSchema);
@@ -101736,21 +101483,24 @@
101736101483
101737101484
/* Make sure the schema version is at least 3. But do not upgrade
101738101485
** from less than 3 to 4, as that will corrupt any preexisting DESC
101739101486
** index.
101740101487
*/
101741
- r1 = sqlite3GetTempReg(pParse);
101742
- sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);
101743
- sqlite3VdbeUsesBtree(v, iDb);
101744
- sqlite3VdbeAddOp2(v, OP_AddImm, r1, -2);
101745
- sqlite3VdbeAddOp2(v, OP_IfPos, r1, sqlite3VdbeCurrentAddr(v)+2);
101746
- VdbeCoverage(v);
101747
- sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3);
101748
- sqlite3ReleaseTempReg(pParse, r1);
101749
-
101750
- /* Reload the schema of the modified table. */
101751
- reloadTableSchema(pParse, pTab, pTab->zName);
101488
+ v = sqlite3GetVdbe(pParse);
101489
+ if( v ){
101490
+ r1 = sqlite3GetTempReg(pParse);
101491
+ sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);
101492
+ sqlite3VdbeUsesBtree(v, iDb);
101493
+ sqlite3VdbeAddOp2(v, OP_AddImm, r1, -2);
101494
+ sqlite3VdbeAddOp2(v, OP_IfPos, r1, sqlite3VdbeCurrentAddr(v)+2);
101495
+ VdbeCoverage(v);
101496
+ sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3);
101497
+ sqlite3ReleaseTempReg(pParse, r1);
101498
+ }
101499
+
101500
+ /* Reload the table definition */
101501
+ renameReloadSchema(pParse, iDb);
101752101502
}
101753101503
101754101504
/*
101755101505
** This function is called by the parser after the table-name in
101756101506
** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument
@@ -101767,11 +101517,10 @@
101767101517
** coding the "ALTER TABLE ... ADD" statement.
101768101518
*/
101769101519
SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
101770101520
Table *pNew;
101771101521
Table *pTab;
101772
- Vdbe *v;
101773101522
int iDb;
101774101523
int i;
101775101524
int nAlloc;
101776101525
sqlite3 *db = pParse->db;
101777101526
@@ -101831,20 +101580,1113 @@
101831101580
}
101832101581
pNew->pSchema = db->aDb[iDb].pSchema;
101833101582
pNew->addColOffset = pTab->addColOffset;
101834101583
pNew->nTabRef = 1;
101835101584
101836
- /* Begin a transaction and increment the schema cookie. */
101837
- sqlite3BeginWriteOperation(pParse, 0, iDb);
101838
- v = sqlite3GetVdbe(pParse);
101839
- if( !v ) goto exit_begin_add_column;
101840
- sqlite3ChangeCookie(pParse, iDb);
101841
-
101842101585
exit_begin_add_column:
101843101586
sqlite3SrcListDelete(db, pSrc);
101844101587
return;
101845101588
}
101589
+
101590
+/*
101591
+** Parameter pTab is the subject of an ALTER TABLE ... RENAME COLUMN
101592
+** command. This function checks if the table is a view or virtual
101593
+** table (columns of views or virtual tables may not be renamed). If so,
101594
+** it loads an error message into pParse and returns non-zero.
101595
+**
101596
+** Or, if pTab is not a view or virtual table, zero is returned.
101597
+*/
101598
+#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)
101599
+static int isRealTable(Parse *pParse, Table *pTab){
101600
+ const char *zType = 0;
101601
+#ifndef SQLITE_OMIT_VIEW
101602
+ if( pTab->pSelect ){
101603
+ zType = "view";
101604
+ }
101605
+#endif
101606
+#ifndef SQLITE_OMIT_VIRTUALTABLE
101607
+ if( IsVirtual(pTab) ){
101608
+ zType = "virtual table";
101609
+ }
101610
+#endif
101611
+ if( zType ){
101612
+ sqlite3ErrorMsg(
101613
+ pParse, "cannot rename columns of %s \"%s\"", zType, pTab->zName
101614
+ );
101615
+ return 1;
101616
+ }
101617
+ return 0;
101618
+}
101619
+#else /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */
101620
+# define isRealTable(x,y) (0)
101621
+#endif
101622
+
101623
+/*
101624
+** Handles the following parser reduction:
101625
+**
101626
+** cmd ::= ALTER TABLE pSrc RENAME COLUMN pOld TO pNew
101627
+*/
101628
+SQLITE_PRIVATE void sqlite3AlterRenameColumn(
101629
+ Parse *pParse, /* Parsing context */
101630
+ SrcList *pSrc, /* Table being altered. pSrc->nSrc==1 */
101631
+ Token *pOld, /* Name of column being changed */
101632
+ Token *pNew /* New column name */
101633
+){
101634
+ sqlite3 *db = pParse->db; /* Database connection */
101635
+ Table *pTab; /* Table being updated */
101636
+ int iCol; /* Index of column being renamed */
101637
+ char *zOld = 0; /* Old column name */
101638
+ char *zNew = 0; /* New column name */
101639
+ const char *zDb; /* Name of schema containing the table */
101640
+ int iSchema; /* Index of the schema */
101641
+ int bQuote; /* True to quote the new name */
101642
+
101643
+ /* Locate the table to be altered */
101644
+ pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);
101645
+ if( !pTab ) goto exit_rename_column;
101646
+
101647
+ /* Cannot alter a system table */
101648
+ if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ) goto exit_rename_column;
101649
+ if( SQLITE_OK!=isRealTable(pParse, pTab) ) goto exit_rename_column;
101650
+
101651
+ /* Which schema holds the table to be altered */
101652
+ iSchema = sqlite3SchemaToIndex(db, pTab->pSchema);
101653
+ assert( iSchema>=0 );
101654
+ zDb = db->aDb[iSchema].zDbSName;
101655
+
101656
+#ifndef SQLITE_OMIT_AUTHORIZATION
101657
+ /* Invoke the authorization callback. */
101658
+ if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){
101659
+ goto exit_rename_column;
101660
+ }
101661
+#endif
101662
+
101663
+ /* Make sure the old name really is a column name in the table to be
101664
+ ** altered. Set iCol to be the index of the column being renamed */
101665
+ zOld = sqlite3NameFromToken(db, pOld);
101666
+ if( !zOld ) goto exit_rename_column;
101667
+ for(iCol=0; iCol<pTab->nCol; iCol++){
101668
+ if( 0==sqlite3StrICmp(pTab->aCol[iCol].zName, zOld) ) break;
101669
+ }
101670
+ if( iCol==pTab->nCol ){
101671
+ sqlite3ErrorMsg(pParse, "no such column: \"%s\"", zOld);
101672
+ goto exit_rename_column;
101673
+ }
101674
+
101675
+ /* Do the rename operation using a recursive UPDATE statement that
101676
+ ** uses the sqlite_rename_column() SQL function to compute the new
101677
+ ** CREATE statement text for the sqlite_master table.
101678
+ */
101679
+ zNew = sqlite3NameFromToken(db, pNew);
101680
+ if( !zNew ) goto exit_rename_column;
101681
+ assert( pNew->n>0 );
101682
+ bQuote = sqlite3Isquote(pNew->z[0]);
101683
+ sqlite3NestedParse(pParse,
101684
+ "UPDATE \"%w\".%s SET "
101685
+ "sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, %d) "
101686
+ "WHERE name NOT LIKE 'sqlite_%%' AND (type != 'index' OR tbl_name = %Q)"
101687
+ " AND sql NOT LIKE 'create virtual%%'",
101688
+ zDb, MASTER_NAME,
101689
+ zDb, pTab->zName, iCol, zNew, bQuote, iSchema==1,
101690
+ pTab->zName
101691
+ );
101692
+
101693
+ sqlite3NestedParse(pParse,
101694
+ "UPDATE temp.%s SET "
101695
+ "sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, 1) "
101696
+ "WHERE type IN ('trigger', 'view')",
101697
+ MASTER_NAME,
101698
+ zDb, pTab->zName, iCol, zNew, bQuote
101699
+ );
101700
+
101701
+ /* Drop and reload the database schema. */
101702
+ renameReloadSchema(pParse, iSchema);
101703
+ renameTestSchema(pParse, zDb, iSchema==1);
101704
+
101705
+ exit_rename_column:
101706
+ sqlite3SrcListDelete(db, pSrc);
101707
+ sqlite3DbFree(db, zOld);
101708
+ sqlite3DbFree(db, zNew);
101709
+ return;
101710
+}
101711
+
101712
+/*
101713
+** Each RenameToken object maps an element of the parse tree into
101714
+** the token that generated that element. The parse tree element
101715
+** might be one of:
101716
+**
101717
+** * A pointer to an Expr that represents an ID
101718
+** * The name of a table column in Column.zName
101719
+**
101720
+** A list of RenameToken objects can be constructed during parsing.
101721
+** Each new object is created by sqlite3RenameTokenMap().
101722
+** As the parse tree is transformed, the sqlite3RenameTokenRemap()
101723
+** routine is used to keep the mapping current.
101724
+**
101725
+** After the parse finishes, renameTokenFind() routine can be used
101726
+** to look up the actual token value that created some element in
101727
+** the parse tree.
101728
+*/
101729
+struct RenameToken {
101730
+ void *p; /* Parse tree element created by token t */
101731
+ Token t; /* The token that created parse tree element p */
101732
+ RenameToken *pNext; /* Next is a list of all RenameToken objects */
101733
+};
101734
+
101735
+/*
101736
+** The context of an ALTER TABLE RENAME COLUMN operation that gets passed
101737
+** down into the Walker.
101738
+*/
101739
+typedef struct RenameCtx RenameCtx;
101740
+struct RenameCtx {
101741
+ RenameToken *pList; /* List of tokens to overwrite */
101742
+ int nList; /* Number of tokens in pList */
101743
+ int iCol; /* Index of column being renamed */
101744
+ Table *pTab; /* Table being ALTERed */
101745
+ const char *zOld; /* Old column name */
101746
+};
101747
+
101748
+#ifdef SQLITE_DEBUG
101749
+/*
101750
+** This function is only for debugging. It performs two tasks:
101751
+**
101752
+** 1. Checks that pointer pPtr does not already appear in the
101753
+** rename-token list.
101754
+**
101755
+** 2. Dereferences each pointer in the rename-token list.
101756
+**
101757
+** The second is most effective when debugging under valgrind or
101758
+** address-sanitizer or similar. If any of these pointers no longer
101759
+** point to valid objects, an exception is raised by the memory-checking
101760
+** tool.
101761
+**
101762
+** The point of this is to prevent comparisons of invalid pointer values.
101763
+** Even though this always seems to work, it is undefined according to the
101764
+** C standard. Example of undefined comparison:
101765
+**
101766
+** sqlite3_free(x);
101767
+** if( x==y ) ...
101768
+**
101769
+** Technically, as x no longer points into a valid object or to the byte
101770
+** following a valid object, it may not be used in comparison operations.
101771
+*/
101772
+void renameTokenCheckAll(Parse *pParse, void *pPtr){
101773
+ if( pParse->nErr==0 && pParse->db->mallocFailed==0 ){
101774
+ RenameToken *p;
101775
+ u8 i = 0;
101776
+ for(p=pParse->pRename; p; p=p->pNext){
101777
+ if( p->p ){
101778
+ assert( p->p!=pPtr );
101779
+ i += *(u8*)(p->p);
101780
+ }
101781
+ }
101782
+ }
101783
+}
101784
+#else
101785
+# define renameTokenCheckAll(x,y)
101786
+#endif
101787
+
101788
+/*
101789
+** Add a new RenameToken object mapping parse tree element pPtr into
101790
+** token *pToken to the Parse object currently under construction.
101791
+**
101792
+** Return a copy of pPtr.
101793
+*/
101794
+SQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse *pParse, void *pPtr, Token *pToken){
101795
+ RenameToken *pNew;
101796
+ assert( pPtr || pParse->db->mallocFailed );
101797
+ renameTokenCheckAll(pParse, pPtr);
101798
+ pNew = sqlite3DbMallocZero(pParse->db, sizeof(RenameToken));
101799
+ if( pNew ){
101800
+ pNew->p = pPtr;
101801
+ pNew->t = *pToken;
101802
+ pNew->pNext = pParse->pRename;
101803
+ pParse->pRename = pNew;
101804
+ }
101805
+
101806
+ return pPtr;
101807
+}
101808
+
101809
+/*
101810
+** It is assumed that there is already a RenameToken object associated
101811
+** with parse tree element pFrom. This function remaps the associated token
101812
+** to parse tree element pTo.
101813
+*/
101814
+SQLITE_PRIVATE void sqlite3RenameTokenRemap(Parse *pParse, void *pTo, void *pFrom){
101815
+ RenameToken *p;
101816
+ renameTokenCheckAll(pParse, pTo);
101817
+ for(p=pParse->pRename; p; p=p->pNext){
101818
+ if( p->p==pFrom ){
101819
+ p->p = pTo;
101820
+ break;
101821
+ }
101822
+ }
101823
+}
101824
+
101825
+/*
101826
+** Walker callback used by sqlite3RenameExprUnmap().
101827
+*/
101828
+static int renameUnmapExprCb(Walker *pWalker, Expr *pExpr){
101829
+ Parse *pParse = pWalker->pParse;
101830
+ sqlite3RenameTokenRemap(pParse, 0, (void*)pExpr);
101831
+ return WRC_Continue;
101832
+}
101833
+
101834
+/*
101835
+** Remove all nodes that are part of expression pExpr from the rename list.
101836
+*/
101837
+SQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse *pParse, Expr *pExpr){
101838
+ Walker sWalker;
101839
+ memset(&sWalker, 0, sizeof(Walker));
101840
+ sWalker.pParse = pParse;
101841
+ sWalker.xExprCallback = renameUnmapExprCb;
101842
+ sqlite3WalkExpr(&sWalker, pExpr);
101843
+}
101844
+
101845
+/*
101846
+** Free the list of RenameToken objects given in the second argument
101847
+*/
101848
+static void renameTokenFree(sqlite3 *db, RenameToken *pToken){
101849
+ RenameToken *pNext;
101850
+ RenameToken *p;
101851
+ for(p=pToken; p; p=pNext){
101852
+ pNext = p->pNext;
101853
+ sqlite3DbFree(db, p);
101854
+ }
101855
+}
101856
+
101857
+/*
101858
+** Search the Parse object passed as the first argument for a RenameToken
101859
+** object associated with parse tree element pPtr. If found, remove it
101860
+** from the Parse object and add it to the list maintained by the
101861
+** RenameCtx object passed as the second argument.
101862
+*/
101863
+static void renameTokenFind(Parse *pParse, struct RenameCtx *pCtx, void *pPtr){
101864
+ RenameToken **pp;
101865
+ assert( pPtr!=0 );
101866
+ for(pp=&pParse->pRename; (*pp); pp=&(*pp)->pNext){
101867
+ if( (*pp)->p==pPtr ){
101868
+ RenameToken *pToken = *pp;
101869
+ *pp = pToken->pNext;
101870
+ pToken->pNext = pCtx->pList;
101871
+ pCtx->pList = pToken;
101872
+ pCtx->nList++;
101873
+ break;
101874
+ }
101875
+ }
101876
+}
101877
+
101878
+/*
101879
+** This is a Walker select callback. It does nothing. It is only required
101880
+** because without a dummy callback, sqlite3WalkExpr() and similar do not
101881
+** descend into sub-select statements.
101882
+*/
101883
+static int renameColumnSelectCb(Walker *pWalker, Select *p){
101884
+ UNUSED_PARAMETER(pWalker);
101885
+ UNUSED_PARAMETER(p);
101886
+ return WRC_Continue;
101887
+}
101888
+
101889
+/*
101890
+** This is a Walker expression callback.
101891
+**
101892
+** For every TK_COLUMN node in the expression tree, search to see
101893
+** if the column being references is the column being renamed by an
101894
+** ALTER TABLE statement. If it is, then attach its associated
101895
+** RenameToken object to the list of RenameToken objects being
101896
+** constructed in RenameCtx object at pWalker->u.pRename.
101897
+*/
101898
+static int renameColumnExprCb(Walker *pWalker, Expr *pExpr){
101899
+ RenameCtx *p = pWalker->u.pRename;
101900
+ if( pExpr->op==TK_TRIGGER
101901
+ && pExpr->iColumn==p->iCol
101902
+ && pWalker->pParse->pTriggerTab==p->pTab
101903
+ ){
101904
+ renameTokenFind(pWalker->pParse, p, (void*)pExpr);
101905
+ }else if( pExpr->op==TK_COLUMN
101906
+ && pExpr->iColumn==p->iCol
101907
+ && p->pTab==pExpr->pTab
101908
+ ){
101909
+ renameTokenFind(pWalker->pParse, p, (void*)pExpr);
101910
+ }
101911
+ return WRC_Continue;
101912
+}
101913
+
101914
+/*
101915
+** The RenameCtx contains a list of tokens that reference a column that
101916
+** is being renamed by an ALTER TABLE statement. Return the "last"
101917
+** RenameToken in the RenameCtx and remove that RenameToken from the
101918
+** RenameContext. "Last" means the last RenameToken encountered when
101919
+** the input SQL is parsed from left to right. Repeated calls to this routine
101920
+** return all column name tokens in the order that they are encountered
101921
+** in the SQL statement.
101922
+*/
101923
+static RenameToken *renameColumnTokenNext(RenameCtx *pCtx){
101924
+ RenameToken *pBest = pCtx->pList;
101925
+ RenameToken *pToken;
101926
+ RenameToken **pp;
101927
+
101928
+ for(pToken=pBest->pNext; pToken; pToken=pToken->pNext){
101929
+ if( pToken->t.z>pBest->t.z ) pBest = pToken;
101930
+ }
101931
+ for(pp=&pCtx->pList; *pp!=pBest; pp=&(*pp)->pNext);
101932
+ *pp = pBest->pNext;
101933
+
101934
+ return pBest;
101935
+}
101936
+
101937
+/*
101938
+** An error occured while parsing or otherwise processing a database
101939
+** object (either pParse->pNewTable, pNewIndex or pNewTrigger) as part of an
101940
+** ALTER TABLE RENAME COLUMN program. The error message emitted by the
101941
+** sub-routine is currently stored in pParse->zErrMsg. This function
101942
+** adds context to the error message and then stores it in pCtx.
101943
+*/
101944
+static void renameColumnParseError(
101945
+ sqlite3_context *pCtx,
101946
+ int bPost,
101947
+ sqlite3_value *pType,
101948
+ sqlite3_value *pObject,
101949
+ Parse *pParse
101950
+){
101951
+ const char *zT = (const char*)sqlite3_value_text(pType);
101952
+ const char *zN = (const char*)sqlite3_value_text(pObject);
101953
+ char *zErr;
101954
+
101955
+ zErr = sqlite3_mprintf("error in %s %s%s: %s",
101956
+ zT, zN, (bPost ? " after rename" : ""),
101957
+ pParse->zErrMsg
101958
+ );
101959
+ sqlite3_result_error(pCtx, zErr, -1);
101960
+ sqlite3_free(zErr);
101961
+}
101962
+
101963
+/*
101964
+** For each name in the the expression-list pEList (i.e. each
101965
+** pEList->a[i].zName) that matches the string in zOld, extract the
101966
+** corresponding rename-token from Parse object pParse and add it
101967
+** to the RenameCtx pCtx.
101968
+*/
101969
+static void renameColumnElistNames(
101970
+ Parse *pParse,
101971
+ RenameCtx *pCtx,
101972
+ ExprList *pEList,
101973
+ const char *zOld
101974
+){
101975
+ if( pEList ){
101976
+ int i;
101977
+ for(i=0; i<pEList->nExpr; i++){
101978
+ char *zName = pEList->a[i].zName;
101979
+ if( 0==sqlite3_stricmp(zName, zOld) ){
101980
+ renameTokenFind(pParse, pCtx, (void*)zName);
101981
+ }
101982
+ }
101983
+ }
101984
+}
101985
+
101986
+/*
101987
+** For each name in the the id-list pIdList (i.e. each pIdList->a[i].zName)
101988
+** that matches the string in zOld, extract the corresponding rename-token
101989
+** from Parse object pParse and add it to the RenameCtx pCtx.
101990
+*/
101991
+static void renameColumnIdlistNames(
101992
+ Parse *pParse,
101993
+ RenameCtx *pCtx,
101994
+ IdList *pIdList,
101995
+ const char *zOld
101996
+){
101997
+ if( pIdList ){
101998
+ int i;
101999
+ for(i=0; i<pIdList->nId; i++){
102000
+ char *zName = pIdList->a[i].zName;
102001
+ if( 0==sqlite3_stricmp(zName, zOld) ){
102002
+ renameTokenFind(pParse, pCtx, (void*)zName);
102003
+ }
102004
+ }
102005
+ }
102006
+}
102007
+
102008
+/*
102009
+** Parse the SQL statement zSql using Parse object (*p). The Parse object
102010
+** is initialized by this function before it is used.
102011
+*/
102012
+static int renameParseSql(
102013
+ Parse *p, /* Memory to use for Parse object */
102014
+ const char *zDb, /* Name of schema SQL belongs to */
102015
+ int bTable, /* 1 -> RENAME TABLE, 0 -> RENAME COLUMN */
102016
+ sqlite3 *db, /* Database handle */
102017
+ const char *zSql, /* SQL to parse */
102018
+ int bTemp /* True if SQL is from temp schema */
102019
+){
102020
+ int rc;
102021
+ char *zErr = 0;
102022
+
102023
+ db->init.iDb = bTemp ? 1 : sqlite3FindDbName(db, zDb);
102024
+
102025
+ /* Parse the SQL statement passed as the first argument. If no error
102026
+ ** occurs and the parse does not result in a new table, index or
102027
+ ** trigger object, the database must be corrupt. */
102028
+ memset(p, 0, sizeof(Parse));
102029
+ p->eParseMode = (bTable ? PARSE_MODE_RENAME_TABLE : PARSE_MODE_RENAME_COLUMN);
102030
+ p->db = db;
102031
+ p->nQueryLoop = 1;
102032
+ rc = sqlite3RunParser(p, zSql, &zErr);
102033
+ assert( p->zErrMsg==0 );
102034
+ assert( rc!=SQLITE_OK || zErr==0 );
102035
+ assert( (0!=p->pNewTable) + (0!=p->pNewIndex) + (0!=p->pNewTrigger)<2 );
102036
+ p->zErrMsg = zErr;
102037
+ if( db->mallocFailed ) rc = SQLITE_NOMEM;
102038
+ if( rc==SQLITE_OK
102039
+ && p->pNewTable==0 && p->pNewIndex==0 && p->pNewTrigger==0
102040
+ ){
102041
+ rc = SQLITE_CORRUPT_BKPT;
102042
+ }
102043
+
102044
+#ifdef SQLITE_DEBUG
102045
+ /* Ensure that all mappings in the Parse.pRename list really do map to
102046
+ ** a part of the input string. */
102047
+ if( rc==SQLITE_OK ){
102048
+ int nSql = sqlite3Strlen30(zSql);
102049
+ RenameToken *pToken;
102050
+ for(pToken=p->pRename; pToken; pToken=pToken->pNext){
102051
+ assert( pToken->t.z>=zSql && &pToken->t.z[pToken->t.n]<=&zSql[nSql] );
102052
+ }
102053
+ }
102054
+#endif
102055
+
102056
+ db->init.iDb = 0;
102057
+ return rc;
102058
+}
102059
+
102060
+/*
102061
+** This function edits SQL statement zSql, replacing each token identified
102062
+** by the linked list pRename with the text of zNew. If argument bQuote is
102063
+** true, then zNew is always quoted first. If no error occurs, the result
102064
+** is loaded into context object pCtx as the result.
102065
+**
102066
+** Or, if an error occurs (i.e. an OOM condition), an error is left in
102067
+** pCtx and an SQLite error code returned.
102068
+*/
102069
+static int renameEditSql(
102070
+ sqlite3_context *pCtx, /* Return result here */
102071
+ RenameCtx *pRename, /* Rename context */
102072
+ const char *zSql, /* SQL statement to edit */
102073
+ const char *zNew, /* New token text */
102074
+ int bQuote /* True to always quote token */
102075
+){
102076
+ int nNew = sqlite3Strlen30(zNew);
102077
+ int nSql = sqlite3Strlen30(zSql);
102078
+ sqlite3 *db = sqlite3_context_db_handle(pCtx);
102079
+ int rc = SQLITE_OK;
102080
+ char *zQuot;
102081
+ char *zOut;
102082
+ int nQuot;
102083
+
102084
+ /* Set zQuot to point to a buffer containing a quoted copy of the
102085
+ ** identifier zNew. If the corresponding identifier in the original
102086
+ ** ALTER TABLE statement was quoted (bQuote==1), then set zNew to
102087
+ ** point to zQuot so that all substitutions are made using the
102088
+ ** quoted version of the new column name. */
102089
+ zQuot = sqlite3MPrintf(db, "\"%w\"", zNew);
102090
+ if( zQuot==0 ){
102091
+ return SQLITE_NOMEM;
102092
+ }else{
102093
+ nQuot = sqlite3Strlen30(zQuot);
102094
+ }
102095
+ if( bQuote ){
102096
+ zNew = zQuot;
102097
+ nNew = nQuot;
102098
+ }
102099
+
102100
+ /* At this point pRename->pList contains a list of RenameToken objects
102101
+ ** corresponding to all tokens in the input SQL that must be replaced
102102
+ ** with the new column name. All that remains is to construct and
102103
+ ** return the edited SQL string. */
102104
+ assert( nQuot>=nNew );
102105
+ zOut = sqlite3DbMallocZero(db, nSql + pRename->nList*nQuot + 1);
102106
+ if( zOut ){
102107
+ int nOut = nSql;
102108
+ memcpy(zOut, zSql, nSql);
102109
+ while( pRename->pList ){
102110
+ int iOff; /* Offset of token to replace in zOut */
102111
+ RenameToken *pBest = renameColumnTokenNext(pRename);
102112
+
102113
+ u32 nReplace;
102114
+ const char *zReplace;
102115
+ if( sqlite3IsIdChar(*pBest->t.z) ){
102116
+ nReplace = nNew;
102117
+ zReplace = zNew;
102118
+ }else{
102119
+ nReplace = nQuot;
102120
+ zReplace = zQuot;
102121
+ }
102122
+
102123
+ iOff = pBest->t.z - zSql;
102124
+ if( pBest->t.n!=nReplace ){
102125
+ memmove(&zOut[iOff + nReplace], &zOut[iOff + pBest->t.n],
102126
+ nOut - (iOff + pBest->t.n)
102127
+ );
102128
+ nOut += nReplace - pBest->t.n;
102129
+ zOut[nOut] = '\0';
102130
+ }
102131
+ memcpy(&zOut[iOff], zReplace, nReplace);
102132
+ sqlite3DbFree(db, pBest);
102133
+ }
102134
+
102135
+ sqlite3_result_text(pCtx, zOut, -1, SQLITE_TRANSIENT);
102136
+ sqlite3DbFree(db, zOut);
102137
+ }else{
102138
+ rc = SQLITE_NOMEM;
102139
+ }
102140
+
102141
+ sqlite3_free(zQuot);
102142
+ return rc;
102143
+}
102144
+
102145
+/*
102146
+** Resolve all symbols in the trigger at pParse->pNewTrigger, assuming
102147
+** it was read from the schema of database zDb. Return SQLITE_OK if
102148
+** successful. Otherwise, return an SQLite error code and leave an error
102149
+** message in the Parse object.
102150
+*/
102151
+static int renameResolveTrigger(Parse *pParse, const char *zDb){
102152
+ sqlite3 *db = pParse->db;
102153
+ TriggerStep *pStep;
102154
+ NameContext sNC;
102155
+ int rc = SQLITE_OK;
102156
+
102157
+ memset(&sNC, 0, sizeof(sNC));
102158
+ sNC.pParse = pParse;
102159
+ pParse->pTriggerTab = sqlite3FindTable(db, pParse->pNewTrigger->table, zDb);
102160
+ pParse->eTriggerOp = pParse->pNewTrigger->op;
102161
+
102162
+ /* Resolve symbols in WHEN clause */
102163
+ if( pParse->pNewTrigger->pWhen ){
102164
+ rc = sqlite3ResolveExprNames(&sNC, pParse->pNewTrigger->pWhen);
102165
+ }
102166
+
102167
+ for(pStep=pParse->pNewTrigger->step_list;
102168
+ rc==SQLITE_OK && pStep;
102169
+ pStep=pStep->pNext
102170
+ ){
102171
+ if( pStep->pSelect ){
102172
+ sqlite3SelectPrep(pParse, pStep->pSelect, &sNC);
102173
+ if( pParse->nErr ) rc = pParse->rc;
102174
+ }
102175
+ if( rc==SQLITE_OK && pStep->zTarget ){
102176
+ Table *pTarget = sqlite3LocateTable(pParse, 0, pStep->zTarget, zDb);
102177
+ if( pTarget==0 ){
102178
+ rc = SQLITE_ERROR;
102179
+ }else{
102180
+ SrcList sSrc;
102181
+ memset(&sSrc, 0, sizeof(sSrc));
102182
+ sSrc.nSrc = 1;
102183
+ sSrc.a[0].zName = pStep->zTarget;
102184
+ sSrc.a[0].pTab = pTarget;
102185
+ sNC.pSrcList = &sSrc;
102186
+ if( pStep->pWhere ){
102187
+ rc = sqlite3ResolveExprNames(&sNC, pStep->pWhere);
102188
+ }
102189
+ if( rc==SQLITE_OK ){
102190
+ rc = sqlite3ResolveExprListNames(&sNC, pStep->pExprList);
102191
+ }
102192
+ assert( !pStep->pUpsert || (!pStep->pWhere && !pStep->pExprList) );
102193
+ if( pStep->pUpsert ){
102194
+ Upsert *pUpsert = pStep->pUpsert;
102195
+ assert( rc==SQLITE_OK );
102196
+ pUpsert->pUpsertSrc = &sSrc;
102197
+ sNC.uNC.pUpsert = pUpsert;
102198
+ sNC.ncFlags = NC_UUpsert;
102199
+ rc = sqlite3ResolveExprListNames(&sNC, pUpsert->pUpsertTarget);
102200
+ if( rc==SQLITE_OK ){
102201
+ ExprList *pUpsertSet = pUpsert->pUpsertSet;
102202
+ rc = sqlite3ResolveExprListNames(&sNC, pUpsertSet);
102203
+ }
102204
+ if( rc==SQLITE_OK ){
102205
+ rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertWhere);
102206
+ }
102207
+ if( rc==SQLITE_OK ){
102208
+ rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertTargetWhere);
102209
+ }
102210
+ sNC.ncFlags = 0;
102211
+ }
102212
+ }
102213
+ }
102214
+ }
102215
+ return rc;
102216
+}
102217
+
102218
+/*
102219
+** Invoke sqlite3WalkExpr() or sqlite3WalkSelect() on all Select or Expr
102220
+** objects that are part of the trigger passed as the second argument.
102221
+*/
102222
+static void renameWalkTrigger(Walker *pWalker, Trigger *pTrigger){
102223
+ TriggerStep *pStep;
102224
+
102225
+ /* Find tokens to edit in WHEN clause */
102226
+ sqlite3WalkExpr(pWalker, pTrigger->pWhen);
102227
+
102228
+ /* Find tokens to edit in trigger steps */
102229
+ for(pStep=pTrigger->step_list; pStep; pStep=pStep->pNext){
102230
+ sqlite3WalkSelect(pWalker, pStep->pSelect);
102231
+ sqlite3WalkExpr(pWalker, pStep->pWhere);
102232
+ sqlite3WalkExprList(pWalker, pStep->pExprList);
102233
+ if( pStep->pUpsert ){
102234
+ Upsert *pUpsert = pStep->pUpsert;
102235
+ sqlite3WalkExprList(pWalker, pUpsert->pUpsertTarget);
102236
+ sqlite3WalkExprList(pWalker, pUpsert->pUpsertSet);
102237
+ sqlite3WalkExpr(pWalker, pUpsert->pUpsertWhere);
102238
+ sqlite3WalkExpr(pWalker, pUpsert->pUpsertTargetWhere);
102239
+ }
102240
+ }
102241
+}
102242
+
102243
+/*
102244
+** Free the contents of Parse object (*pParse). Do not free the memory
102245
+** occupied by the Parse object itself.
102246
+*/
102247
+static void renameParseCleanup(Parse *pParse){
102248
+ sqlite3 *db = pParse->db;
102249
+ if( pParse->pVdbe ){
102250
+ sqlite3VdbeFinalize(pParse->pVdbe);
102251
+ }
102252
+ sqlite3DeleteTable(db, pParse->pNewTable);
102253
+ if( pParse->pNewIndex ) sqlite3FreeIndex(db, pParse->pNewIndex);
102254
+ sqlite3DeleteTrigger(db, pParse->pNewTrigger);
102255
+ sqlite3DbFree(db, pParse->zErrMsg);
102256
+ renameTokenFree(db, pParse->pRename);
102257
+ sqlite3ParserReset(pParse);
102258
+}
102259
+
102260
+/*
102261
+** SQL function:
102262
+**
102263
+** sqlite_rename_column(zSql, iCol, bQuote, zNew, zTable, zOld)
102264
+**
102265
+** 0. zSql: SQL statement to rewrite
102266
+** 1. type: Type of object ("table", "view" etc.)
102267
+** 2. object: Name of object
102268
+** 3. Database: Database name (e.g. "main")
102269
+** 4. Table: Table name
102270
+** 5. iCol: Index of column to rename
102271
+** 6. zNew: New column name
102272
+** 7. bQuote: Non-zero if the new column name should be quoted.
102273
+** 8. bTemp: True if zSql comes from temp schema
102274
+**
102275
+** Do a column rename operation on the CREATE statement given in zSql.
102276
+** The iCol-th column (left-most is 0) of table zTable is renamed from zCol
102277
+** into zNew. The name should be quoted if bQuote is true.
102278
+**
102279
+** This function is used internally by the ALTER TABLE RENAME COLUMN command.
102280
+** Though accessible to application code, it is not intended for use by
102281
+** applications. The existance of this function, and the way it works,
102282
+** is subject to change without notice.
102283
+**
102284
+** If any of the parameters are out-of-bounds, then simply return NULL.
102285
+** An out-of-bounds parameter can only occur when the application calls
102286
+** this function directly. The parameters will always be well-formed when
102287
+** this routine is invoked by the bytecode for a legitimate ALTER TABLE
102288
+** statement.
102289
+*/
102290
+static void renameColumnFunc(
102291
+ sqlite3_context *context,
102292
+ int NotUsed,
102293
+ sqlite3_value **argv
102294
+){
102295
+ sqlite3 *db = sqlite3_context_db_handle(context);
102296
+ RenameCtx sCtx;
102297
+ const char *zSql = (const char*)sqlite3_value_text(argv[0]);
102298
+ const char *zDb = (const char*)sqlite3_value_text(argv[3]);
102299
+ const char *zTable = (const char*)sqlite3_value_text(argv[4]);
102300
+ int iCol = sqlite3_value_int(argv[5]);
102301
+ const char *zNew = (const char*)sqlite3_value_text(argv[6]);
102302
+ int bQuote = sqlite3_value_int(argv[7]);
102303
+ int bTemp = sqlite3_value_int(argv[8]);
102304
+ const char *zOld;
102305
+ int rc;
102306
+ Parse sParse;
102307
+ Walker sWalker;
102308
+ Index *pIdx;
102309
+ int i;
102310
+ Table *pTab;
102311
+#ifndef SQLITE_OMIT_AUTHORIZATION
102312
+ sqlite3_xauth xAuth = db->xAuth;
102313
+#endif
102314
+
102315
+ UNUSED_PARAMETER(NotUsed);
102316
+ if( zSql==0 ) return;
102317
+ if( zTable==0 ) return;
102318
+ if( zNew==0 ) return;
102319
+ if( iCol<0 ) return;
102320
+ sqlite3BtreeEnterAll(db);
102321
+ pTab = sqlite3FindTable(db, zTable, zDb);
102322
+ if( pTab==0 || iCol>=pTab->nCol ){
102323
+ sqlite3BtreeLeaveAll(db);
102324
+ return;
102325
+ }
102326
+ zOld = pTab->aCol[iCol].zName;
102327
+ memset(&sCtx, 0, sizeof(sCtx));
102328
+ sCtx.iCol = ((iCol==pTab->iPKey) ? -1 : iCol);
102329
+
102330
+#ifndef SQLITE_OMIT_AUTHORIZATION
102331
+ db->xAuth = 0;
102332
+#endif
102333
+ rc = renameParseSql(&sParse, zDb, 0, db, zSql, bTemp);
102334
+
102335
+ /* Find tokens that need to be replaced. */
102336
+ memset(&sWalker, 0, sizeof(Walker));
102337
+ sWalker.pParse = &sParse;
102338
+ sWalker.xExprCallback = renameColumnExprCb;
102339
+ sWalker.xSelectCallback = renameColumnSelectCb;
102340
+ sWalker.u.pRename = &sCtx;
102341
+
102342
+ sCtx.pTab = pTab;
102343
+ if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
102344
+ if( sParse.pNewTable ){
102345
+ Select *pSelect = sParse.pNewTable->pSelect;
102346
+ if( pSelect ){
102347
+ sParse.rc = SQLITE_OK;
102348
+ sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, 0);
102349
+ rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc);
102350
+ if( rc==SQLITE_OK ){
102351
+ sqlite3WalkSelect(&sWalker, pSelect);
102352
+ }
102353
+ if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
102354
+ }else{
102355
+ /* A regular table */
102356
+ int bFKOnly = sqlite3_stricmp(zTable, sParse.pNewTable->zName);
102357
+ FKey *pFKey;
102358
+ assert( sParse.pNewTable->pSelect==0 );
102359
+ sCtx.pTab = sParse.pNewTable;
102360
+ if( bFKOnly==0 ){
102361
+ renameTokenFind(
102362
+ &sParse, &sCtx, (void*)sParse.pNewTable->aCol[iCol].zName
102363
+ );
102364
+ if( sCtx.iCol<0 ){
102365
+ renameTokenFind(&sParse, &sCtx, (void*)&sParse.pNewTable->iPKey);
102366
+ }
102367
+ sqlite3WalkExprList(&sWalker, sParse.pNewTable->pCheck);
102368
+ for(pIdx=sParse.pNewTable->pIndex; pIdx; pIdx=pIdx->pNext){
102369
+ sqlite3WalkExprList(&sWalker, pIdx->aColExpr);
102370
+ }
102371
+ }
102372
+
102373
+ for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){
102374
+ for(i=0; i<pFKey->nCol; i++){
102375
+ if( bFKOnly==0 && pFKey->aCol[i].iFrom==iCol ){
102376
+ renameTokenFind(&sParse, &sCtx, (void*)&pFKey->aCol[i]);
102377
+ }
102378
+ if( 0==sqlite3_stricmp(pFKey->zTo, zTable)
102379
+ && 0==sqlite3_stricmp(pFKey->aCol[i].zCol, zOld)
102380
+ ){
102381
+ renameTokenFind(&sParse, &sCtx, (void*)pFKey->aCol[i].zCol);
102382
+ }
102383
+ }
102384
+ }
102385
+ }
102386
+ }else if( sParse.pNewIndex ){
102387
+ sqlite3WalkExprList(&sWalker, sParse.pNewIndex->aColExpr);
102388
+ sqlite3WalkExpr(&sWalker, sParse.pNewIndex->pPartIdxWhere);
102389
+ }else{
102390
+ /* A trigger */
102391
+ TriggerStep *pStep;
102392
+ rc = renameResolveTrigger(&sParse, (bTemp ? 0 : zDb));
102393
+ if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
102394
+
102395
+ for(pStep=sParse.pNewTrigger->step_list; pStep; pStep=pStep->pNext){
102396
+ if( pStep->zTarget ){
102397
+ Table *pTarget = sqlite3LocateTable(&sParse, 0, pStep->zTarget, zDb);
102398
+ if( pTarget==pTab ){
102399
+ if( pStep->pUpsert ){
102400
+ ExprList *pUpsertSet = pStep->pUpsert->pUpsertSet;
102401
+ renameColumnElistNames(&sParse, &sCtx, pUpsertSet, zOld);
102402
+ }
102403
+ renameColumnIdlistNames(&sParse, &sCtx, pStep->pIdList, zOld);
102404
+ renameColumnElistNames(&sParse, &sCtx, pStep->pExprList, zOld);
102405
+ }
102406
+ }
102407
+ }
102408
+
102409
+
102410
+ /* Find tokens to edit in UPDATE OF clause */
102411
+ if( sParse.pTriggerTab==pTab ){
102412
+ renameColumnIdlistNames(&sParse, &sCtx,sParse.pNewTrigger->pColumns,zOld);
102413
+ }
102414
+
102415
+ /* Find tokens to edit in various expressions and selects */
102416
+ renameWalkTrigger(&sWalker, sParse.pNewTrigger);
102417
+ }
102418
+
102419
+ assert( rc==SQLITE_OK );
102420
+ rc = renameEditSql(context, &sCtx, zSql, zNew, bQuote);
102421
+
102422
+renameColumnFunc_done:
102423
+ if( rc!=SQLITE_OK ){
102424
+ if( sParse.zErrMsg ){
102425
+ renameColumnParseError(context, 0, argv[1], argv[2], &sParse);
102426
+ }else{
102427
+ sqlite3_result_error_code(context, rc);
102428
+ }
102429
+ }
102430
+
102431
+ renameParseCleanup(&sParse);
102432
+ renameTokenFree(db, sCtx.pList);
102433
+#ifndef SQLITE_OMIT_AUTHORIZATION
102434
+ db->xAuth = xAuth;
102435
+#endif
102436
+ sqlite3BtreeLeaveAll(db);
102437
+}
102438
+
102439
+/*
102440
+** Walker expression callback used by "RENAME TABLE".
102441
+*/
102442
+static int renameTableExprCb(Walker *pWalker, Expr *pExpr){
102443
+ RenameCtx *p = pWalker->u.pRename;
102444
+ if( pExpr->op==TK_COLUMN && p->pTab==pExpr->pTab ){
102445
+ renameTokenFind(pWalker->pParse, p, (void*)&pExpr->pTab);
102446
+ }
102447
+ return WRC_Continue;
102448
+}
102449
+
102450
+/*
102451
+** Walker select callback used by "RENAME TABLE".
102452
+*/
102453
+static int renameTableSelectCb(Walker *pWalker, Select *pSelect){
102454
+ int i;
102455
+ RenameCtx *p = pWalker->u.pRename;
102456
+ SrcList *pSrc = pSelect->pSrc;
102457
+ for(i=0; i<pSrc->nSrc; i++){
102458
+ struct SrcList_item *pItem = &pSrc->a[i];
102459
+ if( pItem->pTab==p->pTab ){
102460
+ renameTokenFind(pWalker->pParse, p, pItem->zName);
102461
+ }
102462
+ }
102463
+
102464
+ return WRC_Continue;
102465
+}
102466
+
102467
+
102468
+/*
102469
+** This C function implements an SQL user function that is used by SQL code
102470
+** generated by the ALTER TABLE ... RENAME command to modify the definition
102471
+** of any foreign key constraints that use the table being renamed as the
102472
+** parent table. It is passed three arguments:
102473
+**
102474
+** 0: The database containing the table being renamed.
102475
+** 1. type: Type of object ("table", "view" etc.)
102476
+** 2. object: Name of object
102477
+** 3: The complete text of the schema statement being modified,
102478
+** 4: The old name of the table being renamed, and
102479
+** 5: The new name of the table being renamed.
102480
+** 6: True if the schema statement comes from the temp db.
102481
+**
102482
+** It returns the new schema statement. For example:
102483
+**
102484
+** sqlite_rename_table('main', 'CREATE TABLE t1(a REFERENCES t2)','t2','t3',0)
102485
+** -> 'CREATE TABLE t1(a REFERENCES t3)'
102486
+*/
102487
+static void renameTableFunc(
102488
+ sqlite3_context *context,
102489
+ int NotUsed,
102490
+ sqlite3_value **argv
102491
+){
102492
+ sqlite3 *db = sqlite3_context_db_handle(context);
102493
+ const char *zDb = (const char*)sqlite3_value_text(argv[0]);
102494
+ const char *zInput = (const char*)sqlite3_value_text(argv[3]);
102495
+ const char *zOld = (const char*)sqlite3_value_text(argv[4]);
102496
+ const char *zNew = (const char*)sqlite3_value_text(argv[5]);
102497
+ int bTemp = sqlite3_value_int(argv[6]);
102498
+ UNUSED_PARAMETER(NotUsed);
102499
+
102500
+ if( zInput && zOld && zNew ){
102501
+ Parse sParse;
102502
+ int rc;
102503
+ int bQuote = 1;
102504
+ RenameCtx sCtx;
102505
+ Walker sWalker;
102506
+
102507
+#ifndef SQLITE_OMIT_AUTHORIZATION
102508
+ sqlite3_xauth xAuth = db->xAuth;
102509
+ db->xAuth = 0;
102510
+#endif
102511
+
102512
+ sqlite3BtreeEnterAll(db);
102513
+
102514
+ memset(&sCtx, 0, sizeof(RenameCtx));
102515
+ sCtx.pTab = sqlite3FindTable(db, zOld, zDb);
102516
+ memset(&sWalker, 0, sizeof(Walker));
102517
+ sWalker.pParse = &sParse;
102518
+ sWalker.xExprCallback = renameTableExprCb;
102519
+ sWalker.xSelectCallback = renameTableSelectCb;
102520
+ sWalker.u.pRename = &sCtx;
102521
+
102522
+ rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp);
102523
+
102524
+ if( rc==SQLITE_OK ){
102525
+ if( sParse.pNewTable ){
102526
+ Table *pTab = sParse.pNewTable;
102527
+
102528
+ if( pTab->pSelect ){
102529
+ NameContext sNC;
102530
+ memset(&sNC, 0, sizeof(sNC));
102531
+ sNC.pParse = &sParse;
102532
+
102533
+ sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC);
102534
+ if( sParse.nErr ) rc = sParse.rc;
102535
+ sqlite3WalkSelect(&sWalker, pTab->pSelect);
102536
+ }else{
102537
+ /* Modify any FK definitions to point to the new table. */
102538
+#ifndef SQLITE_OMIT_FOREIGN_KEY
102539
+ FKey *pFKey;
102540
+ for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
102541
+ if( sqlite3_stricmp(pFKey->zTo, zOld)==0 ){
102542
+ renameTokenFind(&sParse, &sCtx, (void*)pFKey->zTo);
102543
+ }
102544
+ }
102545
+#endif
102546
+
102547
+ /* If this is the table being altered, fix any table refs in CHECK
102548
+ ** expressions. Also update the name that appears right after the
102549
+ ** "CREATE [VIRTUAL] TABLE" bit. */
102550
+ if( sqlite3_stricmp(zOld, pTab->zName)==0 ){
102551
+ sCtx.pTab = pTab;
102552
+ sqlite3WalkExprList(&sWalker, pTab->pCheck);
102553
+ renameTokenFind(&sParse, &sCtx, pTab->zName);
102554
+ }
102555
+ }
102556
+ }
102557
+
102558
+ else if( sParse.pNewIndex ){
102559
+ renameTokenFind(&sParse, &sCtx, sParse.pNewIndex->zName);
102560
+ sqlite3WalkExpr(&sWalker, sParse.pNewIndex->pPartIdxWhere);
102561
+ }
102562
+
102563
+#ifndef SQLITE_OMIT_TRIGGER
102564
+ else{
102565
+ Trigger *pTrigger = sParse.pNewTrigger;
102566
+ TriggerStep *pStep;
102567
+ if( 0==sqlite3_stricmp(sParse.pNewTrigger->table, zOld)
102568
+ && sCtx.pTab->pSchema==pTrigger->pTabSchema
102569
+ ){
102570
+ renameTokenFind(&sParse, &sCtx, sParse.pNewTrigger->table);
102571
+ }
102572
+
102573
+ rc = renameResolveTrigger(&sParse, bTemp ? 0 : zDb);
102574
+ if( rc==SQLITE_OK ){
102575
+ renameWalkTrigger(&sWalker, pTrigger);
102576
+ for(pStep=pTrigger->step_list; pStep; pStep=pStep->pNext){
102577
+ if( pStep->zTarget && 0==sqlite3_stricmp(pStep->zTarget, zOld) ){
102578
+ renameTokenFind(&sParse, &sCtx, pStep->zTarget);
102579
+ }
102580
+ }
102581
+ }
102582
+ }
102583
+#endif
102584
+ }
102585
+
102586
+ if( rc==SQLITE_OK ){
102587
+ rc = renameEditSql(context, &sCtx, zInput, zNew, bQuote);
102588
+ }
102589
+ if( rc!=SQLITE_OK ){
102590
+ if( sParse.zErrMsg ){
102591
+ renameColumnParseError(context, 0, argv[1], argv[2], &sParse);
102592
+ }else{
102593
+ sqlite3_result_error_code(context, rc);
102594
+ }
102595
+ }
102596
+
102597
+ renameParseCleanup(&sParse);
102598
+ renameTokenFree(db, sCtx.pList);
102599
+ sqlite3BtreeLeaveAll(db);
102600
+#ifndef SQLITE_OMIT_AUTHORIZATION
102601
+ db->xAuth = xAuth;
102602
+#endif
102603
+ }
102604
+
102605
+ return;
102606
+}
102607
+
102608
+/*
102609
+** An SQL user function that checks that there are no parse or symbol
102610
+** resolution problems in a CREATE TRIGGER|TABLE|VIEW|INDEX statement.
102611
+** After an ALTER TABLE .. RENAME operation is performed and the schema
102612
+** reloaded, this function is called on each SQL statement in the schema
102613
+** to ensure that it is still usable.
102614
+**
102615
+** 0: Database name ("main", "temp" etc.).
102616
+** 1: SQL statement.
102617
+** 2: Object type ("view", "table", "trigger" or "index").
102618
+** 3: Object name.
102619
+** 4: True if object is from temp schema.
102620
+**
102621
+** Unless it finds an error, this function normally returns NULL. However, it
102622
+** returns integer value 1 if:
102623
+**
102624
+** * the SQL argument creates a trigger, and
102625
+** * the table that the trigger is attached to is in database zDb.
102626
+*/
102627
+static void renameTableTest(
102628
+ sqlite3_context *context,
102629
+ int NotUsed,
102630
+ sqlite3_value **argv
102631
+){
102632
+ sqlite3 *db = sqlite3_context_db_handle(context);
102633
+ char const *zDb = (const char*)sqlite3_value_text(argv[0]);
102634
+ char const *zInput = (const char*)sqlite3_value_text(argv[1]);
102635
+ int bTemp = sqlite3_value_int(argv[4]);
102636
+
102637
+#ifndef SQLITE_OMIT_AUTHORIZATION
102638
+ sqlite3_xauth xAuth = db->xAuth;
102639
+ db->xAuth = 0;
102640
+#endif
102641
+
102642
+ UNUSED_PARAMETER(NotUsed);
102643
+ if( zDb && zInput ){
102644
+ int rc;
102645
+ Parse sParse;
102646
+ rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp);
102647
+ if( rc==SQLITE_OK ){
102648
+ if( sParse.pNewTable && sParse.pNewTable->pSelect ){
102649
+ NameContext sNC;
102650
+ memset(&sNC, 0, sizeof(sNC));
102651
+ sNC.pParse = &sParse;
102652
+ sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, &sNC);
102653
+ if( sParse.nErr ) rc = sParse.rc;
102654
+ }
102655
+
102656
+ else if( sParse.pNewTrigger ){
102657
+ rc = renameResolveTrigger(&sParse, bTemp ? 0 : zDb);
102658
+ if( rc==SQLITE_OK ){
102659
+ int i1 = sqlite3SchemaToIndex(db, sParse.pNewTrigger->pTabSchema);
102660
+ int i2 = sqlite3FindDbName(db, zDb);
102661
+ if( i1==i2 ) sqlite3_result_int(context, 1);
102662
+ }
102663
+ }
102664
+ }
102665
+
102666
+ if( rc!=SQLITE_OK ){
102667
+ renameColumnParseError(context, 1, argv[2], argv[3], &sParse);
102668
+ }
102669
+ renameParseCleanup(&sParse);
102670
+ }
102671
+
102672
+#ifndef SQLITE_OMIT_AUTHORIZATION
102673
+ db->xAuth = xAuth;
102674
+#endif
102675
+}
102676
+
102677
+/*
102678
+** Register built-in functions used to help implement ALTER TABLE
102679
+*/
102680
+SQLITE_PRIVATE void sqlite3AlterFunctions(void){
102681
+ static FuncDef aAlterTableFuncs[] = {
102682
+ FUNCTION(sqlite_rename_column, 9, 0, 0, renameColumnFunc),
102683
+ FUNCTION(sqlite_rename_table, 7, 0, 0, renameTableFunc),
102684
+ FUNCTION(sqlite_rename_test, 5, 0, 0, renameTableTest),
102685
+ };
102686
+ sqlite3InsertBuiltinFuncs(aAlterTableFuncs, ArraySize(aAlterTableFuncs));
102687
+}
101846102688
#endif /* SQLITE_ALTER_TABLE */
101847102689
101848102690
/************** End of alter.c ***********************************************/
101849102691
/************** Begin file analyze.c *****************************************/
101850102692
/*
@@ -104622,11 +105464,11 @@
104622105464
int rc;
104623105465
104624105466
/* Don't do any authorization checks if the database is initialising
104625105467
** or if the parser is being invoked from within sqlite3_declare_vtab.
104626105468
*/
104627
- if( db->init.busy || IN_DECLARE_VTAB ){
105469
+ if( db->init.busy || IN_SPECIAL_PARSE ){
104628105470
return SQLITE_OK;
104629105471
}
104630105472
104631105473
if( db->xAuth==0 ){
104632105474
return SQLITE_OK;
@@ -105128,11 +105970,11 @@
105128105970
}
105129105971
105130105972
/*
105131105973
** Reclaim the memory used by an index
105132105974
*/
105133
-static void freeIndex(sqlite3 *db, Index *p){
105975
+SQLITE_PRIVATE void sqlite3FreeIndex(sqlite3 *db, Index *p){
105134105976
#ifndef SQLITE_OMIT_ANALYZE
105135105977
sqlite3DeleteIndexSamples(db, p);
105136105978
#endif
105137105979
sqlite3ExprDelete(db, p->pPartIdxWhere);
105138105980
sqlite3ExprListDelete(db, p->aColExpr);
@@ -105168,11 +106010,11 @@
105168106010
while( ALWAYS(p) && p->pNext!=pIndex ){ p = p->pNext; }
105169106011
if( ALWAYS(p && p->pNext==pIndex) ){
105170106012
p->pNext = pIndex->pNext;
105171106013
}
105172106014
}
105173
- freeIndex(db, pIndex);
106015
+ sqlite3FreeIndex(db, pIndex);
105174106016
}
105175106017
db->mDbFlags |= DBFLAG_SchemaChange;
105176106018
}
105177106019
105178106020
/*
@@ -105314,11 +106156,11 @@
105314106156
&pIndex->pSchema->idxHash, zName, 0
105315106157
);
105316106158
assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
105317106159
assert( pOld==pIndex || pOld==0 );
105318106160
}
105319
- freeIndex(db, pIndex);
106161
+ sqlite3FreeIndex(db, pIndex);
105320106162
}
105321106163
105322106164
/* Delete any foreign keys attached to this table. */
105323106165
sqlite3FkDelete(db, pTable);
105324106166
@@ -105472,11 +106314,11 @@
105472106314
if( iDb<0 ){
105473106315
sqlite3ErrorMsg(pParse, "unknown database %T", pName1);
105474106316
return -1;
105475106317
}
105476106318
}else{
105477
- assert( db->init.iDb==0 || db->init.busy
106319
+ assert( db->init.iDb==0 || db->init.busy || IN_RENAME_OBJECT
105478106320
|| (db->mDbFlags & DBFLAG_Vacuum)!=0);
105479106321
iDb = db->init.iDb;
105480106322
*pUnqual = pName1;
105481106323
}
105482106324
return iDb;
@@ -105567,10 +106409,13 @@
105567106409
sqlite3ErrorMsg(pParse, "temporary table name must be unqualified");
105568106410
return;
105569106411
}
105570106412
if( !OMIT_TEMPDB && isTemp ) iDb = 1;
105571106413
zName = sqlite3NameFromToken(db, pName);
106414
+ if( IN_RENAME_OBJECT ){
106415
+ sqlite3RenameTokenMap(pParse, (void*)zName, pName);
106416
+ }
105572106417
}
105573106418
pParse->sNameToken = *pName;
105574106419
if( zName==0 ) return;
105575106420
if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
105576106421
goto begin_table_error;
@@ -105602,11 +106447,11 @@
105602106447
** it does. The exception is if the statement being parsed was passed
105603106448
** to an sqlite3_declare_vtab() call. In that case only the column names
105604106449
** and types will be used, so there is no need to test for namespace
105605106450
** collisions.
105606106451
*/
105607
- if( !IN_DECLARE_VTAB ){
106452
+ if( !IN_SPECIAL_PARSE ){
105608106453
char *zDb = db->aDb[iDb].zDbSName;
105609106454
if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
105610106455
goto begin_table_error;
105611106456
}
105612106457
pTable = sqlite3FindTable(db, zName, zDb);
@@ -105761,10 +106606,11 @@
105761106606
sqlite3ErrorMsg(pParse, "too many columns on %s", p->zName);
105762106607
return;
105763106608
}
105764106609
z = sqlite3DbMallocRaw(db, pName->n + pType->n + 2);
105765106610
if( z==0 ) return;
106611
+ if( IN_RENAME_OBJECT ) sqlite3RenameTokenMap(pParse, (void*)z, pName);
105766106612
memcpy(z, pName->z, pName->n);
105767106613
z[pName->n] = 0;
105768106614
sqlite3Dequote(z);
105769106615
for(i=0; i<p->nCol; i++){
105770106616
if( sqlite3_stricmp(z, p->aCol[i].zName)==0 ){
@@ -105967,10 +106813,13 @@
105967106813
x.flags = EP_Skip;
105968106814
pCol->pDflt = sqlite3ExprDup(db, &x, EXPRDUP_REDUCE);
105969106815
sqlite3DbFree(db, x.u.zToken);
105970106816
}
105971106817
}
106818
+ if( IN_RENAME_OBJECT ){
106819
+ sqlite3RenameExprUnmap(pParse, pExpr);
106820
+ }
105972106821
sqlite3ExprDelete(db, pExpr);
105973106822
}
105974106823
105975106824
/*
105976106825
** Backwards Compatibility Hack:
@@ -106058,10 +106907,13 @@
106058106907
if( nTerm==1
106059106908
&& pCol
106060106909
&& sqlite3StrICmp(sqlite3ColumnType(pCol,""), "INTEGER")==0
106061106910
&& sortOrder!=SQLITE_SO_DESC
106062106911
){
106912
+ if( IN_RENAME_OBJECT && pList ){
106913
+ sqlite3RenameTokenRemap(pParse, &pTab->iPKey, pList->a[0].pExpr);
106914
+ }
106063106915
pTab->iPKey = iCol;
106064106916
pTab->keyConf = (u8)onError;
106065106917
assert( autoInc==0 || autoInc==1 );
106066106918
pTab->tabFlags |= autoInc*TF_Autoincrement;
106067106919
if( pList ) pParse->iPkSortOrder = pList->a[0].sortOrder;
@@ -106860,11 +107712,16 @@
106860107712
/* Make a copy of the entire SELECT statement that defines the view.
106861107713
** This will force all the Expr.token.z values to be dynamically
106862107714
** allocated rather than point to the input string - which means that
106863107715
** they will persist after the current sqlite3_exec() call returns.
106864107716
*/
106865
- p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
107717
+ if( IN_RENAME_OBJECT ){
107718
+ p->pSelect = pSelect;
107719
+ pSelect = 0;
107720
+ }else{
107721
+ p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
107722
+ }
106866107723
p->pCheck = sqlite3ExprListDup(db, pCNames, EXPRDUP_REDUCE);
106867107724
if( db->mallocFailed ) goto create_view_fail;
106868107725
106869107726
/* Locate the end of the CREATE VIEW statement. Make sEnd point to
106870107727
** the end.
@@ -107428,10 +108285,13 @@
107428108285
}
107429108286
pFKey->pFrom = p;
107430108287
pFKey->pNextFrom = p->pFKey;
107431108288
z = (char*)&pFKey->aCol[nCol];
107432108289
pFKey->zTo = z;
108290
+ if( IN_RENAME_OBJECT ){
108291
+ sqlite3RenameTokenMap(pParse, (void*)z, pTo);
108292
+ }
107433108293
memcpy(z, pTo->z, pTo->n);
107434108294
z[pTo->n] = 0;
107435108295
sqlite3Dequote(z);
107436108296
z += pTo->n+1;
107437108297
pFKey->nCol = nCol;
@@ -107450,16 +108310,22 @@
107450108310
sqlite3ErrorMsg(pParse,
107451108311
"unknown column \"%s\" in foreign key definition",
107452108312
pFromCol->a[i].zName);
107453108313
goto fk_end;
107454108314
}
108315
+ if( IN_RENAME_OBJECT ){
108316
+ sqlite3RenameTokenRemap(pParse, &pFKey->aCol[i], pFromCol->a[i].zName);
108317
+ }
107455108318
}
107456108319
}
107457108320
if( pToCol ){
107458108321
for(i=0; i<nCol; i++){
107459108322
int n = sqlite3Strlen30(pToCol->a[i].zName);
107460108323
pFKey->aCol[i].zCol = z;
108324
+ if( IN_RENAME_OBJECT ){
108325
+ sqlite3RenameTokenRemap(pParse, z, pToCol->a[i].zName);
108326
+ }
107461108327
memcpy(z, pToCol->a[i].zName, n);
107462108328
z[n] = 0;
107463108329
z += n+1;
107464108330
}
107465108331
}
@@ -107788,25 +108654,27 @@
107788108654
if( zName==0 ) goto exit_create_index;
107789108655
assert( pName->z!=0 );
107790108656
if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
107791108657
goto exit_create_index;
107792108658
}
107793
- if( !db->init.busy ){
107794
- if( sqlite3FindTable(db, zName, 0)!=0 ){
107795
- sqlite3ErrorMsg(pParse, "there is already a table named %s", zName);
108659
+ if( !IN_RENAME_OBJECT ){
108660
+ if( !db->init.busy ){
108661
+ if( sqlite3FindTable(db, zName, 0)!=0 ){
108662
+ sqlite3ErrorMsg(pParse, "there is already a table named %s", zName);
108663
+ goto exit_create_index;
108664
+ }
108665
+ }
108666
+ if( sqlite3FindIndex(db, zName, pDb->zDbSName)!=0 ){
108667
+ if( !ifNotExist ){
108668
+ sqlite3ErrorMsg(pParse, "index %s already exists", zName);
108669
+ }else{
108670
+ assert( !db->init.busy );
108671
+ sqlite3CodeVerifySchema(pParse, iDb);
108672
+ }
107796108673
goto exit_create_index;
107797108674
}
107798108675
}
107799
- if( sqlite3FindIndex(db, zName, pDb->zDbSName)!=0 ){
107800
- if( !ifNotExist ){
107801
- sqlite3ErrorMsg(pParse, "index %s already exists", zName);
107802
- }else{
107803
- assert( !db->init.busy );
107804
- sqlite3CodeVerifySchema(pParse, iDb);
107805
- }
107806
- goto exit_create_index;
107807
- }
107808108676
}else{
107809108677
int n;
107810108678
Index *pLoop;
107811108679
for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){}
107812108680
zName = sqlite3MPrintf(db, "sqlite_autoindex_%s_%d", pTab->zName, n);
@@ -107817,17 +108685,17 @@
107817108685
/* Automatic index names generated from within sqlite3_declare_vtab()
107818108686
** must have names that are distinct from normal automatic index names.
107819108687
** The following statement converts "sqlite3_autoindex..." into
107820108688
** "sqlite3_butoindex..." in order to make the names distinct.
107821108689
** The "vtab_err.test" test demonstrates the need of this statement. */
107822
- if( IN_DECLARE_VTAB ) zName[7]++;
108690
+ if( IN_SPECIAL_PARSE ) zName[7]++;
107823108691
}
107824108692
107825108693
/* Check for authorization to create an index.
107826108694
*/
107827108695
#ifndef SQLITE_OMIT_AUTHORIZATION
107828
- {
108696
+ if( !IN_RENAME_OBJECT ){
107829108697
const char *zDb = pDb->zDbSName;
107830108698
if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iDb), 0, zDb) ){
107831108699
goto exit_create_index;
107832108700
}
107833108701
i = SQLITE_CREATE_INDEX;
@@ -107910,11 +108778,16 @@
107910108778
**
107911108779
** TODO: Issue a warning if two or more columns of the index are identical.
107912108780
** TODO: Issue a warning if the table primary key is used as part of the
107913108781
** index key.
107914108782
*/
107915
- for(i=0, pListItem=pList->a; i<pList->nExpr; i++, pListItem++){
108783
+ pListItem = pList->a;
108784
+ if( IN_RENAME_OBJECT ){
108785
+ pIndex->aColExpr = pList;
108786
+ pList = 0;
108787
+ }
108788
+ for(i=0; i<pIndex->nKeyCol; i++, pListItem++){
107916108789
Expr *pCExpr; /* The i-th index expression */
107917108790
int requestedSortOrder; /* ASC or DESC on the i-th expression */
107918108791
const char *zColl; /* Collation sequence name */
107919108792
107920108793
sqlite3StringToId(pListItem->pExpr);
@@ -107926,16 +108799,12 @@
107926108799
sqlite3ErrorMsg(pParse, "expressions prohibited in PRIMARY KEY and "
107927108800
"UNIQUE constraints");
107928108801
goto exit_create_index;
107929108802
}
107930108803
if( pIndex->aColExpr==0 ){
107931
- ExprList *pCopy = sqlite3ExprListDup(db, pList, 0);
107932
- pIndex->aColExpr = pCopy;
107933
- if( !db->mallocFailed ){
107934
- assert( pCopy!=0 );
107935
- pListItem = &pCopy->a[i];
107936
- }
108804
+ pIndex->aColExpr = pList;
108805
+ pList = 0;
107937108806
}
107938108807
j = XN_EXPR;
107939108808
pIndex->aiColumn[i] = XN_EXPR;
107940108809
pIndex->uniqNotNull = 0;
107941108810
}else{
@@ -108070,102 +108939,105 @@
108070108939
goto exit_create_index;
108071108940
}
108072108941
}
108073108942
}
108074108943
108075
- /* Link the new Index structure to its table and to the other
108076
- ** in-memory database structures.
108077
- */
108078
- assert( pParse->nErr==0 );
108079
- if( db->init.busy ){
108080
- Index *p;
108081
- assert( !IN_DECLARE_VTAB );
108082
- assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
108083
- p = sqlite3HashInsert(&pIndex->pSchema->idxHash,
108084
- pIndex->zName, pIndex);
108085
- if( p ){
108086
- assert( p==pIndex ); /* Malloc must have failed */
108087
- sqlite3OomFault(db);
108088
- goto exit_create_index;
108089
- }
108090
- db->mDbFlags |= DBFLAG_SchemaChange;
108091
- if( pTblName!=0 ){
108092
- pIndex->tnum = db->init.newTnum;
108093
- }
108094
- }
108095
-
108096
- /* If this is the initial CREATE INDEX statement (or CREATE TABLE if the
108097
- ** index is an implied index for a UNIQUE or PRIMARY KEY constraint) then
108098
- ** emit code to allocate the index rootpage on disk and make an entry for
108099
- ** the index in the sqlite_master table and populate the index with
108100
- ** content. But, do not do this if we are simply reading the sqlite_master
108101
- ** table to parse the schema, or if this index is the PRIMARY KEY index
108102
- ** of a WITHOUT ROWID table.
108103
- **
108104
- ** If pTblName==0 it means this index is generated as an implied PRIMARY KEY
108105
- ** or UNIQUE index in a CREATE TABLE statement. Since the table
108106
- ** has just been created, it contains no data and the index initialization
108107
- ** step can be skipped.
108108
- */
108109
- else if( HasRowid(pTab) || pTblName!=0 ){
108110
- Vdbe *v;
108111
- char *zStmt;
108112
- int iMem = ++pParse->nMem;
108113
-
108114
- v = sqlite3GetVdbe(pParse);
108115
- if( v==0 ) goto exit_create_index;
108116
-
108117
- sqlite3BeginWriteOperation(pParse, 1, iDb);
108118
-
108119
- /* Create the rootpage for the index using CreateIndex. But before
108120
- ** doing so, code a Noop instruction and store its address in
108121
- ** Index.tnum. This is required in case this index is actually a
108122
- ** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In
108123
- ** that case the convertToWithoutRowidTable() routine will replace
108124
- ** the Noop with a Goto to jump over the VDBE code generated below. */
108125
- pIndex->tnum = sqlite3VdbeAddOp0(v, OP_Noop);
108126
- sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, iMem, BTREE_BLOBKEY);
108127
-
108128
- /* Gather the complete text of the CREATE INDEX statement into
108129
- ** the zStmt variable
108130
- */
108131
- if( pStart ){
108132
- int n = (int)(pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;
108133
- if( pName->z[n-1]==';' ) n--;
108134
- /* A named index with an explicit CREATE INDEX statement */
108135
- zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
108136
- onError==OE_None ? "" : " UNIQUE", n, pName->z);
108137
- }else{
108138
- /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
108139
- /* zStmt = sqlite3MPrintf(""); */
108140
- zStmt = 0;
108141
- }
108142
-
108143
- /* Add an entry in sqlite_master for this index
108144
- */
108145
- sqlite3NestedParse(pParse,
108146
- "INSERT INTO %Q.%s VALUES('index',%Q,%Q,#%d,%Q);",
108147
- db->aDb[iDb].zDbSName, MASTER_NAME,
108148
- pIndex->zName,
108149
- pTab->zName,
108150
- iMem,
108151
- zStmt
108152
- );
108153
- sqlite3DbFree(db, zStmt);
108154
-
108155
- /* Fill the index with data and reparse the schema. Code an OP_Expire
108156
- ** to invalidate all pre-compiled statements.
108157
- */
108158
- if( pTblName ){
108159
- sqlite3RefillIndex(pParse, pIndex, iMem);
108160
- sqlite3ChangeCookie(pParse, iDb);
108161
- sqlite3VdbeAddParseSchemaOp(v, iDb,
108162
- sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName));
108163
- sqlite3VdbeAddOp2(v, OP_Expire, 0, 1);
108164
- }
108165
-
108166
- sqlite3VdbeJumpHere(v, pIndex->tnum);
108944
+ if( !IN_RENAME_OBJECT ){
108945
+
108946
+ /* Link the new Index structure to its table and to the other
108947
+ ** in-memory database structures.
108948
+ */
108949
+ assert( pParse->nErr==0 );
108950
+ if( db->init.busy ){
108951
+ Index *p;
108952
+ assert( !IN_SPECIAL_PARSE );
108953
+ assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
108954
+ p = sqlite3HashInsert(&pIndex->pSchema->idxHash,
108955
+ pIndex->zName, pIndex);
108956
+ if( p ){
108957
+ assert( p==pIndex ); /* Malloc must have failed */
108958
+ sqlite3OomFault(db);
108959
+ goto exit_create_index;
108960
+ }
108961
+ db->mDbFlags |= DBFLAG_SchemaChange;
108962
+ if( pTblName!=0 ){
108963
+ pIndex->tnum = db->init.newTnum;
108964
+ }
108965
+ }
108966
+
108967
+ /* If this is the initial CREATE INDEX statement (or CREATE TABLE if the
108968
+ ** index is an implied index for a UNIQUE or PRIMARY KEY constraint) then
108969
+ ** emit code to allocate the index rootpage on disk and make an entry for
108970
+ ** the index in the sqlite_master table and populate the index with
108971
+ ** content. But, do not do this if we are simply reading the sqlite_master
108972
+ ** table to parse the schema, or if this index is the PRIMARY KEY index
108973
+ ** of a WITHOUT ROWID table.
108974
+ **
108975
+ ** If pTblName==0 it means this index is generated as an implied PRIMARY KEY
108976
+ ** or UNIQUE index in a CREATE TABLE statement. Since the table
108977
+ ** has just been created, it contains no data and the index initialization
108978
+ ** step can be skipped.
108979
+ */
108980
+ else if( HasRowid(pTab) || pTblName!=0 ){
108981
+ Vdbe *v;
108982
+ char *zStmt;
108983
+ int iMem = ++pParse->nMem;
108984
+
108985
+ v = sqlite3GetVdbe(pParse);
108986
+ if( v==0 ) goto exit_create_index;
108987
+
108988
+ sqlite3BeginWriteOperation(pParse, 1, iDb);
108989
+
108990
+ /* Create the rootpage for the index using CreateIndex. But before
108991
+ ** doing so, code a Noop instruction and store its address in
108992
+ ** Index.tnum. This is required in case this index is actually a
108993
+ ** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In
108994
+ ** that case the convertToWithoutRowidTable() routine will replace
108995
+ ** the Noop with a Goto to jump over the VDBE code generated below. */
108996
+ pIndex->tnum = sqlite3VdbeAddOp0(v, OP_Noop);
108997
+ sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, iMem, BTREE_BLOBKEY);
108998
+
108999
+ /* Gather the complete text of the CREATE INDEX statement into
109000
+ ** the zStmt variable
109001
+ */
109002
+ if( pStart ){
109003
+ int n = (int)(pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;
109004
+ if( pName->z[n-1]==';' ) n--;
109005
+ /* A named index with an explicit CREATE INDEX statement */
109006
+ zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
109007
+ onError==OE_None ? "" : " UNIQUE", n, pName->z);
109008
+ }else{
109009
+ /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
109010
+ /* zStmt = sqlite3MPrintf(""); */
109011
+ zStmt = 0;
109012
+ }
109013
+
109014
+ /* Add an entry in sqlite_master for this index
109015
+ */
109016
+ sqlite3NestedParse(pParse,
109017
+ "INSERT INTO %Q.%s VALUES('index',%Q,%Q,#%d,%Q);",
109018
+ db->aDb[iDb].zDbSName, MASTER_NAME,
109019
+ pIndex->zName,
109020
+ pTab->zName,
109021
+ iMem,
109022
+ zStmt
109023
+ );
109024
+ sqlite3DbFree(db, zStmt);
109025
+
109026
+ /* Fill the index with data and reparse the schema. Code an OP_Expire
109027
+ ** to invalidate all pre-compiled statements.
109028
+ */
109029
+ if( pTblName ){
109030
+ sqlite3RefillIndex(pParse, pIndex, iMem);
109031
+ sqlite3ChangeCookie(pParse, iDb);
109032
+ sqlite3VdbeAddParseSchemaOp(v, iDb,
109033
+ sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName));
109034
+ sqlite3VdbeAddOp2(v, OP_Expire, 0, 1);
109035
+ }
109036
+
109037
+ sqlite3VdbeJumpHere(v, pIndex->tnum);
109038
+ }
108167109039
}
108168109040
108169109041
/* When adding an index to the list of indices for a table, make
108170109042
** sure all indices labeled OE_Replace come after all those labeled
108171109043
** OE_Ignore. This is necessary for the correct constraint check
@@ -108185,14 +109057,19 @@
108185109057
pIndex->pNext = pOther->pNext;
108186109058
pOther->pNext = pIndex;
108187109059
}
108188109060
pIndex = 0;
108189109061
}
109062
+ else if( IN_RENAME_OBJECT ){
109063
+ assert( pParse->pNewIndex==0 );
109064
+ pParse->pNewIndex = pIndex;
109065
+ pIndex = 0;
109066
+ }
108190109067
108191109068
/* Clean up before exiting */
108192109069
exit_create_index:
108193
- if( pIndex ) freeIndex(db, pIndex);
109070
+ if( pIndex ) sqlite3FreeIndex(db, pIndex);
108194109071
sqlite3ExprDelete(db, pPIWhere);
108195109072
sqlite3ExprListDelete(db, pList);
108196109073
sqlite3SrcListDelete(db, pTblName);
108197109074
sqlite3DbFree(db, zName);
108198109075
}
@@ -108357,11 +109234,12 @@
108357109234
** Append a new element to the given IdList. Create a new IdList if
108358109235
** need be.
108359109236
**
108360109237
** A new IdList is returned, or NULL if malloc() fails.
108361109238
*/
108362
-SQLITE_PRIVATE IdList *sqlite3IdListAppend(sqlite3 *db, IdList *pList, Token *pToken){
109239
+SQLITE_PRIVATE IdList *sqlite3IdListAppend(Parse *pParse, IdList *pList, Token *pToken){
109240
+ sqlite3 *db = pParse->db;
108363109241
int i;
108364109242
if( pList==0 ){
108365109243
pList = sqlite3DbMallocZero(db, sizeof(IdList) );
108366109244
if( pList==0 ) return 0;
108367109245
}
@@ -108375,10 +109253,13 @@
108375109253
if( i<0 ){
108376109254
sqlite3IdListDelete(db, pList);
108377109255
return 0;
108378109256
}
108379109257
pList->a[i].zName = sqlite3NameFromToken(db, pToken);
109258
+ if( IN_RENAME_OBJECT && pList->a[i].zName ){
109259
+ sqlite3RenameTokenMap(pParse, (void*)pList->a[i].zName, pToken);
109260
+ }
108380109261
return pList;
108381109262
}
108382109263
108383109264
/*
108384109265
** Delete an IdList.
@@ -108621,10 +109502,14 @@
108621109502
if( p==0 ){
108622109503
goto append_from_error;
108623109504
}
108624109505
assert( p->nSrc>0 );
108625109506
pItem = &p->a[p->nSrc-1];
109507
+ if( IN_RENAME_OBJECT && pItem->zName ){
109508
+ Token *pToken = (pDatabase && pDatabase->z) ? pDatabase : pTable;
109509
+ sqlite3RenameTokenMap(pParse, pItem->zName, pToken);
109510
+ }
108626109511
assert( pAlias!=0 );
108627109512
if( pAlias->n ){
108628109513
pItem->zAlias = sqlite3NameFromToken(db, pAlias);
108629109514
}
108630109515
pItem->pSelect = pSubquery;
@@ -121271,19 +122156,27 @@
121271122156
InitData *pData, /* Initialization context */
121272122157
const char *zObj, /* Object being parsed at the point of error */
121273122158
const char *zExtra /* Error information */
121274122159
){
121275122160
sqlite3 *db = pData->db;
121276
- if( !db->mallocFailed && (db->flags & SQLITE_WriteSchema)==0 ){
122161
+ if( db->mallocFailed ){
122162
+ pData->rc = SQLITE_NOMEM_BKPT;
122163
+ }else if( pData->pzErrMsg[0]!=0 ){
122164
+ /* A error message has already been generated. Do not overwrite it */
122165
+ }else if( pData->mInitFlags & INITFLAG_AlterTable ){
122166
+ *pData->pzErrMsg = sqlite3DbStrDup(db, zExtra);
122167
+ pData->rc = SQLITE_ERROR;
122168
+ }else if( db->flags & SQLITE_WriteSchema ){
122169
+ pData->rc = SQLITE_CORRUPT_BKPT;
122170
+ }else{
121277122171
char *z;
121278122172
if( zObj==0 ) zObj = "?";
121279122173
z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj);
121280122174
if( zExtra && zExtra[0] ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra);
121281
- sqlite3DbFree(db, *pData->pzErrMsg);
121282122175
*pData->pzErrMsg = z;
122176
+ pData->rc = SQLITE_CORRUPT_BKPT;
121283122177
}
121284
- pData->rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_CORRUPT_BKPT;
121285122178
}
121286122179
121287122180
/*
121288122181
** This is the callback routine for the code that initializes the
121289122182
** database. See sqlite3Init() below for additional information.
@@ -121331,11 +122224,11 @@
121331122224
db->init.orphanTrigger = 0;
121332122225
TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0);
121333122226
rc = db->errCode;
121334122227
assert( (rc&0xFF)==(rcp&0xFF) );
121335122228
db->init.iDb = saved_iDb;
121336
- assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 );
122229
+ /* assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 ); */
121337122230
if( SQLITE_OK!=rc ){
121338122231
if( db->init.orphanTrigger ){
121339122232
assert( iDb==1 );
121340122233
}else{
121341122234
pData->rc = rc;
@@ -121378,11 +122271,11 @@
121378122271
** database file is given by iDb. iDb==0 is used for the main
121379122272
** database. iDb==1 should never be used. iDb>=2 is used for
121380122273
** auxiliary databases. Return one of the SQLITE_ error codes to
121381122274
** indicate success or failure.
121382122275
*/
121383
-static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){
122276
+SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFlags){
121384122277
int rc;
121385122278
int i;
121386122279
#ifndef SQLITE_OMIT_DEPRECATED
121387122280
int size;
121388122281
#endif
@@ -121413,10 +122306,11 @@
121413122306
azArg[3] = 0;
121414122307
initData.db = db;
121415122308
initData.iDb = iDb;
121416122309
initData.rc = SQLITE_OK;
121417122310
initData.pzErrMsg = pzErrMsg;
122311
+ initData.mInitFlags = mFlags;
121418122312
sqlite3InitCallback(&initData, 3, (char **)azArg, 0);
121419122313
if( initData.rc ){
121420122314
rc = initData.rc;
121421122315
goto error_out;
121422122316
}
@@ -121619,18 +122513,18 @@
121619122513
assert( db->init.busy==0 );
121620122514
ENC(db) = SCHEMA_ENC(db);
121621122515
assert( db->nDb>0 );
121622122516
/* Do the main schema first */
121623122517
if( !DbHasProperty(db, 0, DB_SchemaLoaded) ){
121624
- rc = sqlite3InitOne(db, 0, pzErrMsg);
122518
+ rc = sqlite3InitOne(db, 0, pzErrMsg, 0);
121625122519
if( rc ) return rc;
121626122520
}
121627122521
/* All other schemas after the main schema. The "temp" schema must be last */
121628122522
for(i=db->nDb-1; i>0; i--){
121629122523
assert( i==1 || sqlite3BtreeHoldsMutex(db->aDb[i].pBt) );
121630122524
if( !DbHasProperty(db, i, DB_SchemaLoaded) ){
121631
- rc = sqlite3InitOne(db, i, pzErrMsg);
122525
+ rc = sqlite3InitOne(db, i, pzErrMsg, 0);
121632122526
if( rc ) return rc;
121633122527
}
121634122528
}
121635122529
if( commit_internal ){
121636122530
sqlite3CommitInternalChanges(db);
@@ -129136,18 +130030,20 @@
129136130030
zName = sqlite3NameFromToken(db, pName);
129137130031
if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
129138130032
goto trigger_cleanup;
129139130033
}
129140130034
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
129141
- if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),zName) ){
129142
- if( !noErr ){
129143
- sqlite3ErrorMsg(pParse, "trigger %T already exists", pName);
129144
- }else{
129145
- assert( !db->init.busy );
129146
- sqlite3CodeVerifySchema(pParse, iDb);
129147
- }
129148
- goto trigger_cleanup;
130035
+ if( !IN_RENAME_OBJECT ){
130036
+ if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),zName) ){
130037
+ if( !noErr ){
130038
+ sqlite3ErrorMsg(pParse, "trigger %T already exists", pName);
130039
+ }else{
130040
+ assert( !db->init.busy );
130041
+ sqlite3CodeVerifySchema(pParse, iDb);
130042
+ }
130043
+ goto trigger_cleanup;
130044
+ }
129149130045
}
129150130046
129151130047
/* Do not create a trigger on a system table */
129152130048
if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){
129153130049
sqlite3ErrorMsg(pParse, "cannot create trigger on system table");
@@ -129167,11 +130063,11 @@
129167130063
" trigger on table: %S", pTableName, 0);
129168130064
goto trigger_cleanup;
129169130065
}
129170130066
129171130067
#ifndef SQLITE_OMIT_AUTHORIZATION
129172
- {
130068
+ if( !IN_RENAME_OBJECT ){
129173130069
int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);
129174130070
int code = SQLITE_CREATE_TRIGGER;
129175130071
const char *zDb = db->aDb[iTabDb].zDbSName;
129176130072
const char *zDbTrig = isTemp ? db->aDb[1].zDbSName : zDb;
129177130073
if( iTabDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER;
@@ -129201,12 +130097,19 @@
129201130097
pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);
129202130098
pTrigger->pSchema = db->aDb[iDb].pSchema;
129203130099
pTrigger->pTabSchema = pTab->pSchema;
129204130100
pTrigger->op = (u8)op;
129205130101
pTrigger->tr_tm = tr_tm==TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER;
129206
- pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);
129207
- pTrigger->pColumns = sqlite3IdListDup(db, pColumns);
130102
+ if( IN_RENAME_OBJECT ){
130103
+ sqlite3RenameTokenRemap(pParse, pTrigger->table, pTableName->a[0].zName);
130104
+ pTrigger->pWhen = pWhen;
130105
+ pWhen = 0;
130106
+ }else{
130107
+ pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);
130108
+ }
130109
+ pTrigger->pColumns = pColumns;
130110
+ pColumns = 0;
129208130111
assert( pParse->pNewTrigger==0 );
129209130112
pParse->pNewTrigger = pTrigger;
129210130113
129211130114
trigger_cleanup:
129212130115
sqlite3DbFree(db, zName);
@@ -129250,10 +130153,18 @@
129250130153
if( sqlite3FixTriggerStep(&sFix, pTrig->step_list)
129251130154
|| sqlite3FixExpr(&sFix, pTrig->pWhen)
129252130155
){
129253130156
goto triggerfinish_cleanup;
129254130157
}
130158
+
130159
+#ifndef SQLITE_OMIT_ALTERTABLE
130160
+ if( IN_RENAME_OBJECT ){
130161
+ assert( !db->init.busy );
130162
+ pParse->pNewTrigger = pTrig;
130163
+ pTrig = 0;
130164
+ }else
130165
+#endif
129255130166
129256130167
/* if we are not initializing,
129257130168
** build the sqlite_master entry
129258130169
*/
129259130170
if( !db->init.busy ){
@@ -129292,11 +130203,11 @@
129292130203
}
129293130204
}
129294130205
129295130206
triggerfinish_cleanup:
129296130207
sqlite3DeleteTrigger(db, pTrig);
129297
- assert( !pParse->pNewTrigger );
130208
+ assert( IN_RENAME_OBJECT || !pParse->pNewTrigger );
129298130209
sqlite3DeleteTriggerStep(db, pStepList);
129299130210
}
129300130211
129301130212
/*
129302130213
** Duplicate a range of text from an SQL statement, then convert all
@@ -129339,16 +130250,17 @@
129339130250
** holds both the TriggerStep object and the TriggerStep.target.z string.
129340130251
**
129341130252
** If an OOM error occurs, NULL is returned and db->mallocFailed is set.
129342130253
*/
129343130254
static TriggerStep *triggerStepAllocate(
129344
- sqlite3 *db, /* Database connection */
130255
+ Parse *pParse, /* Parser context */
129345130256
u8 op, /* Trigger opcode */
129346130257
Token *pName, /* The target name */
129347130258
const char *zStart, /* Start of SQL text */
129348130259
const char *zEnd /* End of SQL text */
129349130260
){
130261
+ sqlite3 *db = pParse->db;
129350130262
TriggerStep *pTriggerStep;
129351130263
129352130264
pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n + 1);
129353130265
if( pTriggerStep ){
129354130266
char *z = (char*)&pTriggerStep[1];
@@ -129355,10 +130267,13 @@
129355130267
memcpy(z, pName->z, pName->n);
129356130268
sqlite3Dequote(z);
129357130269
pTriggerStep->zTarget = z;
129358130270
pTriggerStep->op = op;
129359130271
pTriggerStep->zSpan = triggerSpanDup(db, zStart, zEnd);
130272
+ if( IN_RENAME_OBJECT ){
130273
+ sqlite3RenameTokenMap(pParse, pTriggerStep->zTarget, pName);
130274
+ }
129360130275
}
129361130276
return pTriggerStep;
129362130277
}
129363130278
129364130279
/*
@@ -129367,26 +130282,32 @@
129367130282
**
129368130283
** The parser calls this routine when it sees an INSERT inside the
129369130284
** body of a trigger.
129370130285
*/
129371130286
SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(
129372
- sqlite3 *db, /* The database connection */
130287
+ Parse *pParse, /* Parser */
129373130288
Token *pTableName, /* Name of the table into which we insert */
129374130289
IdList *pColumn, /* List of columns in pTableName to insert into */
129375130290
Select *pSelect, /* A SELECT statement that supplies values */
129376130291
u8 orconf, /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */
129377130292
Upsert *pUpsert, /* ON CONFLICT clauses for upsert */
129378130293
const char *zStart, /* Start of SQL text */
129379130294
const char *zEnd /* End of SQL text */
129380130295
){
130296
+ sqlite3 *db = pParse->db;
129381130297
TriggerStep *pTriggerStep;
129382130298
129383130299
assert(pSelect != 0 || db->mallocFailed);
129384130300
129385
- pTriggerStep = triggerStepAllocate(db, TK_INSERT, pTableName, zStart, zEnd);
130301
+ pTriggerStep = triggerStepAllocate(pParse, TK_INSERT, pTableName,zStart,zEnd);
129386130302
if( pTriggerStep ){
129387
- pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
130303
+ if( IN_RENAME_OBJECT ){
130304
+ pTriggerStep->pSelect = pSelect;
130305
+ pSelect = 0;
130306
+ }else{
130307
+ pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
130308
+ }
129388130309
pTriggerStep->pIdList = pColumn;
129389130310
pTriggerStep->pUpsert = pUpsert;
129390130311
pTriggerStep->orconf = orconf;
129391130312
}else{
129392130313
testcase( pColumn );
@@ -129403,24 +130324,32 @@
129403130324
** Construct a trigger step that implements an UPDATE statement and return
129404130325
** a pointer to that trigger step. The parser calls this routine when it
129405130326
** sees an UPDATE statement inside the body of a CREATE TRIGGER.
129406130327
*/
129407130328
SQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(
129408
- sqlite3 *db, /* The database connection */
130329
+ Parse *pParse, /* Parser */
129409130330
Token *pTableName, /* Name of the table to be updated */
129410130331
ExprList *pEList, /* The SET clause: list of column and new values */
129411130332
Expr *pWhere, /* The WHERE clause */
129412130333
u8 orconf, /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */
129413130334
const char *zStart, /* Start of SQL text */
129414130335
const char *zEnd /* End of SQL text */
129415130336
){
130337
+ sqlite3 *db = pParse->db;
129416130338
TriggerStep *pTriggerStep;
129417130339
129418
- pTriggerStep = triggerStepAllocate(db, TK_UPDATE, pTableName, zStart, zEnd);
130340
+ pTriggerStep = triggerStepAllocate(pParse, TK_UPDATE, pTableName,zStart,zEnd);
129419130341
if( pTriggerStep ){
129420
- pTriggerStep->pExprList = sqlite3ExprListDup(db, pEList, EXPRDUP_REDUCE);
129421
- pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
130342
+ if( IN_RENAME_OBJECT ){
130343
+ pTriggerStep->pExprList = pEList;
130344
+ pTriggerStep->pWhere = pWhere;
130345
+ pEList = 0;
130346
+ pWhere = 0;
130347
+ }else{
130348
+ pTriggerStep->pExprList = sqlite3ExprListDup(db, pEList, EXPRDUP_REDUCE);
130349
+ pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
130350
+ }
129422130351
pTriggerStep->orconf = orconf;
129423130352
}
129424130353
sqlite3ExprListDelete(db, pEList);
129425130354
sqlite3ExprDelete(db, pWhere);
129426130355
return pTriggerStep;
@@ -129430,21 +130359,27 @@
129430130359
** Construct a trigger step that implements a DELETE statement and return
129431130360
** a pointer to that trigger step. The parser calls this routine when it
129432130361
** sees a DELETE statement inside the body of a CREATE TRIGGER.
129433130362
*/
129434130363
SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(
129435
- sqlite3 *db, /* Database connection */
130364
+ Parse *pParse, /* Parser */
129436130365
Token *pTableName, /* The table from which rows are deleted */
129437130366
Expr *pWhere, /* The WHERE clause */
129438130367
const char *zStart, /* Start of SQL text */
129439130368
const char *zEnd /* End of SQL text */
129440130369
){
130370
+ sqlite3 *db = pParse->db;
129441130371
TriggerStep *pTriggerStep;
129442130372
129443
- pTriggerStep = triggerStepAllocate(db, TK_DELETE, pTableName, zStart, zEnd);
130373
+ pTriggerStep = triggerStepAllocate(pParse, TK_DELETE, pTableName,zStart,zEnd);
129444130374
if( pTriggerStep ){
129445
- pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
130375
+ if( IN_RENAME_OBJECT ){
130376
+ pTriggerStep->pWhere = pWhere;
130377
+ pWhere = 0;
130378
+ }else{
130379
+ pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
130380
+ }
129446130381
pTriggerStep->orconf = OE_Default;
129447130382
}
129448130383
sqlite3ExprDelete(db, pWhere);
129449130384
return pTriggerStep;
129450130385
}
@@ -132438,11 +133373,11 @@
132438133373
}
132439133374
pTab = pCtx->pTab;
132440133375
assert( IsVirtual(pTab) );
132441133376
132442133377
memset(&sParse, 0, sizeof(sParse));
132443
- sParse.declareVtab = 1;
133378
+ sParse.eParseMode = PARSE_MODE_DECLARE_VTAB;
132444133379
sParse.db = db;
132445133380
sParse.nQueryLoop = 1;
132446133381
if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable, &zErr)
132447133382
&& sParse.pNewTable
132448133383
&& !db->mallocFailed
@@ -132479,11 +133414,11 @@
132479133414
}else{
132480133415
sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? "%s" : 0), zErr);
132481133416
sqlite3DbFree(db, zErr);
132482133417
rc = SQLITE_ERROR;
132483133418
}
132484
- sParse.declareVtab = 0;
133419
+ sParse.eParseMode = PARSE_MODE_NORMAL;
132485133420
132486133421
if( sParse.pVdbe ){
132487133422
sqlite3VdbeFinalize(sParse.pVdbe);
132488133423
}
132489133424
sqlite3DeleteTable(db, sParse.pNewTable);
@@ -144970,14 +145905,25 @@
144970145905
** that created the expression.
144971145906
*/
144972145907
static Expr *tokenExpr(Parse *pParse, int op, Token t){
144973145908
Expr *p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr)+t.n+1);
144974145909
if( p ){
144975
- memset(p, 0, sizeof(Expr));
145910
+ /* memset(p, 0, sizeof(Expr)); */
144976145911
p->op = (u8)op;
145912
+ p->affinity = 0;
144977145913
p->flags = EP_Leaf;
144978145914
p->iAgg = -1;
145915
+ p->pLeft = p->pRight = 0;
145916
+ p->x.pList = 0;
145917
+ p->pAggInfo = 0;
145918
+ p->pTab = 0;
145919
+ p->op2 = 0;
145920
+ p->iTable = 0;
145921
+ p->iColumn = 0;
145922
+#ifndef SQLITE_OMIT_WINDOWFUNC
145923
+ p->pWin = 0;
145924
+#endif
144979145925
p->u.zToken = (char*)&p[1];
144980145926
memcpy(p->u.zToken, t.z, t.n);
144981145927
p->u.zToken[t.n] = 0;
144982145928
if( sqlite3Isquote(p->u.zToken[0]) ){
144983145929
if( p->u.zToken[0]=='"' ) p->flags |= EP_DblQuoted;
@@ -144984,19 +145930,23 @@
144984145930
sqlite3Dequote(p->u.zToken);
144985145931
}
144986145932
#if SQLITE_MAX_EXPR_DEPTH>0
144987145933
p->nHeight = 1;
144988145934
#endif
145935
+ if( IN_RENAME_OBJECT ){
145936
+ return (Expr*)sqlite3RenameTokenMap(pParse, (void*)p, &t);
145937
+ }
144989145938
}
144990145939
return p;
144991145940
}
145941
+
144992145942
144993145943
/* A routine to convert a binary TK_IS or TK_ISNOT expression into a
144994145944
** unary TK_ISNULL or TK_NOTNULL expression. */
144995145945
static void binaryToUnaryIfNull(Parse *pParse, Expr *pY, Expr *pA, int op){
144996145946
sqlite3 *db = pParse->db;
144997
- if( pA && pY && pY->op==TK_NULL ){
145947
+ if( pA && pY && pY->op==TK_NULL && !IN_RENAME_OBJECT ){
144998145948
pA->op = (u8)op;
144999145949
sqlite3ExprDelete(db, pA->pRight);
145000145950
pA->pRight = 0;
145001145951
}
145002145952
}
@@ -145120,21 +146070,21 @@
145120146070
#define sqlite3ParserCTX_PDECL ,Parse *pParse
145121146071
#define sqlite3ParserCTX_PARAM ,pParse
145122146072
#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
145123146073
#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
145124146074
#define YYFALLBACK 1
145125
-#define YYNSTATE 518
145126
-#define YYNRULE 366
146075
+#define YYNSTATE 521
146076
+#define YYNRULE 367
145127146077
#define YYNTOKEN 155
145128
-#define YY_MAX_SHIFT 517
145129
-#define YY_MIN_SHIFTREDUCE 752
145130
-#define YY_MAX_SHIFTREDUCE 1117
145131
-#define YY_ERROR_ACTION 1118
145132
-#define YY_ACCEPT_ACTION 1119
145133
-#define YY_NO_ACTION 1120
145134
-#define YY_MIN_REDUCE 1121
145135
-#define YY_MAX_REDUCE 1486
146078
+#define YY_MAX_SHIFT 520
146079
+#define YY_MIN_SHIFTREDUCE 756
146080
+#define YY_MAX_SHIFTREDUCE 1122
146081
+#define YY_ERROR_ACTION 1123
146082
+#define YY_ACCEPT_ACTION 1124
146083
+#define YY_NO_ACTION 1125
146084
+#define YY_MIN_REDUCE 1126
146085
+#define YY_MAX_REDUCE 1492
145136146086
/************* End control #defines *******************************************/
145137146087
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
145138146088
145139146089
/* Define the yytestcase() macro to be a no-op if is not already defined
145140146090
** otherwise.
@@ -145199,211 +146149,211 @@
145199146149
** yy_default[] Default action for each state.
145200146150
**
145201146151
*********** Begin parsing tables **********************************************/
145202146152
#define YY_ACTTAB_COUNT (2009)
145203146153
static const YYACTIONTYPE yy_action[] = {
145204
- /* 0 */ 365, 105, 102, 197, 105, 102, 197, 512, 1119, 1,
145205
- /* 10 */ 1, 517, 2, 1123, 512, 1187, 1166, 1450, 272, 367,
145206
- /* 20 */ 127, 1384, 1192, 1192, 1187, 1161, 178, 1200, 64, 64,
145207
- /* 30 */ 474, 883, 319, 425, 345, 37, 37, 804, 359, 884,
145208
- /* 40 */ 506, 506, 506, 112, 113, 103, 1095, 1095, 949, 952,
145209
- /* 50 */ 942, 942, 110, 110, 111, 111, 111, 111, 362, 250,
145210
- /* 60 */ 250, 512, 250, 250, 494, 512, 306, 512, 456, 512,
145211
- /* 70 */ 1074, 488, 509, 475, 6, 509, 805, 134, 495, 226,
145212
- /* 80 */ 194, 425, 37, 37, 512, 206, 64, 64, 64, 64,
146154
+ /* 0 */ 368, 105, 102, 197, 105, 102, 197, 515, 1124, 1,
146155
+ /* 10 */ 1, 520, 2, 1128, 515, 1192, 1171, 1456, 275, 370,
146156
+ /* 20 */ 127, 1389, 1197, 1197, 1192, 1166, 178, 1205, 64, 64,
146157
+ /* 30 */ 477, 887, 322, 428, 348, 37, 37, 808, 362, 888,
146158
+ /* 40 */ 509, 509, 509, 112, 113, 103, 1100, 1100, 953, 956,
146159
+ /* 50 */ 946, 946, 110, 110, 111, 111, 111, 111, 365, 252,
146160
+ /* 60 */ 252, 515, 252, 252, 497, 515, 309, 515, 459, 515,
146161
+ /* 70 */ 1079, 491, 512, 478, 6, 512, 809, 134, 498, 228,
146162
+ /* 80 */ 194, 428, 37, 37, 515, 208, 64, 64, 64, 64,
145213146163
/* 90 */ 13, 13, 109, 109, 109, 109, 108, 108, 107, 107,
145214
- /* 100 */ 107, 106, 398, 255, 378, 13, 13, 395, 394, 425,
145215
- /* 110 */ 250, 250, 367, 473, 402, 1099, 1074, 1075, 1076, 383,
145216
- /* 120 */ 1101, 387, 494, 509, 494, 1417, 1413, 301, 1100, 304,
145217
- /* 130 */ 1251, 493, 367, 496, 16, 16, 112, 113, 103, 1095,
145218
- /* 140 */ 1095, 949, 952, 942, 942, 110, 110, 111, 111, 111,
145219
- /* 150 */ 111, 259, 1102, 492, 1102, 398, 112, 113, 103, 1095,
145220
- /* 160 */ 1095, 949, 952, 942, 942, 110, 110, 111, 111, 111,
145221
- /* 170 */ 111, 129, 1419, 340, 1414, 336, 1054, 489, 1052, 260,
145222
- /* 180 */ 73, 105, 102, 197, 990, 109, 109, 109, 109, 108,
145223
- /* 190 */ 108, 107, 107, 107, 106, 398, 367, 111, 111, 111,
145224
- /* 200 */ 111, 104, 489, 89, 1426, 109, 109, 109, 109, 108,
145225
- /* 210 */ 108, 107, 107, 107, 106, 398, 111, 111, 111, 111,
145226
- /* 220 */ 112, 113, 103, 1095, 1095, 949, 952, 942, 942, 110,
146164
+ /* 100 */ 107, 106, 401, 258, 381, 13, 13, 398, 397, 428,
146165
+ /* 110 */ 252, 252, 370, 476, 405, 1104, 1079, 1080, 1081, 386,
146166
+ /* 120 */ 1106, 390, 497, 512, 497, 1423, 1419, 304, 1105, 307,
146167
+ /* 130 */ 1256, 496, 370, 499, 16, 16, 112, 113, 103, 1100,
146168
+ /* 140 */ 1100, 953, 956, 946, 946, 110, 110, 111, 111, 111,
146169
+ /* 150 */ 111, 262, 1107, 495, 1107, 401, 112, 113, 103, 1100,
146170
+ /* 160 */ 1100, 953, 956, 946, 946, 110, 110, 111, 111, 111,
146171
+ /* 170 */ 111, 129, 1425, 343, 1420, 339, 1059, 492, 1057, 263,
146172
+ /* 180 */ 73, 105, 102, 197, 994, 109, 109, 109, 109, 108,
146173
+ /* 190 */ 108, 107, 107, 107, 106, 401, 370, 111, 111, 111,
146174
+ /* 200 */ 111, 104, 492, 89, 1432, 109, 109, 109, 109, 108,
146175
+ /* 210 */ 108, 107, 107, 107, 106, 401, 111, 111, 111, 111,
146176
+ /* 220 */ 112, 113, 103, 1100, 1100, 953, 956, 946, 946, 110,
145227146177
/* 230 */ 110, 111, 111, 111, 111, 109, 109, 109, 109, 108,
145228
- /* 240 */ 108, 107, 107, 107, 106, 398, 114, 108, 108, 107,
145229
- /* 250 */ 107, 107, 106, 398, 109, 109, 109, 109, 108, 108,
145230
- /* 260 */ 107, 107, 107, 106, 398, 152, 396, 396, 396, 109,
145231
- /* 270 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 398,
145232
- /* 280 */ 178, 490, 1406, 431, 1032, 1480, 1074, 512, 1480, 367,
145233
- /* 290 */ 418, 294, 354, 409, 74, 1074, 109, 109, 109, 109,
145234
- /* 300 */ 108, 108, 107, 107, 107, 106, 398, 1407, 37, 37,
145235
- /* 310 */ 1425, 271, 503, 112, 113, 103, 1095, 1095, 949, 952,
145236
- /* 320 */ 942, 942, 110, 110, 111, 111, 111, 111, 1430, 517,
145237
- /* 330 */ 2, 1123, 1074, 1075, 1076, 427, 272, 1074, 127, 363,
145238
- /* 340 */ 929, 1074, 1075, 1076, 218, 1200, 909, 455, 452, 451,
145239
- /* 350 */ 389, 167, 512, 1030, 152, 442, 920, 450, 152, 870,
145240
- /* 360 */ 919, 286, 109, 109, 109, 109, 108, 108, 107, 107,
145241
- /* 370 */ 107, 106, 398, 13, 13, 258, 849, 250, 250, 225,
145242
- /* 380 */ 106, 398, 367, 1074, 1075, 1076, 308, 385, 1074, 293,
145243
- /* 390 */ 509, 919, 919, 921, 229, 320, 1250, 1383, 1417, 487,
145244
- /* 400 */ 271, 503, 12, 206, 271, 503, 112, 113, 103, 1095,
145245
- /* 410 */ 1095, 949, 952, 942, 942, 110, 110, 111, 111, 111,
145246
- /* 420 */ 111, 1434, 283, 1123, 285, 1074, 1092, 245, 272, 1093,
145247
- /* 430 */ 127, 384, 402, 386, 1074, 1075, 1076, 1200, 159, 236,
145248
- /* 440 */ 253, 318, 458, 313, 457, 223, 786, 105, 102, 197,
145249
- /* 450 */ 510, 311, 838, 838, 442, 109, 109, 109, 109, 108,
145250
- /* 460 */ 108, 107, 107, 107, 106, 398, 512, 511, 512, 250,
145251
- /* 470 */ 250, 1074, 1075, 1076, 432, 367, 1093, 929, 1454, 790,
145252
- /* 480 */ 271, 503, 509, 105, 102, 197, 333, 63, 63, 64,
145253
- /* 490 */ 64, 27, 786, 920, 284, 206, 1349, 919, 512, 112,
145254
- /* 500 */ 113, 103, 1095, 1095, 949, 952, 942, 942, 110, 110,
145255
- /* 510 */ 111, 111, 111, 111, 107, 107, 107, 106, 398, 49,
145256
- /* 520 */ 49, 512, 28, 1074, 402, 494, 418, 294, 919, 919,
145257
- /* 530 */ 921, 186, 465, 1074, 464, 995, 995, 439, 512, 1074,
145258
- /* 540 */ 331, 512, 45, 45, 1078, 339, 173, 168, 109, 109,
145259
- /* 550 */ 109, 109, 108, 108, 107, 107, 107, 106, 398, 13,
145260
- /* 560 */ 13, 203, 13, 13, 250, 250, 1190, 1190, 367, 1074,
145261
- /* 570 */ 1075, 1076, 783, 262, 5, 356, 491, 509, 466, 1074,
145262
- /* 580 */ 1075, 1076, 395, 394, 1074, 1074, 1075, 1076, 3, 279,
145263
- /* 590 */ 1074, 1078, 112, 113, 103, 1095, 1095, 949, 952, 942,
145264
- /* 600 */ 942, 110, 110, 111, 111, 111, 111, 250, 250, 1011,
145265
- /* 610 */ 218, 1074, 869, 455, 452, 451, 939, 939, 950, 953,
145266
- /* 620 */ 509, 250, 250, 450, 1012, 1074, 442, 1102, 1204, 1102,
145267
- /* 630 */ 1074, 1075, 1076, 512, 509, 423, 1074, 1075, 1076, 1013,
145268
- /* 640 */ 509, 109, 109, 109, 109, 108, 108, 107, 107, 107,
145269
- /* 650 */ 106, 398, 1047, 512, 50, 50, 512, 1074, 1075, 1076,
145270
- /* 660 */ 824, 367, 1046, 376, 408, 1059, 1353, 205, 405, 769,
145271
- /* 670 */ 825, 1074, 1075, 1076, 64, 64, 319, 64, 64, 1297,
145272
- /* 680 */ 943, 408, 407, 1353, 1355, 112, 113, 103, 1095, 1095,
145273
- /* 690 */ 949, 952, 942, 942, 110, 110, 111, 111, 111, 111,
145274
- /* 700 */ 291, 479, 512, 1032, 1481, 512, 431, 1481, 351, 1115,
145275
- /* 710 */ 480, 992, 909, 482, 463, 992, 132, 178, 33, 447,
145276
- /* 720 */ 1198, 136, 403, 64, 64, 476, 64, 64, 416, 366,
145277
- /* 730 */ 280, 1141, 250, 250, 109, 109, 109, 109, 108, 108,
145278
- /* 740 */ 107, 107, 107, 106, 398, 509, 222, 437, 408, 263,
145279
- /* 750 */ 1353, 263, 250, 250, 367, 293, 413, 281, 930, 393,
145280
- /* 760 */ 972, 467, 397, 250, 250, 509, 9, 470, 229, 497,
145281
- /* 770 */ 351, 1031, 1030, 1482, 352, 371, 509, 1116, 112, 113,
145282
- /* 780 */ 103, 1095, 1095, 949, 952, 942, 942, 110, 110, 111,
145283
- /* 790 */ 111, 111, 111, 250, 250, 1011, 512, 1342, 292, 250,
145284
- /* 800 */ 250, 250, 250, 1093, 372, 247, 509, 442, 868, 319,
145285
- /* 810 */ 1012, 477, 509, 195, 509, 431, 270, 15, 15, 512,
145286
- /* 820 */ 311, 512, 95, 512, 93, 1013, 364, 109, 109, 109,
145287
- /* 830 */ 109, 108, 108, 107, 107, 107, 106, 398, 512, 1116,
145288
- /* 840 */ 39, 39, 51, 51, 52, 52, 500, 367, 512, 1199,
145289
- /* 850 */ 1093, 914, 436, 338, 133, 433, 221, 220, 219, 53,
145290
- /* 860 */ 53, 319, 1392, 757, 758, 759, 512, 367, 88, 54,
145291
- /* 870 */ 54, 112, 113, 103, 1095, 1095, 949, 952, 942, 942,
145292
- /* 880 */ 110, 110, 111, 111, 111, 111, 274, 55, 55, 196,
145293
- /* 890 */ 512, 112, 113, 103, 1095, 1095, 949, 952, 942, 942,
145294
- /* 900 */ 110, 110, 111, 111, 111, 111, 135, 261, 1144, 373,
145295
- /* 910 */ 512, 40, 40, 512, 868, 512, 989, 512, 989, 116,
146178
+ /* 240 */ 108, 107, 107, 107, 106, 401, 114, 108, 108, 107,
146179
+ /* 250 */ 107, 107, 106, 401, 109, 109, 109, 109, 108, 108,
146180
+ /* 260 */ 107, 107, 107, 106, 401, 152, 399, 399, 399, 109,
146181
+ /* 270 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 401,
146182
+ /* 280 */ 178, 493, 1412, 434, 1037, 1486, 1079, 515, 1486, 370,
146183
+ /* 290 */ 421, 297, 357, 412, 74, 1079, 109, 109, 109, 109,
146184
+ /* 300 */ 108, 108, 107, 107, 107, 106, 401, 1413, 37, 37,
146185
+ /* 310 */ 1431, 274, 506, 112, 113, 103, 1100, 1100, 953, 956,
146186
+ /* 320 */ 946, 946, 110, 110, 111, 111, 111, 111, 1436, 520,
146187
+ /* 330 */ 2, 1128, 1079, 1080, 1081, 430, 275, 1079, 127, 366,
146188
+ /* 340 */ 933, 1079, 1080, 1081, 220, 1205, 913, 458, 455, 454,
146189
+ /* 350 */ 392, 167, 515, 1035, 152, 445, 924, 453, 152, 874,
146190
+ /* 360 */ 923, 289, 109, 109, 109, 109, 108, 108, 107, 107,
146191
+ /* 370 */ 107, 106, 401, 13, 13, 261, 853, 252, 252, 227,
146192
+ /* 380 */ 106, 401, 370, 1079, 1080, 1081, 311, 388, 1079, 296,
146193
+ /* 390 */ 512, 923, 923, 925, 231, 323, 1255, 1388, 1423, 490,
146194
+ /* 400 */ 274, 506, 12, 208, 274, 506, 112, 113, 103, 1100,
146195
+ /* 410 */ 1100, 953, 956, 946, 946, 110, 110, 111, 111, 111,
146196
+ /* 420 */ 111, 1440, 286, 1128, 288, 1079, 1097, 247, 275, 1098,
146197
+ /* 430 */ 127, 387, 405, 389, 1079, 1080, 1081, 1205, 159, 238,
146198
+ /* 440 */ 255, 321, 461, 316, 460, 225, 790, 105, 102, 197,
146199
+ /* 450 */ 513, 314, 842, 842, 445, 109, 109, 109, 109, 108,
146200
+ /* 460 */ 108, 107, 107, 107, 106, 401, 515, 514, 515, 252,
146201
+ /* 470 */ 252, 1079, 1080, 1081, 435, 370, 1098, 933, 1460, 794,
146202
+ /* 480 */ 274, 506, 512, 105, 102, 197, 336, 63, 63, 64,
146203
+ /* 490 */ 64, 27, 790, 924, 287, 208, 1354, 923, 515, 112,
146204
+ /* 500 */ 113, 103, 1100, 1100, 953, 956, 946, 946, 110, 110,
146205
+ /* 510 */ 111, 111, 111, 111, 107, 107, 107, 106, 401, 49,
146206
+ /* 520 */ 49, 515, 28, 1079, 405, 497, 421, 297, 923, 923,
146207
+ /* 530 */ 925, 186, 468, 1079, 467, 999, 999, 442, 515, 1079,
146208
+ /* 540 */ 334, 515, 45, 45, 1083, 342, 173, 168, 109, 109,
146209
+ /* 550 */ 109, 109, 108, 108, 107, 107, 107, 106, 401, 13,
146210
+ /* 560 */ 13, 205, 13, 13, 252, 252, 1195, 1195, 370, 1079,
146211
+ /* 570 */ 1080, 1081, 787, 265, 5, 359, 494, 512, 469, 1079,
146212
+ /* 580 */ 1080, 1081, 398, 397, 1079, 1079, 1080, 1081, 3, 282,
146213
+ /* 590 */ 1079, 1083, 112, 113, 103, 1100, 1100, 953, 956, 946,
146214
+ /* 600 */ 946, 110, 110, 111, 111, 111, 111, 252, 252, 1015,
146215
+ /* 610 */ 220, 1079, 873, 458, 455, 454, 943, 943, 954, 957,
146216
+ /* 620 */ 512, 252, 252, 453, 1016, 1079, 445, 1107, 1209, 1107,
146217
+ /* 630 */ 1079, 1080, 1081, 515, 512, 426, 1079, 1080, 1081, 1017,
146218
+ /* 640 */ 512, 109, 109, 109, 109, 108, 108, 107, 107, 107,
146219
+ /* 650 */ 106, 401, 1052, 515, 50, 50, 515, 1079, 1080, 1081,
146220
+ /* 660 */ 828, 370, 1051, 379, 411, 1064, 1358, 207, 408, 773,
146221
+ /* 670 */ 829, 1079, 1080, 1081, 64, 64, 322, 64, 64, 1302,
146222
+ /* 680 */ 947, 411, 410, 1358, 1360, 112, 113, 103, 1100, 1100,
146223
+ /* 690 */ 953, 956, 946, 946, 110, 110, 111, 111, 111, 111,
146224
+ /* 700 */ 294, 482, 515, 1037, 1487, 515, 434, 1487, 354, 1120,
146225
+ /* 710 */ 483, 996, 913, 485, 466, 996, 132, 178, 33, 450,
146226
+ /* 720 */ 1203, 136, 406, 64, 64, 479, 64, 64, 419, 369,
146227
+ /* 730 */ 283, 1146, 252, 252, 109, 109, 109, 109, 108, 108,
146228
+ /* 740 */ 107, 107, 107, 106, 401, 512, 224, 440, 411, 266,
146229
+ /* 750 */ 1358, 266, 252, 252, 370, 296, 416, 284, 934, 396,
146230
+ /* 760 */ 976, 470, 400, 252, 252, 512, 9, 473, 231, 500,
146231
+ /* 770 */ 354, 1036, 1035, 1488, 355, 374, 512, 1121, 112, 113,
146232
+ /* 780 */ 103, 1100, 1100, 953, 956, 946, 946, 110, 110, 111,
146233
+ /* 790 */ 111, 111, 111, 252, 252, 1015, 515, 1347, 295, 252,
146234
+ /* 800 */ 252, 252, 252, 1098, 375, 249, 512, 445, 872, 322,
146235
+ /* 810 */ 1016, 480, 512, 195, 512, 434, 273, 15, 15, 515,
146236
+ /* 820 */ 314, 515, 95, 515, 93, 1017, 367, 109, 109, 109,
146237
+ /* 830 */ 109, 108, 108, 107, 107, 107, 106, 401, 515, 1121,
146238
+ /* 840 */ 39, 39, 51, 51, 52, 52, 503, 370, 515, 1204,
146239
+ /* 850 */ 1098, 918, 439, 341, 133, 436, 223, 222, 221, 53,
146240
+ /* 860 */ 53, 322, 1400, 761, 762, 763, 515, 370, 88, 54,
146241
+ /* 870 */ 54, 112, 113, 103, 1100, 1100, 953, 956, 946, 946,
146242
+ /* 880 */ 110, 110, 111, 111, 111, 111, 407, 55, 55, 196,
146243
+ /* 890 */ 515, 112, 113, 103, 1100, 1100, 953, 956, 946, 946,
146244
+ /* 900 */ 110, 110, 111, 111, 111, 111, 135, 264, 1149, 376,
146245
+ /* 910 */ 515, 40, 40, 515, 872, 515, 993, 515, 993, 116,
145296146246
/* 920 */ 109, 109, 109, 109, 108, 108, 107, 107, 107, 106,
145297
- /* 930 */ 398, 41, 41, 512, 43, 43, 44, 44, 56, 56,
146247
+ /* 930 */ 401, 41, 41, 515, 43, 43, 44, 44, 56, 56,
145298146248
/* 940 */ 109, 109, 109, 109, 108, 108, 107, 107, 107, 106,
145299
- /* 950 */ 398, 512, 376, 512, 57, 57, 512, 795, 512, 376,
145300
- /* 960 */ 512, 442, 793, 512, 320, 512, 275, 512, 1453, 512,
145301
- /* 970 */ 1282, 813, 58, 58, 14, 14, 512, 59, 59, 118,
145302
- /* 980 */ 118, 60, 60, 512, 46, 46, 61, 61, 62, 62,
145303
- /* 990 */ 47, 47, 512, 190, 189, 91, 512, 140, 140, 512,
145304
- /* 1000 */ 391, 512, 844, 1195, 141, 141, 512, 843, 512, 793,
145305
- /* 1010 */ 512, 410, 512, 69, 69, 367, 278, 48, 48, 256,
145306
- /* 1020 */ 65, 65, 119, 119, 244, 244, 257, 66, 66, 120,
145307
- /* 1030 */ 120, 121, 121, 117, 117, 367, 512, 509, 380, 112,
145308
- /* 1040 */ 113, 103, 1095, 1095, 949, 952, 942, 942, 110, 110,
145309
- /* 1050 */ 111, 111, 111, 111, 512, 868, 512, 139, 139, 112,
145310
- /* 1060 */ 113, 103, 1095, 1095, 949, 952, 942, 942, 110, 110,
145311
- /* 1070 */ 111, 111, 111, 111, 1282, 138, 138, 125, 125, 512,
145312
- /* 1080 */ 12, 512, 1351, 1282, 512, 442, 131, 1282, 109, 109,
145313
- /* 1090 */ 109, 109, 108, 108, 107, 107, 107, 106, 398, 512,
145314
- /* 1100 */ 124, 124, 122, 122, 512, 123, 123, 512, 109, 109,
145315
- /* 1110 */ 109, 109, 108, 108, 107, 107, 107, 106, 398, 512,
145316
- /* 1120 */ 68, 68, 460, 779, 512, 70, 70, 299, 67, 67,
145317
- /* 1130 */ 1027, 251, 251, 353, 1282, 191, 196, 1427, 462, 1296,
145318
- /* 1140 */ 38, 38, 381, 94, 509, 42, 42, 177, 844, 271,
145319
- /* 1150 */ 503, 382, 417, 843, 420, 438, 505, 373, 374, 153,
145320
- /* 1160 */ 252, 868, 429, 367, 222, 249, 194, 883, 182, 290,
145321
- /* 1170 */ 779, 988, 88, 988, 463, 884, 906, 911, 424, 426,
145322
- /* 1180 */ 228, 228, 228, 367, 17, 803, 802, 112, 113, 103,
145323
- /* 1190 */ 1095, 1095, 949, 952, 942, 942, 110, 110, 111, 111,
145324
- /* 1200 */ 111, 111, 392, 295, 810, 811, 88, 112, 101, 103,
145325
- /* 1210 */ 1095, 1095, 949, 952, 942, 942, 110, 110, 111, 111,
145326
- /* 1220 */ 111, 111, 372, 419, 448, 309, 979, 224, 88, 975,
145327
- /* 1230 */ 877, 841, 224, 228, 100, 923, 109, 109, 109, 109,
145328
- /* 1240 */ 108, 108, 107, 107, 107, 106, 398, 86, 430, 777,
145329
- /* 1250 */ 842, 1236, 130, 100, 1235, 412, 109, 109, 109, 109,
145330
- /* 1260 */ 108, 108, 107, 107, 107, 106, 398, 317, 1443, 1397,
145331
- /* 1270 */ 1170, 287, 1169, 979, 1372, 1371, 367, 316, 434, 296,
145332
- /* 1280 */ 1232, 1223, 923, 300, 303, 305, 307, 1183, 1168, 1167,
145333
- /* 1290 */ 312, 321, 322, 1244, 1281, 1219, 367, 268, 1230, 499,
145334
- /* 1300 */ 498, 113, 103, 1095, 1095, 949, 952, 942, 942, 110,
145335
- /* 1310 */ 110, 111, 111, 111, 111, 1287, 1150, 443, 242, 184,
145336
- /* 1320 */ 1216, 1143, 103, 1095, 1095, 949, 952, 942, 942, 110,
145337
- /* 1330 */ 110, 111, 111, 111, 111, 1132, 1131, 1133, 1437, 350,
145338
- /* 1340 */ 411, 324, 188, 98, 504, 289, 4, 326, 315, 109,
145339
- /* 1350 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 398,
145340
- /* 1360 */ 507, 328, 1266, 1274, 358, 453, 282, 192, 1346, 109,
145341
- /* 1370 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 398,
145342
- /* 1380 */ 11, 1166, 1345, 399, 1440, 330, 502, 1110, 231, 428,
145343
- /* 1390 */ 1391, 343, 187, 98, 504, 501, 4, 1107, 1389, 375,
145344
- /* 1400 */ 422, 155, 72, 165, 75, 152, 149, 86, 414, 1263,
145345
- /* 1410 */ 507, 157, 415, 160, 929, 161, 162, 163, 446, 1271,
145346
- /* 1420 */ 96, 96, 8, 30, 208, 1277, 357, 97, 355, 399,
145347
- /* 1430 */ 514, 513, 421, 399, 919, 31, 169, 435, 1340, 212,
145348
- /* 1440 */ 80, 441, 243, 214, 1360, 501, 298, 174, 444, 302,
145349
- /* 1450 */ 215, 271, 503, 1134, 216, 360, 485, 459, 388, 1186,
145350
- /* 1460 */ 361, 484, 1185, 795, 929, 919, 919, 921, 922, 24,
145351
- /* 1470 */ 96, 96, 1184, 1158, 1177, 314, 1157, 97, 1176, 399,
145352
- /* 1480 */ 514, 513, 469, 1156, 919, 1452, 390, 266, 98, 504,
145353
- /* 1490 */ 267, 4, 472, 478, 483, 85, 1227, 333, 230, 492,
145354
- /* 1500 */ 1408, 332, 323, 115, 10, 507, 1228, 181, 335, 98,
145355
- /* 1510 */ 504, 337, 4, 92, 87, 919, 919, 921, 922, 24,
145356
- /* 1520 */ 1429, 1063, 401, 1226, 481, 254, 507, 325, 399, 327,
145357
- /* 1530 */ 349, 349, 348, 239, 346, 1225, 329, 766, 1209, 1326,
145358
- /* 1540 */ 501, 183, 1208, 341, 269, 342, 237, 1069, 1140, 399,
145359
- /* 1550 */ 199, 485, 277, 29, 515, 241, 486, 238, 516, 929,
145360
- /* 1560 */ 276, 501, 240, 1129, 1124, 96, 96, 1376, 142, 154,
145361
- /* 1570 */ 369, 370, 97, 143, 399, 514, 513, 1377, 128, 919,
145362
- /* 1580 */ 929, 1375, 144, 753, 400, 1374, 96, 96, 848, 1154,
145363
- /* 1590 */ 201, 1153, 185, 97, 264, 399, 514, 513, 202, 71,
145364
- /* 1600 */ 919, 146, 1151, 273, 198, 404, 126, 987, 200, 985,
145365
- /* 1610 */ 919, 919, 921, 922, 24, 903, 156, 145, 204, 158,
145366
- /* 1620 */ 827, 98, 504, 288, 4, 207, 1001, 164, 147, 907,
145367
- /* 1630 */ 377, 919, 919, 921, 922, 24, 379, 148, 507, 166,
145368
- /* 1640 */ 76, 77, 368, 1004, 78, 79, 209, 271, 503, 210,
145369
- /* 1650 */ 1000, 137, 18, 297, 211, 228, 440, 1104, 213, 171,
145370
- /* 1660 */ 32, 399, 768, 993, 170, 316, 445, 217, 449, 806,
145371
- /* 1670 */ 406, 310, 172, 501, 81, 19, 20, 454, 82, 83,
145372
- /* 1680 */ 265, 150, 179, 461, 485, 151, 180, 955, 84, 484,
145373
- /* 1690 */ 1035, 34, 929, 35, 468, 1036, 193, 471, 96, 96,
145374
- /* 1700 */ 246, 248, 876, 175, 871, 97, 100, 399, 514, 513,
145375
- /* 1710 */ 1063, 401, 919, 227, 254, 1053, 21, 22, 1049, 349,
145376
- /* 1720 */ 349, 348, 239, 346, 1040, 176, 766, 334, 1051, 7,
145377
- /* 1730 */ 88, 98, 504, 970, 4, 233, 23, 956, 954, 199,
145378
- /* 1740 */ 958, 277, 1010, 919, 919, 921, 922, 24, 507, 276,
145379
- /* 1750 */ 232, 1009, 959, 25, 36, 508, 924, 778, 99, 26,
145380
- /* 1760 */ 347, 90, 504, 837, 4, 234, 344, 235, 1445, 1064,
145381
- /* 1770 */ 1120, 399, 1120, 1444, 1120, 1120, 1120, 1120, 507, 201,
145382
- /* 1780 */ 1120, 1120, 1120, 501, 1120, 1120, 1120, 202, 1120, 1120,
145383
- /* 1790 */ 146, 1120, 1120, 1120, 1120, 1120, 1120, 200, 1120, 1120,
145384
- /* 1800 */ 1120, 399, 929, 1120, 1120, 1120, 1120, 1120, 96, 96,
145385
- /* 1810 */ 1120, 1120, 1120, 501, 1120, 97, 1120, 399, 514, 513,
145386
- /* 1820 */ 1120, 1120, 919, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
145387
- /* 1830 */ 1120, 368, 929, 1120, 1120, 1120, 271, 503, 96, 96,
145388
- /* 1840 */ 1120, 1120, 1120, 1120, 1120, 97, 1120, 399, 514, 513,
145389
- /* 1850 */ 1120, 1120, 919, 919, 919, 921, 922, 24, 1120, 406,
145390
- /* 1860 */ 1120, 1120, 1120, 254, 1120, 1120, 1120, 1120, 349, 349,
145391
- /* 1870 */ 348, 239, 346, 1120, 1120, 766, 1120, 1120, 1120, 1120,
145392
- /* 1880 */ 1120, 1120, 1120, 919, 919, 921, 922, 24, 199, 1120,
145393
- /* 1890 */ 277, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 276, 1120,
145394
- /* 1900 */ 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
145395
- /* 1910 */ 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
145396
- /* 1920 */ 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 201, 1120,
145397
- /* 1930 */ 1120, 1120, 1120, 1120, 1120, 1120, 202, 1120, 1120, 146,
145398
- /* 1940 */ 1120, 1120, 1120, 1120, 1120, 1120, 200, 1120, 1120, 1120,
145399
- /* 1950 */ 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
145400
- /* 1960 */ 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
145401
- /* 1970 */ 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
145402
- /* 1980 */ 368, 1120, 1120, 1120, 1120, 271, 503, 1120, 1120, 1120,
145403
- /* 1990 */ 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
145404
- /* 2000 */ 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 406,
146249
+ /* 950 */ 401, 515, 379, 515, 57, 57, 515, 799, 515, 379,
146250
+ /* 960 */ 515, 445, 200, 515, 323, 515, 1397, 515, 1459, 515,
146251
+ /* 970 */ 1287, 817, 58, 58, 14, 14, 515, 59, 59, 118,
146252
+ /* 980 */ 118, 60, 60, 515, 46, 46, 61, 61, 62, 62,
146253
+ /* 990 */ 47, 47, 515, 190, 189, 91, 515, 140, 140, 515,
146254
+ /* 1000 */ 394, 515, 277, 1200, 141, 141, 515, 1115, 515, 992,
146255
+ /* 1010 */ 515, 992, 515, 69, 69, 370, 278, 48, 48, 259,
146256
+ /* 1020 */ 65, 65, 119, 119, 246, 246, 260, 66, 66, 120,
146257
+ /* 1030 */ 120, 121, 121, 117, 117, 370, 515, 512, 383, 112,
146258
+ /* 1040 */ 113, 103, 1100, 1100, 953, 956, 946, 946, 110, 110,
146259
+ /* 1050 */ 111, 111, 111, 111, 515, 872, 515, 139, 139, 112,
146260
+ /* 1060 */ 113, 103, 1100, 1100, 953, 956, 946, 946, 110, 110,
146261
+ /* 1070 */ 111, 111, 111, 111, 1287, 138, 138, 125, 125, 515,
146262
+ /* 1080 */ 12, 515, 281, 1287, 515, 445, 131, 1287, 109, 109,
146263
+ /* 1090 */ 109, 109, 108, 108, 107, 107, 107, 106, 401, 515,
146264
+ /* 1100 */ 124, 124, 122, 122, 515, 123, 123, 515, 109, 109,
146265
+ /* 1110 */ 109, 109, 108, 108, 107, 107, 107, 106, 401, 515,
146266
+ /* 1120 */ 68, 68, 463, 783, 515, 70, 70, 302, 67, 67,
146267
+ /* 1130 */ 1032, 253, 253, 356, 1287, 191, 196, 1433, 465, 1301,
146268
+ /* 1140 */ 38, 38, 384, 94, 512, 42, 42, 177, 848, 274,
146269
+ /* 1150 */ 506, 385, 420, 847, 1356, 441, 508, 376, 377, 153,
146270
+ /* 1160 */ 423, 872, 432, 370, 224, 251, 194, 887, 182, 293,
146271
+ /* 1170 */ 783, 848, 88, 254, 466, 888, 847, 915, 807, 806,
146272
+ /* 1180 */ 230, 1241, 910, 370, 17, 413, 797, 112, 113, 103,
146273
+ /* 1190 */ 1100, 1100, 953, 956, 946, 946, 110, 110, 111, 111,
146274
+ /* 1200 */ 111, 111, 395, 814, 815, 1175, 983, 112, 101, 103,
146275
+ /* 1210 */ 1100, 1100, 953, 956, 946, 946, 110, 110, 111, 111,
146276
+ /* 1220 */ 111, 111, 375, 422, 427, 429, 298, 230, 230, 88,
146277
+ /* 1230 */ 1240, 451, 312, 797, 226, 88, 109, 109, 109, 109,
146278
+ /* 1240 */ 108, 108, 107, 107, 107, 106, 401, 86, 433, 979,
146279
+ /* 1250 */ 927, 881, 226, 983, 230, 415, 109, 109, 109, 109,
146280
+ /* 1260 */ 108, 108, 107, 107, 107, 106, 401, 320, 845, 781,
146281
+ /* 1270 */ 846, 100, 130, 100, 1403, 290, 370, 319, 1377, 1376,
146282
+ /* 1280 */ 437, 1449, 299, 1237, 303, 306, 308, 310, 1188, 1174,
146283
+ /* 1290 */ 1173, 1172, 315, 324, 325, 1228, 370, 927, 1249, 271,
146284
+ /* 1300 */ 1286, 113, 103, 1100, 1100, 953, 956, 946, 946, 110,
146285
+ /* 1310 */ 110, 111, 111, 111, 111, 1224, 1235, 502, 501, 1292,
146286
+ /* 1320 */ 1221, 1155, 103, 1100, 1100, 953, 956, 946, 946, 110,
146287
+ /* 1330 */ 110, 111, 111, 111, 111, 1148, 1137, 1136, 1138, 1443,
146288
+ /* 1340 */ 446, 244, 184, 98, 507, 188, 4, 353, 327, 109,
146289
+ /* 1350 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 401,
146290
+ /* 1360 */ 510, 329, 331, 199, 414, 456, 292, 285, 318, 109,
146291
+ /* 1370 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 401,
146292
+ /* 1380 */ 11, 1271, 1279, 402, 361, 192, 1171, 1351, 431, 505,
146293
+ /* 1390 */ 346, 1350, 333, 98, 507, 504, 4, 187, 1446, 1115,
146294
+ /* 1400 */ 233, 1396, 155, 1394, 1112, 152, 72, 75, 378, 425,
146295
+ /* 1410 */ 510, 165, 149, 157, 933, 1276, 86, 30, 1268, 417,
146296
+ /* 1420 */ 96, 96, 8, 160, 161, 162, 163, 97, 418, 402,
146297
+ /* 1430 */ 517, 516, 449, 402, 923, 210, 358, 424, 1282, 438,
146298
+ /* 1440 */ 169, 214, 360, 1345, 80, 504, 31, 444, 1365, 301,
146299
+ /* 1450 */ 245, 274, 506, 216, 174, 305, 488, 447, 217, 462,
146300
+ /* 1460 */ 1139, 487, 218, 363, 933, 923, 923, 925, 926, 24,
146301
+ /* 1470 */ 96, 96, 1191, 1190, 1189, 391, 1182, 97, 1163, 402,
146302
+ /* 1480 */ 517, 516, 799, 364, 923, 1162, 317, 1161, 98, 507,
146303
+ /* 1490 */ 1181, 4, 1458, 472, 393, 269, 270, 475, 481, 1232,
146304
+ /* 1500 */ 85, 1233, 326, 328, 232, 510, 495, 1231, 330, 98,
146305
+ /* 1510 */ 507, 1230, 4, 486, 335, 923, 923, 925, 926, 24,
146306
+ /* 1520 */ 1435, 1068, 404, 181, 336, 256, 510, 115, 402, 332,
146307
+ /* 1530 */ 352, 352, 351, 241, 349, 1214, 1414, 770, 338, 10,
146308
+ /* 1540 */ 504, 340, 272, 92, 1331, 1213, 87, 183, 484, 402,
146309
+ /* 1550 */ 201, 488, 280, 239, 344, 345, 489, 1145, 29, 933,
146310
+ /* 1560 */ 279, 504, 1074, 518, 240, 96, 96, 242, 243, 519,
146311
+ /* 1570 */ 1134, 1129, 97, 154, 402, 517, 516, 372, 373, 923,
146312
+ /* 1580 */ 933, 142, 143, 128, 1381, 267, 96, 96, 852, 757,
146313
+ /* 1590 */ 203, 144, 403, 97, 1382, 402, 517, 516, 204, 1380,
146314
+ /* 1600 */ 923, 146, 1379, 1159, 1158, 71, 1156, 276, 202, 185,
146315
+ /* 1610 */ 923, 923, 925, 926, 24, 198, 257, 126, 991, 989,
146316
+ /* 1620 */ 907, 98, 507, 156, 4, 145, 158, 206, 831, 209,
146317
+ /* 1630 */ 291, 923, 923, 925, 926, 24, 1005, 911, 510, 164,
146318
+ /* 1640 */ 147, 380, 371, 382, 166, 76, 77, 274, 506, 148,
146319
+ /* 1650 */ 78, 79, 1008, 211, 212, 1004, 137, 213, 18, 300,
146320
+ /* 1660 */ 230, 402, 997, 1109, 443, 215, 32, 170, 171, 772,
146321
+ /* 1670 */ 409, 448, 319, 504, 219, 172, 452, 81, 19, 457,
146322
+ /* 1680 */ 313, 20, 82, 268, 488, 150, 810, 179, 83, 487,
146323
+ /* 1690 */ 464, 151, 933, 180, 959, 84, 1040, 34, 96, 96,
146324
+ /* 1700 */ 471, 1041, 35, 474, 193, 97, 248, 402, 517, 516,
146325
+ /* 1710 */ 1068, 404, 923, 250, 256, 880, 229, 175, 875, 352,
146326
+ /* 1720 */ 352, 351, 241, 349, 100, 21, 770, 22, 1054, 1056,
146327
+ /* 1730 */ 7, 98, 507, 1045, 4, 337, 1058, 23, 974, 201,
146328
+ /* 1740 */ 176, 280, 88, 923, 923, 925, 926, 24, 510, 279,
146329
+ /* 1750 */ 960, 958, 962, 1014, 963, 1013, 235, 234, 25, 36,
146330
+ /* 1760 */ 99, 90, 507, 928, 4, 511, 350, 782, 26, 841,
146331
+ /* 1770 */ 236, 402, 347, 1069, 237, 1125, 1125, 1451, 510, 203,
146332
+ /* 1780 */ 1450, 1125, 1125, 504, 1125, 1125, 1125, 204, 1125, 1125,
146333
+ /* 1790 */ 146, 1125, 1125, 1125, 1125, 1125, 1125, 202, 1125, 1125,
146334
+ /* 1800 */ 1125, 402, 933, 1125, 1125, 1125, 1125, 1125, 96, 96,
146335
+ /* 1810 */ 1125, 1125, 1125, 504, 1125, 97, 1125, 402, 517, 516,
146336
+ /* 1820 */ 1125, 1125, 923, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146337
+ /* 1830 */ 1125, 371, 933, 1125, 1125, 1125, 274, 506, 96, 96,
146338
+ /* 1840 */ 1125, 1125, 1125, 1125, 1125, 97, 1125, 402, 517, 516,
146339
+ /* 1850 */ 1125, 1125, 923, 923, 923, 925, 926, 24, 1125, 409,
146340
+ /* 1860 */ 1125, 1125, 1125, 256, 1125, 1125, 1125, 1125, 352, 352,
146341
+ /* 1870 */ 351, 241, 349, 1125, 1125, 770, 1125, 1125, 1125, 1125,
146342
+ /* 1880 */ 1125, 1125, 1125, 923, 923, 925, 926, 24, 201, 1125,
146343
+ /* 1890 */ 280, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 279, 1125,
146344
+ /* 1900 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146345
+ /* 1910 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146346
+ /* 1920 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 203, 1125,
146347
+ /* 1930 */ 1125, 1125, 1125, 1125, 1125, 1125, 204, 1125, 1125, 146,
146348
+ /* 1940 */ 1125, 1125, 1125, 1125, 1125, 1125, 202, 1125, 1125, 1125,
146349
+ /* 1950 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146350
+ /* 1960 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146351
+ /* 1970 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146352
+ /* 1980 */ 371, 1125, 1125, 1125, 1125, 274, 506, 1125, 1125, 1125,
146353
+ /* 1990 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146354
+ /* 2000 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 409,
145405146355
};
145406146356
static const YYCODETYPE yy_lookahead[] = {
145407146357
/* 0 */ 184, 238, 239, 240, 238, 239, 240, 163, 155, 156,
145408146358
/* 10 */ 157, 158, 159, 160, 163, 191, 192, 183, 165, 19,
145409146359
/* 20 */ 167, 258, 202, 203, 200, 191, 163, 174, 184, 185,
@@ -145498,16 +146448,16 @@
145498146448
/* 910 */ 163, 184, 185, 163, 132, 163, 141, 163, 143, 22,
145499146449
/* 920 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
145500146450
/* 930 */ 102, 184, 185, 163, 184, 185, 184, 185, 184, 185,
145501146451
/* 940 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
145502146452
/* 950 */ 102, 163, 163, 163, 184, 185, 163, 115, 163, 163,
145503
- /* 960 */ 163, 163, 59, 163, 163, 163, 163, 163, 23, 163,
146453
+ /* 960 */ 163, 163, 15, 163, 163, 163, 163, 163, 23, 163,
145504146454
/* 970 */ 163, 26, 184, 185, 184, 185, 163, 184, 185, 184,
145505146455
/* 980 */ 185, 184, 185, 163, 184, 185, 184, 185, 184, 185,
145506146456
/* 990 */ 184, 185, 163, 96, 97, 147, 163, 184, 185, 163,
145507
- /* 1000 */ 199, 163, 124, 205, 184, 185, 163, 129, 163, 106,
145508
- /* 1010 */ 163, 234, 163, 184, 185, 19, 163, 184, 185, 230,
146457
+ /* 1000 */ 199, 163, 163, 205, 184, 185, 163, 60, 163, 141,
146458
+ /* 1010 */ 163, 143, 163, 184, 185, 19, 163, 184, 185, 230,
145509146459
/* 1020 */ 184, 185, 184, 185, 206, 207, 230, 184, 185, 184,
145510146460
/* 1030 */ 185, 184, 185, 184, 185, 19, 163, 219, 231, 43,
145511146461
/* 1040 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
145512146462
/* 1050 */ 54, 55, 56, 57, 163, 26, 163, 184, 185, 43,
145513146463
/* 1060 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
@@ -145517,74 +146467,74 @@
145517146467
/* 1100 */ 184, 185, 184, 185, 163, 184, 185, 163, 92, 93,
145518146468
/* 1110 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 163,
145519146469
/* 1120 */ 184, 185, 98, 59, 163, 184, 185, 205, 184, 185,
145520146470
/* 1130 */ 23, 206, 207, 26, 163, 26, 107, 153, 154, 237,
145521146471
/* 1140 */ 184, 185, 231, 147, 219, 184, 185, 249, 124, 127,
145522
- /* 1150 */ 128, 231, 254, 129, 118, 231, 177, 178, 262, 263,
145523
- /* 1160 */ 22, 132, 19, 19, 46, 223, 224, 31, 24, 23,
145524
- /* 1170 */ 106, 141, 26, 143, 272, 39, 140, 23, 23, 23,
145525
- /* 1180 */ 26, 26, 26, 19, 22, 109, 110, 43, 44, 45,
146472
+ /* 1150 */ 128, 231, 254, 129, 163, 231, 177, 178, 262, 263,
146473
+ /* 1160 */ 118, 132, 19, 19, 46, 223, 224, 31, 24, 23,
146474
+ /* 1170 */ 106, 124, 26, 22, 272, 39, 129, 23, 109, 110,
146475
+ /* 1180 */ 26, 163, 140, 19, 22, 234, 59, 43, 44, 45,
145526146476
/* 1190 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
145527
- /* 1200 */ 56, 57, 231, 23, 7, 8, 26, 43, 44, 45,
146477
+ /* 1200 */ 56, 57, 231, 7, 8, 193, 59, 43, 44, 45,
145528146478
/* 1210 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
145529
- /* 1220 */ 56, 57, 104, 61, 23, 23, 59, 26, 26, 23,
145530
- /* 1230 */ 23, 23, 26, 26, 26, 59, 92, 93, 94, 95,
146479
+ /* 1220 */ 56, 57, 104, 61, 23, 23, 23, 26, 26, 26,
146480
+ /* 1230 */ 163, 23, 23, 106, 26, 26, 92, 93, 94, 95,
145531146481
/* 1240 */ 96, 97, 98, 99, 100, 101, 102, 138, 105, 23,
145532
- /* 1250 */ 23, 163, 26, 26, 163, 163, 92, 93, 94, 95,
145533
- /* 1260 */ 96, 97, 98, 99, 100, 101, 102, 110, 130, 163,
145534
- /* 1270 */ 193, 163, 193, 106, 163, 163, 19, 120, 163, 163,
145535
- /* 1280 */ 163, 225, 106, 163, 163, 163, 163, 163, 193, 163,
145536
- /* 1290 */ 163, 163, 163, 163, 163, 163, 19, 222, 163, 203,
146482
+ /* 1250 */ 59, 23, 26, 106, 26, 163, 92, 93, 94, 95,
146483
+ /* 1260 */ 96, 97, 98, 99, 100, 101, 102, 110, 23, 23,
146484
+ /* 1270 */ 23, 26, 26, 26, 163, 163, 19, 120, 163, 163,
146485
+ /* 1280 */ 163, 130, 163, 163, 163, 163, 163, 163, 163, 193,
146486
+ /* 1290 */ 193, 163, 163, 163, 163, 225, 19, 106, 163, 222,
145537146487
/* 1300 */ 163, 44, 45, 46, 47, 48, 49, 50, 51, 52,
145538
- /* 1310 */ 53, 54, 55, 56, 57, 163, 163, 251, 250, 209,
146488
+ /* 1310 */ 53, 54, 55, 56, 57, 163, 163, 203, 163, 163,
145539146489
/* 1320 */ 222, 163, 45, 46, 47, 48, 49, 50, 51, 52,
145540
- /* 1330 */ 53, 54, 55, 56, 57, 163, 163, 163, 163, 161,
145541
- /* 1340 */ 226, 222, 182, 19, 20, 256, 22, 222, 187, 92,
146490
+ /* 1330 */ 53, 54, 55, 56, 57, 163, 163, 163, 163, 163,
146491
+ /* 1340 */ 251, 250, 209, 19, 20, 182, 22, 161, 222, 92,
145542146492
/* 1350 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
145543
- /* 1360 */ 36, 222, 213, 213, 213, 188, 226, 196, 187, 92,
146493
+ /* 1360 */ 36, 222, 222, 260, 226, 188, 256, 226, 187, 92,
145544146494
/* 1370 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
145545
- /* 1380 */ 210, 192, 187, 59, 166, 226, 244, 60, 130, 256,
145546
- /* 1390 */ 170, 212, 210, 19, 20, 71, 22, 38, 170, 170,
145547
- /* 1400 */ 104, 260, 257, 22, 257, 81, 43, 138, 18, 213,
145548
- /* 1410 */ 36, 201, 170, 204, 90, 204, 204, 204, 18, 236,
145549
- /* 1420 */ 96, 97, 48, 235, 169, 201, 236, 103, 213, 105,
145550
- /* 1430 */ 106, 107, 213, 59, 110, 235, 201, 170, 213, 169,
145551
- /* 1440 */ 146, 62, 170, 169, 253, 71, 252, 22, 189, 170,
145552
- /* 1450 */ 169, 127, 128, 170, 169, 189, 82, 104, 64, 186,
145553
- /* 1460 */ 189, 87, 186, 115, 90, 141, 142, 143, 144, 145,
145554
- /* 1470 */ 96, 97, 186, 186, 194, 186, 188, 103, 194, 105,
145555
- /* 1480 */ 106, 107, 189, 186, 110, 186, 102, 246, 19, 20,
145556
- /* 1490 */ 246, 22, 189, 133, 84, 104, 228, 22, 170, 134,
145557
- /* 1500 */ 269, 271, 227, 137, 22, 36, 228, 216, 216, 19,
145558
- /* 1510 */ 20, 170, 22, 146, 136, 141, 142, 143, 144, 145,
145559
- /* 1520 */ 0, 1, 2, 228, 135, 5, 36, 227, 59, 227,
145560
- /* 1530 */ 10, 11, 12, 13, 14, 228, 227, 17, 217, 241,
145561
- /* 1540 */ 71, 215, 217, 214, 243, 213, 25, 13, 173, 59,
145562
- /* 1550 */ 30, 82, 32, 26, 172, 6, 87, 164, 162, 90,
145563
- /* 1560 */ 40, 71, 164, 162, 162, 96, 97, 182, 176, 263,
145564
- /* 1570 */ 266, 266, 103, 176, 105, 106, 107, 182, 190, 110,
145565
- /* 1580 */ 90, 182, 176, 4, 3, 182, 96, 97, 98, 182,
145566
- /* 1590 */ 70, 182, 22, 103, 190, 105, 106, 107, 78, 182,
145567
- /* 1600 */ 110, 81, 182, 151, 15, 89, 16, 23, 88, 23,
145568
- /* 1610 */ 141, 142, 143, 144, 145, 128, 139, 119, 24, 131,
145569
- /* 1620 */ 20, 19, 20, 16, 22, 133, 1, 131, 119, 140,
145570
- /* 1630 */ 61, 141, 142, 143, 144, 145, 37, 119, 36, 139,
145571
- /* 1640 */ 53, 53, 122, 105, 53, 53, 34, 127, 128, 130,
145572
- /* 1650 */ 1, 5, 22, 149, 104, 26, 41, 75, 130, 104,
145573
- /* 1660 */ 24, 59, 20, 68, 68, 120, 19, 114, 67, 28,
145574
- /* 1670 */ 150, 23, 22, 71, 22, 22, 22, 67, 22, 138,
145575
- /* 1680 */ 67, 37, 23, 22, 82, 153, 23, 23, 26, 87,
145576
- /* 1690 */ 23, 22, 90, 22, 24, 23, 130, 24, 96, 97,
145577
- /* 1700 */ 23, 23, 105, 22, 132, 103, 26, 105, 106, 107,
145578
- /* 1710 */ 1, 2, 110, 34, 5, 75, 34, 34, 85, 10,
145579
- /* 1720 */ 11, 12, 13, 14, 23, 26, 17, 24, 83, 44,
145580
- /* 1730 */ 26, 19, 20, 23, 22, 22, 34, 23, 23, 30,
145581
- /* 1740 */ 23, 32, 23, 141, 142, 143, 144, 145, 36, 40,
145582
- /* 1750 */ 26, 23, 11, 22, 22, 26, 23, 23, 22, 22,
145583
- /* 1760 */ 15, 19, 20, 124, 22, 130, 23, 130, 130, 1,
145584
- /* 1770 */ 277, 59, 277, 130, 277, 277, 277, 277, 36, 70,
145585
- /* 1780 */ 277, 277, 277, 71, 277, 277, 277, 78, 277, 277,
146495
+ /* 1380 */ 210, 213, 213, 59, 213, 196, 192, 187, 256, 244,
146496
+ /* 1390 */ 212, 187, 226, 19, 20, 71, 22, 210, 166, 60,
146497
+ /* 1400 */ 130, 170, 260, 170, 38, 81, 257, 257, 170, 104,
146498
+ /* 1410 */ 36, 22, 43, 201, 90, 236, 138, 235, 213, 18,
146499
+ /* 1420 */ 96, 97, 48, 204, 204, 204, 204, 103, 170, 105,
146500
+ /* 1430 */ 106, 107, 18, 59, 110, 169, 213, 213, 201, 170,
146501
+ /* 1440 */ 201, 169, 236, 213, 146, 71, 235, 62, 253, 252,
146502
+ /* 1450 */ 170, 127, 128, 169, 22, 170, 82, 189, 169, 104,
146503
+ /* 1460 */ 170, 87, 169, 189, 90, 141, 142, 143, 144, 145,
146504
+ /* 1470 */ 96, 97, 186, 186, 186, 64, 194, 103, 186, 105,
146505
+ /* 1480 */ 106, 107, 115, 189, 110, 188, 186, 186, 19, 20,
146506
+ /* 1490 */ 194, 22, 186, 189, 102, 246, 246, 189, 133, 228,
146507
+ /* 1500 */ 104, 228, 227, 227, 170, 36, 134, 228, 227, 19,
146508
+ /* 1510 */ 20, 228, 22, 84, 271, 141, 142, 143, 144, 145,
146509
+ /* 1520 */ 0, 1, 2, 216, 22, 5, 36, 137, 59, 227,
146510
+ /* 1530 */ 10, 11, 12, 13, 14, 217, 269, 17, 216, 22,
146511
+ /* 1540 */ 71, 170, 243, 146, 241, 217, 136, 215, 135, 59,
146512
+ /* 1550 */ 30, 82, 32, 25, 214, 213, 87, 173, 26, 90,
146513
+ /* 1560 */ 40, 71, 13, 172, 164, 96, 97, 164, 6, 162,
146514
+ /* 1570 */ 162, 162, 103, 263, 105, 106, 107, 266, 266, 110,
146515
+ /* 1580 */ 90, 176, 176, 190, 182, 190, 96, 97, 98, 4,
146516
+ /* 1590 */ 70, 176, 3, 103, 182, 105, 106, 107, 78, 182,
146517
+ /* 1600 */ 110, 81, 182, 182, 182, 182, 182, 151, 88, 22,
146518
+ /* 1610 */ 141, 142, 143, 144, 145, 15, 89, 16, 23, 23,
146519
+ /* 1620 */ 128, 19, 20, 139, 22, 119, 131, 24, 20, 133,
146520
+ /* 1630 */ 16, 141, 142, 143, 144, 145, 1, 140, 36, 131,
146521
+ /* 1640 */ 119, 61, 122, 37, 139, 53, 53, 127, 128, 119,
146522
+ /* 1650 */ 53, 53, 105, 34, 130, 1, 5, 104, 22, 149,
146523
+ /* 1660 */ 26, 59, 68, 75, 41, 130, 24, 68, 104, 20,
146524
+ /* 1670 */ 150, 19, 120, 71, 114, 22, 67, 22, 22, 67,
146525
+ /* 1680 */ 23, 22, 22, 67, 82, 37, 28, 23, 138, 87,
146526
+ /* 1690 */ 22, 153, 90, 23, 23, 26, 23, 22, 96, 97,
146527
+ /* 1700 */ 24, 23, 22, 24, 130, 103, 23, 105, 106, 107,
146528
+ /* 1710 */ 1, 2, 110, 23, 5, 105, 34, 22, 132, 10,
146529
+ /* 1720 */ 11, 12, 13, 14, 26, 34, 17, 34, 85, 83,
146530
+ /* 1730 */ 44, 19, 20, 23, 22, 24, 75, 34, 23, 30,
146531
+ /* 1740 */ 26, 32, 26, 141, 142, 143, 144, 145, 36, 40,
146532
+ /* 1750 */ 23, 23, 23, 23, 11, 23, 22, 26, 22, 22,
146533
+ /* 1760 */ 22, 19, 20, 23, 22, 26, 15, 23, 22, 124,
146534
+ /* 1770 */ 130, 59, 23, 1, 130, 277, 277, 130, 36, 70,
146535
+ /* 1780 */ 130, 277, 277, 71, 277, 277, 277, 78, 277, 277,
145586146536
/* 1790 */ 81, 277, 277, 277, 277, 277, 277, 88, 277, 277,
145587146537
/* 1800 */ 277, 59, 90, 277, 277, 277, 277, 277, 96, 97,
145588146538
/* 1810 */ 277, 277, 277, 71, 277, 103, 277, 105, 106, 107,
145589146539
/* 1820 */ 277, 277, 110, 277, 277, 277, 277, 277, 277, 277,
145590146540
/* 1830 */ 277, 122, 90, 277, 277, 277, 127, 128, 96, 97,
@@ -145605,11 +146555,11 @@
145605146555
/* 1980 */ 122, 277, 277, 277, 277, 127, 128, 277, 277, 277,
145606146556
/* 1990 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
145607146557
/* 2000 */ 277, 277, 277, 277, 277, 277, 277, 277, 150, 277,
145608146558
/* 2010 */ 277, 277, 277, 277, 277, 277, 277, 277, 277,
145609146559
};
145610
-#define YY_SHIFT_COUNT (517)
146560
+#define YY_SHIFT_COUNT (520)
145611146561
#define YY_SHIFT_MIN (0)
145612146562
#define YY_SHIFT_MAX (1858)
145613146563
static const unsigned short int yy_shift_ofst[] = {
145614146564
/* 0 */ 1709, 1520, 1858, 1324, 1324, 277, 1374, 1469, 1602, 1712,
145615146565
/* 10 */ 1712, 1712, 273, 0, 0, 113, 1016, 1712, 1712, 1712,
@@ -145629,46 +146579,47 @@
145629146579
/* 150 */ 597, 464, 474, 262, 681, 531, 531, 531, 531, 531,
145630146580
/* 160 */ 531, 531, 531, 531, 531, 531, 531, 531, 531, 531,
145631146581
/* 170 */ 531, 531, 531, 531, 531, 531, 531, 173, 485, 984,
145632146582
/* 180 */ 984, 576, 485, 19, 1022, 2009, 2009, 2009, 387, 250,
145633146583
/* 190 */ 250, 525, 502, 278, 552, 227, 480, 566, 531, 531,
145634
- /* 200 */ 531, 531, 531, 531, 531, 531, 639, 531, 531, 531,
145635
- /* 210 */ 531, 531, 531, 531, 531, 531, 531, 531, 531, 2,
145636
- /* 220 */ 2, 2, 531, 531, 531, 531, 782, 531, 531, 531,
145637
- /* 230 */ 744, 531, 531, 783, 531, 531, 531, 531, 531, 531,
145638
- /* 240 */ 531, 531, 419, 682, 327, 370, 370, 370, 370, 1029,
145639
- /* 250 */ 327, 327, 1024, 897, 856, 1109, 706, 706, 1143, 1109,
145640
- /* 260 */ 1109, 1143, 842, 945, 1118, 1136, 1136, 1136, 706, 676,
145641
- /* 270 */ 400, 878, 694, 1327, 1258, 1258, 1359, 1359, 1258, 1296,
145642
- /* 280 */ 1381, 1363, 1269, 1390, 1390, 1390, 1390, 1258, 1400, 1269,
145643
- /* 290 */ 1269, 1296, 1381, 1363, 1363, 1269, 1258, 1400, 1294, 1379,
145644
- /* 300 */ 1258, 1400, 1425, 1258, 1400, 1258, 1400, 1425, 1353, 1353,
145645
- /* 310 */ 1353, 1394, 1425, 1353, 1348, 1353, 1394, 1353, 1353, 1425,
145646
- /* 320 */ 1384, 1384, 1425, 1360, 1391, 1360, 1391, 1360, 1391, 1360,
145647
- /* 330 */ 1391, 1258, 1365, 1410, 1475, 1366, 1365, 1482, 1258, 1367,
145648
- /* 340 */ 1366, 1378, 1389, 1269, 1521, 1527, 1534, 1534, 1549, 1549,
145649
- /* 350 */ 1549, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
145650
- /* 360 */ 2009, 2009, 2009, 2009, 2009, 2009, 2009, 570, 345, 686,
145651
- /* 370 */ 748, 50, 740, 1064, 1107, 469, 537, 1036, 1146, 1162,
145652
- /* 380 */ 1154, 1155, 1156, 1180, 1201, 1202, 903, 1076, 1197, 1157,
145653
- /* 390 */ 1167, 1206, 1207, 1208, 775, 1030, 1226, 1227, 1176, 1138,
145654
- /* 400 */ 1579, 1581, 1570, 1452, 1589, 1516, 1590, 1584, 1586, 1487,
145655
- /* 410 */ 1477, 1498, 1594, 1488, 1600, 1492, 1607, 1625, 1496, 1489,
145656
- /* 420 */ 1509, 1569, 1599, 1500, 1587, 1588, 1591, 1592, 1518, 1538,
145657
- /* 430 */ 1612, 1519, 1649, 1646, 1630, 1550, 1504, 1595, 1629, 1596,
145658
- /* 440 */ 1582, 1615, 1528, 1555, 1636, 1642, 1647, 1545, 1553, 1650,
145659
- /* 450 */ 1601, 1652, 1653, 1648, 1654, 1610, 1641, 1656, 1613, 1644,
145660
- /* 460 */ 1659, 1541, 1661, 1532, 1663, 1664, 1662, 1667, 1669, 1670,
145661
- /* 470 */ 1672, 1671, 1673, 1566, 1677, 1678, 1597, 1679, 1681, 1572,
145662
- /* 480 */ 1680, 1682, 1680, 1683, 1633, 1640, 1645, 1685, 1701, 1703,
145663
- /* 490 */ 1699, 1704, 1702, 1710, 1680, 1714, 1715, 1717, 1719, 1724,
145664
- /* 500 */ 1728, 1713, 1741, 1731, 1732, 1733, 1734, 1736, 1737, 1729,
145665
- /* 510 */ 1639, 1635, 1637, 1638, 1643, 1743, 1745, 1768,
146584
+ /* 200 */ 531, 531, 531, 531, 531, 531, 531, 531, 639, 531,
146585
+ /* 210 */ 531, 531, 531, 531, 531, 531, 531, 531, 531, 531,
146586
+ /* 220 */ 531, 2, 2, 2, 531, 531, 531, 531, 782, 531,
146587
+ /* 230 */ 531, 531, 744, 531, 531, 783, 531, 531, 531, 531,
146588
+ /* 240 */ 531, 531, 531, 531, 419, 682, 327, 370, 370, 370,
146589
+ /* 250 */ 370, 1029, 327, 327, 1024, 897, 856, 947, 1109, 706,
146590
+ /* 260 */ 706, 1143, 1109, 1109, 1143, 842, 945, 1118, 1136, 1136,
146591
+ /* 270 */ 1136, 706, 676, 400, 1047, 694, 1339, 1270, 1270, 1366,
146592
+ /* 280 */ 1366, 1270, 1305, 1389, 1369, 1278, 1401, 1401, 1401, 1401,
146593
+ /* 290 */ 1270, 1414, 1278, 1278, 1305, 1389, 1369, 1369, 1278, 1270,
146594
+ /* 300 */ 1414, 1298, 1385, 1270, 1414, 1432, 1270, 1414, 1270, 1414,
146595
+ /* 310 */ 1432, 1355, 1355, 1355, 1411, 1432, 1355, 1367, 1355, 1411,
146596
+ /* 320 */ 1355, 1355, 1432, 1392, 1392, 1432, 1365, 1396, 1365, 1396,
146597
+ /* 330 */ 1365, 1396, 1365, 1396, 1270, 1372, 1429, 1502, 1390, 1372,
146598
+ /* 340 */ 1517, 1270, 1397, 1390, 1410, 1413, 1278, 1528, 1532, 1549,
146599
+ /* 350 */ 1549, 1562, 1562, 1562, 2009, 2009, 2009, 2009, 2009, 2009,
146600
+ /* 360 */ 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
146601
+ /* 370 */ 570, 345, 686, 748, 50, 740, 1064, 1107, 469, 537,
146602
+ /* 380 */ 1042, 1146, 1162, 1154, 1201, 1202, 1203, 1208, 1209, 1127,
146603
+ /* 390 */ 1069, 1196, 1157, 1147, 1226, 1228, 1245, 775, 868, 1246,
146604
+ /* 400 */ 1247, 1191, 1151, 1585, 1589, 1587, 1456, 1600, 1527, 1601,
146605
+ /* 410 */ 1595, 1596, 1492, 1484, 1506, 1603, 1495, 1608, 1496, 1614,
146606
+ /* 420 */ 1635, 1508, 1497, 1521, 1580, 1606, 1505, 1592, 1593, 1597,
146607
+ /* 430 */ 1598, 1530, 1547, 1619, 1524, 1654, 1651, 1636, 1553, 1510,
146608
+ /* 440 */ 1594, 1634, 1599, 1588, 1623, 1535, 1564, 1642, 1649, 1652,
146609
+ /* 450 */ 1552, 1560, 1653, 1609, 1655, 1656, 1657, 1659, 1612, 1658,
146610
+ /* 460 */ 1660, 1616, 1648, 1664, 1550, 1668, 1538, 1670, 1671, 1669,
146611
+ /* 470 */ 1673, 1675, 1676, 1678, 1680, 1679, 1574, 1683, 1690, 1610,
146612
+ /* 480 */ 1682, 1695, 1586, 1698, 1691, 1698, 1693, 1643, 1661, 1646,
146613
+ /* 490 */ 1686, 1710, 1711, 1714, 1716, 1703, 1715, 1698, 1727, 1728,
146614
+ /* 500 */ 1729, 1730, 1731, 1732, 1734, 1743, 1736, 1737, 1740, 1744,
146615
+ /* 510 */ 1738, 1746, 1739, 1645, 1640, 1644, 1647, 1650, 1749, 1751,
146616
+ /* 520 */ 1772,
145666146617
};
145667
-#define YY_REDUCE_COUNT (366)
146618
+#define YY_REDUCE_COUNT (369)
145668146619
#define YY_REDUCE_MIN (-237)
145669
-#define YY_REDUCE_MAX (1420)
146620
+#define YY_REDUCE_MAX (1424)
145670146621
static const short yy_reduce_ofst[] = {
145671146622
/* 0 */ -147, 171, 263, -96, 358, -144, -149, -102, 124, -156,
145672146623
/* 10 */ -98, 305, 401, -57, 209, -237, 245, -94, -79, 189,
145673146624
/* 20 */ 375, 490, 493, 378, 303, 539, 542, 501, 503, 554,
145674146625
/* 30 */ 415, 526, 546, 557, 587, 593, 595, -234, -234, -234,
@@ -145686,81 +146637,82 @@
145686146637
/* 150 */ 364, 41, 513, 509, 509, 117, 500, 789, 796, 646,
145687146638
/* 160 */ 192, 291, 644, 798, 120, 807, 543, 911, 920, 652,
145688146639
/* 170 */ 924, 922, 232, 698, 801, 971, 39, 220, 731, 442,
145689146640
/* 180 */ 902, -199, 979, -43, 421, 896, 942, 605, -184, -126,
145690146641
/* 190 */ 155, 172, 281, 304, 377, 538, 650, 690, 699, 723,
145691
- /* 200 */ 803, 853, 919, 1088, 1091, 1092, 777, 1106, 1108, 1111,
145692
- /* 210 */ 1112, 1115, 1116, 1117, 1120, 1121, 1122, 1123, 1124, 1077,
145693
- /* 220 */ 1079, 1095, 1126, 1127, 1128, 1129, 1056, 1130, 1131, 1132,
145694
- /* 230 */ 1075, 1135, 1137, 1096, 1152, 304, 1153, 1158, 1172, 1173,
145695
- /* 240 */ 1174, 1175, 1066, 1068, 1110, 1098, 1119, 1125, 1139, 1056,
145696
- /* 250 */ 1110, 1110, 1170, 1160, 1178, 1149, 1114, 1140, 1089, 1150,
145697
- /* 260 */ 1151, 1133, 1177, 1171, 1189, 1161, 1181, 1195, 1159, 1142,
145698
- /* 270 */ 1179, 1182, 1218, 1141, 1220, 1228, 1145, 1147, 1229, 1183,
145699
- /* 280 */ 1188, 1210, 1196, 1209, 1211, 1212, 1213, 1242, 1255, 1215,
145700
- /* 290 */ 1219, 1190, 1200, 1224, 1235, 1225, 1267, 1270, 1191, 1194,
145701
- /* 300 */ 1272, 1274, 1259, 1279, 1281, 1283, 1285, 1266, 1273, 1276,
145702
- /* 310 */ 1286, 1280, 1271, 1287, 1288, 1289, 1284, 1297, 1299, 1293,
145703
- /* 320 */ 1241, 1244, 1303, 1268, 1275, 1278, 1300, 1295, 1302, 1307,
145704
- /* 330 */ 1309, 1328, 1291, 1230, 1231, 1321, 1292, 1298, 1341, 1301,
145705
- /* 340 */ 1325, 1326, 1329, 1332, 1375, 1382, 1393, 1398, 1396, 1401,
145706
- /* 350 */ 1402, 1304, 1305, 1306, 1392, 1385, 1395, 1399, 1403, 1397,
145707
- /* 360 */ 1388, 1404, 1407, 1409, 1417, 1420, 1406,
146642
+ /* 200 */ 803, 839, 853, 919, 991, 1018, 1067, 1092, 951, 1111,
146643
+ /* 210 */ 1112, 1115, 1116, 1117, 1119, 1120, 1121, 1122, 1123, 1124,
146644
+ /* 220 */ 1125, 1012, 1096, 1097, 1128, 1129, 1130, 1131, 1070, 1135,
146645
+ /* 230 */ 1137, 1152, 1077, 1153, 1155, 1114, 1156, 304, 1158, 1172,
146646
+ /* 240 */ 1173, 1174, 1175, 1176, 1089, 1091, 1133, 1098, 1126, 1139,
146647
+ /* 250 */ 1140, 1070, 1133, 1133, 1170, 1163, 1186, 1103, 1168, 1138,
146648
+ /* 260 */ 1141, 1110, 1169, 1171, 1132, 1177, 1189, 1194, 1181, 1200,
146649
+ /* 270 */ 1204, 1166, 1145, 1178, 1187, 1232, 1142, 1231, 1233, 1149,
146650
+ /* 280 */ 1150, 1238, 1179, 1182, 1212, 1205, 1219, 1220, 1221, 1222,
146651
+ /* 290 */ 1258, 1266, 1223, 1224, 1206, 1211, 1237, 1239, 1230, 1269,
146652
+ /* 300 */ 1272, 1195, 1197, 1280, 1284, 1268, 1285, 1289, 1290, 1293,
146653
+ /* 310 */ 1274, 1286, 1287, 1288, 1282, 1294, 1292, 1297, 1300, 1296,
146654
+ /* 320 */ 1301, 1306, 1304, 1249, 1250, 1308, 1271, 1275, 1273, 1276,
146655
+ /* 330 */ 1279, 1281, 1283, 1302, 1334, 1307, 1243, 1267, 1318, 1322,
146656
+ /* 340 */ 1303, 1371, 1299, 1328, 1332, 1340, 1342, 1384, 1391, 1400,
146657
+ /* 350 */ 1403, 1407, 1408, 1409, 1311, 1312, 1310, 1405, 1402, 1412,
146658
+ /* 360 */ 1417, 1420, 1406, 1393, 1395, 1421, 1422, 1423, 1424, 1415,
145708146659
};
145709146660
static const YYACTIONTYPE yy_default[] = {
145710
- /* 0 */ 1486, 1486, 1486, 1335, 1118, 1224, 1118, 1118, 1118, 1335,
145711
- /* 10 */ 1335, 1335, 1118, 1254, 1254, 1386, 1149, 1118, 1118, 1118,
145712
- /* 20 */ 1118, 1118, 1118, 1118, 1334, 1118, 1118, 1118, 1118, 1118,
145713
- /* 30 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1260, 1118,
145714
- /* 40 */ 1118, 1118, 1118, 1118, 1336, 1337, 1118, 1118, 1118, 1385,
145715
- /* 50 */ 1387, 1270, 1269, 1268, 1267, 1368, 1241, 1265, 1258, 1262,
145716
- /* 60 */ 1330, 1331, 1329, 1333, 1337, 1336, 1118, 1261, 1301, 1315,
145717
- /* 70 */ 1300, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145718
- /* 80 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145719
- /* 90 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145720
- /* 100 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145721
- /* 110 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1309, 1314, 1320,
145722
- /* 120 */ 1313, 1310, 1303, 1302, 1304, 1305, 1118, 1139, 1188, 1118,
145723
- /* 130 */ 1118, 1118, 1118, 1403, 1402, 1118, 1118, 1149, 1306, 1307,
145724
- /* 140 */ 1317, 1316, 1393, 1442, 1441, 1118, 1118, 1118, 1118, 1118,
145725
- /* 150 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145726
- /* 160 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145727
- /* 170 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1149, 1145, 1295,
145728
- /* 180 */ 1294, 1412, 1145, 1248, 1118, 1398, 1224, 1215, 1118, 1118,
145729
- /* 190 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1390,
145730
- /* 200 */ 1388, 1118, 1350, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145731
- /* 210 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145732
- /* 220 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145733
- /* 230 */ 1220, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145734
- /* 240 */ 1118, 1436, 1118, 1363, 1202, 1220, 1220, 1220, 1220, 1222,
145735
- /* 250 */ 1203, 1201, 1214, 1149, 1125, 1264, 1243, 1243, 1475, 1264,
145736
- /* 260 */ 1264, 1475, 1163, 1456, 1160, 1254, 1254, 1254, 1243, 1332,
145737
- /* 270 */ 1221, 1214, 1118, 1478, 1229, 1229, 1477, 1477, 1229, 1273,
145738
- /* 280 */ 1279, 1191, 1264, 1197, 1197, 1197, 1197, 1229, 1136, 1264,
145739
- /* 290 */ 1264, 1273, 1279, 1191, 1191, 1264, 1229, 1136, 1367, 1472,
145740
- /* 300 */ 1229, 1136, 1343, 1229, 1136, 1229, 1136, 1343, 1189, 1189,
145741
- /* 310 */ 1189, 1178, 1343, 1189, 1163, 1189, 1178, 1189, 1189, 1343,
145742
- /* 320 */ 1347, 1347, 1343, 1247, 1242, 1247, 1242, 1247, 1242, 1247,
145743
- /* 330 */ 1242, 1229, 1248, 1411, 1118, 1259, 1248, 1338, 1229, 1118,
145744
- /* 340 */ 1259, 1257, 1255, 1264, 1142, 1181, 1439, 1439, 1435, 1435,
145745
- /* 350 */ 1435, 1483, 1483, 1398, 1451, 1149, 1149, 1149, 1149, 1451,
145746
- /* 360 */ 1165, 1165, 1149, 1149, 1149, 1149, 1451, 1118, 1118, 1118,
145747
- /* 370 */ 1118, 1118, 1118, 1446, 1118, 1352, 1233, 1118, 1118, 1118,
145748
- /* 380 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145749
- /* 390 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1284,
145750
- /* 400 */ 1118, 1121, 1395, 1118, 1118, 1394, 1118, 1118, 1118, 1118,
145751
- /* 410 */ 1118, 1118, 1234, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145752
- /* 420 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145753
- /* 430 */ 1118, 1474, 1118, 1118, 1118, 1118, 1118, 1118, 1366, 1365,
145754
- /* 440 */ 1118, 1118, 1231, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145755
- /* 450 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145756
- /* 460 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145757
- /* 470 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145758
- /* 480 */ 1256, 1118, 1410, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145759
- /* 490 */ 1424, 1249, 1118, 1118, 1465, 1118, 1118, 1118, 1118, 1118,
145760
- /* 500 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1460,
145761
- /* 510 */ 1205, 1286, 1118, 1285, 1289, 1118, 1130, 1118,
146661
+ /* 0 */ 1492, 1492, 1492, 1340, 1123, 1229, 1123, 1123, 1123, 1340,
146662
+ /* 10 */ 1340, 1340, 1123, 1259, 1259, 1391, 1154, 1123, 1123, 1123,
146663
+ /* 20 */ 1123, 1123, 1123, 1123, 1339, 1123, 1123, 1123, 1123, 1123,
146664
+ /* 30 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1265, 1123,
146665
+ /* 40 */ 1123, 1123, 1123, 1123, 1341, 1342, 1123, 1123, 1123, 1390,
146666
+ /* 50 */ 1392, 1275, 1274, 1273, 1272, 1373, 1246, 1270, 1263, 1267,
146667
+ /* 60 */ 1335, 1336, 1334, 1338, 1342, 1341, 1123, 1266, 1306, 1320,
146668
+ /* 70 */ 1305, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146669
+ /* 80 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146670
+ /* 90 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146671
+ /* 100 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146672
+ /* 110 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1314, 1319, 1325,
146673
+ /* 120 */ 1318, 1315, 1308, 1307, 1309, 1310, 1123, 1144, 1193, 1123,
146674
+ /* 130 */ 1123, 1123, 1123, 1409, 1408, 1123, 1123, 1154, 1311, 1312,
146675
+ /* 140 */ 1322, 1321, 1398, 1448, 1447, 1123, 1123, 1123, 1123, 1123,
146676
+ /* 150 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146677
+ /* 160 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146678
+ /* 170 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1154, 1150, 1300,
146679
+ /* 180 */ 1299, 1418, 1150, 1253, 1123, 1404, 1229, 1220, 1123, 1123,
146680
+ /* 190 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146681
+ /* 200 */ 1123, 1395, 1393, 1123, 1355, 1123, 1123, 1123, 1123, 1123,
146682
+ /* 210 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146683
+ /* 220 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146684
+ /* 230 */ 1123, 1123, 1225, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146685
+ /* 240 */ 1123, 1123, 1123, 1442, 1123, 1368, 1207, 1225, 1225, 1225,
146686
+ /* 250 */ 1225, 1227, 1208, 1206, 1219, 1154, 1130, 1484, 1269, 1248,
146687
+ /* 260 */ 1248, 1481, 1269, 1269, 1481, 1168, 1462, 1165, 1259, 1259,
146688
+ /* 270 */ 1259, 1248, 1337, 1226, 1219, 1123, 1484, 1234, 1234, 1483,
146689
+ /* 280 */ 1483, 1234, 1278, 1284, 1196, 1269, 1202, 1202, 1202, 1202,
146690
+ /* 290 */ 1234, 1141, 1269, 1269, 1278, 1284, 1196, 1196, 1269, 1234,
146691
+ /* 300 */ 1141, 1372, 1478, 1234, 1141, 1348, 1234, 1141, 1234, 1141,
146692
+ /* 310 */ 1348, 1194, 1194, 1194, 1183, 1348, 1194, 1168, 1194, 1183,
146693
+ /* 320 */ 1194, 1194, 1348, 1352, 1352, 1348, 1252, 1247, 1252, 1247,
146694
+ /* 330 */ 1252, 1247, 1252, 1247, 1234, 1253, 1417, 1123, 1264, 1253,
146695
+ /* 340 */ 1343, 1234, 1123, 1264, 1262, 1260, 1269, 1147, 1186, 1445,
146696
+ /* 350 */ 1445, 1441, 1441, 1441, 1489, 1489, 1404, 1457, 1154, 1154,
146697
+ /* 360 */ 1154, 1154, 1457, 1170, 1170, 1154, 1154, 1154, 1154, 1457,
146698
+ /* 370 */ 1123, 1123, 1123, 1123, 1123, 1123, 1452, 1123, 1357, 1238,
146699
+ /* 380 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146700
+ /* 390 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146701
+ /* 400 */ 1123, 1123, 1289, 1123, 1126, 1401, 1123, 1123, 1399, 1123,
146702
+ /* 410 */ 1123, 1123, 1123, 1123, 1123, 1239, 1123, 1123, 1123, 1123,
146703
+ /* 420 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146704
+ /* 430 */ 1123, 1123, 1123, 1123, 1480, 1123, 1123, 1123, 1123, 1123,
146705
+ /* 440 */ 1123, 1371, 1370, 1123, 1123, 1236, 1123, 1123, 1123, 1123,
146706
+ /* 450 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146707
+ /* 460 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146708
+ /* 470 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146709
+ /* 480 */ 1123, 1123, 1123, 1261, 1123, 1416, 1123, 1123, 1123, 1123,
146710
+ /* 490 */ 1123, 1123, 1123, 1430, 1254, 1123, 1123, 1471, 1123, 1123,
146711
+ /* 500 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146712
+ /* 510 */ 1123, 1123, 1466, 1210, 1291, 1123, 1290, 1294, 1123, 1135,
146713
+ /* 520 */ 1123,
145762146714
};
145763146715
/********** End of lemon-generated parsing tables *****************************/
145764146716
145765146717
/* The next table maps tokens (terminal symbols) into fallback tokens.
145766146718
** If a construct like the following:
@@ -146512,102 +147464,103 @@
146512147464
/* 269 */ "cmd ::= ANALYZE",
146513147465
/* 270 */ "cmd ::= ANALYZE nm dbnm",
146514147466
/* 271 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
146515147467
/* 272 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
146516147468
/* 273 */ "add_column_fullname ::= fullname",
146517
- /* 274 */ "cmd ::= create_vtab",
146518
- /* 275 */ "cmd ::= create_vtab LP vtabarglist RP",
146519
- /* 276 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
146520
- /* 277 */ "vtabarg ::=",
146521
- /* 278 */ "vtabargtoken ::= ANY",
146522
- /* 279 */ "vtabargtoken ::= lp anylist RP",
146523
- /* 280 */ "lp ::= LP",
146524
- /* 281 */ "with ::= WITH wqlist",
146525
- /* 282 */ "with ::= WITH RECURSIVE wqlist",
146526
- /* 283 */ "wqlist ::= nm eidlist_opt AS LP select RP",
146527
- /* 284 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
146528
- /* 285 */ "windowdefn_list ::= windowdefn",
146529
- /* 286 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
146530
- /* 287 */ "windowdefn ::= nm AS window",
146531
- /* 288 */ "window ::= LP part_opt orderby_opt frame_opt RP",
146532
- /* 289 */ "part_opt ::= PARTITION BY nexprlist",
146533
- /* 290 */ "part_opt ::=",
146534
- /* 291 */ "frame_opt ::=",
146535
- /* 292 */ "frame_opt ::= range_or_rows frame_bound_s",
146536
- /* 293 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e",
146537
- /* 294 */ "range_or_rows ::= RANGE",
146538
- /* 295 */ "range_or_rows ::= ROWS",
146539
- /* 296 */ "frame_bound_s ::= frame_bound",
146540
- /* 297 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
146541
- /* 298 */ "frame_bound_e ::= frame_bound",
146542
- /* 299 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
146543
- /* 300 */ "frame_bound ::= expr PRECEDING",
146544
- /* 301 */ "frame_bound ::= CURRENT ROW",
146545
- /* 302 */ "frame_bound ::= expr FOLLOWING",
146546
- /* 303 */ "window_clause ::= WINDOW windowdefn_list",
146547
- /* 304 */ "over_clause ::= filter_opt OVER window",
146548
- /* 305 */ "over_clause ::= filter_opt OVER nm",
146549
- /* 306 */ "filter_opt ::=",
146550
- /* 307 */ "filter_opt ::= FILTER LP WHERE expr RP",
146551
- /* 308 */ "input ::= cmdlist",
146552
- /* 309 */ "cmdlist ::= cmdlist ecmd",
146553
- /* 310 */ "cmdlist ::= ecmd",
146554
- /* 311 */ "ecmd ::= SEMI",
146555
- /* 312 */ "ecmd ::= cmdx SEMI",
146556
- /* 313 */ "ecmd ::= explain cmdx",
146557
- /* 314 */ "trans_opt ::=",
146558
- /* 315 */ "trans_opt ::= TRANSACTION",
146559
- /* 316 */ "trans_opt ::= TRANSACTION nm",
146560
- /* 317 */ "savepoint_opt ::= SAVEPOINT",
146561
- /* 318 */ "savepoint_opt ::=",
146562
- /* 319 */ "cmd ::= create_table create_table_args",
146563
- /* 320 */ "columnlist ::= columnlist COMMA columnname carglist",
146564
- /* 321 */ "columnlist ::= columnname carglist",
146565
- /* 322 */ "nm ::= ID|INDEXED",
146566
- /* 323 */ "nm ::= STRING",
146567
- /* 324 */ "nm ::= JOIN_KW",
146568
- /* 325 */ "typetoken ::= typename",
146569
- /* 326 */ "typename ::= ID|STRING",
146570
- /* 327 */ "signed ::= plus_num",
146571
- /* 328 */ "signed ::= minus_num",
146572
- /* 329 */ "carglist ::= carglist ccons",
146573
- /* 330 */ "carglist ::=",
146574
- /* 331 */ "ccons ::= NULL onconf",
146575
- /* 332 */ "conslist_opt ::= COMMA conslist",
146576
- /* 333 */ "conslist ::= conslist tconscomma tcons",
146577
- /* 334 */ "conslist ::= tcons",
146578
- /* 335 */ "tconscomma ::=",
146579
- /* 336 */ "defer_subclause_opt ::= defer_subclause",
146580
- /* 337 */ "resolvetype ::= raisetype",
146581
- /* 338 */ "selectnowith ::= oneselect",
146582
- /* 339 */ "oneselect ::= values",
146583
- /* 340 */ "sclp ::= selcollist COMMA",
146584
- /* 341 */ "as ::= ID|STRING",
146585
- /* 342 */ "expr ::= term",
146586
- /* 343 */ "likeop ::= LIKE_KW|MATCH",
146587
- /* 344 */ "exprlist ::= nexprlist",
146588
- /* 345 */ "nmnum ::= plus_num",
146589
- /* 346 */ "nmnum ::= nm",
146590
- /* 347 */ "nmnum ::= ON",
146591
- /* 348 */ "nmnum ::= DELETE",
146592
- /* 349 */ "nmnum ::= DEFAULT",
146593
- /* 350 */ "plus_num ::= INTEGER|FLOAT",
146594
- /* 351 */ "foreach_clause ::=",
146595
- /* 352 */ "foreach_clause ::= FOR EACH ROW",
146596
- /* 353 */ "trnm ::= nm",
146597
- /* 354 */ "tridxby ::=",
146598
- /* 355 */ "database_kw_opt ::= DATABASE",
146599
- /* 356 */ "database_kw_opt ::=",
146600
- /* 357 */ "kwcolumn_opt ::=",
146601
- /* 358 */ "kwcolumn_opt ::= COLUMNKW",
146602
- /* 359 */ "vtabarglist ::= vtabarg",
146603
- /* 360 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
146604
- /* 361 */ "vtabarg ::= vtabarg vtabargtoken",
146605
- /* 362 */ "anylist ::=",
146606
- /* 363 */ "anylist ::= anylist LP anylist RP",
146607
- /* 364 */ "anylist ::= anylist ANY",
146608
- /* 365 */ "with ::=",
147469
+ /* 274 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
147470
+ /* 275 */ "cmd ::= create_vtab",
147471
+ /* 276 */ "cmd ::= create_vtab LP vtabarglist RP",
147472
+ /* 277 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
147473
+ /* 278 */ "vtabarg ::=",
147474
+ /* 279 */ "vtabargtoken ::= ANY",
147475
+ /* 280 */ "vtabargtoken ::= lp anylist RP",
147476
+ /* 281 */ "lp ::= LP",
147477
+ /* 282 */ "with ::= WITH wqlist",
147478
+ /* 283 */ "with ::= WITH RECURSIVE wqlist",
147479
+ /* 284 */ "wqlist ::= nm eidlist_opt AS LP select RP",
147480
+ /* 285 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
147481
+ /* 286 */ "windowdefn_list ::= windowdefn",
147482
+ /* 287 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
147483
+ /* 288 */ "windowdefn ::= nm AS window",
147484
+ /* 289 */ "window ::= LP part_opt orderby_opt frame_opt RP",
147485
+ /* 290 */ "part_opt ::= PARTITION BY nexprlist",
147486
+ /* 291 */ "part_opt ::=",
147487
+ /* 292 */ "frame_opt ::=",
147488
+ /* 293 */ "frame_opt ::= range_or_rows frame_bound_s",
147489
+ /* 294 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e",
147490
+ /* 295 */ "range_or_rows ::= RANGE",
147491
+ /* 296 */ "range_or_rows ::= ROWS",
147492
+ /* 297 */ "frame_bound_s ::= frame_bound",
147493
+ /* 298 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
147494
+ /* 299 */ "frame_bound_e ::= frame_bound",
147495
+ /* 300 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
147496
+ /* 301 */ "frame_bound ::= expr PRECEDING",
147497
+ /* 302 */ "frame_bound ::= CURRENT ROW",
147498
+ /* 303 */ "frame_bound ::= expr FOLLOWING",
147499
+ /* 304 */ "window_clause ::= WINDOW windowdefn_list",
147500
+ /* 305 */ "over_clause ::= filter_opt OVER window",
147501
+ /* 306 */ "over_clause ::= filter_opt OVER nm",
147502
+ /* 307 */ "filter_opt ::=",
147503
+ /* 308 */ "filter_opt ::= FILTER LP WHERE expr RP",
147504
+ /* 309 */ "input ::= cmdlist",
147505
+ /* 310 */ "cmdlist ::= cmdlist ecmd",
147506
+ /* 311 */ "cmdlist ::= ecmd",
147507
+ /* 312 */ "ecmd ::= SEMI",
147508
+ /* 313 */ "ecmd ::= cmdx SEMI",
147509
+ /* 314 */ "ecmd ::= explain cmdx",
147510
+ /* 315 */ "trans_opt ::=",
147511
+ /* 316 */ "trans_opt ::= TRANSACTION",
147512
+ /* 317 */ "trans_opt ::= TRANSACTION nm",
147513
+ /* 318 */ "savepoint_opt ::= SAVEPOINT",
147514
+ /* 319 */ "savepoint_opt ::=",
147515
+ /* 320 */ "cmd ::= create_table create_table_args",
147516
+ /* 321 */ "columnlist ::= columnlist COMMA columnname carglist",
147517
+ /* 322 */ "columnlist ::= columnname carglist",
147518
+ /* 323 */ "nm ::= ID|INDEXED",
147519
+ /* 324 */ "nm ::= STRING",
147520
+ /* 325 */ "nm ::= JOIN_KW",
147521
+ /* 326 */ "typetoken ::= typename",
147522
+ /* 327 */ "typename ::= ID|STRING",
147523
+ /* 328 */ "signed ::= plus_num",
147524
+ /* 329 */ "signed ::= minus_num",
147525
+ /* 330 */ "carglist ::= carglist ccons",
147526
+ /* 331 */ "carglist ::=",
147527
+ /* 332 */ "ccons ::= NULL onconf",
147528
+ /* 333 */ "conslist_opt ::= COMMA conslist",
147529
+ /* 334 */ "conslist ::= conslist tconscomma tcons",
147530
+ /* 335 */ "conslist ::= tcons",
147531
+ /* 336 */ "tconscomma ::=",
147532
+ /* 337 */ "defer_subclause_opt ::= defer_subclause",
147533
+ /* 338 */ "resolvetype ::= raisetype",
147534
+ /* 339 */ "selectnowith ::= oneselect",
147535
+ /* 340 */ "oneselect ::= values",
147536
+ /* 341 */ "sclp ::= selcollist COMMA",
147537
+ /* 342 */ "as ::= ID|STRING",
147538
+ /* 343 */ "expr ::= term",
147539
+ /* 344 */ "likeop ::= LIKE_KW|MATCH",
147540
+ /* 345 */ "exprlist ::= nexprlist",
147541
+ /* 346 */ "nmnum ::= plus_num",
147542
+ /* 347 */ "nmnum ::= nm",
147543
+ /* 348 */ "nmnum ::= ON",
147544
+ /* 349 */ "nmnum ::= DELETE",
147545
+ /* 350 */ "nmnum ::= DEFAULT",
147546
+ /* 351 */ "plus_num ::= INTEGER|FLOAT",
147547
+ /* 352 */ "foreach_clause ::=",
147548
+ /* 353 */ "foreach_clause ::= FOR EACH ROW",
147549
+ /* 354 */ "trnm ::= nm",
147550
+ /* 355 */ "tridxby ::=",
147551
+ /* 356 */ "database_kw_opt ::= DATABASE",
147552
+ /* 357 */ "database_kw_opt ::=",
147553
+ /* 358 */ "kwcolumn_opt ::=",
147554
+ /* 359 */ "kwcolumn_opt ::= COLUMNKW",
147555
+ /* 360 */ "vtabarglist ::= vtabarg",
147556
+ /* 361 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
147557
+ /* 362 */ "vtabarg ::= vtabarg vtabargtoken",
147558
+ /* 363 */ "anylist ::=",
147559
+ /* 364 */ "anylist ::= anylist LP anylist RP",
147560
+ /* 365 */ "anylist ::= anylist ANY",
147561
+ /* 366 */ "with ::=",
146609147562
};
146610147563
#endif /* NDEBUG */
146611147564
146612147565
146613147566
#if YYSTACKDEPTH<=0
@@ -147391,102 +148344,103 @@
147391148344
{ 160, -1 }, /* (269) cmd ::= ANALYZE */
147392148345
{ 160, -3 }, /* (270) cmd ::= ANALYZE nm dbnm */
147393148346
{ 160, -6 }, /* (271) cmd ::= ALTER TABLE fullname RENAME TO nm */
147394148347
{ 160, -7 }, /* (272) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
147395148348
{ 259, -1 }, /* (273) add_column_fullname ::= fullname */
147396
- { 160, -1 }, /* (274) cmd ::= create_vtab */
147397
- { 160, -4 }, /* (275) cmd ::= create_vtab LP vtabarglist RP */
147398
- { 261, -8 }, /* (276) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
147399
- { 263, 0 }, /* (277) vtabarg ::= */
147400
- { 264, -1 }, /* (278) vtabargtoken ::= ANY */
147401
- { 264, -3 }, /* (279) vtabargtoken ::= lp anylist RP */
147402
- { 265, -1 }, /* (280) lp ::= LP */
147403
- { 232, -2 }, /* (281) with ::= WITH wqlist */
147404
- { 232, -3 }, /* (282) with ::= WITH RECURSIVE wqlist */
147405
- { 208, -6 }, /* (283) wqlist ::= nm eidlist_opt AS LP select RP */
147406
- { 208, -8 }, /* (284) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
147407
- { 267, -1 }, /* (285) windowdefn_list ::= windowdefn */
147408
- { 267, -3 }, /* (286) windowdefn_list ::= windowdefn_list COMMA windowdefn */
147409
- { 268, -3 }, /* (287) windowdefn ::= nm AS window */
147410
- { 269, -5 }, /* (288) window ::= LP part_opt orderby_opt frame_opt RP */
147411
- { 271, -3 }, /* (289) part_opt ::= PARTITION BY nexprlist */
147412
- { 271, 0 }, /* (290) part_opt ::= */
147413
- { 270, 0 }, /* (291) frame_opt ::= */
147414
- { 270, -2 }, /* (292) frame_opt ::= range_or_rows frame_bound_s */
147415
- { 270, -5 }, /* (293) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
147416
- { 273, -1 }, /* (294) range_or_rows ::= RANGE */
147417
- { 273, -1 }, /* (295) range_or_rows ::= ROWS */
147418
- { 275, -1 }, /* (296) frame_bound_s ::= frame_bound */
147419
- { 275, -2 }, /* (297) frame_bound_s ::= UNBOUNDED PRECEDING */
147420
- { 276, -1 }, /* (298) frame_bound_e ::= frame_bound */
147421
- { 276, -2 }, /* (299) frame_bound_e ::= UNBOUNDED FOLLOWING */
147422
- { 274, -2 }, /* (300) frame_bound ::= expr PRECEDING */
147423
- { 274, -2 }, /* (301) frame_bound ::= CURRENT ROW */
147424
- { 274, -2 }, /* (302) frame_bound ::= expr FOLLOWING */
147425
- { 218, -2 }, /* (303) window_clause ::= WINDOW windowdefn_list */
147426
- { 237, -3 }, /* (304) over_clause ::= filter_opt OVER window */
147427
- { 237, -3 }, /* (305) over_clause ::= filter_opt OVER nm */
147428
- { 272, 0 }, /* (306) filter_opt ::= */
147429
- { 272, -5 }, /* (307) filter_opt ::= FILTER LP WHERE expr RP */
147430
- { 155, -1 }, /* (308) input ::= cmdlist */
147431
- { 156, -2 }, /* (309) cmdlist ::= cmdlist ecmd */
147432
- { 156, -1 }, /* (310) cmdlist ::= ecmd */
147433
- { 157, -1 }, /* (311) ecmd ::= SEMI */
147434
- { 157, -2 }, /* (312) ecmd ::= cmdx SEMI */
147435
- { 157, -2 }, /* (313) ecmd ::= explain cmdx */
147436
- { 162, 0 }, /* (314) trans_opt ::= */
147437
- { 162, -1 }, /* (315) trans_opt ::= TRANSACTION */
147438
- { 162, -2 }, /* (316) trans_opt ::= TRANSACTION nm */
147439
- { 164, -1 }, /* (317) savepoint_opt ::= SAVEPOINT */
147440
- { 164, 0 }, /* (318) savepoint_opt ::= */
147441
- { 160, -2 }, /* (319) cmd ::= create_table create_table_args */
147442
- { 171, -4 }, /* (320) columnlist ::= columnlist COMMA columnname carglist */
147443
- { 171, -2 }, /* (321) columnlist ::= columnname carglist */
147444
- { 163, -1 }, /* (322) nm ::= ID|INDEXED */
147445
- { 163, -1 }, /* (323) nm ::= STRING */
147446
- { 163, -1 }, /* (324) nm ::= JOIN_KW */
147447
- { 177, -1 }, /* (325) typetoken ::= typename */
147448
- { 178, -1 }, /* (326) typename ::= ID|STRING */
147449
- { 179, -1 }, /* (327) signed ::= plus_num */
147450
- { 179, -1 }, /* (328) signed ::= minus_num */
147451
- { 176, -2 }, /* (329) carglist ::= carglist ccons */
147452
- { 176, 0 }, /* (330) carglist ::= */
147453
- { 183, -2 }, /* (331) ccons ::= NULL onconf */
147454
- { 172, -2 }, /* (332) conslist_opt ::= COMMA conslist */
147455
- { 195, -3 }, /* (333) conslist ::= conslist tconscomma tcons */
147456
- { 195, -1 }, /* (334) conslist ::= tcons */
147457
- { 196, 0 }, /* (335) tconscomma ::= */
147458
- { 200, -1 }, /* (336) defer_subclause_opt ::= defer_subclause */
147459
- { 202, -1 }, /* (337) resolvetype ::= raisetype */
147460
- { 206, -1 }, /* (338) selectnowith ::= oneselect */
147461
- { 207, -1 }, /* (339) oneselect ::= values */
147462
- { 221, -2 }, /* (340) sclp ::= selcollist COMMA */
147463
- { 222, -1 }, /* (341) as ::= ID|STRING */
147464
- { 185, -1 }, /* (342) expr ::= term */
147465
- { 238, -1 }, /* (343) likeop ::= LIKE_KW|MATCH */
147466
- { 229, -1 }, /* (344) exprlist ::= nexprlist */
147467
- { 247, -1 }, /* (345) nmnum ::= plus_num */
147468
- { 247, -1 }, /* (346) nmnum ::= nm */
147469
- { 247, -1 }, /* (347) nmnum ::= ON */
147470
- { 247, -1 }, /* (348) nmnum ::= DELETE */
147471
- { 247, -1 }, /* (349) nmnum ::= DEFAULT */
147472
- { 180, -1 }, /* (350) plus_num ::= INTEGER|FLOAT */
147473
- { 252, 0 }, /* (351) foreach_clause ::= */
147474
- { 252, -3 }, /* (352) foreach_clause ::= FOR EACH ROW */
147475
- { 255, -1 }, /* (353) trnm ::= nm */
147476
- { 256, 0 }, /* (354) tridxby ::= */
147477
- { 257, -1 }, /* (355) database_kw_opt ::= DATABASE */
147478
- { 257, 0 }, /* (356) database_kw_opt ::= */
147479
- { 260, 0 }, /* (357) kwcolumn_opt ::= */
147480
- { 260, -1 }, /* (358) kwcolumn_opt ::= COLUMNKW */
147481
- { 262, -1 }, /* (359) vtabarglist ::= vtabarg */
147482
- { 262, -3 }, /* (360) vtabarglist ::= vtabarglist COMMA vtabarg */
147483
- { 263, -2 }, /* (361) vtabarg ::= vtabarg vtabargtoken */
147484
- { 266, 0 }, /* (362) anylist ::= */
147485
- { 266, -4 }, /* (363) anylist ::= anylist LP anylist RP */
147486
- { 266, -2 }, /* (364) anylist ::= anylist ANY */
147487
- { 232, 0 }, /* (365) with ::= */
148349
+ { 160, -8 }, /* (274) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
148350
+ { 160, -1 }, /* (275) cmd ::= create_vtab */
148351
+ { 160, -4 }, /* (276) cmd ::= create_vtab LP vtabarglist RP */
148352
+ { 261, -8 }, /* (277) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
148353
+ { 263, 0 }, /* (278) vtabarg ::= */
148354
+ { 264, -1 }, /* (279) vtabargtoken ::= ANY */
148355
+ { 264, -3 }, /* (280) vtabargtoken ::= lp anylist RP */
148356
+ { 265, -1 }, /* (281) lp ::= LP */
148357
+ { 232, -2 }, /* (282) with ::= WITH wqlist */
148358
+ { 232, -3 }, /* (283) with ::= WITH RECURSIVE wqlist */
148359
+ { 208, -6 }, /* (284) wqlist ::= nm eidlist_opt AS LP select RP */
148360
+ { 208, -8 }, /* (285) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
148361
+ { 267, -1 }, /* (286) windowdefn_list ::= windowdefn */
148362
+ { 267, -3 }, /* (287) windowdefn_list ::= windowdefn_list COMMA windowdefn */
148363
+ { 268, -3 }, /* (288) windowdefn ::= nm AS window */
148364
+ { 269, -5 }, /* (289) window ::= LP part_opt orderby_opt frame_opt RP */
148365
+ { 271, -3 }, /* (290) part_opt ::= PARTITION BY nexprlist */
148366
+ { 271, 0 }, /* (291) part_opt ::= */
148367
+ { 270, 0 }, /* (292) frame_opt ::= */
148368
+ { 270, -2 }, /* (293) frame_opt ::= range_or_rows frame_bound_s */
148369
+ { 270, -5 }, /* (294) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
148370
+ { 273, -1 }, /* (295) range_or_rows ::= RANGE */
148371
+ { 273, -1 }, /* (296) range_or_rows ::= ROWS */
148372
+ { 275, -1 }, /* (297) frame_bound_s ::= frame_bound */
148373
+ { 275, -2 }, /* (298) frame_bound_s ::= UNBOUNDED PRECEDING */
148374
+ { 276, -1 }, /* (299) frame_bound_e ::= frame_bound */
148375
+ { 276, -2 }, /* (300) frame_bound_e ::= UNBOUNDED FOLLOWING */
148376
+ { 274, -2 }, /* (301) frame_bound ::= expr PRECEDING */
148377
+ { 274, -2 }, /* (302) frame_bound ::= CURRENT ROW */
148378
+ { 274, -2 }, /* (303) frame_bound ::= expr FOLLOWING */
148379
+ { 218, -2 }, /* (304) window_clause ::= WINDOW windowdefn_list */
148380
+ { 237, -3 }, /* (305) over_clause ::= filter_opt OVER window */
148381
+ { 237, -3 }, /* (306) over_clause ::= filter_opt OVER nm */
148382
+ { 272, 0 }, /* (307) filter_opt ::= */
148383
+ { 272, -5 }, /* (308) filter_opt ::= FILTER LP WHERE expr RP */
148384
+ { 155, -1 }, /* (309) input ::= cmdlist */
148385
+ { 156, -2 }, /* (310) cmdlist ::= cmdlist ecmd */
148386
+ { 156, -1 }, /* (311) cmdlist ::= ecmd */
148387
+ { 157, -1 }, /* (312) ecmd ::= SEMI */
148388
+ { 157, -2 }, /* (313) ecmd ::= cmdx SEMI */
148389
+ { 157, -2 }, /* (314) ecmd ::= explain cmdx */
148390
+ { 162, 0 }, /* (315) trans_opt ::= */
148391
+ { 162, -1 }, /* (316) trans_opt ::= TRANSACTION */
148392
+ { 162, -2 }, /* (317) trans_opt ::= TRANSACTION nm */
148393
+ { 164, -1 }, /* (318) savepoint_opt ::= SAVEPOINT */
148394
+ { 164, 0 }, /* (319) savepoint_opt ::= */
148395
+ { 160, -2 }, /* (320) cmd ::= create_table create_table_args */
148396
+ { 171, -4 }, /* (321) columnlist ::= columnlist COMMA columnname carglist */
148397
+ { 171, -2 }, /* (322) columnlist ::= columnname carglist */
148398
+ { 163, -1 }, /* (323) nm ::= ID|INDEXED */
148399
+ { 163, -1 }, /* (324) nm ::= STRING */
148400
+ { 163, -1 }, /* (325) nm ::= JOIN_KW */
148401
+ { 177, -1 }, /* (326) typetoken ::= typename */
148402
+ { 178, -1 }, /* (327) typename ::= ID|STRING */
148403
+ { 179, -1 }, /* (328) signed ::= plus_num */
148404
+ { 179, -1 }, /* (329) signed ::= minus_num */
148405
+ { 176, -2 }, /* (330) carglist ::= carglist ccons */
148406
+ { 176, 0 }, /* (331) carglist ::= */
148407
+ { 183, -2 }, /* (332) ccons ::= NULL onconf */
148408
+ { 172, -2 }, /* (333) conslist_opt ::= COMMA conslist */
148409
+ { 195, -3 }, /* (334) conslist ::= conslist tconscomma tcons */
148410
+ { 195, -1 }, /* (335) conslist ::= tcons */
148411
+ { 196, 0 }, /* (336) tconscomma ::= */
148412
+ { 200, -1 }, /* (337) defer_subclause_opt ::= defer_subclause */
148413
+ { 202, -1 }, /* (338) resolvetype ::= raisetype */
148414
+ { 206, -1 }, /* (339) selectnowith ::= oneselect */
148415
+ { 207, -1 }, /* (340) oneselect ::= values */
148416
+ { 221, -2 }, /* (341) sclp ::= selcollist COMMA */
148417
+ { 222, -1 }, /* (342) as ::= ID|STRING */
148418
+ { 185, -1 }, /* (343) expr ::= term */
148419
+ { 238, -1 }, /* (344) likeop ::= LIKE_KW|MATCH */
148420
+ { 229, -1 }, /* (345) exprlist ::= nexprlist */
148421
+ { 247, -1 }, /* (346) nmnum ::= plus_num */
148422
+ { 247, -1 }, /* (347) nmnum ::= nm */
148423
+ { 247, -1 }, /* (348) nmnum ::= ON */
148424
+ { 247, -1 }, /* (349) nmnum ::= DELETE */
148425
+ { 247, -1 }, /* (350) nmnum ::= DEFAULT */
148426
+ { 180, -1 }, /* (351) plus_num ::= INTEGER|FLOAT */
148427
+ { 252, 0 }, /* (352) foreach_clause ::= */
148428
+ { 252, -3 }, /* (353) foreach_clause ::= FOR EACH ROW */
148429
+ { 255, -1 }, /* (354) trnm ::= nm */
148430
+ { 256, 0 }, /* (355) tridxby ::= */
148431
+ { 257, -1 }, /* (356) database_kw_opt ::= DATABASE */
148432
+ { 257, 0 }, /* (357) database_kw_opt ::= */
148433
+ { 260, 0 }, /* (358) kwcolumn_opt ::= */
148434
+ { 260, -1 }, /* (359) kwcolumn_opt ::= COLUMNKW */
148435
+ { 262, -1 }, /* (360) vtabarglist ::= vtabarg */
148436
+ { 262, -3 }, /* (361) vtabarglist ::= vtabarglist COMMA vtabarg */
148437
+ { 263, -2 }, /* (362) vtabarg ::= vtabarg vtabargtoken */
148438
+ { 266, 0 }, /* (363) anylist ::= */
148439
+ { 266, -4 }, /* (364) anylist ::= anylist LP anylist RP */
148440
+ { 266, -2 }, /* (365) anylist ::= anylist ANY */
148441
+ { 232, 0 }, /* (366) with ::= */
147488148442
};
147489148443
147490148444
static void yy_accept(yyParser*); /* Forward Declaration */
147491148445
147492148446
/*
@@ -147708,11 +148662,11 @@
147708148662
Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0);
147709148663
if( p ){
147710148664
sqlite3ExprIdToTrueFalse(p);
147711148665
testcase( p->op==TK_TRUEFALSE && sqlite3ExprTruthValue(p) );
147712148666
}
147713
- sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
148667
+ sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
147714148668
}
147715148669
break;
147716148670
case 35: /* ccons ::= NOT NULL onconf */
147717148671
{sqlite3AddNotNull(pParse, yymsp[0].minor.yy70);}
147718148672
break;
@@ -148041,15 +148995,27 @@
148041148995
case 108: /* dbnm ::= */
148042148996
case 122: /* indexed_opt ::= */ yytestcase(yyruleno==122);
148043148997
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
148044148998
break;
148045148999
case 110: /* fullname ::= nm */
148046
- case 112: /* xfullname ::= nm */ yytestcase(yyruleno==112);
148047
-{yymsp[0].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
149000
+{
149001
+ yylhsminor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0);
149002
+ if( IN_RENAME_OBJECT && yylhsminor.yy135 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy135->a[0].zName, &yymsp[0].minor.yy0);
149003
+}
149004
+ yymsp[0].minor.yy135 = yylhsminor.yy135;
148048149005
break;
148049149006
case 111: /* fullname ::= nm DOT nm */
148050
- case 113: /* xfullname ::= nm DOT nm */ yytestcase(yyruleno==113);
149007
+{
149008
+ yylhsminor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
149009
+ if( IN_RENAME_OBJECT && yylhsminor.yy135 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy135->a[0].zName, &yymsp[0].minor.yy0);
149010
+}
149011
+ yymsp[-2].minor.yy135 = yylhsminor.yy135;
149012
+ break;
149013
+ case 112: /* xfullname ::= nm */
149014
+{yymsp[0].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
149015
+ break;
149016
+ case 113: /* xfullname ::= nm DOT nm */
148051149017
{yymsp[-2].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
148052149018
break;
148053149019
case 114: /* xfullname ::= nm DOT nm AS nm */
148054149020
{
148055149021
yymsp[-4].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
@@ -148195,14 +149161,14 @@
148195149161
break;
148196149162
case 159: /* idlist_opt ::= LP idlist RP */
148197149163
{yymsp[-2].minor.yy48 = yymsp[-1].minor.yy48;}
148198149164
break;
148199149165
case 160: /* idlist ::= idlist COMMA nm */
148200
-{yymsp[-2].minor.yy48 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy48,&yymsp[0].minor.yy0);}
149166
+{yymsp[-2].minor.yy48 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy48,&yymsp[0].minor.yy0);}
148201149167
break;
148202149168
case 161: /* idlist ::= nm */
148203
-{yymsp[0].minor.yy48 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
149169
+{yymsp[0].minor.yy48 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
148204149170
break;
148205149171
case 162: /* expr ::= LP expr RP */
148206149172
{yymsp[-2].minor.yy18 = yymsp[-1].minor.yy18;}
148207149173
break;
148208149174
case 163: /* expr ::= ID|INDEXED */
@@ -148211,10 +149177,14 @@
148211149177
break;
148212149178
case 165: /* expr ::= nm DOT nm */
148213149179
{
148214149180
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
148215149181
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
149182
+ if( IN_RENAME_OBJECT ){
149183
+ sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
149184
+ sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
149185
+ }
148216149186
yylhsminor.yy18 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
148217149187
}
148218149188
yymsp[-2].minor.yy18 = yylhsminor.yy18;
148219149189
break;
148220149190
case 166: /* expr ::= nm DOT nm DOT nm */
@@ -148221,10 +149191,14 @@
148221149191
{
148222149192
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
148223149193
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
148224149194
Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
148225149195
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
149196
+ if( IN_RENAME_OBJECT ){
149197
+ sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
149198
+ sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
149199
+ }
148226149200
yylhsminor.yy18 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
148227149201
}
148228149202
yymsp[-4].minor.yy18 = yylhsminor.yy18;
148229149203
break;
148230149204
case 167: /* term ::= NULL|FLOAT|BLOB */
@@ -148518,10 +149492,13 @@
148518149492
case 219: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
148519149493
{
148520149494
sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
148521149495
sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy420, yymsp[-10].minor.yy70,
148522149496
&yymsp[-11].minor.yy0, yymsp[0].minor.yy18, SQLITE_SO_ASC, yymsp[-8].minor.yy70, SQLITE_IDXTYPE_APPDEF);
149497
+ if( IN_RENAME_OBJECT && pParse->pNewIndex ){
149498
+ sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
149499
+ }
148523149500
}
148524149501
break;
148525149502
case 220: /* uniqueflag ::= UNIQUE */
148526149503
case 260: /* raisetype ::= ABORT */ yytestcase(yyruleno==260);
148527149504
{yymsp[0].minor.yy70 = OE_Abort;}
@@ -148593,11 +149570,11 @@
148593149570
case 245: /* trigger_event ::= UPDATE OF idlist */
148594149571
{yymsp[-2].minor.yy34.a = TK_UPDATE; yymsp[-2].minor.yy34.b = yymsp[0].minor.yy48;}
148595149572
break;
148596149573
case 246: /* when_clause ::= */
148597149574
case 265: /* key_opt ::= */ yytestcase(yyruleno==265);
148598
- case 306: /* filter_opt ::= */ yytestcase(yyruleno==306);
149575
+ case 307: /* filter_opt ::= */ yytestcase(yyruleno==307);
148599149576
{ yymsp[1].minor.yy18 = 0; }
148600149577
break;
148601149578
case 247: /* when_clause ::= WHEN expr */
148602149579
case 266: /* key_opt ::= KEY expr */ yytestcase(yyruleno==266);
148603149580
{ yymsp[-1].minor.yy18 = yymsp[0].minor.yy18; }
@@ -148636,21 +149613,21 @@
148636149613
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
148637149614
"within triggers");
148638149615
}
148639149616
break;
148640149617
case 253: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
148641
-{yylhsminor.yy207 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy420, yymsp[-1].minor.yy18, yymsp[-6].minor.yy70, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy392);}
149618
+{yylhsminor.yy207 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy420, yymsp[-1].minor.yy18, yymsp[-6].minor.yy70, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy392);}
148642149619
yymsp[-7].minor.yy207 = yylhsminor.yy207;
148643149620
break;
148644149621
case 254: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
148645149622
{
148646
- yylhsminor.yy207 = sqlite3TriggerInsertStep(pParse->db,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy48,yymsp[-2].minor.yy489,yymsp[-6].minor.yy70,yymsp[-1].minor.yy340,yymsp[-7].minor.yy392,yymsp[0].minor.yy392);/*yylhsminor.yy207-overwrites-yymsp[-6].minor.yy70*/
149623
+ yylhsminor.yy207 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy48,yymsp[-2].minor.yy489,yymsp[-6].minor.yy70,yymsp[-1].minor.yy340,yymsp[-7].minor.yy392,yymsp[0].minor.yy392);/*yylhsminor.yy207-overwrites-yymsp[-6].minor.yy70*/
148647149624
}
148648149625
yymsp[-7].minor.yy207 = yylhsminor.yy207;
148649149626
break;
148650149627
case 255: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
148651
-{yylhsminor.yy207 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy18, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy392);}
149628
+{yylhsminor.yy207 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy18, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy392);}
148652149629
yymsp[-5].minor.yy207 = yylhsminor.yy207;
148653149630
break;
148654149631
case 256: /* trigger_cmd ::= scanpt select scanpt */
148655149632
{yylhsminor.yy207 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy489, yymsp[-2].minor.yy392, yymsp[0].minor.yy392); /*yylhsminor.yy207-overwrites-yymsp[-1].minor.yy489*/}
148656149633
yymsp[-2].minor.yy207 = yylhsminor.yy207;
@@ -148719,134 +149696,139 @@
148719149696
{
148720149697
disableLookaside(pParse);
148721149698
sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy135);
148722149699
}
148723149700
break;
148724
- case 274: /* cmd ::= create_vtab */
149701
+ case 274: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
149702
+{
149703
+ sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy135, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
149704
+}
149705
+ break;
149706
+ case 275: /* cmd ::= create_vtab */
148725149707
{sqlite3VtabFinishParse(pParse,0);}
148726149708
break;
148727
- case 275: /* cmd ::= create_vtab LP vtabarglist RP */
149709
+ case 276: /* cmd ::= create_vtab LP vtabarglist RP */
148728149710
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
148729149711
break;
148730
- case 276: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
149712
+ case 277: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
148731149713
{
148732149714
sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy70);
148733149715
}
148734149716
break;
148735
- case 277: /* vtabarg ::= */
149717
+ case 278: /* vtabarg ::= */
148736149718
{sqlite3VtabArgInit(pParse);}
148737149719
break;
148738
- case 278: /* vtabargtoken ::= ANY */
148739
- case 279: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==279);
148740
- case 280: /* lp ::= LP */ yytestcase(yyruleno==280);
149720
+ case 279: /* vtabargtoken ::= ANY */
149721
+ case 280: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==280);
149722
+ case 281: /* lp ::= LP */ yytestcase(yyruleno==281);
148741149723
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
148742149724
break;
148743
- case 281: /* with ::= WITH wqlist */
148744
- case 282: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==282);
149725
+ case 282: /* with ::= WITH wqlist */
149726
+ case 283: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==283);
148745149727
{ sqlite3WithPush(pParse, yymsp[0].minor.yy449, 1); }
148746149728
break;
148747
- case 283: /* wqlist ::= nm eidlist_opt AS LP select RP */
149729
+ case 284: /* wqlist ::= nm eidlist_opt AS LP select RP */
148748149730
{
148749149731
yymsp[-5].minor.yy449 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy420, yymsp[-1].minor.yy489); /*A-overwrites-X*/
148750149732
}
148751149733
break;
148752
- case 284: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
149734
+ case 285: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
148753149735
{
148754149736
yymsp[-7].minor.yy449 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy449, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy420, yymsp[-1].minor.yy489);
148755149737
}
148756149738
break;
148757
- case 285: /* windowdefn_list ::= windowdefn */
149739
+ case 286: /* windowdefn_list ::= windowdefn */
148758149740
{ yylhsminor.yy327 = yymsp[0].minor.yy327; }
148759149741
yymsp[0].minor.yy327 = yylhsminor.yy327;
148760149742
break;
148761
- case 286: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
149743
+ case 287: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
148762149744
{
148763149745
assert( yymsp[0].minor.yy327!=0 );
148764149746
yymsp[0].minor.yy327->pNextWin = yymsp[-2].minor.yy327;
148765149747
yylhsminor.yy327 = yymsp[0].minor.yy327;
148766149748
}
148767149749
yymsp[-2].minor.yy327 = yylhsminor.yy327;
148768149750
break;
148769
- case 287: /* windowdefn ::= nm AS window */
149751
+ case 288: /* windowdefn ::= nm AS window */
148770149752
{
148771149753
if( ALWAYS(yymsp[0].minor.yy327) ){
148772149754
yymsp[0].minor.yy327->zName = sqlite3DbStrNDup(pParse->db, yymsp[-2].minor.yy0.z, yymsp[-2].minor.yy0.n);
148773149755
}
148774149756
yylhsminor.yy327 = yymsp[0].minor.yy327;
148775149757
}
148776149758
yymsp[-2].minor.yy327 = yylhsminor.yy327;
148777149759
break;
148778
- case 288: /* window ::= LP part_opt orderby_opt frame_opt RP */
149760
+ case 289: /* window ::= LP part_opt orderby_opt frame_opt RP */
148779149761
{
148780149762
yymsp[-4].minor.yy327 = yymsp[-1].minor.yy327;
148781149763
if( ALWAYS(yymsp[-4].minor.yy327) ){
148782149764
yymsp[-4].minor.yy327->pPartition = yymsp[-3].minor.yy420;
148783149765
yymsp[-4].minor.yy327->pOrderBy = yymsp[-2].minor.yy420;
148784149766
}
148785149767
}
148786149768
break;
148787
- case 289: /* part_opt ::= PARTITION BY nexprlist */
149769
+ case 290: /* part_opt ::= PARTITION BY nexprlist */
148788149770
{ yymsp[-2].minor.yy420 = yymsp[0].minor.yy420; }
148789149771
break;
148790
- case 290: /* part_opt ::= */
149772
+ case 291: /* part_opt ::= */
148791149773
{ yymsp[1].minor.yy420 = 0; }
148792149774
break;
148793
- case 291: /* frame_opt ::= */
149775
+ case 292: /* frame_opt ::= */
148794149776
{
148795149777
yymsp[1].minor.yy327 = sqlite3WindowAlloc(pParse, TK_RANGE, TK_UNBOUNDED, 0, TK_CURRENT, 0);
148796149778
}
148797149779
break;
148798
- case 292: /* frame_opt ::= range_or_rows frame_bound_s */
149780
+ case 293: /* frame_opt ::= range_or_rows frame_bound_s */
148799149781
{
148800149782
yylhsminor.yy327 = sqlite3WindowAlloc(pParse, yymsp[-1].minor.yy70, yymsp[0].minor.yy119.eType, yymsp[0].minor.yy119.pExpr, TK_CURRENT, 0);
148801149783
}
148802149784
yymsp[-1].minor.yy327 = yylhsminor.yy327;
148803149785
break;
148804
- case 293: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
149786
+ case 294: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
148805149787
{
148806149788
yylhsminor.yy327 = sqlite3WindowAlloc(pParse, yymsp[-4].minor.yy70, yymsp[-2].minor.yy119.eType, yymsp[-2].minor.yy119.pExpr, yymsp[0].minor.yy119.eType, yymsp[0].minor.yy119.pExpr);
148807149789
}
148808149790
yymsp[-4].minor.yy327 = yylhsminor.yy327;
148809149791
break;
148810
- case 294: /* range_or_rows ::= RANGE */
149792
+ case 295: /* range_or_rows ::= RANGE */
148811149793
{ yymsp[0].minor.yy70 = TK_RANGE; }
148812149794
break;
148813
- case 295: /* range_or_rows ::= ROWS */
149795
+ case 296: /* range_or_rows ::= ROWS */
148814149796
{ yymsp[0].minor.yy70 = TK_ROWS; }
148815149797
break;
148816
- case 296: /* frame_bound_s ::= frame_bound */
148817
- case 298: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==298);
149798
+ case 297: /* frame_bound_s ::= frame_bound */
149799
+ case 299: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==299);
148818149800
{ yylhsminor.yy119 = yymsp[0].minor.yy119; }
148819149801
yymsp[0].minor.yy119 = yylhsminor.yy119;
148820149802
break;
148821
- case 297: /* frame_bound_s ::= UNBOUNDED PRECEDING */
148822
- case 299: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==299);
149803
+ case 298: /* frame_bound_s ::= UNBOUNDED PRECEDING */
149804
+ case 300: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==300);
148823149805
{yymsp[-1].minor.yy119.eType = TK_UNBOUNDED; yymsp[-1].minor.yy119.pExpr = 0;}
148824149806
break;
148825
- case 300: /* frame_bound ::= expr PRECEDING */
149807
+ case 301: /* frame_bound ::= expr PRECEDING */
148826149808
{ yylhsminor.yy119.eType = TK_PRECEDING; yylhsminor.yy119.pExpr = yymsp[-1].minor.yy18; }
148827149809
yymsp[-1].minor.yy119 = yylhsminor.yy119;
148828149810
break;
148829
- case 301: /* frame_bound ::= CURRENT ROW */
149811
+ case 302: /* frame_bound ::= CURRENT ROW */
148830149812
{ yymsp[-1].minor.yy119.eType = TK_CURRENT ; yymsp[-1].minor.yy119.pExpr = 0; }
148831149813
break;
148832
- case 302: /* frame_bound ::= expr FOLLOWING */
149814
+ case 303: /* frame_bound ::= expr FOLLOWING */
148833149815
{ yylhsminor.yy119.eType = TK_FOLLOWING; yylhsminor.yy119.pExpr = yymsp[-1].minor.yy18; }
148834149816
yymsp[-1].minor.yy119 = yylhsminor.yy119;
148835149817
break;
148836
- case 303: /* window_clause ::= WINDOW windowdefn_list */
149818
+ case 304: /* window_clause ::= WINDOW windowdefn_list */
148837149819
{ yymsp[-1].minor.yy327 = yymsp[0].minor.yy327; }
148838149820
break;
148839
- case 304: /* over_clause ::= filter_opt OVER window */
149821
+ case 305: /* over_clause ::= filter_opt OVER window */
148840149822
{
148841149823
yylhsminor.yy327 = yymsp[0].minor.yy327;
148842149824
assert( yylhsminor.yy327!=0 );
148843149825
yylhsminor.yy327->pFilter = yymsp[-2].minor.yy18;
148844149826
}
148845149827
yymsp[-2].minor.yy327 = yylhsminor.yy327;
148846149828
break;
148847
- case 305: /* over_clause ::= filter_opt OVER nm */
149829
+ case 306: /* over_clause ::= filter_opt OVER nm */
148848149830
{
148849149831
yylhsminor.yy327 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
148850149832
if( yylhsminor.yy327 ){
148851149833
yylhsminor.yy327->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
148852149834
yylhsminor.yy327->pFilter = yymsp[-2].minor.yy18;
@@ -148854,72 +149836,72 @@
148854149836
sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy18);
148855149837
}
148856149838
}
148857149839
yymsp[-2].minor.yy327 = yylhsminor.yy327;
148858149840
break;
148859
- case 307: /* filter_opt ::= FILTER LP WHERE expr RP */
149841
+ case 308: /* filter_opt ::= FILTER LP WHERE expr RP */
148860149842
{ yymsp[-4].minor.yy18 = yymsp[-1].minor.yy18; }
148861149843
break;
148862149844
default:
148863
- /* (308) input ::= cmdlist */ yytestcase(yyruleno==308);
148864
- /* (309) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==309);
148865
- /* (310) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=310);
148866
- /* (311) ecmd ::= SEMI */ yytestcase(yyruleno==311);
148867
- /* (312) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==312);
148868
- /* (313) ecmd ::= explain cmdx */ yytestcase(yyruleno==313);
148869
- /* (314) trans_opt ::= */ yytestcase(yyruleno==314);
148870
- /* (315) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==315);
148871
- /* (316) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==316);
148872
- /* (317) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==317);
148873
- /* (318) savepoint_opt ::= */ yytestcase(yyruleno==318);
148874
- /* (319) cmd ::= create_table create_table_args */ yytestcase(yyruleno==319);
148875
- /* (320) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==320);
148876
- /* (321) columnlist ::= columnname carglist */ yytestcase(yyruleno==321);
148877
- /* (322) nm ::= ID|INDEXED */ yytestcase(yyruleno==322);
148878
- /* (323) nm ::= STRING */ yytestcase(yyruleno==323);
148879
- /* (324) nm ::= JOIN_KW */ yytestcase(yyruleno==324);
148880
- /* (325) typetoken ::= typename */ yytestcase(yyruleno==325);
148881
- /* (326) typename ::= ID|STRING */ yytestcase(yyruleno==326);
148882
- /* (327) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=327);
148883
- /* (328) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=328);
148884
- /* (329) carglist ::= carglist ccons */ yytestcase(yyruleno==329);
148885
- /* (330) carglist ::= */ yytestcase(yyruleno==330);
148886
- /* (331) ccons ::= NULL onconf */ yytestcase(yyruleno==331);
148887
- /* (332) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==332);
148888
- /* (333) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==333);
148889
- /* (334) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=334);
148890
- /* (335) tconscomma ::= */ yytestcase(yyruleno==335);
148891
- /* (336) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=336);
148892
- /* (337) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=337);
148893
- /* (338) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=338);
148894
- /* (339) oneselect ::= values */ yytestcase(yyruleno==339);
148895
- /* (340) sclp ::= selcollist COMMA */ yytestcase(yyruleno==340);
148896
- /* (341) as ::= ID|STRING */ yytestcase(yyruleno==341);
148897
- /* (342) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=342);
148898
- /* (343) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==343);
148899
- /* (344) exprlist ::= nexprlist */ yytestcase(yyruleno==344);
148900
- /* (345) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=345);
148901
- /* (346) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=346);
148902
- /* (347) nmnum ::= ON */ yytestcase(yyruleno==347);
148903
- /* (348) nmnum ::= DELETE */ yytestcase(yyruleno==348);
148904
- /* (349) nmnum ::= DEFAULT */ yytestcase(yyruleno==349);
148905
- /* (350) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==350);
148906
- /* (351) foreach_clause ::= */ yytestcase(yyruleno==351);
148907
- /* (352) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==352);
148908
- /* (353) trnm ::= nm */ yytestcase(yyruleno==353);
148909
- /* (354) tridxby ::= */ yytestcase(yyruleno==354);
148910
- /* (355) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==355);
148911
- /* (356) database_kw_opt ::= */ yytestcase(yyruleno==356);
148912
- /* (357) kwcolumn_opt ::= */ yytestcase(yyruleno==357);
148913
- /* (358) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==358);
148914
- /* (359) vtabarglist ::= vtabarg */ yytestcase(yyruleno==359);
148915
- /* (360) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==360);
148916
- /* (361) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==361);
148917
- /* (362) anylist ::= */ yytestcase(yyruleno==362);
148918
- /* (363) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==363);
148919
- /* (364) anylist ::= anylist ANY */ yytestcase(yyruleno==364);
148920
- /* (365) with ::= */ yytestcase(yyruleno==365);
149845
+ /* (309) input ::= cmdlist */ yytestcase(yyruleno==309);
149846
+ /* (310) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==310);
149847
+ /* (311) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=311);
149848
+ /* (312) ecmd ::= SEMI */ yytestcase(yyruleno==312);
149849
+ /* (313) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==313);
149850
+ /* (314) ecmd ::= explain cmdx */ yytestcase(yyruleno==314);
149851
+ /* (315) trans_opt ::= */ yytestcase(yyruleno==315);
149852
+ /* (316) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==316);
149853
+ /* (317) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==317);
149854
+ /* (318) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==318);
149855
+ /* (319) savepoint_opt ::= */ yytestcase(yyruleno==319);
149856
+ /* (320) cmd ::= create_table create_table_args */ yytestcase(yyruleno==320);
149857
+ /* (321) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==321);
149858
+ /* (322) columnlist ::= columnname carglist */ yytestcase(yyruleno==322);
149859
+ /* (323) nm ::= ID|INDEXED */ yytestcase(yyruleno==323);
149860
+ /* (324) nm ::= STRING */ yytestcase(yyruleno==324);
149861
+ /* (325) nm ::= JOIN_KW */ yytestcase(yyruleno==325);
149862
+ /* (326) typetoken ::= typename */ yytestcase(yyruleno==326);
149863
+ /* (327) typename ::= ID|STRING */ yytestcase(yyruleno==327);
149864
+ /* (328) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=328);
149865
+ /* (329) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=329);
149866
+ /* (330) carglist ::= carglist ccons */ yytestcase(yyruleno==330);
149867
+ /* (331) carglist ::= */ yytestcase(yyruleno==331);
149868
+ /* (332) ccons ::= NULL onconf */ yytestcase(yyruleno==332);
149869
+ /* (333) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==333);
149870
+ /* (334) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==334);
149871
+ /* (335) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=335);
149872
+ /* (336) tconscomma ::= */ yytestcase(yyruleno==336);
149873
+ /* (337) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=337);
149874
+ /* (338) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=338);
149875
+ /* (339) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=339);
149876
+ /* (340) oneselect ::= values */ yytestcase(yyruleno==340);
149877
+ /* (341) sclp ::= selcollist COMMA */ yytestcase(yyruleno==341);
149878
+ /* (342) as ::= ID|STRING */ yytestcase(yyruleno==342);
149879
+ /* (343) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=343);
149880
+ /* (344) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==344);
149881
+ /* (345) exprlist ::= nexprlist */ yytestcase(yyruleno==345);
149882
+ /* (346) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=346);
149883
+ /* (347) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=347);
149884
+ /* (348) nmnum ::= ON */ yytestcase(yyruleno==348);
149885
+ /* (349) nmnum ::= DELETE */ yytestcase(yyruleno==349);
149886
+ /* (350) nmnum ::= DEFAULT */ yytestcase(yyruleno==350);
149887
+ /* (351) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==351);
149888
+ /* (352) foreach_clause ::= */ yytestcase(yyruleno==352);
149889
+ /* (353) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==353);
149890
+ /* (354) trnm ::= nm */ yytestcase(yyruleno==354);
149891
+ /* (355) tridxby ::= */ yytestcase(yyruleno==355);
149892
+ /* (356) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==356);
149893
+ /* (357) database_kw_opt ::= */ yytestcase(yyruleno==357);
149894
+ /* (358) kwcolumn_opt ::= */ yytestcase(yyruleno==358);
149895
+ /* (359) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==359);
149896
+ /* (360) vtabarglist ::= vtabarg */ yytestcase(yyruleno==360);
149897
+ /* (361) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==361);
149898
+ /* (362) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==362);
149899
+ /* (363) anylist ::= */ yytestcase(yyruleno==363);
149900
+ /* (364) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==364);
149901
+ /* (365) anylist ::= anylist ANY */ yytestcase(yyruleno==365);
149902
+ /* (366) with ::= */ yytestcase(yyruleno==366);
148921149903
break;
148922149904
/********** End reduce actions ************************************************/
148923149905
};
148924149906
assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
148925149907
yygoto = yyRuleInfo[yyruleno].lhs;
@@ -149738,14 +150720,12 @@
149738150720
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, /* Fx */
149739150721
};
149740150722
#define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40]))
149741150723
#endif
149742150724
149743
-/* Make the IdChar function accessible from ctime.c */
149744
-#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
150725
+/* Make the IdChar function accessible from ctime.c and alter.c */
149745150726
SQLITE_PRIVATE int sqlite3IsIdChar(u8 c){ return IdChar(c); }
149746
-#endif
149747150727
149748150728
#ifndef SQLITE_OMIT_WINDOWFUNC
149749150729
/*
149750150730
** Return the id of the next token in string (*pz). Before returning, set
149751150731
** (*pz) to point to the byte following the parsed token.
@@ -150244,20 +151224,22 @@
150244151224
#endif
150245151225
#ifndef SQLITE_OMIT_VIRTUALTABLE
150246151226
sqlite3_free(pParse->apVtabLock);
150247151227
#endif
150248151228
150249
- if( !IN_DECLARE_VTAB ){
151229
+ if( !IN_SPECIAL_PARSE ){
150250151230
/* If the pParse->declareVtab flag is set, do not delete any table
150251151231
** structure built up in pParse->pNewTable. The calling code (see vtab.c)
150252151232
** will take responsibility for freeing the Table structure.
150253151233
*/
150254151234
sqlite3DeleteTable(db, pParse->pNewTable);
150255151235
}
151236
+ if( !IN_RENAME_OBJECT ){
151237
+ sqlite3DeleteTrigger(db, pParse->pNewTrigger);
151238
+ }
150256151239
150257151240
if( pParse->pWithToFree ) sqlite3WithDelete(db, pParse->pWithToFree);
150258
- sqlite3DeleteTrigger(db, pParse->pNewTrigger);
150259151241
sqlite3DbFree(db, pParse->pVList);
150260151242
while( pParse->pAinc ){
150261151243
AutoincInfo *p = pParse->pAinc;
150262151244
pParse->pAinc = p->pNext;
150263151245
sqlite3DbFreeNN(db, p);
@@ -151990,10 +152972,11 @@
151990152972
int i, origRc = rc;
151991152973
for(i=0; i<2 && zName==0; i++, rc &= 0xff){
151992152974
switch( rc ){
151993152975
case SQLITE_OK: zName = "SQLITE_OK"; break;
151994152976
case SQLITE_ERROR: zName = "SQLITE_ERROR"; break;
152977
+ case SQLITE_ERROR_SNAPSHOT: zName = "SQLITE_ERROR_SNAPSHOT"; break;
151995152978
case SQLITE_INTERNAL: zName = "SQLITE_INTERNAL"; break;
151996152979
case SQLITE_PERM: zName = "SQLITE_PERM"; break;
151997152980
case SQLITE_ABORT: zName = "SQLITE_ABORT"; break;
151998152981
case SQLITE_ABORT_ROLLBACK: zName = "SQLITE_ABORT_ROLLBACK"; break;
151999152982
case SQLITE_BUSY: zName = "SQLITE_BUSY"; break;
@@ -181429,11 +182412,11 @@
181429182412
s.z++;
181430182413
while( geopolySkipSpace(&s)=='[' ){
181431182414
int ii = 0;
181432182415
char c;
181433182416
s.z++;
181434
- if( s.nVertex<=s.nAlloc ){
182417
+ if( s.nVertex>=s.nAlloc ){
181435182418
GeoCoord *aNew;
181436182419
s.nAlloc = s.nAlloc*2 + 16;
181437182420
aNew = sqlite3_realloc64(s.a, s.nAlloc*sizeof(GeoCoord)*2 );
181438182421
if( aNew==0 ){
181439182422
rc = SQLITE_NOMEM;
@@ -181511,11 +182494,11 @@
181511182494
){
181512182495
const unsigned char *a = sqlite3_value_blob(pVal);
181513182496
int nVertex;
181514182497
nVertex = (a[1]<<16) + (a[2]<<8) + a[3];
181515182498
if( (a[0]==0 || a[0]==1)
181516
- && (nVertex*2*sizeof(GeoCoord) + 4)==nByte
182499
+ && (nVertex*2*sizeof(GeoCoord) + 4)==(unsigned int)nByte
181517182500
){
181518182501
p = sqlite3_malloc64( sizeof(*p) + (nVertex-1)*2*sizeof(GeoCoord) );
181519182502
if( p==0 ){
181520182503
if( pRc ) *pRc = SQLITE_NOMEM;
181521182504
if( pCtx ) sqlite3_result_error_nomem(pCtx);
@@ -182764,11 +183747,11 @@
182764183747
}
182765183748
}
182766183749
}
182767183750
182768183751
/* Change the data */
182769
- if( rc==SQLITE_OK ){
183752
+ if( rc==SQLITE_OK && nData>1 ){
182770183753
sqlite3_stmt *pUp = pRtree->pWriteAux;
182771183754
int jj;
182772183755
int nChange = 0;
182773183756
sqlite3_bind_int64(pUp, 1, cell.iRowid);
182774183757
assert( pRtree->nAux>=1 );
@@ -210980,11 +211963,11 @@
210980211963
break;
210981211964
210982211965
case FTS5_SAVEPOINT:
210983211966
assert( p->ts.eState==1 );
210984211967
assert( iSavepoint>=0 );
210985
- assert( iSavepoint>p->ts.iSavepoint );
211968
+ assert( iSavepoint>=p->ts.iSavepoint );
210986211969
p->ts.iSavepoint = iSavepoint;
210987211970
break;
210988211971
210989211972
case FTS5_RELEASE:
210990211973
assert( p->ts.eState==1 );
@@ -211905,10 +212888,17 @@
211905212888
** fts5CursorFirstSorted() above. */
211906212889
assert( pRowidEq==0 && pRowidLe==0 && pRowidGe==0 && pRank==0 );
211907212890
assert( nVal==0 && pMatch==0 && bOrderByRank==0 && bDesc==0 );
211908212891
assert( pCsr->iLastRowid==LARGEST_INT64 );
211909212892
assert( pCsr->iFirstRowid==SMALLEST_INT64 );
212893
+ if( pTab->pSortCsr->bDesc ){
212894
+ pCsr->iLastRowid = pTab->pSortCsr->iFirstRowid;
212895
+ pCsr->iFirstRowid = pTab->pSortCsr->iLastRowid;
212896
+ }else{
212897
+ pCsr->iLastRowid = pTab->pSortCsr->iLastRowid;
212898
+ pCsr->iFirstRowid = pTab->pSortCsr->iFirstRowid;
212899
+ }
211910212900
pCsr->ePlan = FTS5_PLAN_SOURCE;
211911212901
pCsr->pExpr = pTab->pSortCsr->pExpr;
211912212902
rc = fts5CursorFirst(pTab, pCsr, bDesc);
211913212903
}else if( pMatch ){
211914212904
const char *zExpr = (const char*)sqlite3_value_text(apVal[0]);
@@ -213335,11 +214325,11 @@
213335214325
int nArg, /* Number of args */
213336214326
sqlite3_value **apUnused /* Function arguments */
213337214327
){
213338214328
assert( nArg==0 );
213339214329
UNUSED_PARAM2(nArg, apUnused);
213340
- sqlite3_result_text(pCtx, "fts5: 2018-08-30 01:52:10 58078c0d2647a194279fa80e032670441b296ffc3acee692901faa5beca460b7", -1, SQLITE_TRANSIENT);
214330
+ sqlite3_result_text(pCtx, "fts5: 2018-09-06 18:56:36 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5d3c3", -1, SQLITE_TRANSIENT);
213341214331
}
213342214332
213343214333
static int fts5Init(sqlite3 *db){
213344214334
static const sqlite3_module fts5Mod = {
213345214335
/* iVersion */ 2,
@@ -218045,12 +219035,12 @@
218045219035
}
218046219036
#endif /* SQLITE_CORE */
218047219037
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
218048219038
218049219039
/************** End of stmt.c ************************************************/
218050
-#if __LINE__!=218050
219040
+#if __LINE__!=219040
218051219041
#undef SQLITE_SOURCE_ID
218052
-#define SQLITE_SOURCE_ID "2018-08-30 01:52:10 58078c0d2647a194279fa80e032670441b296ffc3acee692901faa5beca4alt2"
219042
+#define SQLITE_SOURCE_ID "2018-09-06 18:56:36 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5alt2"
218053219043
#endif
218054219044
/* Return the source-id for this library */
218055219045
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
218056219046
/************************** End of sqlite3.c ******************************/
218057219047
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1156,11 +1156,11 @@
1156 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1157 ** [sqlite_version()] and [sqlite_source_id()].
1158 */
1159 #define SQLITE_VERSION "3.25.0"
1160 #define SQLITE_VERSION_NUMBER 3025000
1161 #define SQLITE_SOURCE_ID "2018-08-30 01:52:10 58078c0d2647a194279fa80e032670441b296ffc3acee692901faa5beca460b7"
1162
1163 /*
1164 ** CAPI3REF: Run-Time Library Version Numbers
1165 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1166 **
@@ -1503,10 +1503,11 @@
1503 ** the most recent error can be obtained using
1504 ** [sqlite3_extended_errcode()].
1505 */
1506 #define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
1507 #define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
 
1508 #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
1509 #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
1510 #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
1511 #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
1512 #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -10084,15 +10085,15 @@
10084 ** SQLITE_ERROR is returned if either of these conditions is violated, or
10085 ** if schema S does not exist, or if the snapshot object is invalid.
10086 **
10087 ** ^A call to sqlite3_snapshot_open() will fail to open if the specified
10088 ** snapshot has been overwritten by a [checkpoint]. In this case
10089 ** SQLITE_BUSY_SNAPSHOT is returned.
10090 **
10091 ** If there is already a read transaction open when this function is
10092 ** invoked, then the same read transaction remains open (on the same
10093 ** database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_BUSY_SNAPSHOT
10094 ** is returned. If another error code - for example SQLITE_PROTOCOL or an
10095 ** SQLITE_IOERR error code - is returned, then the final state of the
10096 ** read transaction is undefined. If SQLITE_OK is returned, then the
10097 ** read transaction is now open on database snapshot P.
10098 **
@@ -14025,10 +14026,11 @@
14025 typedef struct Module Module;
14026 typedef struct NameContext NameContext;
14027 typedef struct Parse Parse;
14028 typedef struct PreUpdate PreUpdate;
14029 typedef struct PrintfArguments PrintfArguments;
 
14030 typedef struct RowSet RowSet;
14031 typedef struct Savepoint Savepoint;
14032 typedef struct Select Select;
14033 typedef struct SQLiteThread SQLiteThread;
14034 typedef struct SelectDest SelectDest;
@@ -17010,13 +17012,15 @@
17010
17011 /*
17012 ** Each token coming out of the lexer is an instance of
17013 ** this structure. Tokens are also used as part of an expression.
17014 **
17015 ** Note if Token.z==0 then Token.dyn and Token.n are undefined and
17016 ** may contain random values. Do not make any assumptions about Token.dyn
17017 ** and Token.n when Token.z==0.
 
 
17018 */
17019 struct Token {
17020 const char *z; /* Text of the token. Not NULL-terminated! */
17021 unsigned int n; /* Number of characters in this token */
17022 };
@@ -17817,12 +17821,14 @@
17817
17818 Token sLastToken; /* The last token parsed */
17819 ynVar nVar; /* Number of '?' variables seen in the SQL so far */
17820 u8 iPkSortOrder; /* ASC or DESC for INTEGER PRIMARY KEY */
17821 u8 explain; /* True if the EXPLAIN flag is found on the query */
 
 
 
17822 #ifndef SQLITE_OMIT_VIRTUALTABLE
17823 u8 declareVtab; /* True if inside sqlite3_declare_vtab() */
17824 int nVtabLock; /* Number of virtual tables to lock */
17825 #endif
17826 int nHeight; /* Expression tree height of current sub-select */
17827 #ifndef SQLITE_OMIT_EXPLAIN
17828 int addrExplain; /* Address of current OP_Explain opcode */
@@ -17829,10 +17835,11 @@
17829 #endif
17830 VList *pVList; /* Mapping between variable names and numbers */
17831 Vdbe *pReprepare; /* VM being reprepared (sqlite3Reprepare()) */
17832 const char *zTail; /* All SQL text past the last semicolon parsed */
17833 Table *pNewTable; /* A table being constructed by CREATE TABLE */
 
17834 Trigger *pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */
17835 const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */
17836 #ifndef SQLITE_OMIT_VIRTUALTABLE
17837 Token sArg; /* Complete text of a module argument */
17838 Table **apVtabLock; /* Pointer to virtual tables needing locking */
@@ -17839,11 +17846,19 @@
17839 #endif
17840 Table *pZombieTab; /* List of Table objects to delete after code gen */
17841 TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
17842 With *pWith; /* Current WITH clause, or NULL */
17843 With *pWithToFree; /* Free this WITH object at the end of the parse */
 
 
 
17844 };
 
 
 
 
 
17845
17846 /*
17847 ** Sizes and pointers of various parts of the Parse object.
17848 */
17849 #define PARSE_HDR_SZ offsetof(Parse,aTempReg) /* Recursive part w/o aColCache*/
@@ -17855,11 +17870,23 @@
17855 ** Return true if currently inside an sqlite3_declare_vtab() call.
17856 */
17857 #ifdef SQLITE_OMIT_VIRTUALTABLE
17858 #define IN_DECLARE_VTAB 0
17859 #else
17860 #define IN_DECLARE_VTAB (pParse->declareVtab)
 
 
 
 
 
 
 
 
 
 
 
 
17861 #endif
17862
17863 /*
17864 ** An instance of the following structure can be declared on a stack and used
17865 ** to save the Parse.zAuthContext value so that it can be restored later.
@@ -18034,12 +18061,18 @@
18034 typedef struct {
18035 sqlite3 *db; /* The database being initialized */
18036 char **pzErrMsg; /* Error message stored here */
18037 int iDb; /* 0 for main database. 1 for TEMP, 2.. for ATTACHed */
18038 int rc; /* Result code stored here */
 
18039 } InitData;
18040
 
 
 
 
 
18041 /*
18042 ** Structure containing global configuration data for the SQLite library.
18043 **
18044 ** This structure also contains some state information.
18045 */
@@ -18139,10 +18172,11 @@
18139 struct IdxExprTrans *pIdxTrans; /* Convert idxed expr to column */
18140 ExprList *pGroupBy; /* GROUP BY clause */
18141 Select *pSelect; /* HAVING to WHERE clause ctx */
18142 struct WindowRewrite *pRewrite; /* Window rewrite context */
18143 struct WhereConst *pConst; /* WHERE clause constants */
 
18144 } u;
18145 };
18146
18147 /* Forward declarations */
18148 SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
@@ -18338,13 +18372,11 @@
18338 # define sqlite3Isdigit(x) isdigit((unsigned char)(x))
18339 # define sqlite3Isxdigit(x) isxdigit((unsigned char)(x))
18340 # define sqlite3Tolower(x) tolower((unsigned char)(x))
18341 # define sqlite3Isquote(x) ((x)=='"'||(x)=='\''||(x)=='['||(x)=='`')
18342 #endif
18343 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
18344 SQLITE_PRIVATE int sqlite3IsIdChar(u8);
18345 #endif
18346
18347 /*
18348 ** Internal function prototypes
18349 */
18350 SQLITE_PRIVATE int sqlite3StrICmp(const char*,const char*);
@@ -18505,10 +18537,11 @@
18505 SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);
18506 SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
18507 SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
18508 SQLITE_PRIVATE int sqlite3Init(sqlite3*, char**);
18509 SQLITE_PRIVATE int sqlite3InitCallback(void*, int, char**, char**);
 
18510 SQLITE_PRIVATE void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);
18511 #ifndef SQLITE_OMIT_VIRTUALTABLE
18512 SQLITE_PRIVATE Module *sqlite3PragmaVtabRegister(sqlite3*,const char *zName);
18513 #endif
18514 SQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3*);
@@ -18575,20 +18608,21 @@
18575 SQLITE_PRIVATE int sqlite3DbMaskAllZero(yDbMask);
18576 #endif
18577 SQLITE_PRIVATE void sqlite3DropTable(Parse*, SrcList*, int, int);
18578 SQLITE_PRIVATE void sqlite3CodeDropTable(Parse*, Table*, int, int);
18579 SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3*, Table*);
 
18580 #ifndef SQLITE_OMIT_AUTOINCREMENT
18581 SQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse);
18582 SQLITE_PRIVATE void sqlite3AutoincrementEnd(Parse *pParse);
18583 #else
18584 # define sqlite3AutoincrementBegin(X)
18585 # define sqlite3AutoincrementEnd(X)
18586 #endif
18587 SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*);
18588 SQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);
18589 SQLITE_PRIVATE IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token*);
18590 SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*);
18591 SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int);
18592 SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*);
18593 SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,
18594 Token*, Select*, Expr*, IdList*);
@@ -18746,16 +18780,16 @@
18746 SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);
18747 void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
18748 SQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);
18749 SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*,
18750 const char*,const char*);
18751 SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*,
18752 Select*,u8,Upsert*,
18753 const char*,const char*);
18754 SQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8,
18755 const char*,const char*);
18756 SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*,
18757 const char*,const char*);
18758 SQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3*, Trigger*);
18759 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
18760 SQLITE_PRIVATE u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);
18761 # define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))
@@ -18919,10 +18953,11 @@
18919 #endif
18920 SQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3*, int, int, int);
18921 SQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*);
18922 SQLITE_PRIVATE void sqlite3AlterFunctions(void);
18923 SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
 
18924 SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);
18925 SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
18926 SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*, int);
18927 SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr *, int, int);
18928 SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
@@ -18934,10 +18969,13 @@
18934 SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
18935 SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
18936 SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
18937 SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
18938 SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
 
 
 
18939 SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
18940 SQLITE_PRIVATE char sqlite3AffinityType(const char*, Column*);
18941 SQLITE_PRIVATE void sqlite3Analyze(Parse*, Token*, Token*);
18942 SQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler*, sqlite3_file*);
18943 SQLITE_PRIVATE int sqlite3FindDb(sqlite3*, Token*);
@@ -51028,12 +51066,16 @@
51028 ** containing the state of the Pager object passed as an argument. This
51029 ** is intended to be used within debuggers. For example, as an alternative
51030 ** to "print *pPager" in gdb:
51031 **
51032 ** (gdb) printf "%s", print_pager_state(pPager)
 
 
 
 
51033 */
51034 static char *print_pager_state(Pager *p){
51035 static char zRet[1024];
51036
51037 sqlite3_snprintf(1024, zRet,
51038 "Filename: %s\n"
51039 "State: %s errCode=%d\n"
@@ -57308,17 +57350,10 @@
57308 **
57309 ** The returned indicate the current (possibly updated) journal-mode.
57310 */
57311 SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){
57312 u8 eOld = pPager->journalMode; /* Prior journalmode */
57313
57314 #ifdef SQLITE_DEBUG
57315 /* The print_pager_state() routine is intended to be used by the debugger
57316 ** only. We invoke it once here to suppress a compiler warning. */
57317 print_pager_state(pPager);
57318 #endif
57319
57320
57321 /* The eMode parameter is always valid */
57322 assert( eMode==PAGER_JOURNALMODE_DELETE
57323 || eMode==PAGER_JOURNALMODE_TRUNCATE
57324 || eMode==PAGER_JOURNALMODE_PERSIST
@@ -57997,10 +58032,22 @@
57997 # define WALTRACE(X) if(sqlite3WalTrace) sqlite3DebugPrintf X
57998 #else
57999 # define WALTRACE(X)
58000 #endif
58001
 
 
 
 
 
 
 
 
 
 
 
 
58002 /*
58003 ** The maximum (and only) versions of the wal and wal-index formats
58004 ** that may be interpreted by this version of SQLite.
58005 **
58006 ** If a client begins recovering a WAL file and finds that (a) the checksum
@@ -60294,11 +60341,11 @@
60294 if( pWal->pSnapshot && pWal->pSnapshot->mxFrame<mxFrame ){
60295 mxFrame = pWal->pSnapshot->mxFrame;
60296 }
60297 #endif
60298 for(i=1; i<WAL_NREADER; i++){
60299 u32 thisMark = pInfo->aReadMark[i];
60300 if( mxReadMark<=thisMark && thisMark<=mxFrame ){
60301 assert( thisMark!=READMARK_NOT_USED );
60302 mxReadMark = thisMark;
60303 mxI = i;
60304 }
@@ -60307,11 +60354,11 @@
60307 && (mxReadMark<mxFrame || mxI==0)
60308 ){
60309 for(i=1; i<WAL_NREADER; i++){
60310 rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
60311 if( rc==SQLITE_OK ){
60312 mxReadMark = pInfo->aReadMark[i] = mxFrame;
60313 mxI = i;
60314 walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
60315 break;
60316 }else if( rc!=SQLITE_BUSY ){
60317 return rc;
@@ -60359,13 +60406,13 @@
60359 ** frame pWal->hdr.mxFrame - then the client would incorrectly assume
60360 ** that it can read version A from the database file. However, since
60361 ** we can guarantee that the checkpointer that set nBackfill could not
60362 ** see any pages past pWal->hdr.mxFrame, this problem does not come up.
60363 */
60364 pWal->minFrame = pInfo->nBackfill+1;
60365 walShmBarrier(pWal);
60366 if( pInfo->aReadMark[mxI]!=mxReadMark
60367 || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr))
60368 ){
60369 walUnlockShared(pWal, WAL_READ_LOCK(mxI));
60370 return WAL_RETRY;
60371 }else{
@@ -60522,21 +60569,21 @@
60522
60523 if( rc==SQLITE_OK ){
60524 /* Check that the wal file has not been wrapped. Assuming that it has
60525 ** not, also check that no checkpointer has attempted to checkpoint any
60526 ** frames beyond pSnapshot->mxFrame. If either of these conditions are
60527 ** true, return SQLITE_BUSY_SNAPSHOT. Otherwise, overwrite pWal->hdr
60528 ** with *pSnapshot and set *pChanged as appropriate for opening the
60529 ** snapshot. */
60530 if( !memcmp(pSnapshot->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))
60531 && pSnapshot->mxFrame>=pInfo->nBackfillAttempted
60532 ){
60533 assert( pWal->readLock>0 );
60534 memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr));
60535 *pChanged = bChanged;
60536 }else{
60537 rc = SQLITE_BUSY_SNAPSHOT;
60538 }
60539
60540 /* Release the shared CKPT lock obtained above. */
60541 walUnlockShared(pWal, WAL_CKPT_LOCK);
60542 pWal->minFrame = 1;
@@ -61529,11 +61576,11 @@
61529 if( rc==SQLITE_OK ){
61530 WalIndexHdr *pNew = (WalIndexHdr*)pSnapshot;
61531 if( memcmp(pNew->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))
61532 || pNew->mxFrame<walCkptInfo(pWal)->nBackfillAttempted
61533 ){
61534 rc = SQLITE_BUSY_SNAPSHOT;
61535 walUnlockShared(pWal, WAL_CKPT_LOCK);
61536 }
61537 }
61538 return rc;
61539 }
@@ -77145,11 +77192,10 @@
77145 ** and reset(). Inserts are grouped into a transaction.
77146 */
77147 testcase( p->flags & MEM_Agg );
77148 testcase( p->flags & MEM_Dyn );
77149 testcase( p->xDel==sqlite3VdbeFrameMemDel );
77150 testcase( p->flags & MEM_RowSet );
77151 if( p->flags&(MEM_Agg|MEM_Dyn) ){
77152 sqlite3VdbeMemRelease(p);
77153 }else if( p->szMalloc ){
77154 sqlite3DbFreeNN(db, p->zMalloc);
77155 p->szMalloc = 0;
@@ -88319,11 +88365,12 @@
88319 }
88320
88321 /* Opcode: ParseSchema P1 * * P4 *
88322 **
88323 ** Read and parse all entries from the SQLITE_MASTER table of database P1
88324 ** that match the WHERE clause P4.
 
88325 **
88326 ** This opcode invokes the parser to create a new virtual machine,
88327 ** then runs the new virtual machine. It is thus a re-entrant opcode.
88328 */
88329 case OP_ParseSchema: {
@@ -88343,11 +88390,21 @@
88343 #endif
88344
88345 iDb = pOp->p1;
88346 assert( iDb>=0 && iDb<db->nDb );
88347 assert( DbHasProperty(db, iDb, DB_SchemaLoaded) );
88348 /* Used to be a conditional */ {
 
 
 
 
 
 
 
 
 
 
88349 zMaster = MASTER_NAME;
88350 initData.db = db;
88351 initData.iDb = pOp->p1;
88352 initData.pzErrMsg = &p->zErrMsg;
88353 zSql = sqlite3MPrintf(db,
@@ -94301,10 +94358,13 @@
94301 const char *zTabName = pItem->zAlias ? pItem->zAlias : pTab->zName;
94302 assert( zTabName!=0 );
94303 if( sqlite3StrICmp(zTabName, zTab)!=0 ){
94304 continue;
94305 }
 
 
 
94306 }
94307 if( 0==(cntTab++) ){
94308 pMatch = pItem;
94309 }
94310 for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){
@@ -94386,13 +94446,19 @@
94386 if( iCol<pTab->nCol ){
94387 cnt++;
94388 #ifndef SQLITE_OMIT_UPSERT
94389 if( pExpr->iTable==2 ){
94390 testcase( iCol==(-1) );
94391 pExpr->iTable = pNC->uNC.pUpsert->regData + iCol;
94392 eNewExprOp = TK_REGISTER;
94393 ExprSetProperty(pExpr, EP_Alias);
 
 
 
 
 
 
94394 }else
94395 #endif /* SQLITE_OMIT_UPSERT */
94396 {
94397 #ifndef SQLITE_OMIT_TRIGGER
94398 if( iCol<0 ){
@@ -94473,10 +94539,13 @@
94473 }
94474 resolveAlias(pParse, pEList, j, pExpr, "", nSubquery);
94475 cnt = 1;
94476 pMatch = 0;
94477 assert( zTab==0 && zDb==0 );
 
 
 
94478 goto lookupname_end;
94479 }
94480 }
94481 }
94482
@@ -94700,21 +94769,28 @@
94700 if( pExpr->op==TK_ID ){
94701 zDb = 0;
94702 zTable = 0;
94703 zColumn = pExpr->u.zToken;
94704 }else{
 
94705 notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr);
94706 pRight = pExpr->pRight;
94707 if( pRight->op==TK_ID ){
94708 zDb = 0;
94709 zTable = pExpr->pLeft->u.zToken;
94710 zColumn = pRight->u.zToken;
94711 }else{
94712 assert( pRight->op==TK_DOT );
94713 zDb = pExpr->pLeft->u.zToken;
94714 zTable = pRight->pLeft->u.zToken;
94715 zColumn = pRight->pRight->u.zToken;
 
 
 
 
 
 
 
 
94716 }
94717 }
94718 return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);
94719 }
94720
@@ -94794,60 +94870,62 @@
94794 notValid(pParse, pNC, "non-deterministic functions",
94795 NC_IdxExpr|NC_PartIdx);
94796 }
94797 }
94798
 
94799 #ifndef SQLITE_OMIT_WINDOWFUNC
94800 assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)
94801 || (pDef->xValue==0 && pDef->xInverse==0)
94802 || (pDef->xValue && pDef->xInverse && pDef->xSFunc && pDef->xFinalize)
94803 );
94804 if( pDef && pDef->xValue==0 && pExpr->pWin ){
94805 sqlite3ErrorMsg(pParse,
94806 "%.*s() may not be used as a window function", nId, zId
94807 );
94808 pNC->nErr++;
94809 }else if(
94810 (is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
94811 || (is_agg && (pDef->funcFlags & SQLITE_FUNC_WINDOW) && !pExpr->pWin)
94812 || (is_agg && pExpr->pWin && (pNC->ncFlags & NC_AllowWin)==0)
94813 ){
94814 const char *zType;
94815 if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pExpr->pWin ){
94816 zType = "window";
94817 }else{
94818 zType = "aggregate";
94819 }
94820 sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()", zType, nId,zId);
94821 pNC->nErr++;
94822 is_agg = 0;
94823 }
94824 #else
94825 if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){
94826 sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);
94827 pNC->nErr++;
94828 is_agg = 0;
94829 }
94830 #endif
94831 else if( no_such_func && pParse->db->init.busy==0
94832 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
94833 && pParse->explain==0
94834 #endif
94835 ){
94836 sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
94837 pNC->nErr++;
94838 }else if( wrong_num_args ){
94839 sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
94840 nId, zId);
94841 pNC->nErr++;
94842 }
94843 if( is_agg ){
94844 #ifndef SQLITE_OMIT_WINDOWFUNC
94845 pNC->ncFlags &= ~(pExpr->pWin ? NC_AllowWin : NC_AllowAgg);
94846 #else
94847 pNC->ncFlags &= ~NC_AllowAgg;
94848 #endif
 
94849 }
94850 sqlite3WalkExprList(pWalker, pList);
94851 if( is_agg ){
94852 #ifndef SQLITE_OMIT_WINDOWFUNC
94853 if( pExpr->pWin ){
@@ -97358,10 +97436,13 @@
97358 assert( pList->nExpr>0 );
97359 pItem = &pList->a[pList->nExpr-1];
97360 assert( pItem->zName==0 );
97361 pItem->zName = sqlite3DbStrNDup(pParse->db, pName->z, pName->n);
97362 if( dequote ) sqlite3Dequote(pItem->zName);
 
 
 
97363 }
97364 }
97365
97366 /*
97367 ** Set the ExprList.a[].zSpan element of the most recently added item
@@ -101056,356 +101137,10 @@
101056 ** The code in this file only exists if we are not omitting the
101057 ** ALTER TABLE logic from the build.
101058 */
101059 #ifndef SQLITE_OMIT_ALTERTABLE
101060
101061
101062 /*
101063 ** This function is used by SQL generated to implement the
101064 ** ALTER TABLE command. The first argument is the text of a CREATE TABLE or
101065 ** CREATE INDEX command. The second is a table name. The table name in
101066 ** the CREATE TABLE or CREATE INDEX statement is replaced with the third
101067 ** argument and the result returned. Examples:
101068 **
101069 ** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def')
101070 ** -> 'CREATE TABLE def(a, b, c)'
101071 **
101072 ** sqlite_rename_table('CREATE INDEX i ON abc(a)', 'def')
101073 ** -> 'CREATE INDEX i ON def(a, b, c)'
101074 */
101075 static void renameTableFunc(
101076 sqlite3_context *context,
101077 int NotUsed,
101078 sqlite3_value **argv
101079 ){
101080 unsigned char const *zSql = sqlite3_value_text(argv[0]);
101081 unsigned char const *zTableName = sqlite3_value_text(argv[1]);
101082
101083 int token;
101084 Token tname;
101085 unsigned char const *zCsr = zSql;
101086 int len = 0;
101087 char *zRet;
101088
101089 sqlite3 *db = sqlite3_context_db_handle(context);
101090
101091 UNUSED_PARAMETER(NotUsed);
101092
101093 /* The principle used to locate the table name in the CREATE TABLE
101094 ** statement is that the table name is the first non-space token that
101095 ** is immediately followed by a TK_LP or TK_USING token.
101096 */
101097 if( zSql ){
101098 do {
101099 if( !*zCsr ){
101100 /* Ran out of input before finding an opening bracket. Return NULL. */
101101 return;
101102 }
101103
101104 /* Store the token that zCsr points to in tname. */
101105 tname.z = (char*)zCsr;
101106 tname.n = len;
101107
101108 /* Advance zCsr to the next token. Store that token type in 'token',
101109 ** and its length in 'len' (to be used next iteration of this loop).
101110 */
101111 do {
101112 zCsr += len;
101113 len = sqlite3GetToken(zCsr, &token);
101114 } while( token==TK_SPACE );
101115 assert( len>0 || !*zCsr );
101116 } while( token!=TK_LP && token!=TK_USING );
101117
101118 zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", (int)(((u8*)tname.z) - zSql),
101119 zSql, zTableName, tname.z+tname.n);
101120 sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);
101121 }
101122 }
101123
101124 /*
101125 ** This C function implements an SQL user function that is used by SQL code
101126 ** generated by the ALTER TABLE ... RENAME command to modify the definition
101127 ** of any foreign key constraints that use the table being renamed as the
101128 ** parent table. It is passed three arguments:
101129 **
101130 ** 1) The complete text of the CREATE TABLE statement being modified,
101131 ** 2) The old name of the table being renamed, and
101132 ** 3) The new name of the table being renamed.
101133 **
101134 ** It returns the new CREATE TABLE statement. For example:
101135 **
101136 ** sqlite_rename_parent('CREATE TABLE t1(a REFERENCES t2)', 't2', 't3')
101137 ** -> 'CREATE TABLE t1(a REFERENCES t3)'
101138 */
101139 #ifndef SQLITE_OMIT_FOREIGN_KEY
101140 static void renameParentFunc(
101141 sqlite3_context *context,
101142 int NotUsed,
101143 sqlite3_value **argv
101144 ){
101145 sqlite3 *db = sqlite3_context_db_handle(context);
101146 char *zOutput = 0;
101147 char *zResult;
101148 unsigned char const *zInput = sqlite3_value_text(argv[0]);
101149 unsigned char const *zOld = sqlite3_value_text(argv[1]);
101150 unsigned char const *zNew = sqlite3_value_text(argv[2]);
101151
101152 unsigned const char *z; /* Pointer to token */
101153 int n; /* Length of token z */
101154 int token; /* Type of token */
101155
101156 UNUSED_PARAMETER(NotUsed);
101157 if( zInput==0 || zOld==0 ) return;
101158 for(z=zInput; *z; z=z+n){
101159 n = sqlite3GetToken(z, &token);
101160 if( token==TK_REFERENCES ){
101161 char *zParent;
101162 do {
101163 z += n;
101164 n = sqlite3GetToken(z, &token);
101165 }while( token==TK_SPACE );
101166
101167 if( token==TK_ILLEGAL ) break;
101168 zParent = sqlite3DbStrNDup(db, (const char *)z, n);
101169 if( zParent==0 ) break;
101170 sqlite3Dequote(zParent);
101171 if( 0==sqlite3StrICmp((const char *)zOld, zParent) ){
101172 char *zOut = sqlite3MPrintf(db, "%s%.*s\"%w\"",
101173 (zOutput?zOutput:""), (int)(z-zInput), zInput, (const char *)zNew
101174 );
101175 sqlite3DbFree(db, zOutput);
101176 zOutput = zOut;
101177 zInput = &z[n];
101178 }
101179 sqlite3DbFree(db, zParent);
101180 }
101181 }
101182
101183 zResult = sqlite3MPrintf(db, "%s%s", (zOutput?zOutput:""), zInput);
101184 sqlite3_result_text(context, zResult, -1, SQLITE_DYNAMIC);
101185 sqlite3DbFree(db, zOutput);
101186 }
101187 #endif
101188
101189 #ifndef SQLITE_OMIT_TRIGGER
101190 /* This function is used by SQL generated to implement the
101191 ** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER
101192 ** statement. The second is a table name. The table name in the CREATE
101193 ** TRIGGER statement is replaced with the third argument and the result
101194 ** returned. This is analagous to renameTableFunc() above, except for CREATE
101195 ** TRIGGER, not CREATE INDEX and CREATE TABLE.
101196 */
101197 static void renameTriggerFunc(
101198 sqlite3_context *context,
101199 int NotUsed,
101200 sqlite3_value **argv
101201 ){
101202 unsigned char const *zSql = sqlite3_value_text(argv[0]);
101203 unsigned char const *zTableName = sqlite3_value_text(argv[1]);
101204
101205 int token;
101206 Token tname;
101207 int dist = 3;
101208 unsigned char const *zCsr = zSql;
101209 int len = 0;
101210 char *zRet;
101211 sqlite3 *db = sqlite3_context_db_handle(context);
101212
101213 UNUSED_PARAMETER(NotUsed);
101214
101215 /* The principle used to locate the table name in the CREATE TRIGGER
101216 ** statement is that the table name is the first token that is immediately
101217 ** preceded by either TK_ON or TK_DOT and immediately followed by one
101218 ** of TK_WHEN, TK_BEGIN or TK_FOR.
101219 */
101220 if( zSql ){
101221 do {
101222
101223 if( !*zCsr ){
101224 /* Ran out of input before finding the table name. Return NULL. */
101225 return;
101226 }
101227
101228 /* Store the token that zCsr points to in tname. */
101229 tname.z = (char*)zCsr;
101230 tname.n = len;
101231
101232 /* Advance zCsr to the next token. Store that token type in 'token',
101233 ** and its length in 'len' (to be used next iteration of this loop).
101234 */
101235 do {
101236 zCsr += len;
101237 len = sqlite3GetToken(zCsr, &token);
101238 }while( token==TK_SPACE );
101239 assert( len>0 || !*zCsr );
101240
101241 /* Variable 'dist' stores the number of tokens read since the most
101242 ** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN
101243 ** token is read and 'dist' equals 2, the condition stated above
101244 ** to be met.
101245 **
101246 ** Note that ON cannot be a database, table or column name, so
101247 ** there is no need to worry about syntax like
101248 ** "CREATE TRIGGER ... ON ON.ON BEGIN ..." etc.
101249 */
101250 dist++;
101251 if( token==TK_DOT || token==TK_ON ){
101252 dist = 0;
101253 }
101254 } while( dist!=2 || (token!=TK_WHEN && token!=TK_FOR && token!=TK_BEGIN) );
101255
101256 /* Variable tname now contains the token that is the old table-name
101257 ** in the CREATE TRIGGER statement.
101258 */
101259 zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", (int)(((u8*)tname.z) - zSql),
101260 zSql, zTableName, tname.z+tname.n);
101261 sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);
101262 }
101263 }
101264 #endif /* !SQLITE_OMIT_TRIGGER */
101265
101266 /*
101267 ** Register built-in functions used to help implement ALTER TABLE
101268 */
101269 SQLITE_PRIVATE void sqlite3AlterFunctions(void){
101270 static FuncDef aAlterTableFuncs[] = {
101271 FUNCTION(sqlite_rename_table, 2, 0, 0, renameTableFunc),
101272 #ifndef SQLITE_OMIT_TRIGGER
101273 FUNCTION(sqlite_rename_trigger, 2, 0, 0, renameTriggerFunc),
101274 #endif
101275 #ifndef SQLITE_OMIT_FOREIGN_KEY
101276 FUNCTION(sqlite_rename_parent, 3, 0, 0, renameParentFunc),
101277 #endif
101278 };
101279 sqlite3InsertBuiltinFuncs(aAlterTableFuncs, ArraySize(aAlterTableFuncs));
101280 }
101281
101282 /*
101283 ** This function is used to create the text of expressions of the form:
101284 **
101285 ** name=<constant1> OR name=<constant2> OR ...
101286 **
101287 ** If argument zWhere is NULL, then a pointer string containing the text
101288 ** "name=<constant>" is returned, where <constant> is the quoted version
101289 ** of the string passed as argument zConstant. The returned buffer is
101290 ** allocated using sqlite3DbMalloc(). It is the responsibility of the
101291 ** caller to ensure that it is eventually freed.
101292 **
101293 ** If argument zWhere is not NULL, then the string returned is
101294 ** "<where> OR name=<constant>", where <where> is the contents of zWhere.
101295 ** In this case zWhere is passed to sqlite3DbFree() before returning.
101296 **
101297 */
101298 static char *whereOrName(sqlite3 *db, char *zWhere, char *zConstant){
101299 char *zNew;
101300 if( !zWhere ){
101301 zNew = sqlite3MPrintf(db, "name=%Q", zConstant);
101302 }else{
101303 zNew = sqlite3MPrintf(db, "%s OR name=%Q", zWhere, zConstant);
101304 sqlite3DbFree(db, zWhere);
101305 }
101306 return zNew;
101307 }
101308
101309 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
101310 /*
101311 ** Generate the text of a WHERE expression which can be used to select all
101312 ** tables that have foreign key constraints that refer to table pTab (i.e.
101313 ** constraints for which pTab is the parent table) from the sqlite_master
101314 ** table.
101315 */
101316 static char *whereForeignKeys(Parse *pParse, Table *pTab){
101317 FKey *p;
101318 char *zWhere = 0;
101319 for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){
101320 zWhere = whereOrName(pParse->db, zWhere, p->pFrom->zName);
101321 }
101322 return zWhere;
101323 }
101324 #endif
101325
101326 /*
101327 ** Generate the text of a WHERE expression which can be used to select all
101328 ** temporary triggers on table pTab from the sqlite_temp_master table. If
101329 ** table pTab has no temporary triggers, or is itself stored in the
101330 ** temporary database, NULL is returned.
101331 */
101332 static char *whereTempTriggers(Parse *pParse, Table *pTab){
101333 Trigger *pTrig;
101334 char *zWhere = 0;
101335 const Schema *pTempSchema = pParse->db->aDb[1].pSchema; /* Temp db schema */
101336
101337 /* If the table is not located in the temp-db (in which case NULL is
101338 ** returned, loop through the tables list of triggers. For each trigger
101339 ** that is not part of the temp-db schema, add a clause to the WHERE
101340 ** expression being built up in zWhere.
101341 */
101342 if( pTab->pSchema!=pTempSchema ){
101343 sqlite3 *db = pParse->db;
101344 for(pTrig=sqlite3TriggerList(pParse, pTab); pTrig; pTrig=pTrig->pNext){
101345 if( pTrig->pSchema==pTempSchema ){
101346 zWhere = whereOrName(db, zWhere, pTrig->zName);
101347 }
101348 }
101349 }
101350 if( zWhere ){
101351 char *zNew = sqlite3MPrintf(pParse->db, "type='trigger' AND (%s)", zWhere);
101352 sqlite3DbFree(pParse->db, zWhere);
101353 zWhere = zNew;
101354 }
101355 return zWhere;
101356 }
101357
101358 /*
101359 ** Generate code to drop and reload the internal representation of table
101360 ** pTab from the database, including triggers and temporary triggers.
101361 ** Argument zName is the name of the table in the database schema at
101362 ** the time the generated code is executed. This can be different from
101363 ** pTab->zName if this function is being called to code part of an
101364 ** "ALTER TABLE RENAME TO" statement.
101365 */
101366 static void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){
101367 Vdbe *v;
101368 char *zWhere;
101369 int iDb; /* Index of database containing pTab */
101370 #ifndef SQLITE_OMIT_TRIGGER
101371 Trigger *pTrig;
101372 #endif
101373
101374 v = sqlite3GetVdbe(pParse);
101375 if( NEVER(v==0) ) return;
101376 assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );
101377 iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
101378 assert( iDb>=0 );
101379
101380 #ifndef SQLITE_OMIT_TRIGGER
101381 /* Drop any table triggers from the internal schema. */
101382 for(pTrig=sqlite3TriggerList(pParse, pTab); pTrig; pTrig=pTrig->pNext){
101383 int iTrigDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);
101384 assert( iTrigDb==iDb || iTrigDb==1 );
101385 sqlite3VdbeAddOp4(v, OP_DropTrigger, iTrigDb, 0, 0, pTrig->zName, 0);
101386 }
101387 #endif
101388
101389 /* Drop the table and index from the internal schema. */
101390 sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);
101391
101392 /* Reload the table, index and permanent trigger schemas. */
101393 zWhere = sqlite3MPrintf(pParse->db, "tbl_name=%Q", zName);
101394 if( !zWhere ) return;
101395 sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
101396
101397 #ifndef SQLITE_OMIT_TRIGGER
101398 /* Now, if the table is not stored in the temp database, reload any temp
101399 ** triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined.
101400 */
101401 if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){
101402 sqlite3VdbeAddParseSchemaOp(v, 1, zWhere);
101403 }
101404 #endif
101405 }
101406
101407 /*
101408 ** Parameter zName is the name of a table that is about to be altered
101409 ** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN).
101410 ** If the table is a system table, this function leaves an error message
101411 ** in pParse->zErr (system tables may not be altered) and returns non-zero.
@@ -101417,10 +101152,53 @@
101417 sqlite3ErrorMsg(pParse, "table %s may not be altered", zName);
101418 return 1;
101419 }
101420 return 0;
101421 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101422
101423 /*
101424 ** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy"
101425 ** command.
101426 */
@@ -101435,13 +101213,10 @@
101435 char *zName = 0; /* NULL-terminated version of pName */
101436 sqlite3 *db = pParse->db; /* Database connection */
101437 int nTabName; /* Number of UTF-8 characters in zTabName */
101438 const char *zTabName; /* Original name of the table */
101439 Vdbe *v;
101440 #ifndef SQLITE_OMIT_TRIGGER
101441 char *zWhere = 0; /* Where clause to locate temp triggers */
101442 #endif
101443 VTable *pVTab = 0; /* Non-zero if this is a v-tab with an xRename() */
101444 u32 savedDbFlags; /* Saved value of db->mDbFlags */
101445
101446 savedDbFlags = db->mDbFlags;
101447 if( NEVER(db->mallocFailed) ) goto exit_rename_table;
@@ -101510,12 +101285,10 @@
101510 */
101511 v = sqlite3GetVdbe(pParse);
101512 if( v==0 ){
101513 goto exit_rename_table;
101514 }
101515 sqlite3BeginWriteOperation(pParse, pVTab!=0, iDb);
101516 sqlite3ChangeCookie(pParse, iDb);
101517
101518 /* If this is a virtual table, invoke the xRename() function if
101519 ** one is defined. The xRename() callback will modify the names
101520 ** of any resources used by the v-table implementation (including other
101521 ** SQLite tables) that are identified by the name of the virtual table.
@@ -101531,48 +101304,35 @@
101531
101532 /* figure out how many UTF-8 characters are in zName */
101533 zTabName = pTab->zName;
101534 nTabName = sqlite3Utf8CharLen(zTabName, -1);
101535
101536 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
101537 if( db->flags&SQLITE_ForeignKeys ){
101538 /* If foreign-key support is enabled, rewrite the CREATE TABLE
101539 ** statements corresponding to all child tables of foreign key constraints
101540 ** for which the renamed table is the parent table. */
101541 if( (zWhere=whereForeignKeys(pParse, pTab))!=0 ){
101542 sqlite3NestedParse(pParse,
101543 "UPDATE \"%w\".%s SET "
101544 "sql = sqlite_rename_parent(sql, %Q, %Q) "
101545 "WHERE %s;", zDb, MASTER_NAME, zTabName, zName, zWhere);
101546 sqlite3DbFree(db, zWhere);
101547 }
101548 }
101549 #endif
101550
101551 /* Modify the sqlite_master table to use the new table name. */
101552 sqlite3NestedParse(pParse,
101553 "UPDATE %Q.%s SET "
101554 #ifdef SQLITE_OMIT_TRIGGER
101555 "sql = sqlite_rename_table(sql, %Q), "
101556 #else
101557 "sql = CASE "
101558 "WHEN type = 'trigger' THEN sqlite_rename_trigger(sql, %Q)"
101559 "ELSE sqlite_rename_table(sql, %Q) END, "
101560 #endif
101561 "tbl_name = %Q, "
101562 "name = CASE "
101563 "WHEN type='table' THEN %Q "
101564 "WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN "
101565 "'sqlite_autoindex_' || %Q || substr(name,%d+18) "
101566 "ELSE name END "
101567 "WHERE tbl_name=%Q COLLATE nocase AND "
101568 "(type='table' OR type='index' OR type='trigger');",
101569 zDb, MASTER_NAME, zName, zName, zName,
101570 #ifndef SQLITE_OMIT_TRIGGER
101571 zName,
101572 #endif
101573 zName, nTabName, zTabName
101574 );
101575
101576 #ifndef SQLITE_OMIT_AUTOINCREMENT
101577 /* If the sqlite_sequence table exists in this database, then update
101578 ** it with the new table name.
@@ -101582,39 +101342,27 @@
101582 "UPDATE \"%w\".sqlite_sequence set name = %Q WHERE name = %Q",
101583 zDb, zName, pTab->zName);
101584 }
101585 #endif
101586
101587 #ifndef SQLITE_OMIT_TRIGGER
101588 /* If there are TEMP triggers on this table, modify the sqlite_temp_master
101589 ** table. Don't do this if the table being ALTERed is itself located in
101590 ** the temp database.
101591 */
101592 if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){
101593 sqlite3NestedParse(pParse,
101594 "UPDATE sqlite_temp_master SET "
101595 "sql = sqlite_rename_trigger(sql, %Q), "
101596 "tbl_name = %Q "
101597 "WHERE %s;", zName, zName, zWhere);
101598 sqlite3DbFree(db, zWhere);
101599 }
101600 #endif
101601
101602 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
101603 if( db->flags&SQLITE_ForeignKeys ){
101604 FKey *p;
101605 for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){
101606 Table *pFrom = p->pFrom;
101607 if( pFrom!=pTab ){
101608 reloadTableSchema(pParse, p->pFrom, pFrom->zName);
101609 }
101610 }
101611 }
101612 #endif
101613
101614 /* Drop and reload the internal table schema. */
101615 reloadTableSchema(pParse, pTab, zName);
101616
101617 exit_rename_table:
101618 sqlite3SrcListDelete(db, pSrc);
101619 sqlite3DbFree(db, zName);
101620 db->mDbFlags = savedDbFlags;
@@ -101636,16 +101384,15 @@
101636 const char *zTab; /* Table name */
101637 char *zCol; /* Null-terminated column definition */
101638 Column *pCol; /* The new column */
101639 Expr *pDflt; /* Default value for the new column */
101640 sqlite3 *db; /* The database connection; */
101641 Vdbe *v = pParse->pVdbe; /* The prepared statement under construction */
101642 int r1; /* Temporary registers */
101643
101644 db = pParse->db;
101645 if( pParse->nErr || db->mallocFailed ) return;
101646 assert( v!=0 );
101647 pNew = pParse->pNewTable;
101648 assert( pNew );
101649
101650 assert( sqlite3BtreeHoldsAllMutexes(db) );
101651 iDb = sqlite3SchemaToIndex(db, pNew->pSchema);
@@ -101736,21 +101483,24 @@
101736
101737 /* Make sure the schema version is at least 3. But do not upgrade
101738 ** from less than 3 to 4, as that will corrupt any preexisting DESC
101739 ** index.
101740 */
101741 r1 = sqlite3GetTempReg(pParse);
101742 sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);
101743 sqlite3VdbeUsesBtree(v, iDb);
101744 sqlite3VdbeAddOp2(v, OP_AddImm, r1, -2);
101745 sqlite3VdbeAddOp2(v, OP_IfPos, r1, sqlite3VdbeCurrentAddr(v)+2);
101746 VdbeCoverage(v);
101747 sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3);
101748 sqlite3ReleaseTempReg(pParse, r1);
101749
101750 /* Reload the schema of the modified table. */
101751 reloadTableSchema(pParse, pTab, pTab->zName);
 
 
 
101752 }
101753
101754 /*
101755 ** This function is called by the parser after the table-name in
101756 ** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument
@@ -101767,11 +101517,10 @@
101767 ** coding the "ALTER TABLE ... ADD" statement.
101768 */
101769 SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
101770 Table *pNew;
101771 Table *pTab;
101772 Vdbe *v;
101773 int iDb;
101774 int i;
101775 int nAlloc;
101776 sqlite3 *db = pParse->db;
101777
@@ -101831,20 +101580,1113 @@
101831 }
101832 pNew->pSchema = db->aDb[iDb].pSchema;
101833 pNew->addColOffset = pTab->addColOffset;
101834 pNew->nTabRef = 1;
101835
101836 /* Begin a transaction and increment the schema cookie. */
101837 sqlite3BeginWriteOperation(pParse, 0, iDb);
101838 v = sqlite3GetVdbe(pParse);
101839 if( !v ) goto exit_begin_add_column;
101840 sqlite3ChangeCookie(pParse, iDb);
101841
101842 exit_begin_add_column:
101843 sqlite3SrcListDelete(db, pSrc);
101844 return;
101845 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101846 #endif /* SQLITE_ALTER_TABLE */
101847
101848 /************** End of alter.c ***********************************************/
101849 /************** Begin file analyze.c *****************************************/
101850 /*
@@ -104622,11 +105464,11 @@
104622 int rc;
104623
104624 /* Don't do any authorization checks if the database is initialising
104625 ** or if the parser is being invoked from within sqlite3_declare_vtab.
104626 */
104627 if( db->init.busy || IN_DECLARE_VTAB ){
104628 return SQLITE_OK;
104629 }
104630
104631 if( db->xAuth==0 ){
104632 return SQLITE_OK;
@@ -105128,11 +105970,11 @@
105128 }
105129
105130 /*
105131 ** Reclaim the memory used by an index
105132 */
105133 static void freeIndex(sqlite3 *db, Index *p){
105134 #ifndef SQLITE_OMIT_ANALYZE
105135 sqlite3DeleteIndexSamples(db, p);
105136 #endif
105137 sqlite3ExprDelete(db, p->pPartIdxWhere);
105138 sqlite3ExprListDelete(db, p->aColExpr);
@@ -105168,11 +106010,11 @@
105168 while( ALWAYS(p) && p->pNext!=pIndex ){ p = p->pNext; }
105169 if( ALWAYS(p && p->pNext==pIndex) ){
105170 p->pNext = pIndex->pNext;
105171 }
105172 }
105173 freeIndex(db, pIndex);
105174 }
105175 db->mDbFlags |= DBFLAG_SchemaChange;
105176 }
105177
105178 /*
@@ -105314,11 +106156,11 @@
105314 &pIndex->pSchema->idxHash, zName, 0
105315 );
105316 assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
105317 assert( pOld==pIndex || pOld==0 );
105318 }
105319 freeIndex(db, pIndex);
105320 }
105321
105322 /* Delete any foreign keys attached to this table. */
105323 sqlite3FkDelete(db, pTable);
105324
@@ -105472,11 +106314,11 @@
105472 if( iDb<0 ){
105473 sqlite3ErrorMsg(pParse, "unknown database %T", pName1);
105474 return -1;
105475 }
105476 }else{
105477 assert( db->init.iDb==0 || db->init.busy
105478 || (db->mDbFlags & DBFLAG_Vacuum)!=0);
105479 iDb = db->init.iDb;
105480 *pUnqual = pName1;
105481 }
105482 return iDb;
@@ -105567,10 +106409,13 @@
105567 sqlite3ErrorMsg(pParse, "temporary table name must be unqualified");
105568 return;
105569 }
105570 if( !OMIT_TEMPDB && isTemp ) iDb = 1;
105571 zName = sqlite3NameFromToken(db, pName);
 
 
 
105572 }
105573 pParse->sNameToken = *pName;
105574 if( zName==0 ) return;
105575 if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
105576 goto begin_table_error;
@@ -105602,11 +106447,11 @@
105602 ** it does. The exception is if the statement being parsed was passed
105603 ** to an sqlite3_declare_vtab() call. In that case only the column names
105604 ** and types will be used, so there is no need to test for namespace
105605 ** collisions.
105606 */
105607 if( !IN_DECLARE_VTAB ){
105608 char *zDb = db->aDb[iDb].zDbSName;
105609 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
105610 goto begin_table_error;
105611 }
105612 pTable = sqlite3FindTable(db, zName, zDb);
@@ -105761,10 +106606,11 @@
105761 sqlite3ErrorMsg(pParse, "too many columns on %s", p->zName);
105762 return;
105763 }
105764 z = sqlite3DbMallocRaw(db, pName->n + pType->n + 2);
105765 if( z==0 ) return;
 
105766 memcpy(z, pName->z, pName->n);
105767 z[pName->n] = 0;
105768 sqlite3Dequote(z);
105769 for(i=0; i<p->nCol; i++){
105770 if( sqlite3_stricmp(z, p->aCol[i].zName)==0 ){
@@ -105967,10 +106813,13 @@
105967 x.flags = EP_Skip;
105968 pCol->pDflt = sqlite3ExprDup(db, &x, EXPRDUP_REDUCE);
105969 sqlite3DbFree(db, x.u.zToken);
105970 }
105971 }
 
 
 
105972 sqlite3ExprDelete(db, pExpr);
105973 }
105974
105975 /*
105976 ** Backwards Compatibility Hack:
@@ -106058,10 +106907,13 @@
106058 if( nTerm==1
106059 && pCol
106060 && sqlite3StrICmp(sqlite3ColumnType(pCol,""), "INTEGER")==0
106061 && sortOrder!=SQLITE_SO_DESC
106062 ){
 
 
 
106063 pTab->iPKey = iCol;
106064 pTab->keyConf = (u8)onError;
106065 assert( autoInc==0 || autoInc==1 );
106066 pTab->tabFlags |= autoInc*TF_Autoincrement;
106067 if( pList ) pParse->iPkSortOrder = pList->a[0].sortOrder;
@@ -106860,11 +107712,16 @@
106860 /* Make a copy of the entire SELECT statement that defines the view.
106861 ** This will force all the Expr.token.z values to be dynamically
106862 ** allocated rather than point to the input string - which means that
106863 ** they will persist after the current sqlite3_exec() call returns.
106864 */
106865 p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
 
 
 
 
 
106866 p->pCheck = sqlite3ExprListDup(db, pCNames, EXPRDUP_REDUCE);
106867 if( db->mallocFailed ) goto create_view_fail;
106868
106869 /* Locate the end of the CREATE VIEW statement. Make sEnd point to
106870 ** the end.
@@ -107428,10 +108285,13 @@
107428 }
107429 pFKey->pFrom = p;
107430 pFKey->pNextFrom = p->pFKey;
107431 z = (char*)&pFKey->aCol[nCol];
107432 pFKey->zTo = z;
 
 
 
107433 memcpy(z, pTo->z, pTo->n);
107434 z[pTo->n] = 0;
107435 sqlite3Dequote(z);
107436 z += pTo->n+1;
107437 pFKey->nCol = nCol;
@@ -107450,16 +108310,22 @@
107450 sqlite3ErrorMsg(pParse,
107451 "unknown column \"%s\" in foreign key definition",
107452 pFromCol->a[i].zName);
107453 goto fk_end;
107454 }
 
 
 
107455 }
107456 }
107457 if( pToCol ){
107458 for(i=0; i<nCol; i++){
107459 int n = sqlite3Strlen30(pToCol->a[i].zName);
107460 pFKey->aCol[i].zCol = z;
 
 
 
107461 memcpy(z, pToCol->a[i].zName, n);
107462 z[n] = 0;
107463 z += n+1;
107464 }
107465 }
@@ -107788,25 +108654,27 @@
107788 if( zName==0 ) goto exit_create_index;
107789 assert( pName->z!=0 );
107790 if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
107791 goto exit_create_index;
107792 }
107793 if( !db->init.busy ){
107794 if( sqlite3FindTable(db, zName, 0)!=0 ){
107795 sqlite3ErrorMsg(pParse, "there is already a table named %s", zName);
 
 
 
 
 
 
 
 
 
 
 
107796 goto exit_create_index;
107797 }
107798 }
107799 if( sqlite3FindIndex(db, zName, pDb->zDbSName)!=0 ){
107800 if( !ifNotExist ){
107801 sqlite3ErrorMsg(pParse, "index %s already exists", zName);
107802 }else{
107803 assert( !db->init.busy );
107804 sqlite3CodeVerifySchema(pParse, iDb);
107805 }
107806 goto exit_create_index;
107807 }
107808 }else{
107809 int n;
107810 Index *pLoop;
107811 for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){}
107812 zName = sqlite3MPrintf(db, "sqlite_autoindex_%s_%d", pTab->zName, n);
@@ -107817,17 +108685,17 @@
107817 /* Automatic index names generated from within sqlite3_declare_vtab()
107818 ** must have names that are distinct from normal automatic index names.
107819 ** The following statement converts "sqlite3_autoindex..." into
107820 ** "sqlite3_butoindex..." in order to make the names distinct.
107821 ** The "vtab_err.test" test demonstrates the need of this statement. */
107822 if( IN_DECLARE_VTAB ) zName[7]++;
107823 }
107824
107825 /* Check for authorization to create an index.
107826 */
107827 #ifndef SQLITE_OMIT_AUTHORIZATION
107828 {
107829 const char *zDb = pDb->zDbSName;
107830 if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iDb), 0, zDb) ){
107831 goto exit_create_index;
107832 }
107833 i = SQLITE_CREATE_INDEX;
@@ -107910,11 +108778,16 @@
107910 **
107911 ** TODO: Issue a warning if two or more columns of the index are identical.
107912 ** TODO: Issue a warning if the table primary key is used as part of the
107913 ** index key.
107914 */
107915 for(i=0, pListItem=pList->a; i<pList->nExpr; i++, pListItem++){
 
 
 
 
 
107916 Expr *pCExpr; /* The i-th index expression */
107917 int requestedSortOrder; /* ASC or DESC on the i-th expression */
107918 const char *zColl; /* Collation sequence name */
107919
107920 sqlite3StringToId(pListItem->pExpr);
@@ -107926,16 +108799,12 @@
107926 sqlite3ErrorMsg(pParse, "expressions prohibited in PRIMARY KEY and "
107927 "UNIQUE constraints");
107928 goto exit_create_index;
107929 }
107930 if( pIndex->aColExpr==0 ){
107931 ExprList *pCopy = sqlite3ExprListDup(db, pList, 0);
107932 pIndex->aColExpr = pCopy;
107933 if( !db->mallocFailed ){
107934 assert( pCopy!=0 );
107935 pListItem = &pCopy->a[i];
107936 }
107937 }
107938 j = XN_EXPR;
107939 pIndex->aiColumn[i] = XN_EXPR;
107940 pIndex->uniqNotNull = 0;
107941 }else{
@@ -108070,102 +108939,105 @@
108070 goto exit_create_index;
108071 }
108072 }
108073 }
108074
108075 /* Link the new Index structure to its table and to the other
108076 ** in-memory database structures.
108077 */
108078 assert( pParse->nErr==0 );
108079 if( db->init.busy ){
108080 Index *p;
108081 assert( !IN_DECLARE_VTAB );
108082 assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
108083 p = sqlite3HashInsert(&pIndex->pSchema->idxHash,
108084 pIndex->zName, pIndex);
108085 if( p ){
108086 assert( p==pIndex ); /* Malloc must have failed */
108087 sqlite3OomFault(db);
108088 goto exit_create_index;
108089 }
108090 db->mDbFlags |= DBFLAG_SchemaChange;
108091 if( pTblName!=0 ){
108092 pIndex->tnum = db->init.newTnum;
108093 }
108094 }
108095
108096 /* If this is the initial CREATE INDEX statement (or CREATE TABLE if the
108097 ** index is an implied index for a UNIQUE or PRIMARY KEY constraint) then
108098 ** emit code to allocate the index rootpage on disk and make an entry for
108099 ** the index in the sqlite_master table and populate the index with
108100 ** content. But, do not do this if we are simply reading the sqlite_master
108101 ** table to parse the schema, or if this index is the PRIMARY KEY index
108102 ** of a WITHOUT ROWID table.
108103 **
108104 ** If pTblName==0 it means this index is generated as an implied PRIMARY KEY
108105 ** or UNIQUE index in a CREATE TABLE statement. Since the table
108106 ** has just been created, it contains no data and the index initialization
108107 ** step can be skipped.
108108 */
108109 else if( HasRowid(pTab) || pTblName!=0 ){
108110 Vdbe *v;
108111 char *zStmt;
108112 int iMem = ++pParse->nMem;
108113
108114 v = sqlite3GetVdbe(pParse);
108115 if( v==0 ) goto exit_create_index;
108116
108117 sqlite3BeginWriteOperation(pParse, 1, iDb);
108118
108119 /* Create the rootpage for the index using CreateIndex. But before
108120 ** doing so, code a Noop instruction and store its address in
108121 ** Index.tnum. This is required in case this index is actually a
108122 ** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In
108123 ** that case the convertToWithoutRowidTable() routine will replace
108124 ** the Noop with a Goto to jump over the VDBE code generated below. */
108125 pIndex->tnum = sqlite3VdbeAddOp0(v, OP_Noop);
108126 sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, iMem, BTREE_BLOBKEY);
108127
108128 /* Gather the complete text of the CREATE INDEX statement into
108129 ** the zStmt variable
108130 */
108131 if( pStart ){
108132 int n = (int)(pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;
108133 if( pName->z[n-1]==';' ) n--;
108134 /* A named index with an explicit CREATE INDEX statement */
108135 zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
108136 onError==OE_None ? "" : " UNIQUE", n, pName->z);
108137 }else{
108138 /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
108139 /* zStmt = sqlite3MPrintf(""); */
108140 zStmt = 0;
108141 }
108142
108143 /* Add an entry in sqlite_master for this index
108144 */
108145 sqlite3NestedParse(pParse,
108146 "INSERT INTO %Q.%s VALUES('index',%Q,%Q,#%d,%Q);",
108147 db->aDb[iDb].zDbSName, MASTER_NAME,
108148 pIndex->zName,
108149 pTab->zName,
108150 iMem,
108151 zStmt
108152 );
108153 sqlite3DbFree(db, zStmt);
108154
108155 /* Fill the index with data and reparse the schema. Code an OP_Expire
108156 ** to invalidate all pre-compiled statements.
108157 */
108158 if( pTblName ){
108159 sqlite3RefillIndex(pParse, pIndex, iMem);
108160 sqlite3ChangeCookie(pParse, iDb);
108161 sqlite3VdbeAddParseSchemaOp(v, iDb,
108162 sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName));
108163 sqlite3VdbeAddOp2(v, OP_Expire, 0, 1);
108164 }
108165
108166 sqlite3VdbeJumpHere(v, pIndex->tnum);
 
 
 
108167 }
108168
108169 /* When adding an index to the list of indices for a table, make
108170 ** sure all indices labeled OE_Replace come after all those labeled
108171 ** OE_Ignore. This is necessary for the correct constraint check
@@ -108185,14 +109057,19 @@
108185 pIndex->pNext = pOther->pNext;
108186 pOther->pNext = pIndex;
108187 }
108188 pIndex = 0;
108189 }
 
 
 
 
 
108190
108191 /* Clean up before exiting */
108192 exit_create_index:
108193 if( pIndex ) freeIndex(db, pIndex);
108194 sqlite3ExprDelete(db, pPIWhere);
108195 sqlite3ExprListDelete(db, pList);
108196 sqlite3SrcListDelete(db, pTblName);
108197 sqlite3DbFree(db, zName);
108198 }
@@ -108357,11 +109234,12 @@
108357 ** Append a new element to the given IdList. Create a new IdList if
108358 ** need be.
108359 **
108360 ** A new IdList is returned, or NULL if malloc() fails.
108361 */
108362 SQLITE_PRIVATE IdList *sqlite3IdListAppend(sqlite3 *db, IdList *pList, Token *pToken){
 
108363 int i;
108364 if( pList==0 ){
108365 pList = sqlite3DbMallocZero(db, sizeof(IdList) );
108366 if( pList==0 ) return 0;
108367 }
@@ -108375,10 +109253,13 @@
108375 if( i<0 ){
108376 sqlite3IdListDelete(db, pList);
108377 return 0;
108378 }
108379 pList->a[i].zName = sqlite3NameFromToken(db, pToken);
 
 
 
108380 return pList;
108381 }
108382
108383 /*
108384 ** Delete an IdList.
@@ -108621,10 +109502,14 @@
108621 if( p==0 ){
108622 goto append_from_error;
108623 }
108624 assert( p->nSrc>0 );
108625 pItem = &p->a[p->nSrc-1];
 
 
 
 
108626 assert( pAlias!=0 );
108627 if( pAlias->n ){
108628 pItem->zAlias = sqlite3NameFromToken(db, pAlias);
108629 }
108630 pItem->pSelect = pSubquery;
@@ -121271,19 +122156,27 @@
121271 InitData *pData, /* Initialization context */
121272 const char *zObj, /* Object being parsed at the point of error */
121273 const char *zExtra /* Error information */
121274 ){
121275 sqlite3 *db = pData->db;
121276 if( !db->mallocFailed && (db->flags & SQLITE_WriteSchema)==0 ){
 
 
 
 
 
 
 
 
 
121277 char *z;
121278 if( zObj==0 ) zObj = "?";
121279 z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj);
121280 if( zExtra && zExtra[0] ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra);
121281 sqlite3DbFree(db, *pData->pzErrMsg);
121282 *pData->pzErrMsg = z;
 
121283 }
121284 pData->rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_CORRUPT_BKPT;
121285 }
121286
121287 /*
121288 ** This is the callback routine for the code that initializes the
121289 ** database. See sqlite3Init() below for additional information.
@@ -121331,11 +122224,11 @@
121331 db->init.orphanTrigger = 0;
121332 TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0);
121333 rc = db->errCode;
121334 assert( (rc&0xFF)==(rcp&0xFF) );
121335 db->init.iDb = saved_iDb;
121336 assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 );
121337 if( SQLITE_OK!=rc ){
121338 if( db->init.orphanTrigger ){
121339 assert( iDb==1 );
121340 }else{
121341 pData->rc = rc;
@@ -121378,11 +122271,11 @@
121378 ** database file is given by iDb. iDb==0 is used for the main
121379 ** database. iDb==1 should never be used. iDb>=2 is used for
121380 ** auxiliary databases. Return one of the SQLITE_ error codes to
121381 ** indicate success or failure.
121382 */
121383 static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){
121384 int rc;
121385 int i;
121386 #ifndef SQLITE_OMIT_DEPRECATED
121387 int size;
121388 #endif
@@ -121413,10 +122306,11 @@
121413 azArg[3] = 0;
121414 initData.db = db;
121415 initData.iDb = iDb;
121416 initData.rc = SQLITE_OK;
121417 initData.pzErrMsg = pzErrMsg;
 
121418 sqlite3InitCallback(&initData, 3, (char **)azArg, 0);
121419 if( initData.rc ){
121420 rc = initData.rc;
121421 goto error_out;
121422 }
@@ -121619,18 +122513,18 @@
121619 assert( db->init.busy==0 );
121620 ENC(db) = SCHEMA_ENC(db);
121621 assert( db->nDb>0 );
121622 /* Do the main schema first */
121623 if( !DbHasProperty(db, 0, DB_SchemaLoaded) ){
121624 rc = sqlite3InitOne(db, 0, pzErrMsg);
121625 if( rc ) return rc;
121626 }
121627 /* All other schemas after the main schema. The "temp" schema must be last */
121628 for(i=db->nDb-1; i>0; i--){
121629 assert( i==1 || sqlite3BtreeHoldsMutex(db->aDb[i].pBt) );
121630 if( !DbHasProperty(db, i, DB_SchemaLoaded) ){
121631 rc = sqlite3InitOne(db, i, pzErrMsg);
121632 if( rc ) return rc;
121633 }
121634 }
121635 if( commit_internal ){
121636 sqlite3CommitInternalChanges(db);
@@ -129136,18 +130030,20 @@
129136 zName = sqlite3NameFromToken(db, pName);
129137 if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
129138 goto trigger_cleanup;
129139 }
129140 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
129141 if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),zName) ){
129142 if( !noErr ){
129143 sqlite3ErrorMsg(pParse, "trigger %T already exists", pName);
129144 }else{
129145 assert( !db->init.busy );
129146 sqlite3CodeVerifySchema(pParse, iDb);
129147 }
129148 goto trigger_cleanup;
 
 
129149 }
129150
129151 /* Do not create a trigger on a system table */
129152 if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){
129153 sqlite3ErrorMsg(pParse, "cannot create trigger on system table");
@@ -129167,11 +130063,11 @@
129167 " trigger on table: %S", pTableName, 0);
129168 goto trigger_cleanup;
129169 }
129170
129171 #ifndef SQLITE_OMIT_AUTHORIZATION
129172 {
129173 int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);
129174 int code = SQLITE_CREATE_TRIGGER;
129175 const char *zDb = db->aDb[iTabDb].zDbSName;
129176 const char *zDbTrig = isTemp ? db->aDb[1].zDbSName : zDb;
129177 if( iTabDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER;
@@ -129201,12 +130097,19 @@
129201 pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);
129202 pTrigger->pSchema = db->aDb[iDb].pSchema;
129203 pTrigger->pTabSchema = pTab->pSchema;
129204 pTrigger->op = (u8)op;
129205 pTrigger->tr_tm = tr_tm==TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER;
129206 pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);
129207 pTrigger->pColumns = sqlite3IdListDup(db, pColumns);
 
 
 
 
 
 
 
129208 assert( pParse->pNewTrigger==0 );
129209 pParse->pNewTrigger = pTrigger;
129210
129211 trigger_cleanup:
129212 sqlite3DbFree(db, zName);
@@ -129250,10 +130153,18 @@
129250 if( sqlite3FixTriggerStep(&sFix, pTrig->step_list)
129251 || sqlite3FixExpr(&sFix, pTrig->pWhen)
129252 ){
129253 goto triggerfinish_cleanup;
129254 }
 
 
 
 
 
 
 
 
129255
129256 /* if we are not initializing,
129257 ** build the sqlite_master entry
129258 */
129259 if( !db->init.busy ){
@@ -129292,11 +130203,11 @@
129292 }
129293 }
129294
129295 triggerfinish_cleanup:
129296 sqlite3DeleteTrigger(db, pTrig);
129297 assert( !pParse->pNewTrigger );
129298 sqlite3DeleteTriggerStep(db, pStepList);
129299 }
129300
129301 /*
129302 ** Duplicate a range of text from an SQL statement, then convert all
@@ -129339,16 +130250,17 @@
129339 ** holds both the TriggerStep object and the TriggerStep.target.z string.
129340 **
129341 ** If an OOM error occurs, NULL is returned and db->mallocFailed is set.
129342 */
129343 static TriggerStep *triggerStepAllocate(
129344 sqlite3 *db, /* Database connection */
129345 u8 op, /* Trigger opcode */
129346 Token *pName, /* The target name */
129347 const char *zStart, /* Start of SQL text */
129348 const char *zEnd /* End of SQL text */
129349 ){
 
129350 TriggerStep *pTriggerStep;
129351
129352 pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n + 1);
129353 if( pTriggerStep ){
129354 char *z = (char*)&pTriggerStep[1];
@@ -129355,10 +130267,13 @@
129355 memcpy(z, pName->z, pName->n);
129356 sqlite3Dequote(z);
129357 pTriggerStep->zTarget = z;
129358 pTriggerStep->op = op;
129359 pTriggerStep->zSpan = triggerSpanDup(db, zStart, zEnd);
 
 
 
129360 }
129361 return pTriggerStep;
129362 }
129363
129364 /*
@@ -129367,26 +130282,32 @@
129367 **
129368 ** The parser calls this routine when it sees an INSERT inside the
129369 ** body of a trigger.
129370 */
129371 SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(
129372 sqlite3 *db, /* The database connection */
129373 Token *pTableName, /* Name of the table into which we insert */
129374 IdList *pColumn, /* List of columns in pTableName to insert into */
129375 Select *pSelect, /* A SELECT statement that supplies values */
129376 u8 orconf, /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */
129377 Upsert *pUpsert, /* ON CONFLICT clauses for upsert */
129378 const char *zStart, /* Start of SQL text */
129379 const char *zEnd /* End of SQL text */
129380 ){
 
129381 TriggerStep *pTriggerStep;
129382
129383 assert(pSelect != 0 || db->mallocFailed);
129384
129385 pTriggerStep = triggerStepAllocate(db, TK_INSERT, pTableName, zStart, zEnd);
129386 if( pTriggerStep ){
129387 pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
 
 
 
 
 
129388 pTriggerStep->pIdList = pColumn;
129389 pTriggerStep->pUpsert = pUpsert;
129390 pTriggerStep->orconf = orconf;
129391 }else{
129392 testcase( pColumn );
@@ -129403,24 +130324,32 @@
129403 ** Construct a trigger step that implements an UPDATE statement and return
129404 ** a pointer to that trigger step. The parser calls this routine when it
129405 ** sees an UPDATE statement inside the body of a CREATE TRIGGER.
129406 */
129407 SQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(
129408 sqlite3 *db, /* The database connection */
129409 Token *pTableName, /* Name of the table to be updated */
129410 ExprList *pEList, /* The SET clause: list of column and new values */
129411 Expr *pWhere, /* The WHERE clause */
129412 u8 orconf, /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */
129413 const char *zStart, /* Start of SQL text */
129414 const char *zEnd /* End of SQL text */
129415 ){
 
129416 TriggerStep *pTriggerStep;
129417
129418 pTriggerStep = triggerStepAllocate(db, TK_UPDATE, pTableName, zStart, zEnd);
129419 if( pTriggerStep ){
129420 pTriggerStep->pExprList = sqlite3ExprListDup(db, pEList, EXPRDUP_REDUCE);
129421 pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
 
 
 
 
 
 
 
129422 pTriggerStep->orconf = orconf;
129423 }
129424 sqlite3ExprListDelete(db, pEList);
129425 sqlite3ExprDelete(db, pWhere);
129426 return pTriggerStep;
@@ -129430,21 +130359,27 @@
129430 ** Construct a trigger step that implements a DELETE statement and return
129431 ** a pointer to that trigger step. The parser calls this routine when it
129432 ** sees a DELETE statement inside the body of a CREATE TRIGGER.
129433 */
129434 SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(
129435 sqlite3 *db, /* Database connection */
129436 Token *pTableName, /* The table from which rows are deleted */
129437 Expr *pWhere, /* The WHERE clause */
129438 const char *zStart, /* Start of SQL text */
129439 const char *zEnd /* End of SQL text */
129440 ){
 
129441 TriggerStep *pTriggerStep;
129442
129443 pTriggerStep = triggerStepAllocate(db, TK_DELETE, pTableName, zStart, zEnd);
129444 if( pTriggerStep ){
129445 pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
 
 
 
 
 
129446 pTriggerStep->orconf = OE_Default;
129447 }
129448 sqlite3ExprDelete(db, pWhere);
129449 return pTriggerStep;
129450 }
@@ -132438,11 +133373,11 @@
132438 }
132439 pTab = pCtx->pTab;
132440 assert( IsVirtual(pTab) );
132441
132442 memset(&sParse, 0, sizeof(sParse));
132443 sParse.declareVtab = 1;
132444 sParse.db = db;
132445 sParse.nQueryLoop = 1;
132446 if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable, &zErr)
132447 && sParse.pNewTable
132448 && !db->mallocFailed
@@ -132479,11 +133414,11 @@
132479 }else{
132480 sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? "%s" : 0), zErr);
132481 sqlite3DbFree(db, zErr);
132482 rc = SQLITE_ERROR;
132483 }
132484 sParse.declareVtab = 0;
132485
132486 if( sParse.pVdbe ){
132487 sqlite3VdbeFinalize(sParse.pVdbe);
132488 }
132489 sqlite3DeleteTable(db, sParse.pNewTable);
@@ -144970,14 +145905,25 @@
144970 ** that created the expression.
144971 */
144972 static Expr *tokenExpr(Parse *pParse, int op, Token t){
144973 Expr *p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr)+t.n+1);
144974 if( p ){
144975 memset(p, 0, sizeof(Expr));
144976 p->op = (u8)op;
 
144977 p->flags = EP_Leaf;
144978 p->iAgg = -1;
 
 
 
 
 
 
 
 
 
 
144979 p->u.zToken = (char*)&p[1];
144980 memcpy(p->u.zToken, t.z, t.n);
144981 p->u.zToken[t.n] = 0;
144982 if( sqlite3Isquote(p->u.zToken[0]) ){
144983 if( p->u.zToken[0]=='"' ) p->flags |= EP_DblQuoted;
@@ -144984,19 +145930,23 @@
144984 sqlite3Dequote(p->u.zToken);
144985 }
144986 #if SQLITE_MAX_EXPR_DEPTH>0
144987 p->nHeight = 1;
144988 #endif
 
 
 
144989 }
144990 return p;
144991 }
 
144992
144993 /* A routine to convert a binary TK_IS or TK_ISNOT expression into a
144994 ** unary TK_ISNULL or TK_NOTNULL expression. */
144995 static void binaryToUnaryIfNull(Parse *pParse, Expr *pY, Expr *pA, int op){
144996 sqlite3 *db = pParse->db;
144997 if( pA && pY && pY->op==TK_NULL ){
144998 pA->op = (u8)op;
144999 sqlite3ExprDelete(db, pA->pRight);
145000 pA->pRight = 0;
145001 }
145002 }
@@ -145120,21 +146070,21 @@
145120 #define sqlite3ParserCTX_PDECL ,Parse *pParse
145121 #define sqlite3ParserCTX_PARAM ,pParse
145122 #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
145123 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
145124 #define YYFALLBACK 1
145125 #define YYNSTATE 518
145126 #define YYNRULE 366
145127 #define YYNTOKEN 155
145128 #define YY_MAX_SHIFT 517
145129 #define YY_MIN_SHIFTREDUCE 752
145130 #define YY_MAX_SHIFTREDUCE 1117
145131 #define YY_ERROR_ACTION 1118
145132 #define YY_ACCEPT_ACTION 1119
145133 #define YY_NO_ACTION 1120
145134 #define YY_MIN_REDUCE 1121
145135 #define YY_MAX_REDUCE 1486
145136 /************* End control #defines *******************************************/
145137 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
145138
145139 /* Define the yytestcase() macro to be a no-op if is not already defined
145140 ** otherwise.
@@ -145199,211 +146149,211 @@
145199 ** yy_default[] Default action for each state.
145200 **
145201 *********** Begin parsing tables **********************************************/
145202 #define YY_ACTTAB_COUNT (2009)
145203 static const YYACTIONTYPE yy_action[] = {
145204 /* 0 */ 365, 105, 102, 197, 105, 102, 197, 512, 1119, 1,
145205 /* 10 */ 1, 517, 2, 1123, 512, 1187, 1166, 1450, 272, 367,
145206 /* 20 */ 127, 1384, 1192, 1192, 1187, 1161, 178, 1200, 64, 64,
145207 /* 30 */ 474, 883, 319, 425, 345, 37, 37, 804, 359, 884,
145208 /* 40 */ 506, 506, 506, 112, 113, 103, 1095, 1095, 949, 952,
145209 /* 50 */ 942, 942, 110, 110, 111, 111, 111, 111, 362, 250,
145210 /* 60 */ 250, 512, 250, 250, 494, 512, 306, 512, 456, 512,
145211 /* 70 */ 1074, 488, 509, 475, 6, 509, 805, 134, 495, 226,
145212 /* 80 */ 194, 425, 37, 37, 512, 206, 64, 64, 64, 64,
145213 /* 90 */ 13, 13, 109, 109, 109, 109, 108, 108, 107, 107,
145214 /* 100 */ 107, 106, 398, 255, 378, 13, 13, 395, 394, 425,
145215 /* 110 */ 250, 250, 367, 473, 402, 1099, 1074, 1075, 1076, 383,
145216 /* 120 */ 1101, 387, 494, 509, 494, 1417, 1413, 301, 1100, 304,
145217 /* 130 */ 1251, 493, 367, 496, 16, 16, 112, 113, 103, 1095,
145218 /* 140 */ 1095, 949, 952, 942, 942, 110, 110, 111, 111, 111,
145219 /* 150 */ 111, 259, 1102, 492, 1102, 398, 112, 113, 103, 1095,
145220 /* 160 */ 1095, 949, 952, 942, 942, 110, 110, 111, 111, 111,
145221 /* 170 */ 111, 129, 1419, 340, 1414, 336, 1054, 489, 1052, 260,
145222 /* 180 */ 73, 105, 102, 197, 990, 109, 109, 109, 109, 108,
145223 /* 190 */ 108, 107, 107, 107, 106, 398, 367, 111, 111, 111,
145224 /* 200 */ 111, 104, 489, 89, 1426, 109, 109, 109, 109, 108,
145225 /* 210 */ 108, 107, 107, 107, 106, 398, 111, 111, 111, 111,
145226 /* 220 */ 112, 113, 103, 1095, 1095, 949, 952, 942, 942, 110,
145227 /* 230 */ 110, 111, 111, 111, 111, 109, 109, 109, 109, 108,
145228 /* 240 */ 108, 107, 107, 107, 106, 398, 114, 108, 108, 107,
145229 /* 250 */ 107, 107, 106, 398, 109, 109, 109, 109, 108, 108,
145230 /* 260 */ 107, 107, 107, 106, 398, 152, 396, 396, 396, 109,
145231 /* 270 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 398,
145232 /* 280 */ 178, 490, 1406, 431, 1032, 1480, 1074, 512, 1480, 367,
145233 /* 290 */ 418, 294, 354, 409, 74, 1074, 109, 109, 109, 109,
145234 /* 300 */ 108, 108, 107, 107, 107, 106, 398, 1407, 37, 37,
145235 /* 310 */ 1425, 271, 503, 112, 113, 103, 1095, 1095, 949, 952,
145236 /* 320 */ 942, 942, 110, 110, 111, 111, 111, 111, 1430, 517,
145237 /* 330 */ 2, 1123, 1074, 1075, 1076, 427, 272, 1074, 127, 363,
145238 /* 340 */ 929, 1074, 1075, 1076, 218, 1200, 909, 455, 452, 451,
145239 /* 350 */ 389, 167, 512, 1030, 152, 442, 920, 450, 152, 870,
145240 /* 360 */ 919, 286, 109, 109, 109, 109, 108, 108, 107, 107,
145241 /* 370 */ 107, 106, 398, 13, 13, 258, 849, 250, 250, 225,
145242 /* 380 */ 106, 398, 367, 1074, 1075, 1076, 308, 385, 1074, 293,
145243 /* 390 */ 509, 919, 919, 921, 229, 320, 1250, 1383, 1417, 487,
145244 /* 400 */ 271, 503, 12, 206, 271, 503, 112, 113, 103, 1095,
145245 /* 410 */ 1095, 949, 952, 942, 942, 110, 110, 111, 111, 111,
145246 /* 420 */ 111, 1434, 283, 1123, 285, 1074, 1092, 245, 272, 1093,
145247 /* 430 */ 127, 384, 402, 386, 1074, 1075, 1076, 1200, 159, 236,
145248 /* 440 */ 253, 318, 458, 313, 457, 223, 786, 105, 102, 197,
145249 /* 450 */ 510, 311, 838, 838, 442, 109, 109, 109, 109, 108,
145250 /* 460 */ 108, 107, 107, 107, 106, 398, 512, 511, 512, 250,
145251 /* 470 */ 250, 1074, 1075, 1076, 432, 367, 1093, 929, 1454, 790,
145252 /* 480 */ 271, 503, 509, 105, 102, 197, 333, 63, 63, 64,
145253 /* 490 */ 64, 27, 786, 920, 284, 206, 1349, 919, 512, 112,
145254 /* 500 */ 113, 103, 1095, 1095, 949, 952, 942, 942, 110, 110,
145255 /* 510 */ 111, 111, 111, 111, 107, 107, 107, 106, 398, 49,
145256 /* 520 */ 49, 512, 28, 1074, 402, 494, 418, 294, 919, 919,
145257 /* 530 */ 921, 186, 465, 1074, 464, 995, 995, 439, 512, 1074,
145258 /* 540 */ 331, 512, 45, 45, 1078, 339, 173, 168, 109, 109,
145259 /* 550 */ 109, 109, 108, 108, 107, 107, 107, 106, 398, 13,
145260 /* 560 */ 13, 203, 13, 13, 250, 250, 1190, 1190, 367, 1074,
145261 /* 570 */ 1075, 1076, 783, 262, 5, 356, 491, 509, 466, 1074,
145262 /* 580 */ 1075, 1076, 395, 394, 1074, 1074, 1075, 1076, 3, 279,
145263 /* 590 */ 1074, 1078, 112, 113, 103, 1095, 1095, 949, 952, 942,
145264 /* 600 */ 942, 110, 110, 111, 111, 111, 111, 250, 250, 1011,
145265 /* 610 */ 218, 1074, 869, 455, 452, 451, 939, 939, 950, 953,
145266 /* 620 */ 509, 250, 250, 450, 1012, 1074, 442, 1102, 1204, 1102,
145267 /* 630 */ 1074, 1075, 1076, 512, 509, 423, 1074, 1075, 1076, 1013,
145268 /* 640 */ 509, 109, 109, 109, 109, 108, 108, 107, 107, 107,
145269 /* 650 */ 106, 398, 1047, 512, 50, 50, 512, 1074, 1075, 1076,
145270 /* 660 */ 824, 367, 1046, 376, 408, 1059, 1353, 205, 405, 769,
145271 /* 670 */ 825, 1074, 1075, 1076, 64, 64, 319, 64, 64, 1297,
145272 /* 680 */ 943, 408, 407, 1353, 1355, 112, 113, 103, 1095, 1095,
145273 /* 690 */ 949, 952, 942, 942, 110, 110, 111, 111, 111, 111,
145274 /* 700 */ 291, 479, 512, 1032, 1481, 512, 431, 1481, 351, 1115,
145275 /* 710 */ 480, 992, 909, 482, 463, 992, 132, 178, 33, 447,
145276 /* 720 */ 1198, 136, 403, 64, 64, 476, 64, 64, 416, 366,
145277 /* 730 */ 280, 1141, 250, 250, 109, 109, 109, 109, 108, 108,
145278 /* 740 */ 107, 107, 107, 106, 398, 509, 222, 437, 408, 263,
145279 /* 750 */ 1353, 263, 250, 250, 367, 293, 413, 281, 930, 393,
145280 /* 760 */ 972, 467, 397, 250, 250, 509, 9, 470, 229, 497,
145281 /* 770 */ 351, 1031, 1030, 1482, 352, 371, 509, 1116, 112, 113,
145282 /* 780 */ 103, 1095, 1095, 949, 952, 942, 942, 110, 110, 111,
145283 /* 790 */ 111, 111, 111, 250, 250, 1011, 512, 1342, 292, 250,
145284 /* 800 */ 250, 250, 250, 1093, 372, 247, 509, 442, 868, 319,
145285 /* 810 */ 1012, 477, 509, 195, 509, 431, 270, 15, 15, 512,
145286 /* 820 */ 311, 512, 95, 512, 93, 1013, 364, 109, 109, 109,
145287 /* 830 */ 109, 108, 108, 107, 107, 107, 106, 398, 512, 1116,
145288 /* 840 */ 39, 39, 51, 51, 52, 52, 500, 367, 512, 1199,
145289 /* 850 */ 1093, 914, 436, 338, 133, 433, 221, 220, 219, 53,
145290 /* 860 */ 53, 319, 1392, 757, 758, 759, 512, 367, 88, 54,
145291 /* 870 */ 54, 112, 113, 103, 1095, 1095, 949, 952, 942, 942,
145292 /* 880 */ 110, 110, 111, 111, 111, 111, 274, 55, 55, 196,
145293 /* 890 */ 512, 112, 113, 103, 1095, 1095, 949, 952, 942, 942,
145294 /* 900 */ 110, 110, 111, 111, 111, 111, 135, 261, 1144, 373,
145295 /* 910 */ 512, 40, 40, 512, 868, 512, 989, 512, 989, 116,
145296 /* 920 */ 109, 109, 109, 109, 108, 108, 107, 107, 107, 106,
145297 /* 930 */ 398, 41, 41, 512, 43, 43, 44, 44, 56, 56,
145298 /* 940 */ 109, 109, 109, 109, 108, 108, 107, 107, 107, 106,
145299 /* 950 */ 398, 512, 376, 512, 57, 57, 512, 795, 512, 376,
145300 /* 960 */ 512, 442, 793, 512, 320, 512, 275, 512, 1453, 512,
145301 /* 970 */ 1282, 813, 58, 58, 14, 14, 512, 59, 59, 118,
145302 /* 980 */ 118, 60, 60, 512, 46, 46, 61, 61, 62, 62,
145303 /* 990 */ 47, 47, 512, 190, 189, 91, 512, 140, 140, 512,
145304 /* 1000 */ 391, 512, 844, 1195, 141, 141, 512, 843, 512, 793,
145305 /* 1010 */ 512, 410, 512, 69, 69, 367, 278, 48, 48, 256,
145306 /* 1020 */ 65, 65, 119, 119, 244, 244, 257, 66, 66, 120,
145307 /* 1030 */ 120, 121, 121, 117, 117, 367, 512, 509, 380, 112,
145308 /* 1040 */ 113, 103, 1095, 1095, 949, 952, 942, 942, 110, 110,
145309 /* 1050 */ 111, 111, 111, 111, 512, 868, 512, 139, 139, 112,
145310 /* 1060 */ 113, 103, 1095, 1095, 949, 952, 942, 942, 110, 110,
145311 /* 1070 */ 111, 111, 111, 111, 1282, 138, 138, 125, 125, 512,
145312 /* 1080 */ 12, 512, 1351, 1282, 512, 442, 131, 1282, 109, 109,
145313 /* 1090 */ 109, 109, 108, 108, 107, 107, 107, 106, 398, 512,
145314 /* 1100 */ 124, 124, 122, 122, 512, 123, 123, 512, 109, 109,
145315 /* 1110 */ 109, 109, 108, 108, 107, 107, 107, 106, 398, 512,
145316 /* 1120 */ 68, 68, 460, 779, 512, 70, 70, 299, 67, 67,
145317 /* 1130 */ 1027, 251, 251, 353, 1282, 191, 196, 1427, 462, 1296,
145318 /* 1140 */ 38, 38, 381, 94, 509, 42, 42, 177, 844, 271,
145319 /* 1150 */ 503, 382, 417, 843, 420, 438, 505, 373, 374, 153,
145320 /* 1160 */ 252, 868, 429, 367, 222, 249, 194, 883, 182, 290,
145321 /* 1170 */ 779, 988, 88, 988, 463, 884, 906, 911, 424, 426,
145322 /* 1180 */ 228, 228, 228, 367, 17, 803, 802, 112, 113, 103,
145323 /* 1190 */ 1095, 1095, 949, 952, 942, 942, 110, 110, 111, 111,
145324 /* 1200 */ 111, 111, 392, 295, 810, 811, 88, 112, 101, 103,
145325 /* 1210 */ 1095, 1095, 949, 952, 942, 942, 110, 110, 111, 111,
145326 /* 1220 */ 111, 111, 372, 419, 448, 309, 979, 224, 88, 975,
145327 /* 1230 */ 877, 841, 224, 228, 100, 923, 109, 109, 109, 109,
145328 /* 1240 */ 108, 108, 107, 107, 107, 106, 398, 86, 430, 777,
145329 /* 1250 */ 842, 1236, 130, 100, 1235, 412, 109, 109, 109, 109,
145330 /* 1260 */ 108, 108, 107, 107, 107, 106, 398, 317, 1443, 1397,
145331 /* 1270 */ 1170, 287, 1169, 979, 1372, 1371, 367, 316, 434, 296,
145332 /* 1280 */ 1232, 1223, 923, 300, 303, 305, 307, 1183, 1168, 1167,
145333 /* 1290 */ 312, 321, 322, 1244, 1281, 1219, 367, 268, 1230, 499,
145334 /* 1300 */ 498, 113, 103, 1095, 1095, 949, 952, 942, 942, 110,
145335 /* 1310 */ 110, 111, 111, 111, 111, 1287, 1150, 443, 242, 184,
145336 /* 1320 */ 1216, 1143, 103, 1095, 1095, 949, 952, 942, 942, 110,
145337 /* 1330 */ 110, 111, 111, 111, 111, 1132, 1131, 1133, 1437, 350,
145338 /* 1340 */ 411, 324, 188, 98, 504, 289, 4, 326, 315, 109,
145339 /* 1350 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 398,
145340 /* 1360 */ 507, 328, 1266, 1274, 358, 453, 282, 192, 1346, 109,
145341 /* 1370 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 398,
145342 /* 1380 */ 11, 1166, 1345, 399, 1440, 330, 502, 1110, 231, 428,
145343 /* 1390 */ 1391, 343, 187, 98, 504, 501, 4, 1107, 1389, 375,
145344 /* 1400 */ 422, 155, 72, 165, 75, 152, 149, 86, 414, 1263,
145345 /* 1410 */ 507, 157, 415, 160, 929, 161, 162, 163, 446, 1271,
145346 /* 1420 */ 96, 96, 8, 30, 208, 1277, 357, 97, 355, 399,
145347 /* 1430 */ 514, 513, 421, 399, 919, 31, 169, 435, 1340, 212,
145348 /* 1440 */ 80, 441, 243, 214, 1360, 501, 298, 174, 444, 302,
145349 /* 1450 */ 215, 271, 503, 1134, 216, 360, 485, 459, 388, 1186,
145350 /* 1460 */ 361, 484, 1185, 795, 929, 919, 919, 921, 922, 24,
145351 /* 1470 */ 96, 96, 1184, 1158, 1177, 314, 1157, 97, 1176, 399,
145352 /* 1480 */ 514, 513, 469, 1156, 919, 1452, 390, 266, 98, 504,
145353 /* 1490 */ 267, 4, 472, 478, 483, 85, 1227, 333, 230, 492,
145354 /* 1500 */ 1408, 332, 323, 115, 10, 507, 1228, 181, 335, 98,
145355 /* 1510 */ 504, 337, 4, 92, 87, 919, 919, 921, 922, 24,
145356 /* 1520 */ 1429, 1063, 401, 1226, 481, 254, 507, 325, 399, 327,
145357 /* 1530 */ 349, 349, 348, 239, 346, 1225, 329, 766, 1209, 1326,
145358 /* 1540 */ 501, 183, 1208, 341, 269, 342, 237, 1069, 1140, 399,
145359 /* 1550 */ 199, 485, 277, 29, 515, 241, 486, 238, 516, 929,
145360 /* 1560 */ 276, 501, 240, 1129, 1124, 96, 96, 1376, 142, 154,
145361 /* 1570 */ 369, 370, 97, 143, 399, 514, 513, 1377, 128, 919,
145362 /* 1580 */ 929, 1375, 144, 753, 400, 1374, 96, 96, 848, 1154,
145363 /* 1590 */ 201, 1153, 185, 97, 264, 399, 514, 513, 202, 71,
145364 /* 1600 */ 919, 146, 1151, 273, 198, 404, 126, 987, 200, 985,
145365 /* 1610 */ 919, 919, 921, 922, 24, 903, 156, 145, 204, 158,
145366 /* 1620 */ 827, 98, 504, 288, 4, 207, 1001, 164, 147, 907,
145367 /* 1630 */ 377, 919, 919, 921, 922, 24, 379, 148, 507, 166,
145368 /* 1640 */ 76, 77, 368, 1004, 78, 79, 209, 271, 503, 210,
145369 /* 1650 */ 1000, 137, 18, 297, 211, 228, 440, 1104, 213, 171,
145370 /* 1660 */ 32, 399, 768, 993, 170, 316, 445, 217, 449, 806,
145371 /* 1670 */ 406, 310, 172, 501, 81, 19, 20, 454, 82, 83,
145372 /* 1680 */ 265, 150, 179, 461, 485, 151, 180, 955, 84, 484,
145373 /* 1690 */ 1035, 34, 929, 35, 468, 1036, 193, 471, 96, 96,
145374 /* 1700 */ 246, 248, 876, 175, 871, 97, 100, 399, 514, 513,
145375 /* 1710 */ 1063, 401, 919, 227, 254, 1053, 21, 22, 1049, 349,
145376 /* 1720 */ 349, 348, 239, 346, 1040, 176, 766, 334, 1051, 7,
145377 /* 1730 */ 88, 98, 504, 970, 4, 233, 23, 956, 954, 199,
145378 /* 1740 */ 958, 277, 1010, 919, 919, 921, 922, 24, 507, 276,
145379 /* 1750 */ 232, 1009, 959, 25, 36, 508, 924, 778, 99, 26,
145380 /* 1760 */ 347, 90, 504, 837, 4, 234, 344, 235, 1445, 1064,
145381 /* 1770 */ 1120, 399, 1120, 1444, 1120, 1120, 1120, 1120, 507, 201,
145382 /* 1780 */ 1120, 1120, 1120, 501, 1120, 1120, 1120, 202, 1120, 1120,
145383 /* 1790 */ 146, 1120, 1120, 1120, 1120, 1120, 1120, 200, 1120, 1120,
145384 /* 1800 */ 1120, 399, 929, 1120, 1120, 1120, 1120, 1120, 96, 96,
145385 /* 1810 */ 1120, 1120, 1120, 501, 1120, 97, 1120, 399, 514, 513,
145386 /* 1820 */ 1120, 1120, 919, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
145387 /* 1830 */ 1120, 368, 929, 1120, 1120, 1120, 271, 503, 96, 96,
145388 /* 1840 */ 1120, 1120, 1120, 1120, 1120, 97, 1120, 399, 514, 513,
145389 /* 1850 */ 1120, 1120, 919, 919, 919, 921, 922, 24, 1120, 406,
145390 /* 1860 */ 1120, 1120, 1120, 254, 1120, 1120, 1120, 1120, 349, 349,
145391 /* 1870 */ 348, 239, 346, 1120, 1120, 766, 1120, 1120, 1120, 1120,
145392 /* 1880 */ 1120, 1120, 1120, 919, 919, 921, 922, 24, 199, 1120,
145393 /* 1890 */ 277, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 276, 1120,
145394 /* 1900 */ 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
145395 /* 1910 */ 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
145396 /* 1920 */ 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 201, 1120,
145397 /* 1930 */ 1120, 1120, 1120, 1120, 1120, 1120, 202, 1120, 1120, 146,
145398 /* 1940 */ 1120, 1120, 1120, 1120, 1120, 1120, 200, 1120, 1120, 1120,
145399 /* 1950 */ 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
145400 /* 1960 */ 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
145401 /* 1970 */ 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
145402 /* 1980 */ 368, 1120, 1120, 1120, 1120, 271, 503, 1120, 1120, 1120,
145403 /* 1990 */ 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120,
145404 /* 2000 */ 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 406,
145405 };
145406 static const YYCODETYPE yy_lookahead[] = {
145407 /* 0 */ 184, 238, 239, 240, 238, 239, 240, 163, 155, 156,
145408 /* 10 */ 157, 158, 159, 160, 163, 191, 192, 183, 165, 19,
145409 /* 20 */ 167, 258, 202, 203, 200, 191, 163, 174, 184, 185,
@@ -145498,16 +146448,16 @@
145498 /* 910 */ 163, 184, 185, 163, 132, 163, 141, 163, 143, 22,
145499 /* 920 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
145500 /* 930 */ 102, 184, 185, 163, 184, 185, 184, 185, 184, 185,
145501 /* 940 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
145502 /* 950 */ 102, 163, 163, 163, 184, 185, 163, 115, 163, 163,
145503 /* 960 */ 163, 163, 59, 163, 163, 163, 163, 163, 23, 163,
145504 /* 970 */ 163, 26, 184, 185, 184, 185, 163, 184, 185, 184,
145505 /* 980 */ 185, 184, 185, 163, 184, 185, 184, 185, 184, 185,
145506 /* 990 */ 184, 185, 163, 96, 97, 147, 163, 184, 185, 163,
145507 /* 1000 */ 199, 163, 124, 205, 184, 185, 163, 129, 163, 106,
145508 /* 1010 */ 163, 234, 163, 184, 185, 19, 163, 184, 185, 230,
145509 /* 1020 */ 184, 185, 184, 185, 206, 207, 230, 184, 185, 184,
145510 /* 1030 */ 185, 184, 185, 184, 185, 19, 163, 219, 231, 43,
145511 /* 1040 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
145512 /* 1050 */ 54, 55, 56, 57, 163, 26, 163, 184, 185, 43,
145513 /* 1060 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
@@ -145517,74 +146467,74 @@
145517 /* 1100 */ 184, 185, 184, 185, 163, 184, 185, 163, 92, 93,
145518 /* 1110 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 163,
145519 /* 1120 */ 184, 185, 98, 59, 163, 184, 185, 205, 184, 185,
145520 /* 1130 */ 23, 206, 207, 26, 163, 26, 107, 153, 154, 237,
145521 /* 1140 */ 184, 185, 231, 147, 219, 184, 185, 249, 124, 127,
145522 /* 1150 */ 128, 231, 254, 129, 118, 231, 177, 178, 262, 263,
145523 /* 1160 */ 22, 132, 19, 19, 46, 223, 224, 31, 24, 23,
145524 /* 1170 */ 106, 141, 26, 143, 272, 39, 140, 23, 23, 23,
145525 /* 1180 */ 26, 26, 26, 19, 22, 109, 110, 43, 44, 45,
145526 /* 1190 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
145527 /* 1200 */ 56, 57, 231, 23, 7, 8, 26, 43, 44, 45,
145528 /* 1210 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
145529 /* 1220 */ 56, 57, 104, 61, 23, 23, 59, 26, 26, 23,
145530 /* 1230 */ 23, 23, 26, 26, 26, 59, 92, 93, 94, 95,
145531 /* 1240 */ 96, 97, 98, 99, 100, 101, 102, 138, 105, 23,
145532 /* 1250 */ 23, 163, 26, 26, 163, 163, 92, 93, 94, 95,
145533 /* 1260 */ 96, 97, 98, 99, 100, 101, 102, 110, 130, 163,
145534 /* 1270 */ 193, 163, 193, 106, 163, 163, 19, 120, 163, 163,
145535 /* 1280 */ 163, 225, 106, 163, 163, 163, 163, 163, 193, 163,
145536 /* 1290 */ 163, 163, 163, 163, 163, 163, 19, 222, 163, 203,
145537 /* 1300 */ 163, 44, 45, 46, 47, 48, 49, 50, 51, 52,
145538 /* 1310 */ 53, 54, 55, 56, 57, 163, 163, 251, 250, 209,
145539 /* 1320 */ 222, 163, 45, 46, 47, 48, 49, 50, 51, 52,
145540 /* 1330 */ 53, 54, 55, 56, 57, 163, 163, 163, 163, 161,
145541 /* 1340 */ 226, 222, 182, 19, 20, 256, 22, 222, 187, 92,
145542 /* 1350 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
145543 /* 1360 */ 36, 222, 213, 213, 213, 188, 226, 196, 187, 92,
145544 /* 1370 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
145545 /* 1380 */ 210, 192, 187, 59, 166, 226, 244, 60, 130, 256,
145546 /* 1390 */ 170, 212, 210, 19, 20, 71, 22, 38, 170, 170,
145547 /* 1400 */ 104, 260, 257, 22, 257, 81, 43, 138, 18, 213,
145548 /* 1410 */ 36, 201, 170, 204, 90, 204, 204, 204, 18, 236,
145549 /* 1420 */ 96, 97, 48, 235, 169, 201, 236, 103, 213, 105,
145550 /* 1430 */ 106, 107, 213, 59, 110, 235, 201, 170, 213, 169,
145551 /* 1440 */ 146, 62, 170, 169, 253, 71, 252, 22, 189, 170,
145552 /* 1450 */ 169, 127, 128, 170, 169, 189, 82, 104, 64, 186,
145553 /* 1460 */ 189, 87, 186, 115, 90, 141, 142, 143, 144, 145,
145554 /* 1470 */ 96, 97, 186, 186, 194, 186, 188, 103, 194, 105,
145555 /* 1480 */ 106, 107, 189, 186, 110, 186, 102, 246, 19, 20,
145556 /* 1490 */ 246, 22, 189, 133, 84, 104, 228, 22, 170, 134,
145557 /* 1500 */ 269, 271, 227, 137, 22, 36, 228, 216, 216, 19,
145558 /* 1510 */ 20, 170, 22, 146, 136, 141, 142, 143, 144, 145,
145559 /* 1520 */ 0, 1, 2, 228, 135, 5, 36, 227, 59, 227,
145560 /* 1530 */ 10, 11, 12, 13, 14, 228, 227, 17, 217, 241,
145561 /* 1540 */ 71, 215, 217, 214, 243, 213, 25, 13, 173, 59,
145562 /* 1550 */ 30, 82, 32, 26, 172, 6, 87, 164, 162, 90,
145563 /* 1560 */ 40, 71, 164, 162, 162, 96, 97, 182, 176, 263,
145564 /* 1570 */ 266, 266, 103, 176, 105, 106, 107, 182, 190, 110,
145565 /* 1580 */ 90, 182, 176, 4, 3, 182, 96, 97, 98, 182,
145566 /* 1590 */ 70, 182, 22, 103, 190, 105, 106, 107, 78, 182,
145567 /* 1600 */ 110, 81, 182, 151, 15, 89, 16, 23, 88, 23,
145568 /* 1610 */ 141, 142, 143, 144, 145, 128, 139, 119, 24, 131,
145569 /* 1620 */ 20, 19, 20, 16, 22, 133, 1, 131, 119, 140,
145570 /* 1630 */ 61, 141, 142, 143, 144, 145, 37, 119, 36, 139,
145571 /* 1640 */ 53, 53, 122, 105, 53, 53, 34, 127, 128, 130,
145572 /* 1650 */ 1, 5, 22, 149, 104, 26, 41, 75, 130, 104,
145573 /* 1660 */ 24, 59, 20, 68, 68, 120, 19, 114, 67, 28,
145574 /* 1670 */ 150, 23, 22, 71, 22, 22, 22, 67, 22, 138,
145575 /* 1680 */ 67, 37, 23, 22, 82, 153, 23, 23, 26, 87,
145576 /* 1690 */ 23, 22, 90, 22, 24, 23, 130, 24, 96, 97,
145577 /* 1700 */ 23, 23, 105, 22, 132, 103, 26, 105, 106, 107,
145578 /* 1710 */ 1, 2, 110, 34, 5, 75, 34, 34, 85, 10,
145579 /* 1720 */ 11, 12, 13, 14, 23, 26, 17, 24, 83, 44,
145580 /* 1730 */ 26, 19, 20, 23, 22, 22, 34, 23, 23, 30,
145581 /* 1740 */ 23, 32, 23, 141, 142, 143, 144, 145, 36, 40,
145582 /* 1750 */ 26, 23, 11, 22, 22, 26, 23, 23, 22, 22,
145583 /* 1760 */ 15, 19, 20, 124, 22, 130, 23, 130, 130, 1,
145584 /* 1770 */ 277, 59, 277, 130, 277, 277, 277, 277, 36, 70,
145585 /* 1780 */ 277, 277, 277, 71, 277, 277, 277, 78, 277, 277,
145586 /* 1790 */ 81, 277, 277, 277, 277, 277, 277, 88, 277, 277,
145587 /* 1800 */ 277, 59, 90, 277, 277, 277, 277, 277, 96, 97,
145588 /* 1810 */ 277, 277, 277, 71, 277, 103, 277, 105, 106, 107,
145589 /* 1820 */ 277, 277, 110, 277, 277, 277, 277, 277, 277, 277,
145590 /* 1830 */ 277, 122, 90, 277, 277, 277, 127, 128, 96, 97,
@@ -145605,11 +146555,11 @@
145605 /* 1980 */ 122, 277, 277, 277, 277, 127, 128, 277, 277, 277,
145606 /* 1990 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
145607 /* 2000 */ 277, 277, 277, 277, 277, 277, 277, 277, 150, 277,
145608 /* 2010 */ 277, 277, 277, 277, 277, 277, 277, 277, 277,
145609 };
145610 #define YY_SHIFT_COUNT (517)
145611 #define YY_SHIFT_MIN (0)
145612 #define YY_SHIFT_MAX (1858)
145613 static const unsigned short int yy_shift_ofst[] = {
145614 /* 0 */ 1709, 1520, 1858, 1324, 1324, 277, 1374, 1469, 1602, 1712,
145615 /* 10 */ 1712, 1712, 273, 0, 0, 113, 1016, 1712, 1712, 1712,
@@ -145629,46 +146579,47 @@
145629 /* 150 */ 597, 464, 474, 262, 681, 531, 531, 531, 531, 531,
145630 /* 160 */ 531, 531, 531, 531, 531, 531, 531, 531, 531, 531,
145631 /* 170 */ 531, 531, 531, 531, 531, 531, 531, 173, 485, 984,
145632 /* 180 */ 984, 576, 485, 19, 1022, 2009, 2009, 2009, 387, 250,
145633 /* 190 */ 250, 525, 502, 278, 552, 227, 480, 566, 531, 531,
145634 /* 200 */ 531, 531, 531, 531, 531, 531, 639, 531, 531, 531,
145635 /* 210 */ 531, 531, 531, 531, 531, 531, 531, 531, 531, 2,
145636 /* 220 */ 2, 2, 531, 531, 531, 531, 782, 531, 531, 531,
145637 /* 230 */ 744, 531, 531, 783, 531, 531, 531, 531, 531, 531,
145638 /* 240 */ 531, 531, 419, 682, 327, 370, 370, 370, 370, 1029,
145639 /* 250 */ 327, 327, 1024, 897, 856, 1109, 706, 706, 1143, 1109,
145640 /* 260 */ 1109, 1143, 842, 945, 1118, 1136, 1136, 1136, 706, 676,
145641 /* 270 */ 400, 878, 694, 1327, 1258, 1258, 1359, 1359, 1258, 1296,
145642 /* 280 */ 1381, 1363, 1269, 1390, 1390, 1390, 1390, 1258, 1400, 1269,
145643 /* 290 */ 1269, 1296, 1381, 1363, 1363, 1269, 1258, 1400, 1294, 1379,
145644 /* 300 */ 1258, 1400, 1425, 1258, 1400, 1258, 1400, 1425, 1353, 1353,
145645 /* 310 */ 1353, 1394, 1425, 1353, 1348, 1353, 1394, 1353, 1353, 1425,
145646 /* 320 */ 1384, 1384, 1425, 1360, 1391, 1360, 1391, 1360, 1391, 1360,
145647 /* 330 */ 1391, 1258, 1365, 1410, 1475, 1366, 1365, 1482, 1258, 1367,
145648 /* 340 */ 1366, 1378, 1389, 1269, 1521, 1527, 1534, 1534, 1549, 1549,
145649 /* 350 */ 1549, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
145650 /* 360 */ 2009, 2009, 2009, 2009, 2009, 2009, 2009, 570, 345, 686,
145651 /* 370 */ 748, 50, 740, 1064, 1107, 469, 537, 1036, 1146, 1162,
145652 /* 380 */ 1154, 1155, 1156, 1180, 1201, 1202, 903, 1076, 1197, 1157,
145653 /* 390 */ 1167, 1206, 1207, 1208, 775, 1030, 1226, 1227, 1176, 1138,
145654 /* 400 */ 1579, 1581, 1570, 1452, 1589, 1516, 1590, 1584, 1586, 1487,
145655 /* 410 */ 1477, 1498, 1594, 1488, 1600, 1492, 1607, 1625, 1496, 1489,
145656 /* 420 */ 1509, 1569, 1599, 1500, 1587, 1588, 1591, 1592, 1518, 1538,
145657 /* 430 */ 1612, 1519, 1649, 1646, 1630, 1550, 1504, 1595, 1629, 1596,
145658 /* 440 */ 1582, 1615, 1528, 1555, 1636, 1642, 1647, 1545, 1553, 1650,
145659 /* 450 */ 1601, 1652, 1653, 1648, 1654, 1610, 1641, 1656, 1613, 1644,
145660 /* 460 */ 1659, 1541, 1661, 1532, 1663, 1664, 1662, 1667, 1669, 1670,
145661 /* 470 */ 1672, 1671, 1673, 1566, 1677, 1678, 1597, 1679, 1681, 1572,
145662 /* 480 */ 1680, 1682, 1680, 1683, 1633, 1640, 1645, 1685, 1701, 1703,
145663 /* 490 */ 1699, 1704, 1702, 1710, 1680, 1714, 1715, 1717, 1719, 1724,
145664 /* 500 */ 1728, 1713, 1741, 1731, 1732, 1733, 1734, 1736, 1737, 1729,
145665 /* 510 */ 1639, 1635, 1637, 1638, 1643, 1743, 1745, 1768,
 
145666 };
145667 #define YY_REDUCE_COUNT (366)
145668 #define YY_REDUCE_MIN (-237)
145669 #define YY_REDUCE_MAX (1420)
145670 static const short yy_reduce_ofst[] = {
145671 /* 0 */ -147, 171, 263, -96, 358, -144, -149, -102, 124, -156,
145672 /* 10 */ -98, 305, 401, -57, 209, -237, 245, -94, -79, 189,
145673 /* 20 */ 375, 490, 493, 378, 303, 539, 542, 501, 503, 554,
145674 /* 30 */ 415, 526, 546, 557, 587, 593, 595, -234, -234, -234,
@@ -145686,81 +146637,82 @@
145686 /* 150 */ 364, 41, 513, 509, 509, 117, 500, 789, 796, 646,
145687 /* 160 */ 192, 291, 644, 798, 120, 807, 543, 911, 920, 652,
145688 /* 170 */ 924, 922, 232, 698, 801, 971, 39, 220, 731, 442,
145689 /* 180 */ 902, -199, 979, -43, 421, 896, 942, 605, -184, -126,
145690 /* 190 */ 155, 172, 281, 304, 377, 538, 650, 690, 699, 723,
145691 /* 200 */ 803, 853, 919, 1088, 1091, 1092, 777, 1106, 1108, 1111,
145692 /* 210 */ 1112, 1115, 1116, 1117, 1120, 1121, 1122, 1123, 1124, 1077,
145693 /* 220 */ 1079, 1095, 1126, 1127, 1128, 1129, 1056, 1130, 1131, 1132,
145694 /* 230 */ 1075, 1135, 1137, 1096, 1152, 304, 1153, 1158, 1172, 1173,
145695 /* 240 */ 1174, 1175, 1066, 1068, 1110, 1098, 1119, 1125, 1139, 1056,
145696 /* 250 */ 1110, 1110, 1170, 1160, 1178, 1149, 1114, 1140, 1089, 1150,
145697 /* 260 */ 1151, 1133, 1177, 1171, 1189, 1161, 1181, 1195, 1159, 1142,
145698 /* 270 */ 1179, 1182, 1218, 1141, 1220, 1228, 1145, 1147, 1229, 1183,
145699 /* 280 */ 1188, 1210, 1196, 1209, 1211, 1212, 1213, 1242, 1255, 1215,
145700 /* 290 */ 1219, 1190, 1200, 1224, 1235, 1225, 1267, 1270, 1191, 1194,
145701 /* 300 */ 1272, 1274, 1259, 1279, 1281, 1283, 1285, 1266, 1273, 1276,
145702 /* 310 */ 1286, 1280, 1271, 1287, 1288, 1289, 1284, 1297, 1299, 1293,
145703 /* 320 */ 1241, 1244, 1303, 1268, 1275, 1278, 1300, 1295, 1302, 1307,
145704 /* 330 */ 1309, 1328, 1291, 1230, 1231, 1321, 1292, 1298, 1341, 1301,
145705 /* 340 */ 1325, 1326, 1329, 1332, 1375, 1382, 1393, 1398, 1396, 1401,
145706 /* 350 */ 1402, 1304, 1305, 1306, 1392, 1385, 1395, 1399, 1403, 1397,
145707 /* 360 */ 1388, 1404, 1407, 1409, 1417, 1420, 1406,
145708 };
145709 static const YYACTIONTYPE yy_default[] = {
145710 /* 0 */ 1486, 1486, 1486, 1335, 1118, 1224, 1118, 1118, 1118, 1335,
145711 /* 10 */ 1335, 1335, 1118, 1254, 1254, 1386, 1149, 1118, 1118, 1118,
145712 /* 20 */ 1118, 1118, 1118, 1118, 1334, 1118, 1118, 1118, 1118, 1118,
145713 /* 30 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1260, 1118,
145714 /* 40 */ 1118, 1118, 1118, 1118, 1336, 1337, 1118, 1118, 1118, 1385,
145715 /* 50 */ 1387, 1270, 1269, 1268, 1267, 1368, 1241, 1265, 1258, 1262,
145716 /* 60 */ 1330, 1331, 1329, 1333, 1337, 1336, 1118, 1261, 1301, 1315,
145717 /* 70 */ 1300, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145718 /* 80 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145719 /* 90 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145720 /* 100 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145721 /* 110 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1309, 1314, 1320,
145722 /* 120 */ 1313, 1310, 1303, 1302, 1304, 1305, 1118, 1139, 1188, 1118,
145723 /* 130 */ 1118, 1118, 1118, 1403, 1402, 1118, 1118, 1149, 1306, 1307,
145724 /* 140 */ 1317, 1316, 1393, 1442, 1441, 1118, 1118, 1118, 1118, 1118,
145725 /* 150 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145726 /* 160 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145727 /* 170 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1149, 1145, 1295,
145728 /* 180 */ 1294, 1412, 1145, 1248, 1118, 1398, 1224, 1215, 1118, 1118,
145729 /* 190 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1390,
145730 /* 200 */ 1388, 1118, 1350, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145731 /* 210 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145732 /* 220 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145733 /* 230 */ 1220, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145734 /* 240 */ 1118, 1436, 1118, 1363, 1202, 1220, 1220, 1220, 1220, 1222,
145735 /* 250 */ 1203, 1201, 1214, 1149, 1125, 1264, 1243, 1243, 1475, 1264,
145736 /* 260 */ 1264, 1475, 1163, 1456, 1160, 1254, 1254, 1254, 1243, 1332,
145737 /* 270 */ 1221, 1214, 1118, 1478, 1229, 1229, 1477, 1477, 1229, 1273,
145738 /* 280 */ 1279, 1191, 1264, 1197, 1197, 1197, 1197, 1229, 1136, 1264,
145739 /* 290 */ 1264, 1273, 1279, 1191, 1191, 1264, 1229, 1136, 1367, 1472,
145740 /* 300 */ 1229, 1136, 1343, 1229, 1136, 1229, 1136, 1343, 1189, 1189,
145741 /* 310 */ 1189, 1178, 1343, 1189, 1163, 1189, 1178, 1189, 1189, 1343,
145742 /* 320 */ 1347, 1347, 1343, 1247, 1242, 1247, 1242, 1247, 1242, 1247,
145743 /* 330 */ 1242, 1229, 1248, 1411, 1118, 1259, 1248, 1338, 1229, 1118,
145744 /* 340 */ 1259, 1257, 1255, 1264, 1142, 1181, 1439, 1439, 1435, 1435,
145745 /* 350 */ 1435, 1483, 1483, 1398, 1451, 1149, 1149, 1149, 1149, 1451,
145746 /* 360 */ 1165, 1165, 1149, 1149, 1149, 1149, 1451, 1118, 1118, 1118,
145747 /* 370 */ 1118, 1118, 1118, 1446, 1118, 1352, 1233, 1118, 1118, 1118,
145748 /* 380 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145749 /* 390 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1284,
145750 /* 400 */ 1118, 1121, 1395, 1118, 1118, 1394, 1118, 1118, 1118, 1118,
145751 /* 410 */ 1118, 1118, 1234, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145752 /* 420 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145753 /* 430 */ 1118, 1474, 1118, 1118, 1118, 1118, 1118, 1118, 1366, 1365,
145754 /* 440 */ 1118, 1118, 1231, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145755 /* 450 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145756 /* 460 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145757 /* 470 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145758 /* 480 */ 1256, 1118, 1410, 1118, 1118, 1118, 1118, 1118, 1118, 1118,
145759 /* 490 */ 1424, 1249, 1118, 1118, 1465, 1118, 1118, 1118, 1118, 1118,
145760 /* 500 */ 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1118, 1460,
145761 /* 510 */ 1205, 1286, 1118, 1285, 1289, 1118, 1130, 1118,
 
145762 };
145763 /********** End of lemon-generated parsing tables *****************************/
145764
145765 /* The next table maps tokens (terminal symbols) into fallback tokens.
145766 ** If a construct like the following:
@@ -146512,102 +147464,103 @@
146512 /* 269 */ "cmd ::= ANALYZE",
146513 /* 270 */ "cmd ::= ANALYZE nm dbnm",
146514 /* 271 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
146515 /* 272 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
146516 /* 273 */ "add_column_fullname ::= fullname",
146517 /* 274 */ "cmd ::= create_vtab",
146518 /* 275 */ "cmd ::= create_vtab LP vtabarglist RP",
146519 /* 276 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
146520 /* 277 */ "vtabarg ::=",
146521 /* 278 */ "vtabargtoken ::= ANY",
146522 /* 279 */ "vtabargtoken ::= lp anylist RP",
146523 /* 280 */ "lp ::= LP",
146524 /* 281 */ "with ::= WITH wqlist",
146525 /* 282 */ "with ::= WITH RECURSIVE wqlist",
146526 /* 283 */ "wqlist ::= nm eidlist_opt AS LP select RP",
146527 /* 284 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
146528 /* 285 */ "windowdefn_list ::= windowdefn",
146529 /* 286 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
146530 /* 287 */ "windowdefn ::= nm AS window",
146531 /* 288 */ "window ::= LP part_opt orderby_opt frame_opt RP",
146532 /* 289 */ "part_opt ::= PARTITION BY nexprlist",
146533 /* 290 */ "part_opt ::=",
146534 /* 291 */ "frame_opt ::=",
146535 /* 292 */ "frame_opt ::= range_or_rows frame_bound_s",
146536 /* 293 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e",
146537 /* 294 */ "range_or_rows ::= RANGE",
146538 /* 295 */ "range_or_rows ::= ROWS",
146539 /* 296 */ "frame_bound_s ::= frame_bound",
146540 /* 297 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
146541 /* 298 */ "frame_bound_e ::= frame_bound",
146542 /* 299 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
146543 /* 300 */ "frame_bound ::= expr PRECEDING",
146544 /* 301 */ "frame_bound ::= CURRENT ROW",
146545 /* 302 */ "frame_bound ::= expr FOLLOWING",
146546 /* 303 */ "window_clause ::= WINDOW windowdefn_list",
146547 /* 304 */ "over_clause ::= filter_opt OVER window",
146548 /* 305 */ "over_clause ::= filter_opt OVER nm",
146549 /* 306 */ "filter_opt ::=",
146550 /* 307 */ "filter_opt ::= FILTER LP WHERE expr RP",
146551 /* 308 */ "input ::= cmdlist",
146552 /* 309 */ "cmdlist ::= cmdlist ecmd",
146553 /* 310 */ "cmdlist ::= ecmd",
146554 /* 311 */ "ecmd ::= SEMI",
146555 /* 312 */ "ecmd ::= cmdx SEMI",
146556 /* 313 */ "ecmd ::= explain cmdx",
146557 /* 314 */ "trans_opt ::=",
146558 /* 315 */ "trans_opt ::= TRANSACTION",
146559 /* 316 */ "trans_opt ::= TRANSACTION nm",
146560 /* 317 */ "savepoint_opt ::= SAVEPOINT",
146561 /* 318 */ "savepoint_opt ::=",
146562 /* 319 */ "cmd ::= create_table create_table_args",
146563 /* 320 */ "columnlist ::= columnlist COMMA columnname carglist",
146564 /* 321 */ "columnlist ::= columnname carglist",
146565 /* 322 */ "nm ::= ID|INDEXED",
146566 /* 323 */ "nm ::= STRING",
146567 /* 324 */ "nm ::= JOIN_KW",
146568 /* 325 */ "typetoken ::= typename",
146569 /* 326 */ "typename ::= ID|STRING",
146570 /* 327 */ "signed ::= plus_num",
146571 /* 328 */ "signed ::= minus_num",
146572 /* 329 */ "carglist ::= carglist ccons",
146573 /* 330 */ "carglist ::=",
146574 /* 331 */ "ccons ::= NULL onconf",
146575 /* 332 */ "conslist_opt ::= COMMA conslist",
146576 /* 333 */ "conslist ::= conslist tconscomma tcons",
146577 /* 334 */ "conslist ::= tcons",
146578 /* 335 */ "tconscomma ::=",
146579 /* 336 */ "defer_subclause_opt ::= defer_subclause",
146580 /* 337 */ "resolvetype ::= raisetype",
146581 /* 338 */ "selectnowith ::= oneselect",
146582 /* 339 */ "oneselect ::= values",
146583 /* 340 */ "sclp ::= selcollist COMMA",
146584 /* 341 */ "as ::= ID|STRING",
146585 /* 342 */ "expr ::= term",
146586 /* 343 */ "likeop ::= LIKE_KW|MATCH",
146587 /* 344 */ "exprlist ::= nexprlist",
146588 /* 345 */ "nmnum ::= plus_num",
146589 /* 346 */ "nmnum ::= nm",
146590 /* 347 */ "nmnum ::= ON",
146591 /* 348 */ "nmnum ::= DELETE",
146592 /* 349 */ "nmnum ::= DEFAULT",
146593 /* 350 */ "plus_num ::= INTEGER|FLOAT",
146594 /* 351 */ "foreach_clause ::=",
146595 /* 352 */ "foreach_clause ::= FOR EACH ROW",
146596 /* 353 */ "trnm ::= nm",
146597 /* 354 */ "tridxby ::=",
146598 /* 355 */ "database_kw_opt ::= DATABASE",
146599 /* 356 */ "database_kw_opt ::=",
146600 /* 357 */ "kwcolumn_opt ::=",
146601 /* 358 */ "kwcolumn_opt ::= COLUMNKW",
146602 /* 359 */ "vtabarglist ::= vtabarg",
146603 /* 360 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
146604 /* 361 */ "vtabarg ::= vtabarg vtabargtoken",
146605 /* 362 */ "anylist ::=",
146606 /* 363 */ "anylist ::= anylist LP anylist RP",
146607 /* 364 */ "anylist ::= anylist ANY",
146608 /* 365 */ "with ::=",
 
146609 };
146610 #endif /* NDEBUG */
146611
146612
146613 #if YYSTACKDEPTH<=0
@@ -147391,102 +148344,103 @@
147391 { 160, -1 }, /* (269) cmd ::= ANALYZE */
147392 { 160, -3 }, /* (270) cmd ::= ANALYZE nm dbnm */
147393 { 160, -6 }, /* (271) cmd ::= ALTER TABLE fullname RENAME TO nm */
147394 { 160, -7 }, /* (272) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
147395 { 259, -1 }, /* (273) add_column_fullname ::= fullname */
147396 { 160, -1 }, /* (274) cmd ::= create_vtab */
147397 { 160, -4 }, /* (275) cmd ::= create_vtab LP vtabarglist RP */
147398 { 261, -8 }, /* (276) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
147399 { 263, 0 }, /* (277) vtabarg ::= */
147400 { 264, -1 }, /* (278) vtabargtoken ::= ANY */
147401 { 264, -3 }, /* (279) vtabargtoken ::= lp anylist RP */
147402 { 265, -1 }, /* (280) lp ::= LP */
147403 { 232, -2 }, /* (281) with ::= WITH wqlist */
147404 { 232, -3 }, /* (282) with ::= WITH RECURSIVE wqlist */
147405 { 208, -6 }, /* (283) wqlist ::= nm eidlist_opt AS LP select RP */
147406 { 208, -8 }, /* (284) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
147407 { 267, -1 }, /* (285) windowdefn_list ::= windowdefn */
147408 { 267, -3 }, /* (286) windowdefn_list ::= windowdefn_list COMMA windowdefn */
147409 { 268, -3 }, /* (287) windowdefn ::= nm AS window */
147410 { 269, -5 }, /* (288) window ::= LP part_opt orderby_opt frame_opt RP */
147411 { 271, -3 }, /* (289) part_opt ::= PARTITION BY nexprlist */
147412 { 271, 0 }, /* (290) part_opt ::= */
147413 { 270, 0 }, /* (291) frame_opt ::= */
147414 { 270, -2 }, /* (292) frame_opt ::= range_or_rows frame_bound_s */
147415 { 270, -5 }, /* (293) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
147416 { 273, -1 }, /* (294) range_or_rows ::= RANGE */
147417 { 273, -1 }, /* (295) range_or_rows ::= ROWS */
147418 { 275, -1 }, /* (296) frame_bound_s ::= frame_bound */
147419 { 275, -2 }, /* (297) frame_bound_s ::= UNBOUNDED PRECEDING */
147420 { 276, -1 }, /* (298) frame_bound_e ::= frame_bound */
147421 { 276, -2 }, /* (299) frame_bound_e ::= UNBOUNDED FOLLOWING */
147422 { 274, -2 }, /* (300) frame_bound ::= expr PRECEDING */
147423 { 274, -2 }, /* (301) frame_bound ::= CURRENT ROW */
147424 { 274, -2 }, /* (302) frame_bound ::= expr FOLLOWING */
147425 { 218, -2 }, /* (303) window_clause ::= WINDOW windowdefn_list */
147426 { 237, -3 }, /* (304) over_clause ::= filter_opt OVER window */
147427 { 237, -3 }, /* (305) over_clause ::= filter_opt OVER nm */
147428 { 272, 0 }, /* (306) filter_opt ::= */
147429 { 272, -5 }, /* (307) filter_opt ::= FILTER LP WHERE expr RP */
147430 { 155, -1 }, /* (308) input ::= cmdlist */
147431 { 156, -2 }, /* (309) cmdlist ::= cmdlist ecmd */
147432 { 156, -1 }, /* (310) cmdlist ::= ecmd */
147433 { 157, -1 }, /* (311) ecmd ::= SEMI */
147434 { 157, -2 }, /* (312) ecmd ::= cmdx SEMI */
147435 { 157, -2 }, /* (313) ecmd ::= explain cmdx */
147436 { 162, 0 }, /* (314) trans_opt ::= */
147437 { 162, -1 }, /* (315) trans_opt ::= TRANSACTION */
147438 { 162, -2 }, /* (316) trans_opt ::= TRANSACTION nm */
147439 { 164, -1 }, /* (317) savepoint_opt ::= SAVEPOINT */
147440 { 164, 0 }, /* (318) savepoint_opt ::= */
147441 { 160, -2 }, /* (319) cmd ::= create_table create_table_args */
147442 { 171, -4 }, /* (320) columnlist ::= columnlist COMMA columnname carglist */
147443 { 171, -2 }, /* (321) columnlist ::= columnname carglist */
147444 { 163, -1 }, /* (322) nm ::= ID|INDEXED */
147445 { 163, -1 }, /* (323) nm ::= STRING */
147446 { 163, -1 }, /* (324) nm ::= JOIN_KW */
147447 { 177, -1 }, /* (325) typetoken ::= typename */
147448 { 178, -1 }, /* (326) typename ::= ID|STRING */
147449 { 179, -1 }, /* (327) signed ::= plus_num */
147450 { 179, -1 }, /* (328) signed ::= minus_num */
147451 { 176, -2 }, /* (329) carglist ::= carglist ccons */
147452 { 176, 0 }, /* (330) carglist ::= */
147453 { 183, -2 }, /* (331) ccons ::= NULL onconf */
147454 { 172, -2 }, /* (332) conslist_opt ::= COMMA conslist */
147455 { 195, -3 }, /* (333) conslist ::= conslist tconscomma tcons */
147456 { 195, -1 }, /* (334) conslist ::= tcons */
147457 { 196, 0 }, /* (335) tconscomma ::= */
147458 { 200, -1 }, /* (336) defer_subclause_opt ::= defer_subclause */
147459 { 202, -1 }, /* (337) resolvetype ::= raisetype */
147460 { 206, -1 }, /* (338) selectnowith ::= oneselect */
147461 { 207, -1 }, /* (339) oneselect ::= values */
147462 { 221, -2 }, /* (340) sclp ::= selcollist COMMA */
147463 { 222, -1 }, /* (341) as ::= ID|STRING */
147464 { 185, -1 }, /* (342) expr ::= term */
147465 { 238, -1 }, /* (343) likeop ::= LIKE_KW|MATCH */
147466 { 229, -1 }, /* (344) exprlist ::= nexprlist */
147467 { 247, -1 }, /* (345) nmnum ::= plus_num */
147468 { 247, -1 }, /* (346) nmnum ::= nm */
147469 { 247, -1 }, /* (347) nmnum ::= ON */
147470 { 247, -1 }, /* (348) nmnum ::= DELETE */
147471 { 247, -1 }, /* (349) nmnum ::= DEFAULT */
147472 { 180, -1 }, /* (350) plus_num ::= INTEGER|FLOAT */
147473 { 252, 0 }, /* (351) foreach_clause ::= */
147474 { 252, -3 }, /* (352) foreach_clause ::= FOR EACH ROW */
147475 { 255, -1 }, /* (353) trnm ::= nm */
147476 { 256, 0 }, /* (354) tridxby ::= */
147477 { 257, -1 }, /* (355) database_kw_opt ::= DATABASE */
147478 { 257, 0 }, /* (356) database_kw_opt ::= */
147479 { 260, 0 }, /* (357) kwcolumn_opt ::= */
147480 { 260, -1 }, /* (358) kwcolumn_opt ::= COLUMNKW */
147481 { 262, -1 }, /* (359) vtabarglist ::= vtabarg */
147482 { 262, -3 }, /* (360) vtabarglist ::= vtabarglist COMMA vtabarg */
147483 { 263, -2 }, /* (361) vtabarg ::= vtabarg vtabargtoken */
147484 { 266, 0 }, /* (362) anylist ::= */
147485 { 266, -4 }, /* (363) anylist ::= anylist LP anylist RP */
147486 { 266, -2 }, /* (364) anylist ::= anylist ANY */
147487 { 232, 0 }, /* (365) with ::= */
 
147488 };
147489
147490 static void yy_accept(yyParser*); /* Forward Declaration */
147491
147492 /*
@@ -147708,11 +148662,11 @@
147708 Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0);
147709 if( p ){
147710 sqlite3ExprIdToTrueFalse(p);
147711 testcase( p->op==TK_TRUEFALSE && sqlite3ExprTruthValue(p) );
147712 }
147713 sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
147714 }
147715 break;
147716 case 35: /* ccons ::= NOT NULL onconf */
147717 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy70);}
147718 break;
@@ -148041,15 +148995,27 @@
148041 case 108: /* dbnm ::= */
148042 case 122: /* indexed_opt ::= */ yytestcase(yyruleno==122);
148043 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
148044 break;
148045 case 110: /* fullname ::= nm */
148046 case 112: /* xfullname ::= nm */ yytestcase(yyruleno==112);
148047 {yymsp[0].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
 
 
 
148048 break;
148049 case 111: /* fullname ::= nm DOT nm */
148050 case 113: /* xfullname ::= nm DOT nm */ yytestcase(yyruleno==113);
 
 
 
 
 
 
 
 
 
148051 {yymsp[-2].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
148052 break;
148053 case 114: /* xfullname ::= nm DOT nm AS nm */
148054 {
148055 yymsp[-4].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
@@ -148195,14 +149161,14 @@
148195 break;
148196 case 159: /* idlist_opt ::= LP idlist RP */
148197 {yymsp[-2].minor.yy48 = yymsp[-1].minor.yy48;}
148198 break;
148199 case 160: /* idlist ::= idlist COMMA nm */
148200 {yymsp[-2].minor.yy48 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy48,&yymsp[0].minor.yy0);}
148201 break;
148202 case 161: /* idlist ::= nm */
148203 {yymsp[0].minor.yy48 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
148204 break;
148205 case 162: /* expr ::= LP expr RP */
148206 {yymsp[-2].minor.yy18 = yymsp[-1].minor.yy18;}
148207 break;
148208 case 163: /* expr ::= ID|INDEXED */
@@ -148211,10 +149177,14 @@
148211 break;
148212 case 165: /* expr ::= nm DOT nm */
148213 {
148214 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
148215 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
 
 
 
 
148216 yylhsminor.yy18 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
148217 }
148218 yymsp[-2].minor.yy18 = yylhsminor.yy18;
148219 break;
148220 case 166: /* expr ::= nm DOT nm DOT nm */
@@ -148221,10 +149191,14 @@
148221 {
148222 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
148223 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
148224 Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
148225 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
 
 
 
 
148226 yylhsminor.yy18 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
148227 }
148228 yymsp[-4].minor.yy18 = yylhsminor.yy18;
148229 break;
148230 case 167: /* term ::= NULL|FLOAT|BLOB */
@@ -148518,10 +149492,13 @@
148518 case 219: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
148519 {
148520 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
148521 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy420, yymsp[-10].minor.yy70,
148522 &yymsp[-11].minor.yy0, yymsp[0].minor.yy18, SQLITE_SO_ASC, yymsp[-8].minor.yy70, SQLITE_IDXTYPE_APPDEF);
 
 
 
148523 }
148524 break;
148525 case 220: /* uniqueflag ::= UNIQUE */
148526 case 260: /* raisetype ::= ABORT */ yytestcase(yyruleno==260);
148527 {yymsp[0].minor.yy70 = OE_Abort;}
@@ -148593,11 +149570,11 @@
148593 case 245: /* trigger_event ::= UPDATE OF idlist */
148594 {yymsp[-2].minor.yy34.a = TK_UPDATE; yymsp[-2].minor.yy34.b = yymsp[0].minor.yy48;}
148595 break;
148596 case 246: /* when_clause ::= */
148597 case 265: /* key_opt ::= */ yytestcase(yyruleno==265);
148598 case 306: /* filter_opt ::= */ yytestcase(yyruleno==306);
148599 { yymsp[1].minor.yy18 = 0; }
148600 break;
148601 case 247: /* when_clause ::= WHEN expr */
148602 case 266: /* key_opt ::= KEY expr */ yytestcase(yyruleno==266);
148603 { yymsp[-1].minor.yy18 = yymsp[0].minor.yy18; }
@@ -148636,21 +149613,21 @@
148636 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
148637 "within triggers");
148638 }
148639 break;
148640 case 253: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
148641 {yylhsminor.yy207 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy420, yymsp[-1].minor.yy18, yymsp[-6].minor.yy70, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy392);}
148642 yymsp[-7].minor.yy207 = yylhsminor.yy207;
148643 break;
148644 case 254: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
148645 {
148646 yylhsminor.yy207 = sqlite3TriggerInsertStep(pParse->db,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy48,yymsp[-2].minor.yy489,yymsp[-6].minor.yy70,yymsp[-1].minor.yy340,yymsp[-7].minor.yy392,yymsp[0].minor.yy392);/*yylhsminor.yy207-overwrites-yymsp[-6].minor.yy70*/
148647 }
148648 yymsp[-7].minor.yy207 = yylhsminor.yy207;
148649 break;
148650 case 255: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
148651 {yylhsminor.yy207 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy18, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy392);}
148652 yymsp[-5].minor.yy207 = yylhsminor.yy207;
148653 break;
148654 case 256: /* trigger_cmd ::= scanpt select scanpt */
148655 {yylhsminor.yy207 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy489, yymsp[-2].minor.yy392, yymsp[0].minor.yy392); /*yylhsminor.yy207-overwrites-yymsp[-1].minor.yy489*/}
148656 yymsp[-2].minor.yy207 = yylhsminor.yy207;
@@ -148719,134 +149696,139 @@
148719 {
148720 disableLookaside(pParse);
148721 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy135);
148722 }
148723 break;
148724 case 274: /* cmd ::= create_vtab */
 
 
 
 
 
148725 {sqlite3VtabFinishParse(pParse,0);}
148726 break;
148727 case 275: /* cmd ::= create_vtab LP vtabarglist RP */
148728 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
148729 break;
148730 case 276: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
148731 {
148732 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy70);
148733 }
148734 break;
148735 case 277: /* vtabarg ::= */
148736 {sqlite3VtabArgInit(pParse);}
148737 break;
148738 case 278: /* vtabargtoken ::= ANY */
148739 case 279: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==279);
148740 case 280: /* lp ::= LP */ yytestcase(yyruleno==280);
148741 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
148742 break;
148743 case 281: /* with ::= WITH wqlist */
148744 case 282: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==282);
148745 { sqlite3WithPush(pParse, yymsp[0].minor.yy449, 1); }
148746 break;
148747 case 283: /* wqlist ::= nm eidlist_opt AS LP select RP */
148748 {
148749 yymsp[-5].minor.yy449 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy420, yymsp[-1].minor.yy489); /*A-overwrites-X*/
148750 }
148751 break;
148752 case 284: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
148753 {
148754 yymsp[-7].minor.yy449 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy449, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy420, yymsp[-1].minor.yy489);
148755 }
148756 break;
148757 case 285: /* windowdefn_list ::= windowdefn */
148758 { yylhsminor.yy327 = yymsp[0].minor.yy327; }
148759 yymsp[0].minor.yy327 = yylhsminor.yy327;
148760 break;
148761 case 286: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
148762 {
148763 assert( yymsp[0].minor.yy327!=0 );
148764 yymsp[0].minor.yy327->pNextWin = yymsp[-2].minor.yy327;
148765 yylhsminor.yy327 = yymsp[0].minor.yy327;
148766 }
148767 yymsp[-2].minor.yy327 = yylhsminor.yy327;
148768 break;
148769 case 287: /* windowdefn ::= nm AS window */
148770 {
148771 if( ALWAYS(yymsp[0].minor.yy327) ){
148772 yymsp[0].minor.yy327->zName = sqlite3DbStrNDup(pParse->db, yymsp[-2].minor.yy0.z, yymsp[-2].minor.yy0.n);
148773 }
148774 yylhsminor.yy327 = yymsp[0].minor.yy327;
148775 }
148776 yymsp[-2].minor.yy327 = yylhsminor.yy327;
148777 break;
148778 case 288: /* window ::= LP part_opt orderby_opt frame_opt RP */
148779 {
148780 yymsp[-4].minor.yy327 = yymsp[-1].minor.yy327;
148781 if( ALWAYS(yymsp[-4].minor.yy327) ){
148782 yymsp[-4].minor.yy327->pPartition = yymsp[-3].minor.yy420;
148783 yymsp[-4].minor.yy327->pOrderBy = yymsp[-2].minor.yy420;
148784 }
148785 }
148786 break;
148787 case 289: /* part_opt ::= PARTITION BY nexprlist */
148788 { yymsp[-2].minor.yy420 = yymsp[0].minor.yy420; }
148789 break;
148790 case 290: /* part_opt ::= */
148791 { yymsp[1].minor.yy420 = 0; }
148792 break;
148793 case 291: /* frame_opt ::= */
148794 {
148795 yymsp[1].minor.yy327 = sqlite3WindowAlloc(pParse, TK_RANGE, TK_UNBOUNDED, 0, TK_CURRENT, 0);
148796 }
148797 break;
148798 case 292: /* frame_opt ::= range_or_rows frame_bound_s */
148799 {
148800 yylhsminor.yy327 = sqlite3WindowAlloc(pParse, yymsp[-1].minor.yy70, yymsp[0].minor.yy119.eType, yymsp[0].minor.yy119.pExpr, TK_CURRENT, 0);
148801 }
148802 yymsp[-1].minor.yy327 = yylhsminor.yy327;
148803 break;
148804 case 293: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
148805 {
148806 yylhsminor.yy327 = sqlite3WindowAlloc(pParse, yymsp[-4].minor.yy70, yymsp[-2].minor.yy119.eType, yymsp[-2].minor.yy119.pExpr, yymsp[0].minor.yy119.eType, yymsp[0].minor.yy119.pExpr);
148807 }
148808 yymsp[-4].minor.yy327 = yylhsminor.yy327;
148809 break;
148810 case 294: /* range_or_rows ::= RANGE */
148811 { yymsp[0].minor.yy70 = TK_RANGE; }
148812 break;
148813 case 295: /* range_or_rows ::= ROWS */
148814 { yymsp[0].minor.yy70 = TK_ROWS; }
148815 break;
148816 case 296: /* frame_bound_s ::= frame_bound */
148817 case 298: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==298);
148818 { yylhsminor.yy119 = yymsp[0].minor.yy119; }
148819 yymsp[0].minor.yy119 = yylhsminor.yy119;
148820 break;
148821 case 297: /* frame_bound_s ::= UNBOUNDED PRECEDING */
148822 case 299: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==299);
148823 {yymsp[-1].minor.yy119.eType = TK_UNBOUNDED; yymsp[-1].minor.yy119.pExpr = 0;}
148824 break;
148825 case 300: /* frame_bound ::= expr PRECEDING */
148826 { yylhsminor.yy119.eType = TK_PRECEDING; yylhsminor.yy119.pExpr = yymsp[-1].minor.yy18; }
148827 yymsp[-1].minor.yy119 = yylhsminor.yy119;
148828 break;
148829 case 301: /* frame_bound ::= CURRENT ROW */
148830 { yymsp[-1].minor.yy119.eType = TK_CURRENT ; yymsp[-1].minor.yy119.pExpr = 0; }
148831 break;
148832 case 302: /* frame_bound ::= expr FOLLOWING */
148833 { yylhsminor.yy119.eType = TK_FOLLOWING; yylhsminor.yy119.pExpr = yymsp[-1].minor.yy18; }
148834 yymsp[-1].minor.yy119 = yylhsminor.yy119;
148835 break;
148836 case 303: /* window_clause ::= WINDOW windowdefn_list */
148837 { yymsp[-1].minor.yy327 = yymsp[0].minor.yy327; }
148838 break;
148839 case 304: /* over_clause ::= filter_opt OVER window */
148840 {
148841 yylhsminor.yy327 = yymsp[0].minor.yy327;
148842 assert( yylhsminor.yy327!=0 );
148843 yylhsminor.yy327->pFilter = yymsp[-2].minor.yy18;
148844 }
148845 yymsp[-2].minor.yy327 = yylhsminor.yy327;
148846 break;
148847 case 305: /* over_clause ::= filter_opt OVER nm */
148848 {
148849 yylhsminor.yy327 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
148850 if( yylhsminor.yy327 ){
148851 yylhsminor.yy327->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
148852 yylhsminor.yy327->pFilter = yymsp[-2].minor.yy18;
@@ -148854,72 +149836,72 @@
148854 sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy18);
148855 }
148856 }
148857 yymsp[-2].minor.yy327 = yylhsminor.yy327;
148858 break;
148859 case 307: /* filter_opt ::= FILTER LP WHERE expr RP */
148860 { yymsp[-4].minor.yy18 = yymsp[-1].minor.yy18; }
148861 break;
148862 default:
148863 /* (308) input ::= cmdlist */ yytestcase(yyruleno==308);
148864 /* (309) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==309);
148865 /* (310) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=310);
148866 /* (311) ecmd ::= SEMI */ yytestcase(yyruleno==311);
148867 /* (312) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==312);
148868 /* (313) ecmd ::= explain cmdx */ yytestcase(yyruleno==313);
148869 /* (314) trans_opt ::= */ yytestcase(yyruleno==314);
148870 /* (315) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==315);
148871 /* (316) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==316);
148872 /* (317) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==317);
148873 /* (318) savepoint_opt ::= */ yytestcase(yyruleno==318);
148874 /* (319) cmd ::= create_table create_table_args */ yytestcase(yyruleno==319);
148875 /* (320) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==320);
148876 /* (321) columnlist ::= columnname carglist */ yytestcase(yyruleno==321);
148877 /* (322) nm ::= ID|INDEXED */ yytestcase(yyruleno==322);
148878 /* (323) nm ::= STRING */ yytestcase(yyruleno==323);
148879 /* (324) nm ::= JOIN_KW */ yytestcase(yyruleno==324);
148880 /* (325) typetoken ::= typename */ yytestcase(yyruleno==325);
148881 /* (326) typename ::= ID|STRING */ yytestcase(yyruleno==326);
148882 /* (327) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=327);
148883 /* (328) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=328);
148884 /* (329) carglist ::= carglist ccons */ yytestcase(yyruleno==329);
148885 /* (330) carglist ::= */ yytestcase(yyruleno==330);
148886 /* (331) ccons ::= NULL onconf */ yytestcase(yyruleno==331);
148887 /* (332) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==332);
148888 /* (333) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==333);
148889 /* (334) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=334);
148890 /* (335) tconscomma ::= */ yytestcase(yyruleno==335);
148891 /* (336) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=336);
148892 /* (337) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=337);
148893 /* (338) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=338);
148894 /* (339) oneselect ::= values */ yytestcase(yyruleno==339);
148895 /* (340) sclp ::= selcollist COMMA */ yytestcase(yyruleno==340);
148896 /* (341) as ::= ID|STRING */ yytestcase(yyruleno==341);
148897 /* (342) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=342);
148898 /* (343) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==343);
148899 /* (344) exprlist ::= nexprlist */ yytestcase(yyruleno==344);
148900 /* (345) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=345);
148901 /* (346) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=346);
148902 /* (347) nmnum ::= ON */ yytestcase(yyruleno==347);
148903 /* (348) nmnum ::= DELETE */ yytestcase(yyruleno==348);
148904 /* (349) nmnum ::= DEFAULT */ yytestcase(yyruleno==349);
148905 /* (350) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==350);
148906 /* (351) foreach_clause ::= */ yytestcase(yyruleno==351);
148907 /* (352) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==352);
148908 /* (353) trnm ::= nm */ yytestcase(yyruleno==353);
148909 /* (354) tridxby ::= */ yytestcase(yyruleno==354);
148910 /* (355) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==355);
148911 /* (356) database_kw_opt ::= */ yytestcase(yyruleno==356);
148912 /* (357) kwcolumn_opt ::= */ yytestcase(yyruleno==357);
148913 /* (358) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==358);
148914 /* (359) vtabarglist ::= vtabarg */ yytestcase(yyruleno==359);
148915 /* (360) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==360);
148916 /* (361) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==361);
148917 /* (362) anylist ::= */ yytestcase(yyruleno==362);
148918 /* (363) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==363);
148919 /* (364) anylist ::= anylist ANY */ yytestcase(yyruleno==364);
148920 /* (365) with ::= */ yytestcase(yyruleno==365);
148921 break;
148922 /********** End reduce actions ************************************************/
148923 };
148924 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
148925 yygoto = yyRuleInfo[yyruleno].lhs;
@@ -149738,14 +150720,12 @@
149738 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, /* Fx */
149739 };
149740 #define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40]))
149741 #endif
149742
149743 /* Make the IdChar function accessible from ctime.c */
149744 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
149745 SQLITE_PRIVATE int sqlite3IsIdChar(u8 c){ return IdChar(c); }
149746 #endif
149747
149748 #ifndef SQLITE_OMIT_WINDOWFUNC
149749 /*
149750 ** Return the id of the next token in string (*pz). Before returning, set
149751 ** (*pz) to point to the byte following the parsed token.
@@ -150244,20 +151224,22 @@
150244 #endif
150245 #ifndef SQLITE_OMIT_VIRTUALTABLE
150246 sqlite3_free(pParse->apVtabLock);
150247 #endif
150248
150249 if( !IN_DECLARE_VTAB ){
150250 /* If the pParse->declareVtab flag is set, do not delete any table
150251 ** structure built up in pParse->pNewTable. The calling code (see vtab.c)
150252 ** will take responsibility for freeing the Table structure.
150253 */
150254 sqlite3DeleteTable(db, pParse->pNewTable);
150255 }
 
 
 
150256
150257 if( pParse->pWithToFree ) sqlite3WithDelete(db, pParse->pWithToFree);
150258 sqlite3DeleteTrigger(db, pParse->pNewTrigger);
150259 sqlite3DbFree(db, pParse->pVList);
150260 while( pParse->pAinc ){
150261 AutoincInfo *p = pParse->pAinc;
150262 pParse->pAinc = p->pNext;
150263 sqlite3DbFreeNN(db, p);
@@ -151990,10 +152972,11 @@
151990 int i, origRc = rc;
151991 for(i=0; i<2 && zName==0; i++, rc &= 0xff){
151992 switch( rc ){
151993 case SQLITE_OK: zName = "SQLITE_OK"; break;
151994 case SQLITE_ERROR: zName = "SQLITE_ERROR"; break;
 
151995 case SQLITE_INTERNAL: zName = "SQLITE_INTERNAL"; break;
151996 case SQLITE_PERM: zName = "SQLITE_PERM"; break;
151997 case SQLITE_ABORT: zName = "SQLITE_ABORT"; break;
151998 case SQLITE_ABORT_ROLLBACK: zName = "SQLITE_ABORT_ROLLBACK"; break;
151999 case SQLITE_BUSY: zName = "SQLITE_BUSY"; break;
@@ -181429,11 +182412,11 @@
181429 s.z++;
181430 while( geopolySkipSpace(&s)=='[' ){
181431 int ii = 0;
181432 char c;
181433 s.z++;
181434 if( s.nVertex<=s.nAlloc ){
181435 GeoCoord *aNew;
181436 s.nAlloc = s.nAlloc*2 + 16;
181437 aNew = sqlite3_realloc64(s.a, s.nAlloc*sizeof(GeoCoord)*2 );
181438 if( aNew==0 ){
181439 rc = SQLITE_NOMEM;
@@ -181511,11 +182494,11 @@
181511 ){
181512 const unsigned char *a = sqlite3_value_blob(pVal);
181513 int nVertex;
181514 nVertex = (a[1]<<16) + (a[2]<<8) + a[3];
181515 if( (a[0]==0 || a[0]==1)
181516 && (nVertex*2*sizeof(GeoCoord) + 4)==nByte
181517 ){
181518 p = sqlite3_malloc64( sizeof(*p) + (nVertex-1)*2*sizeof(GeoCoord) );
181519 if( p==0 ){
181520 if( pRc ) *pRc = SQLITE_NOMEM;
181521 if( pCtx ) sqlite3_result_error_nomem(pCtx);
@@ -182764,11 +183747,11 @@
182764 }
182765 }
182766 }
182767
182768 /* Change the data */
182769 if( rc==SQLITE_OK ){
182770 sqlite3_stmt *pUp = pRtree->pWriteAux;
182771 int jj;
182772 int nChange = 0;
182773 sqlite3_bind_int64(pUp, 1, cell.iRowid);
182774 assert( pRtree->nAux>=1 );
@@ -210980,11 +211963,11 @@
210980 break;
210981
210982 case FTS5_SAVEPOINT:
210983 assert( p->ts.eState==1 );
210984 assert( iSavepoint>=0 );
210985 assert( iSavepoint>p->ts.iSavepoint );
210986 p->ts.iSavepoint = iSavepoint;
210987 break;
210988
210989 case FTS5_RELEASE:
210990 assert( p->ts.eState==1 );
@@ -211905,10 +212888,17 @@
211905 ** fts5CursorFirstSorted() above. */
211906 assert( pRowidEq==0 && pRowidLe==0 && pRowidGe==0 && pRank==0 );
211907 assert( nVal==0 && pMatch==0 && bOrderByRank==0 && bDesc==0 );
211908 assert( pCsr->iLastRowid==LARGEST_INT64 );
211909 assert( pCsr->iFirstRowid==SMALLEST_INT64 );
 
 
 
 
 
 
 
211910 pCsr->ePlan = FTS5_PLAN_SOURCE;
211911 pCsr->pExpr = pTab->pSortCsr->pExpr;
211912 rc = fts5CursorFirst(pTab, pCsr, bDesc);
211913 }else if( pMatch ){
211914 const char *zExpr = (const char*)sqlite3_value_text(apVal[0]);
@@ -213335,11 +214325,11 @@
213335 int nArg, /* Number of args */
213336 sqlite3_value **apUnused /* Function arguments */
213337 ){
213338 assert( nArg==0 );
213339 UNUSED_PARAM2(nArg, apUnused);
213340 sqlite3_result_text(pCtx, "fts5: 2018-08-30 01:52:10 58078c0d2647a194279fa80e032670441b296ffc3acee692901faa5beca460b7", -1, SQLITE_TRANSIENT);
213341 }
213342
213343 static int fts5Init(sqlite3 *db){
213344 static const sqlite3_module fts5Mod = {
213345 /* iVersion */ 2,
@@ -218045,12 +219035,12 @@
218045 }
218046 #endif /* SQLITE_CORE */
218047 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
218048
218049 /************** End of stmt.c ************************************************/
218050 #if __LINE__!=218050
218051 #undef SQLITE_SOURCE_ID
218052 #define SQLITE_SOURCE_ID "2018-08-30 01:52:10 58078c0d2647a194279fa80e032670441b296ffc3acee692901faa5beca4alt2"
218053 #endif
218054 /* Return the source-id for this library */
218055 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
218056 /************************** End of sqlite3.c ******************************/
218057
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1156,11 +1156,11 @@
1156 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1157 ** [sqlite_version()] and [sqlite_source_id()].
1158 */
1159 #define SQLITE_VERSION "3.25.0"
1160 #define SQLITE_VERSION_NUMBER 3025000
1161 #define SQLITE_SOURCE_ID "2018-09-06 18:56:36 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5d3c3"
1162
1163 /*
1164 ** CAPI3REF: Run-Time Library Version Numbers
1165 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1166 **
@@ -1503,10 +1503,11 @@
1503 ** the most recent error can be obtained using
1504 ** [sqlite3_extended_errcode()].
1505 */
1506 #define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
1507 #define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
1508 #define SQLITE_ERROR_SNAPSHOT (SQLITE_ERROR | (3<<8))
1509 #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
1510 #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
1511 #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
1512 #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
1513 #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -10084,15 +10085,15 @@
10085 ** SQLITE_ERROR is returned if either of these conditions is violated, or
10086 ** if schema S does not exist, or if the snapshot object is invalid.
10087 **
10088 ** ^A call to sqlite3_snapshot_open() will fail to open if the specified
10089 ** snapshot has been overwritten by a [checkpoint]. In this case
10090 ** SQLITE_ERROR_SNAPSHOT is returned.
10091 **
10092 ** If there is already a read transaction open when this function is
10093 ** invoked, then the same read transaction remains open (on the same
10094 ** database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_ERROR_SNAPSHOT
10095 ** is returned. If another error code - for example SQLITE_PROTOCOL or an
10096 ** SQLITE_IOERR error code - is returned, then the final state of the
10097 ** read transaction is undefined. If SQLITE_OK is returned, then the
10098 ** read transaction is now open on database snapshot P.
10099 **
@@ -14025,10 +14026,11 @@
14026 typedef struct Module Module;
14027 typedef struct NameContext NameContext;
14028 typedef struct Parse Parse;
14029 typedef struct PreUpdate PreUpdate;
14030 typedef struct PrintfArguments PrintfArguments;
14031 typedef struct RenameToken RenameToken;
14032 typedef struct RowSet RowSet;
14033 typedef struct Savepoint Savepoint;
14034 typedef struct Select Select;
14035 typedef struct SQLiteThread SQLiteThread;
14036 typedef struct SelectDest SelectDest;
@@ -17010,13 +17012,15 @@
17012
17013 /*
17014 ** Each token coming out of the lexer is an instance of
17015 ** this structure. Tokens are also used as part of an expression.
17016 **
17017 ** The memory that "z" points to is owned by other objects. Take care
17018 ** that the owner of the "z" string does not deallocate the string before
17019 ** the Token goes out of scope! Very often, the "z" points to some place
17020 ** in the middle of the Parse.zSql text. But it might also point to a
17021 ** static string.
17022 */
17023 struct Token {
17024 const char *z; /* Text of the token. Not NULL-terminated! */
17025 unsigned int n; /* Number of characters in this token */
17026 };
@@ -17817,12 +17821,14 @@
17821
17822 Token sLastToken; /* The last token parsed */
17823 ynVar nVar; /* Number of '?' variables seen in the SQL so far */
17824 u8 iPkSortOrder; /* ASC or DESC for INTEGER PRIMARY KEY */
17825 u8 explain; /* True if the EXPLAIN flag is found on the query */
17826 #if !(defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_OMIT_ALTERTABLE))
17827 u8 eParseMode; /* PARSE_MODE_XXX constant */
17828 #endif
17829 #ifndef SQLITE_OMIT_VIRTUALTABLE
 
17830 int nVtabLock; /* Number of virtual tables to lock */
17831 #endif
17832 int nHeight; /* Expression tree height of current sub-select */
17833 #ifndef SQLITE_OMIT_EXPLAIN
17834 int addrExplain; /* Address of current OP_Explain opcode */
@@ -17829,10 +17835,11 @@
17835 #endif
17836 VList *pVList; /* Mapping between variable names and numbers */
17837 Vdbe *pReprepare; /* VM being reprepared (sqlite3Reprepare()) */
17838 const char *zTail; /* All SQL text past the last semicolon parsed */
17839 Table *pNewTable; /* A table being constructed by CREATE TABLE */
17840 Index *pNewIndex; /* An index being constructed by CREATE INDEX */
17841 Trigger *pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */
17842 const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */
17843 #ifndef SQLITE_OMIT_VIRTUALTABLE
17844 Token sArg; /* Complete text of a module argument */
17845 Table **apVtabLock; /* Pointer to virtual tables needing locking */
@@ -17839,11 +17846,19 @@
17846 #endif
17847 Table *pZombieTab; /* List of Table objects to delete after code gen */
17848 TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
17849 With *pWith; /* Current WITH clause, or NULL */
17850 With *pWithToFree; /* Free this WITH object at the end of the parse */
17851 #ifndef SQLITE_OMIT_ALTERTABLE
17852 RenameToken *pRename; /* Tokens subject to renaming by ALTER TABLE */
17853 #endif
17854 };
17855
17856 #define PARSE_MODE_NORMAL 0
17857 #define PARSE_MODE_DECLARE_VTAB 1
17858 #define PARSE_MODE_RENAME_COLUMN 2
17859 #define PARSE_MODE_RENAME_TABLE 3
17860
17861 /*
17862 ** Sizes and pointers of various parts of the Parse object.
17863 */
17864 #define PARSE_HDR_SZ offsetof(Parse,aTempReg) /* Recursive part w/o aColCache*/
@@ -17855,11 +17870,23 @@
17870 ** Return true if currently inside an sqlite3_declare_vtab() call.
17871 */
17872 #ifdef SQLITE_OMIT_VIRTUALTABLE
17873 #define IN_DECLARE_VTAB 0
17874 #else
17875 #define IN_DECLARE_VTAB (pParse->eParseMode==PARSE_MODE_DECLARE_VTAB)
17876 #endif
17877
17878 #if defined(SQLITE_OMIT_ALTERTABLE)
17879 #define IN_RENAME_OBJECT 0
17880 #else
17881 #define IN_RENAME_OBJECT (pParse->eParseMode>=PARSE_MODE_RENAME_COLUMN)
17882 #endif
17883
17884 #if defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_OMIT_ALTERTABLE)
17885 #define IN_SPECIAL_PARSE 0
17886 #else
17887 #define IN_SPECIAL_PARSE (pParse->eParseMode!=PARSE_MODE_NORMAL)
17888 #endif
17889
17890 /*
17891 ** An instance of the following structure can be declared on a stack and used
17892 ** to save the Parse.zAuthContext value so that it can be restored later.
@@ -18034,12 +18061,18 @@
18061 typedef struct {
18062 sqlite3 *db; /* The database being initialized */
18063 char **pzErrMsg; /* Error message stored here */
18064 int iDb; /* 0 for main database. 1 for TEMP, 2.. for ATTACHed */
18065 int rc; /* Result code stored here */
18066 u32 mInitFlags; /* Flags controlling error messages */
18067 } InitData;
18068
18069 /*
18070 ** Allowed values for mInitFlags
18071 */
18072 #define INITFLAG_AlterTable 0x0001 /* This is a reparse after ALTER TABLE */
18073
18074 /*
18075 ** Structure containing global configuration data for the SQLite library.
18076 **
18077 ** This structure also contains some state information.
18078 */
@@ -18139,10 +18172,11 @@
18172 struct IdxExprTrans *pIdxTrans; /* Convert idxed expr to column */
18173 ExprList *pGroupBy; /* GROUP BY clause */
18174 Select *pSelect; /* HAVING to WHERE clause ctx */
18175 struct WindowRewrite *pRewrite; /* Window rewrite context */
18176 struct WhereConst *pConst; /* WHERE clause constants */
18177 struct RenameCtx *pRename; /* RENAME COLUMN context */
18178 } u;
18179 };
18180
18181 /* Forward declarations */
18182 SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);
@@ -18338,13 +18372,11 @@
18372 # define sqlite3Isdigit(x) isdigit((unsigned char)(x))
18373 # define sqlite3Isxdigit(x) isxdigit((unsigned char)(x))
18374 # define sqlite3Tolower(x) tolower((unsigned char)(x))
18375 # define sqlite3Isquote(x) ((x)=='"'||(x)=='\''||(x)=='['||(x)=='`')
18376 #endif
 
18377 SQLITE_PRIVATE int sqlite3IsIdChar(u8);
 
18378
18379 /*
18380 ** Internal function prototypes
18381 */
18382 SQLITE_PRIVATE int sqlite3StrICmp(const char*,const char*);
@@ -18505,10 +18537,11 @@
18537 SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);
18538 SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
18539 SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
18540 SQLITE_PRIVATE int sqlite3Init(sqlite3*, char**);
18541 SQLITE_PRIVATE int sqlite3InitCallback(void*, int, char**, char**);
18542 SQLITE_PRIVATE int sqlite3InitOne(sqlite3*, int, char**, u32);
18543 SQLITE_PRIVATE void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);
18544 #ifndef SQLITE_OMIT_VIRTUALTABLE
18545 SQLITE_PRIVATE Module *sqlite3PragmaVtabRegister(sqlite3*,const char *zName);
18546 #endif
18547 SQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3*);
@@ -18575,20 +18608,21 @@
18608 SQLITE_PRIVATE int sqlite3DbMaskAllZero(yDbMask);
18609 #endif
18610 SQLITE_PRIVATE void sqlite3DropTable(Parse*, SrcList*, int, int);
18611 SQLITE_PRIVATE void sqlite3CodeDropTable(Parse*, Table*, int, int);
18612 SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3*, Table*);
18613 SQLITE_PRIVATE void sqlite3FreeIndex(sqlite3*, Index*);
18614 #ifndef SQLITE_OMIT_AUTOINCREMENT
18615 SQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse);
18616 SQLITE_PRIVATE void sqlite3AutoincrementEnd(Parse *pParse);
18617 #else
18618 # define sqlite3AutoincrementBegin(X)
18619 # define sqlite3AutoincrementEnd(X)
18620 #endif
18621 SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*);
18622 SQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);
18623 SQLITE_PRIVATE IdList *sqlite3IdListAppend(Parse*, IdList*, Token*);
18624 SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*);
18625 SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int);
18626 SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*);
18627 SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,
18628 Token*, Select*, Expr*, IdList*);
@@ -18746,16 +18780,16 @@
18780 SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);
18781 void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
18782 SQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);
18783 SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*,
18784 const char*,const char*);
18785 SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(Parse*,Token*, IdList*,
18786 Select*,u8,Upsert*,
18787 const char*,const char*);
18788 SQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(Parse*,Token*,ExprList*, Expr*, u8,
18789 const char*,const char*);
18790 SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(Parse*,Token*, Expr*,
18791 const char*,const char*);
18792 SQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3*, Trigger*);
18793 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
18794 SQLITE_PRIVATE u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);
18795 # define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))
@@ -18919,10 +18953,11 @@
18953 #endif
18954 SQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3*, int, int, int);
18955 SQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*);
18956 SQLITE_PRIVATE void sqlite3AlterFunctions(void);
18957 SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
18958 SQLITE_PRIVATE void sqlite3AlterRenameColumn(Parse*, SrcList*, Token*, Token*);
18959 SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);
18960 SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
18961 SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*, int);
18962 SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr *, int, int);
18963 SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
@@ -18934,10 +18969,13 @@
18969 SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
18970 SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
18971 SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
18972 SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
18973 SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
18974 SQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse*, void*, Token*);
18975 SQLITE_PRIVATE void sqlite3RenameTokenRemap(Parse*, void *pTo, void *pFrom);
18976 SQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse*, Expr*);
18977 SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
18978 SQLITE_PRIVATE char sqlite3AffinityType(const char*, Column*);
18979 SQLITE_PRIVATE void sqlite3Analyze(Parse*, Token*, Token*);
18980 SQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler*, sqlite3_file*);
18981 SQLITE_PRIVATE int sqlite3FindDb(sqlite3*, Token*);
@@ -51028,12 +51066,16 @@
51066 ** containing the state of the Pager object passed as an argument. This
51067 ** is intended to be used within debuggers. For example, as an alternative
51068 ** to "print *pPager" in gdb:
51069 **
51070 ** (gdb) printf "%s", print_pager_state(pPager)
51071 **
51072 ** This routine has external linkage in order to suppress compiler warnings
51073 ** about an unused function. It is enclosed within SQLITE_DEBUG and so does
51074 ** not appear in normal builds.
51075 */
51076 char *print_pager_state(Pager *p){
51077 static char zRet[1024];
51078
51079 sqlite3_snprintf(1024, zRet,
51080 "Filename: %s\n"
51081 "State: %s errCode=%d\n"
@@ -57308,17 +57350,10 @@
57350 **
57351 ** The returned indicate the current (possibly updated) journal-mode.
57352 */
57353 SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){
57354 u8 eOld = pPager->journalMode; /* Prior journalmode */
 
 
 
 
 
 
 
57355
57356 /* The eMode parameter is always valid */
57357 assert( eMode==PAGER_JOURNALMODE_DELETE
57358 || eMode==PAGER_JOURNALMODE_TRUNCATE
57359 || eMode==PAGER_JOURNALMODE_PERSIST
@@ -57997,10 +58032,22 @@
58032 # define WALTRACE(X) if(sqlite3WalTrace) sqlite3DebugPrintf X
58033 #else
58034 # define WALTRACE(X)
58035 #endif
58036
58037 /*
58038 ** WAL mode depends on atomic aligned 32-bit loads and stores in a few
58039 ** places. The following macros try to make this explicit.
58040 */
58041 #if GCC_VESRION>=5004000
58042 # define AtomicLoad(PTR) __atomic_load_n((PTR),__ATOMIC_RELAXED)
58043 # define AtomicStore(PTR,VAL) __atomic_store_n((PTR),(VAL),__ATOMIC_RELAXED)
58044 #else
58045 # define AtomicLoad(PTR) (*(PTR))
58046 # define AtomicStore(PTR,VAL) (*(PTR) = (VAL))
58047 #endif
58048
58049 /*
58050 ** The maximum (and only) versions of the wal and wal-index formats
58051 ** that may be interpreted by this version of SQLite.
58052 **
58053 ** If a client begins recovering a WAL file and finds that (a) the checksum
@@ -60294,11 +60341,11 @@
60341 if( pWal->pSnapshot && pWal->pSnapshot->mxFrame<mxFrame ){
60342 mxFrame = pWal->pSnapshot->mxFrame;
60343 }
60344 #endif
60345 for(i=1; i<WAL_NREADER; i++){
60346 u32 thisMark = AtomicLoad(pInfo->aReadMark+i);
60347 if( mxReadMark<=thisMark && thisMark<=mxFrame ){
60348 assert( thisMark!=READMARK_NOT_USED );
60349 mxReadMark = thisMark;
60350 mxI = i;
60351 }
@@ -60307,11 +60354,11 @@
60354 && (mxReadMark<mxFrame || mxI==0)
60355 ){
60356 for(i=1; i<WAL_NREADER; i++){
60357 rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
60358 if( rc==SQLITE_OK ){
60359 mxReadMark = AtomicStore(pInfo->aReadMark+i,mxFrame);
60360 mxI = i;
60361 walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
60362 break;
60363 }else if( rc!=SQLITE_BUSY ){
60364 return rc;
@@ -60359,13 +60406,13 @@
60406 ** frame pWal->hdr.mxFrame - then the client would incorrectly assume
60407 ** that it can read version A from the database file. However, since
60408 ** we can guarantee that the checkpointer that set nBackfill could not
60409 ** see any pages past pWal->hdr.mxFrame, this problem does not come up.
60410 */
60411 pWal->minFrame = AtomicLoad(&pInfo->nBackfill)+1;
60412 walShmBarrier(pWal);
60413 if( AtomicLoad(pInfo->aReadMark+mxI)!=mxReadMark
60414 || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr))
60415 ){
60416 walUnlockShared(pWal, WAL_READ_LOCK(mxI));
60417 return WAL_RETRY;
60418 }else{
@@ -60522,21 +60569,21 @@
60569
60570 if( rc==SQLITE_OK ){
60571 /* Check that the wal file has not been wrapped. Assuming that it has
60572 ** not, also check that no checkpointer has attempted to checkpoint any
60573 ** frames beyond pSnapshot->mxFrame. If either of these conditions are
60574 ** true, return SQLITE_ERROR_SNAPSHOT. Otherwise, overwrite pWal->hdr
60575 ** with *pSnapshot and set *pChanged as appropriate for opening the
60576 ** snapshot. */
60577 if( !memcmp(pSnapshot->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))
60578 && pSnapshot->mxFrame>=pInfo->nBackfillAttempted
60579 ){
60580 assert( pWal->readLock>0 );
60581 memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr));
60582 *pChanged = bChanged;
60583 }else{
60584 rc = SQLITE_ERROR_SNAPSHOT;
60585 }
60586
60587 /* Release the shared CKPT lock obtained above. */
60588 walUnlockShared(pWal, WAL_CKPT_LOCK);
60589 pWal->minFrame = 1;
@@ -61529,11 +61576,11 @@
61576 if( rc==SQLITE_OK ){
61577 WalIndexHdr *pNew = (WalIndexHdr*)pSnapshot;
61578 if( memcmp(pNew->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))
61579 || pNew->mxFrame<walCkptInfo(pWal)->nBackfillAttempted
61580 ){
61581 rc = SQLITE_ERROR_SNAPSHOT;
61582 walUnlockShared(pWal, WAL_CKPT_LOCK);
61583 }
61584 }
61585 return rc;
61586 }
@@ -77145,11 +77192,10 @@
77192 ** and reset(). Inserts are grouped into a transaction.
77193 */
77194 testcase( p->flags & MEM_Agg );
77195 testcase( p->flags & MEM_Dyn );
77196 testcase( p->xDel==sqlite3VdbeFrameMemDel );
 
77197 if( p->flags&(MEM_Agg|MEM_Dyn) ){
77198 sqlite3VdbeMemRelease(p);
77199 }else if( p->szMalloc ){
77200 sqlite3DbFreeNN(db, p->zMalloc);
77201 p->szMalloc = 0;
@@ -88319,11 +88365,12 @@
88365 }
88366
88367 /* Opcode: ParseSchema P1 * * P4 *
88368 **
88369 ** Read and parse all entries from the SQLITE_MASTER table of database P1
88370 ** that match the WHERE clause P4. If P4 is a NULL pointer, then the
88371 ** entire schema for P1 is reparsed.
88372 **
88373 ** This opcode invokes the parser to create a new virtual machine,
88374 ** then runs the new virtual machine. It is thus a re-entrant opcode.
88375 */
88376 case OP_ParseSchema: {
@@ -88343,11 +88390,21 @@
88390 #endif
88391
88392 iDb = pOp->p1;
88393 assert( iDb>=0 && iDb<db->nDb );
88394 assert( DbHasProperty(db, iDb, DB_SchemaLoaded) );
88395
88396 #ifndef SQLITE_OMIT_ALTERTABLE
88397 if( pOp->p4.z==0 ){
88398 sqlite3SchemaClear(db->aDb[iDb].pSchema);
88399 db->mDbFlags &= ~DBFLAG_SchemaKnownOk;
88400 rc = sqlite3InitOne(db, iDb, &p->zErrMsg, INITFLAG_AlterTable);
88401 db->mDbFlags |= DBFLAG_SchemaChange;
88402 p->expired = 0;
88403 }else
88404 #endif
88405 {
88406 zMaster = MASTER_NAME;
88407 initData.db = db;
88408 initData.iDb = pOp->p1;
88409 initData.pzErrMsg = &p->zErrMsg;
88410 zSql = sqlite3MPrintf(db,
@@ -94301,10 +94358,13 @@
94358 const char *zTabName = pItem->zAlias ? pItem->zAlias : pTab->zName;
94359 assert( zTabName!=0 );
94360 if( sqlite3StrICmp(zTabName, zTab)!=0 ){
94361 continue;
94362 }
94363 if( IN_RENAME_OBJECT && pItem->zAlias ){
94364 sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->pTab);
94365 }
94366 }
94367 if( 0==(cntTab++) ){
94368 pMatch = pItem;
94369 }
94370 for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){
@@ -94386,13 +94446,19 @@
94446 if( iCol<pTab->nCol ){
94447 cnt++;
94448 #ifndef SQLITE_OMIT_UPSERT
94449 if( pExpr->iTable==2 ){
94450 testcase( iCol==(-1) );
94451 if( IN_RENAME_OBJECT ){
94452 pExpr->iColumn = iCol;
94453 pExpr->pTab = pTab;
94454 eNewExprOp = TK_COLUMN;
94455 }else{
94456 pExpr->iTable = pNC->uNC.pUpsert->regData + iCol;
94457 eNewExprOp = TK_REGISTER;
94458 ExprSetProperty(pExpr, EP_Alias);
94459 }
94460 }else
94461 #endif /* SQLITE_OMIT_UPSERT */
94462 {
94463 #ifndef SQLITE_OMIT_TRIGGER
94464 if( iCol<0 ){
@@ -94473,10 +94539,13 @@
94539 }
94540 resolveAlias(pParse, pEList, j, pExpr, "", nSubquery);
94541 cnt = 1;
94542 pMatch = 0;
94543 assert( zTab==0 && zDb==0 );
94544 if( IN_RENAME_OBJECT ){
94545 sqlite3RenameTokenRemap(pParse, 0, (void*)pExpr);
94546 }
94547 goto lookupname_end;
94548 }
94549 }
94550 }
94551
@@ -94700,21 +94769,28 @@
94769 if( pExpr->op==TK_ID ){
94770 zDb = 0;
94771 zTable = 0;
94772 zColumn = pExpr->u.zToken;
94773 }else{
94774 Expr *pLeft = pExpr->pLeft;
94775 notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr);
94776 pRight = pExpr->pRight;
94777 if( pRight->op==TK_ID ){
94778 zDb = 0;
 
 
94779 }else{
94780 assert( pRight->op==TK_DOT );
94781 zDb = pLeft->u.zToken;
94782 pLeft = pRight->pLeft;
94783 pRight = pRight->pRight;
94784 }
94785 zTable = pLeft->u.zToken;
94786 zColumn = pRight->u.zToken;
94787 if( IN_RENAME_OBJECT ){
94788 sqlite3RenameTokenRemap(pParse, (void*)pExpr, (void*)pRight);
94789 }
94790 if( IN_RENAME_OBJECT ){
94791 sqlite3RenameTokenRemap(pParse, (void*)&pExpr->pTab, (void*)pLeft);
94792 }
94793 }
94794 return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);
94795 }
94796
@@ -94794,60 +94870,62 @@
94870 notValid(pParse, pNC, "non-deterministic functions",
94871 NC_IdxExpr|NC_PartIdx);
94872 }
94873 }
94874
94875 if( 0==IN_RENAME_OBJECT ){
94876 #ifndef SQLITE_OMIT_WINDOWFUNC
94877 assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)
94878 || (pDef->xValue==0 && pDef->xInverse==0)
94879 || (pDef->xValue && pDef->xInverse && pDef->xSFunc && pDef->xFinalize)
94880 );
94881 if( pDef && pDef->xValue==0 && pExpr->pWin ){
94882 sqlite3ErrorMsg(pParse,
94883 "%.*s() may not be used as a window function", nId, zId
94884 );
94885 pNC->nErr++;
94886 }else if(
94887 (is_agg && (pNC->ncFlags & NC_AllowAgg)==0)
94888 || (is_agg && (pDef->funcFlags & SQLITE_FUNC_WINDOW) && !pExpr->pWin)
94889 || (is_agg && pExpr->pWin && (pNC->ncFlags & NC_AllowWin)==0)
94890 ){
94891 const char *zType;
94892 if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pExpr->pWin ){
94893 zType = "window";
94894 }else{
94895 zType = "aggregate";
94896 }
94897 sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId);
94898 pNC->nErr++;
94899 is_agg = 0;
94900 }
94901 #else
94902 if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){
94903 sqlite3ErrorMsg(pParse,"misuse of aggregate function %.*s()",nId,zId);
94904 pNC->nErr++;
94905 is_agg = 0;
94906 }
94907 #endif
94908 else if( no_such_func && pParse->db->init.busy==0
94909 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
94910 && pParse->explain==0
94911 #endif
94912 ){
94913 sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
94914 pNC->nErr++;
94915 }else if( wrong_num_args ){
94916 sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
94917 nId, zId);
94918 pNC->nErr++;
94919 }
94920 if( is_agg ){
94921 #ifndef SQLITE_OMIT_WINDOWFUNC
94922 pNC->ncFlags &= ~(pExpr->pWin ? NC_AllowWin : NC_AllowAgg);
94923 #else
94924 pNC->ncFlags &= ~NC_AllowAgg;
94925 #endif
94926 }
94927 }
94928 sqlite3WalkExprList(pWalker, pList);
94929 if( is_agg ){
94930 #ifndef SQLITE_OMIT_WINDOWFUNC
94931 if( pExpr->pWin ){
@@ -97358,10 +97436,13 @@
97436 assert( pList->nExpr>0 );
97437 pItem = &pList->a[pList->nExpr-1];
97438 assert( pItem->zName==0 );
97439 pItem->zName = sqlite3DbStrNDup(pParse->db, pName->z, pName->n);
97440 if( dequote ) sqlite3Dequote(pItem->zName);
97441 if( IN_RENAME_OBJECT ){
97442 sqlite3RenameTokenMap(pParse, (void*)pItem->zName, pName);
97443 }
97444 }
97445 }
97446
97447 /*
97448 ** Set the ExprList.a[].zSpan element of the most recently added item
@@ -101056,356 +101137,10 @@
101137 ** The code in this file only exists if we are not omitting the
101138 ** ALTER TABLE logic from the build.
101139 */
101140 #ifndef SQLITE_OMIT_ALTERTABLE
101141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101142 /*
101143 ** Parameter zName is the name of a table that is about to be altered
101144 ** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN).
101145 ** If the table is a system table, this function leaves an error message
101146 ** in pParse->zErr (system tables may not be altered) and returns non-zero.
@@ -101417,10 +101152,53 @@
101152 sqlite3ErrorMsg(pParse, "table %s may not be altered", zName);
101153 return 1;
101154 }
101155 return 0;
101156 }
101157
101158 /*
101159 ** Generate code to verify that the schemas of database zDb and, if
101160 ** bTemp is not true, database "temp", can still be parsed. This is
101161 ** called at the end of the generation of an ALTER TABLE ... RENAME ...
101162 ** statement to ensure that the operation has not rendered any schema
101163 ** objects unusable.
101164 */
101165 void renameTestSchema(Parse *pParse, const char *zDb, int bTemp){
101166 sqlite3NestedParse(pParse,
101167 "SELECT 1 "
101168 "FROM \"%w\".%s "
101169 "WHERE name NOT LIKE 'sqlite_%%'"
101170 " AND sql NOT LIKE 'create virtual%%'"
101171 " AND sqlite_rename_test(%Q, sql, type, name, %d)=NULL ",
101172 zDb, MASTER_NAME,
101173 zDb, bTemp
101174 );
101175
101176 if( bTemp==0 ){
101177 sqlite3NestedParse(pParse,
101178 "SELECT 1 "
101179 "FROM temp.%s "
101180 "WHERE name NOT LIKE 'sqlite_%%'"
101181 " AND sql NOT LIKE 'create virtual%%'"
101182 " AND sqlite_rename_test(%Q, sql, type, name, 1)=NULL ",
101183 MASTER_NAME, zDb
101184 );
101185 }
101186 }
101187
101188 /*
101189 ** Generate code to reload the schema for database iDb. And, if iDb!=1, for
101190 ** the temp database as well.
101191 */
101192 void renameReloadSchema(Parse *pParse, int iDb){
101193 Vdbe *v = pParse->pVdbe;
101194 if( v ){
101195 sqlite3ChangeCookie(pParse, iDb);
101196 sqlite3VdbeAddParseSchemaOp(pParse->pVdbe, iDb, 0);
101197 if( iDb!=1 ) sqlite3VdbeAddParseSchemaOp(pParse->pVdbe, 1, 0);
101198 }
101199 }
101200
101201 /*
101202 ** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy"
101203 ** command.
101204 */
@@ -101435,13 +101213,10 @@
101213 char *zName = 0; /* NULL-terminated version of pName */
101214 sqlite3 *db = pParse->db; /* Database connection */
101215 int nTabName; /* Number of UTF-8 characters in zTabName */
101216 const char *zTabName; /* Original name of the table */
101217 Vdbe *v;
 
 
 
101218 VTable *pVTab = 0; /* Non-zero if this is a v-tab with an xRename() */
101219 u32 savedDbFlags; /* Saved value of db->mDbFlags */
101220
101221 savedDbFlags = db->mDbFlags;
101222 if( NEVER(db->mallocFailed) ) goto exit_rename_table;
@@ -101510,12 +101285,10 @@
101285 */
101286 v = sqlite3GetVdbe(pParse);
101287 if( v==0 ){
101288 goto exit_rename_table;
101289 }
 
 
101290
101291 /* If this is a virtual table, invoke the xRename() function if
101292 ** one is defined. The xRename() callback will modify the names
101293 ** of any resources used by the v-table implementation (including other
101294 ** SQLite tables) that are identified by the name of the virtual table.
@@ -101531,48 +101304,35 @@
101304
101305 /* figure out how many UTF-8 characters are in zName */
101306 zTabName = pTab->zName;
101307 nTabName = sqlite3Utf8CharLen(zTabName, -1);
101308
101309 /* Rewrite all CREATE TABLE, INDEX, TRIGGER or VIEW statements in
101310 ** the schema to use the new table name. */
101311 sqlite3NestedParse(pParse,
101312 "UPDATE \"%w\".%s SET "
101313 "sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, %d) "
101314 "WHERE (type!='index' OR tbl_name=%Q COLLATE nocase)"
101315 "AND name NOT LIKE 'sqlite_%%'"
101316 , zDb, MASTER_NAME, zDb, zTabName, zName, (iDb==1), zTabName
101317 );
101318
101319 /* Update the tbl_name and name columns of the sqlite_master table
101320 ** as required. */
 
 
 
 
101321 sqlite3NestedParse(pParse,
101322 "UPDATE %Q.%s SET "
 
 
 
 
 
 
 
101323 "tbl_name = %Q, "
101324 "name = CASE "
101325 "WHEN type='table' THEN %Q "
101326 "WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN "
101327 "'sqlite_autoindex_' || %Q || substr(name,%d+18) "
101328 "ELSE name END "
101329 "WHERE tbl_name=%Q COLLATE nocase AND "
101330 "(type='table' OR type='index' OR type='trigger');",
101331 zDb, MASTER_NAME,
101332 zName, zName, zName,
101333 nTabName, zTabName
 
 
101334 );
101335
101336 #ifndef SQLITE_OMIT_AUTOINCREMENT
101337 /* If the sqlite_sequence table exists in this database, then update
101338 ** it with the new table name.
@@ -101582,39 +101342,27 @@
101342 "UPDATE \"%w\".sqlite_sequence set name = %Q WHERE name = %Q",
101343 zDb, zName, pTab->zName);
101344 }
101345 #endif
101346
101347 /* If the table being renamed is not itself part of the temp database,
101348 ** edit view and trigger definitions within the temp database
101349 ** as required. */
101350 if( iDb!=1 ){
 
 
101351 sqlite3NestedParse(pParse,
101352 "UPDATE sqlite_temp_master SET "
101353 "sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, 1), "
101354 "tbl_name = "
101355 "CASE WHEN tbl_name=%Q COLLATE nocase AND "
101356 " sqlite_rename_test(%Q, sql, type, name, 1) "
101357 "THEN %Q ELSE tbl_name END "
101358 "WHERE type IN ('view', 'trigger')"
101359 , zDb, zTabName, zName, zTabName, zDb, zName);
101360 }
101361
101362 renameReloadSchema(pParse, iDb);
101363 renameTestSchema(pParse, zDb, iDb==1);
 
 
 
 
 
 
 
 
 
 
101364
101365 exit_rename_table:
101366 sqlite3SrcListDelete(db, pSrc);
101367 sqlite3DbFree(db, zName);
101368 db->mDbFlags = savedDbFlags;
@@ -101636,16 +101384,15 @@
101384 const char *zTab; /* Table name */
101385 char *zCol; /* Null-terminated column definition */
101386 Column *pCol; /* The new column */
101387 Expr *pDflt; /* Default value for the new column */
101388 sqlite3 *db; /* The database connection; */
101389 Vdbe *v; /* The prepared statement under construction */
101390 int r1; /* Temporary registers */
101391
101392 db = pParse->db;
101393 if( pParse->nErr || db->mallocFailed ) return;
 
101394 pNew = pParse->pNewTable;
101395 assert( pNew );
101396
101397 assert( sqlite3BtreeHoldsAllMutexes(db) );
101398 iDb = sqlite3SchemaToIndex(db, pNew->pSchema);
@@ -101736,21 +101483,24 @@
101483
101484 /* Make sure the schema version is at least 3. But do not upgrade
101485 ** from less than 3 to 4, as that will corrupt any preexisting DESC
101486 ** index.
101487 */
101488 v = sqlite3GetVdbe(pParse);
101489 if( v ){
101490 r1 = sqlite3GetTempReg(pParse);
101491 sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);
101492 sqlite3VdbeUsesBtree(v, iDb);
101493 sqlite3VdbeAddOp2(v, OP_AddImm, r1, -2);
101494 sqlite3VdbeAddOp2(v, OP_IfPos, r1, sqlite3VdbeCurrentAddr(v)+2);
101495 VdbeCoverage(v);
101496 sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3);
101497 sqlite3ReleaseTempReg(pParse, r1);
101498 }
101499
101500 /* Reload the table definition */
101501 renameReloadSchema(pParse, iDb);
101502 }
101503
101504 /*
101505 ** This function is called by the parser after the table-name in
101506 ** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument
@@ -101767,11 +101517,10 @@
101517 ** coding the "ALTER TABLE ... ADD" statement.
101518 */
101519 SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
101520 Table *pNew;
101521 Table *pTab;
 
101522 int iDb;
101523 int i;
101524 int nAlloc;
101525 sqlite3 *db = pParse->db;
101526
@@ -101831,20 +101580,1113 @@
101580 }
101581 pNew->pSchema = db->aDb[iDb].pSchema;
101582 pNew->addColOffset = pTab->addColOffset;
101583 pNew->nTabRef = 1;
101584
 
 
 
 
 
 
101585 exit_begin_add_column:
101586 sqlite3SrcListDelete(db, pSrc);
101587 return;
101588 }
101589
101590 /*
101591 ** Parameter pTab is the subject of an ALTER TABLE ... RENAME COLUMN
101592 ** command. This function checks if the table is a view or virtual
101593 ** table (columns of views or virtual tables may not be renamed). If so,
101594 ** it loads an error message into pParse and returns non-zero.
101595 **
101596 ** Or, if pTab is not a view or virtual table, zero is returned.
101597 */
101598 #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)
101599 static int isRealTable(Parse *pParse, Table *pTab){
101600 const char *zType = 0;
101601 #ifndef SQLITE_OMIT_VIEW
101602 if( pTab->pSelect ){
101603 zType = "view";
101604 }
101605 #endif
101606 #ifndef SQLITE_OMIT_VIRTUALTABLE
101607 if( IsVirtual(pTab) ){
101608 zType = "virtual table";
101609 }
101610 #endif
101611 if( zType ){
101612 sqlite3ErrorMsg(
101613 pParse, "cannot rename columns of %s \"%s\"", zType, pTab->zName
101614 );
101615 return 1;
101616 }
101617 return 0;
101618 }
101619 #else /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */
101620 # define isRealTable(x,y) (0)
101621 #endif
101622
101623 /*
101624 ** Handles the following parser reduction:
101625 **
101626 ** cmd ::= ALTER TABLE pSrc RENAME COLUMN pOld TO pNew
101627 */
101628 SQLITE_PRIVATE void sqlite3AlterRenameColumn(
101629 Parse *pParse, /* Parsing context */
101630 SrcList *pSrc, /* Table being altered. pSrc->nSrc==1 */
101631 Token *pOld, /* Name of column being changed */
101632 Token *pNew /* New column name */
101633 ){
101634 sqlite3 *db = pParse->db; /* Database connection */
101635 Table *pTab; /* Table being updated */
101636 int iCol; /* Index of column being renamed */
101637 char *zOld = 0; /* Old column name */
101638 char *zNew = 0; /* New column name */
101639 const char *zDb; /* Name of schema containing the table */
101640 int iSchema; /* Index of the schema */
101641 int bQuote; /* True to quote the new name */
101642
101643 /* Locate the table to be altered */
101644 pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);
101645 if( !pTab ) goto exit_rename_column;
101646
101647 /* Cannot alter a system table */
101648 if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ) goto exit_rename_column;
101649 if( SQLITE_OK!=isRealTable(pParse, pTab) ) goto exit_rename_column;
101650
101651 /* Which schema holds the table to be altered */
101652 iSchema = sqlite3SchemaToIndex(db, pTab->pSchema);
101653 assert( iSchema>=0 );
101654 zDb = db->aDb[iSchema].zDbSName;
101655
101656 #ifndef SQLITE_OMIT_AUTHORIZATION
101657 /* Invoke the authorization callback. */
101658 if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){
101659 goto exit_rename_column;
101660 }
101661 #endif
101662
101663 /* Make sure the old name really is a column name in the table to be
101664 ** altered. Set iCol to be the index of the column being renamed */
101665 zOld = sqlite3NameFromToken(db, pOld);
101666 if( !zOld ) goto exit_rename_column;
101667 for(iCol=0; iCol<pTab->nCol; iCol++){
101668 if( 0==sqlite3StrICmp(pTab->aCol[iCol].zName, zOld) ) break;
101669 }
101670 if( iCol==pTab->nCol ){
101671 sqlite3ErrorMsg(pParse, "no such column: \"%s\"", zOld);
101672 goto exit_rename_column;
101673 }
101674
101675 /* Do the rename operation using a recursive UPDATE statement that
101676 ** uses the sqlite_rename_column() SQL function to compute the new
101677 ** CREATE statement text for the sqlite_master table.
101678 */
101679 zNew = sqlite3NameFromToken(db, pNew);
101680 if( !zNew ) goto exit_rename_column;
101681 assert( pNew->n>0 );
101682 bQuote = sqlite3Isquote(pNew->z[0]);
101683 sqlite3NestedParse(pParse,
101684 "UPDATE \"%w\".%s SET "
101685 "sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, %d) "
101686 "WHERE name NOT LIKE 'sqlite_%%' AND (type != 'index' OR tbl_name = %Q)"
101687 " AND sql NOT LIKE 'create virtual%%'",
101688 zDb, MASTER_NAME,
101689 zDb, pTab->zName, iCol, zNew, bQuote, iSchema==1,
101690 pTab->zName
101691 );
101692
101693 sqlite3NestedParse(pParse,
101694 "UPDATE temp.%s SET "
101695 "sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, 1) "
101696 "WHERE type IN ('trigger', 'view')",
101697 MASTER_NAME,
101698 zDb, pTab->zName, iCol, zNew, bQuote
101699 );
101700
101701 /* Drop and reload the database schema. */
101702 renameReloadSchema(pParse, iSchema);
101703 renameTestSchema(pParse, zDb, iSchema==1);
101704
101705 exit_rename_column:
101706 sqlite3SrcListDelete(db, pSrc);
101707 sqlite3DbFree(db, zOld);
101708 sqlite3DbFree(db, zNew);
101709 return;
101710 }
101711
101712 /*
101713 ** Each RenameToken object maps an element of the parse tree into
101714 ** the token that generated that element. The parse tree element
101715 ** might be one of:
101716 **
101717 ** * A pointer to an Expr that represents an ID
101718 ** * The name of a table column in Column.zName
101719 **
101720 ** A list of RenameToken objects can be constructed during parsing.
101721 ** Each new object is created by sqlite3RenameTokenMap().
101722 ** As the parse tree is transformed, the sqlite3RenameTokenRemap()
101723 ** routine is used to keep the mapping current.
101724 **
101725 ** After the parse finishes, renameTokenFind() routine can be used
101726 ** to look up the actual token value that created some element in
101727 ** the parse tree.
101728 */
101729 struct RenameToken {
101730 void *p; /* Parse tree element created by token t */
101731 Token t; /* The token that created parse tree element p */
101732 RenameToken *pNext; /* Next is a list of all RenameToken objects */
101733 };
101734
101735 /*
101736 ** The context of an ALTER TABLE RENAME COLUMN operation that gets passed
101737 ** down into the Walker.
101738 */
101739 typedef struct RenameCtx RenameCtx;
101740 struct RenameCtx {
101741 RenameToken *pList; /* List of tokens to overwrite */
101742 int nList; /* Number of tokens in pList */
101743 int iCol; /* Index of column being renamed */
101744 Table *pTab; /* Table being ALTERed */
101745 const char *zOld; /* Old column name */
101746 };
101747
101748 #ifdef SQLITE_DEBUG
101749 /*
101750 ** This function is only for debugging. It performs two tasks:
101751 **
101752 ** 1. Checks that pointer pPtr does not already appear in the
101753 ** rename-token list.
101754 **
101755 ** 2. Dereferences each pointer in the rename-token list.
101756 **
101757 ** The second is most effective when debugging under valgrind or
101758 ** address-sanitizer or similar. If any of these pointers no longer
101759 ** point to valid objects, an exception is raised by the memory-checking
101760 ** tool.
101761 **
101762 ** The point of this is to prevent comparisons of invalid pointer values.
101763 ** Even though this always seems to work, it is undefined according to the
101764 ** C standard. Example of undefined comparison:
101765 **
101766 ** sqlite3_free(x);
101767 ** if( x==y ) ...
101768 **
101769 ** Technically, as x no longer points into a valid object or to the byte
101770 ** following a valid object, it may not be used in comparison operations.
101771 */
101772 void renameTokenCheckAll(Parse *pParse, void *pPtr){
101773 if( pParse->nErr==0 && pParse->db->mallocFailed==0 ){
101774 RenameToken *p;
101775 u8 i = 0;
101776 for(p=pParse->pRename; p; p=p->pNext){
101777 if( p->p ){
101778 assert( p->p!=pPtr );
101779 i += *(u8*)(p->p);
101780 }
101781 }
101782 }
101783 }
101784 #else
101785 # define renameTokenCheckAll(x,y)
101786 #endif
101787
101788 /*
101789 ** Add a new RenameToken object mapping parse tree element pPtr into
101790 ** token *pToken to the Parse object currently under construction.
101791 **
101792 ** Return a copy of pPtr.
101793 */
101794 SQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse *pParse, void *pPtr, Token *pToken){
101795 RenameToken *pNew;
101796 assert( pPtr || pParse->db->mallocFailed );
101797 renameTokenCheckAll(pParse, pPtr);
101798 pNew = sqlite3DbMallocZero(pParse->db, sizeof(RenameToken));
101799 if( pNew ){
101800 pNew->p = pPtr;
101801 pNew->t = *pToken;
101802 pNew->pNext = pParse->pRename;
101803 pParse->pRename = pNew;
101804 }
101805
101806 return pPtr;
101807 }
101808
101809 /*
101810 ** It is assumed that there is already a RenameToken object associated
101811 ** with parse tree element pFrom. This function remaps the associated token
101812 ** to parse tree element pTo.
101813 */
101814 SQLITE_PRIVATE void sqlite3RenameTokenRemap(Parse *pParse, void *pTo, void *pFrom){
101815 RenameToken *p;
101816 renameTokenCheckAll(pParse, pTo);
101817 for(p=pParse->pRename; p; p=p->pNext){
101818 if( p->p==pFrom ){
101819 p->p = pTo;
101820 break;
101821 }
101822 }
101823 }
101824
101825 /*
101826 ** Walker callback used by sqlite3RenameExprUnmap().
101827 */
101828 static int renameUnmapExprCb(Walker *pWalker, Expr *pExpr){
101829 Parse *pParse = pWalker->pParse;
101830 sqlite3RenameTokenRemap(pParse, 0, (void*)pExpr);
101831 return WRC_Continue;
101832 }
101833
101834 /*
101835 ** Remove all nodes that are part of expression pExpr from the rename list.
101836 */
101837 SQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse *pParse, Expr *pExpr){
101838 Walker sWalker;
101839 memset(&sWalker, 0, sizeof(Walker));
101840 sWalker.pParse = pParse;
101841 sWalker.xExprCallback = renameUnmapExprCb;
101842 sqlite3WalkExpr(&sWalker, pExpr);
101843 }
101844
101845 /*
101846 ** Free the list of RenameToken objects given in the second argument
101847 */
101848 static void renameTokenFree(sqlite3 *db, RenameToken *pToken){
101849 RenameToken *pNext;
101850 RenameToken *p;
101851 for(p=pToken; p; p=pNext){
101852 pNext = p->pNext;
101853 sqlite3DbFree(db, p);
101854 }
101855 }
101856
101857 /*
101858 ** Search the Parse object passed as the first argument for a RenameToken
101859 ** object associated with parse tree element pPtr. If found, remove it
101860 ** from the Parse object and add it to the list maintained by the
101861 ** RenameCtx object passed as the second argument.
101862 */
101863 static void renameTokenFind(Parse *pParse, struct RenameCtx *pCtx, void *pPtr){
101864 RenameToken **pp;
101865 assert( pPtr!=0 );
101866 for(pp=&pParse->pRename; (*pp); pp=&(*pp)->pNext){
101867 if( (*pp)->p==pPtr ){
101868 RenameToken *pToken = *pp;
101869 *pp = pToken->pNext;
101870 pToken->pNext = pCtx->pList;
101871 pCtx->pList = pToken;
101872 pCtx->nList++;
101873 break;
101874 }
101875 }
101876 }
101877
101878 /*
101879 ** This is a Walker select callback. It does nothing. It is only required
101880 ** because without a dummy callback, sqlite3WalkExpr() and similar do not
101881 ** descend into sub-select statements.
101882 */
101883 static int renameColumnSelectCb(Walker *pWalker, Select *p){
101884 UNUSED_PARAMETER(pWalker);
101885 UNUSED_PARAMETER(p);
101886 return WRC_Continue;
101887 }
101888
101889 /*
101890 ** This is a Walker expression callback.
101891 **
101892 ** For every TK_COLUMN node in the expression tree, search to see
101893 ** if the column being references is the column being renamed by an
101894 ** ALTER TABLE statement. If it is, then attach its associated
101895 ** RenameToken object to the list of RenameToken objects being
101896 ** constructed in RenameCtx object at pWalker->u.pRename.
101897 */
101898 static int renameColumnExprCb(Walker *pWalker, Expr *pExpr){
101899 RenameCtx *p = pWalker->u.pRename;
101900 if( pExpr->op==TK_TRIGGER
101901 && pExpr->iColumn==p->iCol
101902 && pWalker->pParse->pTriggerTab==p->pTab
101903 ){
101904 renameTokenFind(pWalker->pParse, p, (void*)pExpr);
101905 }else if( pExpr->op==TK_COLUMN
101906 && pExpr->iColumn==p->iCol
101907 && p->pTab==pExpr->pTab
101908 ){
101909 renameTokenFind(pWalker->pParse, p, (void*)pExpr);
101910 }
101911 return WRC_Continue;
101912 }
101913
101914 /*
101915 ** The RenameCtx contains a list of tokens that reference a column that
101916 ** is being renamed by an ALTER TABLE statement. Return the "last"
101917 ** RenameToken in the RenameCtx and remove that RenameToken from the
101918 ** RenameContext. "Last" means the last RenameToken encountered when
101919 ** the input SQL is parsed from left to right. Repeated calls to this routine
101920 ** return all column name tokens in the order that they are encountered
101921 ** in the SQL statement.
101922 */
101923 static RenameToken *renameColumnTokenNext(RenameCtx *pCtx){
101924 RenameToken *pBest = pCtx->pList;
101925 RenameToken *pToken;
101926 RenameToken **pp;
101927
101928 for(pToken=pBest->pNext; pToken; pToken=pToken->pNext){
101929 if( pToken->t.z>pBest->t.z ) pBest = pToken;
101930 }
101931 for(pp=&pCtx->pList; *pp!=pBest; pp=&(*pp)->pNext);
101932 *pp = pBest->pNext;
101933
101934 return pBest;
101935 }
101936
101937 /*
101938 ** An error occured while parsing or otherwise processing a database
101939 ** object (either pParse->pNewTable, pNewIndex or pNewTrigger) as part of an
101940 ** ALTER TABLE RENAME COLUMN program. The error message emitted by the
101941 ** sub-routine is currently stored in pParse->zErrMsg. This function
101942 ** adds context to the error message and then stores it in pCtx.
101943 */
101944 static void renameColumnParseError(
101945 sqlite3_context *pCtx,
101946 int bPost,
101947 sqlite3_value *pType,
101948 sqlite3_value *pObject,
101949 Parse *pParse
101950 ){
101951 const char *zT = (const char*)sqlite3_value_text(pType);
101952 const char *zN = (const char*)sqlite3_value_text(pObject);
101953 char *zErr;
101954
101955 zErr = sqlite3_mprintf("error in %s %s%s: %s",
101956 zT, zN, (bPost ? " after rename" : ""),
101957 pParse->zErrMsg
101958 );
101959 sqlite3_result_error(pCtx, zErr, -1);
101960 sqlite3_free(zErr);
101961 }
101962
101963 /*
101964 ** For each name in the the expression-list pEList (i.e. each
101965 ** pEList->a[i].zName) that matches the string in zOld, extract the
101966 ** corresponding rename-token from Parse object pParse and add it
101967 ** to the RenameCtx pCtx.
101968 */
101969 static void renameColumnElistNames(
101970 Parse *pParse,
101971 RenameCtx *pCtx,
101972 ExprList *pEList,
101973 const char *zOld
101974 ){
101975 if( pEList ){
101976 int i;
101977 for(i=0; i<pEList->nExpr; i++){
101978 char *zName = pEList->a[i].zName;
101979 if( 0==sqlite3_stricmp(zName, zOld) ){
101980 renameTokenFind(pParse, pCtx, (void*)zName);
101981 }
101982 }
101983 }
101984 }
101985
101986 /*
101987 ** For each name in the the id-list pIdList (i.e. each pIdList->a[i].zName)
101988 ** that matches the string in zOld, extract the corresponding rename-token
101989 ** from Parse object pParse and add it to the RenameCtx pCtx.
101990 */
101991 static void renameColumnIdlistNames(
101992 Parse *pParse,
101993 RenameCtx *pCtx,
101994 IdList *pIdList,
101995 const char *zOld
101996 ){
101997 if( pIdList ){
101998 int i;
101999 for(i=0; i<pIdList->nId; i++){
102000 char *zName = pIdList->a[i].zName;
102001 if( 0==sqlite3_stricmp(zName, zOld) ){
102002 renameTokenFind(pParse, pCtx, (void*)zName);
102003 }
102004 }
102005 }
102006 }
102007
102008 /*
102009 ** Parse the SQL statement zSql using Parse object (*p). The Parse object
102010 ** is initialized by this function before it is used.
102011 */
102012 static int renameParseSql(
102013 Parse *p, /* Memory to use for Parse object */
102014 const char *zDb, /* Name of schema SQL belongs to */
102015 int bTable, /* 1 -> RENAME TABLE, 0 -> RENAME COLUMN */
102016 sqlite3 *db, /* Database handle */
102017 const char *zSql, /* SQL to parse */
102018 int bTemp /* True if SQL is from temp schema */
102019 ){
102020 int rc;
102021 char *zErr = 0;
102022
102023 db->init.iDb = bTemp ? 1 : sqlite3FindDbName(db, zDb);
102024
102025 /* Parse the SQL statement passed as the first argument. If no error
102026 ** occurs and the parse does not result in a new table, index or
102027 ** trigger object, the database must be corrupt. */
102028 memset(p, 0, sizeof(Parse));
102029 p->eParseMode = (bTable ? PARSE_MODE_RENAME_TABLE : PARSE_MODE_RENAME_COLUMN);
102030 p->db = db;
102031 p->nQueryLoop = 1;
102032 rc = sqlite3RunParser(p, zSql, &zErr);
102033 assert( p->zErrMsg==0 );
102034 assert( rc!=SQLITE_OK || zErr==0 );
102035 assert( (0!=p->pNewTable) + (0!=p->pNewIndex) + (0!=p->pNewTrigger)<2 );
102036 p->zErrMsg = zErr;
102037 if( db->mallocFailed ) rc = SQLITE_NOMEM;
102038 if( rc==SQLITE_OK
102039 && p->pNewTable==0 && p->pNewIndex==0 && p->pNewTrigger==0
102040 ){
102041 rc = SQLITE_CORRUPT_BKPT;
102042 }
102043
102044 #ifdef SQLITE_DEBUG
102045 /* Ensure that all mappings in the Parse.pRename list really do map to
102046 ** a part of the input string. */
102047 if( rc==SQLITE_OK ){
102048 int nSql = sqlite3Strlen30(zSql);
102049 RenameToken *pToken;
102050 for(pToken=p->pRename; pToken; pToken=pToken->pNext){
102051 assert( pToken->t.z>=zSql && &pToken->t.z[pToken->t.n]<=&zSql[nSql] );
102052 }
102053 }
102054 #endif
102055
102056 db->init.iDb = 0;
102057 return rc;
102058 }
102059
102060 /*
102061 ** This function edits SQL statement zSql, replacing each token identified
102062 ** by the linked list pRename with the text of zNew. If argument bQuote is
102063 ** true, then zNew is always quoted first. If no error occurs, the result
102064 ** is loaded into context object pCtx as the result.
102065 **
102066 ** Or, if an error occurs (i.e. an OOM condition), an error is left in
102067 ** pCtx and an SQLite error code returned.
102068 */
102069 static int renameEditSql(
102070 sqlite3_context *pCtx, /* Return result here */
102071 RenameCtx *pRename, /* Rename context */
102072 const char *zSql, /* SQL statement to edit */
102073 const char *zNew, /* New token text */
102074 int bQuote /* True to always quote token */
102075 ){
102076 int nNew = sqlite3Strlen30(zNew);
102077 int nSql = sqlite3Strlen30(zSql);
102078 sqlite3 *db = sqlite3_context_db_handle(pCtx);
102079 int rc = SQLITE_OK;
102080 char *zQuot;
102081 char *zOut;
102082 int nQuot;
102083
102084 /* Set zQuot to point to a buffer containing a quoted copy of the
102085 ** identifier zNew. If the corresponding identifier in the original
102086 ** ALTER TABLE statement was quoted (bQuote==1), then set zNew to
102087 ** point to zQuot so that all substitutions are made using the
102088 ** quoted version of the new column name. */
102089 zQuot = sqlite3MPrintf(db, "\"%w\"", zNew);
102090 if( zQuot==0 ){
102091 return SQLITE_NOMEM;
102092 }else{
102093 nQuot = sqlite3Strlen30(zQuot);
102094 }
102095 if( bQuote ){
102096 zNew = zQuot;
102097 nNew = nQuot;
102098 }
102099
102100 /* At this point pRename->pList contains a list of RenameToken objects
102101 ** corresponding to all tokens in the input SQL that must be replaced
102102 ** with the new column name. All that remains is to construct and
102103 ** return the edited SQL string. */
102104 assert( nQuot>=nNew );
102105 zOut = sqlite3DbMallocZero(db, nSql + pRename->nList*nQuot + 1);
102106 if( zOut ){
102107 int nOut = nSql;
102108 memcpy(zOut, zSql, nSql);
102109 while( pRename->pList ){
102110 int iOff; /* Offset of token to replace in zOut */
102111 RenameToken *pBest = renameColumnTokenNext(pRename);
102112
102113 u32 nReplace;
102114 const char *zReplace;
102115 if( sqlite3IsIdChar(*pBest->t.z) ){
102116 nReplace = nNew;
102117 zReplace = zNew;
102118 }else{
102119 nReplace = nQuot;
102120 zReplace = zQuot;
102121 }
102122
102123 iOff = pBest->t.z - zSql;
102124 if( pBest->t.n!=nReplace ){
102125 memmove(&zOut[iOff + nReplace], &zOut[iOff + pBest->t.n],
102126 nOut - (iOff + pBest->t.n)
102127 );
102128 nOut += nReplace - pBest->t.n;
102129 zOut[nOut] = '\0';
102130 }
102131 memcpy(&zOut[iOff], zReplace, nReplace);
102132 sqlite3DbFree(db, pBest);
102133 }
102134
102135 sqlite3_result_text(pCtx, zOut, -1, SQLITE_TRANSIENT);
102136 sqlite3DbFree(db, zOut);
102137 }else{
102138 rc = SQLITE_NOMEM;
102139 }
102140
102141 sqlite3_free(zQuot);
102142 return rc;
102143 }
102144
102145 /*
102146 ** Resolve all symbols in the trigger at pParse->pNewTrigger, assuming
102147 ** it was read from the schema of database zDb. Return SQLITE_OK if
102148 ** successful. Otherwise, return an SQLite error code and leave an error
102149 ** message in the Parse object.
102150 */
102151 static int renameResolveTrigger(Parse *pParse, const char *zDb){
102152 sqlite3 *db = pParse->db;
102153 TriggerStep *pStep;
102154 NameContext sNC;
102155 int rc = SQLITE_OK;
102156
102157 memset(&sNC, 0, sizeof(sNC));
102158 sNC.pParse = pParse;
102159 pParse->pTriggerTab = sqlite3FindTable(db, pParse->pNewTrigger->table, zDb);
102160 pParse->eTriggerOp = pParse->pNewTrigger->op;
102161
102162 /* Resolve symbols in WHEN clause */
102163 if( pParse->pNewTrigger->pWhen ){
102164 rc = sqlite3ResolveExprNames(&sNC, pParse->pNewTrigger->pWhen);
102165 }
102166
102167 for(pStep=pParse->pNewTrigger->step_list;
102168 rc==SQLITE_OK && pStep;
102169 pStep=pStep->pNext
102170 ){
102171 if( pStep->pSelect ){
102172 sqlite3SelectPrep(pParse, pStep->pSelect, &sNC);
102173 if( pParse->nErr ) rc = pParse->rc;
102174 }
102175 if( rc==SQLITE_OK && pStep->zTarget ){
102176 Table *pTarget = sqlite3LocateTable(pParse, 0, pStep->zTarget, zDb);
102177 if( pTarget==0 ){
102178 rc = SQLITE_ERROR;
102179 }else{
102180 SrcList sSrc;
102181 memset(&sSrc, 0, sizeof(sSrc));
102182 sSrc.nSrc = 1;
102183 sSrc.a[0].zName = pStep->zTarget;
102184 sSrc.a[0].pTab = pTarget;
102185 sNC.pSrcList = &sSrc;
102186 if( pStep->pWhere ){
102187 rc = sqlite3ResolveExprNames(&sNC, pStep->pWhere);
102188 }
102189 if( rc==SQLITE_OK ){
102190 rc = sqlite3ResolveExprListNames(&sNC, pStep->pExprList);
102191 }
102192 assert( !pStep->pUpsert || (!pStep->pWhere && !pStep->pExprList) );
102193 if( pStep->pUpsert ){
102194 Upsert *pUpsert = pStep->pUpsert;
102195 assert( rc==SQLITE_OK );
102196 pUpsert->pUpsertSrc = &sSrc;
102197 sNC.uNC.pUpsert = pUpsert;
102198 sNC.ncFlags = NC_UUpsert;
102199 rc = sqlite3ResolveExprListNames(&sNC, pUpsert->pUpsertTarget);
102200 if( rc==SQLITE_OK ){
102201 ExprList *pUpsertSet = pUpsert->pUpsertSet;
102202 rc = sqlite3ResolveExprListNames(&sNC, pUpsertSet);
102203 }
102204 if( rc==SQLITE_OK ){
102205 rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertWhere);
102206 }
102207 if( rc==SQLITE_OK ){
102208 rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertTargetWhere);
102209 }
102210 sNC.ncFlags = 0;
102211 }
102212 }
102213 }
102214 }
102215 return rc;
102216 }
102217
102218 /*
102219 ** Invoke sqlite3WalkExpr() or sqlite3WalkSelect() on all Select or Expr
102220 ** objects that are part of the trigger passed as the second argument.
102221 */
102222 static void renameWalkTrigger(Walker *pWalker, Trigger *pTrigger){
102223 TriggerStep *pStep;
102224
102225 /* Find tokens to edit in WHEN clause */
102226 sqlite3WalkExpr(pWalker, pTrigger->pWhen);
102227
102228 /* Find tokens to edit in trigger steps */
102229 for(pStep=pTrigger->step_list; pStep; pStep=pStep->pNext){
102230 sqlite3WalkSelect(pWalker, pStep->pSelect);
102231 sqlite3WalkExpr(pWalker, pStep->pWhere);
102232 sqlite3WalkExprList(pWalker, pStep->pExprList);
102233 if( pStep->pUpsert ){
102234 Upsert *pUpsert = pStep->pUpsert;
102235 sqlite3WalkExprList(pWalker, pUpsert->pUpsertTarget);
102236 sqlite3WalkExprList(pWalker, pUpsert->pUpsertSet);
102237 sqlite3WalkExpr(pWalker, pUpsert->pUpsertWhere);
102238 sqlite3WalkExpr(pWalker, pUpsert->pUpsertTargetWhere);
102239 }
102240 }
102241 }
102242
102243 /*
102244 ** Free the contents of Parse object (*pParse). Do not free the memory
102245 ** occupied by the Parse object itself.
102246 */
102247 static void renameParseCleanup(Parse *pParse){
102248 sqlite3 *db = pParse->db;
102249 if( pParse->pVdbe ){
102250 sqlite3VdbeFinalize(pParse->pVdbe);
102251 }
102252 sqlite3DeleteTable(db, pParse->pNewTable);
102253 if( pParse->pNewIndex ) sqlite3FreeIndex(db, pParse->pNewIndex);
102254 sqlite3DeleteTrigger(db, pParse->pNewTrigger);
102255 sqlite3DbFree(db, pParse->zErrMsg);
102256 renameTokenFree(db, pParse->pRename);
102257 sqlite3ParserReset(pParse);
102258 }
102259
102260 /*
102261 ** SQL function:
102262 **
102263 ** sqlite_rename_column(zSql, iCol, bQuote, zNew, zTable, zOld)
102264 **
102265 ** 0. zSql: SQL statement to rewrite
102266 ** 1. type: Type of object ("table", "view" etc.)
102267 ** 2. object: Name of object
102268 ** 3. Database: Database name (e.g. "main")
102269 ** 4. Table: Table name
102270 ** 5. iCol: Index of column to rename
102271 ** 6. zNew: New column name
102272 ** 7. bQuote: Non-zero if the new column name should be quoted.
102273 ** 8. bTemp: True if zSql comes from temp schema
102274 **
102275 ** Do a column rename operation on the CREATE statement given in zSql.
102276 ** The iCol-th column (left-most is 0) of table zTable is renamed from zCol
102277 ** into zNew. The name should be quoted if bQuote is true.
102278 **
102279 ** This function is used internally by the ALTER TABLE RENAME COLUMN command.
102280 ** Though accessible to application code, it is not intended for use by
102281 ** applications. The existance of this function, and the way it works,
102282 ** is subject to change without notice.
102283 **
102284 ** If any of the parameters are out-of-bounds, then simply return NULL.
102285 ** An out-of-bounds parameter can only occur when the application calls
102286 ** this function directly. The parameters will always be well-formed when
102287 ** this routine is invoked by the bytecode for a legitimate ALTER TABLE
102288 ** statement.
102289 */
102290 static void renameColumnFunc(
102291 sqlite3_context *context,
102292 int NotUsed,
102293 sqlite3_value **argv
102294 ){
102295 sqlite3 *db = sqlite3_context_db_handle(context);
102296 RenameCtx sCtx;
102297 const char *zSql = (const char*)sqlite3_value_text(argv[0]);
102298 const char *zDb = (const char*)sqlite3_value_text(argv[3]);
102299 const char *zTable = (const char*)sqlite3_value_text(argv[4]);
102300 int iCol = sqlite3_value_int(argv[5]);
102301 const char *zNew = (const char*)sqlite3_value_text(argv[6]);
102302 int bQuote = sqlite3_value_int(argv[7]);
102303 int bTemp = sqlite3_value_int(argv[8]);
102304 const char *zOld;
102305 int rc;
102306 Parse sParse;
102307 Walker sWalker;
102308 Index *pIdx;
102309 int i;
102310 Table *pTab;
102311 #ifndef SQLITE_OMIT_AUTHORIZATION
102312 sqlite3_xauth xAuth = db->xAuth;
102313 #endif
102314
102315 UNUSED_PARAMETER(NotUsed);
102316 if( zSql==0 ) return;
102317 if( zTable==0 ) return;
102318 if( zNew==0 ) return;
102319 if( iCol<0 ) return;
102320 sqlite3BtreeEnterAll(db);
102321 pTab = sqlite3FindTable(db, zTable, zDb);
102322 if( pTab==0 || iCol>=pTab->nCol ){
102323 sqlite3BtreeLeaveAll(db);
102324 return;
102325 }
102326 zOld = pTab->aCol[iCol].zName;
102327 memset(&sCtx, 0, sizeof(sCtx));
102328 sCtx.iCol = ((iCol==pTab->iPKey) ? -1 : iCol);
102329
102330 #ifndef SQLITE_OMIT_AUTHORIZATION
102331 db->xAuth = 0;
102332 #endif
102333 rc = renameParseSql(&sParse, zDb, 0, db, zSql, bTemp);
102334
102335 /* Find tokens that need to be replaced. */
102336 memset(&sWalker, 0, sizeof(Walker));
102337 sWalker.pParse = &sParse;
102338 sWalker.xExprCallback = renameColumnExprCb;
102339 sWalker.xSelectCallback = renameColumnSelectCb;
102340 sWalker.u.pRename = &sCtx;
102341
102342 sCtx.pTab = pTab;
102343 if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
102344 if( sParse.pNewTable ){
102345 Select *pSelect = sParse.pNewTable->pSelect;
102346 if( pSelect ){
102347 sParse.rc = SQLITE_OK;
102348 sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, 0);
102349 rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc);
102350 if( rc==SQLITE_OK ){
102351 sqlite3WalkSelect(&sWalker, pSelect);
102352 }
102353 if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
102354 }else{
102355 /* A regular table */
102356 int bFKOnly = sqlite3_stricmp(zTable, sParse.pNewTable->zName);
102357 FKey *pFKey;
102358 assert( sParse.pNewTable->pSelect==0 );
102359 sCtx.pTab = sParse.pNewTable;
102360 if( bFKOnly==0 ){
102361 renameTokenFind(
102362 &sParse, &sCtx, (void*)sParse.pNewTable->aCol[iCol].zName
102363 );
102364 if( sCtx.iCol<0 ){
102365 renameTokenFind(&sParse, &sCtx, (void*)&sParse.pNewTable->iPKey);
102366 }
102367 sqlite3WalkExprList(&sWalker, sParse.pNewTable->pCheck);
102368 for(pIdx=sParse.pNewTable->pIndex; pIdx; pIdx=pIdx->pNext){
102369 sqlite3WalkExprList(&sWalker, pIdx->aColExpr);
102370 }
102371 }
102372
102373 for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){
102374 for(i=0; i<pFKey->nCol; i++){
102375 if( bFKOnly==0 && pFKey->aCol[i].iFrom==iCol ){
102376 renameTokenFind(&sParse, &sCtx, (void*)&pFKey->aCol[i]);
102377 }
102378 if( 0==sqlite3_stricmp(pFKey->zTo, zTable)
102379 && 0==sqlite3_stricmp(pFKey->aCol[i].zCol, zOld)
102380 ){
102381 renameTokenFind(&sParse, &sCtx, (void*)pFKey->aCol[i].zCol);
102382 }
102383 }
102384 }
102385 }
102386 }else if( sParse.pNewIndex ){
102387 sqlite3WalkExprList(&sWalker, sParse.pNewIndex->aColExpr);
102388 sqlite3WalkExpr(&sWalker, sParse.pNewIndex->pPartIdxWhere);
102389 }else{
102390 /* A trigger */
102391 TriggerStep *pStep;
102392 rc = renameResolveTrigger(&sParse, (bTemp ? 0 : zDb));
102393 if( rc!=SQLITE_OK ) goto renameColumnFunc_done;
102394
102395 for(pStep=sParse.pNewTrigger->step_list; pStep; pStep=pStep->pNext){
102396 if( pStep->zTarget ){
102397 Table *pTarget = sqlite3LocateTable(&sParse, 0, pStep->zTarget, zDb);
102398 if( pTarget==pTab ){
102399 if( pStep->pUpsert ){
102400 ExprList *pUpsertSet = pStep->pUpsert->pUpsertSet;
102401 renameColumnElistNames(&sParse, &sCtx, pUpsertSet, zOld);
102402 }
102403 renameColumnIdlistNames(&sParse, &sCtx, pStep->pIdList, zOld);
102404 renameColumnElistNames(&sParse, &sCtx, pStep->pExprList, zOld);
102405 }
102406 }
102407 }
102408
102409
102410 /* Find tokens to edit in UPDATE OF clause */
102411 if( sParse.pTriggerTab==pTab ){
102412 renameColumnIdlistNames(&sParse, &sCtx,sParse.pNewTrigger->pColumns,zOld);
102413 }
102414
102415 /* Find tokens to edit in various expressions and selects */
102416 renameWalkTrigger(&sWalker, sParse.pNewTrigger);
102417 }
102418
102419 assert( rc==SQLITE_OK );
102420 rc = renameEditSql(context, &sCtx, zSql, zNew, bQuote);
102421
102422 renameColumnFunc_done:
102423 if( rc!=SQLITE_OK ){
102424 if( sParse.zErrMsg ){
102425 renameColumnParseError(context, 0, argv[1], argv[2], &sParse);
102426 }else{
102427 sqlite3_result_error_code(context, rc);
102428 }
102429 }
102430
102431 renameParseCleanup(&sParse);
102432 renameTokenFree(db, sCtx.pList);
102433 #ifndef SQLITE_OMIT_AUTHORIZATION
102434 db->xAuth = xAuth;
102435 #endif
102436 sqlite3BtreeLeaveAll(db);
102437 }
102438
102439 /*
102440 ** Walker expression callback used by "RENAME TABLE".
102441 */
102442 static int renameTableExprCb(Walker *pWalker, Expr *pExpr){
102443 RenameCtx *p = pWalker->u.pRename;
102444 if( pExpr->op==TK_COLUMN && p->pTab==pExpr->pTab ){
102445 renameTokenFind(pWalker->pParse, p, (void*)&pExpr->pTab);
102446 }
102447 return WRC_Continue;
102448 }
102449
102450 /*
102451 ** Walker select callback used by "RENAME TABLE".
102452 */
102453 static int renameTableSelectCb(Walker *pWalker, Select *pSelect){
102454 int i;
102455 RenameCtx *p = pWalker->u.pRename;
102456 SrcList *pSrc = pSelect->pSrc;
102457 for(i=0; i<pSrc->nSrc; i++){
102458 struct SrcList_item *pItem = &pSrc->a[i];
102459 if( pItem->pTab==p->pTab ){
102460 renameTokenFind(pWalker->pParse, p, pItem->zName);
102461 }
102462 }
102463
102464 return WRC_Continue;
102465 }
102466
102467
102468 /*
102469 ** This C function implements an SQL user function that is used by SQL code
102470 ** generated by the ALTER TABLE ... RENAME command to modify the definition
102471 ** of any foreign key constraints that use the table being renamed as the
102472 ** parent table. It is passed three arguments:
102473 **
102474 ** 0: The database containing the table being renamed.
102475 ** 1. type: Type of object ("table", "view" etc.)
102476 ** 2. object: Name of object
102477 ** 3: The complete text of the schema statement being modified,
102478 ** 4: The old name of the table being renamed, and
102479 ** 5: The new name of the table being renamed.
102480 ** 6: True if the schema statement comes from the temp db.
102481 **
102482 ** It returns the new schema statement. For example:
102483 **
102484 ** sqlite_rename_table('main', 'CREATE TABLE t1(a REFERENCES t2)','t2','t3',0)
102485 ** -> 'CREATE TABLE t1(a REFERENCES t3)'
102486 */
102487 static void renameTableFunc(
102488 sqlite3_context *context,
102489 int NotUsed,
102490 sqlite3_value **argv
102491 ){
102492 sqlite3 *db = sqlite3_context_db_handle(context);
102493 const char *zDb = (const char*)sqlite3_value_text(argv[0]);
102494 const char *zInput = (const char*)sqlite3_value_text(argv[3]);
102495 const char *zOld = (const char*)sqlite3_value_text(argv[4]);
102496 const char *zNew = (const char*)sqlite3_value_text(argv[5]);
102497 int bTemp = sqlite3_value_int(argv[6]);
102498 UNUSED_PARAMETER(NotUsed);
102499
102500 if( zInput && zOld && zNew ){
102501 Parse sParse;
102502 int rc;
102503 int bQuote = 1;
102504 RenameCtx sCtx;
102505 Walker sWalker;
102506
102507 #ifndef SQLITE_OMIT_AUTHORIZATION
102508 sqlite3_xauth xAuth = db->xAuth;
102509 db->xAuth = 0;
102510 #endif
102511
102512 sqlite3BtreeEnterAll(db);
102513
102514 memset(&sCtx, 0, sizeof(RenameCtx));
102515 sCtx.pTab = sqlite3FindTable(db, zOld, zDb);
102516 memset(&sWalker, 0, sizeof(Walker));
102517 sWalker.pParse = &sParse;
102518 sWalker.xExprCallback = renameTableExprCb;
102519 sWalker.xSelectCallback = renameTableSelectCb;
102520 sWalker.u.pRename = &sCtx;
102521
102522 rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp);
102523
102524 if( rc==SQLITE_OK ){
102525 if( sParse.pNewTable ){
102526 Table *pTab = sParse.pNewTable;
102527
102528 if( pTab->pSelect ){
102529 NameContext sNC;
102530 memset(&sNC, 0, sizeof(sNC));
102531 sNC.pParse = &sParse;
102532
102533 sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC);
102534 if( sParse.nErr ) rc = sParse.rc;
102535 sqlite3WalkSelect(&sWalker, pTab->pSelect);
102536 }else{
102537 /* Modify any FK definitions to point to the new table. */
102538 #ifndef SQLITE_OMIT_FOREIGN_KEY
102539 FKey *pFKey;
102540 for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
102541 if( sqlite3_stricmp(pFKey->zTo, zOld)==0 ){
102542 renameTokenFind(&sParse, &sCtx, (void*)pFKey->zTo);
102543 }
102544 }
102545 #endif
102546
102547 /* If this is the table being altered, fix any table refs in CHECK
102548 ** expressions. Also update the name that appears right after the
102549 ** "CREATE [VIRTUAL] TABLE" bit. */
102550 if( sqlite3_stricmp(zOld, pTab->zName)==0 ){
102551 sCtx.pTab = pTab;
102552 sqlite3WalkExprList(&sWalker, pTab->pCheck);
102553 renameTokenFind(&sParse, &sCtx, pTab->zName);
102554 }
102555 }
102556 }
102557
102558 else if( sParse.pNewIndex ){
102559 renameTokenFind(&sParse, &sCtx, sParse.pNewIndex->zName);
102560 sqlite3WalkExpr(&sWalker, sParse.pNewIndex->pPartIdxWhere);
102561 }
102562
102563 #ifndef SQLITE_OMIT_TRIGGER
102564 else{
102565 Trigger *pTrigger = sParse.pNewTrigger;
102566 TriggerStep *pStep;
102567 if( 0==sqlite3_stricmp(sParse.pNewTrigger->table, zOld)
102568 && sCtx.pTab->pSchema==pTrigger->pTabSchema
102569 ){
102570 renameTokenFind(&sParse, &sCtx, sParse.pNewTrigger->table);
102571 }
102572
102573 rc = renameResolveTrigger(&sParse, bTemp ? 0 : zDb);
102574 if( rc==SQLITE_OK ){
102575 renameWalkTrigger(&sWalker, pTrigger);
102576 for(pStep=pTrigger->step_list; pStep; pStep=pStep->pNext){
102577 if( pStep->zTarget && 0==sqlite3_stricmp(pStep->zTarget, zOld) ){
102578 renameTokenFind(&sParse, &sCtx, pStep->zTarget);
102579 }
102580 }
102581 }
102582 }
102583 #endif
102584 }
102585
102586 if( rc==SQLITE_OK ){
102587 rc = renameEditSql(context, &sCtx, zInput, zNew, bQuote);
102588 }
102589 if( rc!=SQLITE_OK ){
102590 if( sParse.zErrMsg ){
102591 renameColumnParseError(context, 0, argv[1], argv[2], &sParse);
102592 }else{
102593 sqlite3_result_error_code(context, rc);
102594 }
102595 }
102596
102597 renameParseCleanup(&sParse);
102598 renameTokenFree(db, sCtx.pList);
102599 sqlite3BtreeLeaveAll(db);
102600 #ifndef SQLITE_OMIT_AUTHORIZATION
102601 db->xAuth = xAuth;
102602 #endif
102603 }
102604
102605 return;
102606 }
102607
102608 /*
102609 ** An SQL user function that checks that there are no parse or symbol
102610 ** resolution problems in a CREATE TRIGGER|TABLE|VIEW|INDEX statement.
102611 ** After an ALTER TABLE .. RENAME operation is performed and the schema
102612 ** reloaded, this function is called on each SQL statement in the schema
102613 ** to ensure that it is still usable.
102614 **
102615 ** 0: Database name ("main", "temp" etc.).
102616 ** 1: SQL statement.
102617 ** 2: Object type ("view", "table", "trigger" or "index").
102618 ** 3: Object name.
102619 ** 4: True if object is from temp schema.
102620 **
102621 ** Unless it finds an error, this function normally returns NULL. However, it
102622 ** returns integer value 1 if:
102623 **
102624 ** * the SQL argument creates a trigger, and
102625 ** * the table that the trigger is attached to is in database zDb.
102626 */
102627 static void renameTableTest(
102628 sqlite3_context *context,
102629 int NotUsed,
102630 sqlite3_value **argv
102631 ){
102632 sqlite3 *db = sqlite3_context_db_handle(context);
102633 char const *zDb = (const char*)sqlite3_value_text(argv[0]);
102634 char const *zInput = (const char*)sqlite3_value_text(argv[1]);
102635 int bTemp = sqlite3_value_int(argv[4]);
102636
102637 #ifndef SQLITE_OMIT_AUTHORIZATION
102638 sqlite3_xauth xAuth = db->xAuth;
102639 db->xAuth = 0;
102640 #endif
102641
102642 UNUSED_PARAMETER(NotUsed);
102643 if( zDb && zInput ){
102644 int rc;
102645 Parse sParse;
102646 rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp);
102647 if( rc==SQLITE_OK ){
102648 if( sParse.pNewTable && sParse.pNewTable->pSelect ){
102649 NameContext sNC;
102650 memset(&sNC, 0, sizeof(sNC));
102651 sNC.pParse = &sParse;
102652 sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, &sNC);
102653 if( sParse.nErr ) rc = sParse.rc;
102654 }
102655
102656 else if( sParse.pNewTrigger ){
102657 rc = renameResolveTrigger(&sParse, bTemp ? 0 : zDb);
102658 if( rc==SQLITE_OK ){
102659 int i1 = sqlite3SchemaToIndex(db, sParse.pNewTrigger->pTabSchema);
102660 int i2 = sqlite3FindDbName(db, zDb);
102661 if( i1==i2 ) sqlite3_result_int(context, 1);
102662 }
102663 }
102664 }
102665
102666 if( rc!=SQLITE_OK ){
102667 renameColumnParseError(context, 1, argv[2], argv[3], &sParse);
102668 }
102669 renameParseCleanup(&sParse);
102670 }
102671
102672 #ifndef SQLITE_OMIT_AUTHORIZATION
102673 db->xAuth = xAuth;
102674 #endif
102675 }
102676
102677 /*
102678 ** Register built-in functions used to help implement ALTER TABLE
102679 */
102680 SQLITE_PRIVATE void sqlite3AlterFunctions(void){
102681 static FuncDef aAlterTableFuncs[] = {
102682 FUNCTION(sqlite_rename_column, 9, 0, 0, renameColumnFunc),
102683 FUNCTION(sqlite_rename_table, 7, 0, 0, renameTableFunc),
102684 FUNCTION(sqlite_rename_test, 5, 0, 0, renameTableTest),
102685 };
102686 sqlite3InsertBuiltinFuncs(aAlterTableFuncs, ArraySize(aAlterTableFuncs));
102687 }
102688 #endif /* SQLITE_ALTER_TABLE */
102689
102690 /************** End of alter.c ***********************************************/
102691 /************** Begin file analyze.c *****************************************/
102692 /*
@@ -104622,11 +105464,11 @@
105464 int rc;
105465
105466 /* Don't do any authorization checks if the database is initialising
105467 ** or if the parser is being invoked from within sqlite3_declare_vtab.
105468 */
105469 if( db->init.busy || IN_SPECIAL_PARSE ){
105470 return SQLITE_OK;
105471 }
105472
105473 if( db->xAuth==0 ){
105474 return SQLITE_OK;
@@ -105128,11 +105970,11 @@
105970 }
105971
105972 /*
105973 ** Reclaim the memory used by an index
105974 */
105975 SQLITE_PRIVATE void sqlite3FreeIndex(sqlite3 *db, Index *p){
105976 #ifndef SQLITE_OMIT_ANALYZE
105977 sqlite3DeleteIndexSamples(db, p);
105978 #endif
105979 sqlite3ExprDelete(db, p->pPartIdxWhere);
105980 sqlite3ExprListDelete(db, p->aColExpr);
@@ -105168,11 +106010,11 @@
106010 while( ALWAYS(p) && p->pNext!=pIndex ){ p = p->pNext; }
106011 if( ALWAYS(p && p->pNext==pIndex) ){
106012 p->pNext = pIndex->pNext;
106013 }
106014 }
106015 sqlite3FreeIndex(db, pIndex);
106016 }
106017 db->mDbFlags |= DBFLAG_SchemaChange;
106018 }
106019
106020 /*
@@ -105314,11 +106156,11 @@
106156 &pIndex->pSchema->idxHash, zName, 0
106157 );
106158 assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
106159 assert( pOld==pIndex || pOld==0 );
106160 }
106161 sqlite3FreeIndex(db, pIndex);
106162 }
106163
106164 /* Delete any foreign keys attached to this table. */
106165 sqlite3FkDelete(db, pTable);
106166
@@ -105472,11 +106314,11 @@
106314 if( iDb<0 ){
106315 sqlite3ErrorMsg(pParse, "unknown database %T", pName1);
106316 return -1;
106317 }
106318 }else{
106319 assert( db->init.iDb==0 || db->init.busy || IN_RENAME_OBJECT
106320 || (db->mDbFlags & DBFLAG_Vacuum)!=0);
106321 iDb = db->init.iDb;
106322 *pUnqual = pName1;
106323 }
106324 return iDb;
@@ -105567,10 +106409,13 @@
106409 sqlite3ErrorMsg(pParse, "temporary table name must be unqualified");
106410 return;
106411 }
106412 if( !OMIT_TEMPDB && isTemp ) iDb = 1;
106413 zName = sqlite3NameFromToken(db, pName);
106414 if( IN_RENAME_OBJECT ){
106415 sqlite3RenameTokenMap(pParse, (void*)zName, pName);
106416 }
106417 }
106418 pParse->sNameToken = *pName;
106419 if( zName==0 ) return;
106420 if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
106421 goto begin_table_error;
@@ -105602,11 +106447,11 @@
106447 ** it does. The exception is if the statement being parsed was passed
106448 ** to an sqlite3_declare_vtab() call. In that case only the column names
106449 ** and types will be used, so there is no need to test for namespace
106450 ** collisions.
106451 */
106452 if( !IN_SPECIAL_PARSE ){
106453 char *zDb = db->aDb[iDb].zDbSName;
106454 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
106455 goto begin_table_error;
106456 }
106457 pTable = sqlite3FindTable(db, zName, zDb);
@@ -105761,10 +106606,11 @@
106606 sqlite3ErrorMsg(pParse, "too many columns on %s", p->zName);
106607 return;
106608 }
106609 z = sqlite3DbMallocRaw(db, pName->n + pType->n + 2);
106610 if( z==0 ) return;
106611 if( IN_RENAME_OBJECT ) sqlite3RenameTokenMap(pParse, (void*)z, pName);
106612 memcpy(z, pName->z, pName->n);
106613 z[pName->n] = 0;
106614 sqlite3Dequote(z);
106615 for(i=0; i<p->nCol; i++){
106616 if( sqlite3_stricmp(z, p->aCol[i].zName)==0 ){
@@ -105967,10 +106813,13 @@
106813 x.flags = EP_Skip;
106814 pCol->pDflt = sqlite3ExprDup(db, &x, EXPRDUP_REDUCE);
106815 sqlite3DbFree(db, x.u.zToken);
106816 }
106817 }
106818 if( IN_RENAME_OBJECT ){
106819 sqlite3RenameExprUnmap(pParse, pExpr);
106820 }
106821 sqlite3ExprDelete(db, pExpr);
106822 }
106823
106824 /*
106825 ** Backwards Compatibility Hack:
@@ -106058,10 +106907,13 @@
106907 if( nTerm==1
106908 && pCol
106909 && sqlite3StrICmp(sqlite3ColumnType(pCol,""), "INTEGER")==0
106910 && sortOrder!=SQLITE_SO_DESC
106911 ){
106912 if( IN_RENAME_OBJECT && pList ){
106913 sqlite3RenameTokenRemap(pParse, &pTab->iPKey, pList->a[0].pExpr);
106914 }
106915 pTab->iPKey = iCol;
106916 pTab->keyConf = (u8)onError;
106917 assert( autoInc==0 || autoInc==1 );
106918 pTab->tabFlags |= autoInc*TF_Autoincrement;
106919 if( pList ) pParse->iPkSortOrder = pList->a[0].sortOrder;
@@ -106860,11 +107712,16 @@
107712 /* Make a copy of the entire SELECT statement that defines the view.
107713 ** This will force all the Expr.token.z values to be dynamically
107714 ** allocated rather than point to the input string - which means that
107715 ** they will persist after the current sqlite3_exec() call returns.
107716 */
107717 if( IN_RENAME_OBJECT ){
107718 p->pSelect = pSelect;
107719 pSelect = 0;
107720 }else{
107721 p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
107722 }
107723 p->pCheck = sqlite3ExprListDup(db, pCNames, EXPRDUP_REDUCE);
107724 if( db->mallocFailed ) goto create_view_fail;
107725
107726 /* Locate the end of the CREATE VIEW statement. Make sEnd point to
107727 ** the end.
@@ -107428,10 +108285,13 @@
108285 }
108286 pFKey->pFrom = p;
108287 pFKey->pNextFrom = p->pFKey;
108288 z = (char*)&pFKey->aCol[nCol];
108289 pFKey->zTo = z;
108290 if( IN_RENAME_OBJECT ){
108291 sqlite3RenameTokenMap(pParse, (void*)z, pTo);
108292 }
108293 memcpy(z, pTo->z, pTo->n);
108294 z[pTo->n] = 0;
108295 sqlite3Dequote(z);
108296 z += pTo->n+1;
108297 pFKey->nCol = nCol;
@@ -107450,16 +108310,22 @@
108310 sqlite3ErrorMsg(pParse,
108311 "unknown column \"%s\" in foreign key definition",
108312 pFromCol->a[i].zName);
108313 goto fk_end;
108314 }
108315 if( IN_RENAME_OBJECT ){
108316 sqlite3RenameTokenRemap(pParse, &pFKey->aCol[i], pFromCol->a[i].zName);
108317 }
108318 }
108319 }
108320 if( pToCol ){
108321 for(i=0; i<nCol; i++){
108322 int n = sqlite3Strlen30(pToCol->a[i].zName);
108323 pFKey->aCol[i].zCol = z;
108324 if( IN_RENAME_OBJECT ){
108325 sqlite3RenameTokenRemap(pParse, z, pToCol->a[i].zName);
108326 }
108327 memcpy(z, pToCol->a[i].zName, n);
108328 z[n] = 0;
108329 z += n+1;
108330 }
108331 }
@@ -107788,25 +108654,27 @@
108654 if( zName==0 ) goto exit_create_index;
108655 assert( pName->z!=0 );
108656 if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
108657 goto exit_create_index;
108658 }
108659 if( !IN_RENAME_OBJECT ){
108660 if( !db->init.busy ){
108661 if( sqlite3FindTable(db, zName, 0)!=0 ){
108662 sqlite3ErrorMsg(pParse, "there is already a table named %s", zName);
108663 goto exit_create_index;
108664 }
108665 }
108666 if( sqlite3FindIndex(db, zName, pDb->zDbSName)!=0 ){
108667 if( !ifNotExist ){
108668 sqlite3ErrorMsg(pParse, "index %s already exists", zName);
108669 }else{
108670 assert( !db->init.busy );
108671 sqlite3CodeVerifySchema(pParse, iDb);
108672 }
108673 goto exit_create_index;
108674 }
108675 }
 
 
 
 
 
 
 
 
 
108676 }else{
108677 int n;
108678 Index *pLoop;
108679 for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){}
108680 zName = sqlite3MPrintf(db, "sqlite_autoindex_%s_%d", pTab->zName, n);
@@ -107817,17 +108685,17 @@
108685 /* Automatic index names generated from within sqlite3_declare_vtab()
108686 ** must have names that are distinct from normal automatic index names.
108687 ** The following statement converts "sqlite3_autoindex..." into
108688 ** "sqlite3_butoindex..." in order to make the names distinct.
108689 ** The "vtab_err.test" test demonstrates the need of this statement. */
108690 if( IN_SPECIAL_PARSE ) zName[7]++;
108691 }
108692
108693 /* Check for authorization to create an index.
108694 */
108695 #ifndef SQLITE_OMIT_AUTHORIZATION
108696 if( !IN_RENAME_OBJECT ){
108697 const char *zDb = pDb->zDbSName;
108698 if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iDb), 0, zDb) ){
108699 goto exit_create_index;
108700 }
108701 i = SQLITE_CREATE_INDEX;
@@ -107910,11 +108778,16 @@
108778 **
108779 ** TODO: Issue a warning if two or more columns of the index are identical.
108780 ** TODO: Issue a warning if the table primary key is used as part of the
108781 ** index key.
108782 */
108783 pListItem = pList->a;
108784 if( IN_RENAME_OBJECT ){
108785 pIndex->aColExpr = pList;
108786 pList = 0;
108787 }
108788 for(i=0; i<pIndex->nKeyCol; i++, pListItem++){
108789 Expr *pCExpr; /* The i-th index expression */
108790 int requestedSortOrder; /* ASC or DESC on the i-th expression */
108791 const char *zColl; /* Collation sequence name */
108792
108793 sqlite3StringToId(pListItem->pExpr);
@@ -107926,16 +108799,12 @@
108799 sqlite3ErrorMsg(pParse, "expressions prohibited in PRIMARY KEY and "
108800 "UNIQUE constraints");
108801 goto exit_create_index;
108802 }
108803 if( pIndex->aColExpr==0 ){
108804 pIndex->aColExpr = pList;
108805 pList = 0;
 
 
 
 
108806 }
108807 j = XN_EXPR;
108808 pIndex->aiColumn[i] = XN_EXPR;
108809 pIndex->uniqNotNull = 0;
108810 }else{
@@ -108070,102 +108939,105 @@
108939 goto exit_create_index;
108940 }
108941 }
108942 }
108943
108944 if( !IN_RENAME_OBJECT ){
108945
108946 /* Link the new Index structure to its table and to the other
108947 ** in-memory database structures.
108948 */
108949 assert( pParse->nErr==0 );
108950 if( db->init.busy ){
108951 Index *p;
108952 assert( !IN_SPECIAL_PARSE );
108953 assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
108954 p = sqlite3HashInsert(&pIndex->pSchema->idxHash,
108955 pIndex->zName, pIndex);
108956 if( p ){
108957 assert( p==pIndex ); /* Malloc must have failed */
108958 sqlite3OomFault(db);
108959 goto exit_create_index;
108960 }
108961 db->mDbFlags |= DBFLAG_SchemaChange;
108962 if( pTblName!=0 ){
108963 pIndex->tnum = db->init.newTnum;
108964 }
108965 }
108966
108967 /* If this is the initial CREATE INDEX statement (or CREATE TABLE if the
108968 ** index is an implied index for a UNIQUE or PRIMARY KEY constraint) then
108969 ** emit code to allocate the index rootpage on disk and make an entry for
108970 ** the index in the sqlite_master table and populate the index with
108971 ** content. But, do not do this if we are simply reading the sqlite_master
108972 ** table to parse the schema, or if this index is the PRIMARY KEY index
108973 ** of a WITHOUT ROWID table.
108974 **
108975 ** If pTblName==0 it means this index is generated as an implied PRIMARY KEY
108976 ** or UNIQUE index in a CREATE TABLE statement. Since the table
108977 ** has just been created, it contains no data and the index initialization
108978 ** step can be skipped.
108979 */
108980 else if( HasRowid(pTab) || pTblName!=0 ){
108981 Vdbe *v;
108982 char *zStmt;
108983 int iMem = ++pParse->nMem;
108984
108985 v = sqlite3GetVdbe(pParse);
108986 if( v==0 ) goto exit_create_index;
108987
108988 sqlite3BeginWriteOperation(pParse, 1, iDb);
108989
108990 /* Create the rootpage for the index using CreateIndex. But before
108991 ** doing so, code a Noop instruction and store its address in
108992 ** Index.tnum. This is required in case this index is actually a
108993 ** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In
108994 ** that case the convertToWithoutRowidTable() routine will replace
108995 ** the Noop with a Goto to jump over the VDBE code generated below. */
108996 pIndex->tnum = sqlite3VdbeAddOp0(v, OP_Noop);
108997 sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, iMem, BTREE_BLOBKEY);
108998
108999 /* Gather the complete text of the CREATE INDEX statement into
109000 ** the zStmt variable
109001 */
109002 if( pStart ){
109003 int n = (int)(pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;
109004 if( pName->z[n-1]==';' ) n--;
109005 /* A named index with an explicit CREATE INDEX statement */
109006 zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
109007 onError==OE_None ? "" : " UNIQUE", n, pName->z);
109008 }else{
109009 /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
109010 /* zStmt = sqlite3MPrintf(""); */
109011 zStmt = 0;
109012 }
109013
109014 /* Add an entry in sqlite_master for this index
109015 */
109016 sqlite3NestedParse(pParse,
109017 "INSERT INTO %Q.%s VALUES('index',%Q,%Q,#%d,%Q);",
109018 db->aDb[iDb].zDbSName, MASTER_NAME,
109019 pIndex->zName,
109020 pTab->zName,
109021 iMem,
109022 zStmt
109023 );
109024 sqlite3DbFree(db, zStmt);
109025
109026 /* Fill the index with data and reparse the schema. Code an OP_Expire
109027 ** to invalidate all pre-compiled statements.
109028 */
109029 if( pTblName ){
109030 sqlite3RefillIndex(pParse, pIndex, iMem);
109031 sqlite3ChangeCookie(pParse, iDb);
109032 sqlite3VdbeAddParseSchemaOp(v, iDb,
109033 sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName));
109034 sqlite3VdbeAddOp2(v, OP_Expire, 0, 1);
109035 }
109036
109037 sqlite3VdbeJumpHere(v, pIndex->tnum);
109038 }
109039 }
109040
109041 /* When adding an index to the list of indices for a table, make
109042 ** sure all indices labeled OE_Replace come after all those labeled
109043 ** OE_Ignore. This is necessary for the correct constraint check
@@ -108185,14 +109057,19 @@
109057 pIndex->pNext = pOther->pNext;
109058 pOther->pNext = pIndex;
109059 }
109060 pIndex = 0;
109061 }
109062 else if( IN_RENAME_OBJECT ){
109063 assert( pParse->pNewIndex==0 );
109064 pParse->pNewIndex = pIndex;
109065 pIndex = 0;
109066 }
109067
109068 /* Clean up before exiting */
109069 exit_create_index:
109070 if( pIndex ) sqlite3FreeIndex(db, pIndex);
109071 sqlite3ExprDelete(db, pPIWhere);
109072 sqlite3ExprListDelete(db, pList);
109073 sqlite3SrcListDelete(db, pTblName);
109074 sqlite3DbFree(db, zName);
109075 }
@@ -108357,11 +109234,12 @@
109234 ** Append a new element to the given IdList. Create a new IdList if
109235 ** need be.
109236 **
109237 ** A new IdList is returned, or NULL if malloc() fails.
109238 */
109239 SQLITE_PRIVATE IdList *sqlite3IdListAppend(Parse *pParse, IdList *pList, Token *pToken){
109240 sqlite3 *db = pParse->db;
109241 int i;
109242 if( pList==0 ){
109243 pList = sqlite3DbMallocZero(db, sizeof(IdList) );
109244 if( pList==0 ) return 0;
109245 }
@@ -108375,10 +109253,13 @@
109253 if( i<0 ){
109254 sqlite3IdListDelete(db, pList);
109255 return 0;
109256 }
109257 pList->a[i].zName = sqlite3NameFromToken(db, pToken);
109258 if( IN_RENAME_OBJECT && pList->a[i].zName ){
109259 sqlite3RenameTokenMap(pParse, (void*)pList->a[i].zName, pToken);
109260 }
109261 return pList;
109262 }
109263
109264 /*
109265 ** Delete an IdList.
@@ -108621,10 +109502,14 @@
109502 if( p==0 ){
109503 goto append_from_error;
109504 }
109505 assert( p->nSrc>0 );
109506 pItem = &p->a[p->nSrc-1];
109507 if( IN_RENAME_OBJECT && pItem->zName ){
109508 Token *pToken = (pDatabase && pDatabase->z) ? pDatabase : pTable;
109509 sqlite3RenameTokenMap(pParse, pItem->zName, pToken);
109510 }
109511 assert( pAlias!=0 );
109512 if( pAlias->n ){
109513 pItem->zAlias = sqlite3NameFromToken(db, pAlias);
109514 }
109515 pItem->pSelect = pSubquery;
@@ -121271,19 +122156,27 @@
122156 InitData *pData, /* Initialization context */
122157 const char *zObj, /* Object being parsed at the point of error */
122158 const char *zExtra /* Error information */
122159 ){
122160 sqlite3 *db = pData->db;
122161 if( db->mallocFailed ){
122162 pData->rc = SQLITE_NOMEM_BKPT;
122163 }else if( pData->pzErrMsg[0]!=0 ){
122164 /* A error message has already been generated. Do not overwrite it */
122165 }else if( pData->mInitFlags & INITFLAG_AlterTable ){
122166 *pData->pzErrMsg = sqlite3DbStrDup(db, zExtra);
122167 pData->rc = SQLITE_ERROR;
122168 }else if( db->flags & SQLITE_WriteSchema ){
122169 pData->rc = SQLITE_CORRUPT_BKPT;
122170 }else{
122171 char *z;
122172 if( zObj==0 ) zObj = "?";
122173 z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj);
122174 if( zExtra && zExtra[0] ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra);
 
122175 *pData->pzErrMsg = z;
122176 pData->rc = SQLITE_CORRUPT_BKPT;
122177 }
 
122178 }
122179
122180 /*
122181 ** This is the callback routine for the code that initializes the
122182 ** database. See sqlite3Init() below for additional information.
@@ -121331,11 +122224,11 @@
122224 db->init.orphanTrigger = 0;
122225 TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0);
122226 rc = db->errCode;
122227 assert( (rc&0xFF)==(rcp&0xFF) );
122228 db->init.iDb = saved_iDb;
122229 /* assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 ); */
122230 if( SQLITE_OK!=rc ){
122231 if( db->init.orphanTrigger ){
122232 assert( iDb==1 );
122233 }else{
122234 pData->rc = rc;
@@ -121378,11 +122271,11 @@
122271 ** database file is given by iDb. iDb==0 is used for the main
122272 ** database. iDb==1 should never be used. iDb>=2 is used for
122273 ** auxiliary databases. Return one of the SQLITE_ error codes to
122274 ** indicate success or failure.
122275 */
122276 SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFlags){
122277 int rc;
122278 int i;
122279 #ifndef SQLITE_OMIT_DEPRECATED
122280 int size;
122281 #endif
@@ -121413,10 +122306,11 @@
122306 azArg[3] = 0;
122307 initData.db = db;
122308 initData.iDb = iDb;
122309 initData.rc = SQLITE_OK;
122310 initData.pzErrMsg = pzErrMsg;
122311 initData.mInitFlags = mFlags;
122312 sqlite3InitCallback(&initData, 3, (char **)azArg, 0);
122313 if( initData.rc ){
122314 rc = initData.rc;
122315 goto error_out;
122316 }
@@ -121619,18 +122513,18 @@
122513 assert( db->init.busy==0 );
122514 ENC(db) = SCHEMA_ENC(db);
122515 assert( db->nDb>0 );
122516 /* Do the main schema first */
122517 if( !DbHasProperty(db, 0, DB_SchemaLoaded) ){
122518 rc = sqlite3InitOne(db, 0, pzErrMsg, 0);
122519 if( rc ) return rc;
122520 }
122521 /* All other schemas after the main schema. The "temp" schema must be last */
122522 for(i=db->nDb-1; i>0; i--){
122523 assert( i==1 || sqlite3BtreeHoldsMutex(db->aDb[i].pBt) );
122524 if( !DbHasProperty(db, i, DB_SchemaLoaded) ){
122525 rc = sqlite3InitOne(db, i, pzErrMsg, 0);
122526 if( rc ) return rc;
122527 }
122528 }
122529 if( commit_internal ){
122530 sqlite3CommitInternalChanges(db);
@@ -129136,18 +130030,20 @@
130030 zName = sqlite3NameFromToken(db, pName);
130031 if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
130032 goto trigger_cleanup;
130033 }
130034 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
130035 if( !IN_RENAME_OBJECT ){
130036 if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),zName) ){
130037 if( !noErr ){
130038 sqlite3ErrorMsg(pParse, "trigger %T already exists", pName);
130039 }else{
130040 assert( !db->init.busy );
130041 sqlite3CodeVerifySchema(pParse, iDb);
130042 }
130043 goto trigger_cleanup;
130044 }
130045 }
130046
130047 /* Do not create a trigger on a system table */
130048 if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){
130049 sqlite3ErrorMsg(pParse, "cannot create trigger on system table");
@@ -129167,11 +130063,11 @@
130063 " trigger on table: %S", pTableName, 0);
130064 goto trigger_cleanup;
130065 }
130066
130067 #ifndef SQLITE_OMIT_AUTHORIZATION
130068 if( !IN_RENAME_OBJECT ){
130069 int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);
130070 int code = SQLITE_CREATE_TRIGGER;
130071 const char *zDb = db->aDb[iTabDb].zDbSName;
130072 const char *zDbTrig = isTemp ? db->aDb[1].zDbSName : zDb;
130073 if( iTabDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER;
@@ -129201,12 +130097,19 @@
130097 pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);
130098 pTrigger->pSchema = db->aDb[iDb].pSchema;
130099 pTrigger->pTabSchema = pTab->pSchema;
130100 pTrigger->op = (u8)op;
130101 pTrigger->tr_tm = tr_tm==TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER;
130102 if( IN_RENAME_OBJECT ){
130103 sqlite3RenameTokenRemap(pParse, pTrigger->table, pTableName->a[0].zName);
130104 pTrigger->pWhen = pWhen;
130105 pWhen = 0;
130106 }else{
130107 pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);
130108 }
130109 pTrigger->pColumns = pColumns;
130110 pColumns = 0;
130111 assert( pParse->pNewTrigger==0 );
130112 pParse->pNewTrigger = pTrigger;
130113
130114 trigger_cleanup:
130115 sqlite3DbFree(db, zName);
@@ -129250,10 +130153,18 @@
130153 if( sqlite3FixTriggerStep(&sFix, pTrig->step_list)
130154 || sqlite3FixExpr(&sFix, pTrig->pWhen)
130155 ){
130156 goto triggerfinish_cleanup;
130157 }
130158
130159 #ifndef SQLITE_OMIT_ALTERTABLE
130160 if( IN_RENAME_OBJECT ){
130161 assert( !db->init.busy );
130162 pParse->pNewTrigger = pTrig;
130163 pTrig = 0;
130164 }else
130165 #endif
130166
130167 /* if we are not initializing,
130168 ** build the sqlite_master entry
130169 */
130170 if( !db->init.busy ){
@@ -129292,11 +130203,11 @@
130203 }
130204 }
130205
130206 triggerfinish_cleanup:
130207 sqlite3DeleteTrigger(db, pTrig);
130208 assert( IN_RENAME_OBJECT || !pParse->pNewTrigger );
130209 sqlite3DeleteTriggerStep(db, pStepList);
130210 }
130211
130212 /*
130213 ** Duplicate a range of text from an SQL statement, then convert all
@@ -129339,16 +130250,17 @@
130250 ** holds both the TriggerStep object and the TriggerStep.target.z string.
130251 **
130252 ** If an OOM error occurs, NULL is returned and db->mallocFailed is set.
130253 */
130254 static TriggerStep *triggerStepAllocate(
130255 Parse *pParse, /* Parser context */
130256 u8 op, /* Trigger opcode */
130257 Token *pName, /* The target name */
130258 const char *zStart, /* Start of SQL text */
130259 const char *zEnd /* End of SQL text */
130260 ){
130261 sqlite3 *db = pParse->db;
130262 TriggerStep *pTriggerStep;
130263
130264 pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n + 1);
130265 if( pTriggerStep ){
130266 char *z = (char*)&pTriggerStep[1];
@@ -129355,10 +130267,13 @@
130267 memcpy(z, pName->z, pName->n);
130268 sqlite3Dequote(z);
130269 pTriggerStep->zTarget = z;
130270 pTriggerStep->op = op;
130271 pTriggerStep->zSpan = triggerSpanDup(db, zStart, zEnd);
130272 if( IN_RENAME_OBJECT ){
130273 sqlite3RenameTokenMap(pParse, pTriggerStep->zTarget, pName);
130274 }
130275 }
130276 return pTriggerStep;
130277 }
130278
130279 /*
@@ -129367,26 +130282,32 @@
130282 **
130283 ** The parser calls this routine when it sees an INSERT inside the
130284 ** body of a trigger.
130285 */
130286 SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(
130287 Parse *pParse, /* Parser */
130288 Token *pTableName, /* Name of the table into which we insert */
130289 IdList *pColumn, /* List of columns in pTableName to insert into */
130290 Select *pSelect, /* A SELECT statement that supplies values */
130291 u8 orconf, /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */
130292 Upsert *pUpsert, /* ON CONFLICT clauses for upsert */
130293 const char *zStart, /* Start of SQL text */
130294 const char *zEnd /* End of SQL text */
130295 ){
130296 sqlite3 *db = pParse->db;
130297 TriggerStep *pTriggerStep;
130298
130299 assert(pSelect != 0 || db->mallocFailed);
130300
130301 pTriggerStep = triggerStepAllocate(pParse, TK_INSERT, pTableName,zStart,zEnd);
130302 if( pTriggerStep ){
130303 if( IN_RENAME_OBJECT ){
130304 pTriggerStep->pSelect = pSelect;
130305 pSelect = 0;
130306 }else{
130307 pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
130308 }
130309 pTriggerStep->pIdList = pColumn;
130310 pTriggerStep->pUpsert = pUpsert;
130311 pTriggerStep->orconf = orconf;
130312 }else{
130313 testcase( pColumn );
@@ -129403,24 +130324,32 @@
130324 ** Construct a trigger step that implements an UPDATE statement and return
130325 ** a pointer to that trigger step. The parser calls this routine when it
130326 ** sees an UPDATE statement inside the body of a CREATE TRIGGER.
130327 */
130328 SQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(
130329 Parse *pParse, /* Parser */
130330 Token *pTableName, /* Name of the table to be updated */
130331 ExprList *pEList, /* The SET clause: list of column and new values */
130332 Expr *pWhere, /* The WHERE clause */
130333 u8 orconf, /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */
130334 const char *zStart, /* Start of SQL text */
130335 const char *zEnd /* End of SQL text */
130336 ){
130337 sqlite3 *db = pParse->db;
130338 TriggerStep *pTriggerStep;
130339
130340 pTriggerStep = triggerStepAllocate(pParse, TK_UPDATE, pTableName,zStart,zEnd);
130341 if( pTriggerStep ){
130342 if( IN_RENAME_OBJECT ){
130343 pTriggerStep->pExprList = pEList;
130344 pTriggerStep->pWhere = pWhere;
130345 pEList = 0;
130346 pWhere = 0;
130347 }else{
130348 pTriggerStep->pExprList = sqlite3ExprListDup(db, pEList, EXPRDUP_REDUCE);
130349 pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
130350 }
130351 pTriggerStep->orconf = orconf;
130352 }
130353 sqlite3ExprListDelete(db, pEList);
130354 sqlite3ExprDelete(db, pWhere);
130355 return pTriggerStep;
@@ -129430,21 +130359,27 @@
130359 ** Construct a trigger step that implements a DELETE statement and return
130360 ** a pointer to that trigger step. The parser calls this routine when it
130361 ** sees a DELETE statement inside the body of a CREATE TRIGGER.
130362 */
130363 SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(
130364 Parse *pParse, /* Parser */
130365 Token *pTableName, /* The table from which rows are deleted */
130366 Expr *pWhere, /* The WHERE clause */
130367 const char *zStart, /* Start of SQL text */
130368 const char *zEnd /* End of SQL text */
130369 ){
130370 sqlite3 *db = pParse->db;
130371 TriggerStep *pTriggerStep;
130372
130373 pTriggerStep = triggerStepAllocate(pParse, TK_DELETE, pTableName,zStart,zEnd);
130374 if( pTriggerStep ){
130375 if( IN_RENAME_OBJECT ){
130376 pTriggerStep->pWhere = pWhere;
130377 pWhere = 0;
130378 }else{
130379 pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
130380 }
130381 pTriggerStep->orconf = OE_Default;
130382 }
130383 sqlite3ExprDelete(db, pWhere);
130384 return pTriggerStep;
130385 }
@@ -132438,11 +133373,11 @@
133373 }
133374 pTab = pCtx->pTab;
133375 assert( IsVirtual(pTab) );
133376
133377 memset(&sParse, 0, sizeof(sParse));
133378 sParse.eParseMode = PARSE_MODE_DECLARE_VTAB;
133379 sParse.db = db;
133380 sParse.nQueryLoop = 1;
133381 if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable, &zErr)
133382 && sParse.pNewTable
133383 && !db->mallocFailed
@@ -132479,11 +133414,11 @@
133414 }else{
133415 sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? "%s" : 0), zErr);
133416 sqlite3DbFree(db, zErr);
133417 rc = SQLITE_ERROR;
133418 }
133419 sParse.eParseMode = PARSE_MODE_NORMAL;
133420
133421 if( sParse.pVdbe ){
133422 sqlite3VdbeFinalize(sParse.pVdbe);
133423 }
133424 sqlite3DeleteTable(db, sParse.pNewTable);
@@ -144970,14 +145905,25 @@
145905 ** that created the expression.
145906 */
145907 static Expr *tokenExpr(Parse *pParse, int op, Token t){
145908 Expr *p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr)+t.n+1);
145909 if( p ){
145910 /* memset(p, 0, sizeof(Expr)); */
145911 p->op = (u8)op;
145912 p->affinity = 0;
145913 p->flags = EP_Leaf;
145914 p->iAgg = -1;
145915 p->pLeft = p->pRight = 0;
145916 p->x.pList = 0;
145917 p->pAggInfo = 0;
145918 p->pTab = 0;
145919 p->op2 = 0;
145920 p->iTable = 0;
145921 p->iColumn = 0;
145922 #ifndef SQLITE_OMIT_WINDOWFUNC
145923 p->pWin = 0;
145924 #endif
145925 p->u.zToken = (char*)&p[1];
145926 memcpy(p->u.zToken, t.z, t.n);
145927 p->u.zToken[t.n] = 0;
145928 if( sqlite3Isquote(p->u.zToken[0]) ){
145929 if( p->u.zToken[0]=='"' ) p->flags |= EP_DblQuoted;
@@ -144984,19 +145930,23 @@
145930 sqlite3Dequote(p->u.zToken);
145931 }
145932 #if SQLITE_MAX_EXPR_DEPTH>0
145933 p->nHeight = 1;
145934 #endif
145935 if( IN_RENAME_OBJECT ){
145936 return (Expr*)sqlite3RenameTokenMap(pParse, (void*)p, &t);
145937 }
145938 }
145939 return p;
145940 }
145941
145942
145943 /* A routine to convert a binary TK_IS or TK_ISNOT expression into a
145944 ** unary TK_ISNULL or TK_NOTNULL expression. */
145945 static void binaryToUnaryIfNull(Parse *pParse, Expr *pY, Expr *pA, int op){
145946 sqlite3 *db = pParse->db;
145947 if( pA && pY && pY->op==TK_NULL && !IN_RENAME_OBJECT ){
145948 pA->op = (u8)op;
145949 sqlite3ExprDelete(db, pA->pRight);
145950 pA->pRight = 0;
145951 }
145952 }
@@ -145120,21 +146070,21 @@
146070 #define sqlite3ParserCTX_PDECL ,Parse *pParse
146071 #define sqlite3ParserCTX_PARAM ,pParse
146072 #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
146073 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
146074 #define YYFALLBACK 1
146075 #define YYNSTATE 521
146076 #define YYNRULE 367
146077 #define YYNTOKEN 155
146078 #define YY_MAX_SHIFT 520
146079 #define YY_MIN_SHIFTREDUCE 756
146080 #define YY_MAX_SHIFTREDUCE 1122
146081 #define YY_ERROR_ACTION 1123
146082 #define YY_ACCEPT_ACTION 1124
146083 #define YY_NO_ACTION 1125
146084 #define YY_MIN_REDUCE 1126
146085 #define YY_MAX_REDUCE 1492
146086 /************* End control #defines *******************************************/
146087 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
146088
146089 /* Define the yytestcase() macro to be a no-op if is not already defined
146090 ** otherwise.
@@ -145199,211 +146149,211 @@
146149 ** yy_default[] Default action for each state.
146150 **
146151 *********** Begin parsing tables **********************************************/
146152 #define YY_ACTTAB_COUNT (2009)
146153 static const YYACTIONTYPE yy_action[] = {
146154 /* 0 */ 368, 105, 102, 197, 105, 102, 197, 515, 1124, 1,
146155 /* 10 */ 1, 520, 2, 1128, 515, 1192, 1171, 1456, 275, 370,
146156 /* 20 */ 127, 1389, 1197, 1197, 1192, 1166, 178, 1205, 64, 64,
146157 /* 30 */ 477, 887, 322, 428, 348, 37, 37, 808, 362, 888,
146158 /* 40 */ 509, 509, 509, 112, 113, 103, 1100, 1100, 953, 956,
146159 /* 50 */ 946, 946, 110, 110, 111, 111, 111, 111, 365, 252,
146160 /* 60 */ 252, 515, 252, 252, 497, 515, 309, 515, 459, 515,
146161 /* 70 */ 1079, 491, 512, 478, 6, 512, 809, 134, 498, 228,
146162 /* 80 */ 194, 428, 37, 37, 515, 208, 64, 64, 64, 64,
146163 /* 90 */ 13, 13, 109, 109, 109, 109, 108, 108, 107, 107,
146164 /* 100 */ 107, 106, 401, 258, 381, 13, 13, 398, 397, 428,
146165 /* 110 */ 252, 252, 370, 476, 405, 1104, 1079, 1080, 1081, 386,
146166 /* 120 */ 1106, 390, 497, 512, 497, 1423, 1419, 304, 1105, 307,
146167 /* 130 */ 1256, 496, 370, 499, 16, 16, 112, 113, 103, 1100,
146168 /* 140 */ 1100, 953, 956, 946, 946, 110, 110, 111, 111, 111,
146169 /* 150 */ 111, 262, 1107, 495, 1107, 401, 112, 113, 103, 1100,
146170 /* 160 */ 1100, 953, 956, 946, 946, 110, 110, 111, 111, 111,
146171 /* 170 */ 111, 129, 1425, 343, 1420, 339, 1059, 492, 1057, 263,
146172 /* 180 */ 73, 105, 102, 197, 994, 109, 109, 109, 109, 108,
146173 /* 190 */ 108, 107, 107, 107, 106, 401, 370, 111, 111, 111,
146174 /* 200 */ 111, 104, 492, 89, 1432, 109, 109, 109, 109, 108,
146175 /* 210 */ 108, 107, 107, 107, 106, 401, 111, 111, 111, 111,
146176 /* 220 */ 112, 113, 103, 1100, 1100, 953, 956, 946, 946, 110,
146177 /* 230 */ 110, 111, 111, 111, 111, 109, 109, 109, 109, 108,
146178 /* 240 */ 108, 107, 107, 107, 106, 401, 114, 108, 108, 107,
146179 /* 250 */ 107, 107, 106, 401, 109, 109, 109, 109, 108, 108,
146180 /* 260 */ 107, 107, 107, 106, 401, 152, 399, 399, 399, 109,
146181 /* 270 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 401,
146182 /* 280 */ 178, 493, 1412, 434, 1037, 1486, 1079, 515, 1486, 370,
146183 /* 290 */ 421, 297, 357, 412, 74, 1079, 109, 109, 109, 109,
146184 /* 300 */ 108, 108, 107, 107, 107, 106, 401, 1413, 37, 37,
146185 /* 310 */ 1431, 274, 506, 112, 113, 103, 1100, 1100, 953, 956,
146186 /* 320 */ 946, 946, 110, 110, 111, 111, 111, 111, 1436, 520,
146187 /* 330 */ 2, 1128, 1079, 1080, 1081, 430, 275, 1079, 127, 366,
146188 /* 340 */ 933, 1079, 1080, 1081, 220, 1205, 913, 458, 455, 454,
146189 /* 350 */ 392, 167, 515, 1035, 152, 445, 924, 453, 152, 874,
146190 /* 360 */ 923, 289, 109, 109, 109, 109, 108, 108, 107, 107,
146191 /* 370 */ 107, 106, 401, 13, 13, 261, 853, 252, 252, 227,
146192 /* 380 */ 106, 401, 370, 1079, 1080, 1081, 311, 388, 1079, 296,
146193 /* 390 */ 512, 923, 923, 925, 231, 323, 1255, 1388, 1423, 490,
146194 /* 400 */ 274, 506, 12, 208, 274, 506, 112, 113, 103, 1100,
146195 /* 410 */ 1100, 953, 956, 946, 946, 110, 110, 111, 111, 111,
146196 /* 420 */ 111, 1440, 286, 1128, 288, 1079, 1097, 247, 275, 1098,
146197 /* 430 */ 127, 387, 405, 389, 1079, 1080, 1081, 1205, 159, 238,
146198 /* 440 */ 255, 321, 461, 316, 460, 225, 790, 105, 102, 197,
146199 /* 450 */ 513, 314, 842, 842, 445, 109, 109, 109, 109, 108,
146200 /* 460 */ 108, 107, 107, 107, 106, 401, 515, 514, 515, 252,
146201 /* 470 */ 252, 1079, 1080, 1081, 435, 370, 1098, 933, 1460, 794,
146202 /* 480 */ 274, 506, 512, 105, 102, 197, 336, 63, 63, 64,
146203 /* 490 */ 64, 27, 790, 924, 287, 208, 1354, 923, 515, 112,
146204 /* 500 */ 113, 103, 1100, 1100, 953, 956, 946, 946, 110, 110,
146205 /* 510 */ 111, 111, 111, 111, 107, 107, 107, 106, 401, 49,
146206 /* 520 */ 49, 515, 28, 1079, 405, 497, 421, 297, 923, 923,
146207 /* 530 */ 925, 186, 468, 1079, 467, 999, 999, 442, 515, 1079,
146208 /* 540 */ 334, 515, 45, 45, 1083, 342, 173, 168, 109, 109,
146209 /* 550 */ 109, 109, 108, 108, 107, 107, 107, 106, 401, 13,
146210 /* 560 */ 13, 205, 13, 13, 252, 252, 1195, 1195, 370, 1079,
146211 /* 570 */ 1080, 1081, 787, 265, 5, 359, 494, 512, 469, 1079,
146212 /* 580 */ 1080, 1081, 398, 397, 1079, 1079, 1080, 1081, 3, 282,
146213 /* 590 */ 1079, 1083, 112, 113, 103, 1100, 1100, 953, 956, 946,
146214 /* 600 */ 946, 110, 110, 111, 111, 111, 111, 252, 252, 1015,
146215 /* 610 */ 220, 1079, 873, 458, 455, 454, 943, 943, 954, 957,
146216 /* 620 */ 512, 252, 252, 453, 1016, 1079, 445, 1107, 1209, 1107,
146217 /* 630 */ 1079, 1080, 1081, 515, 512, 426, 1079, 1080, 1081, 1017,
146218 /* 640 */ 512, 109, 109, 109, 109, 108, 108, 107, 107, 107,
146219 /* 650 */ 106, 401, 1052, 515, 50, 50, 515, 1079, 1080, 1081,
146220 /* 660 */ 828, 370, 1051, 379, 411, 1064, 1358, 207, 408, 773,
146221 /* 670 */ 829, 1079, 1080, 1081, 64, 64, 322, 64, 64, 1302,
146222 /* 680 */ 947, 411, 410, 1358, 1360, 112, 113, 103, 1100, 1100,
146223 /* 690 */ 953, 956, 946, 946, 110, 110, 111, 111, 111, 111,
146224 /* 700 */ 294, 482, 515, 1037, 1487, 515, 434, 1487, 354, 1120,
146225 /* 710 */ 483, 996, 913, 485, 466, 996, 132, 178, 33, 450,
146226 /* 720 */ 1203, 136, 406, 64, 64, 479, 64, 64, 419, 369,
146227 /* 730 */ 283, 1146, 252, 252, 109, 109, 109, 109, 108, 108,
146228 /* 740 */ 107, 107, 107, 106, 401, 512, 224, 440, 411, 266,
146229 /* 750 */ 1358, 266, 252, 252, 370, 296, 416, 284, 934, 396,
146230 /* 760 */ 976, 470, 400, 252, 252, 512, 9, 473, 231, 500,
146231 /* 770 */ 354, 1036, 1035, 1488, 355, 374, 512, 1121, 112, 113,
146232 /* 780 */ 103, 1100, 1100, 953, 956, 946, 946, 110, 110, 111,
146233 /* 790 */ 111, 111, 111, 252, 252, 1015, 515, 1347, 295, 252,
146234 /* 800 */ 252, 252, 252, 1098, 375, 249, 512, 445, 872, 322,
146235 /* 810 */ 1016, 480, 512, 195, 512, 434, 273, 15, 15, 515,
146236 /* 820 */ 314, 515, 95, 515, 93, 1017, 367, 109, 109, 109,
146237 /* 830 */ 109, 108, 108, 107, 107, 107, 106, 401, 515, 1121,
146238 /* 840 */ 39, 39, 51, 51, 52, 52, 503, 370, 515, 1204,
146239 /* 850 */ 1098, 918, 439, 341, 133, 436, 223, 222, 221, 53,
146240 /* 860 */ 53, 322, 1400, 761, 762, 763, 515, 370, 88, 54,
146241 /* 870 */ 54, 112, 113, 103, 1100, 1100, 953, 956, 946, 946,
146242 /* 880 */ 110, 110, 111, 111, 111, 111, 407, 55, 55, 196,
146243 /* 890 */ 515, 112, 113, 103, 1100, 1100, 953, 956, 946, 946,
146244 /* 900 */ 110, 110, 111, 111, 111, 111, 135, 264, 1149, 376,
146245 /* 910 */ 515, 40, 40, 515, 872, 515, 993, 515, 993, 116,
146246 /* 920 */ 109, 109, 109, 109, 108, 108, 107, 107, 107, 106,
146247 /* 930 */ 401, 41, 41, 515, 43, 43, 44, 44, 56, 56,
146248 /* 940 */ 109, 109, 109, 109, 108, 108, 107, 107, 107, 106,
146249 /* 950 */ 401, 515, 379, 515, 57, 57, 515, 799, 515, 379,
146250 /* 960 */ 515, 445, 200, 515, 323, 515, 1397, 515, 1459, 515,
146251 /* 970 */ 1287, 817, 58, 58, 14, 14, 515, 59, 59, 118,
146252 /* 980 */ 118, 60, 60, 515, 46, 46, 61, 61, 62, 62,
146253 /* 990 */ 47, 47, 515, 190, 189, 91, 515, 140, 140, 515,
146254 /* 1000 */ 394, 515, 277, 1200, 141, 141, 515, 1115, 515, 992,
146255 /* 1010 */ 515, 992, 515, 69, 69, 370, 278, 48, 48, 259,
146256 /* 1020 */ 65, 65, 119, 119, 246, 246, 260, 66, 66, 120,
146257 /* 1030 */ 120, 121, 121, 117, 117, 370, 515, 512, 383, 112,
146258 /* 1040 */ 113, 103, 1100, 1100, 953, 956, 946, 946, 110, 110,
146259 /* 1050 */ 111, 111, 111, 111, 515, 872, 515, 139, 139, 112,
146260 /* 1060 */ 113, 103, 1100, 1100, 953, 956, 946, 946, 110, 110,
146261 /* 1070 */ 111, 111, 111, 111, 1287, 138, 138, 125, 125, 515,
146262 /* 1080 */ 12, 515, 281, 1287, 515, 445, 131, 1287, 109, 109,
146263 /* 1090 */ 109, 109, 108, 108, 107, 107, 107, 106, 401, 515,
146264 /* 1100 */ 124, 124, 122, 122, 515, 123, 123, 515, 109, 109,
146265 /* 1110 */ 109, 109, 108, 108, 107, 107, 107, 106, 401, 515,
146266 /* 1120 */ 68, 68, 463, 783, 515, 70, 70, 302, 67, 67,
146267 /* 1130 */ 1032, 253, 253, 356, 1287, 191, 196, 1433, 465, 1301,
146268 /* 1140 */ 38, 38, 384, 94, 512, 42, 42, 177, 848, 274,
146269 /* 1150 */ 506, 385, 420, 847, 1356, 441, 508, 376, 377, 153,
146270 /* 1160 */ 423, 872, 432, 370, 224, 251, 194, 887, 182, 293,
146271 /* 1170 */ 783, 848, 88, 254, 466, 888, 847, 915, 807, 806,
146272 /* 1180 */ 230, 1241, 910, 370, 17, 413, 797, 112, 113, 103,
146273 /* 1190 */ 1100, 1100, 953, 956, 946, 946, 110, 110, 111, 111,
146274 /* 1200 */ 111, 111, 395, 814, 815, 1175, 983, 112, 101, 103,
146275 /* 1210 */ 1100, 1100, 953, 956, 946, 946, 110, 110, 111, 111,
146276 /* 1220 */ 111, 111, 375, 422, 427, 429, 298, 230, 230, 88,
146277 /* 1230 */ 1240, 451, 312, 797, 226, 88, 109, 109, 109, 109,
146278 /* 1240 */ 108, 108, 107, 107, 107, 106, 401, 86, 433, 979,
146279 /* 1250 */ 927, 881, 226, 983, 230, 415, 109, 109, 109, 109,
146280 /* 1260 */ 108, 108, 107, 107, 107, 106, 401, 320, 845, 781,
146281 /* 1270 */ 846, 100, 130, 100, 1403, 290, 370, 319, 1377, 1376,
146282 /* 1280 */ 437, 1449, 299, 1237, 303, 306, 308, 310, 1188, 1174,
146283 /* 1290 */ 1173, 1172, 315, 324, 325, 1228, 370, 927, 1249, 271,
146284 /* 1300 */ 1286, 113, 103, 1100, 1100, 953, 956, 946, 946, 110,
146285 /* 1310 */ 110, 111, 111, 111, 111, 1224, 1235, 502, 501, 1292,
146286 /* 1320 */ 1221, 1155, 103, 1100, 1100, 953, 956, 946, 946, 110,
146287 /* 1330 */ 110, 111, 111, 111, 111, 1148, 1137, 1136, 1138, 1443,
146288 /* 1340 */ 446, 244, 184, 98, 507, 188, 4, 353, 327, 109,
146289 /* 1350 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 401,
146290 /* 1360 */ 510, 329, 331, 199, 414, 456, 292, 285, 318, 109,
146291 /* 1370 */ 109, 109, 109, 108, 108, 107, 107, 107, 106, 401,
146292 /* 1380 */ 11, 1271, 1279, 402, 361, 192, 1171, 1351, 431, 505,
146293 /* 1390 */ 346, 1350, 333, 98, 507, 504, 4, 187, 1446, 1115,
146294 /* 1400 */ 233, 1396, 155, 1394, 1112, 152, 72, 75, 378, 425,
146295 /* 1410 */ 510, 165, 149, 157, 933, 1276, 86, 30, 1268, 417,
146296 /* 1420 */ 96, 96, 8, 160, 161, 162, 163, 97, 418, 402,
146297 /* 1430 */ 517, 516, 449, 402, 923, 210, 358, 424, 1282, 438,
146298 /* 1440 */ 169, 214, 360, 1345, 80, 504, 31, 444, 1365, 301,
146299 /* 1450 */ 245, 274, 506, 216, 174, 305, 488, 447, 217, 462,
146300 /* 1460 */ 1139, 487, 218, 363, 933, 923, 923, 925, 926, 24,
146301 /* 1470 */ 96, 96, 1191, 1190, 1189, 391, 1182, 97, 1163, 402,
146302 /* 1480 */ 517, 516, 799, 364, 923, 1162, 317, 1161, 98, 507,
146303 /* 1490 */ 1181, 4, 1458, 472, 393, 269, 270, 475, 481, 1232,
146304 /* 1500 */ 85, 1233, 326, 328, 232, 510, 495, 1231, 330, 98,
146305 /* 1510 */ 507, 1230, 4, 486, 335, 923, 923, 925, 926, 24,
146306 /* 1520 */ 1435, 1068, 404, 181, 336, 256, 510, 115, 402, 332,
146307 /* 1530 */ 352, 352, 351, 241, 349, 1214, 1414, 770, 338, 10,
146308 /* 1540 */ 504, 340, 272, 92, 1331, 1213, 87, 183, 484, 402,
146309 /* 1550 */ 201, 488, 280, 239, 344, 345, 489, 1145, 29, 933,
146310 /* 1560 */ 279, 504, 1074, 518, 240, 96, 96, 242, 243, 519,
146311 /* 1570 */ 1134, 1129, 97, 154, 402, 517, 516, 372, 373, 923,
146312 /* 1580 */ 933, 142, 143, 128, 1381, 267, 96, 96, 852, 757,
146313 /* 1590 */ 203, 144, 403, 97, 1382, 402, 517, 516, 204, 1380,
146314 /* 1600 */ 923, 146, 1379, 1159, 1158, 71, 1156, 276, 202, 185,
146315 /* 1610 */ 923, 923, 925, 926, 24, 198, 257, 126, 991, 989,
146316 /* 1620 */ 907, 98, 507, 156, 4, 145, 158, 206, 831, 209,
146317 /* 1630 */ 291, 923, 923, 925, 926, 24, 1005, 911, 510, 164,
146318 /* 1640 */ 147, 380, 371, 382, 166, 76, 77, 274, 506, 148,
146319 /* 1650 */ 78, 79, 1008, 211, 212, 1004, 137, 213, 18, 300,
146320 /* 1660 */ 230, 402, 997, 1109, 443, 215, 32, 170, 171, 772,
146321 /* 1670 */ 409, 448, 319, 504, 219, 172, 452, 81, 19, 457,
146322 /* 1680 */ 313, 20, 82, 268, 488, 150, 810, 179, 83, 487,
146323 /* 1690 */ 464, 151, 933, 180, 959, 84, 1040, 34, 96, 96,
146324 /* 1700 */ 471, 1041, 35, 474, 193, 97, 248, 402, 517, 516,
146325 /* 1710 */ 1068, 404, 923, 250, 256, 880, 229, 175, 875, 352,
146326 /* 1720 */ 352, 351, 241, 349, 100, 21, 770, 22, 1054, 1056,
146327 /* 1730 */ 7, 98, 507, 1045, 4, 337, 1058, 23, 974, 201,
146328 /* 1740 */ 176, 280, 88, 923, 923, 925, 926, 24, 510, 279,
146329 /* 1750 */ 960, 958, 962, 1014, 963, 1013, 235, 234, 25, 36,
146330 /* 1760 */ 99, 90, 507, 928, 4, 511, 350, 782, 26, 841,
146331 /* 1770 */ 236, 402, 347, 1069, 237, 1125, 1125, 1451, 510, 203,
146332 /* 1780 */ 1450, 1125, 1125, 504, 1125, 1125, 1125, 204, 1125, 1125,
146333 /* 1790 */ 146, 1125, 1125, 1125, 1125, 1125, 1125, 202, 1125, 1125,
146334 /* 1800 */ 1125, 402, 933, 1125, 1125, 1125, 1125, 1125, 96, 96,
146335 /* 1810 */ 1125, 1125, 1125, 504, 1125, 97, 1125, 402, 517, 516,
146336 /* 1820 */ 1125, 1125, 923, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146337 /* 1830 */ 1125, 371, 933, 1125, 1125, 1125, 274, 506, 96, 96,
146338 /* 1840 */ 1125, 1125, 1125, 1125, 1125, 97, 1125, 402, 517, 516,
146339 /* 1850 */ 1125, 1125, 923, 923, 923, 925, 926, 24, 1125, 409,
146340 /* 1860 */ 1125, 1125, 1125, 256, 1125, 1125, 1125, 1125, 352, 352,
146341 /* 1870 */ 351, 241, 349, 1125, 1125, 770, 1125, 1125, 1125, 1125,
146342 /* 1880 */ 1125, 1125, 1125, 923, 923, 925, 926, 24, 201, 1125,
146343 /* 1890 */ 280, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 279, 1125,
146344 /* 1900 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146345 /* 1910 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146346 /* 1920 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 203, 1125,
146347 /* 1930 */ 1125, 1125, 1125, 1125, 1125, 1125, 204, 1125, 1125, 146,
146348 /* 1940 */ 1125, 1125, 1125, 1125, 1125, 1125, 202, 1125, 1125, 1125,
146349 /* 1950 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146350 /* 1960 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146351 /* 1970 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146352 /* 1980 */ 371, 1125, 1125, 1125, 1125, 274, 506, 1125, 1125, 1125,
146353 /* 1990 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125,
146354 /* 2000 */ 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 409,
146355 };
146356 static const YYCODETYPE yy_lookahead[] = {
146357 /* 0 */ 184, 238, 239, 240, 238, 239, 240, 163, 155, 156,
146358 /* 10 */ 157, 158, 159, 160, 163, 191, 192, 183, 165, 19,
146359 /* 20 */ 167, 258, 202, 203, 200, 191, 163, 174, 184, 185,
@@ -145498,16 +146448,16 @@
146448 /* 910 */ 163, 184, 185, 163, 132, 163, 141, 163, 143, 22,
146449 /* 920 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
146450 /* 930 */ 102, 184, 185, 163, 184, 185, 184, 185, 184, 185,
146451 /* 940 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
146452 /* 950 */ 102, 163, 163, 163, 184, 185, 163, 115, 163, 163,
146453 /* 960 */ 163, 163, 15, 163, 163, 163, 163, 163, 23, 163,
146454 /* 970 */ 163, 26, 184, 185, 184, 185, 163, 184, 185, 184,
146455 /* 980 */ 185, 184, 185, 163, 184, 185, 184, 185, 184, 185,
146456 /* 990 */ 184, 185, 163, 96, 97, 147, 163, 184, 185, 163,
146457 /* 1000 */ 199, 163, 163, 205, 184, 185, 163, 60, 163, 141,
146458 /* 1010 */ 163, 143, 163, 184, 185, 19, 163, 184, 185, 230,
146459 /* 1020 */ 184, 185, 184, 185, 206, 207, 230, 184, 185, 184,
146460 /* 1030 */ 185, 184, 185, 184, 185, 19, 163, 219, 231, 43,
146461 /* 1040 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
146462 /* 1050 */ 54, 55, 56, 57, 163, 26, 163, 184, 185, 43,
146463 /* 1060 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
@@ -145517,74 +146467,74 @@
146467 /* 1100 */ 184, 185, 184, 185, 163, 184, 185, 163, 92, 93,
146468 /* 1110 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 163,
146469 /* 1120 */ 184, 185, 98, 59, 163, 184, 185, 205, 184, 185,
146470 /* 1130 */ 23, 206, 207, 26, 163, 26, 107, 153, 154, 237,
146471 /* 1140 */ 184, 185, 231, 147, 219, 184, 185, 249, 124, 127,
146472 /* 1150 */ 128, 231, 254, 129, 163, 231, 177, 178, 262, 263,
146473 /* 1160 */ 118, 132, 19, 19, 46, 223, 224, 31, 24, 23,
146474 /* 1170 */ 106, 124, 26, 22, 272, 39, 129, 23, 109, 110,
146475 /* 1180 */ 26, 163, 140, 19, 22, 234, 59, 43, 44, 45,
146476 /* 1190 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
146477 /* 1200 */ 56, 57, 231, 7, 8, 193, 59, 43, 44, 45,
146478 /* 1210 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
146479 /* 1220 */ 56, 57, 104, 61, 23, 23, 23, 26, 26, 26,
146480 /* 1230 */ 163, 23, 23, 106, 26, 26, 92, 93, 94, 95,
146481 /* 1240 */ 96, 97, 98, 99, 100, 101, 102, 138, 105, 23,
146482 /* 1250 */ 59, 23, 26, 106, 26, 163, 92, 93, 94, 95,
146483 /* 1260 */ 96, 97, 98, 99, 100, 101, 102, 110, 23, 23,
146484 /* 1270 */ 23, 26, 26, 26, 163, 163, 19, 120, 163, 163,
146485 /* 1280 */ 163, 130, 163, 163, 163, 163, 163, 163, 163, 193,
146486 /* 1290 */ 193, 163, 163, 163, 163, 225, 19, 106, 163, 222,
146487 /* 1300 */ 163, 44, 45, 46, 47, 48, 49, 50, 51, 52,
146488 /* 1310 */ 53, 54, 55, 56, 57, 163, 163, 203, 163, 163,
146489 /* 1320 */ 222, 163, 45, 46, 47, 48, 49, 50, 51, 52,
146490 /* 1330 */ 53, 54, 55, 56, 57, 163, 163, 163, 163, 163,
146491 /* 1340 */ 251, 250, 209, 19, 20, 182, 22, 161, 222, 92,
146492 /* 1350 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
146493 /* 1360 */ 36, 222, 222, 260, 226, 188, 256, 226, 187, 92,
146494 /* 1370 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
146495 /* 1380 */ 210, 213, 213, 59, 213, 196, 192, 187, 256, 244,
146496 /* 1390 */ 212, 187, 226, 19, 20, 71, 22, 210, 166, 60,
146497 /* 1400 */ 130, 170, 260, 170, 38, 81, 257, 257, 170, 104,
146498 /* 1410 */ 36, 22, 43, 201, 90, 236, 138, 235, 213, 18,
146499 /* 1420 */ 96, 97, 48, 204, 204, 204, 204, 103, 170, 105,
146500 /* 1430 */ 106, 107, 18, 59, 110, 169, 213, 213, 201, 170,
146501 /* 1440 */ 201, 169, 236, 213, 146, 71, 235, 62, 253, 252,
146502 /* 1450 */ 170, 127, 128, 169, 22, 170, 82, 189, 169, 104,
146503 /* 1460 */ 170, 87, 169, 189, 90, 141, 142, 143, 144, 145,
146504 /* 1470 */ 96, 97, 186, 186, 186, 64, 194, 103, 186, 105,
146505 /* 1480 */ 106, 107, 115, 189, 110, 188, 186, 186, 19, 20,
146506 /* 1490 */ 194, 22, 186, 189, 102, 246, 246, 189, 133, 228,
146507 /* 1500 */ 104, 228, 227, 227, 170, 36, 134, 228, 227, 19,
146508 /* 1510 */ 20, 228, 22, 84, 271, 141, 142, 143, 144, 145,
146509 /* 1520 */ 0, 1, 2, 216, 22, 5, 36, 137, 59, 227,
146510 /* 1530 */ 10, 11, 12, 13, 14, 217, 269, 17, 216, 22,
146511 /* 1540 */ 71, 170, 243, 146, 241, 217, 136, 215, 135, 59,
146512 /* 1550 */ 30, 82, 32, 25, 214, 213, 87, 173, 26, 90,
146513 /* 1560 */ 40, 71, 13, 172, 164, 96, 97, 164, 6, 162,
146514 /* 1570 */ 162, 162, 103, 263, 105, 106, 107, 266, 266, 110,
146515 /* 1580 */ 90, 176, 176, 190, 182, 190, 96, 97, 98, 4,
146516 /* 1590 */ 70, 176, 3, 103, 182, 105, 106, 107, 78, 182,
146517 /* 1600 */ 110, 81, 182, 182, 182, 182, 182, 151, 88, 22,
146518 /* 1610 */ 141, 142, 143, 144, 145, 15, 89, 16, 23, 23,
146519 /* 1620 */ 128, 19, 20, 139, 22, 119, 131, 24, 20, 133,
146520 /* 1630 */ 16, 141, 142, 143, 144, 145, 1, 140, 36, 131,
146521 /* 1640 */ 119, 61, 122, 37, 139, 53, 53, 127, 128, 119,
146522 /* 1650 */ 53, 53, 105, 34, 130, 1, 5, 104, 22, 149,
146523 /* 1660 */ 26, 59, 68, 75, 41, 130, 24, 68, 104, 20,
146524 /* 1670 */ 150, 19, 120, 71, 114, 22, 67, 22, 22, 67,
146525 /* 1680 */ 23, 22, 22, 67, 82, 37, 28, 23, 138, 87,
146526 /* 1690 */ 22, 153, 90, 23, 23, 26, 23, 22, 96, 97,
146527 /* 1700 */ 24, 23, 22, 24, 130, 103, 23, 105, 106, 107,
146528 /* 1710 */ 1, 2, 110, 23, 5, 105, 34, 22, 132, 10,
146529 /* 1720 */ 11, 12, 13, 14, 26, 34, 17, 34, 85, 83,
146530 /* 1730 */ 44, 19, 20, 23, 22, 24, 75, 34, 23, 30,
146531 /* 1740 */ 26, 32, 26, 141, 142, 143, 144, 145, 36, 40,
146532 /* 1750 */ 23, 23, 23, 23, 11, 23, 22, 26, 22, 22,
146533 /* 1760 */ 22, 19, 20, 23, 22, 26, 15, 23, 22, 124,
146534 /* 1770 */ 130, 59, 23, 1, 130, 277, 277, 130, 36, 70,
146535 /* 1780 */ 130, 277, 277, 71, 277, 277, 277, 78, 277, 277,
146536 /* 1790 */ 81, 277, 277, 277, 277, 277, 277, 88, 277, 277,
146537 /* 1800 */ 277, 59, 90, 277, 277, 277, 277, 277, 96, 97,
146538 /* 1810 */ 277, 277, 277, 71, 277, 103, 277, 105, 106, 107,
146539 /* 1820 */ 277, 277, 110, 277, 277, 277, 277, 277, 277, 277,
146540 /* 1830 */ 277, 122, 90, 277, 277, 277, 127, 128, 96, 97,
@@ -145605,11 +146555,11 @@
146555 /* 1980 */ 122, 277, 277, 277, 277, 127, 128, 277, 277, 277,
146556 /* 1990 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
146557 /* 2000 */ 277, 277, 277, 277, 277, 277, 277, 277, 150, 277,
146558 /* 2010 */ 277, 277, 277, 277, 277, 277, 277, 277, 277,
146559 };
146560 #define YY_SHIFT_COUNT (520)
146561 #define YY_SHIFT_MIN (0)
146562 #define YY_SHIFT_MAX (1858)
146563 static const unsigned short int yy_shift_ofst[] = {
146564 /* 0 */ 1709, 1520, 1858, 1324, 1324, 277, 1374, 1469, 1602, 1712,
146565 /* 10 */ 1712, 1712, 273, 0, 0, 113, 1016, 1712, 1712, 1712,
@@ -145629,46 +146579,47 @@
146579 /* 150 */ 597, 464, 474, 262, 681, 531, 531, 531, 531, 531,
146580 /* 160 */ 531, 531, 531, 531, 531, 531, 531, 531, 531, 531,
146581 /* 170 */ 531, 531, 531, 531, 531, 531, 531, 173, 485, 984,
146582 /* 180 */ 984, 576, 485, 19, 1022, 2009, 2009, 2009, 387, 250,
146583 /* 190 */ 250, 525, 502, 278, 552, 227, 480, 566, 531, 531,
146584 /* 200 */ 531, 531, 531, 531, 531, 531, 531, 531, 639, 531,
146585 /* 210 */ 531, 531, 531, 531, 531, 531, 531, 531, 531, 531,
146586 /* 220 */ 531, 2, 2, 2, 531, 531, 531, 531, 782, 531,
146587 /* 230 */ 531, 531, 744, 531, 531, 783, 531, 531, 531, 531,
146588 /* 240 */ 531, 531, 531, 531, 419, 682, 327, 370, 370, 370,
146589 /* 250 */ 370, 1029, 327, 327, 1024, 897, 856, 947, 1109, 706,
146590 /* 260 */ 706, 1143, 1109, 1109, 1143, 842, 945, 1118, 1136, 1136,
146591 /* 270 */ 1136, 706, 676, 400, 1047, 694, 1339, 1270, 1270, 1366,
146592 /* 280 */ 1366, 1270, 1305, 1389, 1369, 1278, 1401, 1401, 1401, 1401,
146593 /* 290 */ 1270, 1414, 1278, 1278, 1305, 1389, 1369, 1369, 1278, 1270,
146594 /* 300 */ 1414, 1298, 1385, 1270, 1414, 1432, 1270, 1414, 1270, 1414,
146595 /* 310 */ 1432, 1355, 1355, 1355, 1411, 1432, 1355, 1367, 1355, 1411,
146596 /* 320 */ 1355, 1355, 1432, 1392, 1392, 1432, 1365, 1396, 1365, 1396,
146597 /* 330 */ 1365, 1396, 1365, 1396, 1270, 1372, 1429, 1502, 1390, 1372,
146598 /* 340 */ 1517, 1270, 1397, 1390, 1410, 1413, 1278, 1528, 1532, 1549,
146599 /* 350 */ 1549, 1562, 1562, 1562, 2009, 2009, 2009, 2009, 2009, 2009,
146600 /* 360 */ 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
146601 /* 370 */ 570, 345, 686, 748, 50, 740, 1064, 1107, 469, 537,
146602 /* 380 */ 1042, 1146, 1162, 1154, 1201, 1202, 1203, 1208, 1209, 1127,
146603 /* 390 */ 1069, 1196, 1157, 1147, 1226, 1228, 1245, 775, 868, 1246,
146604 /* 400 */ 1247, 1191, 1151, 1585, 1589, 1587, 1456, 1600, 1527, 1601,
146605 /* 410 */ 1595, 1596, 1492, 1484, 1506, 1603, 1495, 1608, 1496, 1614,
146606 /* 420 */ 1635, 1508, 1497, 1521, 1580, 1606, 1505, 1592, 1593, 1597,
146607 /* 430 */ 1598, 1530, 1547, 1619, 1524, 1654, 1651, 1636, 1553, 1510,
146608 /* 440 */ 1594, 1634, 1599, 1588, 1623, 1535, 1564, 1642, 1649, 1652,
146609 /* 450 */ 1552, 1560, 1653, 1609, 1655, 1656, 1657, 1659, 1612, 1658,
146610 /* 460 */ 1660, 1616, 1648, 1664, 1550, 1668, 1538, 1670, 1671, 1669,
146611 /* 470 */ 1673, 1675, 1676, 1678, 1680, 1679, 1574, 1683, 1690, 1610,
146612 /* 480 */ 1682, 1695, 1586, 1698, 1691, 1698, 1693, 1643, 1661, 1646,
146613 /* 490 */ 1686, 1710, 1711, 1714, 1716, 1703, 1715, 1698, 1727, 1728,
146614 /* 500 */ 1729, 1730, 1731, 1732, 1734, 1743, 1736, 1737, 1740, 1744,
146615 /* 510 */ 1738, 1746, 1739, 1645, 1640, 1644, 1647, 1650, 1749, 1751,
146616 /* 520 */ 1772,
146617 };
146618 #define YY_REDUCE_COUNT (369)
146619 #define YY_REDUCE_MIN (-237)
146620 #define YY_REDUCE_MAX (1424)
146621 static const short yy_reduce_ofst[] = {
146622 /* 0 */ -147, 171, 263, -96, 358, -144, -149, -102, 124, -156,
146623 /* 10 */ -98, 305, 401, -57, 209, -237, 245, -94, -79, 189,
146624 /* 20 */ 375, 490, 493, 378, 303, 539, 542, 501, 503, 554,
146625 /* 30 */ 415, 526, 546, 557, 587, 593, 595, -234, -234, -234,
@@ -145686,81 +146637,82 @@
146637 /* 150 */ 364, 41, 513, 509, 509, 117, 500, 789, 796, 646,
146638 /* 160 */ 192, 291, 644, 798, 120, 807, 543, 911, 920, 652,
146639 /* 170 */ 924, 922, 232, 698, 801, 971, 39, 220, 731, 442,
146640 /* 180 */ 902, -199, 979, -43, 421, 896, 942, 605, -184, -126,
146641 /* 190 */ 155, 172, 281, 304, 377, 538, 650, 690, 699, 723,
146642 /* 200 */ 803, 839, 853, 919, 991, 1018, 1067, 1092, 951, 1111,
146643 /* 210 */ 1112, 1115, 1116, 1117, 1119, 1120, 1121, 1122, 1123, 1124,
146644 /* 220 */ 1125, 1012, 1096, 1097, 1128, 1129, 1130, 1131, 1070, 1135,
146645 /* 230 */ 1137, 1152, 1077, 1153, 1155, 1114, 1156, 304, 1158, 1172,
146646 /* 240 */ 1173, 1174, 1175, 1176, 1089, 1091, 1133, 1098, 1126, 1139,
146647 /* 250 */ 1140, 1070, 1133, 1133, 1170, 1163, 1186, 1103, 1168, 1138,
146648 /* 260 */ 1141, 1110, 1169, 1171, 1132, 1177, 1189, 1194, 1181, 1200,
146649 /* 270 */ 1204, 1166, 1145, 1178, 1187, 1232, 1142, 1231, 1233, 1149,
146650 /* 280 */ 1150, 1238, 1179, 1182, 1212, 1205, 1219, 1220, 1221, 1222,
146651 /* 290 */ 1258, 1266, 1223, 1224, 1206, 1211, 1237, 1239, 1230, 1269,
146652 /* 300 */ 1272, 1195, 1197, 1280, 1284, 1268, 1285, 1289, 1290, 1293,
146653 /* 310 */ 1274, 1286, 1287, 1288, 1282, 1294, 1292, 1297, 1300, 1296,
146654 /* 320 */ 1301, 1306, 1304, 1249, 1250, 1308, 1271, 1275, 1273, 1276,
146655 /* 330 */ 1279, 1281, 1283, 1302, 1334, 1307, 1243, 1267, 1318, 1322,
146656 /* 340 */ 1303, 1371, 1299, 1328, 1332, 1340, 1342, 1384, 1391, 1400,
146657 /* 350 */ 1403, 1407, 1408, 1409, 1311, 1312, 1310, 1405, 1402, 1412,
146658 /* 360 */ 1417, 1420, 1406, 1393, 1395, 1421, 1422, 1423, 1424, 1415,
146659 };
146660 static const YYACTIONTYPE yy_default[] = {
146661 /* 0 */ 1492, 1492, 1492, 1340, 1123, 1229, 1123, 1123, 1123, 1340,
146662 /* 10 */ 1340, 1340, 1123, 1259, 1259, 1391, 1154, 1123, 1123, 1123,
146663 /* 20 */ 1123, 1123, 1123, 1123, 1339, 1123, 1123, 1123, 1123, 1123,
146664 /* 30 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1265, 1123,
146665 /* 40 */ 1123, 1123, 1123, 1123, 1341, 1342, 1123, 1123, 1123, 1390,
146666 /* 50 */ 1392, 1275, 1274, 1273, 1272, 1373, 1246, 1270, 1263, 1267,
146667 /* 60 */ 1335, 1336, 1334, 1338, 1342, 1341, 1123, 1266, 1306, 1320,
146668 /* 70 */ 1305, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146669 /* 80 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146670 /* 90 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146671 /* 100 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146672 /* 110 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1314, 1319, 1325,
146673 /* 120 */ 1318, 1315, 1308, 1307, 1309, 1310, 1123, 1144, 1193, 1123,
146674 /* 130 */ 1123, 1123, 1123, 1409, 1408, 1123, 1123, 1154, 1311, 1312,
146675 /* 140 */ 1322, 1321, 1398, 1448, 1447, 1123, 1123, 1123, 1123, 1123,
146676 /* 150 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146677 /* 160 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146678 /* 170 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1154, 1150, 1300,
146679 /* 180 */ 1299, 1418, 1150, 1253, 1123, 1404, 1229, 1220, 1123, 1123,
146680 /* 190 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146681 /* 200 */ 1123, 1395, 1393, 1123, 1355, 1123, 1123, 1123, 1123, 1123,
146682 /* 210 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146683 /* 220 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146684 /* 230 */ 1123, 1123, 1225, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146685 /* 240 */ 1123, 1123, 1123, 1442, 1123, 1368, 1207, 1225, 1225, 1225,
146686 /* 250 */ 1225, 1227, 1208, 1206, 1219, 1154, 1130, 1484, 1269, 1248,
146687 /* 260 */ 1248, 1481, 1269, 1269, 1481, 1168, 1462, 1165, 1259, 1259,
146688 /* 270 */ 1259, 1248, 1337, 1226, 1219, 1123, 1484, 1234, 1234, 1483,
146689 /* 280 */ 1483, 1234, 1278, 1284, 1196, 1269, 1202, 1202, 1202, 1202,
146690 /* 290 */ 1234, 1141, 1269, 1269, 1278, 1284, 1196, 1196, 1269, 1234,
146691 /* 300 */ 1141, 1372, 1478, 1234, 1141, 1348, 1234, 1141, 1234, 1141,
146692 /* 310 */ 1348, 1194, 1194, 1194, 1183, 1348, 1194, 1168, 1194, 1183,
146693 /* 320 */ 1194, 1194, 1348, 1352, 1352, 1348, 1252, 1247, 1252, 1247,
146694 /* 330 */ 1252, 1247, 1252, 1247, 1234, 1253, 1417, 1123, 1264, 1253,
146695 /* 340 */ 1343, 1234, 1123, 1264, 1262, 1260, 1269, 1147, 1186, 1445,
146696 /* 350 */ 1445, 1441, 1441, 1441, 1489, 1489, 1404, 1457, 1154, 1154,
146697 /* 360 */ 1154, 1154, 1457, 1170, 1170, 1154, 1154, 1154, 1154, 1457,
146698 /* 370 */ 1123, 1123, 1123, 1123, 1123, 1123, 1452, 1123, 1357, 1238,
146699 /* 380 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146700 /* 390 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146701 /* 400 */ 1123, 1123, 1289, 1123, 1126, 1401, 1123, 1123, 1399, 1123,
146702 /* 410 */ 1123, 1123, 1123, 1123, 1123, 1239, 1123, 1123, 1123, 1123,
146703 /* 420 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146704 /* 430 */ 1123, 1123, 1123, 1123, 1480, 1123, 1123, 1123, 1123, 1123,
146705 /* 440 */ 1123, 1371, 1370, 1123, 1123, 1236, 1123, 1123, 1123, 1123,
146706 /* 450 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146707 /* 460 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146708 /* 470 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146709 /* 480 */ 1123, 1123, 1123, 1261, 1123, 1416, 1123, 1123, 1123, 1123,
146710 /* 490 */ 1123, 1123, 1123, 1430, 1254, 1123, 1123, 1471, 1123, 1123,
146711 /* 500 */ 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123, 1123,
146712 /* 510 */ 1123, 1123, 1466, 1210, 1291, 1123, 1290, 1294, 1123, 1135,
146713 /* 520 */ 1123,
146714 };
146715 /********** End of lemon-generated parsing tables *****************************/
146716
146717 /* The next table maps tokens (terminal symbols) into fallback tokens.
146718 ** If a construct like the following:
@@ -146512,102 +147464,103 @@
147464 /* 269 */ "cmd ::= ANALYZE",
147465 /* 270 */ "cmd ::= ANALYZE nm dbnm",
147466 /* 271 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
147467 /* 272 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
147468 /* 273 */ "add_column_fullname ::= fullname",
147469 /* 274 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
147470 /* 275 */ "cmd ::= create_vtab",
147471 /* 276 */ "cmd ::= create_vtab LP vtabarglist RP",
147472 /* 277 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
147473 /* 278 */ "vtabarg ::=",
147474 /* 279 */ "vtabargtoken ::= ANY",
147475 /* 280 */ "vtabargtoken ::= lp anylist RP",
147476 /* 281 */ "lp ::= LP",
147477 /* 282 */ "with ::= WITH wqlist",
147478 /* 283 */ "with ::= WITH RECURSIVE wqlist",
147479 /* 284 */ "wqlist ::= nm eidlist_opt AS LP select RP",
147480 /* 285 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
147481 /* 286 */ "windowdefn_list ::= windowdefn",
147482 /* 287 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
147483 /* 288 */ "windowdefn ::= nm AS window",
147484 /* 289 */ "window ::= LP part_opt orderby_opt frame_opt RP",
147485 /* 290 */ "part_opt ::= PARTITION BY nexprlist",
147486 /* 291 */ "part_opt ::=",
147487 /* 292 */ "frame_opt ::=",
147488 /* 293 */ "frame_opt ::= range_or_rows frame_bound_s",
147489 /* 294 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e",
147490 /* 295 */ "range_or_rows ::= RANGE",
147491 /* 296 */ "range_or_rows ::= ROWS",
147492 /* 297 */ "frame_bound_s ::= frame_bound",
147493 /* 298 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
147494 /* 299 */ "frame_bound_e ::= frame_bound",
147495 /* 300 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
147496 /* 301 */ "frame_bound ::= expr PRECEDING",
147497 /* 302 */ "frame_bound ::= CURRENT ROW",
147498 /* 303 */ "frame_bound ::= expr FOLLOWING",
147499 /* 304 */ "window_clause ::= WINDOW windowdefn_list",
147500 /* 305 */ "over_clause ::= filter_opt OVER window",
147501 /* 306 */ "over_clause ::= filter_opt OVER nm",
147502 /* 307 */ "filter_opt ::=",
147503 /* 308 */ "filter_opt ::= FILTER LP WHERE expr RP",
147504 /* 309 */ "input ::= cmdlist",
147505 /* 310 */ "cmdlist ::= cmdlist ecmd",
147506 /* 311 */ "cmdlist ::= ecmd",
147507 /* 312 */ "ecmd ::= SEMI",
147508 /* 313 */ "ecmd ::= cmdx SEMI",
147509 /* 314 */ "ecmd ::= explain cmdx",
147510 /* 315 */ "trans_opt ::=",
147511 /* 316 */ "trans_opt ::= TRANSACTION",
147512 /* 317 */ "trans_opt ::= TRANSACTION nm",
147513 /* 318 */ "savepoint_opt ::= SAVEPOINT",
147514 /* 319 */ "savepoint_opt ::=",
147515 /* 320 */ "cmd ::= create_table create_table_args",
147516 /* 321 */ "columnlist ::= columnlist COMMA columnname carglist",
147517 /* 322 */ "columnlist ::= columnname carglist",
147518 /* 323 */ "nm ::= ID|INDEXED",
147519 /* 324 */ "nm ::= STRING",
147520 /* 325 */ "nm ::= JOIN_KW",
147521 /* 326 */ "typetoken ::= typename",
147522 /* 327 */ "typename ::= ID|STRING",
147523 /* 328 */ "signed ::= plus_num",
147524 /* 329 */ "signed ::= minus_num",
147525 /* 330 */ "carglist ::= carglist ccons",
147526 /* 331 */ "carglist ::=",
147527 /* 332 */ "ccons ::= NULL onconf",
147528 /* 333 */ "conslist_opt ::= COMMA conslist",
147529 /* 334 */ "conslist ::= conslist tconscomma tcons",
147530 /* 335 */ "conslist ::= tcons",
147531 /* 336 */ "tconscomma ::=",
147532 /* 337 */ "defer_subclause_opt ::= defer_subclause",
147533 /* 338 */ "resolvetype ::= raisetype",
147534 /* 339 */ "selectnowith ::= oneselect",
147535 /* 340 */ "oneselect ::= values",
147536 /* 341 */ "sclp ::= selcollist COMMA",
147537 /* 342 */ "as ::= ID|STRING",
147538 /* 343 */ "expr ::= term",
147539 /* 344 */ "likeop ::= LIKE_KW|MATCH",
147540 /* 345 */ "exprlist ::= nexprlist",
147541 /* 346 */ "nmnum ::= plus_num",
147542 /* 347 */ "nmnum ::= nm",
147543 /* 348 */ "nmnum ::= ON",
147544 /* 349 */ "nmnum ::= DELETE",
147545 /* 350 */ "nmnum ::= DEFAULT",
147546 /* 351 */ "plus_num ::= INTEGER|FLOAT",
147547 /* 352 */ "foreach_clause ::=",
147548 /* 353 */ "foreach_clause ::= FOR EACH ROW",
147549 /* 354 */ "trnm ::= nm",
147550 /* 355 */ "tridxby ::=",
147551 /* 356 */ "database_kw_opt ::= DATABASE",
147552 /* 357 */ "database_kw_opt ::=",
147553 /* 358 */ "kwcolumn_opt ::=",
147554 /* 359 */ "kwcolumn_opt ::= COLUMNKW",
147555 /* 360 */ "vtabarglist ::= vtabarg",
147556 /* 361 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
147557 /* 362 */ "vtabarg ::= vtabarg vtabargtoken",
147558 /* 363 */ "anylist ::=",
147559 /* 364 */ "anylist ::= anylist LP anylist RP",
147560 /* 365 */ "anylist ::= anylist ANY",
147561 /* 366 */ "with ::=",
147562 };
147563 #endif /* NDEBUG */
147564
147565
147566 #if YYSTACKDEPTH<=0
@@ -147391,102 +148344,103 @@
148344 { 160, -1 }, /* (269) cmd ::= ANALYZE */
148345 { 160, -3 }, /* (270) cmd ::= ANALYZE nm dbnm */
148346 { 160, -6 }, /* (271) cmd ::= ALTER TABLE fullname RENAME TO nm */
148347 { 160, -7 }, /* (272) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
148348 { 259, -1 }, /* (273) add_column_fullname ::= fullname */
148349 { 160, -8 }, /* (274) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
148350 { 160, -1 }, /* (275) cmd ::= create_vtab */
148351 { 160, -4 }, /* (276) cmd ::= create_vtab LP vtabarglist RP */
148352 { 261, -8 }, /* (277) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
148353 { 263, 0 }, /* (278) vtabarg ::= */
148354 { 264, -1 }, /* (279) vtabargtoken ::= ANY */
148355 { 264, -3 }, /* (280) vtabargtoken ::= lp anylist RP */
148356 { 265, -1 }, /* (281) lp ::= LP */
148357 { 232, -2 }, /* (282) with ::= WITH wqlist */
148358 { 232, -3 }, /* (283) with ::= WITH RECURSIVE wqlist */
148359 { 208, -6 }, /* (284) wqlist ::= nm eidlist_opt AS LP select RP */
148360 { 208, -8 }, /* (285) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
148361 { 267, -1 }, /* (286) windowdefn_list ::= windowdefn */
148362 { 267, -3 }, /* (287) windowdefn_list ::= windowdefn_list COMMA windowdefn */
148363 { 268, -3 }, /* (288) windowdefn ::= nm AS window */
148364 { 269, -5 }, /* (289) window ::= LP part_opt orderby_opt frame_opt RP */
148365 { 271, -3 }, /* (290) part_opt ::= PARTITION BY nexprlist */
148366 { 271, 0 }, /* (291) part_opt ::= */
148367 { 270, 0 }, /* (292) frame_opt ::= */
148368 { 270, -2 }, /* (293) frame_opt ::= range_or_rows frame_bound_s */
148369 { 270, -5 }, /* (294) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
148370 { 273, -1 }, /* (295) range_or_rows ::= RANGE */
148371 { 273, -1 }, /* (296) range_or_rows ::= ROWS */
148372 { 275, -1 }, /* (297) frame_bound_s ::= frame_bound */
148373 { 275, -2 }, /* (298) frame_bound_s ::= UNBOUNDED PRECEDING */
148374 { 276, -1 }, /* (299) frame_bound_e ::= frame_bound */
148375 { 276, -2 }, /* (300) frame_bound_e ::= UNBOUNDED FOLLOWING */
148376 { 274, -2 }, /* (301) frame_bound ::= expr PRECEDING */
148377 { 274, -2 }, /* (302) frame_bound ::= CURRENT ROW */
148378 { 274, -2 }, /* (303) frame_bound ::= expr FOLLOWING */
148379 { 218, -2 }, /* (304) window_clause ::= WINDOW windowdefn_list */
148380 { 237, -3 }, /* (305) over_clause ::= filter_opt OVER window */
148381 { 237, -3 }, /* (306) over_clause ::= filter_opt OVER nm */
148382 { 272, 0 }, /* (307) filter_opt ::= */
148383 { 272, -5 }, /* (308) filter_opt ::= FILTER LP WHERE expr RP */
148384 { 155, -1 }, /* (309) input ::= cmdlist */
148385 { 156, -2 }, /* (310) cmdlist ::= cmdlist ecmd */
148386 { 156, -1 }, /* (311) cmdlist ::= ecmd */
148387 { 157, -1 }, /* (312) ecmd ::= SEMI */
148388 { 157, -2 }, /* (313) ecmd ::= cmdx SEMI */
148389 { 157, -2 }, /* (314) ecmd ::= explain cmdx */
148390 { 162, 0 }, /* (315) trans_opt ::= */
148391 { 162, -1 }, /* (316) trans_opt ::= TRANSACTION */
148392 { 162, -2 }, /* (317) trans_opt ::= TRANSACTION nm */
148393 { 164, -1 }, /* (318) savepoint_opt ::= SAVEPOINT */
148394 { 164, 0 }, /* (319) savepoint_opt ::= */
148395 { 160, -2 }, /* (320) cmd ::= create_table create_table_args */
148396 { 171, -4 }, /* (321) columnlist ::= columnlist COMMA columnname carglist */
148397 { 171, -2 }, /* (322) columnlist ::= columnname carglist */
148398 { 163, -1 }, /* (323) nm ::= ID|INDEXED */
148399 { 163, -1 }, /* (324) nm ::= STRING */
148400 { 163, -1 }, /* (325) nm ::= JOIN_KW */
148401 { 177, -1 }, /* (326) typetoken ::= typename */
148402 { 178, -1 }, /* (327) typename ::= ID|STRING */
148403 { 179, -1 }, /* (328) signed ::= plus_num */
148404 { 179, -1 }, /* (329) signed ::= minus_num */
148405 { 176, -2 }, /* (330) carglist ::= carglist ccons */
148406 { 176, 0 }, /* (331) carglist ::= */
148407 { 183, -2 }, /* (332) ccons ::= NULL onconf */
148408 { 172, -2 }, /* (333) conslist_opt ::= COMMA conslist */
148409 { 195, -3 }, /* (334) conslist ::= conslist tconscomma tcons */
148410 { 195, -1 }, /* (335) conslist ::= tcons */
148411 { 196, 0 }, /* (336) tconscomma ::= */
148412 { 200, -1 }, /* (337) defer_subclause_opt ::= defer_subclause */
148413 { 202, -1 }, /* (338) resolvetype ::= raisetype */
148414 { 206, -1 }, /* (339) selectnowith ::= oneselect */
148415 { 207, -1 }, /* (340) oneselect ::= values */
148416 { 221, -2 }, /* (341) sclp ::= selcollist COMMA */
148417 { 222, -1 }, /* (342) as ::= ID|STRING */
148418 { 185, -1 }, /* (343) expr ::= term */
148419 { 238, -1 }, /* (344) likeop ::= LIKE_KW|MATCH */
148420 { 229, -1 }, /* (345) exprlist ::= nexprlist */
148421 { 247, -1 }, /* (346) nmnum ::= plus_num */
148422 { 247, -1 }, /* (347) nmnum ::= nm */
148423 { 247, -1 }, /* (348) nmnum ::= ON */
148424 { 247, -1 }, /* (349) nmnum ::= DELETE */
148425 { 247, -1 }, /* (350) nmnum ::= DEFAULT */
148426 { 180, -1 }, /* (351) plus_num ::= INTEGER|FLOAT */
148427 { 252, 0 }, /* (352) foreach_clause ::= */
148428 { 252, -3 }, /* (353) foreach_clause ::= FOR EACH ROW */
148429 { 255, -1 }, /* (354) trnm ::= nm */
148430 { 256, 0 }, /* (355) tridxby ::= */
148431 { 257, -1 }, /* (356) database_kw_opt ::= DATABASE */
148432 { 257, 0 }, /* (357) database_kw_opt ::= */
148433 { 260, 0 }, /* (358) kwcolumn_opt ::= */
148434 { 260, -1 }, /* (359) kwcolumn_opt ::= COLUMNKW */
148435 { 262, -1 }, /* (360) vtabarglist ::= vtabarg */
148436 { 262, -3 }, /* (361) vtabarglist ::= vtabarglist COMMA vtabarg */
148437 { 263, -2 }, /* (362) vtabarg ::= vtabarg vtabargtoken */
148438 { 266, 0 }, /* (363) anylist ::= */
148439 { 266, -4 }, /* (364) anylist ::= anylist LP anylist RP */
148440 { 266, -2 }, /* (365) anylist ::= anylist ANY */
148441 { 232, 0 }, /* (366) with ::= */
148442 };
148443
148444 static void yy_accept(yyParser*); /* Forward Declaration */
148445
148446 /*
@@ -147708,11 +148662,11 @@
148662 Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0);
148663 if( p ){
148664 sqlite3ExprIdToTrueFalse(p);
148665 testcase( p->op==TK_TRUEFALSE && sqlite3ExprTruthValue(p) );
148666 }
148667 sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
148668 }
148669 break;
148670 case 35: /* ccons ::= NOT NULL onconf */
148671 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy70);}
148672 break;
@@ -148041,15 +148995,27 @@
148995 case 108: /* dbnm ::= */
148996 case 122: /* indexed_opt ::= */ yytestcase(yyruleno==122);
148997 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
148998 break;
148999 case 110: /* fullname ::= nm */
149000 {
149001 yylhsminor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0);
149002 if( IN_RENAME_OBJECT && yylhsminor.yy135 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy135->a[0].zName, &yymsp[0].minor.yy0);
149003 }
149004 yymsp[0].minor.yy135 = yylhsminor.yy135;
149005 break;
149006 case 111: /* fullname ::= nm DOT nm */
149007 {
149008 yylhsminor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
149009 if( IN_RENAME_OBJECT && yylhsminor.yy135 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy135->a[0].zName, &yymsp[0].minor.yy0);
149010 }
149011 yymsp[-2].minor.yy135 = yylhsminor.yy135;
149012 break;
149013 case 112: /* xfullname ::= nm */
149014 {yymsp[0].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
149015 break;
149016 case 113: /* xfullname ::= nm DOT nm */
149017 {yymsp[-2].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
149018 break;
149019 case 114: /* xfullname ::= nm DOT nm AS nm */
149020 {
149021 yymsp[-4].minor.yy135 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
@@ -148195,14 +149161,14 @@
149161 break;
149162 case 159: /* idlist_opt ::= LP idlist RP */
149163 {yymsp[-2].minor.yy48 = yymsp[-1].minor.yy48;}
149164 break;
149165 case 160: /* idlist ::= idlist COMMA nm */
149166 {yymsp[-2].minor.yy48 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy48,&yymsp[0].minor.yy0);}
149167 break;
149168 case 161: /* idlist ::= nm */
149169 {yymsp[0].minor.yy48 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
149170 break;
149171 case 162: /* expr ::= LP expr RP */
149172 {yymsp[-2].minor.yy18 = yymsp[-1].minor.yy18;}
149173 break;
149174 case 163: /* expr ::= ID|INDEXED */
@@ -148211,10 +149177,14 @@
149177 break;
149178 case 165: /* expr ::= nm DOT nm */
149179 {
149180 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
149181 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
149182 if( IN_RENAME_OBJECT ){
149183 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
149184 sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
149185 }
149186 yylhsminor.yy18 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
149187 }
149188 yymsp[-2].minor.yy18 = yylhsminor.yy18;
149189 break;
149190 case 166: /* expr ::= nm DOT nm DOT nm */
@@ -148221,10 +149191,14 @@
149191 {
149192 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
149193 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
149194 Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
149195 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
149196 if( IN_RENAME_OBJECT ){
149197 sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
149198 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
149199 }
149200 yylhsminor.yy18 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
149201 }
149202 yymsp[-4].minor.yy18 = yylhsminor.yy18;
149203 break;
149204 case 167: /* term ::= NULL|FLOAT|BLOB */
@@ -148518,10 +149492,13 @@
149492 case 219: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
149493 {
149494 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
149495 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy420, yymsp[-10].minor.yy70,
149496 &yymsp[-11].minor.yy0, yymsp[0].minor.yy18, SQLITE_SO_ASC, yymsp[-8].minor.yy70, SQLITE_IDXTYPE_APPDEF);
149497 if( IN_RENAME_OBJECT && pParse->pNewIndex ){
149498 sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
149499 }
149500 }
149501 break;
149502 case 220: /* uniqueflag ::= UNIQUE */
149503 case 260: /* raisetype ::= ABORT */ yytestcase(yyruleno==260);
149504 {yymsp[0].minor.yy70 = OE_Abort;}
@@ -148593,11 +149570,11 @@
149570 case 245: /* trigger_event ::= UPDATE OF idlist */
149571 {yymsp[-2].minor.yy34.a = TK_UPDATE; yymsp[-2].minor.yy34.b = yymsp[0].minor.yy48;}
149572 break;
149573 case 246: /* when_clause ::= */
149574 case 265: /* key_opt ::= */ yytestcase(yyruleno==265);
149575 case 307: /* filter_opt ::= */ yytestcase(yyruleno==307);
149576 { yymsp[1].minor.yy18 = 0; }
149577 break;
149578 case 247: /* when_clause ::= WHEN expr */
149579 case 266: /* key_opt ::= KEY expr */ yytestcase(yyruleno==266);
149580 { yymsp[-1].minor.yy18 = yymsp[0].minor.yy18; }
@@ -148636,21 +149613,21 @@
149613 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
149614 "within triggers");
149615 }
149616 break;
149617 case 253: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
149618 {yylhsminor.yy207 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy420, yymsp[-1].minor.yy18, yymsp[-6].minor.yy70, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy392);}
149619 yymsp[-7].minor.yy207 = yylhsminor.yy207;
149620 break;
149621 case 254: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
149622 {
149623 yylhsminor.yy207 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy48,yymsp[-2].minor.yy489,yymsp[-6].minor.yy70,yymsp[-1].minor.yy340,yymsp[-7].minor.yy392,yymsp[0].minor.yy392);/*yylhsminor.yy207-overwrites-yymsp[-6].minor.yy70*/
149624 }
149625 yymsp[-7].minor.yy207 = yylhsminor.yy207;
149626 break;
149627 case 255: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
149628 {yylhsminor.yy207 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy18, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy392);}
149629 yymsp[-5].minor.yy207 = yylhsminor.yy207;
149630 break;
149631 case 256: /* trigger_cmd ::= scanpt select scanpt */
149632 {yylhsminor.yy207 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy489, yymsp[-2].minor.yy392, yymsp[0].minor.yy392); /*yylhsminor.yy207-overwrites-yymsp[-1].minor.yy489*/}
149633 yymsp[-2].minor.yy207 = yylhsminor.yy207;
@@ -148719,134 +149696,139 @@
149696 {
149697 disableLookaside(pParse);
149698 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy135);
149699 }
149700 break;
149701 case 274: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
149702 {
149703 sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy135, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
149704 }
149705 break;
149706 case 275: /* cmd ::= create_vtab */
149707 {sqlite3VtabFinishParse(pParse,0);}
149708 break;
149709 case 276: /* cmd ::= create_vtab LP vtabarglist RP */
149710 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
149711 break;
149712 case 277: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
149713 {
149714 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy70);
149715 }
149716 break;
149717 case 278: /* vtabarg ::= */
149718 {sqlite3VtabArgInit(pParse);}
149719 break;
149720 case 279: /* vtabargtoken ::= ANY */
149721 case 280: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==280);
149722 case 281: /* lp ::= LP */ yytestcase(yyruleno==281);
149723 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
149724 break;
149725 case 282: /* with ::= WITH wqlist */
149726 case 283: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==283);
149727 { sqlite3WithPush(pParse, yymsp[0].minor.yy449, 1); }
149728 break;
149729 case 284: /* wqlist ::= nm eidlist_opt AS LP select RP */
149730 {
149731 yymsp[-5].minor.yy449 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy420, yymsp[-1].minor.yy489); /*A-overwrites-X*/
149732 }
149733 break;
149734 case 285: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
149735 {
149736 yymsp[-7].minor.yy449 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy449, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy420, yymsp[-1].minor.yy489);
149737 }
149738 break;
149739 case 286: /* windowdefn_list ::= windowdefn */
149740 { yylhsminor.yy327 = yymsp[0].minor.yy327; }
149741 yymsp[0].minor.yy327 = yylhsminor.yy327;
149742 break;
149743 case 287: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
149744 {
149745 assert( yymsp[0].minor.yy327!=0 );
149746 yymsp[0].minor.yy327->pNextWin = yymsp[-2].minor.yy327;
149747 yylhsminor.yy327 = yymsp[0].minor.yy327;
149748 }
149749 yymsp[-2].minor.yy327 = yylhsminor.yy327;
149750 break;
149751 case 288: /* windowdefn ::= nm AS window */
149752 {
149753 if( ALWAYS(yymsp[0].minor.yy327) ){
149754 yymsp[0].minor.yy327->zName = sqlite3DbStrNDup(pParse->db, yymsp[-2].minor.yy0.z, yymsp[-2].minor.yy0.n);
149755 }
149756 yylhsminor.yy327 = yymsp[0].minor.yy327;
149757 }
149758 yymsp[-2].minor.yy327 = yylhsminor.yy327;
149759 break;
149760 case 289: /* window ::= LP part_opt orderby_opt frame_opt RP */
149761 {
149762 yymsp[-4].minor.yy327 = yymsp[-1].minor.yy327;
149763 if( ALWAYS(yymsp[-4].minor.yy327) ){
149764 yymsp[-4].minor.yy327->pPartition = yymsp[-3].minor.yy420;
149765 yymsp[-4].minor.yy327->pOrderBy = yymsp[-2].minor.yy420;
149766 }
149767 }
149768 break;
149769 case 290: /* part_opt ::= PARTITION BY nexprlist */
149770 { yymsp[-2].minor.yy420 = yymsp[0].minor.yy420; }
149771 break;
149772 case 291: /* part_opt ::= */
149773 { yymsp[1].minor.yy420 = 0; }
149774 break;
149775 case 292: /* frame_opt ::= */
149776 {
149777 yymsp[1].minor.yy327 = sqlite3WindowAlloc(pParse, TK_RANGE, TK_UNBOUNDED, 0, TK_CURRENT, 0);
149778 }
149779 break;
149780 case 293: /* frame_opt ::= range_or_rows frame_bound_s */
149781 {
149782 yylhsminor.yy327 = sqlite3WindowAlloc(pParse, yymsp[-1].minor.yy70, yymsp[0].minor.yy119.eType, yymsp[0].minor.yy119.pExpr, TK_CURRENT, 0);
149783 }
149784 yymsp[-1].minor.yy327 = yylhsminor.yy327;
149785 break;
149786 case 294: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
149787 {
149788 yylhsminor.yy327 = sqlite3WindowAlloc(pParse, yymsp[-4].minor.yy70, yymsp[-2].minor.yy119.eType, yymsp[-2].minor.yy119.pExpr, yymsp[0].minor.yy119.eType, yymsp[0].minor.yy119.pExpr);
149789 }
149790 yymsp[-4].minor.yy327 = yylhsminor.yy327;
149791 break;
149792 case 295: /* range_or_rows ::= RANGE */
149793 { yymsp[0].minor.yy70 = TK_RANGE; }
149794 break;
149795 case 296: /* range_or_rows ::= ROWS */
149796 { yymsp[0].minor.yy70 = TK_ROWS; }
149797 break;
149798 case 297: /* frame_bound_s ::= frame_bound */
149799 case 299: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==299);
149800 { yylhsminor.yy119 = yymsp[0].minor.yy119; }
149801 yymsp[0].minor.yy119 = yylhsminor.yy119;
149802 break;
149803 case 298: /* frame_bound_s ::= UNBOUNDED PRECEDING */
149804 case 300: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==300);
149805 {yymsp[-1].minor.yy119.eType = TK_UNBOUNDED; yymsp[-1].minor.yy119.pExpr = 0;}
149806 break;
149807 case 301: /* frame_bound ::= expr PRECEDING */
149808 { yylhsminor.yy119.eType = TK_PRECEDING; yylhsminor.yy119.pExpr = yymsp[-1].minor.yy18; }
149809 yymsp[-1].minor.yy119 = yylhsminor.yy119;
149810 break;
149811 case 302: /* frame_bound ::= CURRENT ROW */
149812 { yymsp[-1].minor.yy119.eType = TK_CURRENT ; yymsp[-1].minor.yy119.pExpr = 0; }
149813 break;
149814 case 303: /* frame_bound ::= expr FOLLOWING */
149815 { yylhsminor.yy119.eType = TK_FOLLOWING; yylhsminor.yy119.pExpr = yymsp[-1].minor.yy18; }
149816 yymsp[-1].minor.yy119 = yylhsminor.yy119;
149817 break;
149818 case 304: /* window_clause ::= WINDOW windowdefn_list */
149819 { yymsp[-1].minor.yy327 = yymsp[0].minor.yy327; }
149820 break;
149821 case 305: /* over_clause ::= filter_opt OVER window */
149822 {
149823 yylhsminor.yy327 = yymsp[0].minor.yy327;
149824 assert( yylhsminor.yy327!=0 );
149825 yylhsminor.yy327->pFilter = yymsp[-2].minor.yy18;
149826 }
149827 yymsp[-2].minor.yy327 = yylhsminor.yy327;
149828 break;
149829 case 306: /* over_clause ::= filter_opt OVER nm */
149830 {
149831 yylhsminor.yy327 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
149832 if( yylhsminor.yy327 ){
149833 yylhsminor.yy327->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
149834 yylhsminor.yy327->pFilter = yymsp[-2].minor.yy18;
@@ -148854,72 +149836,72 @@
149836 sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy18);
149837 }
149838 }
149839 yymsp[-2].minor.yy327 = yylhsminor.yy327;
149840 break;
149841 case 308: /* filter_opt ::= FILTER LP WHERE expr RP */
149842 { yymsp[-4].minor.yy18 = yymsp[-1].minor.yy18; }
149843 break;
149844 default:
149845 /* (309) input ::= cmdlist */ yytestcase(yyruleno==309);
149846 /* (310) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==310);
149847 /* (311) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=311);
149848 /* (312) ecmd ::= SEMI */ yytestcase(yyruleno==312);
149849 /* (313) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==313);
149850 /* (314) ecmd ::= explain cmdx */ yytestcase(yyruleno==314);
149851 /* (315) trans_opt ::= */ yytestcase(yyruleno==315);
149852 /* (316) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==316);
149853 /* (317) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==317);
149854 /* (318) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==318);
149855 /* (319) savepoint_opt ::= */ yytestcase(yyruleno==319);
149856 /* (320) cmd ::= create_table create_table_args */ yytestcase(yyruleno==320);
149857 /* (321) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==321);
149858 /* (322) columnlist ::= columnname carglist */ yytestcase(yyruleno==322);
149859 /* (323) nm ::= ID|INDEXED */ yytestcase(yyruleno==323);
149860 /* (324) nm ::= STRING */ yytestcase(yyruleno==324);
149861 /* (325) nm ::= JOIN_KW */ yytestcase(yyruleno==325);
149862 /* (326) typetoken ::= typename */ yytestcase(yyruleno==326);
149863 /* (327) typename ::= ID|STRING */ yytestcase(yyruleno==327);
149864 /* (328) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=328);
149865 /* (329) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=329);
149866 /* (330) carglist ::= carglist ccons */ yytestcase(yyruleno==330);
149867 /* (331) carglist ::= */ yytestcase(yyruleno==331);
149868 /* (332) ccons ::= NULL onconf */ yytestcase(yyruleno==332);
149869 /* (333) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==333);
149870 /* (334) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==334);
149871 /* (335) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=335);
149872 /* (336) tconscomma ::= */ yytestcase(yyruleno==336);
149873 /* (337) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=337);
149874 /* (338) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=338);
149875 /* (339) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=339);
149876 /* (340) oneselect ::= values */ yytestcase(yyruleno==340);
149877 /* (341) sclp ::= selcollist COMMA */ yytestcase(yyruleno==341);
149878 /* (342) as ::= ID|STRING */ yytestcase(yyruleno==342);
149879 /* (343) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=343);
149880 /* (344) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==344);
149881 /* (345) exprlist ::= nexprlist */ yytestcase(yyruleno==345);
149882 /* (346) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=346);
149883 /* (347) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=347);
149884 /* (348) nmnum ::= ON */ yytestcase(yyruleno==348);
149885 /* (349) nmnum ::= DELETE */ yytestcase(yyruleno==349);
149886 /* (350) nmnum ::= DEFAULT */ yytestcase(yyruleno==350);
149887 /* (351) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==351);
149888 /* (352) foreach_clause ::= */ yytestcase(yyruleno==352);
149889 /* (353) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==353);
149890 /* (354) trnm ::= nm */ yytestcase(yyruleno==354);
149891 /* (355) tridxby ::= */ yytestcase(yyruleno==355);
149892 /* (356) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==356);
149893 /* (357) database_kw_opt ::= */ yytestcase(yyruleno==357);
149894 /* (358) kwcolumn_opt ::= */ yytestcase(yyruleno==358);
149895 /* (359) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==359);
149896 /* (360) vtabarglist ::= vtabarg */ yytestcase(yyruleno==360);
149897 /* (361) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==361);
149898 /* (362) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==362);
149899 /* (363) anylist ::= */ yytestcase(yyruleno==363);
149900 /* (364) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==364);
149901 /* (365) anylist ::= anylist ANY */ yytestcase(yyruleno==365);
149902 /* (366) with ::= */ yytestcase(yyruleno==366);
149903 break;
149904 /********** End reduce actions ************************************************/
149905 };
149906 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
149907 yygoto = yyRuleInfo[yyruleno].lhs;
@@ -149738,14 +150720,12 @@
150720 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, /* Fx */
150721 };
150722 #define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40]))
150723 #endif
150724
150725 /* Make the IdChar function accessible from ctime.c and alter.c */
 
150726 SQLITE_PRIVATE int sqlite3IsIdChar(u8 c){ return IdChar(c); }
 
150727
150728 #ifndef SQLITE_OMIT_WINDOWFUNC
150729 /*
150730 ** Return the id of the next token in string (*pz). Before returning, set
150731 ** (*pz) to point to the byte following the parsed token.
@@ -150244,20 +151224,22 @@
151224 #endif
151225 #ifndef SQLITE_OMIT_VIRTUALTABLE
151226 sqlite3_free(pParse->apVtabLock);
151227 #endif
151228
151229 if( !IN_SPECIAL_PARSE ){
151230 /* If the pParse->declareVtab flag is set, do not delete any table
151231 ** structure built up in pParse->pNewTable. The calling code (see vtab.c)
151232 ** will take responsibility for freeing the Table structure.
151233 */
151234 sqlite3DeleteTable(db, pParse->pNewTable);
151235 }
151236 if( !IN_RENAME_OBJECT ){
151237 sqlite3DeleteTrigger(db, pParse->pNewTrigger);
151238 }
151239
151240 if( pParse->pWithToFree ) sqlite3WithDelete(db, pParse->pWithToFree);
 
151241 sqlite3DbFree(db, pParse->pVList);
151242 while( pParse->pAinc ){
151243 AutoincInfo *p = pParse->pAinc;
151244 pParse->pAinc = p->pNext;
151245 sqlite3DbFreeNN(db, p);
@@ -151990,10 +152972,11 @@
152972 int i, origRc = rc;
152973 for(i=0; i<2 && zName==0; i++, rc &= 0xff){
152974 switch( rc ){
152975 case SQLITE_OK: zName = "SQLITE_OK"; break;
152976 case SQLITE_ERROR: zName = "SQLITE_ERROR"; break;
152977 case SQLITE_ERROR_SNAPSHOT: zName = "SQLITE_ERROR_SNAPSHOT"; break;
152978 case SQLITE_INTERNAL: zName = "SQLITE_INTERNAL"; break;
152979 case SQLITE_PERM: zName = "SQLITE_PERM"; break;
152980 case SQLITE_ABORT: zName = "SQLITE_ABORT"; break;
152981 case SQLITE_ABORT_ROLLBACK: zName = "SQLITE_ABORT_ROLLBACK"; break;
152982 case SQLITE_BUSY: zName = "SQLITE_BUSY"; break;
@@ -181429,11 +182412,11 @@
182412 s.z++;
182413 while( geopolySkipSpace(&s)=='[' ){
182414 int ii = 0;
182415 char c;
182416 s.z++;
182417 if( s.nVertex>=s.nAlloc ){
182418 GeoCoord *aNew;
182419 s.nAlloc = s.nAlloc*2 + 16;
182420 aNew = sqlite3_realloc64(s.a, s.nAlloc*sizeof(GeoCoord)*2 );
182421 if( aNew==0 ){
182422 rc = SQLITE_NOMEM;
@@ -181511,11 +182494,11 @@
182494 ){
182495 const unsigned char *a = sqlite3_value_blob(pVal);
182496 int nVertex;
182497 nVertex = (a[1]<<16) + (a[2]<<8) + a[3];
182498 if( (a[0]==0 || a[0]==1)
182499 && (nVertex*2*sizeof(GeoCoord) + 4)==(unsigned int)nByte
182500 ){
182501 p = sqlite3_malloc64( sizeof(*p) + (nVertex-1)*2*sizeof(GeoCoord) );
182502 if( p==0 ){
182503 if( pRc ) *pRc = SQLITE_NOMEM;
182504 if( pCtx ) sqlite3_result_error_nomem(pCtx);
@@ -182764,11 +183747,11 @@
183747 }
183748 }
183749 }
183750
183751 /* Change the data */
183752 if( rc==SQLITE_OK && nData>1 ){
183753 sqlite3_stmt *pUp = pRtree->pWriteAux;
183754 int jj;
183755 int nChange = 0;
183756 sqlite3_bind_int64(pUp, 1, cell.iRowid);
183757 assert( pRtree->nAux>=1 );
@@ -210980,11 +211963,11 @@
211963 break;
211964
211965 case FTS5_SAVEPOINT:
211966 assert( p->ts.eState==1 );
211967 assert( iSavepoint>=0 );
211968 assert( iSavepoint>=p->ts.iSavepoint );
211969 p->ts.iSavepoint = iSavepoint;
211970 break;
211971
211972 case FTS5_RELEASE:
211973 assert( p->ts.eState==1 );
@@ -211905,10 +212888,17 @@
212888 ** fts5CursorFirstSorted() above. */
212889 assert( pRowidEq==0 && pRowidLe==0 && pRowidGe==0 && pRank==0 );
212890 assert( nVal==0 && pMatch==0 && bOrderByRank==0 && bDesc==0 );
212891 assert( pCsr->iLastRowid==LARGEST_INT64 );
212892 assert( pCsr->iFirstRowid==SMALLEST_INT64 );
212893 if( pTab->pSortCsr->bDesc ){
212894 pCsr->iLastRowid = pTab->pSortCsr->iFirstRowid;
212895 pCsr->iFirstRowid = pTab->pSortCsr->iLastRowid;
212896 }else{
212897 pCsr->iLastRowid = pTab->pSortCsr->iLastRowid;
212898 pCsr->iFirstRowid = pTab->pSortCsr->iFirstRowid;
212899 }
212900 pCsr->ePlan = FTS5_PLAN_SOURCE;
212901 pCsr->pExpr = pTab->pSortCsr->pExpr;
212902 rc = fts5CursorFirst(pTab, pCsr, bDesc);
212903 }else if( pMatch ){
212904 const char *zExpr = (const char*)sqlite3_value_text(apVal[0]);
@@ -213335,11 +214325,11 @@
214325 int nArg, /* Number of args */
214326 sqlite3_value **apUnused /* Function arguments */
214327 ){
214328 assert( nArg==0 );
214329 UNUSED_PARAM2(nArg, apUnused);
214330 sqlite3_result_text(pCtx, "fts5: 2018-09-06 18:56:36 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5d3c3", -1, SQLITE_TRANSIENT);
214331 }
214332
214333 static int fts5Init(sqlite3 *db){
214334 static const sqlite3_module fts5Mod = {
214335 /* iVersion */ 2,
@@ -218045,12 +219035,12 @@
219035 }
219036 #endif /* SQLITE_CORE */
219037 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
219038
219039 /************** End of stmt.c ************************************************/
219040 #if __LINE__!=219040
219041 #undef SQLITE_SOURCE_ID
219042 #define SQLITE_SOURCE_ID "2018-09-06 18:56:36 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5alt2"
219043 #endif
219044 /* Return the source-id for this library */
219045 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
219046 /************************** End of sqlite3.c ******************************/
219047
+4 -3
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126126
#define SQLITE_VERSION "3.25.0"
127127
#define SQLITE_VERSION_NUMBER 3025000
128
-#define SQLITE_SOURCE_ID "2018-08-30 01:52:10 58078c0d2647a194279fa80e032670441b296ffc3acee692901faa5beca460b7"
128
+#define SQLITE_SOURCE_ID "2018-09-06 18:56:36 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5d3c3"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
@@ -470,10 +470,11 @@
470470
** the most recent error can be obtained using
471471
** [sqlite3_extended_errcode()].
472472
*/
473473
#define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
474474
#define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
475
+#define SQLITE_ERROR_SNAPSHOT (SQLITE_ERROR | (3<<8))
475476
#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
476477
#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
477478
#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
478479
#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
479480
#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -9051,15 +9052,15 @@
90519052
** SQLITE_ERROR is returned if either of these conditions is violated, or
90529053
** if schema S does not exist, or if the snapshot object is invalid.
90539054
**
90549055
** ^A call to sqlite3_snapshot_open() will fail to open if the specified
90559056
** snapshot has been overwritten by a [checkpoint]. In this case
9056
-** SQLITE_BUSY_SNAPSHOT is returned.
9057
+** SQLITE_ERROR_SNAPSHOT is returned.
90579058
**
90589059
** If there is already a read transaction open when this function is
90599060
** invoked, then the same read transaction remains open (on the same
9060
-** database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_BUSY_SNAPSHOT
9061
+** database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_ERROR_SNAPSHOT
90619062
** is returned. If another error code - for example SQLITE_PROTOCOL or an
90629063
** SQLITE_IOERR error code - is returned, then the final state of the
90639064
** read transaction is undefined. If SQLITE_OK is returned, then the
90649065
** read transaction is now open on database snapshot P.
90659066
**
90669067
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.25.0"
127 #define SQLITE_VERSION_NUMBER 3025000
128 #define SQLITE_SOURCE_ID "2018-08-30 01:52:10 58078c0d2647a194279fa80e032670441b296ffc3acee692901faa5beca460b7"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -470,10 +470,11 @@
470 ** the most recent error can be obtained using
471 ** [sqlite3_extended_errcode()].
472 */
473 #define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
474 #define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
 
475 #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
476 #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
477 #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
478 #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
479 #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -9051,15 +9052,15 @@
9051 ** SQLITE_ERROR is returned if either of these conditions is violated, or
9052 ** if schema S does not exist, or if the snapshot object is invalid.
9053 **
9054 ** ^A call to sqlite3_snapshot_open() will fail to open if the specified
9055 ** snapshot has been overwritten by a [checkpoint]. In this case
9056 ** SQLITE_BUSY_SNAPSHOT is returned.
9057 **
9058 ** If there is already a read transaction open when this function is
9059 ** invoked, then the same read transaction remains open (on the same
9060 ** database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_BUSY_SNAPSHOT
9061 ** is returned. If another error code - for example SQLITE_PROTOCOL or an
9062 ** SQLITE_IOERR error code - is returned, then the final state of the
9063 ** read transaction is undefined. If SQLITE_OK is returned, then the
9064 ** read transaction is now open on database snapshot P.
9065 **
9066
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.25.0"
127 #define SQLITE_VERSION_NUMBER 3025000
128 #define SQLITE_SOURCE_ID "2018-09-06 18:56:36 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5d3c3"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -470,10 +470,11 @@
470 ** the most recent error can be obtained using
471 ** [sqlite3_extended_errcode()].
472 */
473 #define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
474 #define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
475 #define SQLITE_ERROR_SNAPSHOT (SQLITE_ERROR | (3<<8))
476 #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
477 #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
478 #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
479 #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
480 #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -9051,15 +9052,15 @@
9052 ** SQLITE_ERROR is returned if either of these conditions is violated, or
9053 ** if schema S does not exist, or if the snapshot object is invalid.
9054 **
9055 ** ^A call to sqlite3_snapshot_open() will fail to open if the specified
9056 ** snapshot has been overwritten by a [checkpoint]. In this case
9057 ** SQLITE_ERROR_SNAPSHOT is returned.
9058 **
9059 ** If there is already a read transaction open when this function is
9060 ** invoked, then the same read transaction remains open (on the same
9061 ** database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_ERROR_SNAPSHOT
9062 ** is returned. If another error code - for example SQLITE_PROTOCOL or an
9063 ** SQLITE_IOERR error code - is returned, then the final state of the
9064 ** read transaction is undefined. If SQLITE_OK is returned, then the
9065 ** read transaction is now open on database snapshot P.
9066 **
9067

Keyboard Shortcuts

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