Fossil

Check-in [87f3c946]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merge trunk. Update to Beta 2 of OpenSSL 1.1.1 (with TLS 1.3 support !!!)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | openssl-1.1
Files: files | file ages | folders
SHA3-256: 87f3c9467735e641c5c2cf0e05e7745d597ba12d06f539a5fb95dafa57eb7a9e
User & Date: jan.nijtmans 2018-04-11 08:16:08.548
Context
2018-08-23
15:14
Merge trunk. Update to Beta 7 of OpenSSL 1.1.1 (pre release 9, with TLS 1.3 support !!!) ... (check-in: cbdbc0a0 user: jan.nijtmans tags: openssl-1.1)
2018-04-11
08:16
Merge trunk. Update to Beta 2 of OpenSSL 1.1.1 (with TLS 1.3 support !!!) ... (check-in: 87f3c946 user: jan.nijtmans tags: openssl-1.1)
2018-04-10
17:48
Update the built-in SQLite to version 3.23.1. ... (check-in: 52b3b8ed user: drh tags: trunk)
2018-03-28
08:06
Merge trunk ... (check-in: d9573d87 user: jan.nijtmans tags: openssl-1.1)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/blob.c.
112
113
114
115
116
117
118








119
120
121
122
123
124
125
}
int fossil_isalpha(char c){
  return (c>='a' && c<='z') || (c>='A' && c<='Z');
}
int fossil_isalnum(char c){
  return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9');
}










/*
** COMMAND: test-isspace
**
** Verify that the fossil_isspace() routine is working correctly by
** testing it on all possible inputs.







>
>
>
>
>
>
>
>







112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
}
int fossil_isalpha(char c){
  return (c>='a' && c<='z') || (c>='A' && c<='Z');
}
int fossil_isalnum(char c){
  return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9');
}

/* Return true if and only if the entire string consists of only
** alphanumeric characters.
*/
int fossil_no_strange_characters(const char *z){
  while( z && (fossil_isalnum(z[0]) || z[0]=='_' || z[0]=='-') ) z++;
  return z[0]==0;
}


/*
** COMMAND: test-isspace
**
** Verify that the fossil_isspace() routine is working correctly by
** testing it on all possible inputs.
Changes to src/cache.c.
163
164
165
166
167
168
169
170







171
172
173
174
175
176

177
178
179
180
181
182
183
  sqlite3_bind_text(pStmt, 1, zKey, -1, SQLITE_STATIC);
  sqlite3_bind_int(pStmt, 2, blob_size(pContent));
  sqlite3_bind_int(pStmt, 3, sqlite3_last_insert_rowid(db));
  if( sqlite3_step(pStmt)!=SQLITE_DONE) goto cache_write_end;
  rc = sqlite3_changes(db);

  /* If the write was successful, truncate the cache to keep at most
  ** max-cache-entry entries in the cache */







  if( rc ){
    nKeep = db_get_int("max-cache-entry",10);
    sqlite3_finalize(pStmt);
    pStmt = cacheStmt(db,
                 "DELETE FROM cache WHERE rowid IN ("
                    "SELECT rowid FROM cache ORDER BY tm DESC"

                    " LIMIT -1 OFFSET ?1)");
    if( pStmt ){
      sqlite3_bind_int(pStmt, 1, nKeep);
      sqlite3_step(pStmt);
    }
  }








|
>
>
>
>
>
>
>





|
>







163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
  sqlite3_bind_text(pStmt, 1, zKey, -1, SQLITE_STATIC);
  sqlite3_bind_int(pStmt, 2, blob_size(pContent));
  sqlite3_bind_int(pStmt, 3, sqlite3_last_insert_rowid(db));
  if( sqlite3_step(pStmt)!=SQLITE_DONE) goto cache_write_end;
  rc = sqlite3_changes(db);

  /* If the write was successful, truncate the cache to keep at most
  ** max-cache-entry entries in the cache.
  **
  ** The cache entry replacement algorithm is approximately LRU
  ** (least recently used).  However, each access of an entry buys
  ** that entry an extra hour of grace, so that more commonly accessed
  ** entries are held in cache longer.  The extra "grace" allotted to
  ** an entry is limited to 2 days worth.
  */
  if( rc ){
    nKeep = db_get_int("max-cache-entry",10);
    sqlite3_finalize(pStmt);
    pStmt = cacheStmt(db,
                 "DELETE FROM cache WHERE rowid IN ("
                    "SELECT rowid FROM cache"
                    " ORDER BY (tm + 3600*min(nRef,48)) DESC"
                    " LIMIT -1 OFFSET ?1)");
    if( pStmt ){
      sqlite3_bind_int(pStmt, 1, nKeep);
      sqlite3_step(pStmt);
    }
  }

289
290
291
292
293
294
295
296

297
298
299
300
301
302
303
    if( db ){
      sqlite3_exec(db, "DELETE FROM cache; DELETE FROM blob; VACUUM;",0,0,0);
      sqlite3_close(db);
      fossil_print("cache cleared\n");
    }else{
      fossil_print("nothing to clear; cache does not exist\n");
    }
  }else if(( strncmp(zCmd, "list", nCmd)==0 ) || ( strncmp(zCmd, "ls", nCmd)==0 )){

    db = cacheOpen(0);
    if( db==0 ){
      fossil_print("cache does not exist\n");
    }else{
      int nEntry = 0;
      char *zDbName = cacheName();
      cache_register_sizename(db);







|
>







297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
    if( db ){
      sqlite3_exec(db, "DELETE FROM cache; DELETE FROM blob; VACUUM;",0,0,0);
      sqlite3_close(db);
      fossil_print("cache cleared\n");
    }else{
      fossil_print("nothing to clear; cache does not exist\n");
    }
  }else if(( strncmp(zCmd, "list", nCmd)==0 )
             || ( strncmp(zCmd, "ls", nCmd)==0 )){
    db = cacheOpen(0);
    if( db==0 ){
      fossil_print("cache does not exist\n");
    }else{
      int nEntry = 0;
      char *zDbName = cacheName();
      cache_register_sizename(db);
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
    @ The web-page cache is disabled for this repository
  }else{
    char *zDbName = cacheName();
    cache_register_sizename(db);
    pStmt = cacheStmt(db,
         "SELECT key, sizename(sz), nRef, datetime(tm,'unixepoch')"
         "  FROM cache"
         " ORDER BY tm DESC"
    );
    if( pStmt ){
      @ <ol>
      while( sqlite3_step(pStmt)==SQLITE_ROW ){
        const unsigned char *zName = sqlite3_column_text(pStmt,0);
        @ <li><p>%z(href("%R/cacheget?key=%T",zName))%h(zName)</a><br />
        @ size: %s(sqlite3_column_text(pStmt,1))







|







357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
    @ The web-page cache is disabled for this repository
  }else{
    char *zDbName = cacheName();
    cache_register_sizename(db);
    pStmt = cacheStmt(db,
         "SELECT key, sizename(sz), nRef, datetime(tm,'unixepoch')"
         "  FROM cache"
         " ORDER BY (tm + 3600*min(nRef,48)) DESC"
    );
    if( pStmt ){
      @ <ol>
      while( sqlite3_step(pStmt)==SQLITE_ROW ){
        const unsigned char *zName = sqlite3_column_text(pStmt,0);
        @ <li><p>%z(href("%R/cacheget?key=%T",zName))%h(zName)</a><br />
        @ size: %s(sqlite3_column_text(pStmt,1))
Changes to src/cgi.c.
553
554
555
556
557
558
559





560
561
562
563
564
565
566
**
**      *  cookies and query parameters that have uppercase names
**         are ignored.
**
**      *  it is impossible for a cookie or query parameter to
**         override the value of an environment variable since
**         environment variables always have uppercase names.





**
** Parameters are separated by the "terminator" character.  Whitespace
** before the NAME is ignored.
**
** The input string "z" is modified but no copies is made.  "z"
** should not be deallocated or changed again after this routine
** returns or it will corrupt the parameter table.







>
>
>
>
>







553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
**
**      *  cookies and query parameters that have uppercase names
**         are ignored.
**
**      *  it is impossible for a cookie or query parameter to
**         override the value of an environment variable since
**         environment variables always have uppercase names.
**
** 2018-03-29:  Also ignore the entry if NAME that contains any characters
** other than [a-zA-Z0-9_].  There are no known exploits involving unusual
** names that contain characters outside that set, but it never hurts to
** be extra cautious when sanitizing inputs.
**
** Parameters are separated by the "terminator" character.  Whitespace
** before the NAME is ignored.
**
** The input string "z" is modified but no copies is made.  "z"
** should not be deallocated or changed again after this routine
** returns or it will corrupt the parameter table.
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
        z++;
      }
      dehttpize(zValue);
    }else{
      if( *z ){ *z++ = 0; }
      zValue = "";
    }
    if( fossil_islower(zName[0]) ){
      cgi_set_parameter_nocopy(zName, zValue, isQP);
    }
#ifdef FOSSIL_ENABLE_JSON
    json_setenv( zName, cson_value_new_string(zValue,strlen(zValue)) );
#endif /* FOSSIL_ENABLE_JSON */
  }
}







|







588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
        z++;
      }
      dehttpize(zValue);
    }else{
      if( *z ){ *z++ = 0; }
      zValue = "";
    }
    if( fossil_islower(zName[0]) && fossil_no_strange_characters(zName+1) ){
      cgi_set_parameter_nocopy(zName, zValue, isQP);
    }
#ifdef FOSSIL_ENABLE_JSON
    json_setenv( zName, cson_value_new_string(zValue,strlen(zValue)) );
#endif /* FOSSIL_ENABLE_JSON */
  }
}
Changes to src/clone.c.
315
316
317
318
319
320
321
322
323
324
325


326
327
328
329
330
331
332
    }else{
      @ Contact the site administrator and ask them to give
      @ you "Download Zip" privileges.
    }
  }else{
    const char *zDLTag = db_get("download-tag","trunk");
    const char *zNm = db_get("short-project-name","download");
    char *zUrl = href("%R/zip/%t.zip?uuid=%t", zNm, zDLTag);
    @ <p>ZIP Archive: %z(zUrl)%h(zNm).zip</a>
    zUrl = href("%R/tarball/%t.tar.gz?uuid=%t", zNm, zDLTag);
    @ <p>Tarball: %z(zUrl)%h(zNm).tar.gz</a>


  }
  if( !g.perm.Clone ){
    @ <p>You are not authorized to clone this repository.
    if( g.zLogin==0 || g.zLogin[0]==0 ){
      @ Maybe you would be able to clone if you
      @ <a href="../login">logged in</a>.
    }else{







|

|

>
>







315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
    }else{
      @ Contact the site administrator and ask them to give
      @ you "Download Zip" privileges.
    }
  }else{
    const char *zDLTag = db_get("download-tag","trunk");
    const char *zNm = db_get("short-project-name","download");
    char *zUrl = href("%R/zip/%t/%t.zip", zDLTag, zNm);
    @ <p>ZIP Archive: %z(zUrl)%h(zNm).zip</a>
    zUrl = href("%R/tarball/%t/%t.tar.gz", zDLTag, zNm);
    @ <p>Tarball: %z(zUrl)%h(zNm).tar.gz</a>
    zUrl = href("%R/sqlar/%t/%t.sqlar", zDLTag, zNm);
    @ <p>SQLite Archive: %z(zUrl)%h(zNm).sqlar</a>
  }
  if( !g.perm.Clone ){
    @ <p>You are not authorized to clone this repository.
    if( g.zLogin==0 || g.zLogin[0]==0 ){
      @ Maybe you would be able to clone if you
      @ <a href="../login">logged in</a>.
    }else{
Changes to src/info.c.
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
      blob_trim(&projName);
      zPJ = blob_str(&projName);
      for(jj=0; zPJ[jj]; jj++){
        if( (zPJ[jj]>0 && zPJ[jj]<' ') || strchr("\"*/:<>?\\|", zPJ[jj]) ){
          zPJ[jj] = '_';
        }
      }
      zUrl = mprintf("%R/tarball/%t-%S.tar.gz?r=%s", zPJ, zUuid, zUuid);
      @ <tr><th>Downloads:</th><td>
      @ %z(href("%s",zUrl))Tarball</a>
      @ | %z(href("%R/zip/%t-%S.zip?r=%!S",zPJ,zUuid,zUuid))ZIP archive</a>
      @ | %z(href("%R/sqlar/%t-%S.sqlar?r=%!S",zPJ,zUuid,zUuid))\
      @ SQL archive</a></td></tr>
      fossil_free(zUrl);
      blob_reset(&projName);
    }

    @ <tr><th>Timelines:</th><td>
    @   %z(href("%R/timeline?f=%!S&unhide",zUuid))family</a>







|


|
|







712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
      blob_trim(&projName);
      zPJ = blob_str(&projName);
      for(jj=0; zPJ[jj]; jj++){
        if( (zPJ[jj]>0 && zPJ[jj]<' ') || strchr("\"*/:<>?\\|", zPJ[jj]) ){
          zPJ[jj] = '_';
        }
      }
      zUrl = mprintf("%R/tarball/%S/%t-%S.tar.gz", zUuid, zPJ, zUuid);
      @ <tr><th>Downloads:</th><td>
      @ %z(href("%s",zUrl))Tarball</a>
      @ | %z(href("%R/zip/%S/%t-%S.zip",zUuid, zPJ,zUuid))ZIP archive</a>
      @ | %z(href("%R/sqlar/%S/%t-%S.sqlar",zUuid,zPJ,zUuid))\
      @ SQL archive</a></td></tr>
      fossil_free(zUrl);
      blob_reset(&projName);
    }

    @ <tr><th>Timelines:</th><td>
    @   %z(href("%R/timeline?f=%!S&unhide",zUuid))family</a>
Changes to src/main.mk.
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
                 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                 -DSQLITE_ENABLE_FTS4 \
                 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
                 -DSQLITE_ENABLE_DBSTAT_VTAB \
                 -DSQLITE_ENABLE_JSON1 \
                 -DSQLITE_ENABLE_FTS5 \
                 -DSQLITE_ENABLE_STMTVTAB \
                 -DSQLITE_USE_ZLIB \
                 -DSQLITE_INTROSPECTION_PRAGMAS \
                 -DSQLITE_ENABLE_DBPAGE_VTAB

# Setup the options used to compile the included SQLite shell.
SHELL_OPTIONS = -DNDEBUG=1 \
                -DSQLITE_THREADSAFE=0 \
                -DSQLITE_DEFAULT_MEMSTATUS=0 \







|







553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
                 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                 -DSQLITE_ENABLE_FTS4 \
                 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
                 -DSQLITE_ENABLE_DBSTAT_VTAB \
                 -DSQLITE_ENABLE_JSON1 \
                 -DSQLITE_ENABLE_FTS5 \
                 -DSQLITE_ENABLE_STMTVTAB \
                 -DSQLITE_HAVE_ZLIB \
                 -DSQLITE_INTROSPECTION_PRAGMAS \
                 -DSQLITE_ENABLE_DBPAGE_VTAB

# Setup the options used to compile the included SQLite shell.
SHELL_OPTIONS = -DNDEBUG=1 \
                -DSQLITE_THREADSAFE=0 \
                -DSQLITE_DEFAULT_MEMSTATUS=0 \
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
                -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                -DSQLITE_ENABLE_FTS4 \
                -DSQLITE_ENABLE_FTS3_PARENTHESIS \
                -DSQLITE_ENABLE_DBSTAT_VTAB \
                -DSQLITE_ENABLE_JSON1 \
                -DSQLITE_ENABLE_FTS5 \
                -DSQLITE_ENABLE_STMTVTAB \
                -DSQLITE_USE_ZLIB \
                -DSQLITE_INTROSPECTION_PRAGMAS \
                -DSQLITE_ENABLE_DBPAGE_VTAB \
                -Dmain=sqlite3_shell \
                -DSQLITE_SHELL_IS_UTF8=1 \
                -DSQLITE_OMIT_LOAD_EXTENSION=1 \
                -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
                -DSQLITE_SHELL_DBNAME_PROC=fossil_open







|







580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
                -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                -DSQLITE_ENABLE_FTS4 \
                -DSQLITE_ENABLE_FTS3_PARENTHESIS \
                -DSQLITE_ENABLE_DBSTAT_VTAB \
                -DSQLITE_ENABLE_JSON1 \
                -DSQLITE_ENABLE_FTS5 \
                -DSQLITE_ENABLE_STMTVTAB \
                -DSQLITE_HAVE_ZLIB \
                -DSQLITE_INTROSPECTION_PRAGMAS \
                -DSQLITE_ENABLE_DBPAGE_VTAB \
                -Dmain=sqlite3_shell \
                -DSQLITE_SHELL_IS_UTF8=1 \
                -DSQLITE_OMIT_LOAD_EXTENSION=1 \
                -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
                -DSQLITE_SHELL_DBNAME_PROC=fossil_open
Changes to src/makemake.tcl.
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
  -DSQLITE_ENABLE_EXPLAIN_COMMENTS
  -DSQLITE_ENABLE_FTS4
  -DSQLITE_ENABLE_FTS3_PARENTHESIS
  -DSQLITE_ENABLE_DBSTAT_VTAB
  -DSQLITE_ENABLE_JSON1
  -DSQLITE_ENABLE_FTS5
  -DSQLITE_ENABLE_STMTVTAB
  -DSQLITE_USE_ZLIB
  -DSQLITE_INTROSPECTION_PRAGMAS
  -DSQLITE_ENABLE_DBPAGE_VTAB
}
#lappend SQLITE_OPTIONS -DSQLITE_ENABLE_FTS3=1
#lappend SQLITE_OPTIONS -DSQLITE_ENABLE_STAT4
#lappend SQLITE_OPTIONS -DSQLITE_WIN32_NO_ANSI
#lappend SQLITE_OPTIONS -DSQLITE_WINNT_MAX_PATH_CHARS=4096







|







188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
  -DSQLITE_ENABLE_EXPLAIN_COMMENTS
  -DSQLITE_ENABLE_FTS4
  -DSQLITE_ENABLE_FTS3_PARENTHESIS
  -DSQLITE_ENABLE_DBSTAT_VTAB
  -DSQLITE_ENABLE_JSON1
  -DSQLITE_ENABLE_FTS5
  -DSQLITE_ENABLE_STMTVTAB
  -DSQLITE_HAVE_ZLIB
  -DSQLITE_INTROSPECTION_PRAGMAS
  -DSQLITE_ENABLE_DBPAGE_VTAB
}
#lappend SQLITE_OPTIONS -DSQLITE_ENABLE_FTS3=1
#lappend SQLITE_OPTIONS -DSQLITE_ENABLE_STAT4
#lappend SQLITE_OPTIONS -DSQLITE_WIN32_NO_ANSI
#lappend SQLITE_OPTIONS -DSQLITE_WINNT_MAX_PATH_CHARS=4096
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
endif

#### The directories where the OpenSSL include and library files are located.
#    The recommended usage here is to use the Sysinternals junction tool
#    to create a hard link between an "openssl-1.x" sub-directory of the
#    Fossil source code directory and the target OpenSSL source directory.
#
OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.1.0h
OPENSSLINCDIR = $(OPENSSLDIR)/include
OPENSSLLIBDIR = $(OPENSSLDIR)

#### Either the directory where the Tcl library is installed or the Tcl
#    source code directory resides (depending on the value of the macro
#    FOSSIL_TCL_SOURCE).  If this points to the Tcl install directory,
#    this directory must have "include" and "lib" sub-directories.  If







|







699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
endif

#### The directories where the OpenSSL include and library files are located.
#    The recommended usage here is to use the Sysinternals junction tool
#    to create a hard link between an "openssl-1.x" sub-directory of the
#    Fossil source code directory and the target OpenSSL source directory.
#
OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.1.1-pre4
OPENSSLINCDIR = $(OPENSSLDIR)/include
OPENSSLLIBDIR = $(OPENSSLDIR)

#### Either the directory where the Tcl library is installed or the Tcl
#    source code directory resides (depending on the value of the macro
#    FOSSIL_TCL_SOURCE).  If this points to the Tcl install directory,
#    this directory must have "include" and "lib" sub-directories.  If
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565

# Enable support for the SQLite Encryption Extension?
!ifndef USE_SEE
USE_SEE = 0
!endif

!if $(FOSSIL_ENABLE_SSL)!=0
SSLDIR    = $(B)\compat\openssl-1.1.0h
SSLINCDIR = $(SSLDIR)\inc32
!if $(FOSSIL_DYNAMIC_BUILD)!=0
SSLLIBDIR = $(SSLDIR)\out32dll
!else
SSLLIBDIR = $(SSLDIR)\out32
!endif
SSLLFLAGS = /nologo /opt:ref /debug







|







1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565

# Enable support for the SQLite Encryption Extension?
!ifndef USE_SEE
USE_SEE = 0
!endif

!if $(FOSSIL_ENABLE_SSL)!=0
SSLDIR    = $(B)\compat\openssl-1.1.1-pre4
SSLINCDIR = $(SSLDIR)\inc32
!if $(FOSSIL_DYNAMIC_BUILD)!=0
SSLLIBDIR = $(SSLDIR)\out32dll
!else
SSLLIBDIR = $(SSLDIR)\out32
!endif
SSLLFLAGS = /nologo /opt:ref /debug
Changes to src/shell.c.
146
147
148
149
150
151
152



153
154
155
156
157
158
159
#if defined(_WIN32) || defined(WIN32)
# include <io.h>
# include <fcntl.h>
# define isatty(h) _isatty(h)
# ifndef access
#  define access(f,m) _access((f),(m))
# endif



# undef popen
# define popen _popen
# undef pclose
# define pclose _pclose
#else
 /* Make sure isatty() has a prototype. */
 extern int isatty(int);







>
>
>







146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#if defined(_WIN32) || defined(WIN32)
# include <io.h>
# include <fcntl.h>
# define isatty(h) _isatty(h)
# ifndef access
#  define access(f,m) _access((f),(m))
# endif
# ifndef unlink
#  define unlink _unlink
# endif
# undef popen
# define popen _popen
# undef pclose
# define pclose _pclose
#else
 /* Make sure isatty() has a prototype. */
 extern int isatty(int);
2138
2139
2140
2141
2142
2143
2144



2145
2146
2147
2148
2149
2150
2151
#  include <sys/time.h>
#else
#  include "windows.h"
#  include <io.h>
#  include <direct.h>
/* #  include "test_windirent.h" */
#  define dirent DIRENT



#  ifndef stat
#    define stat _stat
#  endif
#  define mkdir(path,mode) _mkdir(path)
#  define lstat(path,buf) stat(path,buf)
#endif
#include <time.h>







>
>
>







2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
#  include <sys/time.h>
#else
#  include "windows.h"
#  include <io.h>
#  include <direct.h>
/* #  include "test_windirent.h" */
#  define dirent DIRENT
#  ifndef chmod
#    define chmod _chmod
#  endif
#  ifndef stat
#    define stat _stat
#  endif
#  define mkdir(path,mode) _mkdir(path)
#  define lstat(path,buf) stat(path,buf)
#endif
#include <time.h>
6123
6124
6125
6126
6127
6128
6129

6130
6131
6132

6133
6134
6135
6136
6137
6138
6139

  /* Append the LFH to the body of the new archive */
  nByte = ZIPFILE_LFH_FIXED_SZ + e.cds.nFile + 9;
  if( (rc = zipfileBufferGrow(&p->body, nByte)) ) goto zipfile_step_out;
  p->body.n += zipfileSerializeLFH(&e, &p->body.a[p->body.n]);

  /* Append the data to the body of the new archive */

  if( (rc = zipfileBufferGrow(&p->body, nData)) ) goto zipfile_step_out;
  memcpy(&p->body.a[p->body.n], aData, nData);
  p->body.n += nData;


  /* Append the CDS record to the directory of the new archive */
  nByte = ZIPFILE_CDS_FIXED_SZ + e.cds.nFile + 9;
  if( (rc = zipfileBufferGrow(&p->cds, nByte)) ) goto zipfile_step_out;
  p->cds.n += zipfileSerializeCDS(&e, &p->cds.a[p->cds.n]);

  /* Increment the count of entries in the archive */







>
|
|
|
>







6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147

  /* Append the LFH to the body of the new archive */
  nByte = ZIPFILE_LFH_FIXED_SZ + e.cds.nFile + 9;
  if( (rc = zipfileBufferGrow(&p->body, nByte)) ) goto zipfile_step_out;
  p->body.n += zipfileSerializeLFH(&e, &p->body.a[p->body.n]);

  /* Append the data to the body of the new archive */
  if( nData>0 ){
    if( (rc = zipfileBufferGrow(&p->body, nData)) ) goto zipfile_step_out;
    memcpy(&p->body.a[p->body.n], aData, nData);
    p->body.n += nData;
  }

  /* Append the CDS record to the directory of the new archive */
  nByte = ZIPFILE_CDS_FIXED_SZ + e.cds.nFile + 9;
  if( (rc = zipfileBufferGrow(&p->cds, nByte)) ) goto zipfile_step_out;
  p->cds.n += zipfileSerializeCDS(&e, &p->cds.a[p->cds.n]);

  /* Increment the count of entries in the archive */
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
    if( f==0 ){
      utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile);
    }
  }
  return f;
}

#if !defined(SQLITE_UNTESTABLE)
#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
/*
** A routine for handling output from sqlite3_trace().
*/
static int sql_trace_callback(
  unsigned mType,
  void *pArg,







<







11253
11254
11255
11256
11257
11258
11259

11260
11261
11262
11263
11264
11265
11266
    if( f==0 ){
      utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile);
    }
  }
  return f;
}


#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
/*
** A routine for handling output from sqlite3_trace().
*/
static int sql_trace_callback(
  unsigned mType,
  void *pArg,
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
    const char *z = (const char*)pX;
    int i = strlen30(z);
    while( i>0 && z[i-1]==';' ){ i--; }
    utf8_printf(f, "%.*s;\n", i, z);
  }
  return 0;
}
#endif
#endif

/*
** A no-op routine that runs with the ".breakpoint" doc-command.  This is
** a useful spot to set a debugger breakpoint.
*/
static void test_breakpoint(void){







<







11274
11275
11276
11277
11278
11279
11280

11281
11282
11283
11284
11285
11286
11287
    const char *z = (const char*)pX;
    int i = strlen30(z);
    while( i>0 && z[i-1]==';' ){ i--; }
    utf8_printf(f, "%.*s;\n", i, z);
  }
  return 0;
}

#endif

/*
** A no-op routine that runs with the ".breakpoint" doc-command.  This is
** a useful spot to set a debugger breakpoint.
*/
static void test_breakpoint(void){
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
    if( bUpdate==0 ){
      rc = arExecSql(pAr, zDrop);
      if( rc!=SQLITE_OK ) goto end_ar_transaction;
    }
    rc = arExecSql(pAr, zCreate);
  }
  for(i=0; i<pAr->nArg && rc==SQLITE_OK; i++){
    char *zSql = sqlite3_mprintf(zInsertFmt[pAr->bZip], zTab,
        pAr->bVerbose ? "shell_putsnl(name)" : "name",
        pAr->azArg[i], pAr->zDir);
    rc = arExecSql(pAr, zSql);
    sqlite3_free(zSql);
  }
end_ar_transaction:
  if( rc!=SQLITE_OK ){
    arExecSql(pAr, "ROLLBACK TO ar; RELEASE ar;");
  }else{
    rc = arExecSql(pAr, "RELEASE ar;");
    if( pAr->bZip && pAr->zFile ){







|


|
|







12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
    if( bUpdate==0 ){
      rc = arExecSql(pAr, zDrop);
      if( rc!=SQLITE_OK ) goto end_ar_transaction;
    }
    rc = arExecSql(pAr, zCreate);
  }
  for(i=0; i<pAr->nArg && rc==SQLITE_OK; i++){
    char *zSql2 = sqlite3_mprintf(zInsertFmt[pAr->bZip], zTab,
        pAr->bVerbose ? "shell_putsnl(name)" : "name",
        pAr->azArg[i], pAr->zDir);
    rc = arExecSql(pAr, zSql2);
    sqlite3_free(zSql2);
  }
end_ar_transaction:
  if( rc!=SQLITE_OK ){
    arExecSql(pAr, "ROLLBACK TO ar; RELEASE ar;");
  }else{
    rc = arExecSql(pAr, "RELEASE ar;");
    if( pAr->bZip && pAr->zFile ){
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
      }else{
        raw_printf(stderr, "Usage: .schema ?--indent? ?LIKE-PATTERN?\n");
        rc = 1;
        goto meta_command_exit;
      }
    }
    if( zName!=0 ){
      int isMaster = sqlite3_strlike(zName, "sqlite_master", 0)==0;
      if( isMaster || sqlite3_strlike(zName,"sqlite_temp_master",0)==0 ){
        char *new_argv[2], *new_colv[2];
        new_argv[0] = sqlite3_mprintf(
                      "CREATE TABLE %s (\n"
                      "  type text,\n"
                      "  name text,\n"
                      "  tbl_name text,\n"
                      "  rootpage integer,\n"







|
|







14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
      }else{
        raw_printf(stderr, "Usage: .schema ?--indent? ?LIKE-PATTERN?\n");
        rc = 1;
        goto meta_command_exit;
      }
    }
    if( zName!=0 ){
      int isMaster = sqlite3_strlike(zName, "sqlite_master", '\\')==0;
      if( isMaster || sqlite3_strlike(zName,"sqlite_temp_master", '\\')==0 ){
        char *new_argv[2], *new_colv[2];
        new_argv[0] = sqlite3_mprintf(
                      "CREATE TABLE %s (\n"
                      "  type text,\n"
                      "  name text,\n"
                      "  tbl_name text,\n"
                      "  rootpage integer,\n"
14194
14195
14196
14197
14198
14199
14200


14201
14202
14203
14204
14205

14206

14207

14208
14209
14210
14211
14212
14213
14214
           " UNION ALL SELECT shell_module_schema(name),"
           " 'table', name, name, name, 9e+99, 'main' FROM pragma_module_list", 0);
      }
#endif
      appendText(&sSelect, ") WHERE ", 0);
      if( zName ){
        char *zQarg = sqlite3_mprintf("%Q", zName);


        if( strchr(zName, '.') ){
          appendText(&sSelect, "lower(printf('%s.%s',sname,tbl_name))", 0);
        }else{
          appendText(&sSelect, "lower(tbl_name)", 0);
        }

        appendText(&sSelect, strchr(zName, '*') ? " GLOB " : " LIKE ", 0);

        appendText(&sSelect, zQarg, 0);

        appendText(&sSelect, " AND ", 0);
        sqlite3_free(zQarg);
      }
      appendText(&sSelect, "type!='meta' AND sql IS NOT NULL"
                           " ORDER BY snum, rowid", 0);
      if( bDebug ){
        utf8_printf(p->out, "SQL: %s;\n", sSelect.z);







>
>





>
|
>
|
>







14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
           " UNION ALL SELECT shell_module_schema(name),"
           " 'table', name, name, name, 9e+99, 'main' FROM pragma_module_list", 0);
      }
#endif
      appendText(&sSelect, ") WHERE ", 0);
      if( zName ){
        char *zQarg = sqlite3_mprintf("%Q", zName);
        int bGlob = strchr(zName, '*') != 0 || strchr(zName, '?') != 0 ||
                    strchr(zName, '[') != 0;
        if( strchr(zName, '.') ){
          appendText(&sSelect, "lower(printf('%s.%s',sname,tbl_name))", 0);
        }else{
          appendText(&sSelect, "lower(tbl_name)", 0);
        }
        appendText(&sSelect, bGlob ? " GLOB " : " LIKE ", 0);
        appendText(&sSelect, zQarg, 0);
        if( !bGlob ){
          appendText(&sSelect, " ESCAPE '\\' ", 0);
        }
        appendText(&sSelect, " AND ", 0);
        sqlite3_free(zQarg);
      }
      appendText(&sSelect, "type!='meta' AND sql IS NOT NULL"
                           " ORDER BY snum, rowid", 0);
      if( bDebug ){
        utf8_printf(p->out, "SQL: %s;\n", sSelect.z);
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
      }else if( zLike ){
        raw_printf(stderr, "Usage: .sha3sum ?OPTIONS? ?LIKE-PATTERN?\n");
        rc = 1;
        goto meta_command_exit;
      }else{
        zLike = z;
        bSeparate = 1;
        if( sqlite3_strlike("sqlite_%", zLike, 0)==0 ) bSchema = 1;
      }
    }
    if( bSchema ){
      zSql = "SELECT lower(name) FROM sqlite_master"
             " WHERE type='table' AND coalesce(rootpage,0)>1"
             " UNION ALL SELECT 'sqlite_master'"
             " ORDER BY 1 collate nocase";







|







14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
      }else if( zLike ){
        raw_printf(stderr, "Usage: .sha3sum ?OPTIONS? ?LIKE-PATTERN?\n");
        rc = 1;
        goto meta_command_exit;
      }else{
        zLike = z;
        bSeparate = 1;
        if( sqlite3_strlike("sqlite\\_%", zLike, '\\')==0 ) bSchema = 1;
      }
    }
    if( bSchema ){
      zSql = "SELECT lower(name) FROM sqlite_master"
             " WHERE type='table' AND coalesce(rootpage,0)>1"
             " UNION ALL SELECT 'sqlite_master'"
             " ORDER BY 1 collate nocase";
15921
15922
15923
15924
15925
15926
15927


15928
15929
15930
15931
15932
15933
15934
      memcpy(data.colSeparator,",",2);
#ifdef SQLITE_HAVE_ZLIB
    }else if( strcmp(z,"-zip")==0 ){
      data.openMode = SHELL_OPEN_ZIPFILE;
#endif
    }else if( strcmp(z,"-append")==0 ){
      data.openMode = SHELL_OPEN_APPENDVFS;


    }else if( strcmp(z,"-ascii")==0 ){
      data.mode = MODE_Ascii;
      sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,
                       SEP_Unit);
      sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator,
                       SEP_Record);
    }else if( strcmp(z,"-separator")==0 ){







>
>







15932
15933
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
      memcpy(data.colSeparator,",",2);
#ifdef SQLITE_HAVE_ZLIB
    }else if( strcmp(z,"-zip")==0 ){
      data.openMode = SHELL_OPEN_ZIPFILE;
#endif
    }else if( strcmp(z,"-append")==0 ){
      data.openMode = SHELL_OPEN_APPENDVFS;
    }else if( strcmp(z,"-readonly")==0 ){
      data.openMode = SHELL_OPEN_READONLY;
    }else if( strcmp(z,"-ascii")==0 ){
      data.mode = MODE_Ascii;
      sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,
                       SEP_Unit);
      sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator,
                       SEP_Record);
    }else if( strcmp(z,"-separator")==0 ){
Changes to src/sqlite3.c.
1
2
3
4
5
6
7
8
9
10
/******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite
** version 3.23.0.  By combining all the individual C code files into this
** single large file, the entire code can be compiled as a single translation
** unit.  This allows many compilers to do optimizations that would not be
** possible if the files were compiled separately.  Performance improvements
** of 5% or more are commonly seen when SQLite is compiled as a single
** translation unit.
**
** This file is all you need to compile SQLite.  To use SQLite in other


|







1
2
3
4
5
6
7
8
9
10
/******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite
** version 3.23.1.  By combining all the individual C code files into this
** single large file, the entire code can be compiled as a single translation
** unit.  This allows many compilers to do optimizations that would not be
** possible if the files were compiled separately.  Performance improvements
** of 5% or more are commonly seen when SQLite is compiled as a single
** translation unit.
**
** This file is all you need to compile SQLite.  To use SQLite in other
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
** been edited in any way since it was last checked in, then the last
** four hexadecimal digits of the hash may be modified.
**
** See also: [sqlite3_libversion()],
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION        "3.23.0"
#define SQLITE_VERSION_NUMBER 3023000
#define SQLITE_SOURCE_ID      "2018-03-22 17:13:44 eb4f452e354065d610ff57a6a9312ad119b6b0cc467f9dff105f0718bc27ef01"

/*
** CAPI3REF: Run-Time Library Version Numbers
** KEYWORDS: sqlite3_version sqlite3_sourceid
**
** These interfaces provide the same information as the [SQLITE_VERSION],
** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros







|
|
|







1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
** been edited in any way since it was last checked in, then the last
** four hexadecimal digits of the hash may be modified.
**
** See also: [sqlite3_libversion()],
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION        "3.23.1"
#define SQLITE_VERSION_NUMBER 3023001
#define SQLITE_SOURCE_ID      "2018-04-10 17:39:29 4bb2294022060e61de7da5c227a69ccd846ba330e31626ebcd59a94efd148b3b"

/*
** CAPI3REF: Run-Time Library Version Numbers
** KEYWORDS: sqlite3_version sqlite3_sourceid
**
** These interfaces provide the same information as the [SQLITE_VERSION],
** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
2084
2085
2086
2087
2088
2089
2090






2091
2092
2093
2094
2095
2096
2097
** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write
** operations since the previous successful call to 
** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back.
** ^This file control takes the file descriptor out of batch write mode
** so that all subsequent write operations are independent.
** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without
** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].






** </ul>
*/
#define SQLITE_FCNTL_LOCKSTATE               1
#define SQLITE_FCNTL_GET_LOCKPROXYFILE       2
#define SQLITE_FCNTL_SET_LOCKPROXYFILE       3
#define SQLITE_FCNTL_LAST_ERRNO              4
#define SQLITE_FCNTL_SIZE_HINT               5







>
>
>
>
>
>







2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write
** operations since the previous successful call to 
** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back.
** ^This file control takes the file descriptor out of batch write mode
** so that all subsequent write operations are independent.
** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without
** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].
**
** <li>[[SQLITE_FCNTL_LOCK_TIMEOUT]]
** The [SQLITE_FCNTL_LOCK_TIMEOUT] opcode causes attempts to obtain
** a file lock using the xLock or xShmLock methods of the VFS to wait
** for up to M milliseconds before failing, where M is the single 
** unsigned integer parameter.
** </ul>
*/
#define SQLITE_FCNTL_LOCKSTATE               1
#define SQLITE_FCNTL_GET_LOCKPROXYFILE       2
#define SQLITE_FCNTL_SET_LOCKPROXYFILE       3
#define SQLITE_FCNTL_LAST_ERRNO              4
#define SQLITE_FCNTL_SIZE_HINT               5
2118
2119
2120
2121
2122
2123
2124

2125
2126
2127
2128
2129
2130
2131
#define SQLITE_FCNTL_VFS_POINTER            27
#define SQLITE_FCNTL_JOURNAL_POINTER        28
#define SQLITE_FCNTL_WIN32_GET_HANDLE       29
#define SQLITE_FCNTL_PDB                    30
#define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE     31
#define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE    32
#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE  33


/* deprecated names */
#define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
#define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE
#define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO









>







2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
#define SQLITE_FCNTL_VFS_POINTER            27
#define SQLITE_FCNTL_JOURNAL_POINTER        28
#define SQLITE_FCNTL_WIN32_GET_HANDLE       29
#define SQLITE_FCNTL_PDB                    30
#define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE     31
#define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE    32
#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE  33
#define SQLITE_FCNTL_LOCK_TIMEOUT           34

/* deprecated names */
#define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
#define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE
#define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO


9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
*/
#define SQLITE_SERIALIZE_NOCOPY 0x001   /* Do no memory allocations */

/*
** CAPI3REF: Deserialize a database
**
** The sqlite3_deserialize(D,S,P,N,M,F) interface causes the 
** [database connection] D to disconnection from database S and then
** reopen S as an in-memory database based on the serialization contained
** in P.  The serialized database P is N bytes in size.  M is the size of
** the buffer P, which might be larger than N.  If M is larger than N, and
** the SQLITE_DESERIALIZE_READONLY bit is not set in F, then SQLite is
** permitted to add content to the in-memory database as long as the total
** size does not exceed M bytes.
**







|







9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
*/
#define SQLITE_SERIALIZE_NOCOPY 0x001   /* Do no memory allocations */

/*
** CAPI3REF: Deserialize a database
**
** The sqlite3_deserialize(D,S,P,N,M,F) interface causes the 
** [database connection] D to disconnect from database S and then
** reopen S as an in-memory database based on the serialization contained
** in P.  The serialized database P is N bytes in size.  M is the size of
** the buffer P, which might be larger than N.  If M is larger than N, and
** the SQLITE_DESERIALIZE_READONLY bit is not set in F, then SQLite is
** permitted to add content to the in-memory database as long as the total
** size does not exceed M bytes.
**
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
** DESTRUCTOR: sqlite3_changegroup
*/
SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*);

/*
** CAPI3REF: Apply A Changeset To A Database
**
** Apply a changeset to a database. This function attempts to update the
** "main" database attached to handle db with the changes found in the
** changeset passed via the second and third arguments.
**
** The fourth argument (xFilter) passed to this function is the "filter
** callback". If it is not NULL, then for each table affected by at least one
** change in the changeset, the filter callback is invoked with
** the table name as the second argument, and a copy of the context pointer
** passed as the sixth argument to this function as the first. If the "filter
** callback" returns zero, then no attempt is made to apply any changes to 
** the table. Otherwise, if the return value is non-zero or the xFilter
** argument to this function is NULL, all changes related to the table are
** attempted.
**
** For each table that is not excluded by the filter callback, this function 
** tests that the target database contains a compatible table. A table is 
** considered compatible if all of the following are true:
**
** <ul>
**   <li> The table has the same name as the name recorded in the 







|
|
|

|



|
|
|
|
<







10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997

10998
10999
11000
11001
11002
11003
11004
** DESTRUCTOR: sqlite3_changegroup
*/
SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*);

/*
** CAPI3REF: Apply A Changeset To A Database
**
** Apply a changeset or patchset to a database. These functions attempt to
** update the "main" database attached to handle db with the changes found in
** the changeset passed via the second and third arguments. 
**
** The fourth argument (xFilter) passed to these functions is the "filter
** callback". If it is not NULL, then for each table affected by at least one
** change in the changeset, the filter callback is invoked with
** the table name as the second argument, and a copy of the context pointer
** passed as the sixth argument as the first. If the "filter callback"
** returns zero, then no attempt is made to apply any changes to the table.
** Otherwise, if the return value is non-zero or the xFilter argument to
** is NULL, all changes related to the table are attempted.

**
** For each table that is not excluded by the filter callback, this function 
** tests that the target database contains a compatible table. A table is 
** considered compatible if all of the following are true:
**
** <ul>
**   <li> The table has the same name as the name recorded in the 
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
** actions are taken by sqlite3changeset_apply() depending on the value
** returned by each invocation of the conflict-handler function. Refer to
** the documentation for the three 
** [SQLITE_CHANGESET_OMIT|available return values] for details.
**
** <dl>
** <dt>DELETE Changes<dd>
**   For each DELETE change, this function checks if the target database 
**   contains a row with the same primary key value (or values) as the 
**   original row values stored in the changeset. If it does, and the values 
**   stored in all non-primary key columns also match the values stored in 
**   the changeset the row is deleted from the target database.
**
**   If a row with matching primary key values is found, but one or more of
**   the non-primary key fields contains a value different from the original







|







11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
** actions are taken by sqlite3changeset_apply() depending on the value
** returned by each invocation of the conflict-handler function. Refer to
** the documentation for the three 
** [SQLITE_CHANGESET_OMIT|available return values] for details.
**
** <dl>
** <dt>DELETE Changes<dd>
**   For each DELETE change, the function checks if the target database 
**   contains a row with the same primary key value (or values) as the 
**   original row values stored in the changeset. If it does, and the values 
**   stored in all non-primary key columns also match the values stored in 
**   the changeset the row is deleted from the target database.
**
**   If a row with matching primary key values is found, but one or more of
**   the non-primary key fields contains a value different from the original
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
**   violation (e.g. NOT NULL or UNIQUE), the conflict handler function is 
**   invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT].
**   This includes the case where the INSERT operation is re-attempted because 
**   an earlier call to the conflict handler function returned 
**   [SQLITE_CHANGESET_REPLACE].
**
** <dt>UPDATE Changes<dd>
**   For each UPDATE change, this function checks if the target database 
**   contains a row with the same primary key value (or values) as the 
**   original row values stored in the changeset. If it does, and the values 
**   stored in all modified non-primary key columns also match the values
**   stored in the changeset the row is updated within the target database.
**
**   If a row with matching primary key values is found, but one or more of
**   the modified non-primary key fields contains a value different from an







|







11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
**   violation (e.g. NOT NULL or UNIQUE), the conflict handler function is 
**   invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT].
**   This includes the case where the INSERT operation is re-attempted because 
**   an earlier call to the conflict handler function returned 
**   [SQLITE_CHANGESET_REPLACE].
**
** <dt>UPDATE Changes<dd>
**   For each UPDATE change, the function checks if the target database 
**   contains a row with the same primary key value (or values) as the 
**   original row values stored in the changeset. If it does, and the values 
**   stored in all modified non-primary key columns also match the values
**   stored in the changeset the row is updated within the target database.
**
**   If a row with matching primary key values is found, but one or more of
**   the modified non-primary key fields contains a value different from an
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116

















11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132



































11133
11134
11135
11136
11137
11138
11139
** </dl>
**
** It is safe to execute SQL statements, including those that write to the
** table that the callback related to, from within the xConflict callback.
** This can be used to further customize the applications conflict
** resolution strategy.
**
** All changes made by this function are enclosed in a savepoint transaction.
** If any other error (aside from a constraint failure when attempting to
** write to the target database) occurs, then the savepoint transaction is
** rolled back, restoring the target database to its original state, and an 
** SQLite error code returned.

















*/
SQLITE_API int sqlite3changeset_apply(
  sqlite3 *db,                    /* Apply change to "main" db of this handle */
  int nChangeset,                 /* Size of changeset in bytes */
  void *pChangeset,               /* Changeset blob */
  int(*xFilter)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    const char *zTab              /* Table name */
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx                      /* First argument passed to xConflict */
);




































/* 
** CAPI3REF: Constants Passed To The Conflict Handler
**
** Values that may be passed as the second argument to a conflict-handler.
**
** <dl>







|




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
** </dl>
**
** It is safe to execute SQL statements, including those that write to the
** table that the callback related to, from within the xConflict callback.
** This can be used to further customize the applications conflict
** resolution strategy.
**
** All changes made by these functions are enclosed in a savepoint transaction.
** If any other error (aside from a constraint failure when attempting to
** write to the target database) occurs, then the savepoint transaction is
** rolled back, restoring the target database to its original state, and an 
** SQLite error code returned.
**
** If the output parameters (ppRebase) and (pnRebase) are non-NULL and
** the input is a changeset (not a patchset), then sqlite3changeset_apply_v2()
** may set (*ppRebase) to point to a "rebase" that may be used with the 
** sqlite3_rebaser APIs buffer before returning. In this case (*pnRebase)
** is set to the size of the buffer in bytes. It is the responsibility of the
** caller to eventually free any such buffer using sqlite3_free(). The buffer
** is only allocated and populated if one or more conflicts were encountered
** while applying the patchset. See comments surrounding the sqlite3_rebaser
** APIs for further details.
**
** The behavior of sqlite3changeset_apply_v2() and its streaming equivalent
** may be modified by passing a combination of
** [SQLITE_CHANGESETAPPLY_NOSAVEPOINT | supported flags] as the 9th parameter.
**
** Note that the sqlite3changeset_apply_v2() API is still <b>experimental</b>
** and therefore subject to change.
*/
SQLITE_API int sqlite3changeset_apply(
  sqlite3 *db,                    /* Apply change to "main" db of this handle */
  int nChangeset,                 /* Size of changeset in bytes */
  void *pChangeset,               /* Changeset blob */
  int(*xFilter)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    const char *zTab              /* Table name */
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx                      /* First argument passed to xConflict */
);
SQLITE_API int sqlite3changeset_apply_v2(
  sqlite3 *db,                    /* Apply change to "main" db of this handle */
  int nChangeset,                 /* Size of changeset in bytes */
  void *pChangeset,               /* Changeset blob */
  int(*xFilter)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    const char *zTab              /* Table name */
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx,                     /* First argument passed to xConflict */
  void **ppRebase, int *pnRebase, /* OUT: Rebase data */
  int flags                       /* Combination of SESSION_APPLY_* flags */
);

/*
** CAPI3REF: Flags for sqlite3changeset_apply_v2
**
** The following flags may passed via the 9th parameter to
** [sqlite3changeset_apply_v2] and [sqlite3changeset_apply_v2_strm]:
**
** <dl>
** <dt>SQLITE_CHANGESETAPPLY_NOSAVEPOINT <dd>
**   Usually, the sessions module encloses all operations performed by
**   a single call to apply_v2() or apply_v2_strm() in a [SAVEPOINT]. The
**   SAVEPOINT is committed if the changeset or patchset is successfully
**   applied, or rolled back if an error occurs. Specifying this flag
**   causes the sessions module to omit this savepoint. In this case, if the
**   caller has an open transaction or savepoint when apply_v2() is called, 
**   it may revert the partially applied changeset by rolling it back.
*/
#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT   0x0001

/* 
** CAPI3REF: Constants Passed To The Conflict Handler
**
** Values that may be passed as the second argument to a conflict-handler.
**
** <dl>
11223
11224
11225
11226
11227
11228
11229



























































































































































11230
11231
11232
11233
11234
11235
11236
11237
11238

11239
11240
11241
11242
11243
11244
11245
**   and the call to sqlite3changeset_apply() returns SQLITE_ABORT.
** </dl>
*/
#define SQLITE_CHANGESET_OMIT       0
#define SQLITE_CHANGESET_REPLACE    1
#define SQLITE_CHANGESET_ABORT      2




























































































































































/*
** CAPI3REF: Streaming Versions of API functions.
**
** The six streaming API xxx_strm() functions serve similar purposes to the 
** corresponding non-streaming API functions:
**
** <table border=1 style="margin-left:8ex;margin-right:8ex">
**   <tr><th>Streaming function<th>Non-streaming equivalent</th>
**   <tr><td>sqlite3changeset_apply_strm<td>[sqlite3changeset_apply] 

**   <tr><td>sqlite3changeset_concat_strm<td>[sqlite3changeset_concat] 
**   <tr><td>sqlite3changeset_invert_strm<td>[sqlite3changeset_invert] 
**   <tr><td>sqlite3changeset_start_strm<td>[sqlite3changeset_start] 
**   <tr><td>sqlite3session_changeset_strm<td>[sqlite3session_changeset] 
**   <tr><td>sqlite3session_patchset_strm<td>[sqlite3session_patchset] 
** </table>
**







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









>







11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
**   and the call to sqlite3changeset_apply() returns SQLITE_ABORT.
** </dl>
*/
#define SQLITE_CHANGESET_OMIT       0
#define SQLITE_CHANGESET_REPLACE    1
#define SQLITE_CHANGESET_ABORT      2

/* 
** CAPI3REF: Rebasing changesets
** EXPERIMENTAL
**
** Suppose there is a site hosting a database in state S0. And that
** modifications are made that move that database to state S1 and a
** changeset recorded (the "local" changeset). Then, a changeset based
** on S0 is received from another site (the "remote" changeset) and 
** applied to the database. The database is then in state 
** (S1+"remote"), where the exact state depends on any conflict
** resolution decisions (OMIT or REPLACE) made while applying "remote".
** Rebasing a changeset is to update it to take those conflict 
** resolution decisions into account, so that the same conflicts
** do not have to be resolved elsewhere in the network. 
**
** For example, if both the local and remote changesets contain an
** INSERT of the same key on "CREATE TABLE t1(a PRIMARY KEY, b)":
**
**   local:  INSERT INTO t1 VALUES(1, 'v1');
**   remote: INSERT INTO t1 VALUES(1, 'v2');
**
** and the conflict resolution is REPLACE, then the INSERT change is
** removed from the local changeset (it was overridden). Or, if the
** conflict resolution was "OMIT", then the local changeset is modified
** to instead contain:
**
**           UPDATE t1 SET b = 'v2' WHERE a=1;
**
** Changes within the local changeset are rebased as follows:
**
** <dl>
** <dt>Local INSERT<dd>
**   This may only conflict with a remote INSERT. If the conflict 
**   resolution was OMIT, then add an UPDATE change to the rebased
**   changeset. Or, if the conflict resolution was REPLACE, add
**   nothing to the rebased changeset.
**
** <dt>Local DELETE<dd>
**   This may conflict with a remote UPDATE or DELETE. In both cases the
**   only possible resolution is OMIT. If the remote operation was a
**   DELETE, then add no change to the rebased changeset. If the remote
**   operation was an UPDATE, then the old.* fields of change are updated
**   to reflect the new.* values in the UPDATE.
**
** <dt>Local UPDATE<dd>
**   This may conflict with a remote UPDATE or DELETE. If it conflicts
**   with a DELETE, and the conflict resolution was OMIT, then the update
**   is changed into an INSERT. Any undefined values in the new.* record
**   from the update change are filled in using the old.* values from
**   the conflicting DELETE. Or, if the conflict resolution was REPLACE,
**   the UPDATE change is simply omitted from the rebased changeset.
**
**   If conflict is with a remote UPDATE and the resolution is OMIT, then
**   the old.* values are rebased using the new.* values in the remote
**   change. Or, if the resolution is REPLACE, then the change is copied
**   into the rebased changeset with updates to columns also updated by
**   the conflicting remote UPDATE removed. If this means no columns would 
**   be updated, the change is omitted.
** </dl>
**
** A local change may be rebased against multiple remote changes 
** simultaneously. If a single key is modified by multiple remote 
** changesets, they are combined as follows before the local changeset
** is rebased:
**
** <ul>
**    <li> If there has been one or more REPLACE resolutions on a
**         key, it is rebased according to a REPLACE.
**
**    <li> If there have been no REPLACE resolutions on a key, then
**         the local changeset is rebased according to the most recent
**         of the OMIT resolutions.
** </ul>
**
** Note that conflict resolutions from multiple remote changesets are 
** combined on a per-field basis, not per-row. This means that in the 
** case of multiple remote UPDATE operations, some fields of a single 
** local change may be rebased for REPLACE while others are rebased for 
** OMIT.
**
** In order to rebase a local changeset, the remote changeset must first
** be applied to the local database using sqlite3changeset_apply_v2() and
** the buffer of rebase information captured. Then:
**
** <ol>
**   <li> An sqlite3_rebaser object is created by calling 
**        sqlite3rebaser_create().
**   <li> The new object is configured with the rebase buffer obtained from
**        sqlite3changeset_apply_v2() by calling sqlite3rebaser_configure().
**        If the local changeset is to be rebased against multiple remote
**        changesets, then sqlite3rebaser_configure() should be called
**        multiple times, in the same order that the multiple
**        sqlite3changeset_apply_v2() calls were made.
**   <li> Each local changeset is rebased by calling sqlite3rebaser_rebase().
**   <li> The sqlite3_rebaser object is deleted by calling
**        sqlite3rebaser_delete().
** </ol>
*/
typedef struct sqlite3_rebaser sqlite3_rebaser;

/*
** CAPI3REF: Create a changeset rebaser object.
** EXPERIMENTAL
**
** Allocate a new changeset rebaser object. If successful, set (*ppNew) to
** point to the new object and return SQLITE_OK. Otherwise, if an error
** occurs, return an SQLite error code (e.g. SQLITE_NOMEM) and set (*ppNew) 
** to NULL. 
*/
SQLITE_API int sqlite3rebaser_create(sqlite3_rebaser **ppNew);

/*
** CAPI3REF: Configure a changeset rebaser object.
** EXPERIMENTAL
**
** Configure the changeset rebaser object to rebase changesets according
** to the conflict resolutions described by buffer pRebase (size nRebase
** bytes), which must have been obtained from a previous call to
** sqlite3changeset_apply_v2().
*/
SQLITE_API int sqlite3rebaser_configure(
  sqlite3_rebaser*, 
  int nRebase, const void *pRebase
); 

/*
** CAPI3REF: Rebase a changeset
** EXPERIMENTAL
**
** Argument pIn must point to a buffer containing a changeset nIn bytes
** in size. This function allocates and populates a buffer with a copy
** of the changeset rebased rebased according to the configuration of the
** rebaser object passed as the first argument. If successful, (*ppOut)
** is set to point to the new buffer containing the rebased changset and 
** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the
** responsibility of the caller to eventually free the new buffer using
** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)
** are set to zero and an SQLite error code returned.
*/
SQLITE_API int sqlite3rebaser_rebase(
  sqlite3_rebaser*,
  int nIn, const void *pIn, 
  int *pnOut, void **ppOut 
);

/*
** CAPI3REF: Delete a changeset rebaser object.
** EXPERIMENTAL
**
** Delete the changeset rebaser object and all associated resources. There
** should be one call to this function for each successful invocation
** of sqlite3rebaser_create().
*/
SQLITE_API void sqlite3rebaser_delete(sqlite3_rebaser *p); 

/*
** CAPI3REF: Streaming Versions of API functions.
**
** The six streaming API xxx_strm() functions serve similar purposes to the 
** corresponding non-streaming API functions:
**
** <table border=1 style="margin-left:8ex;margin-right:8ex">
**   <tr><th>Streaming function<th>Non-streaming equivalent</th>
**   <tr><td>sqlite3changeset_apply_strm<td>[sqlite3changeset_apply] 
**   <tr><td>sqlite3changeset_apply_strm_v2<td>[sqlite3changeset_apply_v2] 
**   <tr><td>sqlite3changeset_concat_strm<td>[sqlite3changeset_concat] 
**   <tr><td>sqlite3changeset_invert_strm<td>[sqlite3changeset_invert] 
**   <tr><td>sqlite3changeset_start_strm<td>[sqlite3changeset_start] 
**   <tr><td>sqlite3session_changeset_strm<td>[sqlite3session_changeset] 
**   <tr><td>sqlite3session_patchset_strm<td>[sqlite3session_patchset] 
** </table>
**
11326
11327
11328
11329
11330
11331
11332

















11333
11334
11335
11336
11337
11338
11339
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx                      /* First argument passed to xConflict */

















);
SQLITE_API int sqlite3changeset_concat_strm(
  int (*xInputA)(void *pIn, void *pData, int *pnData),
  void *pInA,
  int (*xInputB)(void *pIn, void *pData, int *pnData),
  void *pInB,
  int (*xOutput)(void *pOut, const void *pData, int nData),







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx                      /* First argument passed to xConflict */
);
SQLITE_API int sqlite3changeset_apply_v2_strm(
  sqlite3 *db,                    /* Apply change to "main" db of this handle */
  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
  void *pIn,                                          /* First arg for xInput */
  int(*xFilter)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    const char *zTab              /* Table name */
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx,                     /* First argument passed to xConflict */
  void **ppRebase, int *pnRebase,
  int flags
);
SQLITE_API int sqlite3changeset_concat_strm(
  int (*xInputA)(void *pIn, void *pData, int *pnData),
  void *pInA,
  int (*xInputB)(void *pIn, void *pData, int *pnData),
  void *pInB,
  int (*xOutput)(void *pOut, const void *pData, int nData),
11363
11364
11365
11366
11367
11368
11369







11370
11371
11372
11373
11374
11375
11376
SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*, 
    int (*xInput)(void *pIn, void *pData, int *pnData),
    void *pIn
);
SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*,
    int (*xOutput)(void *pOut, const void *pData, int nData), 
    void *pOut







);


/*
** Make sure we can call this stuff from C++.
*/
#if 0







>
>
>
>
>
>
>







11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*, 
    int (*xInput)(void *pIn, void *pData, int *pnData),
    void *pIn
);
SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*,
    int (*xOutput)(void *pOut, const void *pData, int nData), 
    void *pOut
);
SQLITE_API int sqlite3rebaser_rebase_strm(
  sqlite3_rebaser *pRebaser,
  int (*xInput)(void *pIn, void *pData, int *pnData),
  void *pIn,
  int (*xOutput)(void *pOut, const void *pData, int nData),
  void *pOut
);


/*
** Make sure we can call this stuff from C++.
*/
#if 0
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252

13253
13254
13255
13256
13257
13258
13259
** The sqlite.busyHandler member of the sqlite struct contains the busy
** callback for the database handle. Each pager opened via the sqlite
** handle is passed a pointer to sqlite.busyHandler. The busy-handler
** callback is currently invoked only from within pager.c.
*/
typedef struct BusyHandler BusyHandler;
struct BusyHandler {
  int (*xFunc)(void *,int);  /* The busy callback */
  void *pArg;                /* First arg to busy callback */
  int nBusy;                 /* Incremented with each busy call */

};

/*
** Name of the master database table.  The master database table
** is a special table that holds the names and attributes of all
** user tables and indices.
*/







|
|
|
>







13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
** The sqlite.busyHandler member of the sqlite struct contains the busy
** callback for the database handle. Each pager opened via the sqlite
** handle is passed a pointer to sqlite.busyHandler. The busy-handler
** callback is currently invoked only from within pager.c.
*/
typedef struct BusyHandler BusyHandler;
struct BusyHandler {
  int (*xBusyHandler)(void *,int);  /* The busy callback */
  void *pBusyArg;                   /* First arg to busy callback */
  int nBusy;                        /* Incremented with each busy call */
  u8 bExtraFileArg;                 /* Include sqlite3_file as callback arg */
};

/*
** Name of the master database table.  The master database table
** is a special table that holds the names and attributes of all
** user tables and indices.
*/
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
  int,
  void(*)(DbPage*)
);
SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager, sqlite3*);
SQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);

/* Functions used to configure a Pager object. */
SQLITE_PRIVATE void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);
SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager*, u32*, int);
#ifdef SQLITE_HAS_CODEC
SQLITE_PRIVATE void sqlite3PagerAlignReserve(Pager*,Pager*);
#endif
SQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager*, int);
SQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager*, int);
SQLITE_PRIVATE int sqlite3PagerSetSpillsize(Pager*, int);







|







14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
  int,
  void(*)(DbPage*)
);
SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager, sqlite3*);
SQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);

/* Functions used to configure a Pager object. */
SQLITE_PRIVATE void sqlite3PagerSetBusyHandler(Pager*, int(*)(void *), void *);
SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager*, u32*, int);
#ifdef SQLITE_HAS_CODEC
SQLITE_PRIVATE void sqlite3PagerAlignReserve(Pager*,Pager*);
#endif
SQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager*, int);
SQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager*, int);
SQLITE_PRIVATE int sqlite3PagerSetSpillsize(Pager*, int);
14540
14541
14542
14543
14544
14545
14546





14547
14548
14549
14550
14551
14552
14553
SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*);
SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*);
SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*);
SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*);
SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *);
SQLITE_PRIVATE void sqlite3PagerClearCache(Pager*);
SQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *);






/* Functions used to truncate the database file. */
SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);

SQLITE_PRIVATE void sqlite3PagerRekey(DbPage*, Pgno, u16);

#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)







>
>
>
>
>







14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*);
SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*);
SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*);
SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*);
SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *);
SQLITE_PRIVATE void sqlite3PagerClearCache(Pager*);
SQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *);
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
SQLITE_PRIVATE void sqlite3PagerResetLockTimeout(Pager *pPager);
#else
# define sqlite3PagerResetLockTimeout(X)
#endif

/* Functions used to truncate the database file. */
SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);

SQLITE_PRIVATE void sqlite3PagerRekey(DbPage*, Pgno, u16);

#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)
18097
18098
18099
18100
18101
18102
18103
18104
18105
18106
18107
18108
18109
18110
18111
SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
SQLITE_PRIVATE char sqlite3AffinityType(const char*, u8*);
SQLITE_PRIVATE void sqlite3Analyze(Parse*, Token*, Token*);
SQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler*);
SQLITE_PRIVATE int sqlite3FindDb(sqlite3*, Token*);
SQLITE_PRIVATE int sqlite3FindDbName(sqlite3 *, const char *);
SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3*,int iDB);
SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3*,Index*);
SQLITE_PRIVATE void sqlite3DefaultRowEst(Index*);
SQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3*, int);
SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);







|







18341
18342
18343
18344
18345
18346
18347
18348
18349
18350
18351
18352
18353
18354
18355
SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
SQLITE_PRIVATE char sqlite3AffinityType(const char*, u8*);
SQLITE_PRIVATE void sqlite3Analyze(Parse*, Token*, Token*);
SQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler*, sqlite3_file*);
SQLITE_PRIVATE int sqlite3FindDb(sqlite3*, Token*);
SQLITE_PRIVATE int sqlite3FindDbName(sqlite3 *, const char *);
SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3*,int iDB);
SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3*,Index*);
SQLITE_PRIVATE void sqlite3DefaultRowEst(Index*);
SQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3*, int);
SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
21067
21068
21069
21070
21071
21072
21073

21074
21075


21076
21077
21078
21079
21080
21081
21082
21083
21084
21085
21086
21087
21088
21089
21090
21091
21092
21093
21094
21095
21096
21097
21098
21099
** and we need to know about the failures.  Use sqlite3OsFileControlHint()
** when simply tossing information over the wall to the VFS and we do not
** really care if the VFS receives and understands the information since it
** is only a hint and can be safely ignored.  The sqlite3OsFileControlHint()
** routine has no return value since the return value would be meaningless.
*/
SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){

#ifdef SQLITE_TEST
  if( op!=SQLITE_FCNTL_COMMIT_PHASETWO ){


    /* Faults are not injected into COMMIT_PHASETWO because, assuming SQLite
    ** is using a regular VFS, it is called after the corresponding
    ** transaction has been committed. Injecting a fault at this point
    ** confuses the test scripts - the COMMIT comand returns SQLITE_NOMEM
    ** but the transaction is committed anyway.
    **
    ** The core must call OsFileControl() though, not OsFileControlHint(),
    ** as if a custom VFS (e.g. zipvfs) returns an error here, it probably
    ** means the commit really has failed and an error should be returned
    ** to the user.  */
    DO_OS_MALLOC_TEST(id);
  }
#endif
  return id->pMethods->xFileControl(id, op, pArg);
}
SQLITE_PRIVATE void sqlite3OsFileControlHint(sqlite3_file *id, int op, void *pArg){
  (void)id->pMethods->xFileControl(id, op, pArg);
}

SQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id){
  int (*xSectorSize)(sqlite3_file*) = id->pMethods->xSectorSize;
  return (xSectorSize ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE);
}
SQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id){







>

|
>
>
















|







21311
21312
21313
21314
21315
21316
21317
21318
21319
21320
21321
21322
21323
21324
21325
21326
21327
21328
21329
21330
21331
21332
21333
21334
21335
21336
21337
21338
21339
21340
21341
21342
21343
21344
21345
21346
** and we need to know about the failures.  Use sqlite3OsFileControlHint()
** when simply tossing information over the wall to the VFS and we do not
** really care if the VFS receives and understands the information since it
** is only a hint and can be safely ignored.  The sqlite3OsFileControlHint()
** routine has no return value since the return value would be meaningless.
*/
SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){
  if( id->pMethods==0 ) return SQLITE_NOTFOUND;
#ifdef SQLITE_TEST
  if( op!=SQLITE_FCNTL_COMMIT_PHASETWO
   && op!=SQLITE_FCNTL_LOCK_TIMEOUT
  ){
    /* Faults are not injected into COMMIT_PHASETWO because, assuming SQLite
    ** is using a regular VFS, it is called after the corresponding
    ** transaction has been committed. Injecting a fault at this point
    ** confuses the test scripts - the COMMIT comand returns SQLITE_NOMEM
    ** but the transaction is committed anyway.
    **
    ** The core must call OsFileControl() though, not OsFileControlHint(),
    ** as if a custom VFS (e.g. zipvfs) returns an error here, it probably
    ** means the commit really has failed and an error should be returned
    ** to the user.  */
    DO_OS_MALLOC_TEST(id);
  }
#endif
  return id->pMethods->xFileControl(id, op, pArg);
}
SQLITE_PRIVATE void sqlite3OsFileControlHint(sqlite3_file *id, int op, void *pArg){
  if( id->pMethods ) (void)id->pMethods->xFileControl(id, op, pArg);
}

SQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id){
  int (*xSectorSize)(sqlite3_file*) = id->pMethods->xSectorSize;
  return (xSectorSize ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE);
}
SQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id){
31024
31025
31026
31027
31028
31029
31030



31031
31032
31033
31034
31035
31036
31037
  int deviceCharacteristics;          /* Precomputed device characteristics */
#if SQLITE_ENABLE_LOCKING_STYLE
  int openFlags;                      /* The flags specified at open() */
#endif
#if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__)
  unsigned fsFlags;                   /* cached details from statfs() */
#endif



#if OS_VXWORKS
  struct vxworksFileId *pId;          /* Unique file ID */
#endif
#ifdef SQLITE_DEBUG
  /* The next group of variables are used to track whether or not the
  ** transaction counter in bytes 24-27 of database files are updated
  ** whenever any part of the database changes.  An assertion fault will







>
>
>







31271
31272
31273
31274
31275
31276
31277
31278
31279
31280
31281
31282
31283
31284
31285
31286
31287
  int deviceCharacteristics;          /* Precomputed device characteristics */
#if SQLITE_ENABLE_LOCKING_STYLE
  int openFlags;                      /* The flags specified at open() */
#endif
#if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__)
  unsigned fsFlags;                   /* cached details from statfs() */
#endif
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
  unsigned iBusyTimeout;              /* Wait this many millisec on locks */
#endif
#if OS_VXWORKS
  struct vxworksFileId *pId;          /* Unique file ID */
#endif
#ifdef SQLITE_DEBUG
  /* The next group of variables are used to track whether or not the
  ** transaction counter in bytes 24-27 of database files are updated
  ** whenever any part of the database changes.  An assertion fault will
32457
32458
32459
32460
32461
32462
32463





































32464
32465
32466
32467
32468
32469
32470
  
  unixLeaveMutex();
  OSTRACE(("TEST WR-LOCK %d %d %d (unix)\n", pFile->h, rc, reserved));

  *pResOut = reserved;
  return rc;
}






































/*
** Attempt to set a system-lock on the file pFile.  The lock is 
** described by pLock.
**
** If the pFile was opened read/write from unix-excl, then the only lock
** ever obtained is an exclusive lock, and it is obtained exactly once







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







32707
32708
32709
32710
32711
32712
32713
32714
32715
32716
32717
32718
32719
32720
32721
32722
32723
32724
32725
32726
32727
32728
32729
32730
32731
32732
32733
32734
32735
32736
32737
32738
32739
32740
32741
32742
32743
32744
32745
32746
32747
32748
32749
32750
32751
32752
32753
32754
32755
32756
32757
  
  unixLeaveMutex();
  OSTRACE(("TEST WR-LOCK %d %d %d (unix)\n", pFile->h, rc, reserved));

  *pResOut = reserved;
  return rc;
}

/*
** Set a posix-advisory-lock.
**
** There are two versions of this routine.  If compiled with
** SQLITE_ENABLE_SETLK_TIMEOUT then the routine has an extra parameter
** which is a pointer to a unixFile.  If the unixFile->iBusyTimeout
** value is set, then it is the number of milliseconds to wait before
** failing the lock.  The iBusyTimeout value is always reset back to
** zero on each call.
**
** If SQLITE_ENABLE_SETLK_TIMEOUT is not defined, then do a non-blocking
** attempt to set the lock.
*/
#ifndef SQLITE_ENABLE_SETLK_TIMEOUT
# define osSetPosixAdvisoryLock(h,x,t) osFcntl(h,F_SETLK,x)
#else
static int osSetPosixAdvisoryLock(
  int h,                /* The file descriptor on which to take the lock */
  struct flock *pLock,  /* The description of the lock */
  unixFile *pFile       /* Structure holding timeout value */
){
  int rc = osFcntl(h,F_SETLK,pLock);
  while( rc<0 && pFile->iBusyTimeout>0 ){
    /* On systems that support some kind of blocking file lock with a timeout,
    ** make appropriate changes here to invoke that blocking file lock.  On
    ** generic posix, however, there is no such API.  So we simply try the
    ** lock once every millisecond until either the timeout expires, or until
    ** the lock is obtained. */
    usleep(1000);
    rc = osFcntl(h,F_SETLK,pLock);
    pFile->iBusyTimeout--;
  }
  return rc;
}
#endif /* SQLITE_ENABLE_SETLK_TIMEOUT */


/*
** Attempt to set a system-lock on the file pFile.  The lock is 
** described by pLock.
**
** If the pFile was opened read/write from unix-excl, then the only lock
** ever obtained is an exclusive lock, and it is obtained exactly once
32490
32491
32492
32493
32494
32495
32496
32497
32498
32499
32500
32501
32502
32503
32504
32505
32506
32507
32508
32509
32510
32511
32512
    if( pInode->bProcessLock==0 ){
      struct flock lock;
      assert( pInode->nLock==0 );
      lock.l_whence = SEEK_SET;
      lock.l_start = SHARED_FIRST;
      lock.l_len = SHARED_SIZE;
      lock.l_type = F_WRLCK;
      rc = osFcntl(pFile->h, F_SETLK, &lock);
      if( rc<0 ) return rc;
      pInode->bProcessLock = 1;
      pInode->nLock++;
    }else{
      rc = 0;
    }
  }else{
    rc = osFcntl(pFile->h, F_SETLK, pLock);
  }
  return rc;
}

/*
** Lock the file with the lock specified by parameter eFileLock - one
** of the following:







|







|







32777
32778
32779
32780
32781
32782
32783
32784
32785
32786
32787
32788
32789
32790
32791
32792
32793
32794
32795
32796
32797
32798
32799
    if( pInode->bProcessLock==0 ){
      struct flock lock;
      assert( pInode->nLock==0 );
      lock.l_whence = SEEK_SET;
      lock.l_start = SHARED_FIRST;
      lock.l_len = SHARED_SIZE;
      lock.l_type = F_WRLCK;
      rc = osSetPosixAdvisoryLock(pFile->h, &lock, pFile);
      if( rc<0 ) return rc;
      pInode->bProcessLock = 1;
      pInode->nLock++;
    }else{
      rc = 0;
    }
  }else{
    rc = osSetPosixAdvisoryLock(pFile->h, pLock, pFile);
  }
  return rc;
}

/*
** Lock the file with the lock specified by parameter eFileLock - one
** of the following:
34858
34859
34860
34861
34862
34863
34864






34865
34866
34867
34868
34869
34870
34871
      }
      return SQLITE_OK;
    }
    case SQLITE_FCNTL_HAS_MOVED: {
      *(int*)pArg = fileHasMoved(pFile);
      return SQLITE_OK;
    }






#if SQLITE_MAX_MMAP_SIZE>0
    case SQLITE_FCNTL_MMAP_SIZE: {
      i64 newLimit = *(i64*)pArg;
      int rc = SQLITE_OK;
      if( newLimit>sqlite3GlobalConfig.mxMmap ){
        newLimit = sqlite3GlobalConfig.mxMmap;
      }







>
>
>
>
>
>







35145
35146
35147
35148
35149
35150
35151
35152
35153
35154
35155
35156
35157
35158
35159
35160
35161
35162
35163
35164
      }
      return SQLITE_OK;
    }
    case SQLITE_FCNTL_HAS_MOVED: {
      *(int*)pArg = fileHasMoved(pFile);
      return SQLITE_OK;
    }
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
    case SQLITE_FCNTL_LOCK_TIMEOUT: {
      pFile->iBusyTimeout = *(int*)pArg;
      return SQLITE_OK;
    }
#endif
#if SQLITE_MAX_MMAP_SIZE>0
    case SQLITE_FCNTL_MMAP_SIZE: {
      i64 newLimit = *(i64*)pArg;
      int rc = SQLITE_OK;
      if( newLimit>sqlite3GlobalConfig.mxMmap ){
        newLimit = sqlite3GlobalConfig.mxMmap;
      }
35177
35178
35179
35180
35181
35182
35183
35184
35185
35186
35187
35188
35189
35190
35191

  if( pShmNode->h>=0 ){
    /* Initialize the locking parameters */
    f.l_type = lockType;
    f.l_whence = SEEK_SET;
    f.l_start = ofst;
    f.l_len = n;
    rc = osFcntl(pShmNode->h, F_SETLK, &f);
    rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;
  }

  /* Update the global lock state and do debug tracing */
#ifdef SQLITE_DEBUG
  { u16 mask;
  OSTRACE(("SHM-LOCK "));







|







35470
35471
35472
35473
35474
35475
35476
35477
35478
35479
35480
35481
35482
35483
35484

  if( pShmNode->h>=0 ){
    /* Initialize the locking parameters */
    f.l_type = lockType;
    f.l_whence = SEEK_SET;
    f.l_start = ofst;
    f.l_len = n;
    rc = osSetPosixAdvisoryLock(pShmNode->h, &f, pFile);
    rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;
  }

  /* Update the global lock state and do debug tracing */
#ifdef SQLITE_DEBUG
  { u16 mask;
  OSTRACE(("SHM-LOCK "));
45037
45038
45039
45040
45041
45042
45043
45044
45045
45046
45047
45048
45049
45050
45051
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file implements in-memory VFS.  A database is held as a contiguous
** block of memory.
**
** This file also implements interface sqlite3_serialize() and
** sqlite3_deserialize().
*/
#ifdef SQLITE_ENABLE_DESERIALIZE
/* #include "sqliteInt.h" */







|







45330
45331
45332
45333
45334
45335
45336
45337
45338
45339
45340
45341
45342
45343
45344
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file implements an in-memory VFS. A database is held as a contiguous
** block of memory.
**
** This file also implements interface sqlite3_serialize() and
** sqlite3_deserialize().
*/
#ifdef SQLITE_ENABLE_DESERIALIZE
/* #include "sqliteInt.h" */
50951
50952
50953
50954
50955
50956
50957
50958
50959
50960
50961
50962
50963
50964
50965
    ** successfully committed, but the EXCLUSIVE lock is still held on the
    ** file. So it is safe to truncate the database file to its minimum
    ** required size.  */
    assert( pPager->eLock==EXCLUSIVE_LOCK );
    rc = pager_truncate(pPager, pPager->dbSize);
  }

  if( rc==SQLITE_OK && bCommit && isOpen(pPager->fd) ){
    rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_COMMIT_PHASETWO, 0);
    if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;
  }

  if( !pPager->exclusiveMode 
   && (!pagerUseWal(pPager) || sqlite3WalExclusiveMode(pPager->pWal, 0))
  ){







|







51244
51245
51246
51247
51248
51249
51250
51251
51252
51253
51254
51255
51256
51257
51258
    ** successfully committed, but the EXCLUSIVE lock is still held on the
    ** file. So it is safe to truncate the database file to its minimum
    ** required size.  */
    assert( pPager->eLock==EXCLUSIVE_LOCK );
    rc = pager_truncate(pPager, pPager->dbSize);
  }

  if( rc==SQLITE_OK && bCommit ){
    rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_COMMIT_PHASETWO, 0);
    if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;
  }

  if( !pPager->exclusiveMode 
   && (!pagerUseWal(pPager) || sqlite3WalExclusiveMode(pPager->pWal, 0))
  ){
51770
51771
51772
51773
51774
51775
51776
51777
51778
51779
51780
51781
51782
51783
51784
51785
51786
  }
  /* Following a rollback, the database file should be back in its original
  ** state prior to the start of the transaction, so invoke the
  ** SQLITE_FCNTL_DB_UNCHANGED file-control method to disable the
  ** assertion that the transaction counter was modified.
  */
#ifdef SQLITE_DEBUG
  if( pPager->fd->pMethods ){
    sqlite3OsFileControlHint(pPager->fd,SQLITE_FCNTL_DB_UNCHANGED,0);
  }
#endif

  /* If this playback is happening automatically as a result of an IO or 
  ** malloc error that occurred after the change-counter was updated but 
  ** before the transaction was committed, then the change-counter 
  ** modification may just have been reverted. If this happens in exclusive 
  ** mode, then subsequent transactions performed by the connection will not







<
|
<







52063
52064
52065
52066
52067
52068
52069

52070

52071
52072
52073
52074
52075
52076
52077
  }
  /* Following a rollback, the database file should be back in its original
  ** state prior to the start of the transaction, so invoke the
  ** SQLITE_FCNTL_DB_UNCHANGED file-control method to disable the
  ** assertion that the transaction counter was modified.
  */
#ifdef SQLITE_DEBUG

  sqlite3OsFileControlHint(pPager->fd,SQLITE_FCNTL_DB_UNCHANGED,0);

#endif

  /* If this playback is happening automatically as a result of an IO or 
  ** malloc error that occurred after the change-counter was updated but 
  ** before the transaction was committed, then the change-counter 
  ** modification may just have been reverted. If this happens in exclusive 
  ** mode, then subsequent transactions performed by the connection will not
52525
52526
52527
52528
52529
52530
52531
52532
52533
52534
52535
52536

52537
52538
52539
52540
52541
52542
52543
52544
52545
52546
52547
52548
52549
52550
52551
52552
**   SHARED_LOCK   -> EXCLUSIVE_LOCK   | No
**   RESERVED_LOCK -> EXCLUSIVE_LOCK   | Yes
**
** If the busy-handler callback returns non-zero, the lock is 
** retried. If it returns zero, then the SQLITE_BUSY error is
** returned to the caller of the pager API function.
*/
SQLITE_PRIVATE void sqlite3PagerSetBusyhandler(
  Pager *pPager,                       /* Pager object */
  int (*xBusyHandler)(void *),         /* Pointer to busy-handler function */
  void *pBusyHandlerArg                /* Argument to pass to xBusyHandler */
){

  pPager->xBusyHandler = xBusyHandler;
  pPager->pBusyHandlerArg = pBusyHandlerArg;

  if( isOpen(pPager->fd) ){
    void **ap = (void **)&pPager->xBusyHandler;
    assert( ((int(*)(void *))(ap[0]))==xBusyHandler );
    assert( ap[1]==pBusyHandlerArg );
    sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_BUSYHANDLER, (void *)ap);
  }
}

/*
** Change the page size used by the Pager object. The new page size 
** is passed in *pPageSize.
**
** If the pager is in the error state when this function is called, it







|




>


<
<
|
|
|
|
<







52816
52817
52818
52819
52820
52821
52822
52823
52824
52825
52826
52827
52828
52829
52830


52831
52832
52833
52834

52835
52836
52837
52838
52839
52840
52841
**   SHARED_LOCK   -> EXCLUSIVE_LOCK   | No
**   RESERVED_LOCK -> EXCLUSIVE_LOCK   | Yes
**
** If the busy-handler callback returns non-zero, the lock is 
** retried. If it returns zero, then the SQLITE_BUSY error is
** returned to the caller of the pager API function.
*/
SQLITE_PRIVATE void sqlite3PagerSetBusyHandler(
  Pager *pPager,                       /* Pager object */
  int (*xBusyHandler)(void *),         /* Pointer to busy-handler function */
  void *pBusyHandlerArg                /* Argument to pass to xBusyHandler */
){
  void **ap;
  pPager->xBusyHandler = xBusyHandler;
  pPager->pBusyHandlerArg = pBusyHandlerArg;


  ap = (void **)&pPager->xBusyHandler;
  assert( ((int(*)(void *))(ap[0]))==xBusyHandler );
  assert( ap[1]==pBusyHandlerArg );
  sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_BUSYHANDLER, (void *)ap);

}

/*
** Change the page size used by the Pager object. The new page size 
** is passed in *pPageSize.
**
** If the pager is in the error state when this function is called, it
54514
54515
54516
54517
54518
54519
54520

54521
54522
54523
54524
54525
54526
54527
}
SQLITE_PRIVATE void sqlite3PagerUnrefPageOne(DbPage *pPg){
  Pager *pPager;
  assert( pPg!=0 );
  assert( pPg->pgno==1 );
  assert( (pPg->flags & PGHDR_MMAP)==0 ); /* Page1 is never memory mapped */
  pPager = pPg->pPager;

  sqlite3PcacheRelease(pPg);
  pagerUnlockIfUnused(pPager);
}

/*
** This function is called at the start of every write transaction.
** There must already be a RESERVED or EXCLUSIVE lock on the database 







>







54803
54804
54805
54806
54807
54808
54809
54810
54811
54812
54813
54814
54815
54816
54817
}
SQLITE_PRIVATE void sqlite3PagerUnrefPageOne(DbPage *pPg){
  Pager *pPager;
  assert( pPg!=0 );
  assert( pPg->pgno==1 );
  assert( (pPg->flags & PGHDR_MMAP)==0 ); /* Page1 is never memory mapped */
  pPager = pPg->pPager;
  sqlite3PagerResetLockTimeout(pPager);
  sqlite3PcacheRelease(pPg);
  pagerUnlockIfUnused(pPager);
}

/*
** This function is called at the start of every write transaction.
** There must already be a RESERVED or EXCLUSIVE lock on the database 
55109
55110
55111
55112
55113
55114
55115
55116
55117
55118
55119
55120
55121
55122
55123
55124
55125
55126
55127
55128
** or pages with the Pager.noSync flag set.
**
** If successful, or if called on a pager for which it is a no-op, this
** function returns SQLITE_OK. Otherwise, an IO error code is returned.
*/
SQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager, const char *zMaster){
  int rc = SQLITE_OK;

  if( isOpen(pPager->fd) ){
    void *pArg = (void*)zMaster;
    rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC, pArg);
    if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;
  }
  if( rc==SQLITE_OK && !pPager->noSync ){
    assert( !MEMDB );
    rc = sqlite3OsSync(pPager->fd, pPager->syncFlags);
  }
  return rc;
}








<
<
|
|
|
<







55399
55400
55401
55402
55403
55404
55405


55406
55407
55408

55409
55410
55411
55412
55413
55414
55415
** or pages with the Pager.noSync flag set.
**
** If successful, or if called on a pager for which it is a no-op, this
** function returns SQLITE_OK. Otherwise, an IO error code is returned.
*/
SQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager, const char *zMaster){
  int rc = SQLITE_OK;


  void *pArg = (void*)zMaster;
  rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC, pArg);
  if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;

  if( rc==SQLITE_OK && !pPager->noSync ){
    assert( !MEMDB );
    rc = sqlite3OsSync(pPager->fd, pPager->syncFlags);
  }
  return rc;
}

55791
55792
55793
55794
55795
55796
55797










55798
55799
55800
55801
55802
55803
55804
** with the pager.  This might return NULL if the file has
** not yet been opened.
*/
SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager *pPager){
  return pPager->fd;
}











/*
** Return the file handle for the journal file (if it exists).
** This will be either the rollback journal or the WAL file.
*/
SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){
#if SQLITE_OMIT_WAL
  return pPager->jfd;







>
>
>
>
>
>
>
>
>
>







56078
56079
56080
56081
56082
56083
56084
56085
56086
56087
56088
56089
56090
56091
56092
56093
56094
56095
56096
56097
56098
56099
56100
56101
** with the pager.  This might return NULL if the file has
** not yet been opened.
*/
SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager *pPager){
  return pPager->fd;
}

#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
/*
** Reset the lock timeout for pager.
*/
SQLITE_PRIVATE void sqlite3PagerResetLockTimeout(Pager *pPager){
  int x = 0;
  sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_LOCK_TIMEOUT, &x);
}
#endif

/*
** Return the file handle for the journal file (if it exists).
** This will be either the rollback journal or the WAL file.
*/
SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){
#if SQLITE_OMIT_WAL
  return pPager->jfd;
56251
56252
56253
56254
56255
56256
56257

56258
56259
56260
56261
56262
56263
56264
  if( pPager->pWal ){
    rc = sqlite3WalCheckpoint(pPager->pWal, db, eMode,
        (eMode==SQLITE_CHECKPOINT_PASSIVE ? 0 : pPager->xBusyHandler),
        pPager->pBusyHandlerArg,
        pPager->walSyncFlags, pPager->pageSize, (u8 *)pPager->pTmpSpace,
        pnLog, pnCkpt
    );

  }
  return rc;
}

SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager){
  return sqlite3WalCallback(pPager->pWal);
}







>







56548
56549
56550
56551
56552
56553
56554
56555
56556
56557
56558
56559
56560
56561
56562
  if( pPager->pWal ){
    rc = sqlite3WalCheckpoint(pPager->pWal, db, eMode,
        (eMode==SQLITE_CHECKPOINT_PASSIVE ? 0 : pPager->xBusyHandler),
        pPager->pBusyHandlerArg,
        pPager->walSyncFlags, pPager->pageSize, (u8 *)pPager->pTmpSpace,
        pnLog, pnCkpt
    );
    sqlite3PagerResetLockTimeout(pPager);
  }
  return rc;
}

SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager){
  return sqlite3WalCallback(pPager->pWal);
}
63527
63528
63529
63530
63531
63532
63533
63534

63535
63536
63537
63538
63539
63540
63541
/*
** Invoke the busy handler for a btree.
*/
static int btreeInvokeBusyHandler(void *pArg){
  BtShared *pBt = (BtShared*)pArg;
  assert( pBt->db );
  assert( sqlite3_mutex_held(pBt->db->mutex) );
  return sqlite3InvokeBusyHandler(&pBt->db->busyHandler);

}

/*
** Open a database file.
** 
** zFilename is the name of the database file.  If zFilename is NULL
** then an ephemeral database is created.  The ephemeral database might







|
>







63825
63826
63827
63828
63829
63830
63831
63832
63833
63834
63835
63836
63837
63838
63839
63840
/*
** Invoke the busy handler for a btree.
*/
static int btreeInvokeBusyHandler(void *pArg){
  BtShared *pBt = (BtShared*)pArg;
  assert( pBt->db );
  assert( sqlite3_mutex_held(pBt->db->mutex) );
  return sqlite3InvokeBusyHandler(&pBt->db->busyHandler,
                                  sqlite3PagerFile(pBt->pPager));
}

/*
** Open a database file.
** 
** zFilename is the name of the database file.  If zFilename is NULL
** then an ephemeral database is created.  The ephemeral database might
63705
63706
63707
63708
63709
63710
63711
63712
63713
63714
63715
63716
63717
63718
63719
      rc = sqlite3PagerReadFileheader(pBt->pPager,sizeof(zDbHeader),zDbHeader);
    }
    if( rc!=SQLITE_OK ){
      goto btree_open_out;
    }
    pBt->openFlags = (u8)flags;
    pBt->db = db;
    sqlite3PagerSetBusyhandler(pBt->pPager, btreeInvokeBusyHandler, pBt);
    p->pBt = pBt;
  
    pBt->pCursor = 0;
    pBt->pPage1 = 0;
    if( sqlite3PagerIsreadonly(pBt->pPager) ) pBt->btsFlags |= BTS_READ_ONLY;
#if defined(SQLITE_SECURE_DELETE)
    pBt->btsFlags |= BTS_SECURE_DELETE;







|







64004
64005
64006
64007
64008
64009
64010
64011
64012
64013
64014
64015
64016
64017
64018
      rc = sqlite3PagerReadFileheader(pBt->pPager,sizeof(zDbHeader),zDbHeader);
    }
    if( rc!=SQLITE_OK ){
      goto btree_open_out;
    }
    pBt->openFlags = (u8)flags;
    pBt->db = db;
    sqlite3PagerSetBusyHandler(pBt->pPager, btreeInvokeBusyHandler, pBt);
    p->pBt = pBt;
  
    pBt->pCursor = 0;
    pBt->pPage1 = 0;
    if( sqlite3PagerIsreadonly(pBt->pPager) ) pBt->btsFlags |= BTS_READ_ONLY;
#if defined(SQLITE_SECURE_DELETE)
    pBt->btsFlags |= BTS_SECURE_DELETE;
64668
64669
64670
64671
64672
64673
64674

64675
64676
64677
64678
64679
64680
64681
    }
  
    if( rc!=SQLITE_OK ){
      unlockBtreeIfUnused(pBt);
    }
  }while( (rc&0xFF)==SQLITE_BUSY && pBt->inTransaction==TRANS_NONE &&
          btreeInvokeBusyHandler(pBt) );


  if( rc==SQLITE_OK ){
    if( p->inTrans==TRANS_NONE ){
      pBt->nTransaction++;
#ifndef SQLITE_OMIT_SHARED_CACHE
      if( p->sharable ){
        assert( p->lock.pBtree==p && p->lock.iTable==1 );







>







64967
64968
64969
64970
64971
64972
64973
64974
64975
64976
64977
64978
64979
64980
64981
    }
  
    if( rc!=SQLITE_OK ){
      unlockBtreeIfUnused(pBt);
    }
  }while( (rc&0xFF)==SQLITE_BUSY && pBt->inTransaction==TRANS_NONE &&
          btreeInvokeBusyHandler(pBt) );
  sqlite3PagerResetLockTimeout(pBt->pPager);

  if( rc==SQLITE_OK ){
    if( p->inTrans==TRANS_NONE ){
      pBt->nTransaction++;
#ifndef SQLITE_OMIT_SHARED_CACHE
      if( p->sharable ){
        assert( p->lock.pBtree==p && p->lock.iTable==1 );
98713
98714
98715
98716
98717
98718
98719









98720
98721


98722
98723
98724
98725
98726









98727
98728
98729
98730
98731
98732
98733
98734





















98735
98736
98737
98738
98739
98740
98741
98742
98743
98744







98745
98746
98747
98748
98749
98750
98751

/*
** This is the Expr node callback for sqlite3ExprImpliesNotNullRow().
** If the expression node requires that the table at pWalker->iCur
** have a non-NULL column, then set pWalker->eCode to 1 and abort.
*/
static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){









  if( ExprHasProperty(pExpr, EP_FromJoin) ) return WRC_Prune;
  switch( pExpr->op ){


    case TK_ISNULL:
    case TK_IS:
    case TK_OR:
    case TK_FUNCTION:
    case TK_AGG_FUNCTION:









      return WRC_Prune;
    case TK_COLUMN:
    case TK_AGG_COLUMN:
      if( pWalker->u.iCur==pExpr->iTable ){
        pWalker->eCode = 1;
        return WRC_Abort;
      }
      return WRC_Prune;





















    default:
      return WRC_Continue;
  }
}

/*
** Return true (non-zero) if expression p can only be true if at least
** one column of table iTab is non-null.  In other words, return true
** if expression p will always be NULL or false if every column of iTab
** is NULL.







**
** Terms of p that are marked with EP_FromJoin (and hence that come from
** the ON or USING clauses of LEFT JOINS) are excluded from the analysis.
**
** This routine is used to check if a LEFT JOIN can be converted into
** an ordinary JOIN.  The p argument is the WHERE clause.  If the WHERE
** clause requires that some column of the right table of the LEFT JOIN







>
>
>
>
>
>
>
>
>


>
>



|
|
>
>
>
>
>
>
>
>
>


<





>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










>
>
>
>
>
>
>







99013
99014
99015
99016
99017
99018
99019
99020
99021
99022
99023
99024
99025
99026
99027
99028
99029
99030
99031
99032
99033
99034
99035
99036
99037
99038
99039
99040
99041
99042
99043
99044
99045
99046
99047
99048

99049
99050
99051
99052
99053
99054
99055
99056
99057
99058
99059
99060
99061
99062
99063
99064
99065
99066
99067
99068
99069
99070
99071
99072
99073
99074
99075
99076
99077
99078
99079
99080
99081
99082
99083
99084
99085
99086
99087
99088
99089
99090
99091
99092
99093
99094
99095
99096
99097
99098

/*
** This is the Expr node callback for sqlite3ExprImpliesNotNullRow().
** If the expression node requires that the table at pWalker->iCur
** have a non-NULL column, then set pWalker->eCode to 1 and abort.
*/
static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){
  /* This routine is only called for WHERE clause expressions and so it
  ** cannot have any TK_AGG_COLUMN entries because those are only found
  ** in HAVING clauses.  We can get a TK_AGG_FUNCTION in a WHERE clause,
  ** but that is an illegal construct and the query will be rejected at
  ** a later stage of processing, so the TK_AGG_FUNCTION case does not
  ** need to be considered here. */
  assert( pExpr->op!=TK_AGG_COLUMN );
  testcase( pExpr->op==TK_AGG_FUNCTION );

  if( ExprHasProperty(pExpr, EP_FromJoin) ) return WRC_Prune;
  switch( pExpr->op ){
    case TK_ISNOT:
    case TK_NOT:
    case TK_ISNULL:
    case TK_IS:
    case TK_OR:
    case TK_CASE:
    case TK_IN:
    case TK_FUNCTION:
      testcase( pExpr->op==TK_ISNOT );
      testcase( pExpr->op==TK_NOT );
      testcase( pExpr->op==TK_ISNULL );
      testcase( pExpr->op==TK_IS );
      testcase( pExpr->op==TK_OR );
      testcase( pExpr->op==TK_CASE );
      testcase( pExpr->op==TK_IN );
      testcase( pExpr->op==TK_FUNCTION );
      return WRC_Prune;
    case TK_COLUMN:

      if( pWalker->u.iCur==pExpr->iTable ){
        pWalker->eCode = 1;
        return WRC_Abort;
      }
      return WRC_Prune;

    /* Virtual tables are allowed to use constraints like x=NULL.  So
    ** a term of the form x=y does not prove that y is not null if x
    ** is the column of a virtual table */
    case TK_EQ:
    case TK_NE:
    case TK_LT:
    case TK_LE:
    case TK_GT:
    case TK_GE:
      testcase( pExpr->op==TK_EQ );
      testcase( pExpr->op==TK_NE );
      testcase( pExpr->op==TK_LT );
      testcase( pExpr->op==TK_LE );
      testcase( pExpr->op==TK_GT );
      testcase( pExpr->op==TK_GE );
      if( (pExpr->pLeft->op==TK_COLUMN && IsVirtual(pExpr->pLeft->pTab))
       || (pExpr->pRight->op==TK_COLUMN && IsVirtual(pExpr->pRight->pTab))
      ){
       return WRC_Prune;
      }
    default:
      return WRC_Continue;
  }
}

/*
** Return true (non-zero) if expression p can only be true if at least
** one column of table iTab is non-null.  In other words, return true
** if expression p will always be NULL or false if every column of iTab
** is NULL.
**
** False negatives are acceptable.  In other words, it is ok to return
** zero even if expression p will never be true of every column of iTab
** is NULL.  A false negative is merely a missed optimization opportunity.
**
** False positives are not allowed, however.  A false positive may result
** in an incorrect answer.
**
** Terms of p that are marked with EP_FromJoin (and hence that come from
** the ON or USING clauses of LEFT JOINS) are excluded from the analysis.
**
** This routine is used to check if a LEFT JOIN can be converted into
** an ordinary JOIN.  The p argument is the WHERE clause.  If the WHERE
** clause requires that some column of the right table of the LEFT JOIN
101003
101004
101005
101006
101007
101008
101009
101010
101011
101012
101013
101014
101015
101016
101017
  if( v==0 || NEVER(pTab==0) ){
    return;
  }
  if( pTab->tnum==0 ){
    /* Do not gather statistics on views or virtual tables */
    return;
  }
  if( sqlite3_strlike("sqlite_%", pTab->zName, 0)==0 ){
    /* Do not gather statistics on system tables */
    return;
  }
  assert( sqlite3BtreeHoldsAllMutexes(db) );
  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
  assert( iDb>=0 );
  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );







|







101350
101351
101352
101353
101354
101355
101356
101357
101358
101359
101360
101361
101362
101363
101364
  if( v==0 || NEVER(pTab==0) ){
    return;
  }
  if( pTab->tnum==0 ){
    /* Do not gather statistics on views or virtual tables */
    return;
  }
  if( sqlite3_strlike("sqlite\\_%", pTab->zName, '\\')==0 ){
    /* Do not gather statistics on system tables */
    return;
  }
  assert( sqlite3BtreeHoldsAllMutexes(db) );
  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
  assert( iDb>=0 );
  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
104064
104065
104066
104067
104068
104069
104070
104071
104072
104073
104074
104075
104076
104077
104078
  if( p!=0 ){
    pCol = &(p->aCol[p->nCol-1]);
    if( !sqlite3ExprIsConstantOrFunction(pExpr, db->init.busy) ){
      sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant",
          pCol->zName);
    }else{
      /* A copy of pExpr is used instead of the original, as pExpr contains
      ** tokens that point to volatile memory.	
      */
      Expr x;
      sqlite3ExprDelete(db, pCol->pDflt);
      memset(&x, 0, sizeof(x));
      x.op = TK_SPAN;
      x.u.zToken = sqlite3DbSpanDup(db, zStart, zEnd);
      x.pLeft = pExpr;







|







104411
104412
104413
104414
104415
104416
104417
104418
104419
104420
104421
104422
104423
104424
104425
  if( p!=0 ){
    pCol = &(p->aCol[p->nCol-1]);
    if( !sqlite3ExprIsConstantOrFunction(pExpr, db->init.busy) ){
      sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant",
          pCol->zName);
    }else{
      /* A copy of pExpr is used instead of the original, as pExpr contains
      ** tokens that point to volatile memory.
      */
      Expr x;
      sqlite3ExprDelete(db, pCol->pDflt);
      memset(&x, 0, sizeof(x));
      x.op = TK_SPAN;
      x.u.zToken = sqlite3DbSpanDup(db, zStart, zEnd);
      x.pLeft = pExpr;
104308
104309
104310
104311
104312
104313
104314
104315
104316
104317
104318
104319
104320
104321
104322
** the schema-version whenever the schema changes.
*/
SQLITE_PRIVATE void sqlite3ChangeCookie(Parse *pParse, int iDb){
  sqlite3 *db = pParse->db;
  Vdbe *v = pParse->pVdbe;
  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
  sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, 
                    db->aDb[iDb].pSchema->schema_cookie+1);
}

/*
** Measure the number of characters needed to output the given
** identifier.  The number returned includes any quotes used
** but does not include the null terminator.
**







|







104655
104656
104657
104658
104659
104660
104661
104662
104663
104664
104665
104666
104667
104668
104669
** the schema-version whenever the schema changes.
*/
SQLITE_PRIVATE void sqlite3ChangeCookie(Parse *pParse, int iDb){
  sqlite3 *db = pParse->db;
  Vdbe *v = pParse->pVdbe;
  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
  sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, 
                   (int)(1+(unsigned)db->aDb[iDb].pSchema->schema_cookie));
}

/*
** Measure the number of characters needed to output the given
** identifier.  The number returned includes any quotes used
** but does not include the null terminator.
**
104986
104987
104988
104989
104990
104991
104992
104993
104994
104995
104996
104997
104998
104999
105000
*/
SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
  Table *pSelTab;   /* A fake table from which we get the result set */
  Select *pSel;     /* Copy of the SELECT that implements the view */
  int nErr = 0;     /* Number of errors encountered */
  int n;            /* Temporarily holds the number of cursors assigned */
  sqlite3 *db = pParse->db;  /* Database connection for malloc errors */
#ifndef SQLITE_OMIT_VIRTUALTABLE	
  int rc;
#endif
#ifndef SQLITE_OMIT_AUTHORIZATION
  sqlite3_xauth xAuth;       /* Saved xAuth pointer */
#endif

  assert( pTable );







|







105333
105334
105335
105336
105337
105338
105339
105340
105341
105342
105343
105344
105345
105346
105347
*/
SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
  Table *pSelTab;   /* A fake table from which we get the result set */
  Select *pSel;     /* Copy of the SELECT that implements the view */
  int nErr = 0;     /* Number of errors encountered */
  int n;            /* Temporarily holds the number of cursors assigned */
  sqlite3 *db = pParse->db;  /* Database connection for malloc errors */
#ifndef SQLITE_OMIT_VIRTUALTABLE
  int rc;
#endif
#ifndef SQLITE_OMIT_AUTHORIZATION
  sqlite3_xauth xAuth;       /* Saved xAuth pointer */
#endif

  assert( pTable );
123692
123693
123694
123695
123696
123697
123698
123699
123700
123701
123702
123703
123704
123705
123706
      ** (the only way this can happen is if the compound sub-query is
      ** currently part of pSub->pSrc). See ticket [d11a6e908f].  */
      ExprList *pOrderBy = pSub->pOrderBy;
      for(i=0; i<pOrderBy->nExpr; i++){
        pOrderBy->a[i].u.x.iOrderByCol = 0;
      }
      assert( pParent->pOrderBy==0 );
      assert( pSub->pPrior==0 );
      pParent->pOrderBy = pOrderBy;
      pSub->pOrderBy = 0;
    }
    pWhere = sqlite3ExprDup(db, pSub->pWhere, 0);
    if( isLeftJoin>0 ){
      setJoinExpr(pWhere, iNewParent);
    }







<







124039
124040
124041
124042
124043
124044
124045

124046
124047
124048
124049
124050
124051
124052
      ** (the only way this can happen is if the compound sub-query is
      ** currently part of pSub->pSrc). See ticket [d11a6e908f].  */
      ExprList *pOrderBy = pSub->pOrderBy;
      for(i=0; i<pOrderBy->nExpr; i++){
        pOrderBy->a[i].u.x.iOrderByCol = 0;
      }
      assert( pParent->pOrderBy==0 );

      pParent->pOrderBy = pOrderBy;
      pSub->pOrderBy = 0;
    }
    pWhere = sqlite3ExprDup(db, pSub->pWhere, 0);
    if( isLeftJoin>0 ){
      setJoinExpr(pWhere, iNewParent);
    }
123776
123777
123778
123779
123780
123781
123782
123783
123784


123785
123786
123787
123788
123789
123790
123791
**           to suppress it. **)
**
**   (2) The inner query is the recursive part of a common table expression.
**
**   (3) The inner query has a LIMIT clause (since the changes to the WHERE
**       close would change the meaning of the LIMIT).
**
**   (4) (** This restriction was removed on 2018-03-21.  It used to read:
**       The inner query is the right operand of a LEFT JOIN. **)


**
**   (5) The WHERE clause expression originates in the ON or USING clause
**       of a LEFT JOIN where iCursor is not the right-hand table of that
**       left join.  An example:
**
**           SELECT *
**           FROM (SELECT 1 AS a1 UNION ALL SELECT 2) AS aa







<
|
>
>







124122
124123
124124
124125
124126
124127
124128

124129
124130
124131
124132
124133
124134
124135
124136
124137
124138
**           to suppress it. **)
**
**   (2) The inner query is the recursive part of a common table expression.
**
**   (3) The inner query has a LIMIT clause (since the changes to the WHERE
**       close would change the meaning of the LIMIT).
**

**   (4) The inner query is the right operand of a LEFT JOIN and the
**       expression to be pushed down does not come from the ON clause
**       on that LEFT JOIN.
**
**   (5) The WHERE clause expression originates in the ON or USING clause
**       of a LEFT JOIN where iCursor is not the right-hand table of that
**       left join.  An example:
**
**           SELECT *
**           FROM (SELECT 1 AS a1 UNION ALL SELECT 2) AS aa
123799
123800
123801
123802
123803
123804
123805
123806

123807
123808
123809
123810
123811
123812
123813
** Return 0 if no changes are made and non-zero if one or more WHERE clause
** terms are duplicated into the subquery.
*/
static int pushDownWhereTerms(
  Parse *pParse,        /* Parse context (for malloc() and error reporting) */
  Select *pSubq,        /* The subquery whose WHERE clause is to be augmented */
  Expr *pWhere,         /* The WHERE clause of the outer query */
  int iCursor           /* Cursor number of the subquery */

){
  Expr *pNew;
  int nChng = 0;
  if( pWhere==0 ) return 0;
  if( pSubq->selFlags & SF_Recursive ) return 0;  /* restriction (2) */

#ifdef SQLITE_DEBUG







|
>







124146
124147
124148
124149
124150
124151
124152
124153
124154
124155
124156
124157
124158
124159
124160
124161
** Return 0 if no changes are made and non-zero if one or more WHERE clause
** terms are duplicated into the subquery.
*/
static int pushDownWhereTerms(
  Parse *pParse,        /* Parse context (for malloc() and error reporting) */
  Select *pSubq,        /* The subquery whose WHERE clause is to be augmented */
  Expr *pWhere,         /* The WHERE clause of the outer query */
  int iCursor,          /* Cursor number of the subquery */
  int isLeftJoin        /* True if pSubq is the right term of a LEFT JOIN */
){
  Expr *pNew;
  int nChng = 0;
  if( pWhere==0 ) return 0;
  if( pSubq->selFlags & SF_Recursive ) return 0;  /* restriction (2) */

#ifdef SQLITE_DEBUG
123823
123824
123825
123826
123827
123828
123829
123830

123831
123832






123833
123834
123835
123836
123837
123838
123839
  }
#endif

  if( pSubq->pLimit!=0 ){
    return 0; /* restriction (3) */
  }
  while( pWhere->op==TK_AND ){
    nChng += pushDownWhereTerms(pParse, pSubq, pWhere->pRight, iCursor);

    pWhere = pWhere->pLeft;
  }






  if( ExprHasProperty(pWhere,EP_FromJoin) && pWhere->iRightJoinTable!=iCursor ){
    return 0; /* restriction (5) */
  }
  if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){
    nChng++;
    while( pSubq ){
      SubstContext x;







|
>


>
>
>
>
>
>







124171
124172
124173
124174
124175
124176
124177
124178
124179
124180
124181
124182
124183
124184
124185
124186
124187
124188
124189
124190
124191
124192
124193
124194
  }
#endif

  if( pSubq->pLimit!=0 ){
    return 0; /* restriction (3) */
  }
  while( pWhere->op==TK_AND ){
    nChng += pushDownWhereTerms(pParse, pSubq, pWhere->pRight,
                                iCursor, isLeftJoin);
    pWhere = pWhere->pLeft;
  }
  if( isLeftJoin
   && (ExprHasProperty(pWhere,EP_FromJoin)==0
         || pWhere->iRightJoinTable!=iCursor)
  ){
    return 0; /* restriction (4) */
  }
  if( ExprHasProperty(pWhere,EP_FromJoin) && pWhere->iRightJoinTable!=iCursor ){
    return 0; /* restriction (5) */
  }
  if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){
    nChng++;
    while( pSubq ){
      SubstContext x;
124289
124290
124291
124292
124293
124294
124295
124296
124297
124298
124299
124300
124301
124302
124303
124304
124305
  }
  assert( p->pSrc!=0 );
  if( (selFlags & SF_Expanded)!=0 ){
    return WRC_Prune;
  }
  pTabList = p->pSrc;
  pEList = p->pEList;
  if( OK_IF_ALWAYS_TRUE(p->pWith) ){
    sqlite3WithPush(pParse, p->pWith, 0);
  }

  /* Make sure cursor numbers have been assigned to all entries in
  ** the FROM clause of the SELECT statement.
  */
  sqlite3SrcListAssignCursors(pParse, pTabList);

  /* Look up every table named in the FROM clause of the select.  If







<
|
<







124644
124645
124646
124647
124648
124649
124650

124651

124652
124653
124654
124655
124656
124657
124658
  }
  assert( p->pSrc!=0 );
  if( (selFlags & SF_Expanded)!=0 ){
    return WRC_Prune;
  }
  pTabList = p->pSrc;
  pEList = p->pEList;

  sqlite3WithPush(pParse, p->pWith, 0);


  /* Make sure cursor numbers have been assigned to all entries in
  ** the FROM clause of the SELECT statement.
  */
  sqlite3SrcListAssignCursors(pParse, pTabList);

  /* Look up every table named in the FROM clause of the select.  If
125293
125294
125295
125296
125297
125298
125299
125300

125301
125302
125303
125304
125305
125306
125307
    */
    pParse->nHeight += sqlite3SelectExprHeight(p);

    /* Make copies of constant WHERE-clause terms in the outer query down
    ** inside the subquery.  This can help the subquery to run more efficiently.
    */
    if( OptimizationEnabled(db, SQLITE_PushDown)
     && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor)

    ){
#if SELECTTRACE_ENABLED
      if( sqlite3SelectTrace & 0x100 ){
        SELECTTRACE(0x100,pParse,p,("After WHERE-clause push-down:\n"));
        sqlite3TreeViewSelect(0, p, 0);
      }
#endif







|
>







125646
125647
125648
125649
125650
125651
125652
125653
125654
125655
125656
125657
125658
125659
125660
125661
    */
    pParse->nHeight += sqlite3SelectExprHeight(p);

    /* Make copies of constant WHERE-clause terms in the outer query down
    ** inside the subquery.  This can help the subquery to run more efficiently.
    */
    if( OptimizationEnabled(db, SQLITE_PushDown)
     && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor,
                           (pItem->fg.jointype & JT_OUTER)!=0)
    ){
#if SELECTTRACE_ENABLED
      if( sqlite3SelectTrace & 0x100 ){
        SELECTTRACE(0x100,pParse,p,("After WHERE-clause push-down:\n"));
        sqlite3TreeViewSelect(0, p, 0);
      }
#endif
127753
127754
127755
127756
127757
127758
127759
127760
127761
127762
127763
127764
127765
127766
127767
    assert( pPk!=0 );
    nPk = pPk->nKeyCol;
    iPk = pParse->nMem+1;
    pParse->nMem += nPk;
    regKey = ++pParse->nMem;
    iEph = pParse->nTab++;

    sqlite3VdbeAddOp2(v, OP_Null, 0, iPk);
    addrOpen = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iEph, nPk);
    sqlite3VdbeSetP4KeyInfo(pParse, pPk);
  }

  /* Begin the database scan. 
  **
  ** Do not consider a single-pass strategy for a multi-row update if







|







128107
128108
128109
128110
128111
128112
128113
128114
128115
128116
128117
128118
128119
128120
128121
    assert( pPk!=0 );
    nPk = pPk->nKeyCol;
    iPk = pParse->nMem+1;
    pParse->nMem += nPk;
    regKey = ++pParse->nMem;
    iEph = pParse->nTab++;

    sqlite3VdbeAddOp3(v, OP_Null, 0, iPk, iPk+nPk-1);
    addrOpen = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iEph, nPk);
    sqlite3VdbeSetP4KeyInfo(pParse, pPk);
  }

  /* Begin the database scan. 
  **
  ** Do not consider a single-pass strategy for a multi-row update if
129925
129926
129927
129928
129929
129930
129931
129932
129933
129934
129935
129936
129937
129938
129939
** a separate source file for easier editing.
*/

/*
** Trace output macros
*/
#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
/***/ int sqlite3WhereTrace;
#endif
#if defined(SQLITE_DEBUG) \
    && (defined(SQLITE_TEST) || defined(SQLITE_ENABLE_WHERETRACE))
# define WHERETRACE(K,X)  if(sqlite3WhereTrace&(K)) sqlite3DebugPrintf X
# define WHERETRACE_ENABLED 1
#else
# define WHERETRACE(K,X)







|







130279
130280
130281
130282
130283
130284
130285
130286
130287
130288
130289
130290
130291
130292
130293
** a separate source file for easier editing.
*/

/*
** Trace output macros
*/
#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
/***/ extern int sqlite3WhereTrace;
#endif
#if defined(SQLITE_DEBUG) \
    && (defined(SQLITE_TEST) || defined(SQLITE_ENABLE_WHERETRACE))
# define WHERETRACE(K,X)  if(sqlite3WhereTrace&(K)) sqlite3DebugPrintf X
# define WHERETRACE_ENABLED 1
#else
# define WHERETRACE(K,X)
132574
132575
132576
132577
132578
132579
132580
132581
132582
132583
132584
132585
132586
132587
132588
132589
132590
132591
132592

132593
132594
132595
132596
132597
132598
132599
        continue;
      }
      if( iLoop<3 && (pTerm->wtFlags & TERM_VARSELECT) ){
        if( iNext==0 ) iNext = 3;
        continue;
      }

      if( pTerm->wtFlags & TERM_LIKECOND ){
        /* If the TERM_LIKECOND flag is set, that means that the range search
        ** is sufficient to guarantee that the LIKE operator is true, so we
        ** can skip the call to the like(A,B) function.  But this only works
        ** for strings.  So do not skip the call to the function on the pass
        ** that compares BLOBs. */
#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS
        continue;
#else
        u32 x = pLevel->iLikeRepCntr;
        assert( x>0 );
        skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)?OP_IfNot:OP_If, (int)(x>>1));

        VdbeCoverage(v);
#endif
      }
#ifdef WHERETRACE_ENABLED /* 0xffff */
      if( sqlite3WhereTrace ){
        VdbeNoopComment((v, "WhereTerm[%d] (%p) priority=%d",
                         pWC->nTerm-j, pTerm, iLoop));







|









|
|
>







132928
132929
132930
132931
132932
132933
132934
132935
132936
132937
132938
132939
132940
132941
132942
132943
132944
132945
132946
132947
132948
132949
132950
132951
132952
132953
132954
        continue;
      }
      if( iLoop<3 && (pTerm->wtFlags & TERM_VARSELECT) ){
        if( iNext==0 ) iNext = 3;
        continue;
      }

      if( (pTerm->wtFlags & TERM_LIKECOND)!=0 ){
        /* If the TERM_LIKECOND flag is set, that means that the range search
        ** is sufficient to guarantee that the LIKE operator is true, so we
        ** can skip the call to the like(A,B) function.  But this only works
        ** for strings.  So do not skip the call to the function on the pass
        ** that compares BLOBs. */
#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS
        continue;
#else
        u32 x = pLevel->iLikeRepCntr;
        if( x>0 ){
          skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)?OP_IfNot:OP_If,(int)(x>>1));
        }
        VdbeCoverage(v);
#endif
      }
#ifdef WHERETRACE_ENABLED /* 0xffff */
      if( sqlite3WhereTrace ){
        VdbeNoopComment((v, "WhereTerm[%d] (%p) priority=%d",
                         pWC->nTerm-j, pTerm, iLoop));
136577
136578
136579
136580
136581
136582
136583
136584
136585
136586
136587
136588
136589
136590
136591
136592
  int rc = SQLITE_OK;             /* Return code */
  LogEst rSize;                   /* Number of rows in the table */
  LogEst rLogSize;                /* Logarithm of table size */
  WhereTerm *pTop = 0, *pBtm = 0; /* Top and bottom range constraints */

  pNew = pBuilder->pNew;
  if( db->mallocFailed ) return SQLITE_NOMEM_BKPT;
  WHERETRACE(0x800, ("BEGIN addBtreeIdx(%s), nEq=%d\n",
                     pProbe->zName, pNew->u.btree.nEq));

  assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 );
  assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 );
  if( pNew->wsFlags & WHERE_BTM_LIMIT ){
    opMask = WO_LT|WO_LE;
  }else{
    assert( pNew->u.btree.nBtm==0 );







|
|







136932
136933
136934
136935
136936
136937
136938
136939
136940
136941
136942
136943
136944
136945
136946
136947
  int rc = SQLITE_OK;             /* Return code */
  LogEst rSize;                   /* Number of rows in the table */
  LogEst rLogSize;                /* Logarithm of table size */
  WhereTerm *pTop = 0, *pBtm = 0; /* Top and bottom range constraints */

  pNew = pBuilder->pNew;
  if( db->mallocFailed ) return SQLITE_NOMEM_BKPT;
  WHERETRACE(0x800, ("BEGIN %s.addBtreeIdx(%s), nEq=%d\n",
                     pProbe->pTable->zName,pProbe->zName, pNew->u.btree.nEq));

  assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 );
  assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 );
  if( pNew->wsFlags & WHERE_BTM_LIMIT ){
    opMask = WO_LT|WO_LE;
  }else{
    assert( pNew->u.btree.nBtm==0 );
136864
136865
136866
136867
136868
136869
136870
136871
136872
136873
136874
136875
136876
136877
136878
136879
    whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter + nInMul);
    pNew->nOut = saved_nOut;
    pNew->u.btree.nEq = saved_nEq;
    pNew->nSkip = saved_nSkip;
    pNew->wsFlags = saved_wsFlags;
  }

  WHERETRACE(0x800, ("END addBtreeIdx(%s), nEq=%d, rc=%d\n",
                      pProbe->zName, saved_nEq, rc));
  return rc;
}

/*
** Return True if it is possible that pIndex might be useful in
** implementing the ORDER BY clause in pBuilder.
**







|
|







137219
137220
137221
137222
137223
137224
137225
137226
137227
137228
137229
137230
137231
137232
137233
137234
    whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter + nInMul);
    pNew->nOut = saved_nOut;
    pNew->u.btree.nEq = saved_nEq;
    pNew->nSkip = saved_nSkip;
    pNew->wsFlags = saved_wsFlags;
  }

  WHERETRACE(0x800, ("END %s.addBtreeIdx(%s), nEq=%d, rc=%d\n",
                      pProbe->pTable->zName, pProbe->zName, saved_nEq, rc));
  return rc;
}

/*
** Return True if it is possible that pIndex might be useful in
** implementing the ORDER BY clause in pBuilder.
**
137303
137304
137305
137306
137307
137308
137309
137310
137311

137312
137313
137314
137315
137316
137317
137318
137319
      int j = pIdxCons->iTermOffset;
      if( iTerm>=nConstraint
       || j<0
       || j>=pWC->nTerm
       || pNew->aLTerm[iTerm]!=0
       || pIdxCons->usable==0
      ){
        rc = SQLITE_ERROR;
        sqlite3ErrorMsg(pParse,"%s.xBestIndex malfunction",pSrc->pTab->zName);

        return rc;
      }
      testcase( iTerm==nConstraint-1 );
      testcase( j==0 );
      testcase( j==pWC->nTerm-1 );
      pTerm = &pWC->a[j];
      pNew->prereq |= pTerm->prereqRight;
      assert( iTerm<pNew->nLSlot );







<

>
|







137658
137659
137660
137661
137662
137663
137664

137665
137666
137667
137668
137669
137670
137671
137672
137673
137674
      int j = pIdxCons->iTermOffset;
      if( iTerm>=nConstraint
       || j<0
       || j>=pWC->nTerm
       || pNew->aLTerm[iTerm]!=0
       || pIdxCons->usable==0
      ){

        sqlite3ErrorMsg(pParse,"%s.xBestIndex malfunction",pSrc->pTab->zName);
        testcase( pIdxInfo->needToFreeIdxStr );
        return SQLITE_ERROR;
      }
      testcase( iTerm==nConstraint-1 );
      testcase( j==0 );
      testcase( j==pWC->nTerm-1 );
      pTerm = &pWC->a[j];
      pNew->prereq |= pTerm->prereqRight;
      assert( iTerm<pNew->nLSlot );
137333
137334
137335
137336
137337
137338
137339









137340
137341
137342
137343
137344
137345
137346
        *pbIn = 1; assert( (mExclude & WO_IN)==0 );
      }
    }
  }
  pNew->u.vtab.omitMask &= ~mNoOmit;

  pNew->nLTerm = mxTerm+1;









  assert( pNew->nLTerm<=pNew->nLSlot );
  pNew->u.vtab.idxNum = pIdxInfo->idxNum;
  pNew->u.vtab.needFree = pIdxInfo->needToFreeIdxStr;
  pIdxInfo->needToFreeIdxStr = 0;
  pNew->u.vtab.idxStr = pIdxInfo->idxStr;
  pNew->u.vtab.isOrdered = (i8)(pIdxInfo->orderByConsumed ?
      pIdxInfo->nOrderBy : 0);







>
>
>
>
>
>
>
>
>







137688
137689
137690
137691
137692
137693
137694
137695
137696
137697
137698
137699
137700
137701
137702
137703
137704
137705
137706
137707
137708
137709
137710
        *pbIn = 1; assert( (mExclude & WO_IN)==0 );
      }
    }
  }
  pNew->u.vtab.omitMask &= ~mNoOmit;

  pNew->nLTerm = mxTerm+1;
  for(i=0; i<=mxTerm; i++){
    if( pNew->aLTerm[i]==0 ){
      /* The non-zero argvIdx values must be contiguous.  Raise an
      ** error if they are not */
      sqlite3ErrorMsg(pParse,"%s.xBestIndex malfunction",pSrc->pTab->zName);
      testcase( pIdxInfo->needToFreeIdxStr );
      return SQLITE_ERROR;
    }
  }
  assert( pNew->nLTerm<=pNew->nLSlot );
  pNew->u.vtab.idxNum = pIdxInfo->idxNum;
  pNew->u.vtab.needFree = pIdxInfo->needToFreeIdxStr;
  pIdxInfo->needToFreeIdxStr = 0;
  pNew->u.vtab.idxStr = pIdxInfo->idxStr;
  pNew->u.vtab.isOrdered = (i8)(pIdxInfo->orderByConsumed ?
      pIdxInfo->nOrderBy : 0);
137448
137449
137450
137451
137452
137453
137454

137455
137456
137457
137458
137459
137460
137461
  nConstraint = p->nConstraint;
  if( whereLoopResize(pParse->db, pNew, nConstraint) ){
    sqlite3DbFree(pParse->db, p);
    return SQLITE_NOMEM_BKPT;
  }

  /* First call xBestIndex() with all constraints usable. */

  WHERETRACE(0x40, ("  VirtualOne: all usable\n"));
  rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn);

  /* If the call to xBestIndex() with all terms enabled produced a plan
  ** that does not require any source tables (IOW: a plan with mBest==0),
  ** then there is no point in making any further calls to xBestIndex() 
  ** since they will all return the same result (if the xBestIndex()







>







137812
137813
137814
137815
137816
137817
137818
137819
137820
137821
137822
137823
137824
137825
137826
  nConstraint = p->nConstraint;
  if( whereLoopResize(pParse->db, pNew, nConstraint) ){
    sqlite3DbFree(pParse->db, p);
    return SQLITE_NOMEM_BKPT;
  }

  /* First call xBestIndex() with all constraints usable. */
  WHERETRACE(0x800, ("BEGIN %s.addVirtual()\n", pSrc->pTab->zName));
  WHERETRACE(0x40, ("  VirtualOne: all usable\n"));
  rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn);

  /* If the call to xBestIndex() with all terms enabled produced a plan
  ** that does not require any source tables (IOW: a plan with mBest==0),
  ** then there is no point in making any further calls to xBestIndex() 
  ** since they will all return the same result (if the xBestIndex()
137523
137524
137525
137526
137527
137528
137529

137530
137531
137532
137533
137534
137535
137536
      rc = whereLoopAddVirtualOne(
          pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn);
    }
  }

  if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr);
  sqlite3DbFreeNN(pParse->db, p);

  return rc;
}
#endif /* SQLITE_OMIT_VIRTUALTABLE */

/*
** Add WhereLoop entries to handle OR terms.  This works for either
** btrees or virtual tables.







>







137888
137889
137890
137891
137892
137893
137894
137895
137896
137897
137898
137899
137900
137901
137902
      rc = whereLoopAddVirtualOne(
          pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn);
    }
  }

  if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr);
  sqlite3DbFreeNN(pParse->db, p);
  WHERETRACE(0x800, ("END %s.addVirtual(), rc=%d\n", pSrc->pTab->zName, rc));
  return rc;
}
#endif /* SQLITE_OMIT_VIRTUALTABLE */

/*
** Add WhereLoop entries to handle OR terms.  This works for either
** btrees or virtual tables.
139663
139664
139665
139666
139667
139668
139669
139670
139671
139672
139673
139674
139675
139676
139677
139678
139679
139680
139681
139682
139683
139684
139685
139686
139687
#define YYSTACKDEPTH 100
#endif
#define sqlite3ParserARG_SDECL Parse *pParse;
#define sqlite3ParserARG_PDECL ,Parse *pParse
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
#define YYFALLBACK 1
#define YYNSTATE             466
#define YYNRULE              330
#define YYNTOKEN             143
#define YY_MAX_SHIFT         465
#define YY_MIN_SHIFTREDUCE   675
#define YY_MAX_SHIFTREDUCE   1004
#define YY_ERROR_ACTION      1005
#define YY_ACCEPT_ACTION     1006
#define YY_NO_ACTION         1007
#define YY_MIN_REDUCE        1008
#define YY_MAX_REDUCE        1337
/************* End control #defines *******************************************/

/* Define the yytestcase() macro to be a no-op if is not already defined
** otherwise.
**
** Applications can choose to define yytestcase() in the %include section
** to a macro that can assist in verifying code coverage.  For production







|
|

|
|
|
|
|
|
|
|







140029
140030
140031
140032
140033
140034
140035
140036
140037
140038
140039
140040
140041
140042
140043
140044
140045
140046
140047
140048
140049
140050
140051
140052
140053
#define YYSTACKDEPTH 100
#endif
#define sqlite3ParserARG_SDECL Parse *pParse;
#define sqlite3ParserARG_PDECL ,Parse *pParse
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
#define YYFALLBACK 1
#define YYNSTATE             472
#define YYNRULE              333
#define YYNTOKEN             143
#define YY_MAX_SHIFT         471
#define YY_MIN_SHIFTREDUCE   681
#define YY_MAX_SHIFTREDUCE   1013
#define YY_ERROR_ACTION      1014
#define YY_ACCEPT_ACTION     1015
#define YY_NO_ACTION         1016
#define YY_MIN_REDUCE        1017
#define YY_MAX_REDUCE        1349
/************* End control #defines *******************************************/

/* Define the yytestcase() macro to be a no-op if is not already defined
** otherwise.
**
** Applications can choose to define yytestcase() in the %include section
** to a macro that can assist in verifying code coverage.  For production
139739
139740
139741
139742
139743
139744
139745
139746
139747
139748
139749
139750
139751
139752
139753
139754
139755
139756
139757
139758
139759
139760
139761
139762
139763
139764
139765
139766
139767
139768
139769
139770
139771
139772
139773
139774
139775
139776
139777
139778
139779
139780
139781
139782
139783
139784
139785
139786
139787
139788
139789
139790
139791
139792
139793
139794
139795
139796
139797
139798
139799
139800
139801
139802
139803
139804
139805
139806
139807
139808
139809
139810
139811
139812
139813
139814
139815
139816
139817
139818
139819
139820
139821
139822
139823
139824
139825
139826
139827
139828
139829
139830
139831
139832
139833
139834
139835
139836
139837
139838
139839
139840
139841
139842
139843
139844
139845
139846
139847
139848
139849
139850
139851
139852
139853
139854
139855
139856
139857
139858
139859
139860
139861
139862
139863
139864
139865
139866
139867
139868
139869
139870
139871
139872
139873
139874
139875
139876
139877
139878
139879
139880
139881
139882
139883
139884
139885
139886
139887
139888
139889
139890
139891
139892
139893
139894
139895
139896
139897
139898
139899
139900
139901
139902


139903
139904
139905
139906
139907
139908
139909
139910
139911
139912
139913
139914
139915
139916
139917
139918
139919
139920
139921
139922
139923
139924
139925
139926
139927
139928
139929
139930
139931
139932
139933
139934
139935
139936
139937
139938
139939
139940
139941
139942
139943
139944
139945
139946
139947
139948
139949
139950
139951
139952
139953
139954
139955
139956
139957
139958
139959
139960
139961
139962
139963
139964
139965
139966
139967
139968
139969
139970
139971
139972
139973
139974
139975
139976
139977
139978
139979
139980
139981
139982
139983
139984
139985
139986
139987
139988
139989
139990
139991
139992
139993
139994
139995
139996
139997
139998
139999
140000
140001
140002
140003
140004
140005
140006
140007
140008
140009
140010
140011
140012
140013
140014
140015
140016
140017
140018

140019
140020
140021
140022
140023
140024
140025
140026

140027
140028
140029
140030
140031
140032
140033
140034
140035

140036
140037
140038
140039

140040

140041
140042
140043
140044
140045
140046
140047
140048
140049
140050
140051
140052
140053
140054
140055
140056
140057
140058
140059
140060
140061
140062
140063
140064
140065
140066
140067
140068
140069
140070
140071
140072
140073


140074
140075
140076
140077
140078
140079
140080

140081
140082
140083
140084
140085
140086
140087
140088
140089
140090
140091
140092
140093
140094
140095
140096
140097
140098
140099
140100
140101
140102
140103
140104
140105
140106
140107
140108
140109
140110
140111
140112
140113
140114
140115
140116
140117
140118
140119
140120
140121
140122
140123
140124
140125

140126
140127
140128
140129
140130
140131
140132
140133
140134
140135
140136
140137
140138
140139
140140
140141
140142
140143
140144
140145
140146
140147
140148
140149
140150
140151
140152
140153
140154
140155
140156
140157
140158
140159
140160
140161
140162
140163
140164

140165
140166
140167
140168
140169
140170
140171
140172
140173
140174
140175
140176
140177
140178
140179
140180
140181
140182
140183
140184
140185
140186
140187
140188
140189
140190
140191
140192
140193
140194
140195
140196
140197
140198
140199
140200
140201
140202
140203
140204
140205
140206
140207
140208
140209
140210
140211
140212
140213

140214
140215
140216
140217
140218
140219
140220
**  yy_shift_ofst[]    For each state, the offset into yy_action for
**                     shifting terminals.
**  yy_reduce_ofst[]   For each state, the offset into yy_action for
**                     shifting non-terminals after a reduce.
**  yy_default[]       Default action for each state.
**
*********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (1541)
static const YYACTIONTYPE yy_action[] = {
 /*     0 */  1006,  156,  156,    2, 1302,   90,   87,  179,   90,   87,
 /*    10 */   179,  460, 1048,  460,  465, 1010,  460,  333, 1130,  335,
 /*    20 */   246,  330,  112,  303,  439, 1258,  304,  419, 1129, 1087,
 /*    30 */    72,  798,   50,   50,   50,   50,  331,   30,   30,  799,
 /*    40 */   951,  364,  371,   97,   98,   88,  983,  983,  859,  862,
 /*    50 */   851,  851,   95,   95,   96,   96,   96,   96,  120,  371,
 /*    60 */   370,  120,  348,   22,   90,   87,  179,  438,  423,  438,
 /*    70 */   440,  335,  420,  385,   90,   87,  179,  116,   73,  163,
 /*    80 */   848,  848,  860,  863,   94,   94,   94,   94,   93,   93,
 /*    90 */    92,   92,   92,   91,  361,   97,   98,   88,  983,  983,
 /*   100 */   859,  862,  851,  851,   95,   95,   96,   96,   96,   96,
 /*   110 */   718,  365,  339,   93,   93,   92,   92,   92,   91,  361,
 /*   120 */    99,  371,  453,  335,   94,   94,   94,   94,   93,   93,
 /*   130 */    92,   92,   92,   91,  361,  852,   94,   94,   94,   94,
 /*   140 */    93,   93,   92,   92,   92,   91,  361,   97,   98,   88,
 /*   150 */   983,  983,  859,  862,  851,  851,   95,   95,   96,   96,
 /*   160 */    96,   96,   92,   92,   92,   91,  361,  838,  132,  195,
 /*   170 */    58,  244,  412,  409,  408,  335,  457,  457,  457,  304,
 /*   180 */    59,  332,  831,  407,  394,  962,  830,  391,   94,   94,
 /*   190 */    94,   94,   93,   93,   92,   92,   92,   91,  361,   97,
 /*   200 */    98,   88,  983,  983,  859,  862,  851,  851,   95,   95,
 /*   210 */    96,   96,   96,   96,  426,  357,  460,  830,  830,  832,
 /*   220 */    91,  361,  962,  963,  964,  195,  459,  335,  412,  409,
 /*   230 */   408,  280,  361,  820,  132,   11,   11,   50,   50,  407,
 /*   240 */    94,   94,   94,   94,   93,   93,   92,   92,   92,   91,
 /*   250 */   361,   97,   98,   88,  983,  983,  859,  862,  851,  851,
 /*   260 */    95,   95,   96,   96,   96,   96,  460,  221,  460,  264,
 /*   270 */   375,  254,  438,  428, 1276, 1276,  383, 1074, 1053,  335,
 /*   280 */   245,  422,  299,  713,  271,  271, 1074,   50,   50,   50,
 /*   290 */    50,  962,   94,   94,   94,   94,   93,   93,   92,   92,
 /*   300 */    92,   91,  361,   97,   98,   88,  983,  983,  859,  862,
 /*   310 */   851,  851,   95,   95,   96,   96,   96,   96,   90,   87,
 /*   320 */   179, 1306,  438,  437,  438,  418,  368,  253,  962,  963,
 /*   330 */   964,  335,  360,  360,  360,  706,  359,  358,  324,  962,
 /*   340 */  1281,  951,  364,  230,   94,   94,   94,   94,   93,   93,
 /*   350 */    92,   92,   92,   91,  361,   97,   98,   88,  983,  983,
 /*   360 */   859,  862,  851,  851,   95,   95,   96,   96,   96,   96,
 /*   370 */   769,  460,  120,  226,  226,  366,  962,  963,  964, 1089,
 /*   380 */   990,  900,  990,  335, 1057,  425,  421,  839,  759,  759,
 /*   390 */   425,  427,   50,   50,  432,  381,   94,   94,   94,   94,
 /*   400 */    93,   93,   92,   92,   92,   91,  361,   97,   98,   88,
 /*   410 */   983,  983,  859,  862,  851,  851,   95,   95,   96,   96,
 /*   420 */    96,   96,  460,  259,  460,  120,  117,  354,  942, 1332,
 /*   430 */   942, 1333, 1332,  278, 1333,  335,  680,  681,  682,  825,
 /*   440 */   201,  176,  303,   50,   50,   49,   49,  404,   94,   94,
 /*   450 */    94,   94,   93,   93,   92,   92,   92,   91,  361,   97,
 /*   460 */    98,   88,  983,  983,  859,  862,  851,  851,   95,   95,
 /*   470 */    96,   96,   96,   96,  199,  460,  380,  265,  433,  380,
 /*   480 */   265,  383,  256,  158,  258,  319, 1003,  335,  155,  940,
 /*   490 */   177,  940,  273,  379,  276,  322,   34,   34,  302,  962,
 /*   500 */    94,   94,   94,   94,   93,   93,   92,   92,   92,   91,
 /*   510 */   361,   97,   98,   88,  983,  983,  859,  862,  851,  851,
 /*   520 */    95,   95,   96,   96,   96,   96,  905,  905,  397,  460,
 /*   530 */   301,  158,  101,  319,  941,  340,  962,  963,  964,  313,
 /*   540 */   283,  449,  335,  327,  146, 1266, 1004,  257,  234,  248,
 /*   550 */    35,   35,   94,   94,   94,   94,   93,   93,   92,   92,
 /*   560 */    92,   91,  361,  709,  785, 1227,   97,   98,   88,  983,
 /*   570 */   983,  859,  862,  851,  851,   95,   95,   96,   96,   96,
 /*   580 */    96,  962, 1227, 1229,  245,  422,  838,  198,  197,  196,
 /*   590 */  1079, 1079, 1077, 1077, 1004, 1334,  320,  335,  172,  171,
 /*   600 */   709,  831,  159,  271,  271,  830,   76,   94,   94,   94,
 /*   610 */    94,   93,   93,   92,   92,   92,   91,  361,  962,  963,
 /*   620 */   964,   97,   98,   88,  983,  983,  859,  862,  851,  851,
 /*   630 */    95,   95,   96,   96,   96,   96,  830,  830,  832, 1157,
 /*   640 */  1157,  199, 1157,  173, 1227,  231,  232, 1282,    2,  335,
 /*   650 */   271,  764,  271,  820,  271,  271,  763,  389,  389,  389,
 /*   660 */   132,   79,   94,   94,   94,   94,   93,   93,   92,   92,
 /*   670 */    92,   91,  361,   97,   98,   88,  983,  983,  859,  862,
 /*   680 */   851,  851,   95,   95,   96,   96,   96,   96,  460,  264,
 /*   690 */   223,  460, 1257,  783, 1223, 1157, 1086, 1082,   80,  271,
 /*   700 */    78,  335,  340, 1031,  341,  344,  345,  902,  346,   10,
 /*   710 */    10,  902,   25,   25,   94,   94,   94,   94,   93,   93,
 /*   720 */    92,   92,   92,   91,  361,   97,   86,   88,  983,  983,
 /*   730 */   859,  862,  851,  851,   95,   95,   96,   96,   96,   96,
 /*   740 */  1157,  270,  395,  117,  233,  263,  235,   70,  456,  341,
 /*   750 */   225,  176,  335, 1305,  342,  133,  736,  966,  980,  249,
 /*   760 */  1150,  396,  325, 1085, 1028,  178,   94,   94,   94,   94,
 /*   770 */    93,   93,   92,   92,   92,   91,  361,   98,   88,  983,
 /*   780 */   983,  859,  862,  851,  851,   95,   95,   96,   96,   96,
 /*   790 */    96,  783,  783,  132,  120,  966,  120,  120,  120,  798,
 /*   800 */   252,  937,  335,  353,  321,  429,  355,  799,  822,  692,
 /*   810 */   390,  203,  446,  450,  372,  716,  454,   94,   94,   94,
 /*   820 */    94,   93,   93,   92,   92,   92,   91,  361,   88,  983,
 /*   830 */   983,  859,  862,  851,  851,   95,   95,   96,   96,   96,
 /*   840 */    96,   84,  455, 1225,    3, 1209,  120,  120,  382,  387,
 /*   850 */   120,  203, 1271,  716,  384,  168,  266,  203,  458,   72,
 /*   860 */   260, 1246,   84,  455,  178,    3,  378,   94,   94,   94,
 /*   870 */    94,   93,   93,   92,   92,   92,   91,  361,  350,  458,
 /*   880 */  1245,  362,  430,  213,  228,  290,  415,  285,  414,  200,
 /*   890 */   783,  882,  444,  726,  725,  405,  283,  921,  209,  921,
 /*   900 */   281,  132,  362,   72,  838,  289,  147,  733,  734,  392,
 /*   910 */    81,   82,  922,  444,  922,  267,  288,   83,  362,  462,
 /*   920 */   461,  272,  132,  830,   23,  838,  388,  923, 1216,  923,
 /*   930 */  1056,   81,   82,   84,  455,  899,    3,  899,   83,  362,
 /*   940 */   462,  461,  761,  962,  830,   75,    1,  443,  275,  747,
 /*   950 */   458,    5,  962,  204,  830,  830,  832,  833,   18,  748,
 /*   960 */   229,  962,  277,   19,  153,  317,  317,  316,  216,  314,
 /*   970 */   279,  460,  689,  362, 1055,  830,  830,  832,  833,   18,
 /*   980 */   962,  963,  964,  962,  444,  181,  460,  251,  981,  962,
 /*   990 */   963,  964,    8,    8,   20,  250,  838, 1070,  962,  963,
 /*  1000 */   964,  417,   81,   82,  768,  204,  347,   36,   36,   83,
 /*  1010 */   362,  462,  461, 1054,  284,  830,   84,  455, 1123,    3,
 /*  1020 */   962,  963,  964,  460,  183,  962,  981,  764,  889, 1107,
 /*  1030 */   460,  184,  763,  458,  132,  182,   74,  455,  460,    3,
 /*  1040 */   981,  898,  834,  898,    8,    8,  830,  830,  832,  833,
 /*  1050 */    18,    8,    8,  458,  219, 1156,  362, 1103,  349,    8,
 /*  1060 */     8,  240,  962,  963,  964,  236,  889,  444,  792,  336,
 /*  1070 */   158,  203,  885,  435,  700,  209,  362,  114,  981,  838,
 /*  1080 */   834,  227,  334, 1114,  441,   81,   82,  444,  442,  305,
 /*  1090 */   784,  306,   83,  362,  462,  461,  369, 1162,  830,  838,
 /*  1100 */   460, 1037,  237, 1030,  237,   81,   82,    7,   96,   96,
 /*  1110 */    96,   96,   83,  362,  462,  461, 1019, 1018,  830, 1020,
 /*  1120 */  1289,   37,   37,  400,   96,   96,   96,   96,   89,  830,
 /*  1130 */   830,  832,  833,   18, 1100,  318,  962,  292,   94,   94,
 /*  1140 */    94,   94,   93,   93,   92,   92,   92,   91,  361,  830,
 /*  1150 */   830,  832,  833,   18,   94,   94,   94,   94,   93,   93,
 /*  1160 */    92,   92,   92,   91,  361,  359,  358,  226,  226,  727,
 /*  1170 */   294,  296,  460,  962,  963,  964,  460,  989,  160,  425,
 /*  1180 */   170, 1295,  262,  460,  987,  374,  988,  386, 1145,  255,
 /*  1190 */   326,  460,  373,   38,   38,  410,  174,   39,   39,  413,
 /*  1200 */   460,  287,  460, 1053,   40,   40,  298,  728, 1220,  990,
 /*  1210 */   445,  990,   26,   26, 1219,  460,  311,  460,  169, 1292,
 /*  1220 */   460,   27,   27,   29,   29,  998,  460,  206,  135,  995,
 /*  1230 */  1265, 1263,  460,   57,   60,  460,   41,   41,   42,   42,
 /*  1240 */   460,   43,   43,  460,  343,  351,  460,    9,    9,  460,
 /*  1250 */   144,  460,  130,   44,   44,  460,  103,  103,  460,  137,
 /*  1260 */    70,   45,   45,  460,   46,   46,  460,   31,   31, 1142,
 /*  1270 */    47,   47,   48,   48,  460,  376,   32,   32,  460,  122,
 /*  1280 */   122,  460,  157,  460,  123,  123,  139,  124,  124,  460,
 /*  1290 */   186,  460,  377,  460,  115,   54,   54,  460,  403,   33,
 /*  1300 */    33,  460,  104,  104,   51,   51,  460,  161,  460,  140,
 /*  1310 */   105,  105,  106,  106,  102,  102,  460,  141,  121,  121,
 /*  1320 */   460,  142,  119,  119,  190,  460, 1152,  110,  110,  109,
 /*  1330 */   109,  702,  460,  148,  393,   65,  460,  107,  107,  460,
 /*  1340 */   323,  108,  108,  399,  460, 1234,   53,   53, 1214,  269,
 /*  1350 */   154,  416, 1115,   55,   55,  220,  401,   52,   52,  191,
 /*  1360 */    24,   24,  274,  192,  193,   28,   28, 1021,  328,  702,
 /*  1370 */  1073,  352, 1072,  718, 1071,  431, 1111, 1064,  329, 1045,
 /*  1380 */    69,  205,    6,  291, 1044,  286, 1112, 1043, 1304, 1110,
 /*  1390 */   293,  300,  295,  297, 1063, 1200, 1109,   77,  241,  448,
 /*  1400 */   356,  452,  436,  100,  214,   71,  434, 1027, 1093,   21,
 /*  1410 */   463,  242,  243,  957,  215,  217,  218,  464,  309,  307,
 /*  1420 */   308,  310, 1016,  125, 1250, 1251, 1011, 1249,  126,  127,
 /*  1430 */  1248,  113,  676,  337,  238,  338,  134,  363,  167, 1041,
 /*  1440 */  1040,   56,  247,  367,  180,  897,  111,  895,  136, 1038,
 /*  1450 */   818,  128,  138,  750,  261,  911,  185,  143,  145,   61,
 /*  1460 */    62,   63,   64,  129,  914,  187,  188,  910,  118,   12,
 /*  1470 */   189,  903,  268,  992,  203,  162,  398,  150,  149,  691,
 /*  1480 */   402,  288,  194,  406,  151,  411,   66,   13,  729,  239,
 /*  1490 */   282,   14,   67,  131,  837,  836,  865,  758,   15,    4,
 /*  1500 */    68,  762,  175,  222,  224,  424,  152,  869,  791,  202,
 /*  1510 */   786,   75,   72,  880,  866,  864,   16,   17,  920,  207,
 /*  1520 */   919,  208,  447,  946,  164,  211,  947,  210,  165,  451,
 /*  1530 */   868,  166,  315,  835,  701,   85,  212, 1297,  312,  952,
 /*  1540 */  1296,


};
static const YYCODETYPE yy_lookahead[] = {
 /*     0 */   144,  145,  146,  147,  172,  222,  223,  224,  222,  223,
 /*    10 */   224,  152,  180,  152,  148,  149,  152,  173,  176,   19,
 /*    20 */   154,  173,  156,  152,  163,  242,  152,  163,  176,  163,
 /*    30 */    26,   31,  173,  174,  173,  174,  173,  173,  174,   39,
 /*    40 */     1,    2,  152,   43,   44,   45,   46,   47,   48,   49,
 /*    50 */    50,   51,   52,   53,   54,   55,   56,   57,  197,  169,
 /*    60 */   170,  197,  188,  197,  222,  223,  224,  208,  209,  208,
 /*    70 */   209,   19,  208,  152,  222,  223,  224,   22,   26,   24,
 /*    80 */    46,   47,   48,   49,   84,   85,   86,   87,   88,   89,
 /*    90 */    90,   91,   92,   93,   94,   43,   44,   45,   46,   47,
 /*   100 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   110 */   106,  245,  157,   88,   89,   90,   91,   92,   93,   94,
 /*   120 */    68,  231,  251,   19,   84,   85,   86,   87,   88,   89,
 /*   130 */    90,   91,   92,   93,   94,  101,   84,   85,   86,   87,
 /*   140 */    88,   89,   90,   91,   92,   93,   94,   43,   44,   45,
 /*   150 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,
 /*   160 */    56,   57,   90,   91,   92,   93,   94,   82,   79,   99,
 /*   170 */    66,  200,  102,  103,  104,   19,  168,  169,  170,  152,
 /*   180 */    24,  210,   97,  113,  229,   59,  101,  232,   84,   85,
 /*   190 */    86,   87,   88,   89,   90,   91,   92,   93,   94,   43,
 /*   200 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
 /*   210 */    54,   55,   56,   57,  152,  188,  152,  132,  133,  134,
 /*   220 */    93,   94,   96,   97,   98,   99,  152,   19,  102,  103,
 /*   230 */   104,   23,   94,   72,   79,  173,  174,  173,  174,  113,
 /*   240 */    84,   85,   86,   87,   88,   89,   90,   91,   92,   93,
 /*   250 */    94,   43,   44,   45,   46,   47,   48,   49,   50,   51,
 /*   260 */    52,   53,   54,   55,   56,   57,  152,  171,  152,  108,
 /*   270 */   109,  110,  208,  209,  119,  120,  152,  180,  181,   19,
 /*   280 */   119,  120,  152,   23,  152,  152,  189,  173,  174,  173,
 /*   290 */   174,   59,   84,   85,   86,   87,   88,   89,   90,   91,
 /*   300 */    92,   93,   94,   43,   44,   45,   46,   47,   48,   49,
 /*   310 */    50,   51,   52,   53,   54,   55,   56,   57,  222,  223,
 /*   320 */   224,  186,  208,  209,  208,  209,  194,  194,   96,   97,
 /*   330 */    98,   19,  168,  169,  170,   23,   88,   89,  163,   59,
 /*   340 */     0,    1,    2,  219,   84,   85,   86,   87,   88,   89,
 /*   350 */    90,   91,   92,   93,   94,   43,   44,   45,   46,   47,
 /*   360 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   370 */    90,  152,  197,  195,  196,  243,   96,   97,   98,  196,
 /*   380 */   132,   11,  134,   19,  182,  207,  115,   23,  117,  118,
 /*   390 */   207,  163,  173,  174,  152,  220,   84,   85,   86,   87,
 /*   400 */    88,   89,   90,   91,   92,   93,   94,   43,   44,   45,
 /*   410 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,
 /*   420 */    56,   57,  152,   16,  152,  197,  171,  208,   22,   23,
 /*   430 */    22,   23,   26,   16,   26,   19,    7,    8,    9,   23,
 /*   440 */   212,  213,  152,  173,  174,  173,  174,   19,   84,   85,
 /*   450 */    86,   87,   88,   89,   90,   91,   92,   93,   94,   43,
 /*   460 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
 /*   470 */    54,   55,   56,   57,   46,  152,  109,  110,  208,  109,
 /*   480 */   110,  152,   75,  152,   77,   22,   23,   19,  233,   83,
 /*   490 */   152,   83,   75,  238,   77,  164,  173,  174,  226,   59,
 /*   500 */    84,   85,   86,   87,   88,   89,   90,   91,   92,   93,
 /*   510 */    94,   43,   44,   45,   46,   47,   48,   49,   50,   51,
 /*   520 */    52,   53,   54,   55,   56,   57,  108,  109,  110,  152,
 /*   530 */   152,  152,   22,   22,   23,  107,   96,   97,   98,  160,
 /*   540 */   112,  251,   19,  164,   22,  152,   83,  140,  219,  152,
 /*   550 */   173,  174,   84,   85,   86,   87,   88,   89,   90,   91,
 /*   560 */    92,   93,   94,   59,  124,  152,   43,   44,   45,   46,
 /*   570 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   580 */    57,   59,  169,  170,  119,  120,   82,  108,  109,  110,
 /*   590 */   191,  192,  191,  192,   83,  248,  249,   19,   88,   89,
 /*   600 */    96,   97,   24,  152,  152,  101,  138,   84,   85,   86,
 /*   610 */    87,   88,   89,   90,   91,   92,   93,   94,   96,   97,
 /*   620 */    98,   43,   44,   45,   46,   47,   48,   49,   50,   51,
 /*   630 */    52,   53,   54,   55,   56,   57,  132,  133,  134,  152,
 /*   640 */   152,   46,  152,   26,  231,  194,  194,  146,  147,   19,
 /*   650 */   152,  116,  152,   72,  152,  152,  121,  152,  152,  152,
 /*   660 */    79,  138,   84,   85,   86,   87,   88,   89,   90,   91,
 /*   670 */    92,   93,   94,   43,   44,   45,   46,   47,   48,   49,
 /*   680 */    50,   51,   52,   53,   54,   55,   56,   57,  152,  108,
 /*   690 */    23,  152,  194,   26,  194,  152,  194,  194,  137,  152,
 /*   700 */   139,   19,  107,  166,  167,  218,  218,   29,  218,  173,
 /*   710 */   174,   33,  173,  174,   84,   85,   86,   87,   88,   89,
 /*   720 */    90,   91,   92,   93,   94,   43,   44,   45,   46,   47,
 /*   730 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   740 */   152,  194,   64,  171,  239,  239,  239,  130,  166,  167,
 /*   750 */   212,  213,   19,   23,  246,  247,   26,   59,   26,  152,
 /*   760 */   163,  218,  163,  163,  163,   98,   84,   85,   86,   87,
 /*   770 */    88,   89,   90,   91,   92,   93,   94,   44,   45,   46,
 /*   780 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   790 */    57,  124,   26,   79,  197,   97,  197,  197,  197,   31,
 /*   800 */   152,   23,   19,   19,   26,   19,  218,   39,   23,   21,
 /*   810 */   238,   26,  163,  163,  100,   59,  163,   84,   85,   86,
 /*   820 */    87,   88,   89,   90,   91,   92,   93,   94,   45,   46,
 /*   830 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   840 */    57,   19,   20,  152,   22,   23,  197,  197,   23,   19,
 /*   850 */   197,   26,  152,   97,   23,  123,   23,   26,   36,   26,
 /*   860 */   152,  152,   19,   20,   98,   22,   78,   84,   85,   86,
 /*   870 */    87,   88,   89,   90,   91,   92,   93,   94,   94,   36,
 /*   880 */   152,   59,   96,   99,  100,  101,  102,  103,  104,  105,
 /*   890 */   124,  103,   70,  100,  101,   23,  112,   12,   26,   12,
 /*   900 */    23,   79,   59,   26,   82,  101,   22,    7,    8,  152,
 /*   910 */    88,   89,   27,   70,   27,  152,  112,   95,   96,   97,
 /*   920 */    98,  152,   79,  101,   22,   82,   96,   42,  140,   42,
 /*   930 */   182,   88,   89,   19,   20,  132,   22,  134,   95,   96,
 /*   940 */    97,   98,   23,   59,  101,   26,   22,   62,  152,   62,
 /*   950 */    36,   22,   59,   24,  132,  133,  134,  135,  136,   72,
 /*   960 */     5,   59,  152,   22,   71,   10,   11,   12,   13,   14,
 /*   970 */   152,  152,   17,   59,  182,  132,  133,  134,  135,  136,
 /*   980 */    96,   97,   98,   59,   70,   30,  152,   32,   59,   96,
 /*   990 */    97,   98,  173,  174,   53,   40,   82,  152,   96,   97,
 /*  1000 */    98,   90,   88,   89,   90,   24,  187,  173,  174,   95,
 /*  1010 */    96,   97,   98,  152,  152,  101,   19,   20,  152,   22,
 /*  1020 */    96,   97,   98,  152,   69,   59,   97,  116,   59,  214,
 /*  1030 */   152,   76,  121,   36,   79,   80,   19,   20,  152,   22,
 /*  1040 */    59,  132,   59,  134,  173,  174,  132,  133,  134,  135,
 /*  1050 */   136,  173,  174,   36,  234,  152,   59,  152,  187,  173,
 /*  1060 */   174,  211,   96,   97,   98,  187,   97,   70,   23,  114,
 /*  1070 */   152,   26,   23,  187,   23,   26,   59,   26,   97,   82,
 /*  1080 */    97,   22,  164,  152,  152,   88,   89,   70,  192,  152,
 /*  1090 */   124,  152,   95,   96,   97,   98,  141,  152,  101,   82,
 /*  1100 */   152,  152,  184,  152,  186,   88,   89,  199,   54,   55,
 /*  1110 */    56,   57,   95,   96,   97,   98,  152,  152,  101,  152,
 /*  1120 */   152,  173,  174,  235,   54,   55,   56,   57,   58,  132,
 /*  1130 */   133,  134,  135,  136,  211,  150,   59,  211,   84,   85,

 /*  1140 */    86,   87,   88,   89,   90,   91,   92,   93,   94,  132,
 /*  1150 */   133,  134,  135,  136,   84,   85,   86,   87,   88,   89,
 /*  1160 */    90,   91,   92,   93,   94,   88,   89,  195,  196,   35,
 /*  1170 */   211,  211,  152,   96,   97,   98,  152,  100,  198,  207,
 /*  1180 */   171,  122,  240,  152,  107,  215,  109,  240,  202,  215,
 /*  1190 */   202,  152,  220,  173,  174,  177,  185,  173,  174,   65,
 /*  1200 */   152,  176,  152,  181,  173,  174,  215,   73,  176,  132,
 /*  1210 */   228,  134,  173,  174,  176,  152,  201,  152,  199,  155,

 /*  1220 */   152,  173,  174,  173,  174,   60,  152,  122,  244,   38,
 /*  1230 */   159,  159,  152,  241,  241,  152,  173,  174,  173,  174,
 /*  1240 */   152,  173,  174,  152,  159,  111,  152,  173,  174,  152,
 /*  1250 */    22,  152,   43,  173,  174,  152,  173,  174,  152,  190,
 /*  1260 */   130,  173,  174,  152,  173,  174,  152,  173,  174,  202,
 /*  1270 */   173,  174,  173,  174,  152,   18,  173,  174,  152,  173,
 /*  1280 */   174,  152,  221,  152,  173,  174,  193,  173,  174,  152,
 /*  1290 */   158,  152,  159,  152,   22,  173,  174,  152,   18,  173,
 /*  1300 */   174,  152,  173,  174,  173,  174,  152,  221,  152,  193,

 /*  1310 */   173,  174,  173,  174,  173,  174,  152,  193,  173,  174,
 /*  1320 */   152,  193,  173,  174,  158,  152,  190,  173,  174,  173,
 /*  1330 */   174,   59,  152,  190,  159,  137,  152,  173,  174,  152,
 /*  1340 */   202,  173,  174,   61,  152,  237,  173,  174,  202,  236,

 /*  1350 */    22,  107,  159,  173,  174,  159,  178,  173,  174,  158,

 /*  1360 */   173,  174,  159,  158,  158,  173,  174,  159,  178,   97,
 /*  1370 */   175,   63,  175,  106,  175,  125,  217,  183,  178,  175,
 /*  1380 */   107,  159,   22,  216,  177,  175,  217,  175,  175,  217,
 /*  1390 */   216,  159,  216,  216,  183,  225,  217,  137,  227,  178,
 /*  1400 */    94,  178,  126,  129,   25,  128,  127,  162,  206,   26,
 /*  1410 */   161,  230,  230,   13,  153,  153,    6,  151,  203,  205,
 /*  1420 */   204,  202,  151,  165,  171,  171,  151,  171,  165,  165,
 /*  1430 */   171,  179,    4,  250,  179,  250,  247,    3,   22,  171,
 /*  1440 */   171,  171,  142,   81,   15,   23,   16,   23,  131,  171,
 /*  1450 */   120,  111,  123,   20,   16,    1,  125,  123,  131,   53,
 /*  1460 */    53,   53,   53,  111,   96,   34,  122,    1,    5,   22,
 /*  1470 */   107,   67,  140,   74,   26,   24,   41,  107,   67,   20,
 /*  1480 */    19,  112,  105,   66,   22,   66,   22,   22,   28,   66,
 /*  1490 */    23,   22,   22,   37,   23,   23,   23,  116,   22,   22,
 /*  1500 */    26,   23,  122,   23,   23,   26,   22,   11,   96,   34,
 /*  1510 */   124,   26,   26,   23,   23,   23,   34,   34,   23,   26,
 /*  1520 */    23,   22,   24,   23,   22,  122,   23,   26,   22,   24,
 /*  1530 */    23,   22,   15,   23,   23,   22,  122,  122,   23,    1,
 /*  1540 */   122,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1550 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1560 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1570 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1580 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1590 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1600 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1610 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1620 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1630 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1640 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1650 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1660 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1670 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1680 */   252,  252,  252,  252,


};
#define YY_SHIFT_COUNT    (465)
#define YY_SHIFT_MIN      (0)
#define YY_SHIFT_MAX      (1538)
static const unsigned short int yy_shift_ofst[] = {
 /*     0 */    39,  822,  955,  843,  997,  997,  997,  997,    0,    0,
 /*    10 */   104,  630,  997,  997,  997,  997,  997,  997,  997, 1077,

 /*    20 */  1077,  126,  161,  155,   52,  156,  208,  260,  312,  364,
 /*    30 */   416,  468,  523,  578,  630,  630,  630,  630,  630,  630,
 /*    40 */   630,  630,  630,  630,  630,  630,  630,  630,  630,  630,
 /*    50 */   630,  682,  630,  733,  783,  783,  914,  997,  997,  997,
 /*    60 */   997,  997,  997,  997,  997,  997,  997,  997,  997,  997,
 /*    70 */   997,  997,  997,  997,  997,  997,  997,  997,  997,  997,
 /*    80 */   997,  997,  997,  997,  997,  997,  997,  997, 1017,  997,
 /*    90 */   997,  997,  997,  997,  997,  997,  997,  997,  997,  997,
 /*   100 */   997,  997, 1070, 1054, 1054, 1054, 1054, 1054,   40,   25,
 /*   110 */    72,  232,  788,  428,  248,  248,  232,  581,  367,  127,
 /*   120 */   465,  138, 1541, 1541, 1541,  784,  784,  784,  522,  522,
 /*   130 */   887,  887,  893,  406,  408,  232,  232,  232,  232,  232,
 /*   140 */   232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
 /*   150 */   232,  232,  232,  232,  232,  370,  340,  714,  698,  698,
 /*   160 */   465,   89,   89,   89,   89,   89,   89, 1541, 1541, 1541,
 /*   170 */   504,   85,   85,  884,   70,  280,  902,  440,  966,  924,
 /*   180 */   232,  232,  232,  232,  232,  232,  232,  232,  232,  232,
 /*   190 */   232,  232,  232,  232,  232,  232, 1134, 1134, 1134,  232,
 /*   200 */   232,  667,  232,  232,  232,  929,  232,  232,  885,  232,
 /*   210 */   232,  232,  232,  232,  232,  232,  232,  232,  232,  418,
 /*   220 */   678,  981,  981,  981,  981,  766,  271,  911,  510,  429,
 /*   230 */   617,  786,  786,  830,  617,  830,    4,  730,  595,  768,
 /*   240 */   786,  561,  768,  768,  732,  535,   55, 1165, 1105, 1105,
 /*   250 */  1191, 1191, 1105, 1228, 1209, 1130, 1257, 1257, 1257, 1257,
 /*   260 */  1105, 1280, 1130, 1228, 1209, 1209, 1130, 1105, 1280, 1198,
 /*   270 */  1282, 1105, 1105, 1280, 1328, 1105, 1280, 1105, 1280, 1328,
 /*   280 */  1244, 1244, 1244, 1308, 1328, 1244, 1267, 1244, 1308, 1244,
 /*   290 */  1244, 1250, 1273, 1250, 1273, 1250, 1273, 1250, 1273, 1105,
 /*   300 */  1360, 1105, 1260, 1328, 1306, 1306, 1328, 1274, 1276, 1277,
 /*   310 */  1279, 1130, 1379, 1383, 1400, 1400, 1410, 1410, 1410, 1541,
 /*   320 */  1541, 1541, 1541, 1541, 1541, 1541, 1541, 1541, 1541, 1541,
 /*   330 */  1541, 1541, 1541, 1541, 1541,   34,  407,  463,  511,  417,
 /*   340 */   479, 1272,  778,  941,  785,  825,  831,  833,  872,  877,
 /*   350 */   756,  793,  900,  804,  919, 1045,  969, 1049,  803,  909,
 /*   360 */  1051,  983, 1059, 1428, 1434, 1416, 1300, 1429, 1362, 1430,
 /*   370 */  1422, 1424, 1330, 1317, 1340, 1329, 1433, 1331, 1438, 1454,
 /*   380 */  1334, 1327, 1406, 1407, 1408, 1409, 1352, 1368, 1431, 1344,
 /*   390 */  1466, 1463, 1447, 1363, 1332, 1404, 1448, 1411, 1399, 1435,
 /*   400 */  1370, 1451, 1459, 1461, 1369, 1377, 1462, 1417, 1464, 1465,
 /*   410 */  1467, 1469, 1419, 1460, 1470, 1423, 1456, 1471, 1472, 1473,
 /*   420 */  1474, 1381, 1476, 1478, 1477, 1479, 1380, 1480, 1481, 1412,
 /*   430 */  1475, 1484, 1386, 1485, 1482, 1486, 1483, 1490, 1485, 1491,
 /*   440 */  1492, 1495, 1493, 1497, 1499, 1496, 1500, 1502, 1498, 1501,
 /*   450 */  1503, 1506, 1505, 1501, 1507, 1509, 1510, 1511, 1513, 1403,
 /*   460 */  1414, 1415, 1418, 1515, 1517, 1538,

};
#define YY_REDUCE_COUNT (334)
#define YY_REDUCE_MIN   (-217)
#define YY_REDUCE_MAX   (1278)
static const short yy_reduce_ofst[] = {
 /*     0 */  -144, -139, -134, -136, -141,   64,  114,  116, -158, -148,
 /*    10 */  -217,   96,  819,  871,  878,  219,  270,  886,  272, -110,
 /*    20 */   413,  918,  972,  228, -214, -214, -214, -214, -214, -214,
 /*    30 */  -214, -214, -214, -214, -214, -214, -214, -214, -214, -214,
 /*    40 */  -214, -214, -214, -214, -214, -214, -214, -214, -214, -214,
 /*    50 */  -214, -214, -214, -214, -214, -214,   62,  323,  377,  536,
 /*    60 */   539,  834,  948, 1020, 1024, 1031, 1039, 1048, 1050, 1063,
 /*    70 */  1065, 1068, 1074, 1080, 1083, 1088, 1091, 1094, 1097, 1099,
 /*    80 */  1103, 1106, 1111, 1114, 1122, 1126, 1129, 1131, 1137, 1139,
 /*    90 */  1141, 1145, 1149, 1154, 1156, 1164, 1168, 1173, 1180, 1184,
 /*   100 */  1187, 1192, -214, -214, -214, -214, -214, -214, -214, -214,
 /*   110 */  -214,  132,  -45,   97,    8,  164,  379,  175,  255, -214,
 /*   120 */   178, -214, -214, -214, -214, -168, -168, -168,  124,  329,
 /*   130 */   399,  401, -129,  347,  347,  331,  133,  451,  452,  498,
 /*   140 */   500,  502,  503,  505,  487,  506,  488,  490,  507,  543,
 /*   150 */   547, -126,  588,  290,   27,  572,  501,  597,  537,  582,
 /*   160 */   183,  599,  600,  601,  649,  650,  653,  508,  538,  -29,
 /*   170 */  -156, -152, -137,  -79,  135,   74,  130,  242,  338,  378,
 /*   180 */   393,  397,  607,  648,  691,  700,  708,  709,  728,  757,
 /*   190 */   763,  769,  796,  810,  818,  845,  202,  748,  792,  861,
 /*   200 */   862,  815,  866,  903,  905,  850,  931,  932,  896,  937,
 /*   210 */   939,  945,   74,  949,  951,  964,  965,  967,  968,  888,
 /*   220 */   820,  923,  926,  959,  960,  815,  980,  908, 1009,  985,
 /*   230 */   986,  970,  974,  942,  988,  947, 1018, 1011, 1022, 1025,
 /*   240 */   991,  982, 1032, 1038, 1015, 1019, 1064,  984, 1071, 1072,
 /*   250 */   992,  993, 1085, 1061, 1069, 1067, 1093, 1116, 1124, 1128,
 /*   260 */  1133, 1132, 1138, 1086, 1136, 1143, 1146, 1175, 1166, 1108,
 /*   270 */  1113, 1193, 1196, 1201, 1178, 1203, 1205, 1208, 1206, 1190,
 /*   280 */  1195, 1197, 1199, 1194, 1200, 1204, 1207, 1210, 1211, 1212,
 /*   290 */  1213, 1159, 1167, 1169, 1174, 1172, 1176, 1179, 1177, 1222,
 /*   300 */  1170, 1232, 1171, 1221, 1181, 1182, 1223, 1202, 1214, 1216,
 /*   310 */  1215, 1219, 1245, 1249, 1261, 1262, 1266, 1271, 1275, 1183,
 /*   320 */  1185, 1189, 1258, 1253, 1254, 1256, 1259, 1263, 1252, 1255,
 /*   330 */  1268, 1269, 1270, 1278, 1264,

};
static const YYACTIONTYPE yy_default[] = {
 /*     0 */  1286, 1276, 1276, 1276, 1209, 1209, 1209, 1209, 1133, 1133,
 /*    10 */  1260, 1036, 1005, 1005, 1005, 1005, 1005, 1005, 1208, 1005,
 /*    20 */  1005, 1005, 1005, 1108, 1139, 1005, 1005, 1005, 1005, 1210,
 /*    30 */  1211, 1005, 1005, 1005, 1259, 1261, 1149, 1148, 1147, 1146,
 /*    40 */  1242, 1120, 1144, 1137, 1141, 1210, 1204, 1205, 1203, 1207,
 /*    50 */  1211, 1005, 1140, 1174, 1188, 1173, 1005, 1005, 1005, 1005,
 /*    60 */  1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005,
 /*    70 */  1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005,
 /*    80 */  1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005,
 /*    90 */  1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005,
 /*   100 */  1005, 1005, 1182, 1187, 1194, 1186, 1183, 1176, 1175, 1177,
 /*   110 */  1178, 1005, 1026, 1075, 1005, 1005, 1005, 1276, 1036, 1179,
 /*   120 */  1005, 1180, 1191, 1190, 1189, 1267, 1294, 1293, 1005, 1005,
 /*   130 */  1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005,
 /*   140 */  1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005,
 /*   150 */  1005, 1005, 1005, 1005, 1005, 1036, 1286, 1276, 1032, 1032,
 /*   160 */  1005, 1276, 1276, 1276, 1276, 1276, 1276, 1272, 1108, 1099,
 /*   170 */  1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005,
 /*   180 */  1005, 1264, 1262, 1005, 1224, 1005, 1005, 1005, 1005, 1005,
 /*   190 */  1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005,
 /*   200 */  1005, 1005, 1005, 1005, 1005, 1104, 1005, 1005, 1005, 1005,
 /*   210 */  1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1288, 1005,
 /*   220 */  1237, 1104, 1104, 1104, 1104, 1106, 1088, 1098, 1036, 1012,
 /*   230 */  1143, 1122, 1122, 1327, 1143, 1327, 1050, 1308, 1047, 1133,
 /*   240 */  1122, 1206, 1133, 1133, 1105, 1098, 1005, 1330, 1113, 1113,
 /*   250 */  1329, 1329, 1113, 1154, 1078, 1143, 1084, 1084, 1084, 1084,
 /*   260 */  1113, 1023, 1143, 1154, 1078, 1078, 1143, 1113, 1023, 1241,
 /*   270 */  1324, 1113, 1113, 1023, 1217, 1113, 1023, 1113, 1023, 1217,
 /*   280 */  1076, 1076, 1076, 1065, 1217, 1076, 1050, 1076, 1065, 1076,
 /*   290 */  1076, 1126, 1121, 1126, 1121, 1126, 1121, 1126, 1121, 1113,
 /*   300 */  1212, 1113, 1005, 1217, 1221, 1221, 1217, 1138, 1127, 1136,
 /*   310 */  1134, 1143, 1029, 1068, 1291, 1291, 1287, 1287, 1287, 1335,
 /*   320 */  1335, 1272, 1303, 1036, 1036, 1036, 1036, 1303, 1052, 1052,
 /*   330 */  1036, 1036, 1036, 1036, 1303, 1005, 1005, 1005, 1005, 1005,
 /*   340 */  1005, 1298, 1005, 1226, 1005, 1005, 1005, 1005, 1005, 1005,
 /*   350 */  1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005,
 /*   360 */  1005, 1005, 1159, 1005, 1008, 1269, 1005, 1005, 1268, 1005,
 /*   370 */  1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005,
 /*   380 */  1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1326,
 /*   390 */  1005, 1005, 1005, 1005, 1005, 1005, 1240, 1239, 1005, 1005,
 /*   400 */  1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005,
 /*   410 */  1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005,
 /*   420 */  1005, 1090, 1005, 1005, 1005, 1312, 1005, 1005, 1005, 1005,
 /*   430 */  1005, 1005, 1005, 1135, 1005, 1128, 1005, 1005, 1317, 1005,
 /*   440 */  1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1278,
 /*   450 */  1005, 1005, 1005, 1277, 1005, 1005, 1005, 1005, 1005, 1161,
 /*   460 */  1005, 1160, 1164, 1005, 1017, 1005,

};
/********** End of lemon-generated parsing tables *****************************/

/* The next table maps tokens (terminal symbols) into fallback tokens.  
** If a construct like the following:
** 
**      %fallback ID X Y Z.







|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>


|
|
|
|
|
|
|
|



|
|



|
|
|


|
|
|


|
|
|
|

|
|
|
|


|
|
|


|
|
|


|
|
|


|
|
|



|
|



|
|
|
|

|
|
|
|


|
|
|


|
|
|


|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
|
<
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
>
|
<
<
|
>
|
>
|
<
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|











|
>
>

|

|

|
|
>
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>

|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>


|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>







140105
140106
140107
140108
140109
140110
140111
140112
140113
140114
140115
140116
140117
140118
140119
140120
140121
140122
140123
140124
140125
140126
140127
140128
140129
140130
140131
140132
140133
140134
140135
140136
140137
140138
140139
140140
140141
140142
140143
140144
140145
140146
140147
140148
140149
140150
140151
140152
140153
140154
140155
140156
140157
140158
140159
140160
140161
140162
140163
140164
140165
140166
140167
140168
140169
140170
140171
140172
140173
140174
140175
140176
140177
140178
140179
140180
140181
140182
140183
140184
140185
140186
140187
140188
140189
140190
140191
140192
140193
140194
140195
140196
140197
140198
140199
140200
140201
140202
140203
140204
140205
140206
140207
140208
140209
140210
140211
140212
140213
140214
140215
140216
140217
140218
140219
140220
140221
140222
140223
140224
140225
140226
140227
140228
140229
140230
140231
140232
140233
140234
140235
140236
140237
140238
140239
140240
140241
140242
140243
140244
140245
140246
140247
140248
140249
140250
140251
140252
140253
140254
140255
140256
140257
140258
140259
140260
140261
140262
140263
140264
140265
140266
140267
140268
140269
140270
140271
140272
140273
140274
140275
140276
140277
140278
140279
140280
140281
140282
140283
140284
140285
140286
140287
140288
140289
140290
140291
140292
140293
140294
140295
140296
140297
140298
140299
140300
140301
140302
140303
140304
140305
140306
140307
140308
140309
140310
140311
140312
140313
140314
140315
140316
140317
140318
140319
140320
140321
140322
140323
140324
140325
140326
140327
140328
140329
140330
140331
140332
140333
140334
140335
140336
140337
140338
140339
140340
140341
140342
140343
140344
140345
140346
140347
140348
140349
140350
140351
140352
140353
140354
140355
140356
140357
140358
140359
140360
140361
140362
140363
140364
140365
140366
140367
140368
140369
140370
140371
140372
140373
140374
140375
140376
140377
140378
140379
140380
140381
140382
140383
140384
140385
140386
140387
140388

140389
140390
140391
140392
140393
140394
140395
140396
140397
140398
140399
140400
140401
140402
140403
140404
140405
140406


140407
140408
140409
140410
140411


140412
140413
140414
140415
140416
140417
140418
140419
140420
140421
140422
140423
140424
140425
140426
140427
140428
140429
140430
140431
140432
140433
140434
140435
140436
140437
140438
140439
140440
140441
140442
140443
140444
140445
140446
140447
140448
140449
140450
140451
140452
140453
140454
140455

140456
140457
140458
140459
140460
140461
140462
140463
140464
140465
140466
140467
140468
140469
140470
140471
140472
140473
140474
140475
140476
140477
140478
140479
140480
140481
140482
140483
140484
140485
140486
140487
140488
140489
140490
140491
140492
140493
140494
140495
140496
140497
140498
140499
140500
140501
140502
140503
140504
140505
140506
140507
140508
140509
140510
140511
140512
140513
140514
140515
140516
140517
140518
140519
140520
140521
140522
140523
140524
140525
140526
140527
140528
140529
140530
140531
140532
140533
140534
140535
140536
140537
140538
140539
140540
140541
140542
140543
140544
140545
140546
140547
140548
140549
140550
140551
140552
140553
140554
140555
140556
140557
140558
140559
140560
140561
140562
140563
140564
140565
140566
140567
140568
140569
140570
140571
140572
140573
140574
140575
140576
140577
140578
140579
140580
140581
140582
140583
140584
140585
140586
140587
140588
140589
140590
140591
140592
140593
**  yy_shift_ofst[]    For each state, the offset into yy_action for
**                     shifting terminals.
**  yy_reduce_ofst[]   For each state, the offset into yy_action for
**                     shifting non-terminals after a reduce.
**  yy_default[]       Default action for each state.
**
*********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (1566)
static const YYACTIONTYPE yy_action[] = {
 /*     0 */  1169, 1015,  167,  167,    1,  168,  466, 1313,  466, 1083,
 /*    10 */  1062,  466,   97,   94,  183, 1057,  466,  329, 1083,  342,
 /*    20 */    97,   94,  183,  459,  459,  459,  436,   57,   57,   57,
 /*    30 */    57,  807,   57,   57,  367,  367,  367,   57,   57,  808,
 /*    40 */  1270, 1088, 1088,  104,  105,   95,  991,  991,  868,  871,
 /*    50 */   860,  860,  102,  102,  103,  103,  103,  103,  233,  233,
 /*    60 */   326, 1011,  449,  437,  449,  446,  351,  449,  461, 1142,
 /*    70 */   463,  342,  449,  426, 1316,  209,  180,  742,   80,  299,
 /*    80 */   857,  857,  869,  872,  101,  101,  101,  101,  100,  100,
 /*    90 */    99,   99,   99,   98,  368,  104,  105,   95,  991,  991,
 /*   100 */   868,  871,  860,  860,  102,  102,  103,  103,  103,  103,
 /*   110 */    99,   99,   99,   98,  368,  355,   97,   94,  183,  228,
 /*   120 */   106, 1012,  407,  342,  101,  101,  101,  101,  100,  100,
 /*   130 */    99,   99,   99,   98,  368,  861,  101,  101,  101,  101,
 /*   140 */   100,  100,   99,   99,   99,   98,  368,  104,  105,   95,
 /*   150 */   991,  991,  868,  871,  860,  860,  102,  102,  103,  103,
 /*   160 */   103,  103,  201,  368,  375,  420,  417,  416,  387,  273,
 /*   170 */    65,   97,   94,  183,  168,  342,  415,  951, 1343,  396,
 /*   180 */    66, 1343,  320,  959,  371,  970,  334,  340,  101,  101,
 /*   190 */   101,  101,  100,  100,   99,   99,   99,   98,  368,  104,
 /*   200 */   105,   95,  991,  991,  868,  871,  860,  860,  102,  102,
 /*   210 */   103,  103,  103,  103,  373,  100,  100,   99,   99,   99,
 /*   220 */    98,  368,  970,  971,  972,  201, 1100,  342,  420,  417,
 /*   230 */   416,  287,  366,  365,  337,  970, 1162,  463,  949,  415,
 /*   240 */   101,  101,  101,  101,  100,  100,   99,   99,   99,   98,
 /*   250 */   368,  104,  105,   95,  991,  991,  868,  871,  860,  860,
 /*   260 */   102,  102,  103,  103,  103,  103,  777,  241,  233,  233,
 /*   270 */     9,  847,  970,  971,  972,  390,  998, 1141,  998,  342,
 /*   280 */   463,  252,  829,  719,   98,  368,  840,  298,  338,  142,
 /*   290 */   839,  339,  101,  101,  101,  101,  100,  100,   99,   99,
 /*   300 */    99,   98,  368,  104,  105,   95,  991,  991,  868,  871,
 /*   310 */   860,  860,  102,  102,  103,  103,  103,  103,  272,  466,
 /*   320 */   392,  839,  839,  841,   97,   94,  183,  390, 1317,  253,
 /*   330 */   456,  342,  125,  166,  807,  712,  208,  407,  386,  970,
 /*   340 */    57,   57,  808,  238,  101,  101,  101,  101,  100,  100,
 /*   350 */    99,   99,   99,   98,  368,  104,  105,   95,  991,  991,
 /*   360 */   868,  871,  860,  860,  102,  102,  103,  103,  103,  103,
 /*   370 */   466,  108,  466,  267,  465,  442,  970,  971,  972,  261,
 /*   380 */   951, 1344,  909,  342, 1344,  142,  829,  848, 1292,  959,
 /*   390 */   371,   55,   55,   57,   57,  242,  101,  101,  101,  101,
 /*   400 */   100,  100,   99,   99,   99,   98,  368,  104,  105,   95,
 /*   410 */   991,  991,  868,  871,  860,  860,  102,  102,  103,  103,
 /*   420 */   103,  103,  272,  382,  262,  253,  456,  310,  364,  253,
 /*   430 */   456,   86,  264,   84,  266,  342,  441,  176,  175,  834,
 /*   440 */   464,  949,  767,  767,  332,  313, 1094,  396,  101,  101,
 /*   450 */   101,  101,  100,  100,   99,   99,   99,   98,  368,  104,
 /*   460 */   105,   95,  991,  991,  868,  871,  860,  860,  102,  102,
 /*   470 */   103,  103,  103,  103,  227,  227,  233,  233,  233,  233,
 /*   480 */   387,  273,  234,  234,  326,  950,  463,  342,  463,  298,
 /*   490 */   463,  914,  914,  404,  463, 1037,  123,  265,   27,  970,
 /*   500 */   101,  101,  101,  101,  100,  100,   99,   99,   99,   98,
 /*   510 */   368,  104,  105,   95,  991,  991,  868,  871,  860,  860,
 /*   520 */   102,  102,  103,  103,  103,  103,  435,  233,  233,  466,
 /*   530 */   285,  686,  687,  688,  127,  271,  970,  971,  972,  463,
 /*   540 */  1345,  327,  342,  407,  157, 1012,  988,   13,   13,  181,
 /*   550 */    41,   41,  101,  101,  101,  101,  100,  100,   99,   99,
 /*   560 */    99,   98,  368,  715,  794,  378,  104,  105,   95,  991,
 /*   570 */   991,  868,  871,  860,  860,  102,  102,  103,  103,  103,
 /*   580 */   103,  970,  378,  377,  346,  239,  847, 1086, 1086,  280,
 /*   590 */  1169,  283,  204,  203,  202,  177,  298,  342,  407,  298,
 /*   600 */   715,  840,  169,  299,  407,  839,   82,  101,  101,  101,
 /*   610 */   101,  100,  100,   99,   99,   99,   98,  368,  970,  971,
 /*   620 */   972,  104,  105,   95,  991,  991,  868,  871,  860,  860,
 /*   630 */   102,  102,  103,  103,  103,  103,  839,  839,  841,  362,
 /*   640 */   240,  124, 1169,  172,  126,  378, 1269, 1169, 1066,  342,
 /*   650 */   253,  456,  407,  407,  407,  396,  352,  401,  407,  429,
 /*   660 */   398,   85,  101,  101,  101,  101,  100,  100,   99,   99,
 /*   670 */    99,   98,  368,  104,  105,   95,  991,  991,  868,  871,
 /*   680 */   860,  860,  102,  102,  103,  103,  103,  103, 1169,  466,
 /*   690 */   230,  233,  233,  792, 1235, 1095, 1091, 1293,    1,   77,
 /*   700 */   278,  342,  205,  463,  974,  911, 1040,  348,  353,  911,
 /*   710 */    42,   42,   79,  403,  101,  101,  101,  101,  100,  100,
 /*   720 */    99,   99,   99,   98,  368,  104,   93,   95,  991,  991,
 /*   730 */   868,  871,  860,  860,  102,  102,  103,  103,  103,  103,
 /*   740 */   402,    9,  974,  243,  772,  458,  348,  232,  180,  771,
 /*   750 */   946,  312,  342,  328,  363,  349,  143,  831,  389, 1278,
 /*   760 */   211,  211,   21,  347,  432,  182,  101,  101,  101,  101,
 /*   770 */   100,  100,   99,   99,   99,   98,  368,  105,   95,  991,
 /*   780 */   991,  868,  871,  860,  860,  102,  102,  103,  103,  103,
 /*   790 */   103,  792,  724,   22,  732,  731,  233,  233, 1239,  256,
 /*   800 */   391,  274,  342,  211,   79,  360,  257,  413,  463,  397,
 /*   810 */   207,  288,  260,  450,   79, 1239, 1241,  101,  101,  101,
 /*   820 */   101,  100,  100,   99,   99,   99,   98,  368,   95,  991,
 /*   830 */   991,  868,  871,  860,  860,  102,  102,  103,  103,  103,
 /*   840 */   103,   91,  457,  296,    3,  233,  233,    5,  438,  212,
 /*   850 */   331,  394,  739,  740,  295,  898,  894,  463,  460,  207,
 /*   860 */   801, 1237,  722,  211,  698,  843, 1283,  101,  101,  101,
 /*   870 */   101,  100,  100,   99,   99,   99,   98,  368, 1239,  380,
 /*   880 */   357,  369,  233,  233,  989,  219,  236,  297,  423,  292,
 /*   890 */   422,  206,  454,  898,  463,  970,   91,  457,  290,    3,
 /*   900 */   722,  142,  268,  843,  847,  466, 1258,  149,  388,  425,
 /*   910 */    88,   89,  769,  460,  930,   87,  447,   90,  369,  468,
 /*   920 */   467,  385,  989,  839, 1257,  439,   57,   57,  395,  931,
 /*   930 */  1065,  158,  970,  971,  972,  772,  369,  471, 1019,  399,
 /*   940 */   771,  253,  456,  254,  932,  119,  891,  454,  233,  233,
 /*   950 */     4,  970, 1096,  275,  839,  839,  841,  842,   19,  847,
 /*   960 */   463,  449,  448,  163,  453,   88,   89,  776,  970, 1127,
 /*   970 */   279,  930,   90,  369,  468,  467,   91,  457,  839,    3,
 /*   980 */   235, 1064,  466, 1228,  233,  233,  931,  970,  970,  971,
 /*   990 */   972,  970,  908,  460,  908,    2,  463,   81,  457,  212,
 /*  1000 */     3,  932,  282,   10,   10,  970,  971,  972,  189,  839,
 /*  1010 */   839,  841,  842,   19,  460,  284,  369,  354,  907,  286,
 /*  1020 */   907,  753,  466, 1079,  970,  971,  972,  454,  970,  971,
 /*  1030 */   972,  754,  970, 1063,  989,  372,  792,  369, 1118,  847,
 /*  1040 */   291,  452,  466,   10,   10,   88,   89,  142,  454,  168,
 /*  1050 */   300,  412,   90,  369,  468,  467,  793,  356,  839,  706,
 /*  1060 */   847,  341,  121,   10,   10,  301,   88,   89,  379,  970,
 /*  1070 */   971,  972,  989,   90,  369,  468,  467,  244,  205,  839,
 /*  1080 */  1306,  245, 1135,  245,  250, 1168, 1114,  253,  456,  839,
 /*  1090 */   839,  841,  842,   19, 1125,  237,  122,  451, 1174,  733,
 /*  1100 */   324,  324,  323,  222,  321,  466, 1046,  695,  182,  225,
 /*  1110 */   839,  839,  841,  842,   19,  103,  103,  103,  103,   96,
 /*  1120 */   185,  466,  259, 1039, 1028,  170,   10,   10, 1027,  421,
 /*  1130 */   258, 1029, 1300,  708,  792,  466,  408,  734,    8,  347,
 /*  1140 */   444,  174,   12,   12,  290,  101,  101,  101,  101,  100,
 /*  1150 */   100,   99,   99,   99,   98,  368,   32,   32,  466,  187,
 /*  1160 */   466, 1111,  103,  103,  103,  103,  188,  466,  325,  138,
 /*  1170 */   186,  708,  303,  305,  307,  358,  970,  270,  393,   43,
 /*  1180 */    43,   44,   44, 1157,  333,  178,  418,  294,   45,   45,
 /*  1190 */  1232,  318,  101,  101,  101,  101,  100,  100,   99,   99,
 /*  1200 */    99,   98,  368,  381,  343,  366,  365,  466,  263,  253,
 /*  1210 */   456,  466, 1062,  970,  971,  972, 1231,  997,  309,  466,
 /*  1220 */   455,  466,  427,  466,  995,  173,  996, 1303,   46,   46,
 /*  1230 */   145,  376,   37,   37, 1006, 1277,  466,  214, 1275,   64,
 /*  1240 */    47,   47,   33,   33,   34,   34, 1003,   67,  466,  998,
 /*  1250 */   350,  998,  466,  155,  233,  233,  466,   36,   36,   24,
 /*  1260 */   140,   77, 1154,  466,  383,  466,  463,  428,  466,   48,
 /*  1270 */    48,  466,  147,   49,   49,  466,  150,   50,   50,  466,
 /*  1280 */   151,  152,  466,  384,   11,   11,   51,   51,  466,  110,
 /*  1290 */   110,  153,   52,   52,  411,  466,   38,   38,  466,  191,
 /*  1300 */    53,   53,  466,   54,   54,  466,  400,  466,  330,   39,
 /*  1310 */    39,  466, 1164,  466,   25,  466,   56,   56,  466,  131,
 /*  1320 */   131,   72,  466,  132,  132,  159,  133,  133,   61,   61,
 /*  1330 */  1226,  195,   40,   40,  111,  111,   58,   58,  406,  112,
 /*  1340 */   112,  466,  277,  113,  113,  466,  226,  466, 1246,  466,
 /*  1350 */   197,  466,  164,  466,  409,  466,  198,  466,  199,  466,
 /*  1360 */   335,  281,  109,  109,  466, 1030,  130,  130,  129,  129,
 /*  1370 */   117,  117,  116,  116,  114,  114,  115,  115,   60,   60,
 /*  1380 */    62,   62,  466,  359,  466,   59,   59,  424, 1082, 1081,
 /*  1390 */  1080,  724, 1073, 1054,  336,  293, 1053, 1052, 1315,  431,
 /*  1400 */   361,   76,  248,   31,   31,   35,   35, 1072,  249,  440,
 /*  1410 */   302,  434,  213, 1122,    6,  311, 1212,  107,   83,  251,
 /*  1420 */    78, 1123,  445,  220,  443, 1036,  304,   23, 1121,  469,
 /*  1430 */   965,  221,  223, 1104,  314,  224,  344,  317,  315,  316,
 /*  1440 */   470,  306, 1025, 1120,  308, 1262, 1020,  134,  120,  246,
 /*  1450 */   682,  370,  171,  255, 1263,  135,  184, 1261, 1260,  374,
 /*  1460 */   118,  906,  904,  827, 1050,  146,  136,  137,  148, 1049,
 /*  1470 */    63, 1047,  756,  190,  269,  920,  154,  156,   68,   69,
 /*  1480 */    70,   71,  139,  923,  192,  193,  144,  919,  345,  128,
 /*  1490 */    14,  194,  276,  211, 1000,  405,  196,  161,  912,  160,
 /*  1500 */    26,  697,  410,  295,  200,  289,  414,  162,  419,   73,
 /*  1510 */    15,   16,  141,   74,   28,  247,  846,  845,  735,  874,
 /*  1520 */   954,   75,  430,  955,   29,  433,  179,  229,  231,  800,
 /*  1530 */   165,  795,   87,  210,  889,   79,  875,   17,  873,  877,
 /*  1540 */   929,   18,  928,  216,  215,  878,   20,   30,  462,  844,
 /*  1550 */   707,   92,  766,  770,    7,  322,  217,  218,  319, 1308,
 /*  1560 */   960, 1016, 1016, 1016, 1016, 1307,
};
static const YYCODETYPE yy_lookahead[] = {
 /*     0 */   152,  144,  145,  146,  147,  152,  152,  172,  152,  180,
 /*    10 */   181,  152,  223,  224,  225,  180,  152,  164,  189,   19,
 /*    20 */   223,  224,  225,  168,  169,  170,  163,  173,  174,  173,
 /*    30 */   174,   31,  173,  174,  168,  169,  170,  173,  174,   39,
 /*    40 */   243,  191,  192,   43,   44,   45,   46,   47,   48,   49,
 /*    50 */    50,   51,   52,   53,   54,   55,   56,   57,  195,  196,
 /*    60 */    22,   23,  208,  209,  208,  209,  218,  208,  209,  176,
 /*    70 */   207,   19,  208,  209,   23,  212,  213,   26,   26,  152,
 /*    80 */    46,   47,   48,   49,   84,   85,   86,   87,   88,   89,
 /*    90 */    90,   91,   92,   93,   94,   43,   44,   45,   46,   47,
 /*   100 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   110 */    90,   91,   92,   93,   94,  188,  223,  224,  225,  171,
 /*   120 */    68,   83,  152,   19,   84,   85,   86,   87,   88,   89,
 /*   130 */    90,   91,   92,   93,   94,  101,   84,   85,   86,   87,
 /*   140 */    88,   89,   90,   91,   92,   93,   94,   43,   44,   45,
 /*   150 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,
 /*   160 */    56,   57,   99,   94,  194,  102,  103,  104,  109,  110,
 /*   170 */    66,  223,  224,  225,  152,   19,  113,   22,   23,  152,
 /*   180 */    24,   26,  160,    1,    2,   59,  164,  173,   84,   85,
 /*   190 */    86,   87,   88,   89,   90,   91,   92,   93,   94,   43,
 /*   200 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
 /*   210 */    54,   55,   56,   57,  244,   88,   89,   90,   91,   92,
 /*   220 */    93,   94,   96,   97,   98,   99,  196,   19,  102,  103,
 /*   230 */   104,   23,   88,   89,  173,   59,  163,  207,   83,  113,
 /*   240 */    84,   85,   86,   87,   88,   89,   90,   91,   92,   93,
 /*   250 */    94,   43,   44,   45,   46,   47,   48,   49,   50,   51,
 /*   260 */    52,   53,   54,   55,   56,   57,   90,  240,  195,  196,
 /*   270 */   171,   82,   96,   97,   98,  152,  132,  176,  134,   19,
 /*   280 */   207,  200,   72,   23,   93,   94,   97,  152,  173,   79,
 /*   290 */   101,  210,   84,   85,   86,   87,   88,   89,   90,   91,
 /*   300 */    92,   93,   94,   43,   44,   45,   46,   47,   48,   49,
 /*   310 */    50,   51,   52,   53,   54,   55,   56,   57,  108,  152,
 /*   320 */   152,  132,  133,  134,  223,  224,  225,  152,  186,  119,
 /*   330 */   120,   19,  197,  234,   31,   23,   26,  152,  239,   59,
 /*   340 */   173,  174,   39,  220,   84,   85,   86,   87,   88,   89,
 /*   350 */    90,   91,   92,   93,   94,   43,   44,   45,   46,   47,
 /*   360 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   370 */   152,   22,  152,   16,  152,  208,   96,   97,   98,  194,
 /*   380 */    22,   23,   11,   19,   26,   79,   72,   23,    0,    1,
 /*   390 */     2,  173,  174,  173,  174,  220,   84,   85,   86,   87,
 /*   400 */    88,   89,   90,   91,   92,   93,   94,   43,   44,   45,
 /*   410 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,
 /*   420 */    56,   57,  108,  109,  110,  119,  120,  152,  208,  119,
 /*   430 */   120,  137,   75,  139,   77,   19,  152,   88,   89,   23,
 /*   440 */   115,   83,  117,  118,  163,  227,  163,  152,   84,   85,
 /*   450 */    86,   87,   88,   89,   90,   91,   92,   93,   94,   43,
 /*   460 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
 /*   470 */    54,   55,   56,   57,  195,  196,  195,  196,  195,  196,
 /*   480 */   109,  110,  195,  196,   22,   23,  207,   19,  207,  152,
 /*   490 */   207,  108,  109,  110,  207,  163,   22,  140,   24,   59,
 /*   500 */    84,   85,   86,   87,   88,   89,   90,   91,   92,   93,
 /*   510 */    94,   43,   44,   45,   46,   47,   48,   49,   50,   51,
 /*   520 */    52,   53,   54,   55,   56,   57,  152,  195,  196,  152,
 /*   530 */    16,    7,    8,    9,  197,  240,   96,   97,   98,  207,
 /*   540 */   249,  250,   19,  152,   22,   83,   26,  173,  174,  152,
 /*   550 */   173,  174,   84,   85,   86,   87,   88,   89,   90,   91,
 /*   560 */    92,   93,   94,   59,  124,  152,   43,   44,   45,   46,
 /*   570 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   580 */    57,   59,  169,  170,  157,  194,   82,  191,  192,   75,
 /*   590 */   152,   77,  108,  109,  110,   26,  152,   19,  152,  152,
 /*   600 */    96,   97,   24,  152,  152,  101,  138,   84,   85,   86,
 /*   610 */    87,   88,   89,   90,   91,   92,   93,   94,   96,   97,
 /*   620 */    98,   43,   44,   45,   46,   47,   48,   49,   50,   51,
 /*   630 */    52,   53,   54,   55,   56,   57,  132,  133,  134,  188,
 /*   640 */   194,  197,  152,  123,  197,  232,  194,  152,  182,   19,
 /*   650 */   119,  120,  152,  152,  152,  152,  218,  230,  152,  163,
 /*   660 */   233,  138,   84,   85,   86,   87,   88,   89,   90,   91,
 /*   670 */    92,   93,   94,   43,   44,   45,   46,   47,   48,   49,
 /*   680 */    50,   51,   52,   53,   54,   55,   56,   57,  152,  152,
 /*   690 */    23,  195,  196,   26,  194,  194,  194,  146,  147,  130,
 /*   700 */   194,   19,   46,  207,   59,   29,  166,  167,  218,   33,
 /*   710 */   173,  174,   26,  218,   84,   85,   86,   87,   88,   89,
 /*   720 */    90,   91,   92,   93,   94,   43,   44,   45,   46,   47,
 /*   730 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
 /*   740 */    64,  171,   97,  240,  116,  166,  167,  212,  213,  121,
 /*   750 */    23,  152,   19,   26,  218,  247,  248,   23,   23,  152,
 /*   760 */    26,   26,   22,  107,  163,   98,   84,   85,   86,   87,
 /*   770 */    88,   89,   90,   91,   92,   93,   94,   44,   45,   46,
 /*   780 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   790 */    57,  124,  106,   53,  100,  101,  195,  196,  152,  152,
 /*   800 */    23,   23,   19,   26,   26,   19,  152,   23,  207,  239,
 /*   810 */    26,   23,  152,  163,   26,  169,  170,   84,   85,   86,
 /*   820 */    87,   88,   89,   90,   91,   92,   93,   94,   45,   46,
 /*   830 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
 /*   840 */    57,   19,   20,  101,   22,  195,  196,   22,   19,   24,
 /*   850 */   163,   19,    7,    8,  112,   59,   23,  207,   36,   26,
 /*   860 */    23,  152,   59,   26,   21,   59,  152,   84,   85,   86,
 /*   870 */    87,   88,   89,   90,   91,   92,   93,   94,  232,  221,
 /*   880 */    94,   59,  195,  196,   59,   99,  100,  101,  102,  103,
 /*   890 */   104,  105,   70,   97,  207,   59,   19,   20,  112,   22,
 /*   900 */    97,   79,  152,   97,   82,  152,  152,   71,  221,   90,
 /*   910 */    88,   89,   23,   36,   12,   26,  163,   95,   96,   97,
 /*   920 */    98,   78,   97,  101,  152,   96,  173,  174,   96,   27,
 /*   930 */   182,   22,   96,   97,   98,  116,   59,  148,  149,  152,
 /*   940 */   121,  119,  120,  154,   42,  156,  103,   70,  195,  196,
 /*   950 */    22,   59,  163,  152,  132,  133,  134,  135,  136,   82,
 /*   960 */   207,  208,  209,   71,   62,   88,   89,   90,   59,  152,
 /*   970 */   152,   12,   95,   96,   97,   98,   19,   20,  101,   22,
 /*   980 */    22,  182,  152,  140,  195,  196,   27,   59,   96,   97,
 /*   990 */    98,   59,  132,   36,  134,   22,  207,   19,   20,   24,
 /*  1000 */    22,   42,  152,  173,  174,   96,   97,   98,  219,  132,
 /*  1010 */   133,  134,  135,  136,   36,  152,   59,  187,  132,  152,
 /*  1020 */   134,   62,  152,  152,   96,   97,   98,   70,   96,   97,
 /*  1030 */    98,   72,   59,  152,   59,  246,   26,   59,  214,   82,
 /*  1040 */   152,  192,  152,  173,  174,   88,   89,   79,   70,  152,
 /*  1050 */   152,   19,   95,   96,   97,   98,  124,  187,  101,   23,
 /*  1060 */    82,  164,   26,  173,  174,  152,   88,   89,  100,   96,
 /*  1070 */    97,   98,   97,   95,   96,   97,   98,  187,   46,  101,
 /*  1080 */   122,  184,  152,  186,  211,  152,  152,  119,  120,  132,
 /*  1090 */   133,  134,  135,  136,  152,    5,   22,  152,  152,   35,
 /*  1100 */    10,   11,   12,   13,   14,  152,  152,   17,   98,  235,
 /*  1110 */   132,  133,  134,  135,  136,   54,   55,   56,   57,   58,
 /*  1120 */    30,  152,   32,  152,  152,  198,  173,  174,  152,   65,
 /*  1130 */    40,  152,  152,   59,  124,  152,  236,   73,  199,  107,
 /*  1140 */   187,  171,  173,  174,  112,   84,   85,   86,   87,   88,
 /*  1150 */    89,   90,   91,   92,   93,   94,  173,  174,  152,   69,

 /*  1160 */   152,  211,   54,   55,   56,   57,   76,  152,  150,   79,
 /*  1170 */    80,   97,  211,  211,  211,  111,   59,  241,  241,  173,
 /*  1180 */   174,  173,  174,  202,  202,  185,  177,  176,  173,  174,
 /*  1190 */   176,  201,   84,   85,   86,   87,   88,   89,   90,   91,
 /*  1200 */    92,   93,   94,  215,  114,   88,   89,  152,  215,  119,
 /*  1210 */   120,  152,  181,   96,   97,   98,  176,  100,  215,  152,
 /*  1220 */   229,  152,  163,  152,  107,  199,  109,  155,  173,  174,
 /*  1230 */   245,  141,  173,  174,   60,  159,  152,  122,  159,  242,
 /*  1240 */   173,  174,  173,  174,  173,  174,   38,  242,  152,  132,
 /*  1250 */   159,  134,  152,   22,  195,  196,  152,  173,  174,  222,
 /*  1260 */    43,  130,  202,  152,   18,  152,  207,  208,  152,  173,
 /*  1270 */   174,  152,  190,  173,  174,  152,  193,  173,  174,  152,
 /*  1280 */   193,  193,  152,  159,  173,  174,  173,  174,  152,  173,
 /*  1290 */   174,  193,  173,  174,   18,  152,  173,  174,  152,  158,
 /*  1300 */   173,  174,  152,  173,  174,  152,  159,  152,  202,  173,
 /*  1310 */   174,  152,  190,  152,  222,  152,  173,  174,  152,  173,
 /*  1320 */   174,  137,  152,  173,  174,  190,  173,  174,  173,  174,
 /*  1330 */   202,  158,  173,  174,  173,  174,  173,  174,   61,  173,


 /*  1340 */   174,  152,  237,  173,  174,  152,  159,  152,  238,  152,
 /*  1350 */   158,  152,   22,  152,  178,  152,  158,  152,  158,  152,
 /*  1360 */   178,  159,  173,  174,  152,  159,  173,  174,  173,  174,
 /*  1370 */   173,  174,  173,  174,  173,  174,  173,  174,  173,  174,
 /*  1380 */   173,  174,  152,   63,  152,  173,  174,  107,  175,  175,


 /*  1390 */   175,  106,  183,  175,  178,  175,  177,  175,  175,  178,
 /*  1400 */    94,  107,  231,  173,  174,  173,  174,  183,  231,  125,
 /*  1410 */   216,  178,  159,  217,   22,  159,  226,  129,  137,  228,
 /*  1420 */   128,  217,  126,   25,  127,  162,  216,   26,  217,  161,
 /*  1430 */    13,  153,  153,  206,  205,    6,  251,  202,  204,  203,
 /*  1440 */   151,  216,  151,  217,  216,  171,  151,  165,  179,  179,
 /*  1450 */     4,    3,   22,  142,  171,  165,   15,  171,  171,   81,
 /*  1460 */    16,   23,   23,  120,  171,  131,  165,  111,  123,  171,
 /*  1470 */   171,  171,   20,  125,   16,    1,  123,  131,   53,   53,
 /*  1480 */    53,   53,  111,   96,   34,  122,  248,    1,  251,    5,
 /*  1490 */    22,  107,  140,   26,   74,   41,  122,  107,   67,   67,
 /*  1500 */    24,   20,   19,  112,  105,   23,   66,   22,   66,   22,
 /*  1510 */    22,   22,   37,   22,   22,   66,   23,   23,   28,   23,
 /*  1520 */    23,   26,   24,   23,   22,   24,  122,   23,   23,   96,
 /*  1530 */    22,  124,   26,   34,   23,   26,   23,   34,   23,   23,
 /*  1540 */    23,   34,   23,   22,   26,   11,   22,   22,   26,   23,
 /*  1550 */    23,   22,  116,   23,   22,   15,  122,  122,   23,  122,
 /*  1560 */     1,  252,  252,  252,  252,  122,  252,  252,  252,  252,
 /*  1570 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1580 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1590 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1600 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1610 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1620 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1630 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1640 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1650 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1660 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1670 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1680 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1690 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
 /*  1700 */   252,  252,  252,  252,  252,  252,  252,  252,  252,
};
#define YY_SHIFT_COUNT    (471)
#define YY_SHIFT_MIN      (0)
#define YY_SHIFT_MAX      (1559)
static const unsigned short int yy_shift_ofst[] = {
 /*     0 */   182, 1090,  822,  822,  306,  957,  957,  957,  957,  210,
 /*    10 */     0,    0,  104,  630,  957,  957,  957,  957,  957,  957,
 /*    20 */   957, 1117, 1117,  126,  968,  306,  306,  306,  306,  306,
 /*    30 */   306,   52,  156,  208,  260,  312,  364,  416,  468,  523,
 /*    40 */   578,  630,  630,  630,  630,  630,  630,  630,  630,  630,
 /*    50 */   630,  630,  630,  630,  630,  630,  630,  630,  682,  630,
 /*    60 */   733,  783,  783,  877,  957,  957,  957,  957,  957,  957,

 /*    70 */   957,  957,  957,  957,  957,  957,  957,  957,  957,  957,
 /*    80 */   957,  957,  957,  957,  957,  957,  957,  957,  957,  957,
 /*    90 */   957,  957,  957,  957,  957,  978,  957,  957,  957,  957,
 /*   100 */   957,  957,  957,  957,  957,  957,  957,  957,  957, 1061,
 /*   110 */  1108, 1108, 1108, 1108, 1108,   40,  127,   20,  280,  843,
 /*   120 */  1032,  144,  144,  280,  310,  310,  310,  310,   59,  191,
 /*   130 */    69, 1566, 1566, 1566,  786,  786,  786,  522,  836,  522,
 /*   140 */   959,  959,  892,  155,  358,  280,  280,  280,  280,  280,
 /*   150 */   280,  280,  280,  280,  280,  280,  280,  280,  280,  280,
 /*   160 */   280,  280,  280,  280,  280,  280,  371,  388,  645,  645,
 /*   170 */   531, 1566, 1566, 1566,  504,  189,  189,  909,   63,  176,
 /*   180 */   928,  440,  932,  973,  280,  280,  280,  280,  280,  314,
 /*   190 */   280,  280,  280,  280,  280,  280,  280,  280,  280,  280,
 /*   200 */   280,  280, 1064, 1064, 1064,  280,  280,  280,  280,  667,
 /*   210 */   280,  280,  280,  825,  280,  280,  902,  280,  280,  280,
 /*   220 */   280,  280,  280,  280,  280,  383,  676,  325,  975,  975,
 /*   230 */   975,  975, 1010,  325,  325,  819,  349,  524,  569,  829,
 /*   240 */   829,  832,  569,  832,  686,   51,  656,  303,  303,  303,
 /*   250 */   829,  294,  520,  628,  474, 1174, 1115, 1115, 1208, 1208,
 /*   260 */  1115, 1231, 1217, 1131, 1246, 1246, 1246, 1246, 1115, 1276,
 /*   270 */  1131, 1231, 1217, 1217, 1131, 1115, 1276, 1184, 1277, 1115,
 /*   280 */  1276, 1330, 1115, 1276, 1115, 1276, 1330, 1280, 1280, 1280,
 /*   290 */  1320, 1330, 1280, 1285, 1280, 1320, 1280, 1280, 1330, 1306,
 /*   300 */  1306, 1330, 1284, 1294, 1284, 1294, 1284, 1294, 1284, 1294,
 /*   310 */  1115, 1392, 1115, 1281, 1288, 1296, 1292, 1297, 1131, 1398,
 /*   320 */  1401, 1417, 1417, 1429, 1429, 1429, 1566, 1566, 1566, 1566,
 /*   330 */  1566, 1566, 1566, 1566, 1566, 1566, 1566, 1566, 1566, 1566,
 /*   340 */  1566, 1566,   34,  357,   38,  462,  514,  484, 1074,  727,
 /*   350 */   740,  734,  735,  777,  778,  784,  788,  803,  694,  845,
 /*   360 */   742,  796,  833,  837,  889,  860,  886, 1036,  806,  958,
 /*   370 */  1446, 1448, 1430, 1311, 1441, 1378, 1444, 1438, 1439, 1343,
 /*   380 */  1334, 1356, 1345, 1452, 1348, 1458, 1474, 1353, 1346, 1425,
 /*   390 */  1426, 1427, 1428, 1371, 1387, 1450, 1363, 1486, 1484, 1468,
 /*   400 */  1384, 1352, 1431, 1467, 1432, 1420, 1454, 1374, 1390, 1476,
 /*   410 */  1481, 1483, 1391, 1399, 1485, 1440, 1487, 1488, 1482, 1489,
 /*   420 */  1442, 1490, 1491, 1449, 1475, 1493, 1494, 1496, 1495, 1497,
 /*   430 */  1492, 1498, 1500, 1502, 1501, 1404, 1504, 1505, 1433, 1499,
 /*   440 */  1508, 1407, 1506, 1503, 1509, 1507, 1511, 1513, 1515, 1506,
 /*   450 */  1516, 1517, 1518, 1519, 1521, 1534, 1524, 1525, 1526, 1527,
 /*   460 */  1529, 1530, 1532, 1522, 1436, 1434, 1435, 1437, 1443, 1535,
 /*   470 */  1540, 1559,
};
#define YY_REDUCE_COUNT (341)
#define YY_REDUCE_MIN   (-211)
#define YY_REDUCE_MAX   (1301)
static const short yy_reduce_ofst[] = {
 /*     0 */  -143,  789,  753, 1059, -137, -146, -144, -141, -136,  687,
 /*    10 */  -107,  101, -203,  -52,  830,  870,  890,  167,  953,  218,
 /*    20 */   220,  413,  646,  897,   73,  281,  283,  332,  496,  601,
 /*    30 */   650, -211, -211, -211, -211, -211, -211, -211, -211, -211,
 /*    40 */  -211, -211, -211, -211, -211, -211, -211, -211, -211, -211,
 /*    50 */  -211, -211, -211, -211, -211, -211, -211, -211, -211, -211,
 /*    60 */  -211, -211, -211,  374,  377,  537,  969,  983, 1006, 1008,
 /*    70 */  1015, 1055, 1067, 1069, 1071, 1084, 1096, 1100, 1104, 1111,
 /*    80 */  1113, 1116, 1119, 1123, 1127, 1130, 1136, 1143, 1146, 1150,
 /*    90 */  1153, 1155, 1159, 1161, 1163, 1166, 1170, 1189, 1193, 1195,
 /*   100 */  1197, 1199, 1201, 1203, 1205, 1207, 1212, 1230, 1232, -211,
 /*   110 */  -211, -211, -211, -211, -211, -211, -211, -211,  -30,  427,
 /*   120 */  -171, -145, -134,   22,  279,  287,  279,  287,   99, -211,
 /*   130 */  -211, -211, -211, -211, -165, -165, -165,  123,  135,  175,
 /*   140 */  -150,  396,  337,  291,  291, -147,  185,  391,  446,  444,
 /*   150 */   452,  500,  501,  502,   27, -152,  295,  438,  490,  503,
 /*   160 */   495,  506,  -73,  447,  451,  536,  570,  551,  540,  579,
 /*   170 */    30,  508,  535,   81,   14,   61,  115,  168,  142,  222,
 /*   180 */   275,  284,  397,  599,  607,  647,  654,  660,  709,  658,
 /*   190 */   714,  750,  754,  772,  787,  801,  817,  818,  850,  863,
 /*   200 */   867,  871,  466,  748,  799,  881,  888,  898,  913,  824,
 /*   210 */   930,  933,  934,  873,  942,  945,  849,  946,  222,  954,
 /*   220 */   971,  972,  976,  979,  980,  900,  874,  927,  950,  961,
 /*   230 */   962,  963,  824,  927,  927,  939,  970, 1018,  981,  988,
 /*   240 */   993,  936,  982,  937, 1009, 1000, 1031, 1011, 1014, 1040,
 /*   250 */  1003,  991,  990, 1026, 1072,  985, 1076, 1079,  997, 1005,
 /*   260 */  1091, 1037, 1082, 1060, 1083, 1087, 1088, 1098, 1124, 1141,
 /*   270 */  1106, 1092, 1122, 1135, 1128, 1147, 1173, 1110, 1105, 1187,
 /*   280 */  1192, 1176, 1202, 1198, 1206, 1200, 1182, 1213, 1214, 1215,
 /*   290 */  1209, 1216, 1218, 1219, 1220, 1224, 1222, 1223, 1221, 1171,
 /*   300 */  1177, 1233, 1196, 1194, 1204, 1210, 1211, 1225, 1226, 1228,
 /*   310 */  1253, 1190, 1256, 1191, 1227, 1229, 1234, 1236, 1235, 1263,
 /*   320 */  1268, 1278, 1279, 1289, 1291, 1295, 1185, 1237, 1238, 1282,
 /*   330 */  1274, 1283, 1286, 1287, 1290, 1269, 1270, 1293, 1298, 1299,
 /*   340 */  1300, 1301,
};
static const YYACTIONTYPE yy_default[] = {
 /*     0 */  1297, 1349, 1221, 1014, 1119, 1221, 1221, 1221, 1221, 1014,
 /*    10 */  1145, 1145, 1272, 1045, 1014, 1014, 1014, 1014, 1014, 1220,
 /*    20 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
 /*    30 */  1014, 1151, 1014, 1014, 1014, 1014, 1222, 1223, 1014, 1014,
 /*    40 */  1014, 1271, 1273, 1161, 1160, 1159, 1158, 1254, 1132, 1156,
 /*    50 */  1149, 1153, 1216, 1217, 1215, 1219, 1222, 1223, 1014, 1152,
 /*    60 */  1186, 1200, 1185, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
 /*    70 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
 /*    80 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
 /*    90 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
 /*   100 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1194,
 /*   110 */  1199, 1206, 1198, 1195, 1188, 1187, 1189, 1190, 1014, 1035,
 /*   120 */  1084, 1014, 1014, 1014, 1289, 1288, 1014, 1014, 1045, 1191,
 /*   130 */  1192, 1203, 1202, 1201, 1279, 1305, 1304, 1014, 1014, 1014,
 /*   140 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
 /*   150 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
 /*   160 */  1014, 1014, 1014, 1014, 1014, 1014, 1045, 1297, 1041, 1041,
 /*   170 */  1014, 1284, 1119, 1110, 1014, 1014, 1014, 1014, 1014, 1014,
 /*   180 */  1014, 1014, 1014, 1014, 1014, 1276, 1274, 1014, 1236, 1014,
 /*   190 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
 /*   200 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
 /*   210 */  1014, 1014, 1014, 1115, 1014, 1014, 1014, 1014, 1014, 1014,
 /*   220 */  1014, 1014, 1014, 1014, 1299, 1014, 1249, 1098, 1115, 1115,
 /*   230 */  1115, 1115, 1117, 1099, 1097, 1109, 1045, 1021, 1155, 1134,
 /*   240 */  1134, 1338, 1155, 1338, 1059, 1319, 1056, 1145, 1145, 1145,
 /*   250 */  1134, 1218, 1116, 1109, 1014, 1341, 1124, 1124, 1340, 1340,
 /*   260 */  1124, 1166, 1087, 1155, 1093, 1093, 1093, 1093, 1124, 1032,
 /*   270 */  1155, 1166, 1087, 1087, 1155, 1124, 1032, 1253, 1335, 1124,
 /*   280 */  1032, 1229, 1124, 1032, 1124, 1032, 1229, 1085, 1085, 1085,
 /*   290 */  1074, 1229, 1085, 1059, 1085, 1074, 1085, 1085, 1229, 1233,
 /*   300 */  1233, 1229, 1138, 1133, 1138, 1133, 1138, 1133, 1138, 1133,
 /*   310 */  1124, 1224, 1124, 1014, 1150, 1139, 1148, 1146, 1155, 1038,
 /*   320 */  1077, 1302, 1302, 1298, 1298, 1298, 1346, 1346, 1284, 1314,
 /*   330 */  1045, 1045, 1045, 1045, 1314, 1061, 1061, 1045, 1045, 1045,
 /*   340 */  1045, 1314, 1014, 1014, 1014, 1014, 1014, 1014, 1309, 1014,
 /*   350 */  1238, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
 /*   360 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1171,
 /*   370 */  1014, 1017, 1281, 1014, 1014, 1280, 1014, 1014, 1014, 1014,
 /*   380 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
 /*   390 */  1014, 1014, 1014, 1014, 1014, 1014, 1337, 1014, 1014, 1014,
 /*   400 */  1014, 1014, 1014, 1252, 1251, 1014, 1014, 1126, 1014, 1014,
 /*   410 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
 /*   420 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
 /*   430 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
 /*   440 */  1014, 1014, 1147, 1014, 1140, 1014, 1014, 1014, 1014, 1328,
 /*   450 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
 /*   460 */  1014, 1014, 1014, 1323, 1101, 1173, 1014, 1172, 1176, 1014,
 /*   470 */  1026, 1014,
};
/********** End of lemon-generated parsing tables *****************************/

/* The next table maps tokens (terminal symbols) into fallback tokens.  
** If a construct like the following:
** 
**      %fallback ID X Y Z.
140592
140593
140594
140595
140596
140597
140598
140599
140600
140601
140602
140603
140604
140605
140606
  /*  190 */ "orconf",
  /*  191 */ "resolvetype",
  /*  192 */ "raisetype",
  /*  193 */ "ifexists",
  /*  194 */ "fullname",
  /*  195 */ "selectnowith",
  /*  196 */ "oneselect",
  /*  197 */ "with",
  /*  198 */ "multiselect_op",
  /*  199 */ "distinct",
  /*  200 */ "selcollist",
  /*  201 */ "from",
  /*  202 */ "where_opt",
  /*  203 */ "groupby_opt",
  /*  204 */ "having_opt",







|







140965
140966
140967
140968
140969
140970
140971
140972
140973
140974
140975
140976
140977
140978
140979
  /*  190 */ "orconf",
  /*  191 */ "resolvetype",
  /*  192 */ "raisetype",
  /*  193 */ "ifexists",
  /*  194 */ "fullname",
  /*  195 */ "selectnowith",
  /*  196 */ "oneselect",
  /*  197 */ "wqlist",
  /*  198 */ "multiselect_op",
  /*  199 */ "distinct",
  /*  200 */ "selcollist",
  /*  201 */ "from",
  /*  202 */ "where_opt",
  /*  203 */ "groupby_opt",
  /*  204 */ "having_opt",
140614
140615
140616
140617
140618
140619
140620
140621
140622
140623
140624
140625
140626
140627
140628
140629
140630
140631
140632
140633
140634
140635
140636
140637
140638
140639
140640
140641
140642
140643
140644
140645
140646
140647
140648
140649
140650
140651
140652
140653
140654
140655
140656
140657
140658
140659
140660
  /*  212 */ "seltablist",
  /*  213 */ "stl_prefix",
  /*  214 */ "joinop",
  /*  215 */ "indexed_opt",
  /*  216 */ "on_opt",
  /*  217 */ "using_opt",
  /*  218 */ "idlist",
  /*  219 */ "setlist",
  /*  220 */ "insert_cmd",
  /*  221 */ "idlist_opt",
  /*  222 */ "likeop",
  /*  223 */ "between_op",
  /*  224 */ "in_op",
  /*  225 */ "paren_exprlist",
  /*  226 */ "case_operand",
  /*  227 */ "case_exprlist",
  /*  228 */ "case_else",
  /*  229 */ "uniqueflag",
  /*  230 */ "collate",
  /*  231 */ "nmnum",
  /*  232 */ "trigger_decl",
  /*  233 */ "trigger_cmd_list",
  /*  234 */ "trigger_time",
  /*  235 */ "trigger_event",
  /*  236 */ "foreach_clause",
  /*  237 */ "when_clause",
  /*  238 */ "trigger_cmd",
  /*  239 */ "trnm",
  /*  240 */ "tridxby",
  /*  241 */ "database_kw_opt",
  /*  242 */ "key_opt",
  /*  243 */ "add_column_fullname",
  /*  244 */ "kwcolumn_opt",
  /*  245 */ "create_vtab",
  /*  246 */ "vtabarglist",
  /*  247 */ "vtabarg",
  /*  248 */ "vtabargtoken",
  /*  249 */ "lp",
  /*  250 */ "anylist",
  /*  251 */ "wqlist",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */

#ifndef NDEBUG
/* For tracing reduce actions, the names of all rules are required.
*/
static const char *const yyRuleName[] = {







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







140987
140988
140989
140990
140991
140992
140993
140994
140995
140996
140997
140998
140999
141000
141001
141002
141003
141004
141005
141006
141007
141008
141009
141010
141011
141012
141013
141014
141015
141016
141017
141018
141019
141020
141021
141022
141023
141024
141025
141026
141027
141028
141029
141030
141031
141032
141033
  /*  212 */ "seltablist",
  /*  213 */ "stl_prefix",
  /*  214 */ "joinop",
  /*  215 */ "indexed_opt",
  /*  216 */ "on_opt",
  /*  217 */ "using_opt",
  /*  218 */ "idlist",
  /*  219 */ "with",
  /*  220 */ "setlist",
  /*  221 */ "insert_cmd",
  /*  222 */ "idlist_opt",
  /*  223 */ "likeop",
  /*  224 */ "between_op",
  /*  225 */ "in_op",
  /*  226 */ "paren_exprlist",
  /*  227 */ "case_operand",
  /*  228 */ "case_exprlist",
  /*  229 */ "case_else",
  /*  230 */ "uniqueflag",
  /*  231 */ "collate",
  /*  232 */ "nmnum",
  /*  233 */ "trigger_decl",
  /*  234 */ "trigger_cmd_list",
  /*  235 */ "trigger_time",
  /*  236 */ "trigger_event",
  /*  237 */ "foreach_clause",
  /*  238 */ "when_clause",
  /*  239 */ "trigger_cmd",
  /*  240 */ "trnm",
  /*  241 */ "tridxby",
  /*  242 */ "database_kw_opt",
  /*  243 */ "key_opt",
  /*  244 */ "add_column_fullname",
  /*  245 */ "kwcolumn_opt",
  /*  246 */ "create_vtab",
  /*  247 */ "vtabarglist",
  /*  248 */ "vtabarg",
  /*  249 */ "vtabargtoken",
  /*  250 */ "lp",
  /*  251 */ "anylist",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */

#ifndef NDEBUG
/* For tracing reduce actions, the names of all rules are required.
*/
static const char *const yyRuleName[] = {
140734
140735
140736
140737
140738
140739
140740
140741


140742
140743
140744
140745
140746
140747
140748
140749
140750
140751
140752
140753
140754
140755
140756
140757
140758
140759
140760
140761
140762
140763
140764
140765
140766
140767
140768
140769
140770
140771
140772



140773
140774
140775
140776
140777
140778
140779
140780
140781
140782
140783
140784
140785
140786
140787
140788
140789
140790
140791
140792
140793
140794
140795
140796
140797
140798
140799
140800
140801
140802
140803
140804
140805
140806
140807
140808
140809
140810
140811
140812
140813
140814
140815
140816
140817
140818
140819
140820
140821
140822
140823
140824
140825
140826
140827
140828
140829
140830
140831
140832
140833
140834
140835
140836
140837
140838
140839
140840
140841
140842
140843
140844



140845
140846
140847
140848
140849
140850
140851
140852
140853
140854
140855
140856
140857
140858
140859
140860
140861
140862
140863
140864
140865
140866
140867
140868
140869
140870
140871
140872
140873
140874
140875
140876
140877
140878
140879
140880
140881
140882
140883
140884
140885
140886
140887
140888
140889
140890
140891
140892
140893
140894
140895
140896
140897
140898
140899
140900
140901
140902
140903
140904
140905
140906
140907
140908
140909
140910
140911
140912
140913
140914
140915
140916
140917
140918
140919
140920
140921
140922
140923
140924
140925
140926
140927
140928
140929
140930
140931
140932
140933
140934
140935
140936
140937
140938
140939
140940
140941
140942
140943
140944
140945
140946
140947
140948
140949
140950
140951
140952
140953
140954
140955
140956
140957
140958
140959
140960
140961
140962
140963
140964
140965
140966
140967
140968
140969
140970
140971
140972
140973
140974
140975
140976
140977
140978
140979
140980
140981
140982
140983
140984
140985
140986
140987
140988
140989
140990

140991
140992
140993
140994
140995
140996
140997
 /*  73 */ "resolvetype ::= REPLACE",
 /*  74 */ "cmd ::= DROP TABLE ifexists fullname",
 /*  75 */ "ifexists ::= IF EXISTS",
 /*  76 */ "ifexists ::=",
 /*  77 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select",
 /*  78 */ "cmd ::= DROP VIEW ifexists fullname",
 /*  79 */ "cmd ::= select",
 /*  80 */ "select ::= with selectnowith",


 /*  81 */ "selectnowith ::= selectnowith multiselect_op oneselect",
 /*  82 */ "multiselect_op ::= UNION",
 /*  83 */ "multiselect_op ::= UNION ALL",
 /*  84 */ "multiselect_op ::= EXCEPT|INTERSECT",
 /*  85 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
 /*  86 */ "values ::= VALUES LP nexprlist RP",
 /*  87 */ "values ::= values COMMA LP exprlist RP",
 /*  88 */ "distinct ::= DISTINCT",
 /*  89 */ "distinct ::= ALL",
 /*  90 */ "distinct ::=",
 /*  91 */ "sclp ::=",
 /*  92 */ "selcollist ::= sclp scanpt expr scanpt as",
 /*  93 */ "selcollist ::= sclp scanpt STAR",
 /*  94 */ "selcollist ::= sclp scanpt nm DOT STAR",
 /*  95 */ "as ::= AS nm",
 /*  96 */ "as ::=",
 /*  97 */ "from ::=",
 /*  98 */ "from ::= FROM seltablist",
 /*  99 */ "stl_prefix ::= seltablist joinop",
 /* 100 */ "stl_prefix ::=",
 /* 101 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
 /* 102 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt",
 /* 103 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
 /* 104 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
 /* 105 */ "dbnm ::=",
 /* 106 */ "dbnm ::= DOT nm",
 /* 107 */ "fullname ::= nm dbnm",
 /* 108 */ "joinop ::= COMMA|JOIN",
 /* 109 */ "joinop ::= JOIN_KW JOIN",
 /* 110 */ "joinop ::= JOIN_KW nm JOIN",
 /* 111 */ "joinop ::= JOIN_KW nm nm JOIN",



 /* 112 */ "on_opt ::= ON expr",
 /* 113 */ "on_opt ::=",
 /* 114 */ "indexed_opt ::=",
 /* 115 */ "indexed_opt ::= INDEXED BY nm",
 /* 116 */ "indexed_opt ::= NOT INDEXED",
 /* 117 */ "using_opt ::= USING LP idlist RP",
 /* 118 */ "using_opt ::=",
 /* 119 */ "orderby_opt ::=",
 /* 120 */ "orderby_opt ::= ORDER BY sortlist",
 /* 121 */ "sortlist ::= sortlist COMMA expr sortorder",
 /* 122 */ "sortlist ::= expr sortorder",
 /* 123 */ "sortorder ::= ASC",
 /* 124 */ "sortorder ::= DESC",
 /* 125 */ "sortorder ::=",
 /* 126 */ "groupby_opt ::=",
 /* 127 */ "groupby_opt ::= GROUP BY nexprlist",
 /* 128 */ "having_opt ::=",
 /* 129 */ "having_opt ::= HAVING expr",
 /* 130 */ "limit_opt ::=",
 /* 131 */ "limit_opt ::= LIMIT expr",
 /* 132 */ "limit_opt ::= LIMIT expr OFFSET expr",
 /* 133 */ "limit_opt ::= LIMIT expr COMMA expr",
 /* 134 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt",
 /* 135 */ "where_opt ::=",
 /* 136 */ "where_opt ::= WHERE expr",
 /* 137 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt",
 /* 138 */ "setlist ::= setlist COMMA nm EQ expr",
 /* 139 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
 /* 140 */ "setlist ::= nm EQ expr",
 /* 141 */ "setlist ::= LP idlist RP EQ expr",
 /* 142 */ "cmd ::= with insert_cmd INTO fullname idlist_opt select",
 /* 143 */ "cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES",
 /* 144 */ "insert_cmd ::= INSERT orconf",
 /* 145 */ "insert_cmd ::= REPLACE",
 /* 146 */ "idlist_opt ::=",
 /* 147 */ "idlist_opt ::= LP idlist RP",
 /* 148 */ "idlist ::= idlist COMMA nm",
 /* 149 */ "idlist ::= nm",
 /* 150 */ "expr ::= LP expr RP",
 /* 151 */ "expr ::= ID|INDEXED",
 /* 152 */ "expr ::= JOIN_KW",
 /* 153 */ "expr ::= nm DOT nm",
 /* 154 */ "expr ::= nm DOT nm DOT nm",
 /* 155 */ "term ::= NULL|FLOAT|BLOB",
 /* 156 */ "term ::= STRING",
 /* 157 */ "term ::= INTEGER",
 /* 158 */ "expr ::= VARIABLE",
 /* 159 */ "expr ::= expr COLLATE ID|STRING",
 /* 160 */ "expr ::= CAST LP expr AS typetoken RP",
 /* 161 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
 /* 162 */ "expr ::= ID|INDEXED LP STAR RP",
 /* 163 */ "term ::= CTIME_KW",
 /* 164 */ "expr ::= LP nexprlist COMMA expr RP",
 /* 165 */ "expr ::= expr AND expr",
 /* 166 */ "expr ::= expr OR expr",
 /* 167 */ "expr ::= expr LT|GT|GE|LE expr",
 /* 168 */ "expr ::= expr EQ|NE expr",
 /* 169 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
 /* 170 */ "expr ::= expr PLUS|MINUS expr",
 /* 171 */ "expr ::= expr STAR|SLASH|REM expr",
 /* 172 */ "expr ::= expr CONCAT expr",
 /* 173 */ "likeop ::= NOT LIKE_KW|MATCH",
 /* 174 */ "expr ::= expr likeop expr",
 /* 175 */ "expr ::= expr likeop expr ESCAPE expr",
 /* 176 */ "expr ::= expr ISNULL|NOTNULL",
 /* 177 */ "expr ::= expr NOT NULL",
 /* 178 */ "expr ::= expr IS expr",
 /* 179 */ "expr ::= expr IS NOT expr",
 /* 180 */ "expr ::= NOT expr",
 /* 181 */ "expr ::= BITNOT expr",
 /* 182 */ "expr ::= MINUS expr",
 /* 183 */ "expr ::= PLUS expr",



 /* 184 */ "between_op ::= BETWEEN",
 /* 185 */ "between_op ::= NOT BETWEEN",
 /* 186 */ "expr ::= expr between_op expr AND expr",
 /* 187 */ "in_op ::= IN",
 /* 188 */ "in_op ::= NOT IN",
 /* 189 */ "expr ::= expr in_op LP exprlist RP",
 /* 190 */ "expr ::= LP select RP",
 /* 191 */ "expr ::= expr in_op LP select RP",
 /* 192 */ "expr ::= expr in_op nm dbnm paren_exprlist",
 /* 193 */ "expr ::= EXISTS LP select RP",
 /* 194 */ "expr ::= CASE case_operand case_exprlist case_else END",
 /* 195 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
 /* 196 */ "case_exprlist ::= WHEN expr THEN expr",
 /* 197 */ "case_else ::= ELSE expr",
 /* 198 */ "case_else ::=",
 /* 199 */ "case_operand ::= expr",
 /* 200 */ "case_operand ::=",
 /* 201 */ "exprlist ::=",
 /* 202 */ "nexprlist ::= nexprlist COMMA expr",
 /* 203 */ "nexprlist ::= expr",
 /* 204 */ "paren_exprlist ::=",
 /* 205 */ "paren_exprlist ::= LP exprlist RP",
 /* 206 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
 /* 207 */ "uniqueflag ::= UNIQUE",
 /* 208 */ "uniqueflag ::=",
 /* 209 */ "eidlist_opt ::=",
 /* 210 */ "eidlist_opt ::= LP eidlist RP",
 /* 211 */ "eidlist ::= eidlist COMMA nm collate sortorder",
 /* 212 */ "eidlist ::= nm collate sortorder",
 /* 213 */ "collate ::=",
 /* 214 */ "collate ::= COLLATE ID|STRING",
 /* 215 */ "cmd ::= DROP INDEX ifexists fullname",
 /* 216 */ "cmd ::= VACUUM",
 /* 217 */ "cmd ::= VACUUM nm",
 /* 218 */ "cmd ::= PRAGMA nm dbnm",
 /* 219 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
 /* 220 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
 /* 221 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
 /* 222 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
 /* 223 */ "plus_num ::= PLUS INTEGER|FLOAT",
 /* 224 */ "minus_num ::= MINUS INTEGER|FLOAT",
 /* 225 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
 /* 226 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
 /* 227 */ "trigger_time ::= BEFORE|AFTER",
 /* 228 */ "trigger_time ::= INSTEAD OF",
 /* 229 */ "trigger_time ::=",
 /* 230 */ "trigger_event ::= DELETE|INSERT",
 /* 231 */ "trigger_event ::= UPDATE",
 /* 232 */ "trigger_event ::= UPDATE OF idlist",
 /* 233 */ "when_clause ::=",
 /* 234 */ "when_clause ::= WHEN expr",
 /* 235 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
 /* 236 */ "trigger_cmd_list ::= trigger_cmd SEMI",
 /* 237 */ "trnm ::= nm DOT nm",
 /* 238 */ "tridxby ::= INDEXED BY nm",
 /* 239 */ "tridxby ::= NOT INDEXED",
 /* 240 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
 /* 241 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select scanpt",
 /* 242 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
 /* 243 */ "trigger_cmd ::= scanpt select scanpt",
 /* 244 */ "expr ::= RAISE LP IGNORE RP",
 /* 245 */ "expr ::= RAISE LP raisetype COMMA nm RP",
 /* 246 */ "raisetype ::= ROLLBACK",
 /* 247 */ "raisetype ::= ABORT",
 /* 248 */ "raisetype ::= FAIL",
 /* 249 */ "cmd ::= DROP TRIGGER ifexists fullname",
 /* 250 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
 /* 251 */ "cmd ::= DETACH database_kw_opt expr",
 /* 252 */ "key_opt ::=",
 /* 253 */ "key_opt ::= KEY expr",
 /* 254 */ "cmd ::= REINDEX",
 /* 255 */ "cmd ::= REINDEX nm dbnm",
 /* 256 */ "cmd ::= ANALYZE",
 /* 257 */ "cmd ::= ANALYZE nm dbnm",
 /* 258 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
 /* 259 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
 /* 260 */ "add_column_fullname ::= fullname",
 /* 261 */ "cmd ::= create_vtab",
 /* 262 */ "cmd ::= create_vtab LP vtabarglist RP",
 /* 263 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
 /* 264 */ "vtabarg ::=",
 /* 265 */ "vtabargtoken ::= ANY",
 /* 266 */ "vtabargtoken ::= lp anylist RP",
 /* 267 */ "lp ::= LP",
 /* 268 */ "with ::=",
 /* 269 */ "with ::= WITH wqlist",
 /* 270 */ "with ::= WITH RECURSIVE wqlist",
 /* 271 */ "wqlist ::= nm eidlist_opt AS LP select RP",
 /* 272 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
 /* 273 */ "input ::= cmdlist",
 /* 274 */ "cmdlist ::= cmdlist ecmd",
 /* 275 */ "cmdlist ::= ecmd",
 /* 276 */ "ecmd ::= SEMI",
 /* 277 */ "ecmd ::= explain cmdx SEMI",
 /* 278 */ "explain ::=",
 /* 279 */ "trans_opt ::=",
 /* 280 */ "trans_opt ::= TRANSACTION",
 /* 281 */ "trans_opt ::= TRANSACTION nm",
 /* 282 */ "savepoint_opt ::= SAVEPOINT",
 /* 283 */ "savepoint_opt ::=",
 /* 284 */ "cmd ::= create_table create_table_args",
 /* 285 */ "columnlist ::= columnlist COMMA columnname carglist",
 /* 286 */ "columnlist ::= columnname carglist",
 /* 287 */ "nm ::= ID|INDEXED",
 /* 288 */ "nm ::= STRING",
 /* 289 */ "nm ::= JOIN_KW",
 /* 290 */ "typetoken ::= typename",
 /* 291 */ "typename ::= ID|STRING",
 /* 292 */ "signed ::= plus_num",
 /* 293 */ "signed ::= minus_num",
 /* 294 */ "carglist ::= carglist ccons",
 /* 295 */ "carglist ::=",
 /* 296 */ "ccons ::= NULL onconf",
 /* 297 */ "conslist_opt ::= COMMA conslist",
 /* 298 */ "conslist ::= conslist tconscomma tcons",
 /* 299 */ "conslist ::= tcons",
 /* 300 */ "tconscomma ::=",
 /* 301 */ "defer_subclause_opt ::= defer_subclause",
 /* 302 */ "resolvetype ::= raisetype",
 /* 303 */ "selectnowith ::= oneselect",
 /* 304 */ "oneselect ::= values",
 /* 305 */ "sclp ::= selcollist COMMA",
 /* 306 */ "as ::= ID|STRING",
 /* 307 */ "expr ::= term",
 /* 308 */ "likeop ::= LIKE_KW|MATCH",
 /* 309 */ "exprlist ::= nexprlist",
 /* 310 */ "nmnum ::= plus_num",
 /* 311 */ "nmnum ::= nm",
 /* 312 */ "nmnum ::= ON",
 /* 313 */ "nmnum ::= DELETE",
 /* 314 */ "nmnum ::= DEFAULT",
 /* 315 */ "plus_num ::= INTEGER|FLOAT",
 /* 316 */ "foreach_clause ::=",
 /* 317 */ "foreach_clause ::= FOR EACH ROW",
 /* 318 */ "trnm ::= nm",
 /* 319 */ "tridxby ::=",
 /* 320 */ "database_kw_opt ::= DATABASE",
 /* 321 */ "database_kw_opt ::=",
 /* 322 */ "kwcolumn_opt ::=",
 /* 323 */ "kwcolumn_opt ::= COLUMNKW",
 /* 324 */ "vtabarglist ::= vtabarg",
 /* 325 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
 /* 326 */ "vtabarg ::= vtabarg vtabargtoken",
 /* 327 */ "anylist ::=",
 /* 328 */ "anylist ::= anylist LP anylist RP",
 /* 329 */ "anylist ::= anylist ANY",

};
#endif /* NDEBUG */


#if YYSTACKDEPTH<=0
/*
** Try to increase the size of the parser stack.  Return the number







|
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
|
|
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>







141107
141108
141109
141110
141111
141112
141113
141114
141115
141116
141117
141118
141119
141120
141121
141122
141123
141124
141125
141126
141127
141128
141129
141130
141131
141132
141133
141134
141135
141136
141137
141138
141139
141140
141141
141142
141143


141144
141145
141146
141147
141148
141149
141150
141151
141152
141153
141154
141155
141156
141157
141158
141159
141160
141161
141162
141163
141164
141165
141166
141167
141168
141169
141170
141171
141172
141173
141174
141175
141176
141177
141178
141179
141180
141181
141182
141183
141184
141185
141186
141187
141188
141189
141190
141191
141192
141193
141194
141195
141196
141197
141198
141199
141200
141201



141202
141203
141204
141205
141206
141207
141208
141209
141210
141211
141212
141213
141214
141215
141216
141217
141218
141219
141220
141221
141222
141223
141224
141225
141226
141227
141228
141229
141230
141231
141232
141233
141234
141235
141236
141237
141238
141239
141240
141241
141242
141243
141244
141245
141246
141247
141248
141249
141250
141251
141252
141253
141254
141255
141256
141257
141258
141259
141260
141261
141262
141263
141264
141265
141266
141267
141268
141269
141270
141271
141272
141273
141274
141275
141276
141277
141278
141279
141280
141281
141282
141283
141284
141285
141286
141287
141288
141289
141290
141291
141292
141293
141294
141295
141296
141297
141298
141299
141300
141301
141302
141303
141304

141305
141306
141307
141308
141309
141310
141311
141312
141313
141314
141315
141316
141317
141318
141319
141320
141321
141322
141323
141324
141325
141326
141327
141328
141329
141330
141331
141332
141333
141334
141335
141336
141337
141338
141339
141340
141341
141342
141343
141344
141345
141346
141347
141348
141349
141350
141351
141352
141353
141354
141355
141356
141357
141358
141359
141360
141361
141362
141363
141364
141365
141366
141367
141368
141369
141370
141371
141372
141373
 /*  73 */ "resolvetype ::= REPLACE",
 /*  74 */ "cmd ::= DROP TABLE ifexists fullname",
 /*  75 */ "ifexists ::= IF EXISTS",
 /*  76 */ "ifexists ::=",
 /*  77 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select",
 /*  78 */ "cmd ::= DROP VIEW ifexists fullname",
 /*  79 */ "cmd ::= select",
 /*  80 */ "select ::= WITH wqlist selectnowith",
 /*  81 */ "select ::= WITH RECURSIVE wqlist selectnowith",
 /*  82 */ "select ::= selectnowith",
 /*  83 */ "selectnowith ::= selectnowith multiselect_op oneselect",
 /*  84 */ "multiselect_op ::= UNION",
 /*  85 */ "multiselect_op ::= UNION ALL",
 /*  86 */ "multiselect_op ::= EXCEPT|INTERSECT",
 /*  87 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
 /*  88 */ "values ::= VALUES LP nexprlist RP",
 /*  89 */ "values ::= values COMMA LP exprlist RP",
 /*  90 */ "distinct ::= DISTINCT",
 /*  91 */ "distinct ::= ALL",
 /*  92 */ "distinct ::=",
 /*  93 */ "sclp ::=",
 /*  94 */ "selcollist ::= sclp scanpt expr scanpt as",
 /*  95 */ "selcollist ::= sclp scanpt STAR",
 /*  96 */ "selcollist ::= sclp scanpt nm DOT STAR",
 /*  97 */ "as ::= AS nm",
 /*  98 */ "as ::=",
 /*  99 */ "from ::=",
 /* 100 */ "from ::= FROM seltablist",
 /* 101 */ "stl_prefix ::= seltablist joinop",
 /* 102 */ "stl_prefix ::=",
 /* 103 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
 /* 104 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt",
 /* 105 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
 /* 106 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
 /* 107 */ "dbnm ::=",
 /* 108 */ "dbnm ::= DOT nm",
 /* 109 */ "fullname ::= nm",


 /* 110 */ "fullname ::= nm DOT nm",
 /* 111 */ "joinop ::= COMMA|JOIN",
 /* 112 */ "joinop ::= JOIN_KW JOIN",
 /* 113 */ "joinop ::= JOIN_KW nm JOIN",
 /* 114 */ "joinop ::= JOIN_KW nm nm JOIN",
 /* 115 */ "on_opt ::= ON expr",
 /* 116 */ "on_opt ::=",
 /* 117 */ "indexed_opt ::=",
 /* 118 */ "indexed_opt ::= INDEXED BY nm",
 /* 119 */ "indexed_opt ::= NOT INDEXED",
 /* 120 */ "using_opt ::= USING LP idlist RP",
 /* 121 */ "using_opt ::=",
 /* 122 */ "orderby_opt ::=",
 /* 123 */ "orderby_opt ::= ORDER BY sortlist",
 /* 124 */ "sortlist ::= sortlist COMMA expr sortorder",
 /* 125 */ "sortlist ::= expr sortorder",
 /* 126 */ "sortorder ::= ASC",
 /* 127 */ "sortorder ::= DESC",
 /* 128 */ "sortorder ::=",
 /* 129 */ "groupby_opt ::=",
 /* 130 */ "groupby_opt ::= GROUP BY nexprlist",
 /* 131 */ "having_opt ::=",
 /* 132 */ "having_opt ::= HAVING expr",
 /* 133 */ "limit_opt ::=",
 /* 134 */ "limit_opt ::= LIMIT expr",
 /* 135 */ "limit_opt ::= LIMIT expr OFFSET expr",
 /* 136 */ "limit_opt ::= LIMIT expr COMMA expr",
 /* 137 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt",
 /* 138 */ "where_opt ::=",
 /* 139 */ "where_opt ::= WHERE expr",
 /* 140 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt",
 /* 141 */ "setlist ::= setlist COMMA nm EQ expr",
 /* 142 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
 /* 143 */ "setlist ::= nm EQ expr",
 /* 144 */ "setlist ::= LP idlist RP EQ expr",
 /* 145 */ "cmd ::= with insert_cmd INTO fullname idlist_opt select",
 /* 146 */ "cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES",
 /* 147 */ "insert_cmd ::= INSERT orconf",
 /* 148 */ "insert_cmd ::= REPLACE",
 /* 149 */ "idlist_opt ::=",
 /* 150 */ "idlist_opt ::= LP idlist RP",
 /* 151 */ "idlist ::= idlist COMMA nm",
 /* 152 */ "idlist ::= nm",
 /* 153 */ "expr ::= LP expr RP",
 /* 154 */ "expr ::= ID|INDEXED",
 /* 155 */ "expr ::= JOIN_KW",
 /* 156 */ "expr ::= nm DOT nm",
 /* 157 */ "expr ::= nm DOT nm DOT nm",
 /* 158 */ "term ::= NULL|FLOAT|BLOB",
 /* 159 */ "term ::= STRING",
 /* 160 */ "term ::= INTEGER",
 /* 161 */ "expr ::= VARIABLE",
 /* 162 */ "expr ::= expr COLLATE ID|STRING",
 /* 163 */ "expr ::= CAST LP expr AS typetoken RP",
 /* 164 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
 /* 165 */ "expr ::= ID|INDEXED LP STAR RP",
 /* 166 */ "term ::= CTIME_KW",
 /* 167 */ "expr ::= LP nexprlist COMMA expr RP",



 /* 168 */ "expr ::= expr AND expr",
 /* 169 */ "expr ::= expr OR expr",
 /* 170 */ "expr ::= expr LT|GT|GE|LE expr",
 /* 171 */ "expr ::= expr EQ|NE expr",
 /* 172 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
 /* 173 */ "expr ::= expr PLUS|MINUS expr",
 /* 174 */ "expr ::= expr STAR|SLASH|REM expr",
 /* 175 */ "expr ::= expr CONCAT expr",
 /* 176 */ "likeop ::= NOT LIKE_KW|MATCH",
 /* 177 */ "expr ::= expr likeop expr",
 /* 178 */ "expr ::= expr likeop expr ESCAPE expr",
 /* 179 */ "expr ::= expr ISNULL|NOTNULL",
 /* 180 */ "expr ::= expr NOT NULL",
 /* 181 */ "expr ::= expr IS expr",
 /* 182 */ "expr ::= expr IS NOT expr",
 /* 183 */ "expr ::= NOT expr",
 /* 184 */ "expr ::= BITNOT expr",
 /* 185 */ "expr ::= MINUS expr",
 /* 186 */ "expr ::= PLUS expr",
 /* 187 */ "between_op ::= BETWEEN",
 /* 188 */ "between_op ::= NOT BETWEEN",
 /* 189 */ "expr ::= expr between_op expr AND expr",
 /* 190 */ "in_op ::= IN",
 /* 191 */ "in_op ::= NOT IN",
 /* 192 */ "expr ::= expr in_op LP exprlist RP",
 /* 193 */ "expr ::= LP select RP",
 /* 194 */ "expr ::= expr in_op LP select RP",
 /* 195 */ "expr ::= expr in_op nm dbnm paren_exprlist",
 /* 196 */ "expr ::= EXISTS LP select RP",
 /* 197 */ "expr ::= CASE case_operand case_exprlist case_else END",
 /* 198 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
 /* 199 */ "case_exprlist ::= WHEN expr THEN expr",
 /* 200 */ "case_else ::= ELSE expr",
 /* 201 */ "case_else ::=",
 /* 202 */ "case_operand ::= expr",
 /* 203 */ "case_operand ::=",
 /* 204 */ "exprlist ::=",
 /* 205 */ "nexprlist ::= nexprlist COMMA expr",
 /* 206 */ "nexprlist ::= expr",
 /* 207 */ "paren_exprlist ::=",
 /* 208 */ "paren_exprlist ::= LP exprlist RP",
 /* 209 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
 /* 210 */ "uniqueflag ::= UNIQUE",
 /* 211 */ "uniqueflag ::=",
 /* 212 */ "eidlist_opt ::=",
 /* 213 */ "eidlist_opt ::= LP eidlist RP",
 /* 214 */ "eidlist ::= eidlist COMMA nm collate sortorder",
 /* 215 */ "eidlist ::= nm collate sortorder",
 /* 216 */ "collate ::=",
 /* 217 */ "collate ::= COLLATE ID|STRING",
 /* 218 */ "cmd ::= DROP INDEX ifexists fullname",
 /* 219 */ "cmd ::= VACUUM",
 /* 220 */ "cmd ::= VACUUM nm",
 /* 221 */ "cmd ::= PRAGMA nm dbnm",
 /* 222 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
 /* 223 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
 /* 224 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
 /* 225 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
 /* 226 */ "plus_num ::= PLUS INTEGER|FLOAT",
 /* 227 */ "minus_num ::= MINUS INTEGER|FLOAT",
 /* 228 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
 /* 229 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
 /* 230 */ "trigger_time ::= BEFORE|AFTER",
 /* 231 */ "trigger_time ::= INSTEAD OF",
 /* 232 */ "trigger_time ::=",
 /* 233 */ "trigger_event ::= DELETE|INSERT",
 /* 234 */ "trigger_event ::= UPDATE",
 /* 235 */ "trigger_event ::= UPDATE OF idlist",
 /* 236 */ "when_clause ::=",
 /* 237 */ "when_clause ::= WHEN expr",
 /* 238 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
 /* 239 */ "trigger_cmd_list ::= trigger_cmd SEMI",
 /* 240 */ "trnm ::= nm DOT nm",
 /* 241 */ "tridxby ::= INDEXED BY nm",
 /* 242 */ "tridxby ::= NOT INDEXED",
 /* 243 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
 /* 244 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select scanpt",
 /* 245 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
 /* 246 */ "trigger_cmd ::= scanpt select scanpt",
 /* 247 */ "expr ::= RAISE LP IGNORE RP",
 /* 248 */ "expr ::= RAISE LP raisetype COMMA nm RP",
 /* 249 */ "raisetype ::= ROLLBACK",
 /* 250 */ "raisetype ::= ABORT",
 /* 251 */ "raisetype ::= FAIL",
 /* 252 */ "cmd ::= DROP TRIGGER ifexists fullname",
 /* 253 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
 /* 254 */ "cmd ::= DETACH database_kw_opt expr",
 /* 255 */ "key_opt ::=",
 /* 256 */ "key_opt ::= KEY expr",
 /* 257 */ "cmd ::= REINDEX",
 /* 258 */ "cmd ::= REINDEX nm dbnm",
 /* 259 */ "cmd ::= ANALYZE",
 /* 260 */ "cmd ::= ANALYZE nm dbnm",
 /* 261 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
 /* 262 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
 /* 263 */ "add_column_fullname ::= fullname",
 /* 264 */ "cmd ::= create_vtab",
 /* 265 */ "cmd ::= create_vtab LP vtabarglist RP",
 /* 266 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
 /* 267 */ "vtabarg ::=",
 /* 268 */ "vtabargtoken ::= ANY",
 /* 269 */ "vtabargtoken ::= lp anylist RP",
 /* 270 */ "lp ::= LP",

 /* 271 */ "with ::= WITH wqlist",
 /* 272 */ "with ::= WITH RECURSIVE wqlist",
 /* 273 */ "wqlist ::= nm eidlist_opt AS LP select RP",
 /* 274 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
 /* 275 */ "input ::= cmdlist",
 /* 276 */ "cmdlist ::= cmdlist ecmd",
 /* 277 */ "cmdlist ::= ecmd",
 /* 278 */ "ecmd ::= SEMI",
 /* 279 */ "ecmd ::= explain cmdx SEMI",
 /* 280 */ "explain ::=",
 /* 281 */ "trans_opt ::=",
 /* 282 */ "trans_opt ::= TRANSACTION",
 /* 283 */ "trans_opt ::= TRANSACTION nm",
 /* 284 */ "savepoint_opt ::= SAVEPOINT",
 /* 285 */ "savepoint_opt ::=",
 /* 286 */ "cmd ::= create_table create_table_args",
 /* 287 */ "columnlist ::= columnlist COMMA columnname carglist",
 /* 288 */ "columnlist ::= columnname carglist",
 /* 289 */ "nm ::= ID|INDEXED",
 /* 290 */ "nm ::= STRING",
 /* 291 */ "nm ::= JOIN_KW",
 /* 292 */ "typetoken ::= typename",
 /* 293 */ "typename ::= ID|STRING",
 /* 294 */ "signed ::= plus_num",
 /* 295 */ "signed ::= minus_num",
 /* 296 */ "carglist ::= carglist ccons",
 /* 297 */ "carglist ::=",
 /* 298 */ "ccons ::= NULL onconf",
 /* 299 */ "conslist_opt ::= COMMA conslist",
 /* 300 */ "conslist ::= conslist tconscomma tcons",
 /* 301 */ "conslist ::= tcons",
 /* 302 */ "tconscomma ::=",
 /* 303 */ "defer_subclause_opt ::= defer_subclause",
 /* 304 */ "resolvetype ::= raisetype",
 /* 305 */ "selectnowith ::= oneselect",
 /* 306 */ "oneselect ::= values",
 /* 307 */ "sclp ::= selcollist COMMA",
 /* 308 */ "as ::= ID|STRING",
 /* 309 */ "expr ::= term",
 /* 310 */ "likeop ::= LIKE_KW|MATCH",
 /* 311 */ "exprlist ::= nexprlist",
 /* 312 */ "nmnum ::= plus_num",
 /* 313 */ "nmnum ::= nm",
 /* 314 */ "nmnum ::= ON",
 /* 315 */ "nmnum ::= DELETE",
 /* 316 */ "nmnum ::= DEFAULT",
 /* 317 */ "plus_num ::= INTEGER|FLOAT",
 /* 318 */ "foreach_clause ::=",
 /* 319 */ "foreach_clause ::= FOR EACH ROW",
 /* 320 */ "trnm ::= nm",
 /* 321 */ "tridxby ::=",
 /* 322 */ "database_kw_opt ::= DATABASE",
 /* 323 */ "database_kw_opt ::=",
 /* 324 */ "kwcolumn_opt ::=",
 /* 325 */ "kwcolumn_opt ::= COLUMNKW",
 /* 326 */ "vtabarglist ::= vtabarg",
 /* 327 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
 /* 328 */ "vtabarg ::= vtabarg vtabargtoken",
 /* 329 */ "anylist ::=",
 /* 330 */ "anylist ::= anylist LP anylist RP",
 /* 331 */ "anylist ::= anylist ANY",
 /* 332 */ "with ::=",
};
#endif /* NDEBUG */


#if YYSTACKDEPTH<=0
/*
** Try to increase the size of the parser stack.  Return the number
141117
141118
141119
141120
141121
141122
141123
141124
141125
141126
141127
141128
141129
141130
141131
141132
141133
141134
141135
141136
141137
141138
141139
141140
141141
141142
141143
141144
141145
141146
141147
141148
141149
141150
141151
141152
141153
141154
141155
141156
141157
141158
141159
141160
141161
141162
141163
141164
141165
141166
141167
141168
141169
141170
141171
141172
141173
141174
141175
141176
141177
141178
141179
141180
141181
141182
}
      break;
    case 173: /* term */
    case 174: /* expr */
    case 202: /* where_opt */
    case 204: /* having_opt */
    case 216: /* on_opt */
    case 226: /* case_operand */
    case 228: /* case_else */
    case 237: /* when_clause */
    case 242: /* key_opt */
{
sqlite3ExprDelete(pParse->db, (yypminor->yy314));
}
      break;
    case 178: /* eidlist_opt */
    case 187: /* sortlist */
    case 188: /* eidlist */
    case 200: /* selcollist */
    case 203: /* groupby_opt */
    case 205: /* orderby_opt */
    case 208: /* nexprlist */
    case 209: /* exprlist */
    case 210: /* sclp */
    case 219: /* setlist */
    case 225: /* paren_exprlist */
    case 227: /* case_exprlist */
{
sqlite3ExprListDelete(pParse->db, (yypminor->yy322));
}
      break;
    case 194: /* fullname */
    case 201: /* from */
    case 212: /* seltablist */
    case 213: /* stl_prefix */
{
sqlite3SrcListDelete(pParse->db, (yypminor->yy259));
}
      break;
    case 197: /* with */
    case 251: /* wqlist */
{
sqlite3WithDelete(pParse->db, (yypminor->yy451));
}
      break;
    case 217: /* using_opt */
    case 218: /* idlist */
    case 221: /* idlist_opt */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy384));
}
      break;
    case 233: /* trigger_cmd_list */
    case 238: /* trigger_cmd */
{
sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy203));
}
      break;
    case 235: /* trigger_event */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy90).b);
}
      break;
/********* End destructor definitions *****************************************/
    default:  break;   /* If no destructor action specified: do nothing */
  }







|
|
|
|













|
|
|












|
<






|




|
|




|







141493
141494
141495
141496
141497
141498
141499
141500
141501
141502
141503
141504
141505
141506
141507
141508
141509
141510
141511
141512
141513
141514
141515
141516
141517
141518
141519
141520
141521
141522
141523
141524
141525
141526
141527
141528
141529
141530
141531
141532

141533
141534
141535
141536
141537
141538
141539
141540
141541
141542
141543
141544
141545
141546
141547
141548
141549
141550
141551
141552
141553
141554
141555
141556
141557
}
      break;
    case 173: /* term */
    case 174: /* expr */
    case 202: /* where_opt */
    case 204: /* having_opt */
    case 216: /* on_opt */
    case 227: /* case_operand */
    case 229: /* case_else */
    case 238: /* when_clause */
    case 243: /* key_opt */
{
sqlite3ExprDelete(pParse->db, (yypminor->yy314));
}
      break;
    case 178: /* eidlist_opt */
    case 187: /* sortlist */
    case 188: /* eidlist */
    case 200: /* selcollist */
    case 203: /* groupby_opt */
    case 205: /* orderby_opt */
    case 208: /* nexprlist */
    case 209: /* exprlist */
    case 210: /* sclp */
    case 220: /* setlist */
    case 226: /* paren_exprlist */
    case 228: /* case_exprlist */
{
sqlite3ExprListDelete(pParse->db, (yypminor->yy322));
}
      break;
    case 194: /* fullname */
    case 201: /* from */
    case 212: /* seltablist */
    case 213: /* stl_prefix */
{
sqlite3SrcListDelete(pParse->db, (yypminor->yy259));
}
      break;
    case 197: /* wqlist */

{
sqlite3WithDelete(pParse->db, (yypminor->yy451));
}
      break;
    case 217: /* using_opt */
    case 218: /* idlist */
    case 222: /* idlist_opt */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy384));
}
      break;
    case 234: /* trigger_cmd_list */
    case 239: /* trigger_cmd */
{
sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy203));
}
      break;
    case 236: /* trigger_event */
{
sqlite3IdListDelete(pParse->db, (yypminor->yy90).b);
}
      break;
/********* End destructor definitions *****************************************/
    default:  break;   /* If no destructor action specified: do nothing */
  }
141547
141548
141549
141550
141551
141552
141553
141554


141555
141556
141557
141558
141559
141560
141561
141562
141563
141564
141565
141566
141567
141568
141569
141570
141571
141572
141573
141574
141575
141576
141577
141578
141579
141580
141581

141582
141583
141584
141585
141586
141587
141588
141589
141590
141591
141592
141593
141594
141595
141596
141597
141598
141599
141600
141601
141602
141603
141604
141605
141606
141607
141608
141609
141610
141611
141612
141613
141614
141615
141616
141617
141618
141619
141620
141621
141622
141623
141624
141625
141626
141627
141628
141629
141630
141631
141632
141633
141634
141635
141636
141637
141638
141639
141640
141641
141642
141643
141644
141645
141646
141647
141648
141649
141650
141651
141652
141653
141654
141655
141656
141657
141658
141659
141660
141661
141662
141663



141664
141665
141666
141667
141668
141669
141670
141671
141672
141673
141674
141675
141676
141677
141678
141679
141680
141681
141682
141683
141684
141685
141686
141687
141688
141689
141690
141691
141692
141693
141694
141695
141696
141697
141698
141699
141700
141701
141702
141703
141704
141705
141706
141707
141708
141709
141710
141711
141712
141713
141714
141715
141716
141717
141718
141719
141720
141721
141722
141723
141724
141725
141726
141727
141728
141729
141730
141731
141732
141733
141734
141735
141736
141737
141738
141739
141740
141741
141742
141743
141744
141745
141746
141747
141748
141749
141750
141751
141752
141753
141754
141755
141756
141757
141758
141759
141760
141761
141762
141763
141764
141765
141766
141767
141768
141769
141770
141771
141772
141773
141774
141775
141776
141777
141778
141779
141780
141781
141782
141783
141784
141785
141786
141787
141788
141789
141790
141791
141792
141793
141794
141795
141796
141797
141798
141799
141800
141801
141802
141803

141804
141805
141806
141807
141808
141809
141810
  {  191,   -1 }, /* (73) resolvetype ::= REPLACE */
  {  149,   -4 }, /* (74) cmd ::= DROP TABLE ifexists fullname */
  {  193,   -2 }, /* (75) ifexists ::= IF EXISTS */
  {  193,    0 }, /* (76) ifexists ::= */
  {  149,   -9 }, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
  {  149,   -4 }, /* (78) cmd ::= DROP VIEW ifexists fullname */
  {  149,   -1 }, /* (79) cmd ::= select */
  {  163,   -2 }, /* (80) select ::= with selectnowith */


  {  195,   -3 }, /* (81) selectnowith ::= selectnowith multiselect_op oneselect */
  {  198,   -1 }, /* (82) multiselect_op ::= UNION */
  {  198,   -2 }, /* (83) multiselect_op ::= UNION ALL */
  {  198,   -1 }, /* (84) multiselect_op ::= EXCEPT|INTERSECT */
  {  196,   -9 }, /* (85) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
  {  207,   -4 }, /* (86) values ::= VALUES LP nexprlist RP */
  {  207,   -5 }, /* (87) values ::= values COMMA LP exprlist RP */
  {  199,   -1 }, /* (88) distinct ::= DISTINCT */
  {  199,   -1 }, /* (89) distinct ::= ALL */
  {  199,    0 }, /* (90) distinct ::= */
  {  210,    0 }, /* (91) sclp ::= */
  {  200,   -5 }, /* (92) selcollist ::= sclp scanpt expr scanpt as */
  {  200,   -3 }, /* (93) selcollist ::= sclp scanpt STAR */
  {  200,   -5 }, /* (94) selcollist ::= sclp scanpt nm DOT STAR */
  {  211,   -2 }, /* (95) as ::= AS nm */
  {  211,    0 }, /* (96) as ::= */
  {  201,    0 }, /* (97) from ::= */
  {  201,   -2 }, /* (98) from ::= FROM seltablist */
  {  213,   -2 }, /* (99) stl_prefix ::= seltablist joinop */
  {  213,    0 }, /* (100) stl_prefix ::= */
  {  212,   -7 }, /* (101) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
  {  212,   -9 }, /* (102) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
  {  212,   -7 }, /* (103) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
  {  212,   -7 }, /* (104) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
  {  159,    0 }, /* (105) dbnm ::= */
  {  159,   -2 }, /* (106) dbnm ::= DOT nm */
  {  194,   -2 }, /* (107) fullname ::= nm dbnm */

  {  214,   -1 }, /* (108) joinop ::= COMMA|JOIN */
  {  214,   -2 }, /* (109) joinop ::= JOIN_KW JOIN */
  {  214,   -3 }, /* (110) joinop ::= JOIN_KW nm JOIN */
  {  214,   -4 }, /* (111) joinop ::= JOIN_KW nm nm JOIN */
  {  216,   -2 }, /* (112) on_opt ::= ON expr */
  {  216,    0 }, /* (113) on_opt ::= */
  {  215,    0 }, /* (114) indexed_opt ::= */
  {  215,   -3 }, /* (115) indexed_opt ::= INDEXED BY nm */
  {  215,   -2 }, /* (116) indexed_opt ::= NOT INDEXED */
  {  217,   -4 }, /* (117) using_opt ::= USING LP idlist RP */
  {  217,    0 }, /* (118) using_opt ::= */
  {  205,    0 }, /* (119) orderby_opt ::= */
  {  205,   -3 }, /* (120) orderby_opt ::= ORDER BY sortlist */
  {  187,   -4 }, /* (121) sortlist ::= sortlist COMMA expr sortorder */
  {  187,   -2 }, /* (122) sortlist ::= expr sortorder */
  {  176,   -1 }, /* (123) sortorder ::= ASC */
  {  176,   -1 }, /* (124) sortorder ::= DESC */
  {  176,    0 }, /* (125) sortorder ::= */
  {  203,    0 }, /* (126) groupby_opt ::= */
  {  203,   -3 }, /* (127) groupby_opt ::= GROUP BY nexprlist */
  {  204,    0 }, /* (128) having_opt ::= */
  {  204,   -2 }, /* (129) having_opt ::= HAVING expr */
  {  206,    0 }, /* (130) limit_opt ::= */
  {  206,   -2 }, /* (131) limit_opt ::= LIMIT expr */
  {  206,   -4 }, /* (132) limit_opt ::= LIMIT expr OFFSET expr */
  {  206,   -4 }, /* (133) limit_opt ::= LIMIT expr COMMA expr */
  {  149,   -6 }, /* (134) cmd ::= with DELETE FROM fullname indexed_opt where_opt */
  {  202,    0 }, /* (135) where_opt ::= */
  {  202,   -2 }, /* (136) where_opt ::= WHERE expr */
  {  149,   -8 }, /* (137) cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
  {  219,   -5 }, /* (138) setlist ::= setlist COMMA nm EQ expr */
  {  219,   -7 }, /* (139) setlist ::= setlist COMMA LP idlist RP EQ expr */
  {  219,   -3 }, /* (140) setlist ::= nm EQ expr */
  {  219,   -5 }, /* (141) setlist ::= LP idlist RP EQ expr */
  {  149,   -6 }, /* (142) cmd ::= with insert_cmd INTO fullname idlist_opt select */
  {  149,   -7 }, /* (143) cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
  {  220,   -2 }, /* (144) insert_cmd ::= INSERT orconf */
  {  220,   -1 }, /* (145) insert_cmd ::= REPLACE */
  {  221,    0 }, /* (146) idlist_opt ::= */
  {  221,   -3 }, /* (147) idlist_opt ::= LP idlist RP */
  {  218,   -3 }, /* (148) idlist ::= idlist COMMA nm */
  {  218,   -1 }, /* (149) idlist ::= nm */
  {  174,   -3 }, /* (150) expr ::= LP expr RP */
  {  174,   -1 }, /* (151) expr ::= ID|INDEXED */
  {  174,   -1 }, /* (152) expr ::= JOIN_KW */
  {  174,   -3 }, /* (153) expr ::= nm DOT nm */
  {  174,   -5 }, /* (154) expr ::= nm DOT nm DOT nm */
  {  173,   -1 }, /* (155) term ::= NULL|FLOAT|BLOB */
  {  173,   -1 }, /* (156) term ::= STRING */
  {  173,   -1 }, /* (157) term ::= INTEGER */
  {  174,   -1 }, /* (158) expr ::= VARIABLE */
  {  174,   -3 }, /* (159) expr ::= expr COLLATE ID|STRING */
  {  174,   -6 }, /* (160) expr ::= CAST LP expr AS typetoken RP */
  {  174,   -5 }, /* (161) expr ::= ID|INDEXED LP distinct exprlist RP */
  {  174,   -4 }, /* (162) expr ::= ID|INDEXED LP STAR RP */
  {  173,   -1 }, /* (163) term ::= CTIME_KW */
  {  174,   -5 }, /* (164) expr ::= LP nexprlist COMMA expr RP */
  {  174,   -3 }, /* (165) expr ::= expr AND expr */
  {  174,   -3 }, /* (166) expr ::= expr OR expr */
  {  174,   -3 }, /* (167) expr ::= expr LT|GT|GE|LE expr */
  {  174,   -3 }, /* (168) expr ::= expr EQ|NE expr */
  {  174,   -3 }, /* (169) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
  {  174,   -3 }, /* (170) expr ::= expr PLUS|MINUS expr */
  {  174,   -3 }, /* (171) expr ::= expr STAR|SLASH|REM expr */
  {  174,   -3 }, /* (172) expr ::= expr CONCAT expr */
  {  222,   -2 }, /* (173) likeop ::= NOT LIKE_KW|MATCH */
  {  174,   -3 }, /* (174) expr ::= expr likeop expr */
  {  174,   -5 }, /* (175) expr ::= expr likeop expr ESCAPE expr */
  {  174,   -2 }, /* (176) expr ::= expr ISNULL|NOTNULL */
  {  174,   -3 }, /* (177) expr ::= expr NOT NULL */
  {  174,   -3 }, /* (178) expr ::= expr IS expr */
  {  174,   -4 }, /* (179) expr ::= expr IS NOT expr */
  {  174,   -2 }, /* (180) expr ::= NOT expr */
  {  174,   -2 }, /* (181) expr ::= BITNOT expr */
  {  174,   -2 }, /* (182) expr ::= MINUS expr */
  {  174,   -2 }, /* (183) expr ::= PLUS expr */
  {  223,   -1 }, /* (184) between_op ::= BETWEEN */
  {  223,   -2 }, /* (185) between_op ::= NOT BETWEEN */
  {  174,   -5 }, /* (186) expr ::= expr between_op expr AND expr */
  {  224,   -1 }, /* (187) in_op ::= IN */
  {  224,   -2 }, /* (188) in_op ::= NOT IN */
  {  174,   -5 }, /* (189) expr ::= expr in_op LP exprlist RP */



  {  174,   -3 }, /* (190) expr ::= LP select RP */
  {  174,   -5 }, /* (191) expr ::= expr in_op LP select RP */
  {  174,   -5 }, /* (192) expr ::= expr in_op nm dbnm paren_exprlist */
  {  174,   -4 }, /* (193) expr ::= EXISTS LP select RP */
  {  174,   -5 }, /* (194) expr ::= CASE case_operand case_exprlist case_else END */
  {  227,   -5 }, /* (195) case_exprlist ::= case_exprlist WHEN expr THEN expr */
  {  227,   -4 }, /* (196) case_exprlist ::= WHEN expr THEN expr */
  {  228,   -2 }, /* (197) case_else ::= ELSE expr */
  {  228,    0 }, /* (198) case_else ::= */
  {  226,   -1 }, /* (199) case_operand ::= expr */
  {  226,    0 }, /* (200) case_operand ::= */
  {  209,    0 }, /* (201) exprlist ::= */
  {  208,   -3 }, /* (202) nexprlist ::= nexprlist COMMA expr */
  {  208,   -1 }, /* (203) nexprlist ::= expr */
  {  225,    0 }, /* (204) paren_exprlist ::= */
  {  225,   -3 }, /* (205) paren_exprlist ::= LP exprlist RP */
  {  149,  -12 }, /* (206) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
  {  229,   -1 }, /* (207) uniqueflag ::= UNIQUE */
  {  229,    0 }, /* (208) uniqueflag ::= */
  {  178,    0 }, /* (209) eidlist_opt ::= */
  {  178,   -3 }, /* (210) eidlist_opt ::= LP eidlist RP */
  {  188,   -5 }, /* (211) eidlist ::= eidlist COMMA nm collate sortorder */
  {  188,   -3 }, /* (212) eidlist ::= nm collate sortorder */
  {  230,    0 }, /* (213) collate ::= */
  {  230,   -2 }, /* (214) collate ::= COLLATE ID|STRING */
  {  149,   -4 }, /* (215) cmd ::= DROP INDEX ifexists fullname */
  {  149,   -1 }, /* (216) cmd ::= VACUUM */
  {  149,   -2 }, /* (217) cmd ::= VACUUM nm */
  {  149,   -3 }, /* (218) cmd ::= PRAGMA nm dbnm */
  {  149,   -5 }, /* (219) cmd ::= PRAGMA nm dbnm EQ nmnum */
  {  149,   -6 }, /* (220) cmd ::= PRAGMA nm dbnm LP nmnum RP */
  {  149,   -5 }, /* (221) cmd ::= PRAGMA nm dbnm EQ minus_num */
  {  149,   -6 }, /* (222) cmd ::= PRAGMA nm dbnm LP minus_num RP */
  {  169,   -2 }, /* (223) plus_num ::= PLUS INTEGER|FLOAT */
  {  170,   -2 }, /* (224) minus_num ::= MINUS INTEGER|FLOAT */
  {  149,   -5 }, /* (225) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
  {  232,  -11 }, /* (226) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
  {  234,   -1 }, /* (227) trigger_time ::= BEFORE|AFTER */
  {  234,   -2 }, /* (228) trigger_time ::= INSTEAD OF */
  {  234,    0 }, /* (229) trigger_time ::= */
  {  235,   -1 }, /* (230) trigger_event ::= DELETE|INSERT */
  {  235,   -1 }, /* (231) trigger_event ::= UPDATE */
  {  235,   -3 }, /* (232) trigger_event ::= UPDATE OF idlist */
  {  237,    0 }, /* (233) when_clause ::= */
  {  237,   -2 }, /* (234) when_clause ::= WHEN expr */
  {  233,   -3 }, /* (235) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
  {  233,   -2 }, /* (236) trigger_cmd_list ::= trigger_cmd SEMI */
  {  239,   -3 }, /* (237) trnm ::= nm DOT nm */
  {  240,   -3 }, /* (238) tridxby ::= INDEXED BY nm */
  {  240,   -2 }, /* (239) tridxby ::= NOT INDEXED */
  {  238,   -8 }, /* (240) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
  {  238,   -7 }, /* (241) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select scanpt */
  {  238,   -6 }, /* (242) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
  {  238,   -3 }, /* (243) trigger_cmd ::= scanpt select scanpt */
  {  174,   -4 }, /* (244) expr ::= RAISE LP IGNORE RP */
  {  174,   -6 }, /* (245) expr ::= RAISE LP raisetype COMMA nm RP */
  {  192,   -1 }, /* (246) raisetype ::= ROLLBACK */
  {  192,   -1 }, /* (247) raisetype ::= ABORT */
  {  192,   -1 }, /* (248) raisetype ::= FAIL */
  {  149,   -4 }, /* (249) cmd ::= DROP TRIGGER ifexists fullname */
  {  149,   -6 }, /* (250) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
  {  149,   -3 }, /* (251) cmd ::= DETACH database_kw_opt expr */
  {  242,    0 }, /* (252) key_opt ::= */
  {  242,   -2 }, /* (253) key_opt ::= KEY expr */
  {  149,   -1 }, /* (254) cmd ::= REINDEX */
  {  149,   -3 }, /* (255) cmd ::= REINDEX nm dbnm */
  {  149,   -1 }, /* (256) cmd ::= ANALYZE */
  {  149,   -3 }, /* (257) cmd ::= ANALYZE nm dbnm */
  {  149,   -6 }, /* (258) cmd ::= ALTER TABLE fullname RENAME TO nm */
  {  149,   -7 }, /* (259) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
  {  243,   -1 }, /* (260) add_column_fullname ::= fullname */
  {  149,   -1 }, /* (261) cmd ::= create_vtab */
  {  149,   -4 }, /* (262) cmd ::= create_vtab LP vtabarglist RP */
  {  245,   -8 }, /* (263) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
  {  247,    0 }, /* (264) vtabarg ::= */
  {  248,   -1 }, /* (265) vtabargtoken ::= ANY */
  {  248,   -3 }, /* (266) vtabargtoken ::= lp anylist RP */
  {  249,   -1 }, /* (267) lp ::= LP */
  {  197,    0 }, /* (268) with ::= */
  {  197,   -2 }, /* (269) with ::= WITH wqlist */
  {  197,   -3 }, /* (270) with ::= WITH RECURSIVE wqlist */
  {  251,   -6 }, /* (271) wqlist ::= nm eidlist_opt AS LP select RP */
  {  251,   -8 }, /* (272) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
  {  144,   -1 }, /* (273) input ::= cmdlist */
  {  145,   -2 }, /* (274) cmdlist ::= cmdlist ecmd */
  {  145,   -1 }, /* (275) cmdlist ::= ecmd */
  {  146,   -1 }, /* (276) ecmd ::= SEMI */
  {  146,   -3 }, /* (277) ecmd ::= explain cmdx SEMI */
  {  147,    0 }, /* (278) explain ::= */
  {  151,    0 }, /* (279) trans_opt ::= */
  {  151,   -1 }, /* (280) trans_opt ::= TRANSACTION */
  {  151,   -2 }, /* (281) trans_opt ::= TRANSACTION nm */
  {  153,   -1 }, /* (282) savepoint_opt ::= SAVEPOINT */
  {  153,    0 }, /* (283) savepoint_opt ::= */
  {  149,   -2 }, /* (284) cmd ::= create_table create_table_args */
  {  160,   -4 }, /* (285) columnlist ::= columnlist COMMA columnname carglist */
  {  160,   -2 }, /* (286) columnlist ::= columnname carglist */
  {  152,   -1 }, /* (287) nm ::= ID|INDEXED */
  {  152,   -1 }, /* (288) nm ::= STRING */
  {  152,   -1 }, /* (289) nm ::= JOIN_KW */
  {  166,   -1 }, /* (290) typetoken ::= typename */
  {  167,   -1 }, /* (291) typename ::= ID|STRING */
  {  168,   -1 }, /* (292) signed ::= plus_num */
  {  168,   -1 }, /* (293) signed ::= minus_num */
  {  165,   -2 }, /* (294) carglist ::= carglist ccons */
  {  165,    0 }, /* (295) carglist ::= */
  {  172,   -2 }, /* (296) ccons ::= NULL onconf */
  {  161,   -2 }, /* (297) conslist_opt ::= COMMA conslist */
  {  184,   -3 }, /* (298) conslist ::= conslist tconscomma tcons */
  {  184,   -1 }, /* (299) conslist ::= tcons */
  {  185,    0 }, /* (300) tconscomma ::= */
  {  189,   -1 }, /* (301) defer_subclause_opt ::= defer_subclause */
  {  191,   -1 }, /* (302) resolvetype ::= raisetype */
  {  195,   -1 }, /* (303) selectnowith ::= oneselect */
  {  196,   -1 }, /* (304) oneselect ::= values */
  {  210,   -2 }, /* (305) sclp ::= selcollist COMMA */
  {  211,   -1 }, /* (306) as ::= ID|STRING */
  {  174,   -1 }, /* (307) expr ::= term */
  {  222,   -1 }, /* (308) likeop ::= LIKE_KW|MATCH */
  {  209,   -1 }, /* (309) exprlist ::= nexprlist */
  {  231,   -1 }, /* (310) nmnum ::= plus_num */
  {  231,   -1 }, /* (311) nmnum ::= nm */
  {  231,   -1 }, /* (312) nmnum ::= ON */
  {  231,   -1 }, /* (313) nmnum ::= DELETE */
  {  231,   -1 }, /* (314) nmnum ::= DEFAULT */
  {  169,   -1 }, /* (315) plus_num ::= INTEGER|FLOAT */
  {  236,    0 }, /* (316) foreach_clause ::= */
  {  236,   -3 }, /* (317) foreach_clause ::= FOR EACH ROW */
  {  239,   -1 }, /* (318) trnm ::= nm */
  {  240,    0 }, /* (319) tridxby ::= */
  {  241,   -1 }, /* (320) database_kw_opt ::= DATABASE */
  {  241,    0 }, /* (321) database_kw_opt ::= */
  {  244,    0 }, /* (322) kwcolumn_opt ::= */
  {  244,   -1 }, /* (323) kwcolumn_opt ::= COLUMNKW */
  {  246,   -1 }, /* (324) vtabarglist ::= vtabarg */
  {  246,   -3 }, /* (325) vtabarglist ::= vtabarglist COMMA vtabarg */
  {  247,   -2 }, /* (326) vtabarg ::= vtabarg vtabargtoken */
  {  250,    0 }, /* (327) anylist ::= */
  {  250,   -4 }, /* (328) anylist ::= anylist LP anylist RP */
  {  250,   -2 }, /* (329) anylist ::= anylist ANY */

};

static void yy_accept(yyParser*);  /* Forward Declaration */

/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.







|
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>







141922
141923
141924
141925
141926
141927
141928
141929
141930
141931
141932
141933
141934
141935
141936
141937
141938
141939
141940
141941
141942
141943
141944
141945
141946
141947
141948
141949
141950
141951
141952
141953
141954
141955
141956
141957
141958
141959
141960
141961
141962
141963
141964
141965
141966
141967
141968
141969
141970
141971
141972
141973
141974
141975
141976
141977
141978
141979
141980
141981
141982
141983
141984
141985
141986
141987
141988
141989
141990
141991
141992
141993
141994
141995
141996
141997
141998
141999
142000
142001
142002
142003
142004
142005
142006
142007
142008
142009
142010
142011
142012
142013
142014
142015
142016



142017
142018
142019
142020
142021
142022
142023
142024
142025
142026
142027
142028
142029
142030
142031
142032
142033
142034
142035
142036
142037
142038
142039
142040
142041
142042
142043
142044
142045
142046
142047
142048
142049
142050
142051
142052
142053
142054
142055
142056
142057
142058
142059
142060
142061
142062
142063
142064
142065
142066
142067
142068
142069
142070
142071
142072
142073
142074
142075
142076
142077
142078
142079
142080
142081
142082
142083
142084
142085
142086
142087
142088
142089
142090
142091
142092
142093
142094
142095
142096
142097
142098
142099
142100
142101
142102
142103
142104
142105
142106
142107
142108
142109
142110
142111
142112
142113
142114
142115
142116
142117
142118
142119

142120
142121
142122
142123
142124
142125
142126
142127
142128
142129
142130
142131
142132
142133
142134
142135
142136
142137
142138
142139
142140
142141
142142
142143
142144
142145
142146
142147
142148
142149
142150
142151
142152
142153
142154
142155
142156
142157
142158
142159
142160
142161
142162
142163
142164
142165
142166
142167
142168
142169
142170
142171
142172
142173
142174
142175
142176
142177
142178
142179
142180
142181
142182
142183
142184
142185
142186
142187
142188
  {  191,   -1 }, /* (73) resolvetype ::= REPLACE */
  {  149,   -4 }, /* (74) cmd ::= DROP TABLE ifexists fullname */
  {  193,   -2 }, /* (75) ifexists ::= IF EXISTS */
  {  193,    0 }, /* (76) ifexists ::= */
  {  149,   -9 }, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
  {  149,   -4 }, /* (78) cmd ::= DROP VIEW ifexists fullname */
  {  149,   -1 }, /* (79) cmd ::= select */
  {  163,   -3 }, /* (80) select ::= WITH wqlist selectnowith */
  {  163,   -4 }, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
  {  163,   -1 }, /* (82) select ::= selectnowith */
  {  195,   -3 }, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
  {  198,   -1 }, /* (84) multiselect_op ::= UNION */
  {  198,   -2 }, /* (85) multiselect_op ::= UNION ALL */
  {  198,   -1 }, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
  {  196,   -9 }, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
  {  207,   -4 }, /* (88) values ::= VALUES LP nexprlist RP */
  {  207,   -5 }, /* (89) values ::= values COMMA LP exprlist RP */
  {  199,   -1 }, /* (90) distinct ::= DISTINCT */
  {  199,   -1 }, /* (91) distinct ::= ALL */
  {  199,    0 }, /* (92) distinct ::= */
  {  210,    0 }, /* (93) sclp ::= */
  {  200,   -5 }, /* (94) selcollist ::= sclp scanpt expr scanpt as */
  {  200,   -3 }, /* (95) selcollist ::= sclp scanpt STAR */
  {  200,   -5 }, /* (96) selcollist ::= sclp scanpt nm DOT STAR */
  {  211,   -2 }, /* (97) as ::= AS nm */
  {  211,    0 }, /* (98) as ::= */
  {  201,    0 }, /* (99) from ::= */
  {  201,   -2 }, /* (100) from ::= FROM seltablist */
  {  213,   -2 }, /* (101) stl_prefix ::= seltablist joinop */
  {  213,    0 }, /* (102) stl_prefix ::= */
  {  212,   -7 }, /* (103) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
  {  212,   -9 }, /* (104) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
  {  212,   -7 }, /* (105) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
  {  212,   -7 }, /* (106) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
  {  159,    0 }, /* (107) dbnm ::= */
  {  159,   -2 }, /* (108) dbnm ::= DOT nm */
  {  194,   -1 }, /* (109) fullname ::= nm */
  {  194,   -3 }, /* (110) fullname ::= nm DOT nm */
  {  214,   -1 }, /* (111) joinop ::= COMMA|JOIN */
  {  214,   -2 }, /* (112) joinop ::= JOIN_KW JOIN */
  {  214,   -3 }, /* (113) joinop ::= JOIN_KW nm JOIN */
  {  214,   -4 }, /* (114) joinop ::= JOIN_KW nm nm JOIN */
  {  216,   -2 }, /* (115) on_opt ::= ON expr */
  {  216,    0 }, /* (116) on_opt ::= */
  {  215,    0 }, /* (117) indexed_opt ::= */
  {  215,   -3 }, /* (118) indexed_opt ::= INDEXED BY nm */
  {  215,   -2 }, /* (119) indexed_opt ::= NOT INDEXED */
  {  217,   -4 }, /* (120) using_opt ::= USING LP idlist RP */
  {  217,    0 }, /* (121) using_opt ::= */
  {  205,    0 }, /* (122) orderby_opt ::= */
  {  205,   -3 }, /* (123) orderby_opt ::= ORDER BY sortlist */
  {  187,   -4 }, /* (124) sortlist ::= sortlist COMMA expr sortorder */
  {  187,   -2 }, /* (125) sortlist ::= expr sortorder */
  {  176,   -1 }, /* (126) sortorder ::= ASC */
  {  176,   -1 }, /* (127) sortorder ::= DESC */
  {  176,    0 }, /* (128) sortorder ::= */
  {  203,    0 }, /* (129) groupby_opt ::= */
  {  203,   -3 }, /* (130) groupby_opt ::= GROUP BY nexprlist */
  {  204,    0 }, /* (131) having_opt ::= */
  {  204,   -2 }, /* (132) having_opt ::= HAVING expr */
  {  206,    0 }, /* (133) limit_opt ::= */
  {  206,   -2 }, /* (134) limit_opt ::= LIMIT expr */
  {  206,   -4 }, /* (135) limit_opt ::= LIMIT expr OFFSET expr */
  {  206,   -4 }, /* (136) limit_opt ::= LIMIT expr COMMA expr */
  {  149,   -6 }, /* (137) cmd ::= with DELETE FROM fullname indexed_opt where_opt */
  {  202,    0 }, /* (138) where_opt ::= */
  {  202,   -2 }, /* (139) where_opt ::= WHERE expr */
  {  149,   -8 }, /* (140) cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
  {  220,   -5 }, /* (141) setlist ::= setlist COMMA nm EQ expr */
  {  220,   -7 }, /* (142) setlist ::= setlist COMMA LP idlist RP EQ expr */
  {  220,   -3 }, /* (143) setlist ::= nm EQ expr */
  {  220,   -5 }, /* (144) setlist ::= LP idlist RP EQ expr */
  {  149,   -6 }, /* (145) cmd ::= with insert_cmd INTO fullname idlist_opt select */
  {  149,   -7 }, /* (146) cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
  {  221,   -2 }, /* (147) insert_cmd ::= INSERT orconf */
  {  221,   -1 }, /* (148) insert_cmd ::= REPLACE */
  {  222,    0 }, /* (149) idlist_opt ::= */
  {  222,   -3 }, /* (150) idlist_opt ::= LP idlist RP */
  {  218,   -3 }, /* (151) idlist ::= idlist COMMA nm */
  {  218,   -1 }, /* (152) idlist ::= nm */
  {  174,   -3 }, /* (153) expr ::= LP expr RP */
  {  174,   -1 }, /* (154) expr ::= ID|INDEXED */
  {  174,   -1 }, /* (155) expr ::= JOIN_KW */
  {  174,   -3 }, /* (156) expr ::= nm DOT nm */
  {  174,   -5 }, /* (157) expr ::= nm DOT nm DOT nm */
  {  173,   -1 }, /* (158) term ::= NULL|FLOAT|BLOB */
  {  173,   -1 }, /* (159) term ::= STRING */
  {  173,   -1 }, /* (160) term ::= INTEGER */
  {  174,   -1 }, /* (161) expr ::= VARIABLE */
  {  174,   -3 }, /* (162) expr ::= expr COLLATE ID|STRING */
  {  174,   -6 }, /* (163) expr ::= CAST LP expr AS typetoken RP */
  {  174,   -5 }, /* (164) expr ::= ID|INDEXED LP distinct exprlist RP */
  {  174,   -4 }, /* (165) expr ::= ID|INDEXED LP STAR RP */
  {  173,   -1 }, /* (166) term ::= CTIME_KW */
  {  174,   -5 }, /* (167) expr ::= LP nexprlist COMMA expr RP */



  {  174,   -3 }, /* (168) expr ::= expr AND expr */
  {  174,   -3 }, /* (169) expr ::= expr OR expr */
  {  174,   -3 }, /* (170) expr ::= expr LT|GT|GE|LE expr */
  {  174,   -3 }, /* (171) expr ::= expr EQ|NE expr */
  {  174,   -3 }, /* (172) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
  {  174,   -3 }, /* (173) expr ::= expr PLUS|MINUS expr */
  {  174,   -3 }, /* (174) expr ::= expr STAR|SLASH|REM expr */
  {  174,   -3 }, /* (175) expr ::= expr CONCAT expr */
  {  223,   -2 }, /* (176) likeop ::= NOT LIKE_KW|MATCH */
  {  174,   -3 }, /* (177) expr ::= expr likeop expr */
  {  174,   -5 }, /* (178) expr ::= expr likeop expr ESCAPE expr */
  {  174,   -2 }, /* (179) expr ::= expr ISNULL|NOTNULL */
  {  174,   -3 }, /* (180) expr ::= expr NOT NULL */
  {  174,   -3 }, /* (181) expr ::= expr IS expr */
  {  174,   -4 }, /* (182) expr ::= expr IS NOT expr */
  {  174,   -2 }, /* (183) expr ::= NOT expr */
  {  174,   -2 }, /* (184) expr ::= BITNOT expr */
  {  174,   -2 }, /* (185) expr ::= MINUS expr */
  {  174,   -2 }, /* (186) expr ::= PLUS expr */
  {  224,   -1 }, /* (187) between_op ::= BETWEEN */
  {  224,   -2 }, /* (188) between_op ::= NOT BETWEEN */
  {  174,   -5 }, /* (189) expr ::= expr between_op expr AND expr */
  {  225,   -1 }, /* (190) in_op ::= IN */
  {  225,   -2 }, /* (191) in_op ::= NOT IN */
  {  174,   -5 }, /* (192) expr ::= expr in_op LP exprlist RP */
  {  174,   -3 }, /* (193) expr ::= LP select RP */
  {  174,   -5 }, /* (194) expr ::= expr in_op LP select RP */
  {  174,   -5 }, /* (195) expr ::= expr in_op nm dbnm paren_exprlist */
  {  174,   -4 }, /* (196) expr ::= EXISTS LP select RP */
  {  174,   -5 }, /* (197) expr ::= CASE case_operand case_exprlist case_else END */
  {  228,   -5 }, /* (198) case_exprlist ::= case_exprlist WHEN expr THEN expr */
  {  228,   -4 }, /* (199) case_exprlist ::= WHEN expr THEN expr */
  {  229,   -2 }, /* (200) case_else ::= ELSE expr */
  {  229,    0 }, /* (201) case_else ::= */
  {  227,   -1 }, /* (202) case_operand ::= expr */
  {  227,    0 }, /* (203) case_operand ::= */
  {  209,    0 }, /* (204) exprlist ::= */
  {  208,   -3 }, /* (205) nexprlist ::= nexprlist COMMA expr */
  {  208,   -1 }, /* (206) nexprlist ::= expr */
  {  226,    0 }, /* (207) paren_exprlist ::= */
  {  226,   -3 }, /* (208) paren_exprlist ::= LP exprlist RP */
  {  149,  -12 }, /* (209) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
  {  230,   -1 }, /* (210) uniqueflag ::= UNIQUE */
  {  230,    0 }, /* (211) uniqueflag ::= */
  {  178,    0 }, /* (212) eidlist_opt ::= */
  {  178,   -3 }, /* (213) eidlist_opt ::= LP eidlist RP */
  {  188,   -5 }, /* (214) eidlist ::= eidlist COMMA nm collate sortorder */
  {  188,   -3 }, /* (215) eidlist ::= nm collate sortorder */
  {  231,    0 }, /* (216) collate ::= */
  {  231,   -2 }, /* (217) collate ::= COLLATE ID|STRING */
  {  149,   -4 }, /* (218) cmd ::= DROP INDEX ifexists fullname */
  {  149,   -1 }, /* (219) cmd ::= VACUUM */
  {  149,   -2 }, /* (220) cmd ::= VACUUM nm */
  {  149,   -3 }, /* (221) cmd ::= PRAGMA nm dbnm */
  {  149,   -5 }, /* (222) cmd ::= PRAGMA nm dbnm EQ nmnum */
  {  149,   -6 }, /* (223) cmd ::= PRAGMA nm dbnm LP nmnum RP */
  {  149,   -5 }, /* (224) cmd ::= PRAGMA nm dbnm EQ minus_num */
  {  149,   -6 }, /* (225) cmd ::= PRAGMA nm dbnm LP minus_num RP */
  {  169,   -2 }, /* (226) plus_num ::= PLUS INTEGER|FLOAT */
  {  170,   -2 }, /* (227) minus_num ::= MINUS INTEGER|FLOAT */
  {  149,   -5 }, /* (228) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
  {  233,  -11 }, /* (229) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
  {  235,   -1 }, /* (230) trigger_time ::= BEFORE|AFTER */
  {  235,   -2 }, /* (231) trigger_time ::= INSTEAD OF */
  {  235,    0 }, /* (232) trigger_time ::= */
  {  236,   -1 }, /* (233) trigger_event ::= DELETE|INSERT */
  {  236,   -1 }, /* (234) trigger_event ::= UPDATE */
  {  236,   -3 }, /* (235) trigger_event ::= UPDATE OF idlist */
  {  238,    0 }, /* (236) when_clause ::= */
  {  238,   -2 }, /* (237) when_clause ::= WHEN expr */
  {  234,   -3 }, /* (238) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
  {  234,   -2 }, /* (239) trigger_cmd_list ::= trigger_cmd SEMI */
  {  240,   -3 }, /* (240) trnm ::= nm DOT nm */
  {  241,   -3 }, /* (241) tridxby ::= INDEXED BY nm */
  {  241,   -2 }, /* (242) tridxby ::= NOT INDEXED */
  {  239,   -8 }, /* (243) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
  {  239,   -7 }, /* (244) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select scanpt */
  {  239,   -6 }, /* (245) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
  {  239,   -3 }, /* (246) trigger_cmd ::= scanpt select scanpt */
  {  174,   -4 }, /* (247) expr ::= RAISE LP IGNORE RP */
  {  174,   -6 }, /* (248) expr ::= RAISE LP raisetype COMMA nm RP */
  {  192,   -1 }, /* (249) raisetype ::= ROLLBACK */
  {  192,   -1 }, /* (250) raisetype ::= ABORT */
  {  192,   -1 }, /* (251) raisetype ::= FAIL */
  {  149,   -4 }, /* (252) cmd ::= DROP TRIGGER ifexists fullname */
  {  149,   -6 }, /* (253) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
  {  149,   -3 }, /* (254) cmd ::= DETACH database_kw_opt expr */
  {  243,    0 }, /* (255) key_opt ::= */
  {  243,   -2 }, /* (256) key_opt ::= KEY expr */
  {  149,   -1 }, /* (257) cmd ::= REINDEX */
  {  149,   -3 }, /* (258) cmd ::= REINDEX nm dbnm */
  {  149,   -1 }, /* (259) cmd ::= ANALYZE */
  {  149,   -3 }, /* (260) cmd ::= ANALYZE nm dbnm */
  {  149,   -6 }, /* (261) cmd ::= ALTER TABLE fullname RENAME TO nm */
  {  149,   -7 }, /* (262) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
  {  244,   -1 }, /* (263) add_column_fullname ::= fullname */
  {  149,   -1 }, /* (264) cmd ::= create_vtab */
  {  149,   -4 }, /* (265) cmd ::= create_vtab LP vtabarglist RP */
  {  246,   -8 }, /* (266) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
  {  248,    0 }, /* (267) vtabarg ::= */
  {  249,   -1 }, /* (268) vtabargtoken ::= ANY */
  {  249,   -3 }, /* (269) vtabargtoken ::= lp anylist RP */
  {  250,   -1 }, /* (270) lp ::= LP */

  {  219,   -2 }, /* (271) with ::= WITH wqlist */
  {  219,   -3 }, /* (272) with ::= WITH RECURSIVE wqlist */
  {  197,   -6 }, /* (273) wqlist ::= nm eidlist_opt AS LP select RP */
  {  197,   -8 }, /* (274) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
  {  144,   -1 }, /* (275) input ::= cmdlist */
  {  145,   -2 }, /* (276) cmdlist ::= cmdlist ecmd */
  {  145,   -1 }, /* (277) cmdlist ::= ecmd */
  {  146,   -1 }, /* (278) ecmd ::= SEMI */
  {  146,   -3 }, /* (279) ecmd ::= explain cmdx SEMI */
  {  147,    0 }, /* (280) explain ::= */
  {  151,    0 }, /* (281) trans_opt ::= */
  {  151,   -1 }, /* (282) trans_opt ::= TRANSACTION */
  {  151,   -2 }, /* (283) trans_opt ::= TRANSACTION nm */
  {  153,   -1 }, /* (284) savepoint_opt ::= SAVEPOINT */
  {  153,    0 }, /* (285) savepoint_opt ::= */
  {  149,   -2 }, /* (286) cmd ::= create_table create_table_args */
  {  160,   -4 }, /* (287) columnlist ::= columnlist COMMA columnname carglist */
  {  160,   -2 }, /* (288) columnlist ::= columnname carglist */
  {  152,   -1 }, /* (289) nm ::= ID|INDEXED */
  {  152,   -1 }, /* (290) nm ::= STRING */
  {  152,   -1 }, /* (291) nm ::= JOIN_KW */
  {  166,   -1 }, /* (292) typetoken ::= typename */
  {  167,   -1 }, /* (293) typename ::= ID|STRING */
  {  168,   -1 }, /* (294) signed ::= plus_num */
  {  168,   -1 }, /* (295) signed ::= minus_num */
  {  165,   -2 }, /* (296) carglist ::= carglist ccons */
  {  165,    0 }, /* (297) carglist ::= */
  {  172,   -2 }, /* (298) ccons ::= NULL onconf */
  {  161,   -2 }, /* (299) conslist_opt ::= COMMA conslist */
  {  184,   -3 }, /* (300) conslist ::= conslist tconscomma tcons */
  {  184,   -1 }, /* (301) conslist ::= tcons */
  {  185,    0 }, /* (302) tconscomma ::= */
  {  189,   -1 }, /* (303) defer_subclause_opt ::= defer_subclause */
  {  191,   -1 }, /* (304) resolvetype ::= raisetype */
  {  195,   -1 }, /* (305) selectnowith ::= oneselect */
  {  196,   -1 }, /* (306) oneselect ::= values */
  {  210,   -2 }, /* (307) sclp ::= selcollist COMMA */
  {  211,   -1 }, /* (308) as ::= ID|STRING */
  {  174,   -1 }, /* (309) expr ::= term */
  {  223,   -1 }, /* (310) likeop ::= LIKE_KW|MATCH */
  {  209,   -1 }, /* (311) exprlist ::= nexprlist */
  {  232,   -1 }, /* (312) nmnum ::= plus_num */
  {  232,   -1 }, /* (313) nmnum ::= nm */
  {  232,   -1 }, /* (314) nmnum ::= ON */
  {  232,   -1 }, /* (315) nmnum ::= DELETE */
  {  232,   -1 }, /* (316) nmnum ::= DEFAULT */
  {  169,   -1 }, /* (317) plus_num ::= INTEGER|FLOAT */
  {  237,    0 }, /* (318) foreach_clause ::= */
  {  237,   -3 }, /* (319) foreach_clause ::= FOR EACH ROW */
  {  240,   -1 }, /* (320) trnm ::= nm */
  {  241,    0 }, /* (321) tridxby ::= */
  {  242,   -1 }, /* (322) database_kw_opt ::= DATABASE */
  {  242,    0 }, /* (323) database_kw_opt ::= */
  {  245,    0 }, /* (324) kwcolumn_opt ::= */
  {  245,   -1 }, /* (325) kwcolumn_opt ::= COLUMNKW */
  {  247,   -1 }, /* (326) vtabarglist ::= vtabarg */
  {  247,   -3 }, /* (327) vtabarglist ::= vtabarglist COMMA vtabarg */
  {  248,   -2 }, /* (328) vtabarg ::= vtabarg vtabargtoken */
  {  251,    0 }, /* (329) anylist ::= */
  {  251,   -4 }, /* (330) anylist ::= anylist LP anylist RP */
  {  251,   -2 }, /* (331) anylist ::= anylist ANY */
  {  219,    0 }, /* (332) with ::= */
};

static void yy_accept(yyParser*);  /* Forward Declaration */

/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
141930
141931
141932
141933
141934
141935
141936
141937
141938
141939
141940
141941
141942
141943
141944
141945
      case 15: /* ifnotexists ::= */
      case 18: /* temp ::= */ yytestcase(yyruleno==18);
      case 21: /* table_options ::= */ yytestcase(yyruleno==21);
      case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
      case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
      case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
      case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
      case 90: /* distinct ::= */ yytestcase(yyruleno==90);
      case 213: /* collate ::= */ yytestcase(yyruleno==213);
{yymsp[1].minor.yy4 = 0;}
        break;
      case 16: /* ifnotexists ::= IF NOT EXISTS */
{yymsp[-2].minor.yy4 = 1;}
        break;
      case 17: /* temp ::= TEMP */
      case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);







|
|







142308
142309
142310
142311
142312
142313
142314
142315
142316
142317
142318
142319
142320
142321
142322
142323
      case 15: /* ifnotexists ::= */
      case 18: /* temp ::= */ yytestcase(yyruleno==18);
      case 21: /* table_options ::= */ yytestcase(yyruleno==21);
      case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
      case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
      case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
      case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
      case 92: /* distinct ::= */ yytestcase(yyruleno==92);
      case 216: /* collate ::= */ yytestcase(yyruleno==216);
{yymsp[1].minor.yy4 = 0;}
        break;
      case 16: /* ifnotexists ::= IF NOT EXISTS */
{yymsp[-2].minor.yy4 = 1;}
        break;
      case 17: /* temp ::= TEMP */
      case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
141967
141968
141969
141970
141971
141972
141973
141974
141975
141976
141977
141978
141979
141980
141981
}
        break;
      case 23: /* columnname ::= nm typetoken */
{sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
        break;
      case 24: /* typetoken ::= */
      case 60: /* conslist_opt ::= */ yytestcase(yyruleno==60);
      case 96: /* as ::= */ yytestcase(yyruleno==96);
{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;}
        break;
      case 25: /* typetoken ::= typename LP signed RP */
{
  yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);
}
        break;







|







142345
142346
142347
142348
142349
142350
142351
142352
142353
142354
142355
142356
142357
142358
142359
}
        break;
      case 23: /* columnname ::= nm typetoken */
{sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
        break;
      case 24: /* typetoken ::= */
      case 60: /* conslist_opt ::= */ yytestcase(yyruleno==60);
      case 98: /* as ::= */ yytestcase(yyruleno==98);
{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;}
        break;
      case 25: /* typetoken ::= typename LP signed RP */
{
  yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);
}
        break;
142078
142079
142080
142081
142082
142083
142084
142085
142086
142087
142088
142089
142090
142091
142092
142093
142094
142095
142096
142097
142098
142099
{ yymsp[-1].minor.yy4 = OE_None;     /* EV: R-33326-45252 */}
        break;
      case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
{yymsp[-2].minor.yy4 = 0;}
        break;
      case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
      case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
      case 144: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==144);
{yymsp[-1].minor.yy4 = yymsp[0].minor.yy4;}
        break;
      case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
      case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
      case 185: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==185);
      case 188: /* in_op ::= NOT IN */ yytestcase(yyruleno==188);
      case 214: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==214);
{yymsp[-1].minor.yy4 = 1;}
        break;
      case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
{yymsp[-1].minor.yy4 = 0;}
        break;
      case 61: /* tconscomma ::= COMMA */
{pParse->constraintName.n = 0;}







|




|
|
|







142456
142457
142458
142459
142460
142461
142462
142463
142464
142465
142466
142467
142468
142469
142470
142471
142472
142473
142474
142475
142476
142477
{ yymsp[-1].minor.yy4 = OE_None;     /* EV: R-33326-45252 */}
        break;
      case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
{yymsp[-2].minor.yy4 = 0;}
        break;
      case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
      case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
      case 147: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==147);
{yymsp[-1].minor.yy4 = yymsp[0].minor.yy4;}
        break;
      case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
      case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
      case 188: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==188);
      case 191: /* in_op ::= NOT IN */ yytestcase(yyruleno==191);
      case 217: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==217);
{yymsp[-1].minor.yy4 = 1;}
        break;
      case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
{yymsp[-1].minor.yy4 = 0;}
        break;
      case 61: /* tconscomma ::= COMMA */
{pParse->constraintName.n = 0;}
142121
142122
142123
142124
142125
142126
142127
142128
142129
142130
142131
142132
142133
142134
142135
      case 69: /* onconf ::= ON CONFLICT resolvetype */
{yymsp[-2].minor.yy4 = yymsp[0].minor.yy4;}
        break;
      case 72: /* resolvetype ::= IGNORE */
{yymsp[0].minor.yy4 = OE_Ignore;}
        break;
      case 73: /* resolvetype ::= REPLACE */
      case 145: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==145);
{yymsp[0].minor.yy4 = OE_Replace;}
        break;
      case 74: /* cmd ::= DROP TABLE ifexists fullname */
{
  sqlite3DropTable(pParse, yymsp[0].minor.yy259, 0, yymsp[-1].minor.yy4);
}
        break;







|







142499
142500
142501
142502
142503
142504
142505
142506
142507
142508
142509
142510
142511
142512
142513
      case 69: /* onconf ::= ON CONFLICT resolvetype */
{yymsp[-2].minor.yy4 = yymsp[0].minor.yy4;}
        break;
      case 72: /* resolvetype ::= IGNORE */
{yymsp[0].minor.yy4 = OE_Ignore;}
        break;
      case 73: /* resolvetype ::= REPLACE */
      case 148: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==148);
{yymsp[0].minor.yy4 = OE_Replace;}
        break;
      case 74: /* cmd ::= DROP TABLE ifexists fullname */
{
  sqlite3DropTable(pParse, yymsp[0].minor.yy259, 0, yymsp[-1].minor.yy4);
}
        break;
142146
142147
142148
142149
142150
142151
142152
142153












142154
142155
142156
142157
142158
142159
142160
142161









142162
142163
142164
142165
142166
142167
142168
142169
142170
142171
142172
      case 79: /* cmd ::= select */
{
  SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
  sqlite3Select(pParse, yymsp[0].minor.yy387, &dest);
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387);
}
        break;
      case 80: /* select ::= with selectnowith */












{
  Select *p = yymsp[0].minor.yy387;
  if( p ){
    p->pWith = yymsp[-1].minor.yy451;
    parserDoubleLinkSelect(pParse, p);
  }else{
    sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy451);
  }









  yymsp[-1].minor.yy387 = p; /*A-overwrites-W*/
}
        break;
      case 81: /* selectnowith ::= selectnowith multiselect_op oneselect */
{
  Select *pRhs = yymsp[0].minor.yy387;
  Select *pLhs = yymsp[-2].minor.yy387;
  if( pRhs && pRhs->pPrior ){
    SrcList *pFrom;
    Token x;
    x.n = 0;







|
>
>
>
>
>
>
>
>
>
>
>
>








>
>
>
>
>
>
>
>
>
|


|







142524
142525
142526
142527
142528
142529
142530
142531
142532
142533
142534
142535
142536
142537
142538
142539
142540
142541
142542
142543
142544
142545
142546
142547
142548
142549
142550
142551
142552
142553
142554
142555
142556
142557
142558
142559
142560
142561
142562
142563
142564
142565
142566
142567
142568
142569
142570
142571
      case 79: /* cmd ::= select */
{
  SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
  sqlite3Select(pParse, yymsp[0].minor.yy387, &dest);
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387);
}
        break;
      case 80: /* select ::= WITH wqlist selectnowith */
{
  Select *p = yymsp[0].minor.yy387;
  if( p ){
    p->pWith = yymsp[-1].minor.yy451;
    parserDoubleLinkSelect(pParse, p);
  }else{
    sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy451);
  }
  yymsp[-2].minor.yy387 = p;
}
        break;
      case 81: /* select ::= WITH RECURSIVE wqlist selectnowith */
{
  Select *p = yymsp[0].minor.yy387;
  if( p ){
    p->pWith = yymsp[-1].minor.yy451;
    parserDoubleLinkSelect(pParse, p);
  }else{
    sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy451);
  }
  yymsp[-3].minor.yy387 = p;
}
        break;
      case 82: /* select ::= selectnowith */
{
  Select *p = yymsp[0].minor.yy387;
  if( p ){
    parserDoubleLinkSelect(pParse, p);
  }
  yymsp[0].minor.yy387 = p; /*A-overwrites-X*/
}
        break;
      case 83: /* selectnowith ::= selectnowith multiselect_op oneselect */
{
  Select *pRhs = yymsp[0].minor.yy387;
  Select *pLhs = yymsp[-2].minor.yy387;
  if( pRhs && pRhs->pPrior ){
    SrcList *pFrom;
    Token x;
    x.n = 0;
142182
142183
142184
142185
142186
142187
142188
142189
142190
142191
142192
142193
142194
142195
142196
142197
142198
142199
142200
142201
142202
142203
    if( yymsp[-1].minor.yy4!=TK_ALL ) pParse->hasCompound = 1;
  }else{
    sqlite3SelectDelete(pParse->db, pLhs);
  }
  yymsp[-2].minor.yy387 = pRhs;
}
        break;
      case 82: /* multiselect_op ::= UNION */
      case 84: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==84);
{yymsp[0].minor.yy4 = yymsp[0].major; /*A-overwrites-OP*/}
        break;
      case 83: /* multiselect_op ::= UNION ALL */
{yymsp[-1].minor.yy4 = TK_ALL;}
        break;
      case 85: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
{
#if SELECTTRACE_ENABLED
  Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/
#endif
  yymsp[-8].minor.yy387 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy322,yymsp[-5].minor.yy259,yymsp[-4].minor.yy314,yymsp[-3].minor.yy322,yymsp[-2].minor.yy314,yymsp[-1].minor.yy322,yymsp[-7].minor.yy4,yymsp[0].minor.yy314);
#if SELECTTRACE_ENABLED
  /* Populate the Select.zSelName[] string that is used to help with







|
|


|


|







142581
142582
142583
142584
142585
142586
142587
142588
142589
142590
142591
142592
142593
142594
142595
142596
142597
142598
142599
142600
142601
142602
    if( yymsp[-1].minor.yy4!=TK_ALL ) pParse->hasCompound = 1;
  }else{
    sqlite3SelectDelete(pParse->db, pLhs);
  }
  yymsp[-2].minor.yy387 = pRhs;
}
        break;
      case 84: /* multiselect_op ::= UNION */
      case 86: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==86);
{yymsp[0].minor.yy4 = yymsp[0].major; /*A-overwrites-OP*/}
        break;
      case 85: /* multiselect_op ::= UNION ALL */
{yymsp[-1].minor.yy4 = TK_ALL;}
        break;
      case 87: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
{
#if SELECTTRACE_ENABLED
  Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/
#endif
  yymsp[-8].minor.yy387 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy322,yymsp[-5].minor.yy259,yymsp[-4].minor.yy314,yymsp[-3].minor.yy322,yymsp[-2].minor.yy314,yymsp[-1].minor.yy322,yymsp[-7].minor.yy4,yymsp[0].minor.yy314);
#if SELECTTRACE_ENABLED
  /* Populate the Select.zSelName[] string that is used to help with
142220
142221
142222
142223
142224
142225
142226
142227
142228
142229
142230
142231
142232
142233
142234
142235
142236
142237
142238
142239
142240
142241
142242
142243
142244
142245
142246
142247
142248
142249
142250
142251
142252
142253
142254
142255
142256
142257
142258
142259
142260
142261
142262
142263
142264
142265
142266
142267
142268
142269
142270
142271
142272
142273
142274
142275
142276
142277
142278
142279
142280
142281
142282
142283
142284
142285
142286
142287
142288
142289
142290
142291
142292
142293
142294
142295
142296
142297
142298
142299
142300
142301
142302
142303
142304
142305
142306
142307
142308
142309
142310
142311
142312
142313
142314
142315
142316
142317
142318
142319
142320
142321
142322
142323
142324
142325
142326
142327
142328
      for(i=0; sqlite3Isalnum(z[i]); i++){}
      sqlite3_snprintf(sizeof(yymsp[-8].minor.yy387->zSelName), yymsp[-8].minor.yy387->zSelName, "%.*s", i, z);
    }
  }
#endif /* SELECTRACE_ENABLED */
}
        break;
      case 86: /* values ::= VALUES LP nexprlist RP */
{
  yymsp[-3].minor.yy387 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy322,0,0,0,0,0,SF_Values,0);
}
        break;
      case 87: /* values ::= values COMMA LP exprlist RP */
{
  Select *pRight, *pLeft = yymsp[-4].minor.yy387;
  pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy322,0,0,0,0,0,SF_Values|SF_MultiValue,0);
  if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
  if( pRight ){
    pRight->op = TK_ALL;
    pRight->pPrior = pLeft;
    yymsp[-4].minor.yy387 = pRight;
  }else{
    yymsp[-4].minor.yy387 = pLeft;
  }
}
        break;
      case 88: /* distinct ::= DISTINCT */
{yymsp[0].minor.yy4 = SF_Distinct;}
        break;
      case 89: /* distinct ::= ALL */
{yymsp[0].minor.yy4 = SF_All;}
        break;
      case 91: /* sclp ::= */
      case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119);
      case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126);
      case 201: /* exprlist ::= */ yytestcase(yyruleno==201);
      case 204: /* paren_exprlist ::= */ yytestcase(yyruleno==204);
      case 209: /* eidlist_opt ::= */ yytestcase(yyruleno==209);
{yymsp[1].minor.yy322 = 0;}
        break;
      case 92: /* selcollist ::= sclp scanpt expr scanpt as */
{
   yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[-2].minor.yy314);
   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy322, &yymsp[0].minor.yy0, 1);
   sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy322,yymsp[-3].minor.yy336,yymsp[-1].minor.yy336);
}
        break;
      case 93: /* selcollist ::= sclp scanpt STAR */
{
  Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
  yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, p);
}
        break;
      case 94: /* selcollist ::= sclp scanpt nm DOT STAR */
{
  Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
  Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
  Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, pDot);
}
        break;
      case 95: /* as ::= AS nm */
      case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
      case 223: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==223);
      case 224: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==224);
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
        break;
      case 97: /* from ::= */
{yymsp[1].minor.yy259 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy259));}
        break;
      case 98: /* from ::= FROM seltablist */
{
  yymsp[-1].minor.yy259 = yymsp[0].minor.yy259;
  sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy259);
}
        break;
      case 99: /* stl_prefix ::= seltablist joinop */
{
   if( ALWAYS(yymsp[-1].minor.yy259 && yymsp[-1].minor.yy259->nSrc>0) ) yymsp[-1].minor.yy259->a[yymsp[-1].minor.yy259->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy4;
}
        break;
      case 100: /* stl_prefix ::= */
{yymsp[1].minor.yy259 = 0;}
        break;
      case 101: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
{
  yymsp[-6].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
  sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy259, &yymsp[-2].minor.yy0);
}
        break;
      case 102: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
{
  yymsp[-8].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy259,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
  sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy259, yymsp[-4].minor.yy322);
}
        break;
      case 103: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
{
    yymsp[-6].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy387,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
  }
        break;
      case 104: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
{
    if( yymsp[-6].minor.yy259==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy314==0 && yymsp[0].minor.yy384==0 ){
      yymsp[-6].minor.yy259 = yymsp[-4].minor.yy259;
    }else if( yymsp[-4].minor.yy259->nSrc==1 ){
      yymsp[-6].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
      if( yymsp[-6].minor.yy259 ){
        struct SrcList_item *pNew = &yymsp[-6].minor.yy259->a[yymsp[-6].minor.yy259->nSrc-1];







|




|













|


|


|
|
|
|
|
|


|






|





|







|
|
|
|


|


|





|




|


|





|





|




|







142619
142620
142621
142622
142623
142624
142625
142626
142627
142628
142629
142630
142631
142632
142633
142634
142635
142636
142637
142638
142639
142640
142641
142642
142643
142644
142645
142646
142647
142648
142649
142650
142651
142652
142653
142654
142655
142656
142657
142658
142659
142660
142661
142662
142663
142664
142665
142666
142667
142668
142669
142670
142671
142672
142673
142674
142675
142676
142677
142678
142679
142680
142681
142682
142683
142684
142685
142686
142687
142688
142689
142690
142691
142692
142693
142694
142695
142696
142697
142698
142699
142700
142701
142702
142703
142704
142705
142706
142707
142708
142709
142710
142711
142712
142713
142714
142715
142716
142717
142718
142719
142720
142721
142722
142723
142724
142725
142726
142727
      for(i=0; sqlite3Isalnum(z[i]); i++){}
      sqlite3_snprintf(sizeof(yymsp[-8].minor.yy387->zSelName), yymsp[-8].minor.yy387->zSelName, "%.*s", i, z);
    }
  }
#endif /* SELECTRACE_ENABLED */
}
        break;
      case 88: /* values ::= VALUES LP nexprlist RP */
{
  yymsp[-3].minor.yy387 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy322,0,0,0,0,0,SF_Values,0);
}
        break;
      case 89: /* values ::= values COMMA LP exprlist RP */
{
  Select *pRight, *pLeft = yymsp[-4].minor.yy387;
  pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy322,0,0,0,0,0,SF_Values|SF_MultiValue,0);
  if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
  if( pRight ){
    pRight->op = TK_ALL;
    pRight->pPrior = pLeft;
    yymsp[-4].minor.yy387 = pRight;
  }else{
    yymsp[-4].minor.yy387 = pLeft;
  }
}
        break;
      case 90: /* distinct ::= DISTINCT */
{yymsp[0].minor.yy4 = SF_Distinct;}
        break;
      case 91: /* distinct ::= ALL */
{yymsp[0].minor.yy4 = SF_All;}
        break;
      case 93: /* sclp ::= */
      case 122: /* orderby_opt ::= */ yytestcase(yyruleno==122);
      case 129: /* groupby_opt ::= */ yytestcase(yyruleno==129);
      case 204: /* exprlist ::= */ yytestcase(yyruleno==204);
      case 207: /* paren_exprlist ::= */ yytestcase(yyruleno==207);
      case 212: /* eidlist_opt ::= */ yytestcase(yyruleno==212);
{yymsp[1].minor.yy322 = 0;}
        break;
      case 94: /* selcollist ::= sclp scanpt expr scanpt as */
{
   yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[-2].minor.yy314);
   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy322, &yymsp[0].minor.yy0, 1);
   sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy322,yymsp[-3].minor.yy336,yymsp[-1].minor.yy336);
}
        break;
      case 95: /* selcollist ::= sclp scanpt STAR */
{
  Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
  yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, p);
}
        break;
      case 96: /* selcollist ::= sclp scanpt nm DOT STAR */
{
  Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
  Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
  Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, pDot);
}
        break;
      case 97: /* as ::= AS nm */
      case 108: /* dbnm ::= DOT nm */ yytestcase(yyruleno==108);
      case 226: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==226);
      case 227: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==227);
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
        break;
      case 99: /* from ::= */
{yymsp[1].minor.yy259 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy259));}
        break;
      case 100: /* from ::= FROM seltablist */
{
  yymsp[-1].minor.yy259 = yymsp[0].minor.yy259;
  sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy259);
}
        break;
      case 101: /* stl_prefix ::= seltablist joinop */
{
   if( ALWAYS(yymsp[-1].minor.yy259 && yymsp[-1].minor.yy259->nSrc>0) ) yymsp[-1].minor.yy259->a[yymsp[-1].minor.yy259->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy4;
}
        break;
      case 102: /* stl_prefix ::= */
{yymsp[1].minor.yy259 = 0;}
        break;
      case 103: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
{
  yymsp[-6].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
  sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy259, &yymsp[-2].minor.yy0);
}
        break;
      case 104: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
{
  yymsp[-8].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy259,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
  sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy259, yymsp[-4].minor.yy322);
}
        break;
      case 105: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
{
    yymsp[-6].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy387,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
  }
        break;
      case 106: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
{
    if( yymsp[-6].minor.yy259==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy314==0 && yymsp[0].minor.yy384==0 ){
      yymsp[-6].minor.yy259 = yymsp[-4].minor.yy259;
    }else if( yymsp[-4].minor.yy259->nSrc==1 ){
      yymsp[-6].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
      if( yymsp[-6].minor.yy259 ){
        struct SrcList_item *pNew = &yymsp[-6].minor.yy259->a[yymsp[-6].minor.yy259->nSrc-1];
142338
142339
142340
142341
142342
142343
142344
142345
142346
142347
142348
142349
142350
142351



142352
142353
142354
142355
142356
142357
142358
142359
142360
142361
142362
142363
142364
142365
142366
142367
142368
142369
142370
142371
142372
142373
142374
142375
142376
142377
142378
142379
142380
142381
142382
142383
142384
142385
142386
142387
142388
142389
142390
142391
142392
142393
142394
142395
142396
142397
142398
142399
142400
142401
142402
142403
142404
142405
142406
142407
142408
142409
142410
142411
142412
142413
142414
142415
142416
142417
142418
142419
142420
142421
142422
142423
142424
142425
142426
142427
142428
142429
142430
142431
142432
142433
142434
142435
142436
142437
142438
142439
142440
142441
142442
142443
142444
142445
142446
142447
142448
142449
142450
142451
142452
142453
142454
142455
142456
142457
142458
142459
142460
142461
142462
142463
142464
142465
142466
142467
142468
142469
142470
142471
142472
142473
142474
142475
142476
142477
142478
142479
142480
142481
142482
142483
142484
142485
142486
142487
142488
142489
142490
142491
142492
142493
142494
142495
142496
142497
142498
142499
142500
142501
142502
142503
142504
142505
142506
142507
142508
142509
142510
142511
142512
142513
142514
142515
142516
142517
142518
142519
142520
142521
142522
142523
142524
142525
142526
      Select *pSubquery;
      sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy259);
      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy259,0,0,0,0,SF_NestedFrom,0);
      yymsp[-6].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
    }
  }
        break;
      case 105: /* dbnm ::= */
      case 114: /* indexed_opt ::= */ yytestcase(yyruleno==114);
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
        break;
      case 107: /* fullname ::= nm dbnm */
{yymsp[-1].minor.yy259 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;



      case 108: /* joinop ::= COMMA|JOIN */
{ yymsp[0].minor.yy4 = JT_INNER; }
        break;
      case 109: /* joinop ::= JOIN_KW JOIN */
{yymsp[-1].minor.yy4 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0);  /*X-overwrites-A*/}
        break;
      case 110: /* joinop ::= JOIN_KW nm JOIN */
{yymsp[-2].minor.yy4 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
        break;
      case 111: /* joinop ::= JOIN_KW nm nm JOIN */
{yymsp[-3].minor.yy4 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
        break;
      case 112: /* on_opt ::= ON expr */
      case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129);
      case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136);
      case 197: /* case_else ::= ELSE expr */ yytestcase(yyruleno==197);
{yymsp[-1].minor.yy314 = yymsp[0].minor.yy314;}
        break;
      case 113: /* on_opt ::= */
      case 128: /* having_opt ::= */ yytestcase(yyruleno==128);
      case 130: /* limit_opt ::= */ yytestcase(yyruleno==130);
      case 135: /* where_opt ::= */ yytestcase(yyruleno==135);
      case 198: /* case_else ::= */ yytestcase(yyruleno==198);
      case 200: /* case_operand ::= */ yytestcase(yyruleno==200);
{yymsp[1].minor.yy314 = 0;}
        break;
      case 115: /* indexed_opt ::= INDEXED BY nm */
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
        break;
      case 116: /* indexed_opt ::= NOT INDEXED */
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
        break;
      case 117: /* using_opt ::= USING LP idlist RP */
{yymsp[-3].minor.yy384 = yymsp[-1].minor.yy384;}
        break;
      case 118: /* using_opt ::= */
      case 146: /* idlist_opt ::= */ yytestcase(yyruleno==146);
{yymsp[1].minor.yy384 = 0;}
        break;
      case 120: /* orderby_opt ::= ORDER BY sortlist */
      case 127: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==127);
{yymsp[-2].minor.yy322 = yymsp[0].minor.yy322;}
        break;
      case 121: /* sortlist ::= sortlist COMMA expr sortorder */
{
  yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322,yymsp[-1].minor.yy314);
  sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy322,yymsp[0].minor.yy4);
}
        break;
      case 122: /* sortlist ::= expr sortorder */
{
  yymsp[-1].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy314); /*A-overwrites-Y*/
  sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy322,yymsp[0].minor.yy4);
}
        break;
      case 123: /* sortorder ::= ASC */
{yymsp[0].minor.yy4 = SQLITE_SO_ASC;}
        break;
      case 124: /* sortorder ::= DESC */
{yymsp[0].minor.yy4 = SQLITE_SO_DESC;}
        break;
      case 125: /* sortorder ::= */
{yymsp[1].minor.yy4 = SQLITE_SO_UNDEFINED;}
        break;
      case 131: /* limit_opt ::= LIMIT expr */
{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy314,0);}
        break;
      case 132: /* limit_opt ::= LIMIT expr OFFSET expr */
{yymsp[-3].minor.yy314 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy314,yymsp[0].minor.yy314);}
        break;
      case 133: /* limit_opt ::= LIMIT expr COMMA expr */
{yymsp[-3].minor.yy314 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy314,yymsp[-2].minor.yy314);}
        break;
      case 134: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */
{
  sqlite3WithPush(pParse, yymsp[-5].minor.yy451, 1);
  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy259, &yymsp[-1].minor.yy0);
  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy259,yymsp[0].minor.yy314,0,0);
}
        break;
      case 137: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
{
  sqlite3WithPush(pParse, yymsp[-7].minor.yy451, 1);
  sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy259, &yymsp[-3].minor.yy0);
  sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy322,"set list"); 
  sqlite3Update(pParse,yymsp[-4].minor.yy259,yymsp[-1].minor.yy322,yymsp[0].minor.yy314,yymsp[-5].minor.yy4,0,0);
}
        break;
      case 138: /* setlist ::= setlist COMMA nm EQ expr */
{
  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy314);
  sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, 1);
}
        break;
      case 139: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
{
  yymsp[-6].minor.yy322 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy322, yymsp[-3].minor.yy384, yymsp[0].minor.yy314);
}
        break;
      case 140: /* setlist ::= nm EQ expr */
{
  yylhsminor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy314);
  sqlite3ExprListSetName(pParse, yylhsminor.yy322, &yymsp[-2].minor.yy0, 1);
}
  yymsp[-2].minor.yy322 = yylhsminor.yy322;
        break;
      case 141: /* setlist ::= LP idlist RP EQ expr */
{
  yymsp[-4].minor.yy322 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy384, yymsp[0].minor.yy314);
}
        break;
      case 142: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
{
  sqlite3WithPush(pParse, yymsp[-5].minor.yy451, 1);
  sqlite3Insert(pParse, yymsp[-2].minor.yy259, yymsp[0].minor.yy387, yymsp[-1].minor.yy384, yymsp[-4].minor.yy4);
}
        break;
      case 143: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
{
  sqlite3WithPush(pParse, yymsp[-6].minor.yy451, 1);
  sqlite3Insert(pParse, yymsp[-3].minor.yy259, 0, yymsp[-2].minor.yy384, yymsp[-5].minor.yy4);
}
        break;
      case 147: /* idlist_opt ::= LP idlist RP */
{yymsp[-2].minor.yy384 = yymsp[-1].minor.yy384;}
        break;
      case 148: /* idlist ::= idlist COMMA nm */
{yymsp[-2].minor.yy384 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy384,&yymsp[0].minor.yy0);}
        break;
      case 149: /* idlist ::= nm */
{yymsp[0].minor.yy384 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
        break;
      case 150: /* expr ::= LP expr RP */
{yymsp[-2].minor.yy314 = yymsp[-1].minor.yy314;}
        break;
      case 151: /* expr ::= ID|INDEXED */
      case 152: /* expr ::= JOIN_KW */ yytestcase(yyruleno==152);
{yymsp[0].minor.yy314=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 153: /* expr ::= nm DOT nm */
{
  Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
  Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
  yylhsminor.yy314 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
}
  yymsp[-2].minor.yy314 = yylhsminor.yy314;
        break;
      case 154: /* expr ::= nm DOT nm DOT nm */
{
  Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
  Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
  Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
  Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
  yylhsminor.yy314 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
}
  yymsp[-4].minor.yy314 = yylhsminor.yy314;
        break;
      case 155: /* term ::= NULL|FLOAT|BLOB */
      case 156: /* term ::= STRING */ yytestcase(yyruleno==156);
{yymsp[0].minor.yy314=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 157: /* term ::= INTEGER */
{
  yylhsminor.yy314 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
}
  yymsp[0].minor.yy314 = yylhsminor.yy314;
        break;
      case 158: /* expr ::= VARIABLE */
{
  if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
    u32 n = yymsp[0].minor.yy0.n;
    yymsp[0].minor.yy314 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
    sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy314, n);
  }else{
    /* When doing a nested parse, one can include terms in an expression







|
|


|
|

>
>
>
|


|


|


|


|
|
|
|


|
|
|
|
|
|


|


|


|


|
|


|
|


|





|





|


|


|


|


|


|


|

<




|

<





|





|




|






|




|

<



|

<



|


|


|


|


|
|


|







|









|
|


|





|







142737
142738
142739
142740
142741
142742
142743
142744
142745
142746
142747
142748
142749
142750
142751
142752
142753
142754
142755
142756
142757
142758
142759
142760
142761
142762
142763
142764
142765
142766
142767
142768
142769
142770
142771
142772
142773
142774
142775
142776
142777
142778
142779
142780
142781
142782
142783
142784
142785
142786
142787
142788
142789
142790
142791
142792
142793
142794
142795
142796
142797
142798
142799
142800
142801
142802
142803
142804
142805
142806
142807
142808
142809
142810
142811
142812
142813
142814
142815
142816
142817
142818
142819
142820
142821
142822
142823
142824
142825
142826
142827
142828

142829
142830
142831
142832
142833
142834

142835
142836
142837
142838
142839
142840
142841
142842
142843
142844
142845
142846
142847
142848
142849
142850
142851
142852
142853
142854
142855
142856
142857
142858
142859
142860
142861
142862
142863
142864

142865
142866
142867
142868
142869

142870
142871
142872
142873
142874
142875
142876
142877
142878
142879
142880
142881
142882
142883
142884
142885
142886
142887
142888
142889
142890
142891
142892
142893
142894
142895
142896
142897
142898
142899
142900
142901
142902
142903
142904
142905
142906
142907
142908
142909
142910
142911
142912
142913
142914
142915
142916
142917
142918
142919
142920
142921
142922
142923
142924
      Select *pSubquery;
      sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy259);
      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy259,0,0,0,0,SF_NestedFrom,0);
      yymsp[-6].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
    }
  }
        break;
      case 107: /* dbnm ::= */
      case 117: /* indexed_opt ::= */ yytestcase(yyruleno==117);
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
        break;
      case 109: /* fullname ::= nm */
{yymsp[0].minor.yy259 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
        break;
      case 110: /* fullname ::= nm DOT nm */
{yymsp[-2].minor.yy259 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 111: /* joinop ::= COMMA|JOIN */
{ yymsp[0].minor.yy4 = JT_INNER; }
        break;
      case 112: /* joinop ::= JOIN_KW JOIN */
{yymsp[-1].minor.yy4 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0);  /*X-overwrites-A*/}
        break;
      case 113: /* joinop ::= JOIN_KW nm JOIN */
{yymsp[-2].minor.yy4 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
        break;
      case 114: /* joinop ::= JOIN_KW nm nm JOIN */
{yymsp[-3].minor.yy4 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
        break;
      case 115: /* on_opt ::= ON expr */
      case 132: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==132);
      case 139: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==139);
      case 200: /* case_else ::= ELSE expr */ yytestcase(yyruleno==200);
{yymsp[-1].minor.yy314 = yymsp[0].minor.yy314;}
        break;
      case 116: /* on_opt ::= */
      case 131: /* having_opt ::= */ yytestcase(yyruleno==131);
      case 133: /* limit_opt ::= */ yytestcase(yyruleno==133);
      case 138: /* where_opt ::= */ yytestcase(yyruleno==138);
      case 201: /* case_else ::= */ yytestcase(yyruleno==201);
      case 203: /* case_operand ::= */ yytestcase(yyruleno==203);
{yymsp[1].minor.yy314 = 0;}
        break;
      case 118: /* indexed_opt ::= INDEXED BY nm */
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
        break;
      case 119: /* indexed_opt ::= NOT INDEXED */
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
        break;
      case 120: /* using_opt ::= USING LP idlist RP */
{yymsp[-3].minor.yy384 = yymsp[-1].minor.yy384;}
        break;
      case 121: /* using_opt ::= */
      case 149: /* idlist_opt ::= */ yytestcase(yyruleno==149);
{yymsp[1].minor.yy384 = 0;}
        break;
      case 123: /* orderby_opt ::= ORDER BY sortlist */
      case 130: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==130);
{yymsp[-2].minor.yy322 = yymsp[0].minor.yy322;}
        break;
      case 124: /* sortlist ::= sortlist COMMA expr sortorder */
{
  yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322,yymsp[-1].minor.yy314);
  sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy322,yymsp[0].minor.yy4);
}
        break;
      case 125: /* sortlist ::= expr sortorder */
{
  yymsp[-1].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy314); /*A-overwrites-Y*/
  sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy322,yymsp[0].minor.yy4);
}
        break;
      case 126: /* sortorder ::= ASC */
{yymsp[0].minor.yy4 = SQLITE_SO_ASC;}
        break;
      case 127: /* sortorder ::= DESC */
{yymsp[0].minor.yy4 = SQLITE_SO_DESC;}
        break;
      case 128: /* sortorder ::= */
{yymsp[1].minor.yy4 = SQLITE_SO_UNDEFINED;}
        break;
      case 134: /* limit_opt ::= LIMIT expr */
{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy314,0);}
        break;
      case 135: /* limit_opt ::= LIMIT expr OFFSET expr */
{yymsp[-3].minor.yy314 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy314,yymsp[0].minor.yy314);}
        break;
      case 136: /* limit_opt ::= LIMIT expr COMMA expr */
{yymsp[-3].minor.yy314 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy314,yymsp[-2].minor.yy314);}
        break;
      case 137: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */
{

  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy259, &yymsp[-1].minor.yy0);
  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy259,yymsp[0].minor.yy314,0,0);
}
        break;
      case 140: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
{

  sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy259, &yymsp[-3].minor.yy0);
  sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy322,"set list"); 
  sqlite3Update(pParse,yymsp[-4].minor.yy259,yymsp[-1].minor.yy322,yymsp[0].minor.yy314,yymsp[-5].minor.yy4,0,0);
}
        break;
      case 141: /* setlist ::= setlist COMMA nm EQ expr */
{
  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy314);
  sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, 1);
}
        break;
      case 142: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
{
  yymsp[-6].minor.yy322 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy322, yymsp[-3].minor.yy384, yymsp[0].minor.yy314);
}
        break;
      case 143: /* setlist ::= nm EQ expr */
{
  yylhsminor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy314);
  sqlite3ExprListSetName(pParse, yylhsminor.yy322, &yymsp[-2].minor.yy0, 1);
}
  yymsp[-2].minor.yy322 = yylhsminor.yy322;
        break;
      case 144: /* setlist ::= LP idlist RP EQ expr */
{
  yymsp[-4].minor.yy322 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy384, yymsp[0].minor.yy314);
}
        break;
      case 145: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
{

  sqlite3Insert(pParse, yymsp[-2].minor.yy259, yymsp[0].minor.yy387, yymsp[-1].minor.yy384, yymsp[-4].minor.yy4);
}
        break;
      case 146: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
{

  sqlite3Insert(pParse, yymsp[-3].minor.yy259, 0, yymsp[-2].minor.yy384, yymsp[-5].minor.yy4);
}
        break;
      case 150: /* idlist_opt ::= LP idlist RP */
{yymsp[-2].minor.yy384 = yymsp[-1].minor.yy384;}
        break;
      case 151: /* idlist ::= idlist COMMA nm */
{yymsp[-2].minor.yy384 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy384,&yymsp[0].minor.yy0);}
        break;
      case 152: /* idlist ::= nm */
{yymsp[0].minor.yy384 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
        break;
      case 153: /* expr ::= LP expr RP */
{yymsp[-2].minor.yy314 = yymsp[-1].minor.yy314;}
        break;
      case 154: /* expr ::= ID|INDEXED */
      case 155: /* expr ::= JOIN_KW */ yytestcase(yyruleno==155);
{yymsp[0].minor.yy314=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 156: /* expr ::= nm DOT nm */
{
  Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
  Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
  yylhsminor.yy314 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
}
  yymsp[-2].minor.yy314 = yylhsminor.yy314;
        break;
      case 157: /* expr ::= nm DOT nm DOT nm */
{
  Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
  Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
  Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
  Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
  yylhsminor.yy314 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
}
  yymsp[-4].minor.yy314 = yylhsminor.yy314;
        break;
      case 158: /* term ::= NULL|FLOAT|BLOB */
      case 159: /* term ::= STRING */ yytestcase(yyruleno==159);
{yymsp[0].minor.yy314=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 160: /* term ::= INTEGER */
{
  yylhsminor.yy314 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
}
  yymsp[0].minor.yy314 = yylhsminor.yy314;
        break;
      case 161: /* expr ::= VARIABLE */
{
  if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
    u32 n = yymsp[0].minor.yy0.n;
    yymsp[0].minor.yy314 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
    sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy314, n);
  }else{
    /* When doing a nested parse, one can include terms in an expression
142534
142535
142536
142537
142538
142539
142540
142541
142542
142543
142544
142545
142546
142547
142548
142549
142550
142551
142552
142553
142554
142555
142556
142557
142558
142559
142560
142561
142562
142563
142564
142565
142566
142567
142568
142569
142570
142571
142572
142573
142574
142575
142576
142577
142578
142579
142580
142581
142582
142583
142584
142585
142586
142587
142588
142589
142590
142591
142592
142593
142594
142595
142596
142597
142598
142599
142600
142601
142602
142603
142604
142605
142606
142607
142608
142609
142610
142611
142612
142613
142614
142615
142616
142617
142618
142619
142620
142621
142622
142623
142624
142625
142626
142627
142628
142629
142630
142631
142632
142633
142634
142635
142636
142637
142638
142639
142640
142641
142642
142643
142644
142645
142646
142647
142648
142649
142650
142651
142652
142653
142654
142655
142656
142657
142658
142659
142660
142661
142662
142663
142664
142665
142666
142667
142668
142669
142670
142671
142672
142673
142674
142675
142676
142677
    }else{
      yymsp[0].minor.yy314 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
      if( yymsp[0].minor.yy314 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy314->iTable);
    }
  }
}
        break;
      case 159: /* expr ::= expr COLLATE ID|STRING */
{
  yymsp[-2].minor.yy314 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy314, &yymsp[0].minor.yy0, 1);
}
        break;
      case 160: /* expr ::= CAST LP expr AS typetoken RP */
{
  yymsp[-5].minor.yy314 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
  sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy314, yymsp[-3].minor.yy314, 0);
}
        break;
      case 161: /* expr ::= ID|INDEXED LP distinct exprlist RP */
{
  if( yymsp[-1].minor.yy322 && yymsp[-1].minor.yy322->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
    sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
  }
  yylhsminor.yy314 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0);
  if( yymsp[-2].minor.yy4==SF_Distinct && yylhsminor.yy314 ){
    yylhsminor.yy314->flags |= EP_Distinct;
  }
}
  yymsp[-4].minor.yy314 = yylhsminor.yy314;
        break;
      case 162: /* expr ::= ID|INDEXED LP STAR RP */
{
  yylhsminor.yy314 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
}
  yymsp[-3].minor.yy314 = yylhsminor.yy314;
        break;
      case 163: /* term ::= CTIME_KW */
{
  yylhsminor.yy314 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
}
  yymsp[0].minor.yy314 = yylhsminor.yy314;
        break;
      case 164: /* expr ::= LP nexprlist COMMA expr RP */
{
  ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy314);
  yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
  if( yymsp[-4].minor.yy314 ){
    yymsp[-4].minor.yy314->x.pList = pList;
  }else{
    sqlite3ExprListDelete(pParse->db, pList);
  }
}
        break;
      case 165: /* expr ::= expr AND expr */
      case 166: /* expr ::= expr OR expr */ yytestcase(yyruleno==166);
      case 167: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==167);
      case 168: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==168);
      case 169: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==169);
      case 170: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==170);
      case 171: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==171);
      case 172: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==172);
{yymsp[-2].minor.yy314=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy314,yymsp[0].minor.yy314);}
        break;
      case 173: /* likeop ::= NOT LIKE_KW|MATCH */
{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
        break;
      case 174: /* expr ::= expr likeop expr */
{
  ExprList *pList;
  int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
  yymsp[-1].minor.yy0.n &= 0x7fffffff;
  pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy314);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy314);
  yymsp[-2].minor.yy314 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0);
  if( bNot ) yymsp[-2].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy314, 0);
  if( yymsp[-2].minor.yy314 ) yymsp[-2].minor.yy314->flags |= EP_InfixFunc;
}
        break;
      case 175: /* expr ::= expr likeop expr ESCAPE expr */
{
  ExprList *pList;
  int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
  yymsp[-3].minor.yy0.n &= 0x7fffffff;
  pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy314);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy314);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy314);
  yymsp[-4].minor.yy314 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0);
  if( bNot ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
  if( yymsp[-4].minor.yy314 ) yymsp[-4].minor.yy314->flags |= EP_InfixFunc;
}
        break;
      case 176: /* expr ::= expr ISNULL|NOTNULL */
{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy314,0);}
        break;
      case 177: /* expr ::= expr NOT NULL */
{yymsp[-2].minor.yy314 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy314,0);}
        break;
      case 178: /* expr ::= expr IS expr */
{
  yymsp[-2].minor.yy314 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy314,yymsp[0].minor.yy314);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy314, yymsp[-2].minor.yy314, TK_ISNULL);
}
        break;
      case 179: /* expr ::= expr IS NOT expr */
{
  yymsp[-3].minor.yy314 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy314,yymsp[0].minor.yy314);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy314, yymsp[-3].minor.yy314, TK_NOTNULL);
}
        break;
      case 180: /* expr ::= NOT expr */
      case 181: /* expr ::= BITNOT expr */ yytestcase(yyruleno==181);
{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy314, 0);/*A-overwrites-B*/}
        break;
      case 182: /* expr ::= MINUS expr */
{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy314, 0);}
        break;
      case 183: /* expr ::= PLUS expr */
{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse, TK_UPLUS, yymsp[0].minor.yy314, 0);}
        break;
      case 184: /* between_op ::= BETWEEN */
      case 187: /* in_op ::= IN */ yytestcase(yyruleno==187);
{yymsp[0].minor.yy4 = 0;}
        break;
      case 186: /* expr ::= expr between_op expr AND expr */
{
  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy314);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy314);
  yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy314, 0);
  if( yymsp[-4].minor.yy314 ){
    yymsp[-4].minor.yy314->x.pList = pList;
  }else{
    sqlite3ExprListDelete(pParse->db, pList);
  } 
  if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
}
        break;
      case 189: /* expr ::= expr in_op LP exprlist RP */
{
    if( yymsp[-1].minor.yy322==0 ){
      /* Expressions of the form
      **
      **      expr1 IN ()
      **      expr1 NOT IN ()
      **







|




|





|











|





|





|










|
|
|
|
|
|
|
|


|


|











|












|


|


|





|





|
|


|


|


|
|


|












|







142932
142933
142934
142935
142936
142937
142938
142939
142940
142941
142942
142943
142944
142945
142946
142947
142948
142949
142950
142951
142952
142953
142954
142955
142956
142957
142958
142959
142960
142961
142962
142963
142964
142965
142966
142967
142968
142969
142970
142971
142972
142973
142974
142975
142976
142977
142978
142979
142980
142981
142982
142983
142984
142985
142986
142987
142988
142989
142990
142991
142992
142993
142994
142995
142996
142997
142998
142999
143000
143001
143002
143003
143004
143005
143006
143007
143008
143009
143010
143011
143012
143013
143014
143015
143016
143017
143018
143019
143020
143021
143022
143023
143024
143025
143026
143027
143028
143029
143030
143031
143032
143033
143034
143035
143036
143037
143038
143039
143040
143041
143042
143043
143044
143045
143046
143047
143048
143049
143050
143051
143052
143053
143054
143055
143056
143057
143058
143059
143060
143061
143062
143063
143064
143065
143066
143067
143068
143069
143070
143071
143072
143073
143074
143075
    }else{
      yymsp[0].minor.yy314 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
      if( yymsp[0].minor.yy314 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy314->iTable);
    }
  }
}
        break;
      case 162: /* expr ::= expr COLLATE ID|STRING */
{
  yymsp[-2].minor.yy314 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy314, &yymsp[0].minor.yy0, 1);
}
        break;
      case 163: /* expr ::= CAST LP expr AS typetoken RP */
{
  yymsp[-5].minor.yy314 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
  sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy314, yymsp[-3].minor.yy314, 0);
}
        break;
      case 164: /* expr ::= ID|INDEXED LP distinct exprlist RP */
{
  if( yymsp[-1].minor.yy322 && yymsp[-1].minor.yy322->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
    sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
  }
  yylhsminor.yy314 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0);
  if( yymsp[-2].minor.yy4==SF_Distinct && yylhsminor.yy314 ){
    yylhsminor.yy314->flags |= EP_Distinct;
  }
}
  yymsp[-4].minor.yy314 = yylhsminor.yy314;
        break;
      case 165: /* expr ::= ID|INDEXED LP STAR RP */
{
  yylhsminor.yy314 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
}
  yymsp[-3].minor.yy314 = yylhsminor.yy314;
        break;
      case 166: /* term ::= CTIME_KW */
{
  yylhsminor.yy314 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
}
  yymsp[0].minor.yy314 = yylhsminor.yy314;
        break;
      case 167: /* expr ::= LP nexprlist COMMA expr RP */
{
  ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy314);
  yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
  if( yymsp[-4].minor.yy314 ){
    yymsp[-4].minor.yy314->x.pList = pList;
  }else{
    sqlite3ExprListDelete(pParse->db, pList);
  }
}
        break;
      case 168: /* expr ::= expr AND expr */
      case 169: /* expr ::= expr OR expr */ yytestcase(yyruleno==169);
      case 170: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==170);
      case 171: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==171);
      case 172: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==172);
      case 173: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==173);
      case 174: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==174);
      case 175: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==175);
{yymsp[-2].minor.yy314=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy314,yymsp[0].minor.yy314);}
        break;
      case 176: /* likeop ::= NOT LIKE_KW|MATCH */
{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
        break;
      case 177: /* expr ::= expr likeop expr */
{
  ExprList *pList;
  int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
  yymsp[-1].minor.yy0.n &= 0x7fffffff;
  pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy314);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy314);
  yymsp[-2].minor.yy314 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0);
  if( bNot ) yymsp[-2].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy314, 0);
  if( yymsp[-2].minor.yy314 ) yymsp[-2].minor.yy314->flags |= EP_InfixFunc;
}
        break;
      case 178: /* expr ::= expr likeop expr ESCAPE expr */
{
  ExprList *pList;
  int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
  yymsp[-3].minor.yy0.n &= 0x7fffffff;
  pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy314);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy314);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy314);
  yymsp[-4].minor.yy314 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0);
  if( bNot ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
  if( yymsp[-4].minor.yy314 ) yymsp[-4].minor.yy314->flags |= EP_InfixFunc;
}
        break;
      case 179: /* expr ::= expr ISNULL|NOTNULL */
{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy314,0);}
        break;
      case 180: /* expr ::= expr NOT NULL */
{yymsp[-2].minor.yy314 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy314,0);}
        break;
      case 181: /* expr ::= expr IS expr */
{
  yymsp[-2].minor.yy314 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy314,yymsp[0].minor.yy314);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy314, yymsp[-2].minor.yy314, TK_ISNULL);
}
        break;
      case 182: /* expr ::= expr IS NOT expr */
{
  yymsp[-3].minor.yy314 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy314,yymsp[0].minor.yy314);
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy314, yymsp[-3].minor.yy314, TK_NOTNULL);
}
        break;
      case 183: /* expr ::= NOT expr */
      case 184: /* expr ::= BITNOT expr */ yytestcase(yyruleno==184);
{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy314, 0);/*A-overwrites-B*/}
        break;
      case 185: /* expr ::= MINUS expr */
{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy314, 0);}
        break;
      case 186: /* expr ::= PLUS expr */
{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse, TK_UPLUS, yymsp[0].minor.yy314, 0);}
        break;
      case 187: /* between_op ::= BETWEEN */
      case 190: /* in_op ::= IN */ yytestcase(yyruleno==190);
{yymsp[0].minor.yy4 = 0;}
        break;
      case 189: /* expr ::= expr between_op expr AND expr */
{
  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy314);
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy314);
  yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy314, 0);
  if( yymsp[-4].minor.yy314 ){
    yymsp[-4].minor.yy314->x.pList = pList;
  }else{
    sqlite3ExprListDelete(pParse->db, pList);
  } 
  if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
}
        break;
      case 192: /* expr ::= expr in_op LP exprlist RP */
{
    if( yymsp[-1].minor.yy322==0 ){
      /* Expressions of the form
      **
      **      expr1 IN ()
      **      expr1 NOT IN ()
      **
142715
142716
142717
142718
142719
142720
142721
142722
142723
142724
142725
142726
142727
142728
142729
142730
142731
142732
142733
142734
142735
142736
142737
142738
142739
142740
142741
142742
142743
142744
142745
142746
142747
142748
142749
142750
142751
142752
142753
142754
142755
142756
142757
142758
142759
142760
142761
142762
142763
142764
142765
142766
142767
142768
142769
142770
142771
142772
142773
142774
142775
142776
142777
142778
142779
142780
142781
142782
142783
142784
142785
142786
142787
142788
142789
142790
142791
142792
142793
142794
142795
142796
142797
142798
142799
142800
142801
142802
142803
142804
142805
142806
142807
142808
142809
142810
142811
142812
142813
142814
142815
142816
142817
142818
142819
142820
142821
142822
142823
142824
142825
142826
142827
142828
142829
142830
142831
142832
142833
142834
142835
142836
142837
142838
142839
142840
142841
142842
142843
142844
142845
142846
142847
142848
142849
142850
142851
142852
142853
142854
142855
142856
142857
142858
142859
142860
142861
142862
142863
142864
142865
142866
142867
142868
142869
142870
142871
142872
142873
142874
142875
142876
142877
142878
142879
142880
142881
142882
142883
142884
142885
142886
142887
142888
142889
142890
142891
142892
142893
142894
142895
142896
142897
142898
142899
142900
142901
142902
142903
142904
142905
142906
142907
142908
142909
142910
142911
142912
142913
142914
142915
142916
142917
142918
142919
142920
142921
142922
142923
142924
142925
142926
142927
142928
142929
142930
142931
142932
142933
142934
142935
142936
142937
142938
142939
142940
142941
142942
142943
142944
142945
142946
142947
142948
142949
142950
142951
142952
142953
142954
142955
142956
142957
142958
142959
142960
142961
142962
142963
142964
142965
142966
142967
142968
142969
142970
142971
142972
142973
142974
142975
142976
142977
142978
142979
142980
142981
142982
142983
142984
142985
142986
142987
142988
142989
142990
142991
142992
142993
142994
142995
142996
142997
142998
142999
143000
143001
143002
143003
143004
143005
143006
143007
143008
143009
143010
143011
143012
143013
143014
143015
143016
143017
143018
143019
143020
143021
143022
143023
143024
143025
143026
143027
143028
143029
143030
143031
143032
143033
143034
143035
143036
143037
143038
143039
143040
143041
143042
143043
143044
143045
143046
143047
143048
143049
143050
143051
143052
143053
143054
143055
143056
143057
143058
143059
143060
143061
143062
143063
143064
143065
143066
143067
143068
143069
143070
143071
143072
143073
143074
143075
143076
143077
143078
143079
143080
143081
143082
143083
143084
143085
143086
143087

143088
143089
143090
143091
143092
143093
143094
      }else{
        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
      }
      if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
    }
  }
        break;
      case 190: /* expr ::= LP select RP */
{
    yymsp[-2].minor.yy314 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy314, yymsp[-1].minor.yy387);
  }
        break;
      case 191: /* expr ::= expr in_op LP select RP */
{
    yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy314, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy314, yymsp[-1].minor.yy387);
    if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
  }
        break;
      case 192: /* expr ::= expr in_op nm dbnm paren_exprlist */
{
    SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
    Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
    if( yymsp[0].minor.yy322 )  sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy322);
    yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy314, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy314, pSelect);
    if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
  }
        break;
      case 193: /* expr ::= EXISTS LP select RP */
{
    Expr *p;
    p = yymsp[-3].minor.yy314 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
    sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy387);
  }
        break;
      case 194: /* expr ::= CASE case_operand case_exprlist case_else END */
{
  yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy314, 0);
  if( yymsp[-4].minor.yy314 ){
    yymsp[-4].minor.yy314->x.pList = yymsp[-1].minor.yy314 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[-1].minor.yy314) : yymsp[-2].minor.yy322;
    sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy314);
  }else{
    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322);
    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy314);
  }
}
        break;
      case 195: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
{
  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy314);
  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[0].minor.yy314);
}
        break;
      case 196: /* case_exprlist ::= WHEN expr THEN expr */
{
  yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy314);
  yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, yymsp[0].minor.yy314);
}
        break;
      case 199: /* case_operand ::= expr */
{yymsp[0].minor.yy314 = yymsp[0].minor.yy314; /*A-overwrites-X*/}
        break;
      case 202: /* nexprlist ::= nexprlist COMMA expr */
{yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy314);}
        break;
      case 203: /* nexprlist ::= expr */
{yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy314); /*A-overwrites-Y*/}
        break;
      case 205: /* paren_exprlist ::= LP exprlist RP */
      case 210: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==210);
{yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;}
        break;
      case 206: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
{
  sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, 
                     sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy4,
                      &yymsp[-11].minor.yy0, yymsp[0].minor.yy314, SQLITE_SO_ASC, yymsp[-8].minor.yy4, SQLITE_IDXTYPE_APPDEF);
}
        break;
      case 207: /* uniqueflag ::= UNIQUE */
      case 247: /* raisetype ::= ABORT */ yytestcase(yyruleno==247);
{yymsp[0].minor.yy4 = OE_Abort;}
        break;
      case 208: /* uniqueflag ::= */
{yymsp[1].minor.yy4 = OE_None;}
        break;
      case 211: /* eidlist ::= eidlist COMMA nm collate sortorder */
{
  yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy4, yymsp[0].minor.yy4);
}
        break;
      case 212: /* eidlist ::= nm collate sortorder */
{
  yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy4, yymsp[0].minor.yy4); /*A-overwrites-Y*/
}
        break;
      case 215: /* cmd ::= DROP INDEX ifexists fullname */
{sqlite3DropIndex(pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4);}
        break;
      case 216: /* cmd ::= VACUUM */
{sqlite3Vacuum(pParse,0);}
        break;
      case 217: /* cmd ::= VACUUM nm */
{sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
        break;
      case 218: /* cmd ::= PRAGMA nm dbnm */
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
        break;
      case 219: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
        break;
      case 220: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
        break;
      case 221: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
        break;
      case 222: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
        break;
      case 225: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
{
  Token all;
  all.z = yymsp[-3].minor.yy0.z;
  all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
  sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy203, &all);
}
        break;
      case 226: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
{
  sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy4, yymsp[-4].minor.yy90.a, yymsp[-4].minor.yy90.b, yymsp[-2].minor.yy259, yymsp[0].minor.yy314, yymsp[-10].minor.yy4, yymsp[-8].minor.yy4);
  yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
}
        break;
      case 227: /* trigger_time ::= BEFORE|AFTER */
{ yymsp[0].minor.yy4 = yymsp[0].major; /*A-overwrites-X*/ }
        break;
      case 228: /* trigger_time ::= INSTEAD OF */
{ yymsp[-1].minor.yy4 = TK_INSTEAD;}
        break;
      case 229: /* trigger_time ::= */
{ yymsp[1].minor.yy4 = TK_BEFORE; }
        break;
      case 230: /* trigger_event ::= DELETE|INSERT */
      case 231: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==231);
{yymsp[0].minor.yy90.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy90.b = 0;}
        break;
      case 232: /* trigger_event ::= UPDATE OF idlist */
{yymsp[-2].minor.yy90.a = TK_UPDATE; yymsp[-2].minor.yy90.b = yymsp[0].minor.yy384;}
        break;
      case 233: /* when_clause ::= */
      case 252: /* key_opt ::= */ yytestcase(yyruleno==252);
{ yymsp[1].minor.yy314 = 0; }
        break;
      case 234: /* when_clause ::= WHEN expr */
      case 253: /* key_opt ::= KEY expr */ yytestcase(yyruleno==253);
{ yymsp[-1].minor.yy314 = yymsp[0].minor.yy314; }
        break;
      case 235: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
{
  assert( yymsp[-2].minor.yy203!=0 );
  yymsp[-2].minor.yy203->pLast->pNext = yymsp[-1].minor.yy203;
  yymsp[-2].minor.yy203->pLast = yymsp[-1].minor.yy203;
}
        break;
      case 236: /* trigger_cmd_list ::= trigger_cmd SEMI */
{ 
  assert( yymsp[-1].minor.yy203!=0 );
  yymsp[-1].minor.yy203->pLast = yymsp[-1].minor.yy203;
}
        break;
      case 237: /* trnm ::= nm DOT nm */
{
  yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
  sqlite3ErrorMsg(pParse, 
        "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
        "statements within triggers");
}
        break;
      case 238: /* tridxby ::= INDEXED BY nm */
{
  sqlite3ErrorMsg(pParse,
        "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
        "within triggers");
}
        break;
      case 239: /* tridxby ::= NOT INDEXED */
{
  sqlite3ErrorMsg(pParse,
        "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
        "within triggers");
}
        break;
      case 240: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
{yylhsminor.yy203 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy314, yymsp[-6].minor.yy4, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy336);}
  yymsp[-7].minor.yy203 = yylhsminor.yy203;
        break;
      case 241: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select scanpt */
{yylhsminor.yy203 = sqlite3TriggerInsertStep(pParse->db,&yymsp[-3].minor.yy0,yymsp[-2].minor.yy384,yymsp[-1].minor.yy387,yymsp[-5].minor.yy4,yymsp[-6].minor.yy336,yymsp[0].minor.yy336);/*yylhsminor.yy203-overwrites-yymsp[-5].minor.yy4*/}
  yymsp[-6].minor.yy203 = yylhsminor.yy203;
        break;
      case 242: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
{yylhsminor.yy203 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy314, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy336);}
  yymsp[-5].minor.yy203 = yylhsminor.yy203;
        break;
      case 243: /* trigger_cmd ::= scanpt select scanpt */
{yylhsminor.yy203 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy387, yymsp[-2].minor.yy336, yymsp[0].minor.yy336); /*yylhsminor.yy203-overwrites-yymsp[-1].minor.yy387*/}
  yymsp[-2].minor.yy203 = yylhsminor.yy203;
        break;
      case 244: /* expr ::= RAISE LP IGNORE RP */
{
  yymsp[-3].minor.yy314 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); 
  if( yymsp[-3].minor.yy314 ){
    yymsp[-3].minor.yy314->affinity = OE_Ignore;
  }
}
        break;
      case 245: /* expr ::= RAISE LP raisetype COMMA nm RP */
{
  yymsp[-5].minor.yy314 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); 
  if( yymsp[-5].minor.yy314 ) {
    yymsp[-5].minor.yy314->affinity = (char)yymsp[-3].minor.yy4;
  }
}
        break;
      case 246: /* raisetype ::= ROLLBACK */
{yymsp[0].minor.yy4 = OE_Rollback;}
        break;
      case 248: /* raisetype ::= FAIL */
{yymsp[0].minor.yy4 = OE_Fail;}
        break;
      case 249: /* cmd ::= DROP TRIGGER ifexists fullname */
{
  sqlite3DropTrigger(pParse,yymsp[0].minor.yy259,yymsp[-1].minor.yy4);
}
        break;
      case 250: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
{
  sqlite3Attach(pParse, yymsp[-3].minor.yy314, yymsp[-1].minor.yy314, yymsp[0].minor.yy314);
}
        break;
      case 251: /* cmd ::= DETACH database_kw_opt expr */
{
  sqlite3Detach(pParse, yymsp[0].minor.yy314);
}
        break;
      case 254: /* cmd ::= REINDEX */
{sqlite3Reindex(pParse, 0, 0);}
        break;
      case 255: /* cmd ::= REINDEX nm dbnm */
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
        break;
      case 256: /* cmd ::= ANALYZE */
{sqlite3Analyze(pParse, 0, 0);}
        break;
      case 257: /* cmd ::= ANALYZE nm dbnm */
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
        break;
      case 258: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
{
  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy259,&yymsp[0].minor.yy0);
}
        break;
      case 259: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
{
  yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
  sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
}
        break;
      case 260: /* add_column_fullname ::= fullname */
{
  disableLookaside(pParse);
  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy259);
}
        break;
      case 261: /* cmd ::= create_vtab */
{sqlite3VtabFinishParse(pParse,0);}
        break;
      case 262: /* cmd ::= create_vtab LP vtabarglist RP */
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
        break;
      case 263: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
{
    sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy4);
}
        break;
      case 264: /* vtabarg ::= */
{sqlite3VtabArgInit(pParse);}
        break;
      case 265: /* vtabargtoken ::= ANY */
      case 266: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==266);
      case 267: /* lp ::= LP */ yytestcase(yyruleno==267);
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
        break;
      case 268: /* with ::= */
{yymsp[1].minor.yy451 = 0;}
        break;
      case 269: /* with ::= WITH wqlist */
{ yymsp[-1].minor.yy451 = yymsp[0].minor.yy451; }
        break;
      case 270: /* with ::= WITH RECURSIVE wqlist */
{ yymsp[-2].minor.yy451 = yymsp[0].minor.yy451; }
        break;
      case 271: /* wqlist ::= nm eidlist_opt AS LP select RP */
{
  yymsp[-5].minor.yy451 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy322, yymsp[-1].minor.yy387); /*A-overwrites-X*/
}
        break;
      case 272: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
{
  yymsp[-7].minor.yy451 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy451, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy322, yymsp[-1].minor.yy387);
}
        break;
      default:
      /* (273) input ::= cmdlist */ yytestcase(yyruleno==273);
      /* (274) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==274);
      /* (275) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=275);
      /* (276) ecmd ::= SEMI */ yytestcase(yyruleno==276);
      /* (277) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==277);
      /* (278) explain ::= */ yytestcase(yyruleno==278);
      /* (279) trans_opt ::= */ yytestcase(yyruleno==279);
      /* (280) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==280);
      /* (281) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==281);
      /* (282) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==282);
      /* (283) savepoint_opt ::= */ yytestcase(yyruleno==283);
      /* (284) cmd ::= create_table create_table_args */ yytestcase(yyruleno==284);
      /* (285) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==285);
      /* (286) columnlist ::= columnname carglist */ yytestcase(yyruleno==286);
      /* (287) nm ::= ID|INDEXED */ yytestcase(yyruleno==287);
      /* (288) nm ::= STRING */ yytestcase(yyruleno==288);
      /* (289) nm ::= JOIN_KW */ yytestcase(yyruleno==289);
      /* (290) typetoken ::= typename */ yytestcase(yyruleno==290);
      /* (291) typename ::= ID|STRING */ yytestcase(yyruleno==291);
      /* (292) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=292);
      /* (293) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=293);
      /* (294) carglist ::= carglist ccons */ yytestcase(yyruleno==294);
      /* (295) carglist ::= */ yytestcase(yyruleno==295);
      /* (296) ccons ::= NULL onconf */ yytestcase(yyruleno==296);
      /* (297) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==297);
      /* (298) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==298);
      /* (299) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=299);
      /* (300) tconscomma ::= */ yytestcase(yyruleno==300);
      /* (301) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=301);
      /* (302) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=302);
      /* (303) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=303);
      /* (304) oneselect ::= values */ yytestcase(yyruleno==304);
      /* (305) sclp ::= selcollist COMMA */ yytestcase(yyruleno==305);
      /* (306) as ::= ID|STRING */ yytestcase(yyruleno==306);
      /* (307) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=307);
      /* (308) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==308);
      /* (309) exprlist ::= nexprlist */ yytestcase(yyruleno==309);
      /* (310) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=310);
      /* (311) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=311);
      /* (312) nmnum ::= ON */ yytestcase(yyruleno==312);
      /* (313) nmnum ::= DELETE */ yytestcase(yyruleno==313);
      /* (314) nmnum ::= DEFAULT */ yytestcase(yyruleno==314);
      /* (315) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==315);
      /* (316) foreach_clause ::= */ yytestcase(yyruleno==316);
      /* (317) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==317);
      /* (318) trnm ::= nm */ yytestcase(yyruleno==318);
      /* (319) tridxby ::= */ yytestcase(yyruleno==319);
      /* (320) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==320);
      /* (321) database_kw_opt ::= */ yytestcase(yyruleno==321);
      /* (322) kwcolumn_opt ::= */ yytestcase(yyruleno==322);
      /* (323) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==323);
      /* (324) vtabarglist ::= vtabarg */ yytestcase(yyruleno==324);
      /* (325) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==325);
      /* (326) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==326);
      /* (327) anylist ::= */ yytestcase(yyruleno==327);
      /* (328) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==328);
      /* (329) anylist ::= anylist ANY */ yytestcase(yyruleno==329);

        break;
/********** End reduce actions ************************************************/
  };
  assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);







|





|






|









|






|











|





|





|


|


|


|
|


|






|
|


|


|




|




|


|


|


|


|


|


|


|


|







|





|


|


|


|
|


|


|
|


|
|


|






|





|







|






|






|



|



|



|



|







|







|


|


|




|




|




|


|


|


|


|




|





|





|


|


|




|


|
|
|


<
<
<
|
<
<
|
|

|




|





|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>







143113
143114
143115
143116
143117
143118
143119
143120
143121
143122
143123
143124
143125
143126
143127
143128
143129
143130
143131
143132
143133
143134
143135
143136
143137
143138
143139
143140
143141
143142
143143
143144
143145
143146
143147
143148
143149
143150
143151
143152
143153
143154
143155
143156
143157
143158
143159
143160
143161
143162
143163
143164
143165
143166
143167
143168
143169
143170
143171
143172
143173
143174
143175
143176
143177
143178
143179
143180
143181
143182
143183
143184
143185
143186
143187
143188
143189
143190
143191
143192
143193
143194
143195
143196
143197
143198
143199
143200
143201
143202
143203
143204
143205
143206
143207
143208
143209
143210
143211
143212
143213
143214
143215
143216
143217
143218
143219
143220
143221
143222
143223
143224
143225
143226
143227
143228
143229
143230
143231
143232
143233
143234
143235
143236
143237
143238
143239
143240
143241
143242
143243
143244
143245
143246
143247
143248
143249
143250
143251
143252
143253
143254
143255
143256
143257
143258
143259
143260
143261
143262
143263
143264
143265
143266
143267
143268
143269
143270
143271
143272
143273
143274
143275
143276
143277
143278
143279
143280
143281
143282
143283
143284
143285
143286
143287
143288
143289
143290
143291
143292
143293
143294
143295
143296
143297
143298
143299
143300
143301
143302
143303
143304
143305
143306
143307
143308
143309
143310
143311
143312
143313
143314
143315
143316
143317
143318
143319
143320
143321
143322
143323
143324
143325
143326
143327
143328
143329
143330
143331
143332
143333
143334
143335
143336
143337
143338
143339
143340
143341
143342
143343
143344
143345
143346
143347
143348
143349
143350
143351
143352
143353
143354
143355
143356
143357
143358
143359
143360
143361
143362
143363
143364
143365
143366
143367
143368
143369
143370
143371
143372
143373
143374
143375
143376
143377
143378
143379
143380
143381
143382
143383
143384
143385
143386
143387
143388
143389
143390
143391
143392
143393
143394
143395
143396
143397
143398
143399
143400
143401
143402
143403
143404
143405
143406
143407
143408



143409


143410
143411
143412
143413
143414
143415
143416
143417
143418
143419
143420
143421
143422
143423
143424
143425
143426
143427
143428
143429
143430
143431
143432
143433
143434
143435
143436
143437
143438
143439
143440
143441
143442
143443
143444
143445
143446
143447
143448
143449
143450
143451
143452
143453
143454
143455
143456
143457
143458
143459
143460
143461
143462
143463
143464
143465
143466
143467
143468
143469
143470
143471
143472
143473
143474
143475
143476
143477
143478
143479
143480
143481
143482
143483
143484
143485
143486
143487
143488
      }else{
        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
      }
      if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
    }
  }
        break;
      case 193: /* expr ::= LP select RP */
{
    yymsp[-2].minor.yy314 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy314, yymsp[-1].minor.yy387);
  }
        break;
      case 194: /* expr ::= expr in_op LP select RP */
{
    yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy314, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy314, yymsp[-1].minor.yy387);
    if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
  }
        break;
      case 195: /* expr ::= expr in_op nm dbnm paren_exprlist */
{
    SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
    Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
    if( yymsp[0].minor.yy322 )  sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy322);
    yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy314, 0);
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy314, pSelect);
    if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
  }
        break;
      case 196: /* expr ::= EXISTS LP select RP */
{
    Expr *p;
    p = yymsp[-3].minor.yy314 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
    sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy387);
  }
        break;
      case 197: /* expr ::= CASE case_operand case_exprlist case_else END */
{
  yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy314, 0);
  if( yymsp[-4].minor.yy314 ){
    yymsp[-4].minor.yy314->x.pList = yymsp[-1].minor.yy314 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[-1].minor.yy314) : yymsp[-2].minor.yy322;
    sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy314);
  }else{
    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322);
    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy314);
  }
}
        break;
      case 198: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
{
  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy314);
  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[0].minor.yy314);
}
        break;
      case 199: /* case_exprlist ::= WHEN expr THEN expr */
{
  yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy314);
  yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, yymsp[0].minor.yy314);
}
        break;
      case 202: /* case_operand ::= expr */
{yymsp[0].minor.yy314 = yymsp[0].minor.yy314; /*A-overwrites-X*/}
        break;
      case 205: /* nexprlist ::= nexprlist COMMA expr */
{yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy314);}
        break;
      case 206: /* nexprlist ::= expr */
{yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy314); /*A-overwrites-Y*/}
        break;
      case 208: /* paren_exprlist ::= LP exprlist RP */
      case 213: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==213);
{yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;}
        break;
      case 209: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
{
  sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, 
                     sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy4,
                      &yymsp[-11].minor.yy0, yymsp[0].minor.yy314, SQLITE_SO_ASC, yymsp[-8].minor.yy4, SQLITE_IDXTYPE_APPDEF);
}
        break;
      case 210: /* uniqueflag ::= UNIQUE */
      case 250: /* raisetype ::= ABORT */ yytestcase(yyruleno==250);
{yymsp[0].minor.yy4 = OE_Abort;}
        break;
      case 211: /* uniqueflag ::= */
{yymsp[1].minor.yy4 = OE_None;}
        break;
      case 214: /* eidlist ::= eidlist COMMA nm collate sortorder */
{
  yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy4, yymsp[0].minor.yy4);
}
        break;
      case 215: /* eidlist ::= nm collate sortorder */
{
  yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy4, yymsp[0].minor.yy4); /*A-overwrites-Y*/
}
        break;
      case 218: /* cmd ::= DROP INDEX ifexists fullname */
{sqlite3DropIndex(pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4);}
        break;
      case 219: /* cmd ::= VACUUM */
{sqlite3Vacuum(pParse,0);}
        break;
      case 220: /* cmd ::= VACUUM nm */
{sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
        break;
      case 221: /* cmd ::= PRAGMA nm dbnm */
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
        break;
      case 222: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
        break;
      case 223: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
        break;
      case 224: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
        break;
      case 225: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
        break;
      case 228: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
{
  Token all;
  all.z = yymsp[-3].minor.yy0.z;
  all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
  sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy203, &all);
}
        break;
      case 229: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
{
  sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy4, yymsp[-4].minor.yy90.a, yymsp[-4].minor.yy90.b, yymsp[-2].minor.yy259, yymsp[0].minor.yy314, yymsp[-10].minor.yy4, yymsp[-8].minor.yy4);
  yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
}
        break;
      case 230: /* trigger_time ::= BEFORE|AFTER */
{ yymsp[0].minor.yy4 = yymsp[0].major; /*A-overwrites-X*/ }
        break;
      case 231: /* trigger_time ::= INSTEAD OF */
{ yymsp[-1].minor.yy4 = TK_INSTEAD;}
        break;
      case 232: /* trigger_time ::= */
{ yymsp[1].minor.yy4 = TK_BEFORE; }
        break;
      case 233: /* trigger_event ::= DELETE|INSERT */
      case 234: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==234);
{yymsp[0].minor.yy90.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy90.b = 0;}
        break;
      case 235: /* trigger_event ::= UPDATE OF idlist */
{yymsp[-2].minor.yy90.a = TK_UPDATE; yymsp[-2].minor.yy90.b = yymsp[0].minor.yy384;}
        break;
      case 236: /* when_clause ::= */
      case 255: /* key_opt ::= */ yytestcase(yyruleno==255);
{ yymsp[1].minor.yy314 = 0; }
        break;
      case 237: /* when_clause ::= WHEN expr */
      case 256: /* key_opt ::= KEY expr */ yytestcase(yyruleno==256);
{ yymsp[-1].minor.yy314 = yymsp[0].minor.yy314; }
        break;
      case 238: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
{
  assert( yymsp[-2].minor.yy203!=0 );
  yymsp[-2].minor.yy203->pLast->pNext = yymsp[-1].minor.yy203;
  yymsp[-2].minor.yy203->pLast = yymsp[-1].minor.yy203;
}
        break;
      case 239: /* trigger_cmd_list ::= trigger_cmd SEMI */
{ 
  assert( yymsp[-1].minor.yy203!=0 );
  yymsp[-1].minor.yy203->pLast = yymsp[-1].minor.yy203;
}
        break;
      case 240: /* trnm ::= nm DOT nm */
{
  yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
  sqlite3ErrorMsg(pParse, 
        "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
        "statements within triggers");
}
        break;
      case 241: /* tridxby ::= INDEXED BY nm */
{
  sqlite3ErrorMsg(pParse,
        "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
        "within triggers");
}
        break;
      case 242: /* tridxby ::= NOT INDEXED */
{
  sqlite3ErrorMsg(pParse,
        "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
        "within triggers");
}
        break;
      case 243: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
{yylhsminor.yy203 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy314, yymsp[-6].minor.yy4, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy336);}
  yymsp[-7].minor.yy203 = yylhsminor.yy203;
        break;
      case 244: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select scanpt */
{yylhsminor.yy203 = sqlite3TriggerInsertStep(pParse->db,&yymsp[-3].minor.yy0,yymsp[-2].minor.yy384,yymsp[-1].minor.yy387,yymsp[-5].minor.yy4,yymsp[-6].minor.yy336,yymsp[0].minor.yy336);/*yylhsminor.yy203-overwrites-yymsp[-5].minor.yy4*/}
  yymsp[-6].minor.yy203 = yylhsminor.yy203;
        break;
      case 245: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
{yylhsminor.yy203 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy314, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy336);}
  yymsp[-5].minor.yy203 = yylhsminor.yy203;
        break;
      case 246: /* trigger_cmd ::= scanpt select scanpt */
{yylhsminor.yy203 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy387, yymsp[-2].minor.yy336, yymsp[0].minor.yy336); /*yylhsminor.yy203-overwrites-yymsp[-1].minor.yy387*/}
  yymsp[-2].minor.yy203 = yylhsminor.yy203;
        break;
      case 247: /* expr ::= RAISE LP IGNORE RP */
{
  yymsp[-3].minor.yy314 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); 
  if( yymsp[-3].minor.yy314 ){
    yymsp[-3].minor.yy314->affinity = OE_Ignore;
  }
}
        break;
      case 248: /* expr ::= RAISE LP raisetype COMMA nm RP */
{
  yymsp[-5].minor.yy314 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); 
  if( yymsp[-5].minor.yy314 ) {
    yymsp[-5].minor.yy314->affinity = (char)yymsp[-3].minor.yy4;
  }
}
        break;
      case 249: /* raisetype ::= ROLLBACK */
{yymsp[0].minor.yy4 = OE_Rollback;}
        break;
      case 251: /* raisetype ::= FAIL */
{yymsp[0].minor.yy4 = OE_Fail;}
        break;
      case 252: /* cmd ::= DROP TRIGGER ifexists fullname */
{
  sqlite3DropTrigger(pParse,yymsp[0].minor.yy259,yymsp[-1].minor.yy4);
}
        break;
      case 253: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
{
  sqlite3Attach(pParse, yymsp[-3].minor.yy314, yymsp[-1].minor.yy314, yymsp[0].minor.yy314);
}
        break;
      case 254: /* cmd ::= DETACH database_kw_opt expr */
{
  sqlite3Detach(pParse, yymsp[0].minor.yy314);
}
        break;
      case 257: /* cmd ::= REINDEX */
{sqlite3Reindex(pParse, 0, 0);}
        break;
      case 258: /* cmd ::= REINDEX nm dbnm */
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
        break;
      case 259: /* cmd ::= ANALYZE */
{sqlite3Analyze(pParse, 0, 0);}
        break;
      case 260: /* cmd ::= ANALYZE nm dbnm */
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
        break;
      case 261: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
{
  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy259,&yymsp[0].minor.yy0);
}
        break;
      case 262: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
{
  yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
  sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
}
        break;
      case 263: /* add_column_fullname ::= fullname */
{
  disableLookaside(pParse);
  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy259);
}
        break;
      case 264: /* cmd ::= create_vtab */
{sqlite3VtabFinishParse(pParse,0);}
        break;
      case 265: /* cmd ::= create_vtab LP vtabarglist RP */
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
        break;
      case 266: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
{
    sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy4);
}
        break;
      case 267: /* vtabarg ::= */
{sqlite3VtabArgInit(pParse);}
        break;
      case 268: /* vtabargtoken ::= ANY */
      case 269: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==269);
      case 270: /* lp ::= LP */ yytestcase(yyruleno==270);
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
        break;



      case 271: /* with ::= WITH wqlist */


      case 272: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==272);
{ sqlite3WithPush(pParse, yymsp[0].minor.yy451, 1); }
        break;
      case 273: /* wqlist ::= nm eidlist_opt AS LP select RP */
{
  yymsp[-5].minor.yy451 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy322, yymsp[-1].minor.yy387); /*A-overwrites-X*/
}
        break;
      case 274: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
{
  yymsp[-7].minor.yy451 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy451, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy322, yymsp[-1].minor.yy387);
}
        break;
      default:
      /* (275) input ::= cmdlist */ yytestcase(yyruleno==275);
      /* (276) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==276);
      /* (277) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=277);
      /* (278) ecmd ::= SEMI */ yytestcase(yyruleno==278);
      /* (279) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==279);
      /* (280) explain ::= */ yytestcase(yyruleno==280);
      /* (281) trans_opt ::= */ yytestcase(yyruleno==281);
      /* (282) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==282);
      /* (283) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==283);
      /* (284) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==284);
      /* (285) savepoint_opt ::= */ yytestcase(yyruleno==285);
      /* (286) cmd ::= create_table create_table_args */ yytestcase(yyruleno==286);
      /* (287) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==287);
      /* (288) columnlist ::= columnname carglist */ yytestcase(yyruleno==288);
      /* (289) nm ::= ID|INDEXED */ yytestcase(yyruleno==289);
      /* (290) nm ::= STRING */ yytestcase(yyruleno==290);
      /* (291) nm ::= JOIN_KW */ yytestcase(yyruleno==291);
      /* (292) typetoken ::= typename */ yytestcase(yyruleno==292);
      /* (293) typename ::= ID|STRING */ yytestcase(yyruleno==293);
      /* (294) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
      /* (295) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=295);
      /* (296) carglist ::= carglist ccons */ yytestcase(yyruleno==296);
      /* (297) carglist ::= */ yytestcase(yyruleno==297);
      /* (298) ccons ::= NULL onconf */ yytestcase(yyruleno==298);
      /* (299) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==299);
      /* (300) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==300);
      /* (301) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=301);
      /* (302) tconscomma ::= */ yytestcase(yyruleno==302);
      /* (303) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=303);
      /* (304) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=304);
      /* (305) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=305);
      /* (306) oneselect ::= values */ yytestcase(yyruleno==306);
      /* (307) sclp ::= selcollist COMMA */ yytestcase(yyruleno==307);
      /* (308) as ::= ID|STRING */ yytestcase(yyruleno==308);
      /* (309) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=309);
      /* (310) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==310);
      /* (311) exprlist ::= nexprlist */ yytestcase(yyruleno==311);
      /* (312) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=312);
      /* (313) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=313);
      /* (314) nmnum ::= ON */ yytestcase(yyruleno==314);
      /* (315) nmnum ::= DELETE */ yytestcase(yyruleno==315);
      /* (316) nmnum ::= DEFAULT */ yytestcase(yyruleno==316);
      /* (317) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==317);
      /* (318) foreach_clause ::= */ yytestcase(yyruleno==318);
      /* (319) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==319);
      /* (320) trnm ::= nm */ yytestcase(yyruleno==320);
      /* (321) tridxby ::= */ yytestcase(yyruleno==321);
      /* (322) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==322);
      /* (323) database_kw_opt ::= */ yytestcase(yyruleno==323);
      /* (324) kwcolumn_opt ::= */ yytestcase(yyruleno==324);
      /* (325) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==325);
      /* (326) vtabarglist ::= vtabarg */ yytestcase(yyruleno==326);
      /* (327) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==327);
      /* (328) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==328);
      /* (329) anylist ::= */ yytestcase(yyruleno==329);
      /* (330) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==330);
      /* (331) anylist ::= anylist ANY */ yytestcase(yyruleno==331);
      /* (332) with ::= */ yytestcase(yyruleno==332);
        break;
/********** End reduce actions ************************************************/
  };
  assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
146144
146145
146146
146147
146148
146149
146150



146151
146152
146153
146154

146155
146156


146157
146158
146159
146160
146161
146162
146163
146164
146165













146166
146167
146168
146169
146170
146171
146172
146173
146174
146175
146176
146177
146178
146179
146180


146181
146182

146183
146184
146185
146186
146187
146188
146189
146190
146191
146192
146193
146194


146195
146196
146197
146198
146199
146200








146201

146202
146203
146204
146205
146206
146207
146208
}

/*
** This routine implements a busy callback that sleeps and tries
** again until a timeout value is reached.  The timeout value is
** an integer number of milliseconds passed in as the first
** argument.



*/
static int sqliteDefaultBusyCallback(
 void *ptr,               /* Database connection */
 int count                /* Number of times table has been busy */

){
#if SQLITE_OS_WIN || HAVE_USLEEP


  static const u8 delays[] =
     { 1, 2, 5, 10, 15, 20, 25, 25,  25,  50,  50, 100 };
  static const u8 totals[] =
     { 0, 1, 3,  8, 18, 33, 53, 78, 103, 128, 178, 228 };
# define NDELAY ArraySize(delays)
  sqlite3 *db = (sqlite3 *)ptr;
  int timeout = db->busyTimeout;
  int delay, prior;














  assert( count>=0 );
  if( count < NDELAY ){
    delay = delays[count];
    prior = totals[count];
  }else{
    delay = delays[NDELAY-1];
    prior = totals[NDELAY-1] + delay*(count-(NDELAY-1));
  }
  if( prior + delay > timeout ){
    delay = timeout - prior;
    if( delay<=0 ) return 0;
  }
  sqlite3OsSleep(db->pVfs, delay*1000);
  return 1;
#else


  sqlite3 *db = (sqlite3 *)ptr;
  int timeout = ((sqlite3 *)ptr)->busyTimeout;

  if( (count+1)*1000 > timeout ){
    return 0;
  }
  sqlite3OsSleep(db->pVfs, 1000000);
  return 1;
#endif
}

/*
** Invoke the given busy handler.
**
** This routine is called when an operation failed with a lock.


** If this routine returns non-zero, the lock is retried.  If it
** returns 0, the operation aborts with an SQLITE_BUSY error.
*/
SQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler *p){
  int rc;
  if( NEVER(p==0) || p->xFunc==0 || p->nBusy<0 ) return 0;








  rc = p->xFunc(p->pArg, p->nBusy);

  if( rc==0 ){
    p->nBusy = -1;
  }else{
    p->nBusy++;
  }
  return rc; 
}







>
>
>


|
|
>


>
>






|


>
>
>
>
>
>
>
>
>
>
>
>
>








|
|





>
>

|
>
|










|
>
>



|

|
>
>
>
>
>
>
>
>
|
>







146538
146539
146540
146541
146542
146543
146544
146545
146546
146547
146548
146549
146550
146551
146552
146553
146554
146555
146556
146557
146558
146559
146560
146561
146562
146563
146564
146565
146566
146567
146568
146569
146570
146571
146572
146573
146574
146575
146576
146577
146578
146579
146580
146581
146582
146583
146584
146585
146586
146587
146588
146589
146590
146591
146592
146593
146594
146595
146596
146597
146598
146599
146600
146601
146602
146603
146604
146605
146606
146607
146608
146609
146610
146611
146612
146613
146614
146615
146616
146617
146618
146619
146620
146621
146622
146623
146624
146625
146626
146627
146628
146629
146630
146631
146632
146633
146634
146635
}

/*
** This routine implements a busy callback that sleeps and tries
** again until a timeout value is reached.  The timeout value is
** an integer number of milliseconds passed in as the first
** argument.
**
** Return non-zero to retry the lock.  Return zero to stop trying
** and cause SQLite to return SQLITE_BUSY.
*/
static int sqliteDefaultBusyCallback(
  void *ptr,               /* Database connection */
  int count,               /* Number of times table has been busy */
  sqlite3_file *pFile      /* The file on which the lock occurred */
){
#if SQLITE_OS_WIN || HAVE_USLEEP
  /* This case is for systems that have support for sleeping for fractions of
  ** a second.  Examples:  All windows systems, unix systems with usleep() */
  static const u8 delays[] =
     { 1, 2, 5, 10, 15, 20, 25, 25,  25,  50,  50, 100 };
  static const u8 totals[] =
     { 0, 1, 3,  8, 18, 33, 53, 78, 103, 128, 178, 228 };
# define NDELAY ArraySize(delays)
  sqlite3 *db = (sqlite3 *)ptr;
  int tmout = db->busyTimeout;
  int delay, prior;

#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
  if( sqlite3OsFileControl(pFile,SQLITE_FCNTL_LOCK_TIMEOUT,&tmout)==SQLITE_OK ){
    if( count ){
      tmout = 0;
      sqlite3OsFileControl(pFile, SQLITE_FCNTL_LOCK_TIMEOUT, &tmout);
      return 0;
    }else{
      return 1;
    }
  }
#else
  UNUSED_PARAMETER(pFile);
#endif
  assert( count>=0 );
  if( count < NDELAY ){
    delay = delays[count];
    prior = totals[count];
  }else{
    delay = delays[NDELAY-1];
    prior = totals[NDELAY-1] + delay*(count-(NDELAY-1));
  }
  if( prior + delay > tmout ){
    delay = tmout - prior;
    if( delay<=0 ) return 0;
  }
  sqlite3OsSleep(db->pVfs, delay*1000);
  return 1;
#else
  /* This case for unix systems that lack usleep() support.  Sleeping
  ** must be done in increments of whole seconds */
  sqlite3 *db = (sqlite3 *)ptr;
  int tmout = ((sqlite3 *)ptr)->busyTimeout;
  UNUSED_PARAMETER(pFile);
  if( (count+1)*1000 > tmout ){
    return 0;
  }
  sqlite3OsSleep(db->pVfs, 1000000);
  return 1;
#endif
}

/*
** Invoke the given busy handler.
**
** This routine is called when an operation failed to acquire a
** lock on VFS file pFile.
**
** If this routine returns non-zero, the lock is retried.  If it
** returns 0, the operation aborts with an SQLITE_BUSY error.
*/
SQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler *p, sqlite3_file *pFile){
  int rc;
  if( p->xBusyHandler==0 || p->nBusy<0 ) return 0;
  if( p->bExtraFileArg ){
    /* Add an extra parameter with the pFile pointer to the end of the
    ** callback argument list */
    int (*xTra)(void*,int,sqlite3_file*);
    xTra = (int(*)(void*,int,sqlite3_file*))p->xBusyHandler;
    rc = xTra(p->pBusyArg, p->nBusy, pFile);
  }else{
    /* Legacy style busy handler callback */
    rc = p->xBusyHandler(p->pBusyArg, p->nBusy);
  }
  if( rc==0 ){
    p->nBusy = -1;
  }else{
    p->nBusy++;
  }
  return rc; 
}
146216
146217
146218
146219
146220
146221
146222
146223
146224
146225

146226
146227
146228
146229
146230
146231
146232
  int (*xBusy)(void*,int),
  void *pArg
){
#ifdef SQLITE_ENABLE_API_ARMOR
  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
#endif
  sqlite3_mutex_enter(db->mutex);
  db->busyHandler.xFunc = xBusy;
  db->busyHandler.pArg = pArg;
  db->busyHandler.nBusy = 0;

  db->busyTimeout = 0;
  sqlite3_mutex_leave(db->mutex);
  return SQLITE_OK;
}

#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
/*







|
|

>







146643
146644
146645
146646
146647
146648
146649
146650
146651
146652
146653
146654
146655
146656
146657
146658
146659
146660
  int (*xBusy)(void*,int),
  void *pArg
){
#ifdef SQLITE_ENABLE_API_ARMOR
  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
#endif
  sqlite3_mutex_enter(db->mutex);
  db->busyHandler.xBusyHandler = xBusy;
  db->busyHandler.pBusyArg = pArg;
  db->busyHandler.nBusy = 0;
  db->busyHandler.bExtraFileArg = 0;
  db->busyTimeout = 0;
  sqlite3_mutex_leave(db->mutex);
  return SQLITE_OK;
}

#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
/*
146266
146267
146268
146269
146270
146271
146272
146273

146274

146275
146276
146277
146278
146279
146280
146281
** specified number of milliseconds before returning 0.
*/
SQLITE_API int sqlite3_busy_timeout(sqlite3 *db, int ms){
#ifdef SQLITE_ENABLE_API_ARMOR
  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
#endif
  if( ms>0 ){
    sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void*)db);

    db->busyTimeout = ms;

  }else{
    sqlite3_busy_handler(db, 0, 0);
  }
  return SQLITE_OK;
}

/*







|
>

>







146694
146695
146696
146697
146698
146699
146700
146701
146702
146703
146704
146705
146706
146707
146708
146709
146710
146711
** specified number of milliseconds before returning 0.
*/
SQLITE_API int sqlite3_busy_timeout(sqlite3 *db, int ms){
#ifdef SQLITE_ENABLE_API_ARMOR
  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
#endif
  if( ms>0 ){
    sqlite3_busy_handler(db, (int(*)(void*,int))sqliteDefaultBusyCallback,
                             (void*)db);
    db->busyTimeout = ms;
    db->busyHandler.bExtraFileArg = 1;
  }else{
    sqlite3_busy_handler(db, 0, 0);
  }
  return SQLITE_OK;
}

/*
148260
148261
148262
148263
148264
148265
148266
148267
148268
148269
148270
148271
148272
148273
148274
148275
148276
148277
      rc = SQLITE_OK;
    }else if( op==SQLITE_FCNTL_VFS_POINTER ){
      *(sqlite3_vfs**)pArg = sqlite3PagerVfs(pPager);
      rc = SQLITE_OK;
    }else if( op==SQLITE_FCNTL_JOURNAL_POINTER ){
      *(sqlite3_file**)pArg = sqlite3PagerJrnlFile(pPager);
      rc = SQLITE_OK;
    }else if( fd->pMethods ){
      rc = sqlite3OsFileControl(fd, op, pArg);
    }else{
      rc = SQLITE_NOTFOUND;
    }
    sqlite3BtreeLeave(pBtree);
  }
  sqlite3_mutex_leave(db->mutex);
  return rc;
}








|

<
<







148690
148691
148692
148693
148694
148695
148696
148697
148698


148699
148700
148701
148702
148703
148704
148705
      rc = SQLITE_OK;
    }else if( op==SQLITE_FCNTL_VFS_POINTER ){
      *(sqlite3_vfs**)pArg = sqlite3PagerVfs(pPager);
      rc = SQLITE_OK;
    }else if( op==SQLITE_FCNTL_JOURNAL_POINTER ){
      *(sqlite3_file**)pArg = sqlite3PagerJrnlFile(pPager);
      rc = SQLITE_OK;
    }else{
      rc = sqlite3OsFileControl(fd, op, pArg);


    }
    sqlite3BtreeLeave(pBtree);
  }
  sqlite3_mutex_leave(db->mutex);
  return rc;
}

179334
179335
179336
179337
179338
179339
179340
179341
179342
179343
179344
179345
179346
179347
179348
  pCsr->iOffset = (i64)pCsr->szPage * (pCsr->iPageno - 1);

  /* If connected to a ZIPVFS backend, override the page size and
  ** offset with actual values obtained from ZIPVFS.
  */
  fd = sqlite3PagerFile(pPager);
  x[0] = pCsr->iPageno;
  if( fd->pMethods!=0 && sqlite3OsFileControl(fd, 230440, &x)==SQLITE_OK ){
    pCsr->iOffset = x[0];
    pCsr->szPage = (int)x[1];
  }
}

/*
** Move a statvfs cursor to the next entry in the file.







|







179762
179763
179764
179765
179766
179767
179768
179769
179770
179771
179772
179773
179774
179775
179776
  pCsr->iOffset = (i64)pCsr->szPage * (pCsr->iPageno - 1);

  /* If connected to a ZIPVFS backend, override the page size and
  ** offset with actual values obtained from ZIPVFS.
  */
  fd = sqlite3PagerFile(pPager);
  x[0] = pCsr->iPageno;
  if( sqlite3OsFileControl(fd, 230440, &x)==SQLITE_OK ){
    pCsr->iOffset = x[0];
    pCsr->szPage = (int)x[1];
  }
}

/*
** Move a statvfs cursor to the next entry in the file.
180100
180101
180102
180103
180104
180105
180106
180107
180108
180109
180110
180111
180112
180113
180114
/*
** An object of this type is used internally as an abstraction for 
** input data. Input data may be supplied either as a single large buffer
** (e.g. sqlite3changeset_start()) or using a stream function (e.g.
**  sqlite3changeset_start_strm()).
*/
struct SessionInput {
  int bNoDiscard;                 /* If true, discard no data */
  int iCurrent;                   /* Offset in aData[] of current change */
  int iNext;                      /* Offset in aData[] of next change */
  u8 *aData;                      /* Pointer to buffer containing changeset */
  int nData;                      /* Number of bytes in aData */

  SessionBuffer buf;              /* Current read buffer */
  int (*xInput)(void*, void*, int*);        /* Input stream call (or NULL) */







|







180528
180529
180530
180531
180532
180533
180534
180535
180536
180537
180538
180539
180540
180541
180542
/*
** An object of this type is used internally as an abstraction for 
** input data. Input data may be supplied either as a single large buffer
** (e.g. sqlite3changeset_start()) or using a stream function (e.g.
**  sqlite3changeset_start_strm()).
*/
struct SessionInput {
  int bNoDiscard;                 /* If true, do not discard in InputBuffer() */
  int iCurrent;                   /* Offset in aData[] of current change */
  int iNext;                      /* Offset in aData[] of next change */
  u8 *aData;                      /* Pointer to buffer containing changeset */
  int nData;                      /* Number of bytes in aData */

  SessionBuffer buf;              /* Current read buffer */
  int (*xInput)(void*, void*, int*);        /* Input stream call (or NULL) */
180264
180265
180266
180267
180268
180269
180270
180271
180272
180273
180274
180275
180276
180277
180278
180279
**
** As in the changeset format, each field of the single record that is part
** of a patchset change is associated with the correspondingly positioned
** table column, counting from left to right within the CREATE TABLE 
** statement.
**
** For a DELETE change, all fields within the record except those associated
** with PRIMARY KEY columns are set to "undefined". The PRIMARY KEY fields
** contain the values identifying the row to delete.
**
** For an UPDATE change, all fields except those associated with PRIMARY KEY
** columns and columns that are modified by the UPDATE are set to "undefined".
** PRIMARY KEY fields contain the values identifying the table row to update,
** and fields associated with modified columns contain the new column values.
**
** The records associated with INSERT changes are in the same format as for







|
|







180692
180693
180694
180695
180696
180697
180698
180699
180700
180701
180702
180703
180704
180705
180706
180707
**
** As in the changeset format, each field of the single record that is part
** of a patchset change is associated with the correspondingly positioned
** table column, counting from left to right within the CREATE TABLE 
** statement.
**
** For a DELETE change, all fields within the record except those associated
** with PRIMARY KEY columns are omitted. The PRIMARY KEY fields contain the
** values identifying the row to delete.
**
** For an UPDATE change, all fields except those associated with PRIMARY KEY
** columns and columns that are modified by the UPDATE are set to "undefined".
** PRIMARY KEY fields contain the values identifying the table row to update,
** and fields associated with modified columns contain the new column values.
**
** The records associated with INSERT changes are in the same format as for
180548
180549
180550
180551
180552
180553
180554
180555
180556
180557
180558
180559
180560
180561
180562
** The buffer that the argument points to contains a serialized SQL value.
** Return the number of bytes of space occupied by the value (including
** the type byte).
*/
static int sessionSerialLen(u8 *a){
  int e = *a;
  int n;
  if( e==0 ) return 1;
  if( e==SQLITE_NULL ) return 1;
  if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9;
  return sessionVarintGet(&a[1], &n) + 1 + n;
}

/*
** Based on the primary key values stored in change aRecord, calculate a







|







180976
180977
180978
180979
180980
180981
180982
180983
180984
180985
180986
180987
180988
180989
180990
** The buffer that the argument points to contains a serialized SQL value.
** Return the number of bytes of space occupied by the value (including
** the type byte).
*/
static int sessionSerialLen(u8 *a){
  int e = *a;
  int n;
  if( e==0 || e==0xFF ) return 1;
  if( e==SQLITE_NULL ) return 1;
  if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9;
  return sessionVarintGet(&a[1], &n) + 1 + n;
}

/*
** Based on the primary key values stored in change aRecord, calculate a
180628
180629
180630
180631
180632
180633
180634
180635
180636
180637
180638
180639
180640
180641
180642
  int iCol;                       /* Used to iterate through table columns */

  for(iCol=0; iCol<pTab->nCol; iCol++){
    if( pTab->abPK[iCol] ){
      int n1 = sessionSerialLen(a1);
      int n2 = sessionSerialLen(a2);

      if( pTab->abPK[iCol] && (n1!=n2 || memcmp(a1, a2, n1)) ){
        return 0;
      }
      a1 += n1;
      a2 += n2;
    }else{
      if( bLeftPkOnly==0 ) a1 += sessionSerialLen(a1);
      if( bRightPkOnly==0 ) a2 += sessionSerialLen(a2);







|







181056
181057
181058
181059
181060
181061
181062
181063
181064
181065
181066
181067
181068
181069
181070
  int iCol;                       /* Used to iterate through table columns */

  for(iCol=0; iCol<pTab->nCol; iCol++){
    if( pTab->abPK[iCol] ){
      int n1 = sessionSerialLen(a1);
      int n2 = sessionSerialLen(a2);

      if( n1!=n2 || memcmp(a1, a2, n1) ){
        return 0;
      }
      a1 += n1;
      a2 += n2;
    }else{
      if( bLeftPkOnly==0 ) a1 += sessionSerialLen(a1);
      if( bRightPkOnly==0 ) a2 += sessionSerialLen(a2);
180871
180872
180873
180874
180875
180876
180877
180878
180879
180880
180881
180882
180883
180884
180885
        a += sessionVarintGet(a, &n);
        if( sqlite3_value_bytes(pVal)!=n ) return 0;
        if( eType==SQLITE_TEXT ){
          z = sqlite3_value_text(pVal);
        }else{
          z = sqlite3_value_blob(pVal);
        }
        if( memcmp(a, z, n) ) return 0;
        a += n;
      }
    }
  }

  return 1;
}







|







181299
181300
181301
181302
181303
181304
181305
181306
181307
181308
181309
181310
181311
181312
181313
        a += sessionVarintGet(a, &n);
        if( sqlite3_value_bytes(pVal)!=n ) return 0;
        if( eType==SQLITE_TEXT ){
          z = sqlite3_value_text(pVal);
        }else{
          z = sqlite3_value_blob(pVal);
        }
        if( n>0 && memcmp(a, z, n) ) return 0;
        a += n;
      }
    }
  }

  return 1;
}
182215
182216
182217
182218
182219
182220
182221

182222
182223
182224
182225
182226
182227
182228
  int nSql = -1;

  if( 0==sqlite3_stricmp("sqlite_stat1", zTab) ){
    zSql = sqlite3_mprintf(
        "SELECT tbl, ?2, stat FROM %Q.sqlite_stat1 WHERE tbl IS ?1 AND "
        "idx IS (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)", zDb
    );

  }else{
    int i;
    const char *zSep = "";
    SessionBuffer buf = {0, 0, 0};

    sessionAppendStr(&buf, "SELECT * FROM ", &rc);
    sessionAppendIdent(&buf, zDb, &rc);







>







182643
182644
182645
182646
182647
182648
182649
182650
182651
182652
182653
182654
182655
182656
182657
  int nSql = -1;

  if( 0==sqlite3_stricmp("sqlite_stat1", zTab) ){
    zSql = sqlite3_mprintf(
        "SELECT tbl, ?2, stat FROM %Q.sqlite_stat1 WHERE tbl IS ?1 AND "
        "idx IS (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)", zDb
    );
    if( zSql==0 ) rc = SQLITE_NOMEM;
  }else{
    int i;
    const char *zSep = "";
    SessionBuffer buf = {0, 0, 0};

    sessionAppendStr(&buf, "SELECT * FROM ", &rc);
    sessionAppendIdent(&buf, zDb, &rc);
182624
182625
182626
182627
182628
182629
182630
182631
182632
182633
182634
182635
182636
182637
182638
}

/*
** If the SessionInput object passed as the only argument is a streaming
** object and the buffer is full, discard some data to free up space.
*/
static void sessionDiscardData(SessionInput *pIn){
  if( pIn->bEof && pIn->xInput && pIn->iNext>=SESSIONS_STRM_CHUNK_SIZE ){
    int nMove = pIn->buf.nBuf - pIn->iNext;
    assert( nMove>=0 );
    if( nMove>0 ){
      memmove(pIn->buf.aBuf, &pIn->buf.aBuf[pIn->iNext], nMove);
    }
    pIn->buf.nBuf -= pIn->iNext;
    pIn->iNext = 0;







|







183053
183054
183055
183056
183057
183058
183059
183060
183061
183062
183063
183064
183065
183066
183067
}

/*
** If the SessionInput object passed as the only argument is a streaming
** object and the buffer is full, discard some data to free up space.
*/
static void sessionDiscardData(SessionInput *pIn){
  if( pIn->xInput && pIn->iNext>=SESSIONS_STRM_CHUNK_SIZE ){
    int nMove = pIn->buf.nBuf - pIn->iNext;
    assert( nMove>=0 );
    if( nMove>0 ){
      memmove(pIn->buf.aBuf, &pIn->buf.aBuf[pIn->iNext], nMove);
    }
    pIn->buf.nBuf -= pIn->iNext;
    pIn->iNext = 0;
182950
182951
182952
182953
182954
182955
182956
182957

182958
182959
182960
182961
182962
182963
182964
** successfully advanced to the next change in the changeset, an SQLite 
** error code if an error occurs, or SQLITE_DONE if there are no further 
** changes in the changeset.
*/
static int sessionChangesetNext(
  sqlite3_changeset_iter *p,      /* Changeset iterator */
  u8 **paRec,                     /* If non-NULL, store record pointer here */
  int *pnRec                      /* If non-NULL, store size of record here */

){
  int i;
  u8 op;

  assert( (paRec==0 && pnRec==0) || (paRec && pnRec) );

  /* If the iterator is in the error-state, return immediately. */







|
>







183379
183380
183381
183382
183383
183384
183385
183386
183387
183388
183389
183390
183391
183392
183393
183394
** successfully advanced to the next change in the changeset, an SQLite 
** error code if an error occurs, or SQLITE_DONE if there are no further 
** changes in the changeset.
*/
static int sessionChangesetNext(
  sqlite3_changeset_iter *p,      /* Changeset iterator */
  u8 **paRec,                     /* If non-NULL, store record pointer here */
  int *pnRec,                     /* If non-NULL, store size of record here */
  int *pbNew                      /* If non-NULL, true if new table */
){
  int i;
  u8 op;

  assert( (paRec==0 && pnRec==0) || (paRec && pnRec) );

  /* If the iterator is in the error-state, return immediately. */
182985
182986
182987
182988
182989
182990
182991

182992
182993
182994
182995
182996
182997
182998
  }

  sessionDiscardData(&p->in);
  p->in.iCurrent = p->in.iNext;

  op = p->in.aData[p->in.iNext++];
  while( op=='T' || op=='P' ){

    p->bPatchset = (op=='P');
    if( sessionChangesetReadTblhdr(p) ) return p->rc;
    if( (p->rc = sessionInputBuffer(&p->in, 2)) ) return p->rc;
    p->in.iCurrent = p->in.iNext;
    if( p->in.iNext>=p->in.nData ) return SQLITE_DONE;
    op = p->in.aData[p->in.iNext++];
  }







>







183415
183416
183417
183418
183419
183420
183421
183422
183423
183424
183425
183426
183427
183428
183429
  }

  sessionDiscardData(&p->in);
  p->in.iCurrent = p->in.iNext;

  op = p->in.aData[p->in.iNext++];
  while( op=='T' || op=='P' ){
    if( pbNew ) *pbNew = 1;
    p->bPatchset = (op=='P');
    if( sessionChangesetReadTblhdr(p) ) return p->rc;
    if( (p->rc = sessionInputBuffer(&p->in, 2)) ) return p->rc;
    p->in.iCurrent = p->in.iNext;
    if( p->in.iNext>=p->in.nData ) return SQLITE_DONE;
    op = p->in.aData[p->in.iNext++];
  }
183063
183064
183065
183066
183067
183068
183069
183070
183071
183072
183073
183074
183075
183076
183077
** change in the changeset. This function may return SQLITE_ROW, SQLITE_DONE
** or SQLITE_CORRUPT.
**
** This function may not be called on iterators passed to a conflict handler
** callback by changeset_apply().
*/
SQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *p){
  return sessionChangesetNext(p, 0, 0);
}

/*
** The following function extracts information on the current change
** from a changeset iterator. It may only be called after changeset_next()
** has returned SQLITE_ROW.
*/







|







183494
183495
183496
183497
183498
183499
183500
183501
183502
183503
183504
183505
183506
183507
183508
** change in the changeset. This function may return SQLITE_ROW, SQLITE_DONE
** or SQLITE_CORRUPT.
**
** This function may not be called on iterators passed to a conflict handler
** callback by changeset_apply().
*/
SQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *p){
  return sessionChangesetNext(p, 0, 0, 0);
}

/*
** The following function extracts information on the current change
** from a changeset iterator. It may only be called after changeset_next()
** has returned SQLITE_ROW.
*/
183442
183443
183444
183445
183446
183447
183448


183449
183450
183451
183452
183453
183454
183455
  sqlite3_stmt *pSelect;          /* SELECT statement */
  int nCol;                       /* Size of azCol[] and abPK[] arrays */
  const char **azCol;             /* Array of column names */
  u8 *abPK;                       /* Boolean array - true if column is in PK */
  int bStat1;                     /* True if table is sqlite_stat1 */
  int bDeferConstraints;          /* True to defer constraints */
  SessionBuffer constraints;      /* Deferred constraints are stored here */


};

/*
** Formulate a statement to DELETE a row from database db. Assuming a table
** structure like this:
**
**     CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));







>
>







183873
183874
183875
183876
183877
183878
183879
183880
183881
183882
183883
183884
183885
183886
183887
183888
  sqlite3_stmt *pSelect;          /* SELECT statement */
  int nCol;                       /* Size of azCol[] and abPK[] arrays */
  const char **azCol;             /* Array of column names */
  u8 *abPK;                       /* Boolean array - true if column is in PK */
  int bStat1;                     /* True if table is sqlite_stat1 */
  int bDeferConstraints;          /* True to defer constraints */
  SessionBuffer constraints;      /* Deferred constraints are stored here */
  SessionBuffer rebase;           /* Rebase information (if any) here */
  int bRebaseStarted;             /* If table header is already in rebase */
};

/*
** Formulate a statement to DELETE a row from database db. Assuming a table
** structure like this:
**
**     CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));
183708
183709
183710
183711
183712
183713
183714
183715
183716
183717
183718
183719
183720
183721
183722
  if( rc==SQLITE_OK ){
    rc = sessionPrepare(db, &p->pDelete,
        "DELETE FROM main.sqlite_stat1 WHERE tbl=?1 AND idx IS "
        "CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END "
        "AND (?4 OR stat IS ?3)"
    );
  }
  assert( rc==SQLITE_OK );
  return rc;
}

/*
** A wrapper around sqlite3_bind_value() that detects an extra problem. 
** See comments in the body of this function for details.
*/







<







184141
184142
184143
184144
184145
184146
184147

184148
184149
184150
184151
184152
184153
184154
  if( rc==SQLITE_OK ){
    rc = sessionPrepare(db, &p->pDelete,
        "DELETE FROM main.sqlite_stat1 WHERE tbl=?1 AND idx IS "
        "CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END "
        "AND (?4 OR stat IS ?3)"
    );
  }

  return rc;
}

/*
** A wrapper around sqlite3_bind_value() that detects an extra problem. 
** See comments in the body of this function for details.
*/
183822
183823
183824
183825
183826
183827
183828
















































183829
183830
183831
183832
183833
183834
183835
  if( rc==SQLITE_OK ){
    rc = sqlite3_step(pSelect);
    if( rc!=SQLITE_ROW ) rc = sqlite3_reset(pSelect);
  }

  return rc;
}

















































/*
** Invoke the conflict handler for the change that the changeset iterator
** currently points to.
**
** Argument eType must be either CHANGESET_DATA or CHANGESET_CONFLICT.
** If argument pbReplace is NULL, then the type of conflict handler invoked







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







184254
184255
184256
184257
184258
184259
184260
184261
184262
184263
184264
184265
184266
184267
184268
184269
184270
184271
184272
184273
184274
184275
184276
184277
184278
184279
184280
184281
184282
184283
184284
184285
184286
184287
184288
184289
184290
184291
184292
184293
184294
184295
184296
184297
184298
184299
184300
184301
184302
184303
184304
184305
184306
184307
184308
184309
184310
184311
184312
184313
184314
184315
  if( rc==SQLITE_OK ){
    rc = sqlite3_step(pSelect);
    if( rc!=SQLITE_ROW ) rc = sqlite3_reset(pSelect);
  }

  return rc;
}

/*
** This function is called from within sqlite3changset_apply_v2() when
** a conflict is encountered and resolved using conflict resolution
** mode eType (either SQLITE_CHANGESET_OMIT or SQLITE_CHANGESET_REPLACE)..
** It adds a conflict resolution record to the buffer in 
** SessionApplyCtx.rebase, which will eventually be returned to the caller
** of apply_v2() as the "rebase" buffer.
**
** Return SQLITE_OK if successful, or an SQLite error code otherwise.
*/
static int sessionRebaseAdd(
  SessionApplyCtx *p,             /* Apply context */
  int eType,                      /* Conflict resolution (OMIT or REPLACE) */
  sqlite3_changeset_iter *pIter   /* Iterator pointing at current change */
){
  int rc = SQLITE_OK;
  int i;
  int eOp = pIter->op;
  if( p->bRebaseStarted==0 ){
    /* Append a table-header to the rebase buffer */
    const char *zTab = pIter->zTab;
    sessionAppendByte(&p->rebase, 'T', &rc);
    sessionAppendVarint(&p->rebase, p->nCol, &rc);
    sessionAppendBlob(&p->rebase, p->abPK, p->nCol, &rc);
    sessionAppendBlob(&p->rebase, (u8*)zTab, (int)strlen(zTab)+1, &rc);
    p->bRebaseStarted = 1;
  }

  assert( eType==SQLITE_CHANGESET_REPLACE||eType==SQLITE_CHANGESET_OMIT );
  assert( eOp==SQLITE_DELETE || eOp==SQLITE_INSERT || eOp==SQLITE_UPDATE );

  sessionAppendByte(&p->rebase, 
      (eOp==SQLITE_DELETE ? SQLITE_DELETE : SQLITE_INSERT), &rc
  );
  sessionAppendByte(&p->rebase, (eType==SQLITE_CHANGESET_REPLACE), &rc);
  for(i=0; i<p->nCol; i++){
    sqlite3_value *pVal = 0;
    if( eOp==SQLITE_DELETE || (eOp==SQLITE_UPDATE && p->abPK[i]) ){
      sqlite3changeset_old(pIter, i, &pVal);
    }else{
      sqlite3changeset_new(pIter, i, &pVal);
    }
    sessionAppendValue(&p->rebase, pVal, &rc);
  }

  return rc;
}

/*
** Invoke the conflict handler for the change that the changeset iterator
** currently points to.
**
** Argument eType must be either CHANGESET_DATA or CHANGESET_CONFLICT.
** If argument pbReplace is NULL, then the type of conflict handler invoked
183898
183899
183900
183901
183902
183903
183904
183905
183906
183907
183908
183909
183910
183911
183912
  }else if( rc==SQLITE_OK ){
    if( p->bDeferConstraints && eType==SQLITE_CHANGESET_CONFLICT ){
      /* Instead of invoking the conflict handler, append the change blob
      ** to the SessionApplyCtx.constraints buffer. */
      u8 *aBlob = &pIter->in.aData[pIter->in.iCurrent];
      int nBlob = pIter->in.iNext - pIter->in.iCurrent;
      sessionAppendBlob(&p->constraints, aBlob, nBlob, &rc);
      res = SQLITE_CHANGESET_OMIT;
    }else{
      /* No other row with the new.* primary key. */
      res = xConflict(pCtx, eType+1, pIter);
      if( res==SQLITE_CHANGESET_REPLACE ) rc = SQLITE_MISUSE;
    }
  }








|







184378
184379
184380
184381
184382
184383
184384
184385
184386
184387
184388
184389
184390
184391
184392
  }else if( rc==SQLITE_OK ){
    if( p->bDeferConstraints && eType==SQLITE_CHANGESET_CONFLICT ){
      /* Instead of invoking the conflict handler, append the change blob
      ** to the SessionApplyCtx.constraints buffer. */
      u8 *aBlob = &pIter->in.aData[pIter->in.iCurrent];
      int nBlob = pIter->in.iNext - pIter->in.iCurrent;
      sessionAppendBlob(&p->constraints, aBlob, nBlob, &rc);
      return SQLITE_OK;
    }else{
      /* No other row with the new.* primary key. */
      res = xConflict(pCtx, eType+1, pIter);
      if( res==SQLITE_CHANGESET_REPLACE ) rc = SQLITE_MISUSE;
    }
  }

183924
183925
183926
183927
183928
183929
183930



183931
183932
183933
183934
183935
183936
183937
        rc = SQLITE_ABORT;
        break;

      default:
        rc = SQLITE_MISUSE;
        break;
    }



  }

  return rc;
}

/*
** Attempt to apply the change that the iterator passed as the first argument







>
>
>







184404
184405
184406
184407
184408
184409
184410
184411
184412
184413
184414
184415
184416
184417
184418
184419
184420
        rc = SQLITE_ABORT;
        break;

      default:
        rc = SQLITE_MISUSE;
        break;
    }
    if( rc==SQLITE_OK ){
      rc = sessionRebaseAdd(p, res, pIter);
    }
  }

  return rc;
}

/*
** Attempt to apply the change that the iterator passed as the first argument
184099
184100
184101
184102
184103
184104
184105
184106
184107
184108
184109
184110
184111
184112
184113
184114
184115
184116
184117
184118
184119
184120
184121
184122
184123
184124
184125
184126
184127
184128
184129
184130
184131
184132
184133
184134
184135
184136
184137
184138
184139
184140
184141

184142
184143
184144
184145
184146
184147
184148
  void *pCtx                      /* First argument passed to xConflict */
){
  int bReplace = 0;
  int bRetry = 0;
  int rc;

  rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, &bReplace, &bRetry);
  assert( rc==SQLITE_OK || (bRetry==0 && bReplace==0) );

  /* If the bRetry flag is set, the change has not been applied due to an
  ** SQLITE_CHANGESET_DATA problem (i.e. this is an UPDATE or DELETE and
  ** a row with the correct PK is present in the db, but one or more other
  ** fields do not contain the expected values) and the conflict handler 
  ** returned SQLITE_CHANGESET_REPLACE. In this case retry the operation,
  ** but pass NULL as the final argument so that sessionApplyOneOp() ignores
  ** the SQLITE_CHANGESET_DATA problem.  */
  if( bRetry ){
    assert( pIter->op==SQLITE_UPDATE || pIter->op==SQLITE_DELETE );
    rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, 0, 0);
  }

  /* If the bReplace flag is set, the change is an INSERT that has not
  ** been performed because the database already contains a row with the
  ** specified primary key and the conflict handler returned
  ** SQLITE_CHANGESET_REPLACE. In this case remove the conflicting row
  ** before reattempting the INSERT.  */
  else if( bReplace ){
    assert( pIter->op==SQLITE_INSERT );
    rc = sqlite3_exec(db, "SAVEPOINT replace_op", 0, 0, 0);
    if( rc==SQLITE_OK ){
      rc = sessionBindRow(pIter, 
          sqlite3changeset_new, pApply->nCol, pApply->abPK, pApply->pDelete);
      sqlite3_bind_int(pApply->pDelete, pApply->nCol+1, 1);
    }
    if( rc==SQLITE_OK ){
      sqlite3_step(pApply->pDelete);
      rc = sqlite3_reset(pApply->pDelete);
    }
    if( rc==SQLITE_OK ){
      rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, 0, 0);
    }
    if( rc==SQLITE_OK ){
      rc = sqlite3_exec(db, "RELEASE replace_op", 0, 0, 0);

    }
  }

  return rc;
}

/*







|
<
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>







184582
184583
184584
184585
184586
184587
184588
184589

184590
184591
184592
184593
184594
184595
184596
184597
184598
184599
184600
184601
184602
184603
184604
184605
184606
184607
184608
184609
184610
184611
184612
184613
184614
184615
184616
184617
184618
184619
184620
184621
184622
184623
184624
184625
184626
184627
184628
184629
184630
184631
  void *pCtx                      /* First argument passed to xConflict */
){
  int bReplace = 0;
  int bRetry = 0;
  int rc;

  rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, &bReplace, &bRetry);
  if( rc==SQLITE_OK ){

    /* If the bRetry flag is set, the change has not been applied due to an
    ** SQLITE_CHANGESET_DATA problem (i.e. this is an UPDATE or DELETE and
    ** a row with the correct PK is present in the db, but one or more other
    ** fields do not contain the expected values) and the conflict handler 
    ** returned SQLITE_CHANGESET_REPLACE. In this case retry the operation,
    ** but pass NULL as the final argument so that sessionApplyOneOp() ignores
    ** the SQLITE_CHANGESET_DATA problem.  */
    if( bRetry ){
      assert( pIter->op==SQLITE_UPDATE || pIter->op==SQLITE_DELETE );
      rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, 0, 0);
    }

    /* If the bReplace flag is set, the change is an INSERT that has not
    ** been performed because the database already contains a row with the
    ** specified primary key and the conflict handler returned
    ** SQLITE_CHANGESET_REPLACE. In this case remove the conflicting row
    ** before reattempting the INSERT.  */
    else if( bReplace ){
      assert( pIter->op==SQLITE_INSERT );
      rc = sqlite3_exec(db, "SAVEPOINT replace_op", 0, 0, 0);
      if( rc==SQLITE_OK ){
        rc = sessionBindRow(pIter, 
            sqlite3changeset_new, pApply->nCol, pApply->abPK, pApply->pDelete);
        sqlite3_bind_int(pApply->pDelete, pApply->nCol+1, 1);
      }
      if( rc==SQLITE_OK ){
        sqlite3_step(pApply->pDelete);
        rc = sqlite3_reset(pApply->pDelete);
      }
      if( rc==SQLITE_OK ){
        rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, 0, 0);
      }
      if( rc==SQLITE_OK ){
        rc = sqlite3_exec(db, "RELEASE replace_op", 0, 0, 0);
      }
    }
  }

  return rc;
}

/*
184210
184211
184212
184213
184214
184215
184216
184217


184218
184219
184220
184221
184222
184223
184224
184225
184226
184227
184228
184229
184230

184231

184232
184233
184234
184235
184236
184237
184238
    const char *zTab              /* Table name */
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of fifth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx                      /* First argument passed to xConflict */


){
  int schemaMismatch = 0;
  int rc;                         /* Return code */
  const char *zTab = 0;           /* Name of current table */
  int nTab = 0;                   /* Result of sqlite3Strlen30(zTab) */
  SessionApplyCtx sApply;         /* changeset_apply() context object */
  int bPatchset;

  assert( xConflict!=0 );

  pIter->in.bNoDiscard = 1;
  memset(&sApply, 0, sizeof(sApply));
  sqlite3_mutex_enter(sqlite3_db_mutex(db));

  rc = sqlite3_exec(db, "SAVEPOINT changeset_apply", 0, 0, 0);

  if( rc==SQLITE_OK ){
    rc = sqlite3_exec(db, "PRAGMA defer_foreign_keys = 1", 0, 0, 0);
  }
  while( rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter) ){
    int nCol;
    int op;
    const char *zNew;







|
>
>


|










>
|
>







184693
184694
184695
184696
184697
184698
184699
184700
184701
184702
184703
184704
184705
184706
184707
184708
184709
184710
184711
184712
184713
184714
184715
184716
184717
184718
184719
184720
184721
184722
184723
184724
184725
    const char *zTab              /* Table name */
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of fifth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx,                     /* First argument passed to xConflict */
  void **ppRebase, int *pnRebase, /* OUT: Rebase information */
  int flags                       /* SESSION_APPLY_XXX flags */
){
  int schemaMismatch = 0;
  int rc = SQLITE_OK;             /* Return code */
  const char *zTab = 0;           /* Name of current table */
  int nTab = 0;                   /* Result of sqlite3Strlen30(zTab) */
  SessionApplyCtx sApply;         /* changeset_apply() context object */
  int bPatchset;

  assert( xConflict!=0 );

  pIter->in.bNoDiscard = 1;
  memset(&sApply, 0, sizeof(sApply));
  sqlite3_mutex_enter(sqlite3_db_mutex(db));
  if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){
    rc = sqlite3_exec(db, "SAVEPOINT changeset_apply", 0, 0, 0);
  }
  if( rc==SQLITE_OK ){
    rc = sqlite3_exec(db, "PRAGMA defer_foreign_keys = 1", 0, 0, 0);
  }
  while( rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter) ){
    int nCol;
    int op;
    const char *zNew;
184248
184249
184250
184251
184252
184253
184254
184255
184256








184257


184258
184259
184260
184261
184262
184263
184264
      if( rc!=SQLITE_OK ) break;

      sqlite3_free((char*)sApply.azCol);  /* cast works around VC++ bug */
      sqlite3_finalize(sApply.pDelete);
      sqlite3_finalize(sApply.pUpdate); 
      sqlite3_finalize(sApply.pInsert);
      sqlite3_finalize(sApply.pSelect);
      memset(&sApply, 0, sizeof(sApply));
      sApply.db = db;








      sApply.bDeferConstraints = 1;



      /* If an xFilter() callback was specified, invoke it now. If the 
      ** xFilter callback returns zero, skip this table. If it returns
      ** non-zero, proceed. */
      schemaMismatch = (xFilter && (0==xFilter(pCtx, zNew)));
      if( schemaMismatch ){
        zTab = sqlite3_mprintf("%s", zNew);







<

>
>
>
>
>
>
>
>

>
>







184735
184736
184737
184738
184739
184740
184741

184742
184743
184744
184745
184746
184747
184748
184749
184750
184751
184752
184753
184754
184755
184756
184757
184758
184759
184760
      if( rc!=SQLITE_OK ) break;

      sqlite3_free((char*)sApply.azCol);  /* cast works around VC++ bug */
      sqlite3_finalize(sApply.pDelete);
      sqlite3_finalize(sApply.pUpdate); 
      sqlite3_finalize(sApply.pInsert);
      sqlite3_finalize(sApply.pSelect);

      sApply.db = db;
      sApply.pDelete = 0;
      sApply.pUpdate = 0;
      sApply.pInsert = 0;
      sApply.pSelect = 0;
      sApply.nCol = 0;
      sApply.azCol = 0;
      sApply.abPK = 0;
      sApply.bStat1 = 0;
      sApply.bDeferConstraints = 1;
      sApply.bRebaseStarted = 0;
      memset(&sApply.constraints, 0, sizeof(SessionBuffer));

      /* If an xFilter() callback was specified, invoke it now. If the 
      ** xFilter callback returns zero, skip this table. If it returns
      ** non-zero, proceed. */
      schemaMismatch = (xFilter && (0==xFilter(pCtx, zNew)));
      if( schemaMismatch ){
        zTab = sqlite3_mprintf("%s", zNew);
184353
184354
184355
184356
184357
184358
184359

184360
184361
184362
184363
184364
184365
184366






184367
184368
184369
184370
184371
184372

184373
184374
184375































184376
184377
184378
184379
184380
184381
184382
      if( res!=SQLITE_CHANGESET_OMIT ){
        rc = SQLITE_CONSTRAINT;
      }
    }
  }
  sqlite3_exec(db, "PRAGMA defer_foreign_keys = 0", 0, 0, 0);


  if( rc==SQLITE_OK ){
    rc = sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0);
  }else{
    sqlite3_exec(db, "ROLLBACK TO changeset_apply", 0, 0, 0);
    sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0);
  }







  sqlite3_finalize(sApply.pInsert);
  sqlite3_finalize(sApply.pDelete);
  sqlite3_finalize(sApply.pUpdate);
  sqlite3_finalize(sApply.pSelect);
  sqlite3_free((char*)sApply.azCol);  /* cast works around VC++ bug */
  sqlite3_free((char*)sApply.constraints.aBuf);

  sqlite3_mutex_leave(sqlite3_db_mutex(db));
  return rc;
}
































/*
** Apply the changeset passed via pChangeset/nChangeset to the main database
** attached to handle "db". Invoke the supplied conflict handler callback
** to resolve any conflicts encountered while applying the change.
*/
SQLITE_API int sqlite3changeset_apply(







>
|
|
|
|
|
|
|
>
>
>
>
>
>






>



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







184849
184850
184851
184852
184853
184854
184855
184856
184857
184858
184859
184860
184861
184862
184863
184864
184865
184866
184867
184868
184869
184870
184871
184872
184873
184874
184875
184876
184877
184878
184879
184880
184881
184882
184883
184884
184885
184886
184887
184888
184889
184890
184891
184892
184893
184894
184895
184896
184897
184898
184899
184900
184901
184902
184903
184904
184905
184906
184907
184908
184909
184910
184911
184912
184913
184914
184915
184916
184917
      if( res!=SQLITE_CHANGESET_OMIT ){
        rc = SQLITE_CONSTRAINT;
      }
    }
  }
  sqlite3_exec(db, "PRAGMA defer_foreign_keys = 0", 0, 0, 0);

  if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){
    if( rc==SQLITE_OK ){
      rc = sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0);
    }else{
      sqlite3_exec(db, "ROLLBACK TO changeset_apply", 0, 0, 0);
      sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0);
    }
  }

  if( rc==SQLITE_OK && bPatchset==0 && ppRebase && pnRebase ){
    *ppRebase = (void*)sApply.rebase.aBuf;
    *pnRebase = sApply.rebase.nBuf;
    sApply.rebase.aBuf = 0;
  }
  sqlite3_finalize(sApply.pInsert);
  sqlite3_finalize(sApply.pDelete);
  sqlite3_finalize(sApply.pUpdate);
  sqlite3_finalize(sApply.pSelect);
  sqlite3_free((char*)sApply.azCol);  /* cast works around VC++ bug */
  sqlite3_free((char*)sApply.constraints.aBuf);
  sqlite3_free((char*)sApply.rebase.aBuf);
  sqlite3_mutex_leave(sqlite3_db_mutex(db));
  return rc;
}

/*
** Apply the changeset passed via pChangeset/nChangeset to the main 
** database attached to handle "db".
*/
SQLITE_API int sqlite3changeset_apply_v2(
  sqlite3 *db,                    /* Apply change to "main" db of this handle */
  int nChangeset,                 /* Size of changeset in bytes */
  void *pChangeset,               /* Changeset blob */
  int(*xFilter)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    const char *zTab              /* Table name */
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx,                     /* First argument passed to xConflict */
  void **ppRebase, int *pnRebase,
  int flags
){
  sqlite3_changeset_iter *pIter;  /* Iterator to skip through changeset */  
  int rc = sqlite3changeset_start(&pIter, nChangeset, pChangeset);
  if( rc==SQLITE_OK ){
    rc = sessionChangesetApply(
        db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags
    );
  }
  return rc;
}

/*
** Apply the changeset passed via pChangeset/nChangeset to the main database
** attached to handle "db". Invoke the supplied conflict handler callback
** to resolve any conflicts encountered while applying the change.
*/
SQLITE_API int sqlite3changeset_apply(
184390
184391
184392
184393
184394
184395
184396
184397
184398
184399
184400
184401
184402

184403
184404
184405
184406
184407
184408
184409


























184410
184411
184412
184413
184414
184415
184416
184417
184418
184419
184420
184421
184422
184423
184424
184425
184426
184427
184428
184429
184430

184431
184432
184433
184434
184435
184436
184437
184438
184439
184440
184441
184442
184443
184444
184445
184446
184447
184448

184449
184450
184451
184452
184453
184454
184455
184456
184457

184458
184459
184460
184461
184462
184463
184464
184465
184466


184467




































184468
184469



















184470
184471
184472
184473
184474
184475
184476
  int(*xConflict)(
    void *pCtx,                   /* Copy of fifth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx                      /* First argument passed to xConflict */
){
  sqlite3_changeset_iter *pIter;  /* Iterator to skip through changeset */  
  int rc = sqlite3changeset_start(&pIter, nChangeset, pChangeset);
  if( rc==SQLITE_OK ){
    rc = sessionChangesetApply(db, pIter, xFilter, xConflict, pCtx);
  }
  return rc;

}

/*
** Apply the changeset passed via xInput/pIn to the main database
** attached to handle "db". Invoke the supplied conflict handler callback
** to resolve any conflicts encountered while applying the change.
*/


























SQLITE_API int sqlite3changeset_apply_strm(
  sqlite3 *db,                    /* Apply change to "main" db of this handle */
  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
  void *pIn,                                          /* First arg for xInput */
  int(*xFilter)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    const char *zTab              /* Table name */
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx                      /* First argument passed to xConflict */
){
  sqlite3_changeset_iter *pIter;  /* Iterator to skip through changeset */  
  int rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);
  if( rc==SQLITE_OK ){
    rc = sessionChangesetApply(db, pIter, xFilter, xConflict, pCtx);
  }
  return rc;

}

/*
** sqlite3_changegroup handle.
*/
struct sqlite3_changegroup {
  int rc;                         /* Error code */
  int bPatch;                     /* True to accumulate patchsets */
  SessionTable *pList;            /* List of tables in current patch */
};

/*
** This function is called to merge two changes to the same row together as
** part of an sqlite3changeset_concat() operation. A new change object is
** allocated and a pointer to it stored in *ppNew.
*/
static int sessionChangeMerge(
  SessionTable *pTab,             /* Table structure */

  int bPatchset,                  /* True for patchsets */
  SessionChange *pExist,          /* Existing change */
  int op2,                        /* Second change operation */
  int bIndirect,                  /* True if second change is indirect */
  u8 *aRec,                       /* Second change record */
  int nRec,                       /* Number of bytes in aRec */
  SessionChange **ppNew           /* OUT: Merged change */
){
  SessionChange *pNew = 0;


  if( !pExist ){
    pNew = (SessionChange *)sqlite3_malloc(sizeof(SessionChange) + nRec);
    if( !pNew ){
      return SQLITE_NOMEM;
    }
    memset(pNew, 0, sizeof(SessionChange));
    pNew->op = op2;
    pNew->bIndirect = bIndirect;


    pNew->nRecord = nRec;




































    pNew->aRecord = (u8*)&pNew[1];
    memcpy(pNew->aRecord, aRec, nRec);



















  }else{
    int op1 = pExist->op;

    /* 
    **   op1=INSERT, op2=INSERT      ->      Unsupported. Discard op2.
    **   op1=INSERT, op2=UPDATE      ->      INSERT.
    **   op1=INSERT, op2=DELETE      ->      (none)







<
|
<
|
<
<
>







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>















<
|
<
|
<
<
>


















>









>









>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







184925
184926
184927
184928
184929
184930
184931

184932

184933


184934
184935
184936
184937
184938
184939
184940
184941
184942
184943
184944
184945
184946
184947
184948
184949
184950
184951
184952
184953
184954
184955
184956
184957
184958
184959
184960
184961
184962
184963
184964
184965
184966
184967
184968
184969
184970
184971
184972
184973
184974
184975
184976
184977
184978
184979
184980
184981
184982

184983

184984


184985
184986
184987
184988
184989
184990
184991
184992
184993
184994
184995
184996
184997
184998
184999
185000
185001
185002
185003
185004
185005
185006
185007
185008
185009
185010
185011
185012
185013
185014
185015
185016
185017
185018
185019
185020
185021
185022
185023
185024
185025
185026
185027
185028
185029
185030
185031
185032
185033
185034
185035
185036
185037
185038
185039
185040
185041
185042
185043
185044
185045
185046
185047
185048
185049
185050
185051
185052
185053
185054
185055
185056
185057
185058
185059
185060
185061
185062
185063
185064
185065
185066
185067
185068
185069
185070
185071
185072
185073
185074
185075
185076
185077
185078
185079
185080
185081
185082
185083
185084
185085
185086
185087
185088
185089
185090
  int(*xConflict)(
    void *pCtx,                   /* Copy of fifth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx                      /* First argument passed to xConflict */
){

  return sqlite3changeset_apply_v2(

      db, nChangeset, pChangeset, xFilter, xConflict, pCtx, 0, 0, 0


  );
}

/*
** Apply the changeset passed via xInput/pIn to the main database
** attached to handle "db". Invoke the supplied conflict handler callback
** to resolve any conflicts encountered while applying the change.
*/
SQLITE_API int sqlite3changeset_apply_v2_strm(
  sqlite3 *db,                    /* Apply change to "main" db of this handle */
  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
  void *pIn,                                          /* First arg for xInput */
  int(*xFilter)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    const char *zTab              /* Table name */
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx,                     /* First argument passed to xConflict */
  void **ppRebase, int *pnRebase,
  int flags
){
  sqlite3_changeset_iter *pIter;  /* Iterator to skip through changeset */  
  int rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);
  if( rc==SQLITE_OK ){
    rc = sessionChangesetApply(
        db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags
    );
  }
  return rc;
}
SQLITE_API int sqlite3changeset_apply_strm(
  sqlite3 *db,                    /* Apply change to "main" db of this handle */
  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
  void *pIn,                                          /* First arg for xInput */
  int(*xFilter)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    const char *zTab              /* Table name */
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx                      /* First argument passed to xConflict */
){

  return sqlite3changeset_apply_v2_strm(

      db, xInput, pIn, xFilter, xConflict, pCtx, 0, 0, 0


  );
}

/*
** sqlite3_changegroup handle.
*/
struct sqlite3_changegroup {
  int rc;                         /* Error code */
  int bPatch;                     /* True to accumulate patchsets */
  SessionTable *pList;            /* List of tables in current patch */
};

/*
** This function is called to merge two changes to the same row together as
** part of an sqlite3changeset_concat() operation. A new change object is
** allocated and a pointer to it stored in *ppNew.
*/
static int sessionChangeMerge(
  SessionTable *pTab,             /* Table structure */
  int bRebase,                    /* True for a rebase hash-table */
  int bPatchset,                  /* True for patchsets */
  SessionChange *pExist,          /* Existing change */
  int op2,                        /* Second change operation */
  int bIndirect,                  /* True if second change is indirect */
  u8 *aRec,                       /* Second change record */
  int nRec,                       /* Number of bytes in aRec */
  SessionChange **ppNew           /* OUT: Merged change */
){
  SessionChange *pNew = 0;
  int rc = SQLITE_OK;

  if( !pExist ){
    pNew = (SessionChange *)sqlite3_malloc(sizeof(SessionChange) + nRec);
    if( !pNew ){
      return SQLITE_NOMEM;
    }
    memset(pNew, 0, sizeof(SessionChange));
    pNew->op = op2;
    pNew->bIndirect = bIndirect;
    pNew->aRecord = (u8*)&pNew[1];
    if( bIndirect==0 || bRebase==0 ){
      pNew->nRecord = nRec;
      memcpy(pNew->aRecord, aRec, nRec);
    }else{
      int i;
      u8 *pIn = aRec;
      u8 *pOut = pNew->aRecord;
      for(i=0; i<pTab->nCol; i++){
        int nIn = sessionSerialLen(pIn);
        if( *pIn==0 ){
          *pOut++ = 0;
        }else if( pTab->abPK[i]==0 ){
          *pOut++ = 0xFF;
        }else{
          memcpy(pOut, pIn, nIn);
          pOut += nIn;
        }
        pIn += nIn;
      }
      pNew->nRecord = pOut - pNew->aRecord;
    }
  }else if( bRebase ){
    if( pExist->op==SQLITE_DELETE && pExist->bIndirect ){
      *ppNew = pExist;
    }else{
      int nByte = nRec + pExist->nRecord + sizeof(SessionChange);
      pNew = (SessionChange*)sqlite3_malloc(nByte);
      if( pNew==0 ){
        rc = SQLITE_NOMEM;
      }else{
        int i;
        u8 *a1 = pExist->aRecord;
        u8 *a2 = aRec;
        u8 *pOut;

        memset(pNew, 0, nByte);
        pNew->bIndirect = bIndirect || pExist->bIndirect;
        pNew->op = op2;
        pOut = pNew->aRecord = (u8*)&pNew[1];

        for(i=0; i<pTab->nCol; i++){
          int n1 = sessionSerialLen(a1);
          int n2 = sessionSerialLen(a2);
          if( *a1==0xFF || (pTab->abPK[i]==0 && bIndirect) ){
            *pOut++ = 0xFF;
          }else if( *a2==0 ){
            memcpy(pOut, a1, n1);
            pOut += n1;
          }else{
            memcpy(pOut, a2, n2);
            pOut += n2;
          }
          a1 += n1;
          a2 += n2;
        }
        pNew->nRecord = pOut - pNew->aRecord;
      }
      sqlite3_free(pExist);
    }
  }else{
    int op1 = pExist->op;

    /* 
    **   op1=INSERT, op2=INSERT      ->      Unsupported. Discard op2.
    **   op1=INSERT, op2=UPDATE      ->      INSERT.
    **   op1=INSERT, op2=DELETE      ->      (none)
184556
184557
184558
184559
184560
184561
184562
184563
184564
184565
184566
184567
184568
184569
184570
184571
184572

184573
184574
184575
184576
184577
184578
184579
184580
184581
184582
184583
184584
184585
184586
184587
        pNew->nRecord = (int)(aCsr - pNew->aRecord);
      }
      sqlite3_free(pExist);
    }
  }

  *ppNew = pNew;
  return SQLITE_OK;
}

/*
** Add all changes in the changeset traversed by the iterator passed as
** the first argument to the changegroup hash tables.
*/
static int sessionChangesetToHash(
  sqlite3_changeset_iter *pIter,   /* Iterator to read from */
  sqlite3_changegroup *pGrp        /* Changegroup object to add changeset to */

){
  u8 *aRec;
  int nRec;
  int rc = SQLITE_OK;
  SessionTable *pTab = 0;


  while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec) ){
    const char *zNew;
    int nCol;
    int op;
    int iHash;
    int bIndirect;
    SessionChange *pChange;
    SessionChange *pExist = 0;







|








|
>






<
|







185170
185171
185172
185173
185174
185175
185176
185177
185178
185179
185180
185181
185182
185183
185184
185185
185186
185187
185188
185189
185190
185191
185192
185193

185194
185195
185196
185197
185198
185199
185200
185201
        pNew->nRecord = (int)(aCsr - pNew->aRecord);
      }
      sqlite3_free(pExist);
    }
  }

  *ppNew = pNew;
  return rc;
}

/*
** Add all changes in the changeset traversed by the iterator passed as
** the first argument to the changegroup hash tables.
*/
static int sessionChangesetToHash(
  sqlite3_changeset_iter *pIter,   /* Iterator to read from */
  sqlite3_changegroup *pGrp,       /* Changegroup object to add changeset to */
  int bRebase                      /* True if hash table is for rebasing */
){
  u8 *aRec;
  int nRec;
  int rc = SQLITE_OK;
  SessionTable *pTab = 0;


  while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, 0) ){
    const char *zNew;
    int nCol;
    int op;
    int iHash;
    int bIndirect;
    SessionChange *pChange;
    SessionChange *pExist = 0;
184653
184654
184655
184656
184657
184658
184659
184660
184661
184662
184663
184664
184665
184666
184667
        pExist = *pp;
        *pp = (*pp)->pNext;
        pTab->nEntry--;
        break;
      }
    }

    rc = sessionChangeMerge(pTab, 
        pIter->bPatchset, pExist, op, bIndirect, aRec, nRec, &pChange
    );
    if( rc ) break;
    if( pChange ){
      pChange->pNext = pTab->apChange[iHash];
      pTab->apChange[iHash] = pChange;
      pTab->nEntry++;







|







185267
185268
185269
185270
185271
185272
185273
185274
185275
185276
185277
185278
185279
185280
185281
        pExist = *pp;
        *pp = (*pp)->pNext;
        pTab->nEntry--;
        break;
      }
    }

    rc = sessionChangeMerge(pTab, bRebase, 
        pIter->bPatchset, pExist, op, bIndirect, aRec, nRec, &pChange
    );
    if( rc ) break;
    if( pChange ){
      pChange->pNext = pTab->apChange[iHash];
      pTab->apChange[iHash] = pChange;
      pTab->nEntry++;
184761
184762
184763
184764
184765
184766
184767
184768
184769
184770
184771
184772
184773
184774
184775
*/
SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup *pGrp, int nData, void *pData){
  sqlite3_changeset_iter *pIter;  /* Iterator opened on pData/nData */
  int rc;                         /* Return code */

  rc = sqlite3changeset_start(&pIter, nData, pData);
  if( rc==SQLITE_OK ){
    rc = sessionChangesetToHash(pIter, pGrp);
  }
  sqlite3changeset_finalize(pIter);
  return rc;
}

/*
** Obtain a buffer containing a changeset representing the concatenation







|







185375
185376
185377
185378
185379
185380
185381
185382
185383
185384
185385
185386
185387
185388
185389
*/
SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup *pGrp, int nData, void *pData){
  sqlite3_changeset_iter *pIter;  /* Iterator opened on pData/nData */
  int rc;                         /* Return code */

  rc = sqlite3changeset_start(&pIter, nData, pData);
  if( rc==SQLITE_OK ){
    rc = sessionChangesetToHash(pIter, pGrp, 0);
  }
  sqlite3changeset_finalize(pIter);
  return rc;
}

/*
** Obtain a buffer containing a changeset representing the concatenation
184792
184793
184794
184795
184796
184797
184798
184799
184800
184801
184802
184803
184804
184805
184806
  void *pIn
){
  sqlite3_changeset_iter *pIter;  /* Iterator opened on pData/nData */
  int rc;                         /* Return code */

  rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);
  if( rc==SQLITE_OK ){
    rc = sessionChangesetToHash(pIter, pGrp);
  }
  sqlite3changeset_finalize(pIter);
  return rc;
}

/*
** Streaming versions of changegroup_output().







|







185406
185407
185408
185409
185410
185411
185412
185413
185414
185415
185416
185417
185418
185419
185420
  void *pIn
){
  sqlite3_changeset_iter *pIter;  /* Iterator opened on pData/nData */
  int rc;                         /* Return code */

  rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);
  if( rc==SQLITE_OK ){
    rc = sessionChangesetToHash(pIter, pGrp, 0);
  }
  sqlite3changeset_finalize(pIter);
  return rc;
}

/*
** Streaming versions of changegroup_output().
184876
184877
184878
184879
184880
184881
184882























































































































































































































































































































































184883
184884
184885
184886
184887
184888
184889
  if( rc==SQLITE_OK ){
    rc = sqlite3changegroup_output_strm(pGrp, xOutput, pOut);
  }
  sqlite3changegroup_delete(pGrp);

  return rc;
}
























































































































































































































































































































































#endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */

/************** End of sqlite3session.c **************************************/
/************** Begin file json1.c *******************************************/
/*
** 2015-08-12







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







185490
185491
185492
185493
185494
185495
185496
185497
185498
185499
185500
185501
185502
185503
185504
185505
185506
185507
185508
185509
185510
185511
185512
185513
185514
185515
185516
185517
185518
185519
185520
185521
185522
185523
185524
185525
185526
185527
185528
185529
185530
185531
185532
185533
185534
185535
185536
185537
185538
185539
185540
185541
185542
185543
185544
185545
185546
185547
185548
185549
185550
185551
185552
185553
185554
185555
185556
185557
185558
185559
185560
185561
185562
185563
185564
185565
185566
185567
185568
185569
185570
185571
185572
185573
185574
185575
185576
185577
185578
185579
185580
185581
185582
185583
185584
185585
185586
185587
185588
185589
185590
185591
185592
185593
185594
185595
185596
185597
185598
185599
185600
185601
185602
185603
185604
185605
185606
185607
185608
185609
185610
185611
185612
185613
185614
185615
185616
185617
185618
185619
185620
185621
185622
185623
185624
185625
185626
185627
185628
185629
185630
185631
185632
185633
185634
185635
185636
185637
185638
185639
185640
185641
185642
185643
185644
185645
185646
185647
185648
185649
185650
185651
185652
185653
185654
185655
185656
185657
185658
185659
185660
185661
185662
185663
185664
185665
185666
185667
185668
185669
185670
185671
185672
185673
185674
185675
185676
185677
185678
185679
185680
185681
185682
185683
185684
185685
185686
185687
185688
185689
185690
185691
185692
185693
185694
185695
185696
185697
185698
185699
185700
185701
185702
185703
185704
185705
185706
185707
185708
185709
185710
185711
185712
185713
185714
185715
185716
185717
185718
185719
185720
185721
185722
185723
185724
185725
185726
185727
185728
185729
185730
185731
185732
185733
185734
185735
185736
185737
185738
185739
185740
185741
185742
185743
185744
185745
185746
185747
185748
185749
185750
185751
185752
185753
185754
185755
185756
185757
185758
185759
185760
185761
185762
185763
185764
185765
185766
185767
185768
185769
185770
185771
185772
185773
185774
185775
185776
185777
185778
185779
185780
185781
185782
185783
185784
185785
185786
185787
185788
185789
185790
185791
185792
185793
185794
185795
185796
185797
185798
185799
185800
185801
185802
185803
185804
185805
185806
185807
185808
185809
185810
185811
185812
185813
185814
185815
185816
185817
185818
185819
185820
185821
185822
185823
185824
185825
185826
185827
185828
185829
185830
185831
185832
185833
185834
185835
185836
185837
185838
185839
185840
185841
185842
185843
185844
185845
185846
  if( rc==SQLITE_OK ){
    rc = sqlite3changegroup_output_strm(pGrp, xOutput, pOut);
  }
  sqlite3changegroup_delete(pGrp);

  return rc;
}

/*
** Changeset rebaser handle.
*/
struct sqlite3_rebaser {
  sqlite3_changegroup grp;        /* Hash table */
};

/*
** Buffers a1 and a2 must both contain a sessions module record nCol
** fields in size. This function appends an nCol sessions module 
** record to buffer pBuf that is a copy of a1, except that for
** each field that is undefined in a1[], swap in the field from a2[].
*/
static void sessionAppendRecordMerge(
  SessionBuffer *pBuf,            /* Buffer to append to */
  int nCol,                       /* Number of columns in each record */
  u8 *a1, int n1,                 /* Record 1 */
  u8 *a2, int n2,                 /* Record 2 */
  int *pRc                        /* IN/OUT: error code */
){
  sessionBufferGrow(pBuf, n1+n2, pRc);
  if( *pRc==SQLITE_OK ){
    int i;
    u8 *pOut = &pBuf->aBuf[pBuf->nBuf];
    for(i=0; i<nCol; i++){
      int nn1 = sessionSerialLen(a1);
      int nn2 = sessionSerialLen(a2);
      if( *a1==0 || *a1==0xFF ){
        memcpy(pOut, a2, nn2);
        pOut += nn2;
      }else{
        memcpy(pOut, a1, nn1);
        pOut += nn1;
      }
      a1 += nn1;
      a2 += nn2;
    }

    pBuf->nBuf = pOut-pBuf->aBuf;
    assert( pBuf->nBuf<=pBuf->nAlloc );
  }
}

/*
** This function is called when rebasing a local UPDATE change against one 
** or more remote UPDATE changes. The aRec/nRec buffer contains the current
** old.* and new.* records for the change. The rebase buffer (a single
** record) is in aChange/nChange. The rebased change is appended to buffer
** pBuf.
**
** Rebasing the UPDATE involves: 
**
**   * Removing any changes to fields for which the corresponding field
**     in the rebase buffer is set to "replaced" (type 0xFF). If this
**     means the UPDATE change updates no fields, nothing is appended
**     to the output buffer.
**
**   * For each field modified by the local change for which the 
**     corresponding field in the rebase buffer is not "undefined" (0x00)
**     or "replaced" (0xFF), the old.* value is replaced by the value
**     in the rebase buffer.
*/
static void sessionAppendPartialUpdate(
  SessionBuffer *pBuf,            /* Append record here */
  sqlite3_changeset_iter *pIter,  /* Iterator pointed at local change */
  u8 *aRec, int nRec,             /* Local change */
  u8 *aChange, int nChange,       /* Record to rebase against */
  int *pRc                        /* IN/OUT: Return Code */
){
  sessionBufferGrow(pBuf, 2+nRec+nChange, pRc);
  if( *pRc==SQLITE_OK ){
    int bData = 0;
    u8 *pOut = &pBuf->aBuf[pBuf->nBuf];
    int i;
    u8 *a1 = aRec;
    u8 *a2 = aChange;

    *pOut++ = SQLITE_UPDATE;
    *pOut++ = pIter->bIndirect;
    for(i=0; i<pIter->nCol; i++){
      int n1 = sessionSerialLen(a1);
      int n2 = sessionSerialLen(a2);
      if( pIter->abPK[i] || a2[0]==0 ){
        if( !pIter->abPK[i] ) bData = 1;
        memcpy(pOut, a1, n1);
        pOut += n1;
      }else if( a2[0]!=0xFF ){
        bData = 1;
        memcpy(pOut, a2, n2);
        pOut += n2;
      }else{
        *pOut++ = '\0';
      }
      a1 += n1;
      a2 += n2;
    }
    if( bData ){
      a2 = aChange;
      for(i=0; i<pIter->nCol; i++){
        int n1 = sessionSerialLen(a1);
        int n2 = sessionSerialLen(a2);
        if( pIter->abPK[i] || a2[0]!=0xFF ){
          memcpy(pOut, a1, n1);
          pOut += n1;
        }else{
          *pOut++ = '\0';
        }
        a1 += n1;
        a2 += n2;
      }
      pBuf->nBuf = (pOut - pBuf->aBuf);
    }
  }
}

/*
** pIter is configured to iterate through a changeset. This function rebases 
** that changeset according to the current configuration of the rebaser 
** object passed as the first argument. If no error occurs and argument xOutput
** is not NULL, then the changeset is returned to the caller by invoking
** xOutput zero or more times and SQLITE_OK returned. Or, if xOutput is NULL,
** then (*ppOut) is set to point to a buffer containing the rebased changeset
** before this function returns. In this case (*pnOut) is set to the size of
** the buffer in bytes.  It is the responsibility of the caller to eventually
** free the (*ppOut) buffer using sqlite3_free(). 
**
** If an error occurs, an SQLite error code is returned. If ppOut and
** pnOut are not NULL, then the two output parameters are set to 0 before
** returning.
*/
static int sessionRebase(
  sqlite3_rebaser *p,             /* Rebaser hash table */
  sqlite3_changeset_iter *pIter,  /* Input data */
  int (*xOutput)(void *pOut, const void *pData, int nData),
  void *pOut,                     /* Context for xOutput callback */
  int *pnOut,                     /* OUT: Number of bytes in output changeset */
  void **ppOut                    /* OUT: Inverse of pChangeset */
){
  int rc = SQLITE_OK;
  u8 *aRec = 0;
  int nRec = 0;
  int bNew = 0;
  SessionTable *pTab = 0;
  SessionBuffer sOut = {0,0,0};

  while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, &bNew) ){
    SessionChange *pChange = 0;
    int bDone = 0;

    if( bNew ){
      const char *zTab = pIter->zTab;
      for(pTab=p->grp.pList; pTab; pTab=pTab->pNext){
        if( 0==sqlite3_stricmp(pTab->zName, zTab) ) break;
      }
      bNew = 0;

      /* A patchset may not be rebased */
      if( pIter->bPatchset ){
        rc = SQLITE_ERROR;
      }

      /* Append a table header to the output for this new table */
      sessionAppendByte(&sOut, pIter->bPatchset ? 'P' : 'T', &rc);
      sessionAppendVarint(&sOut, pIter->nCol, &rc);
      sessionAppendBlob(&sOut, pIter->abPK, pIter->nCol, &rc);
      sessionAppendBlob(&sOut,(u8*)pIter->zTab,(int)strlen(pIter->zTab)+1,&rc);
    }

    if( pTab && rc==SQLITE_OK ){
      int iHash = sessionChangeHash(pTab, 0, aRec, pTab->nChange);

      for(pChange=pTab->apChange[iHash]; pChange; pChange=pChange->pNext){
        if( sessionChangeEqual(pTab, 0, aRec, 0, pChange->aRecord) ){
          break;
        }
      }
    }

    if( pChange ){
      assert( pChange->op==SQLITE_DELETE || pChange->op==SQLITE_INSERT );
      switch( pIter->op ){
        case SQLITE_INSERT:
          if( pChange->op==SQLITE_INSERT ){
            bDone = 1;
            if( pChange->bIndirect==0 ){
              sessionAppendByte(&sOut, SQLITE_UPDATE, &rc);
              sessionAppendByte(&sOut, pIter->bIndirect, &rc);
              sessionAppendBlob(&sOut, pChange->aRecord, pChange->nRecord, &rc);
              sessionAppendBlob(&sOut, aRec, nRec, &rc);
            }
          }
          break;

        case SQLITE_UPDATE:
          bDone = 1;
          if( pChange->op==SQLITE_DELETE ){
            if( pChange->bIndirect==0 ){
              u8 *pCsr = aRec;
              sessionSkipRecord(&pCsr, pIter->nCol);
              sessionAppendByte(&sOut, SQLITE_INSERT, &rc);
              sessionAppendByte(&sOut, pIter->bIndirect, &rc);
              sessionAppendRecordMerge(&sOut, pIter->nCol,
                  pCsr, nRec-(pCsr-aRec), 
                  pChange->aRecord, pChange->nRecord, &rc
              );
            }
          }else{
            sessionAppendPartialUpdate(&sOut, pIter,
                aRec, nRec, pChange->aRecord, pChange->nRecord, &rc
            );
          }
          break;

        default:
          assert( pIter->op==SQLITE_DELETE );
          bDone = 1;
          if( pChange->op==SQLITE_INSERT ){
            sessionAppendByte(&sOut, SQLITE_DELETE, &rc);
            sessionAppendByte(&sOut, pIter->bIndirect, &rc);
            sessionAppendRecordMerge(&sOut, pIter->nCol,
                pChange->aRecord, pChange->nRecord, aRec, nRec, &rc
            );
          }
          break;
      }
    }

    if( bDone==0 ){
      sessionAppendByte(&sOut, pIter->op, &rc);
      sessionAppendByte(&sOut, pIter->bIndirect, &rc);
      sessionAppendBlob(&sOut, aRec, nRec, &rc);
    }
    if( rc==SQLITE_OK && xOutput && sOut.nBuf>SESSIONS_STRM_CHUNK_SIZE ){
      rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
      sOut.nBuf = 0;
    }
    if( rc ) break;
  }

  if( rc!=SQLITE_OK ){
    sqlite3_free(sOut.aBuf);
    memset(&sOut, 0, sizeof(sOut));
  }

  if( rc==SQLITE_OK ){
    if( xOutput ){
      if( sOut.nBuf>0 ){
        rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
      }
    }else{
      *ppOut = (void*)sOut.aBuf;
      *pnOut = sOut.nBuf;
      sOut.aBuf = 0;
    }
  }
  sqlite3_free(sOut.aBuf);
  return rc;
}

/* 
** Create a new rebaser object.
*/
SQLITE_API int sqlite3rebaser_create(sqlite3_rebaser **ppNew){
  int rc = SQLITE_OK;
  sqlite3_rebaser *pNew;

  pNew = sqlite3_malloc(sizeof(sqlite3_rebaser));
  if( pNew==0 ){
    rc = SQLITE_NOMEM;
  }else{
    memset(pNew, 0, sizeof(sqlite3_rebaser));
  }
  *ppNew = pNew;
  return rc;
}

/* 
** Call this one or more times to configure a rebaser.
*/
SQLITE_API int sqlite3rebaser_configure(
  sqlite3_rebaser *p, 
  int nRebase, const void *pRebase
){
  sqlite3_changeset_iter *pIter = 0;   /* Iterator opened on pData/nData */
  int rc;                              /* Return code */
  rc = sqlite3changeset_start(&pIter, nRebase, (void*)pRebase);
  if( rc==SQLITE_OK ){
    rc = sessionChangesetToHash(pIter, &p->grp, 1);
  }
  sqlite3changeset_finalize(pIter);
  return rc;
}

/* 
** Rebase a changeset according to current rebaser configuration 
*/
SQLITE_API int sqlite3rebaser_rebase(
  sqlite3_rebaser *p,
  int nIn, const void *pIn, 
  int *pnOut, void **ppOut 
){
  sqlite3_changeset_iter *pIter = 0;   /* Iterator to skip through input */  
  int rc = sqlite3changeset_start(&pIter, nIn, (void*)pIn);

  if( rc==SQLITE_OK ){
    rc = sessionRebase(p, pIter, 0, 0, pnOut, ppOut);
    sqlite3changeset_finalize(pIter);
  }

  return rc;
}

/* 
** Rebase a changeset according to current rebaser configuration 
*/
SQLITE_API int sqlite3rebaser_rebase_strm(
  sqlite3_rebaser *p,
  int (*xInput)(void *pIn, void *pData, int *pnData),
  void *pIn,
  int (*xOutput)(void *pOut, const void *pData, int nData),
  void *pOut
){
  sqlite3_changeset_iter *pIter = 0;   /* Iterator to skip through input */  
  int rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);

  if( rc==SQLITE_OK ){
    rc = sessionRebase(p, pIter, xOutput, pOut, 0, 0);
    sqlite3changeset_finalize(pIter);
  }

  return rc;
}

/* 
** Destroy a rebaser object 
*/
SQLITE_API void sqlite3rebaser_delete(sqlite3_rebaser *p){
  if( p ){
    sessionDeleteTable(p->grp.pList);
    sqlite3_free(p);
  }
}

#endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */

/************** End of sqlite3session.c **************************************/
/************** Begin file json1.c *******************************************/
/*
** 2015-08-12
202600
202601
202602
202603
202604
202605
202606






202607
202608
202609
202610
202611
202612
202613
202614
202615
202616
202617
202618
202619
202620
202621
202622
202623
202624
202625
202626
202627
202628
202629
202630
202631
202632
202633
202634
202635
202636
202637
                                    FTS5_BI_ROWID_GE, 0, 0, -1},
  };

  int aColMap[3];
  aColMap[0] = -1;
  aColMap[1] = nCol;
  aColMap[2] = nCol+1;







  /* Set idxFlags flags for all WHERE clause terms that will be used. */
  for(i=0; i<pInfo->nConstraint; i++){
    struct sqlite3_index_constraint *p = &pInfo->aConstraint[i];
    int iCol = p->iColumn;

    if( (p->op==SQLITE_INDEX_CONSTRAINT_MATCH && iCol>=0 && iCol<=nCol)
     || (p->op==SQLITE_INDEX_CONSTRAINT_EQ && iCol==nCol)
    ){
      /* A MATCH operator or equivalent */
      if( p->usable ){
        idxFlags = (idxFlags & 0xFFFF) | FTS5_BI_MATCH | (iCol << 16);
        aConstraint[0].iConsIndex = i;
      }else{
        /* As there exists an unusable MATCH constraint this is an 
        ** unusable plan. Set a prohibitively high cost. */
        pInfo->estimatedCost = 1e50;
        return SQLITE_OK;
      }
    }else{
      int j;
      for(j=1; j<ArraySize(aConstraint); j++){
        struct Constraint *pC = &aConstraint[j];
        if( iCol==aColMap[pC->iCol] && p->op & pC->op && p->usable ){
          pC->iConsIndex = i;
          idxFlags |= pC->fts5op;
        }
      }
    }
  }








>
>
>
>
>
>



















|



|







203557
203558
203559
203560
203561
203562
203563
203564
203565
203566
203567
203568
203569
203570
203571
203572
203573
203574
203575
203576
203577
203578
203579
203580
203581
203582
203583
203584
203585
203586
203587
203588
203589
203590
203591
203592
203593
203594
203595
203596
203597
203598
203599
203600
                                    FTS5_BI_ROWID_GE, 0, 0, -1},
  };

  int aColMap[3];
  aColMap[0] = -1;
  aColMap[1] = nCol;
  aColMap[2] = nCol+1;

  assert( SQLITE_INDEX_CONSTRAINT_EQ<SQLITE_INDEX_CONSTRAINT_MATCH );
  assert( SQLITE_INDEX_CONSTRAINT_GT<SQLITE_INDEX_CONSTRAINT_MATCH );
  assert( SQLITE_INDEX_CONSTRAINT_LE<SQLITE_INDEX_CONSTRAINT_MATCH );
  assert( SQLITE_INDEX_CONSTRAINT_GE<SQLITE_INDEX_CONSTRAINT_MATCH );
  assert( SQLITE_INDEX_CONSTRAINT_LE<SQLITE_INDEX_CONSTRAINT_MATCH );

  /* Set idxFlags flags for all WHERE clause terms that will be used. */
  for(i=0; i<pInfo->nConstraint; i++){
    struct sqlite3_index_constraint *p = &pInfo->aConstraint[i];
    int iCol = p->iColumn;

    if( (p->op==SQLITE_INDEX_CONSTRAINT_MATCH && iCol>=0 && iCol<=nCol)
     || (p->op==SQLITE_INDEX_CONSTRAINT_EQ && iCol==nCol)
    ){
      /* A MATCH operator or equivalent */
      if( p->usable ){
        idxFlags = (idxFlags & 0xFFFF) | FTS5_BI_MATCH | (iCol << 16);
        aConstraint[0].iConsIndex = i;
      }else{
        /* As there exists an unusable MATCH constraint this is an 
        ** unusable plan. Set a prohibitively high cost. */
        pInfo->estimatedCost = 1e50;
        return SQLITE_OK;
      }
    }else if( p->op<=SQLITE_INDEX_CONSTRAINT_MATCH ){
      int j;
      for(j=1; j<ArraySize(aConstraint); j++){
        struct Constraint *pC = &aConstraint[j];
        if( iCol==aColMap[pC->iCol] && (p->op & pC->op) && p->usable ){
          pC->iConsIndex = i;
          idxFlags |= pC->fts5op;
        }
      }
    }
  }

204695
204696
204697
204698
204699
204700
204701
204702
204703
204704
204705
204706
204707
204708
204709
static void fts5SourceIdFunc(
  sqlite3_context *pCtx,          /* Function call context */
  int nArg,                       /* Number of args */
  sqlite3_value **apUnused        /* Function arguments */
){
  assert( nArg==0 );
  UNUSED_PARAM2(nArg, apUnused);
  sqlite3_result_text(pCtx, "fts5: 2018-03-22 17:13:44 eb4f452e354065d610ff57a6a9312ad119b6b0cc467f9dff105f0718bc27ef01", -1, SQLITE_TRANSIENT);
}

static int fts5Init(sqlite3 *db){
  static const sqlite3_module fts5Mod = {
    /* iVersion      */ 2,
    /* xCreate       */ fts5CreateMethod,
    /* xConnect      */ fts5ConnectMethod,







|







205658
205659
205660
205661
205662
205663
205664
205665
205666
205667
205668
205669
205670
205671
205672
static void fts5SourceIdFunc(
  sqlite3_context *pCtx,          /* Function call context */
  int nArg,                       /* Number of args */
  sqlite3_value **apUnused        /* Function arguments */
){
  assert( nArg==0 );
  UNUSED_PARAM2(nArg, apUnused);
  sqlite3_result_text(pCtx, "fts5: 2018-04-10 17:39:29 4bb2294022060e61de7da5c227a69ccd846ba330e31626ebcd59a94efd148b3b", -1, SQLITE_TRANSIENT);
}

static int fts5Init(sqlite3 *db){
  static const sqlite3_module fts5Mod = {
    /* iVersion      */ 2,
    /* xCreate       */ fts5CreateMethod,
    /* xConnect      */ fts5ConnectMethod,
208965
208966
208967
208968
208969
208970
208971
208972
208973
208974
208975
208976
208977
208978
#endif
  return rc;
}
#endif /* SQLITE_CORE */
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */

/************** End of stmt.c ************************************************/
#if __LINE__!=208972
#undef SQLITE_SOURCE_ID
#define SQLITE_SOURCE_ID      "2018-03-22 17:13:44 eb4f452e354065d610ff57a6a9312ad119b6b0cc467f9dff105f0718bc27alt2"
#endif
/* Return the source-id for this library */
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
/************************** End of sqlite3.c ******************************/







|

|




209928
209929
209930
209931
209932
209933
209934
209935
209936
209937
209938
209939
209940
209941
#endif
  return rc;
}
#endif /* SQLITE_CORE */
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */

/************** End of stmt.c ************************************************/
#if __LINE__!=209935
#undef SQLITE_SOURCE_ID
#define SQLITE_SOURCE_ID      "2018-04-10 17:39:29 4bb2294022060e61de7da5c227a69ccd846ba330e31626ebcd59a94efd14alt2"
#endif
/* Return the source-id for this library */
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
/************************** End of sqlite3.c ******************************/
Changes to src/sqlite3.h.
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
** been edited in any way since it was last checked in, then the last
** four hexadecimal digits of the hash may be modified.
**
** See also: [sqlite3_libversion()],
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION        "3.23.0"
#define SQLITE_VERSION_NUMBER 3023000
#define SQLITE_SOURCE_ID      "2018-03-22 17:13:44 eb4f452e354065d610ff57a6a9312ad119b6b0cc467f9dff105f0718bc27ef01"

/*
** CAPI3REF: Run-Time Library Version Numbers
** KEYWORDS: sqlite3_version sqlite3_sourceid
**
** These interfaces provide the same information as the [SQLITE_VERSION],
** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros







|
|
|







119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
** been edited in any way since it was last checked in, then the last
** four hexadecimal digits of the hash may be modified.
**
** See also: [sqlite3_libversion()],
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION        "3.23.1"
#define SQLITE_VERSION_NUMBER 3023001
#define SQLITE_SOURCE_ID      "2018-04-10 17:39:29 4bb2294022060e61de7da5c227a69ccd846ba330e31626ebcd59a94efd148b3b"

/*
** CAPI3REF: Run-Time Library Version Numbers
** KEYWORDS: sqlite3_version sqlite3_sourceid
**
** These interfaces provide the same information as the [SQLITE_VERSION],
** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
1060
1061
1062
1063
1064
1065
1066






1067
1068
1069
1070
1071
1072
1073
** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write
** operations since the previous successful call to 
** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back.
** ^This file control takes the file descriptor out of batch write mode
** so that all subsequent write operations are independent.
** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without
** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].






** </ul>
*/
#define SQLITE_FCNTL_LOCKSTATE               1
#define SQLITE_FCNTL_GET_LOCKPROXYFILE       2
#define SQLITE_FCNTL_SET_LOCKPROXYFILE       3
#define SQLITE_FCNTL_LAST_ERRNO              4
#define SQLITE_FCNTL_SIZE_HINT               5







>
>
>
>
>
>







1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write
** operations since the previous successful call to 
** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back.
** ^This file control takes the file descriptor out of batch write mode
** so that all subsequent write operations are independent.
** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without
** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].
**
** <li>[[SQLITE_FCNTL_LOCK_TIMEOUT]]
** The [SQLITE_FCNTL_LOCK_TIMEOUT] opcode causes attempts to obtain
** a file lock using the xLock or xShmLock methods of the VFS to wait
** for up to M milliseconds before failing, where M is the single 
** unsigned integer parameter.
** </ul>
*/
#define SQLITE_FCNTL_LOCKSTATE               1
#define SQLITE_FCNTL_GET_LOCKPROXYFILE       2
#define SQLITE_FCNTL_SET_LOCKPROXYFILE       3
#define SQLITE_FCNTL_LAST_ERRNO              4
#define SQLITE_FCNTL_SIZE_HINT               5
1094
1095
1096
1097
1098
1099
1100

1101
1102
1103
1104
1105
1106
1107
#define SQLITE_FCNTL_VFS_POINTER            27
#define SQLITE_FCNTL_JOURNAL_POINTER        28
#define SQLITE_FCNTL_WIN32_GET_HANDLE       29
#define SQLITE_FCNTL_PDB                    30
#define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE     31
#define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE    32
#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE  33


/* deprecated names */
#define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
#define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE
#define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO









>







1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
#define SQLITE_FCNTL_VFS_POINTER            27
#define SQLITE_FCNTL_JOURNAL_POINTER        28
#define SQLITE_FCNTL_WIN32_GET_HANDLE       29
#define SQLITE_FCNTL_PDB                    30
#define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE     31
#define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE    32
#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE  33
#define SQLITE_FCNTL_LOCK_TIMEOUT           34

/* deprecated names */
#define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
#define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE
#define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO


8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
*/
#define SQLITE_SERIALIZE_NOCOPY 0x001   /* Do no memory allocations */

/*
** CAPI3REF: Deserialize a database
**
** The sqlite3_deserialize(D,S,P,N,M,F) interface causes the 
** [database connection] D to disconnection from database S and then
** reopen S as an in-memory database based on the serialization contained
** in P.  The serialized database P is N bytes in size.  M is the size of
** the buffer P, which might be larger than N.  If M is larger than N, and
** the SQLITE_DESERIALIZE_READONLY bit is not set in F, then SQLite is
** permitted to add content to the in-memory database as long as the total
** size does not exceed M bytes.
**







|







8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
*/
#define SQLITE_SERIALIZE_NOCOPY 0x001   /* Do no memory allocations */

/*
** CAPI3REF: Deserialize a database
**
** The sqlite3_deserialize(D,S,P,N,M,F) interface causes the 
** [database connection] D to disconnect from database S and then
** reopen S as an in-memory database based on the serialization contained
** in P.  The serialized database P is N bytes in size.  M is the size of
** the buffer P, which might be larger than N.  If M is larger than N, and
** the SQLITE_DESERIALIZE_READONLY bit is not set in F, then SQLite is
** permitted to add content to the in-memory database as long as the total
** size does not exceed M bytes.
**
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
** DESTRUCTOR: sqlite3_changegroup
*/
SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*);

/*
** CAPI3REF: Apply A Changeset To A Database
**
** Apply a changeset to a database. This function attempts to update the
** "main" database attached to handle db with the changes found in the
** changeset passed via the second and third arguments.
**
** The fourth argument (xFilter) passed to this function is the "filter
** callback". If it is not NULL, then for each table affected by at least one
** change in the changeset, the filter callback is invoked with
** the table name as the second argument, and a copy of the context pointer
** passed as the sixth argument to this function as the first. If the "filter
** callback" returns zero, then no attempt is made to apply any changes to 
** the table. Otherwise, if the return value is non-zero or the xFilter
** argument to this function is NULL, all changes related to the table are
** attempted.
**
** For each table that is not excluded by the filter callback, this function 
** tests that the target database contains a compatible table. A table is 
** considered compatible if all of the following are true:
**
** <ul>
**   <li> The table has the same name as the name recorded in the 







|
|
|

|



|
|
|
|
<







9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973

9974
9975
9976
9977
9978
9979
9980
** DESTRUCTOR: sqlite3_changegroup
*/
SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*);

/*
** CAPI3REF: Apply A Changeset To A Database
**
** Apply a changeset or patchset to a database. These functions attempt to
** update the "main" database attached to handle db with the changes found in
** the changeset passed via the second and third arguments. 
**
** The fourth argument (xFilter) passed to these functions is the "filter
** callback". If it is not NULL, then for each table affected by at least one
** change in the changeset, the filter callback is invoked with
** the table name as the second argument, and a copy of the context pointer
** passed as the sixth argument as the first. If the "filter callback"
** returns zero, then no attempt is made to apply any changes to the table.
** Otherwise, if the return value is non-zero or the xFilter argument to
** is NULL, all changes related to the table are attempted.

**
** For each table that is not excluded by the filter callback, this function 
** tests that the target database contains a compatible table. A table is 
** considered compatible if all of the following are true:
**
** <ul>
**   <li> The table has the same name as the name recorded in the 
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
** actions are taken by sqlite3changeset_apply() depending on the value
** returned by each invocation of the conflict-handler function. Refer to
** the documentation for the three 
** [SQLITE_CHANGESET_OMIT|available return values] for details.
**
** <dl>
** <dt>DELETE Changes<dd>
**   For each DELETE change, this function checks if the target database 
**   contains a row with the same primary key value (or values) as the 
**   original row values stored in the changeset. If it does, and the values 
**   stored in all non-primary key columns also match the values stored in 
**   the changeset the row is deleted from the target database.
**
**   If a row with matching primary key values is found, but one or more of
**   the non-primary key fields contains a value different from the original







|







10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
** actions are taken by sqlite3changeset_apply() depending on the value
** returned by each invocation of the conflict-handler function. Refer to
** the documentation for the three 
** [SQLITE_CHANGESET_OMIT|available return values] for details.
**
** <dl>
** <dt>DELETE Changes<dd>
**   For each DELETE change, the function checks if the target database 
**   contains a row with the same primary key value (or values) as the 
**   original row values stored in the changeset. If it does, and the values 
**   stored in all non-primary key columns also match the values stored in 
**   the changeset the row is deleted from the target database.
**
**   If a row with matching primary key values is found, but one or more of
**   the non-primary key fields contains a value different from the original
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
**   violation (e.g. NOT NULL or UNIQUE), the conflict handler function is 
**   invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT].
**   This includes the case where the INSERT operation is re-attempted because 
**   an earlier call to the conflict handler function returned 
**   [SQLITE_CHANGESET_REPLACE].
**
** <dt>UPDATE Changes<dd>
**   For each UPDATE change, this function checks if the target database 
**   contains a row with the same primary key value (or values) as the 
**   original row values stored in the changeset. If it does, and the values 
**   stored in all modified non-primary key columns also match the values
**   stored in the changeset the row is updated within the target database.
**
**   If a row with matching primary key values is found, but one or more of
**   the modified non-primary key fields contains a value different from an







|







10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
**   violation (e.g. NOT NULL or UNIQUE), the conflict handler function is 
**   invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT].
**   This includes the case where the INSERT operation is re-attempted because 
**   an earlier call to the conflict handler function returned 
**   [SQLITE_CHANGESET_REPLACE].
**
** <dt>UPDATE Changes<dd>
**   For each UPDATE change, the function checks if the target database 
**   contains a row with the same primary key value (or values) as the 
**   original row values stored in the changeset. If it does, and the values 
**   stored in all modified non-primary key columns also match the values
**   stored in the changeset the row is updated within the target database.
**
**   If a row with matching primary key values is found, but one or more of
**   the modified non-primary key fields contains a value different from an
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092

















10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108



































10109
10110
10111
10112
10113
10114
10115
** </dl>
**
** It is safe to execute SQL statements, including those that write to the
** table that the callback related to, from within the xConflict callback.
** This can be used to further customize the applications conflict
** resolution strategy.
**
** All changes made by this function are enclosed in a savepoint transaction.
** If any other error (aside from a constraint failure when attempting to
** write to the target database) occurs, then the savepoint transaction is
** rolled back, restoring the target database to its original state, and an 
** SQLite error code returned.

















*/
SQLITE_API int sqlite3changeset_apply(
  sqlite3 *db,                    /* Apply change to "main" db of this handle */
  int nChangeset,                 /* Size of changeset in bytes */
  void *pChangeset,               /* Changeset blob */
  int(*xFilter)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    const char *zTab              /* Table name */
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx                      /* First argument passed to xConflict */
);




































/* 
** CAPI3REF: Constants Passed To The Conflict Handler
**
** Values that may be passed as the second argument to a conflict-handler.
**
** <dl>







|




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
** </dl>
**
** It is safe to execute SQL statements, including those that write to the
** table that the callback related to, from within the xConflict callback.
** This can be used to further customize the applications conflict
** resolution strategy.
**
** All changes made by these functions are enclosed in a savepoint transaction.
** If any other error (aside from a constraint failure when attempting to
** write to the target database) occurs, then the savepoint transaction is
** rolled back, restoring the target database to its original state, and an 
** SQLite error code returned.
**
** If the output parameters (ppRebase) and (pnRebase) are non-NULL and
** the input is a changeset (not a patchset), then sqlite3changeset_apply_v2()
** may set (*ppRebase) to point to a "rebase" that may be used with the 
** sqlite3_rebaser APIs buffer before returning. In this case (*pnRebase)
** is set to the size of the buffer in bytes. It is the responsibility of the
** caller to eventually free any such buffer using sqlite3_free(). The buffer
** is only allocated and populated if one or more conflicts were encountered
** while applying the patchset. See comments surrounding the sqlite3_rebaser
** APIs for further details.
**
** The behavior of sqlite3changeset_apply_v2() and its streaming equivalent
** may be modified by passing a combination of
** [SQLITE_CHANGESETAPPLY_NOSAVEPOINT | supported flags] as the 9th parameter.
**
** Note that the sqlite3changeset_apply_v2() API is still <b>experimental</b>
** and therefore subject to change.
*/
SQLITE_API int sqlite3changeset_apply(
  sqlite3 *db,                    /* Apply change to "main" db of this handle */
  int nChangeset,                 /* Size of changeset in bytes */
  void *pChangeset,               /* Changeset blob */
  int(*xFilter)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    const char *zTab              /* Table name */
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx                      /* First argument passed to xConflict */
);
SQLITE_API int sqlite3changeset_apply_v2(
  sqlite3 *db,                    /* Apply change to "main" db of this handle */
  int nChangeset,                 /* Size of changeset in bytes */
  void *pChangeset,               /* Changeset blob */
  int(*xFilter)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    const char *zTab              /* Table name */
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx,                     /* First argument passed to xConflict */
  void **ppRebase, int *pnRebase, /* OUT: Rebase data */
  int flags                       /* Combination of SESSION_APPLY_* flags */
);

/*
** CAPI3REF: Flags for sqlite3changeset_apply_v2
**
** The following flags may passed via the 9th parameter to
** [sqlite3changeset_apply_v2] and [sqlite3changeset_apply_v2_strm]:
**
** <dl>
** <dt>SQLITE_CHANGESETAPPLY_NOSAVEPOINT <dd>
**   Usually, the sessions module encloses all operations performed by
**   a single call to apply_v2() or apply_v2_strm() in a [SAVEPOINT]. The
**   SAVEPOINT is committed if the changeset or patchset is successfully
**   applied, or rolled back if an error occurs. Specifying this flag
**   causes the sessions module to omit this savepoint. In this case, if the
**   caller has an open transaction or savepoint when apply_v2() is called, 
**   it may revert the partially applied changeset by rolling it back.
*/
#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT   0x0001

/* 
** CAPI3REF: Constants Passed To The Conflict Handler
**
** Values that may be passed as the second argument to a conflict-handler.
**
** <dl>
10199
10200
10201
10202
10203
10204
10205



























































































































































10206
10207
10208
10209
10210
10211
10212
10213
10214

10215
10216
10217
10218
10219
10220
10221
**   and the call to sqlite3changeset_apply() returns SQLITE_ABORT.
** </dl>
*/
#define SQLITE_CHANGESET_OMIT       0
#define SQLITE_CHANGESET_REPLACE    1
#define SQLITE_CHANGESET_ABORT      2




























































































































































/*
** CAPI3REF: Streaming Versions of API functions.
**
** The six streaming API xxx_strm() functions serve similar purposes to the 
** corresponding non-streaming API functions:
**
** <table border=1 style="margin-left:8ex;margin-right:8ex">
**   <tr><th>Streaming function<th>Non-streaming equivalent</th>
**   <tr><td>sqlite3changeset_apply_strm<td>[sqlite3changeset_apply] 

**   <tr><td>sqlite3changeset_concat_strm<td>[sqlite3changeset_concat] 
**   <tr><td>sqlite3changeset_invert_strm<td>[sqlite3changeset_invert] 
**   <tr><td>sqlite3changeset_start_strm<td>[sqlite3changeset_start] 
**   <tr><td>sqlite3session_changeset_strm<td>[sqlite3session_changeset] 
**   <tr><td>sqlite3session_patchset_strm<td>[sqlite3session_patchset] 
** </table>
**







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









>







10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
**   and the call to sqlite3changeset_apply() returns SQLITE_ABORT.
** </dl>
*/
#define SQLITE_CHANGESET_OMIT       0
#define SQLITE_CHANGESET_REPLACE    1
#define SQLITE_CHANGESET_ABORT      2

/* 
** CAPI3REF: Rebasing changesets
** EXPERIMENTAL
**
** Suppose there is a site hosting a database in state S0. And that
** modifications are made that move that database to state S1 and a
** changeset recorded (the "local" changeset). Then, a changeset based
** on S0 is received from another site (the "remote" changeset) and 
** applied to the database. The database is then in state 
** (S1+"remote"), where the exact state depends on any conflict
** resolution decisions (OMIT or REPLACE) made while applying "remote".
** Rebasing a changeset is to update it to take those conflict 
** resolution decisions into account, so that the same conflicts
** do not have to be resolved elsewhere in the network. 
**
** For example, if both the local and remote changesets contain an
** INSERT of the same key on "CREATE TABLE t1(a PRIMARY KEY, b)":
**
**   local:  INSERT INTO t1 VALUES(1, 'v1');
**   remote: INSERT INTO t1 VALUES(1, 'v2');
**
** and the conflict resolution is REPLACE, then the INSERT change is
** removed from the local changeset (it was overridden). Or, if the
** conflict resolution was "OMIT", then the local changeset is modified
** to instead contain:
**
**           UPDATE t1 SET b = 'v2' WHERE a=1;
**
** Changes within the local changeset are rebased as follows:
**
** <dl>
** <dt>Local INSERT<dd>
**   This may only conflict with a remote INSERT. If the conflict 
**   resolution was OMIT, then add an UPDATE change to the rebased
**   changeset. Or, if the conflict resolution was REPLACE, add
**   nothing to the rebased changeset.
**
** <dt>Local DELETE<dd>
**   This may conflict with a remote UPDATE or DELETE. In both cases the
**   only possible resolution is OMIT. If the remote operation was a
**   DELETE, then add no change to the rebased changeset. If the remote
**   operation was an UPDATE, then the old.* fields of change are updated
**   to reflect the new.* values in the UPDATE.
**
** <dt>Local UPDATE<dd>
**   This may conflict with a remote UPDATE or DELETE. If it conflicts
**   with a DELETE, and the conflict resolution was OMIT, then the update
**   is changed into an INSERT. Any undefined values in the new.* record
**   from the update change are filled in using the old.* values from
**   the conflicting DELETE. Or, if the conflict resolution was REPLACE,
**   the UPDATE change is simply omitted from the rebased changeset.
**
**   If conflict is with a remote UPDATE and the resolution is OMIT, then
**   the old.* values are rebased using the new.* values in the remote
**   change. Or, if the resolution is REPLACE, then the change is copied
**   into the rebased changeset with updates to columns also updated by
**   the conflicting remote UPDATE removed. If this means no columns would 
**   be updated, the change is omitted.
** </dl>
**
** A local change may be rebased against multiple remote changes 
** simultaneously. If a single key is modified by multiple remote 
** changesets, they are combined as follows before the local changeset
** is rebased:
**
** <ul>
**    <li> If there has been one or more REPLACE resolutions on a
**         key, it is rebased according to a REPLACE.
**
**    <li> If there have been no REPLACE resolutions on a key, then
**         the local changeset is rebased according to the most recent
**         of the OMIT resolutions.
** </ul>
**
** Note that conflict resolutions from multiple remote changesets are 
** combined on a per-field basis, not per-row. This means that in the 
** case of multiple remote UPDATE operations, some fields of a single 
** local change may be rebased for REPLACE while others are rebased for 
** OMIT.
**
** In order to rebase a local changeset, the remote changeset must first
** be applied to the local database using sqlite3changeset_apply_v2() and
** the buffer of rebase information captured. Then:
**
** <ol>
**   <li> An sqlite3_rebaser object is created by calling 
**        sqlite3rebaser_create().
**   <li> The new object is configured with the rebase buffer obtained from
**        sqlite3changeset_apply_v2() by calling sqlite3rebaser_configure().
**        If the local changeset is to be rebased against multiple remote
**        changesets, then sqlite3rebaser_configure() should be called
**        multiple times, in the same order that the multiple
**        sqlite3changeset_apply_v2() calls were made.
**   <li> Each local changeset is rebased by calling sqlite3rebaser_rebase().
**   <li> The sqlite3_rebaser object is deleted by calling
**        sqlite3rebaser_delete().
** </ol>
*/
typedef struct sqlite3_rebaser sqlite3_rebaser;

/*
** CAPI3REF: Create a changeset rebaser object.
** EXPERIMENTAL
**
** Allocate a new changeset rebaser object. If successful, set (*ppNew) to
** point to the new object and return SQLITE_OK. Otherwise, if an error
** occurs, return an SQLite error code (e.g. SQLITE_NOMEM) and set (*ppNew) 
** to NULL. 
*/
SQLITE_API int sqlite3rebaser_create(sqlite3_rebaser **ppNew);

/*
** CAPI3REF: Configure a changeset rebaser object.
** EXPERIMENTAL
**
** Configure the changeset rebaser object to rebase changesets according
** to the conflict resolutions described by buffer pRebase (size nRebase
** bytes), which must have been obtained from a previous call to
** sqlite3changeset_apply_v2().
*/
SQLITE_API int sqlite3rebaser_configure(
  sqlite3_rebaser*, 
  int nRebase, const void *pRebase
); 

/*
** CAPI3REF: Rebase a changeset
** EXPERIMENTAL
**
** Argument pIn must point to a buffer containing a changeset nIn bytes
** in size. This function allocates and populates a buffer with a copy
** of the changeset rebased rebased according to the configuration of the
** rebaser object passed as the first argument. If successful, (*ppOut)
** is set to point to the new buffer containing the rebased changset and 
** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the
** responsibility of the caller to eventually free the new buffer using
** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)
** are set to zero and an SQLite error code returned.
*/
SQLITE_API int sqlite3rebaser_rebase(
  sqlite3_rebaser*,
  int nIn, const void *pIn, 
  int *pnOut, void **ppOut 
);

/*
** CAPI3REF: Delete a changeset rebaser object.
** EXPERIMENTAL
**
** Delete the changeset rebaser object and all associated resources. There
** should be one call to this function for each successful invocation
** of sqlite3rebaser_create().
*/
SQLITE_API void sqlite3rebaser_delete(sqlite3_rebaser *p); 

/*
** CAPI3REF: Streaming Versions of API functions.
**
** The six streaming API xxx_strm() functions serve similar purposes to the 
** corresponding non-streaming API functions:
**
** <table border=1 style="margin-left:8ex;margin-right:8ex">
**   <tr><th>Streaming function<th>Non-streaming equivalent</th>
**   <tr><td>sqlite3changeset_apply_strm<td>[sqlite3changeset_apply] 
**   <tr><td>sqlite3changeset_apply_strm_v2<td>[sqlite3changeset_apply_v2] 
**   <tr><td>sqlite3changeset_concat_strm<td>[sqlite3changeset_concat] 
**   <tr><td>sqlite3changeset_invert_strm<td>[sqlite3changeset_invert] 
**   <tr><td>sqlite3changeset_start_strm<td>[sqlite3changeset_start] 
**   <tr><td>sqlite3session_changeset_strm<td>[sqlite3session_changeset] 
**   <tr><td>sqlite3session_patchset_strm<td>[sqlite3session_patchset] 
** </table>
**
10302
10303
10304
10305
10306
10307
10308

















10309
10310
10311
10312
10313
10314
10315
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx                      /* First argument passed to xConflict */

















);
SQLITE_API int sqlite3changeset_concat_strm(
  int (*xInputA)(void *pIn, void *pData, int *pnData),
  void *pInA,
  int (*xInputB)(void *pIn, void *pData, int *pnData),
  void *pInB,
  int (*xOutput)(void *pOut, const void *pData, int nData),







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx                      /* First argument passed to xConflict */
);
SQLITE_API int sqlite3changeset_apply_v2_strm(
  sqlite3 *db,                    /* Apply change to "main" db of this handle */
  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
  void *pIn,                                          /* First arg for xInput */
  int(*xFilter)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    const char *zTab              /* Table name */
  ),
  int(*xConflict)(
    void *pCtx,                   /* Copy of sixth arg to _apply() */
    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */
    sqlite3_changeset_iter *p     /* Handle describing change and conflict */
  ),
  void *pCtx,                     /* First argument passed to xConflict */
  void **ppRebase, int *pnRebase,
  int flags
);
SQLITE_API int sqlite3changeset_concat_strm(
  int (*xInputA)(void *pIn, void *pData, int *pnData),
  void *pInA,
  int (*xInputB)(void *pIn, void *pData, int *pnData),
  void *pInB,
  int (*xOutput)(void *pOut, const void *pData, int nData),
10339
10340
10341
10342
10343
10344
10345







10346
10347
10348
10349
10350
10351
10352
SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*, 
    int (*xInput)(void *pIn, void *pData, int *pnData),
    void *pIn
);
SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*,
    int (*xOutput)(void *pOut, const void *pData, int nData), 
    void *pOut







);


/*
** Make sure we can call this stuff from C++.
*/
#ifdef __cplusplus







>
>
>
>
>
>
>







10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*, 
    int (*xInput)(void *pIn, void *pData, int *pnData),
    void *pIn
);
SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*,
    int (*xOutput)(void *pOut, const void *pData, int nData), 
    void *pOut
);
SQLITE_API int sqlite3rebaser_rebase_strm(
  sqlite3_rebaser *pRebaser,
  int (*xInput)(void *pIn, void *pData, int *pnData),
  void *pIn,
  int (*xOutput)(void *pOut, const void *pData, int nData),
  void *pOut
);


/*
** Make sure we can call this stuff from C++.
*/
#ifdef __cplusplus
Changes to src/tar.c.
644
645
646
647
648
649
650





























651
652
653
654
655
656
657
658








659
660
661
662
663
664
665
666
667
668
669
670
671



672
673
674
675
676
677
678
  }
  tarball_of_checkin(rid, &tarball, zName, pInclude, pExclude);
  glob_free(pInclude);
  glob_free(pExclude);
  blob_write_to_file(&tarball, g.argv[3]);
  blob_reset(&tarball);
}






























/*
** WEBPAGE: tarball
** URL: /tarball
**
** Generate a compressed tarball for the check-in specified by the "r"
** query parameter.  Return that compressed tarball as the HTTP reply
** content.








**
** Query parameters:
**
**   name=NAME[.tar.gz]  The base name of the output file.  The default
**                       value is a configuration parameter in the project
**                       settings.  A prefix of the name, omitting the
**                       extension, is used as the top-most directory name.
**
**   r=TAG               The check-in that is turned into a compressed tarball.
**                       Defaults to "trunk".  This query parameter used to
**                       be called "uuid" and "uuid" is still accepted for
**                       backwards compatibility.  If omitted, the default
**                       check-in name is "trunk".



**
**   in=PATTERN          Only include files that match the comma-separate
**                       list of GLOB patterns in PATTERN, as with ex=
**
**   ex=PATTERN          Omit any file that match PATTERN.  PATTERN is a
**                       comma-separated list of GLOB patterns, where each
**                       pattern can optionally be quoted using ".." or '..'.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>








>
>
>
>
>
>
>
>











|
|
>
>
>







644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
  }
  tarball_of_checkin(rid, &tarball, zName, pInclude, pExclude);
  glob_free(pInclude);
  glob_free(pExclude);
  blob_write_to_file(&tarball, g.argv[3]);
  blob_reset(&tarball);
}

/*
** Check to see if the input string is of the form:
**
**        checkin-name/filename.ext
**
** In other words, check to see if the input contains a single '/'
** character that separates a valid check-in name from a filename.
**
** If the condition is true, return the check-in name and set the
** input string to be the filename.
**
** If the condition is false, return NULL
*/
char *tar_uuid_from_name(char **pzName){
  char *zName = *pzName;
  int i, n;
  for(i=n=0; zName[i]; i++){
    if( zName[i]=='/' ){
      if( n==0 ) n = i;
      else return 0;
    }
  }
  if( n==0 ) return 0;
  if( zName[n+1]==0 ) return 0;
  zName[n] = 0;
  *pzName = fossil_strdup(&zName[n+1]);
  return zName;
}

/*
** WEBPAGE: tarball
** URL: /tarball
**
** Generate a compressed tarball for the check-in specified by the "r"
** query parameter.  Return that compressed tarball as the HTTP reply
** content.
**
** The r= and name= query parameters can be specified as extensions to the
** URI.  Example, the following URIs are all equivalent:
**
**      /tarball/release/xyz.tar.gz
**      /tarball?r=release&name=xyz.tar.gz
**      /tarball/xyz.tar.gz?r=release
**      /tarball?name=release/xyz.tar.gz
**
** Query parameters:
**
**   name=NAME[.tar.gz]  The base name of the output file.  The default
**                       value is a configuration parameter in the project
**                       settings.  A prefix of the name, omitting the
**                       extension, is used as the top-most directory name.
**
**   r=TAG               The check-in that is turned into a compressed tarball.
**                       Defaults to "trunk".  This query parameter used to
**                       be called "uuid" and "uuid" is still accepted for
**                       backwards compatibility.  If the name= query parameter
**                       contains one "/" character then the part before the /
**                       is the TAG and the part after the / is the true name.
**                       If no TAG is specified by any of the above means, then
**                       "trunk" is used as the default.
**
**   in=PATTERN          Only include files that match the comma-separate
**                       list of GLOB patterns in PATTERN, as with ex=
**
**   ex=PATTERN          Omit any file that match PATTERN.  PATTERN is a
**                       comma-separated list of GLOB patterns, where each
**                       pattern can optionally be quoted using ".." or '..'.
689
690
691
692
693
694
695
696
697
698
699

700
701
702
703
704
705
706

707
708
709
710
711
712
713
  Glob *pExclude = 0;           /* The compiled ex= glob pattern */
  Blob tarball;                 /* Tarball accumulated here */
  const char *z;

  login_check_credentials();
  if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
  load_control();
  zName = mprintf("%s", PD("name",""));
  nName = strlen(zName);
  z = P("r");
  if( z==0 ) z = P("uuid");

  if( z==0 ) z = "trunk";
  g.zOpenRevision = zRid = fossil_strdup(z);
  nRid = strlen(zRid);
  zInclude = P("in");
  if( zInclude ) pInclude = glob_create(zInclude);
  zExclude = P("ex");
  if( zExclude ) pExclude = glob_create(zExclude);

  if( nName>7 && fossil_strcmp(&zName[nName-7], ".tar.gz")==0 ){
    /* Special case:  Remove the ".tar.gz" suffix.  */
    nName -= 7;
    zName[nName] = 0;
  }else{
    /* If the file suffix is not ".tar.gz" then just remove the
    ** suffix up to and including the last "." */







|
<


>







>







729
730
731
732
733
734
735
736

737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
  Glob *pExclude = 0;           /* The compiled ex= glob pattern */
  Blob tarball;                 /* Tarball accumulated here */
  const char *z;

  login_check_credentials();
  if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
  load_control();
  zName = fossil_strdup(PD("name",""));

  z = P("r");
  if( z==0 ) z = P("uuid");
  if( z==0 ) z = tar_uuid_from_name(&zName);
  if( z==0 ) z = "trunk";
  g.zOpenRevision = zRid = fossil_strdup(z);
  nRid = strlen(zRid);
  zInclude = P("in");
  if( zInclude ) pInclude = glob_create(zInclude);
  zExclude = P("ex");
  if( zExclude ) pExclude = glob_create(zExclude);
  nName = strlen(zName);
  if( nName>7 && fossil_strcmp(&zName[nName-7], ".tar.gz")==0 ){
    /* Special case:  Remove the ".tar.gz" suffix.  */
    nName -= 7;
    zName[nName] = 0;
  }else{
    /* If the file suffix is not ".tar.gz" then just remove the
    ** suffix up to and including the last "." */
Changes to src/zip.c.
834
835
836
837
838
839
840









841
842
843
844
845
846
847
/*
** WEBPAGE: sqlar
** WEBPAGE: zip
**
** Generate a ZIP or SQL archive for the check-in specified by the "r"
** query parameter.  Return the archive as the HTTP reply content.
**









** Query parameters:
**
**   name=NAME           The base name of the output file.  The default
**                       value is a configuration parameter in the project
**                       settings.  A prefix of the name, omitting the
**                       extension, is used as the top-most directory name.
**







>
>
>
>
>
>
>
>
>







834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
/*
** WEBPAGE: sqlar
** WEBPAGE: zip
**
** Generate a ZIP or SQL archive for the check-in specified by the "r"
** query parameter.  Return the archive as the HTTP reply content.
**
** If the NAME contains one "/" then the part before the "/" is taken
** as the TAG and the part after the "/" becomes the true name.  Hence,
** the following URLs are all equivalent:
**
**     /sqlar/508c42a6398f8/download.sqlar
**     /sqlar?r=508c42a6398f8&name=download.sqlar
**     /sqlar/download.sqlar?r=508c42a6398f8
**     /sqlar?name=508c42a6398f8/download.sqlar
**
** Query parameters:
**
**   name=NAME           The base name of the output file.  The default
**                       value is a configuration parameter in the project
**                       settings.  A prefix of the name, omitting the
**                       extension, is used as the top-most directory name.
**
881
882
883
884
885
886
887
888
889
890

891

892
893
894
895
896
897
898
    zType = "SQL";
  }else{
    eType = ARCHIVE_ZIP;
    zType = "ZIP";
  }
  load_control();
  zName = mprintf("%s", PD("name",""));
  nName = strlen(zName);
  z = P("r");
  if( z==0 ) z = P("uuid");

  if( z==0 ) z = "trunk";

  g.zOpenRevision = zRid = fossil_strdup(z);
  nRid = strlen(zRid);
  zInclude = P("in");
  if( zInclude ) pInclude = glob_create(zInclude);
  zExclude = P("ex");
  if( zExclude ) pExclude = glob_create(zExclude);
  if( eType==ARCHIVE_ZIP 







<


>

>







890
891
892
893
894
895
896

897
898
899
900
901
902
903
904
905
906
907
908
    zType = "SQL";
  }else{
    eType = ARCHIVE_ZIP;
    zType = "ZIP";
  }
  load_control();
  zName = mprintf("%s", PD("name",""));

  z = P("r");
  if( z==0 ) z = P("uuid");
  if( z==0 ) z = tar_uuid_from_name(&zName);
  if( z==0 ) z = "trunk";
  nName = strlen(zName);
  g.zOpenRevision = zRid = fossil_strdup(z);
  nRid = strlen(zRid);
  zInclude = P("in");
  if( zInclude ) pInclude = glob_create(zInclude);
  zExclude = P("ex");
  if( zExclude ) pExclude = glob_create(zExclude);
  if( eType==ARCHIVE_ZIP 
Changes to win/Makefile.PellesCGMake.
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
UTILS_OBJ=$(UTILS:.exe=.obj)
UTILS_SRC=$(foreach uf,$(UTILS),$(SRCDIR)$(uf:.exe=.c))

# define the SQLite files, which need special flags on compile
SQLITESRC=sqlite3.c
ORIGSQLITESRC=$(foreach sf,$(SQLITESRC),$(SRCDIR)$(sf))
SQLITEOBJ=$(foreach sf,$(SQLITESRC),$(sf:.c=.obj))
SQLITEDEFINES=-DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_USE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_WIN32_NO_ANSI

# define the SQLite shell files, which need special flags on compile
SQLITESHELLSRC=shell.c
ORIGSQLITESHELLSRC=$(foreach sf,$(SQLITESHELLSRC),$(SRCDIR)$(sf))
SQLITESHELLOBJ=$(foreach sf,$(SQLITESHELLSRC),$(sf:.c=.obj))
SQLITESHELLDEFINES=-DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_USE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=fossil_open -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen

# define the th scripting files, which need special flags on compile
THSRC=th.c th_lang.c
ORIGTHSRC=$(foreach sf,$(THSRC),$(SRCDIR)$(sf))
THOBJ=$(foreach sf,$(THSRC),$(sf:.c=.obj))

# define the zlib files, needed by this compile







|





|







81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
UTILS_OBJ=$(UTILS:.exe=.obj)
UTILS_SRC=$(foreach uf,$(UTILS),$(SRCDIR)$(uf:.exe=.c))

# define the SQLite files, which need special flags on compile
SQLITESRC=sqlite3.c
ORIGSQLITESRC=$(foreach sf,$(SQLITESRC),$(SRCDIR)$(sf))
SQLITEOBJ=$(foreach sf,$(SQLITESRC),$(sf:.c=.obj))
SQLITEDEFINES=-DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_WIN32_NO_ANSI

# define the SQLite shell files, which need special flags on compile
SQLITESHELLSRC=shell.c
ORIGSQLITESHELLSRC=$(foreach sf,$(SQLITESHELLSRC),$(SRCDIR)$(sf))
SQLITESHELLOBJ=$(foreach sf,$(SQLITESHELLSRC),$(sf:.c=.obj))
SQLITESHELLDEFINES=-DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=fossil_open -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen

# define the th scripting files, which need special flags on compile
THSRC=th.c th_lang.c
ORIGTHSRC=$(foreach sf,$(THSRC),$(SRCDIR)$(sf))
THOBJ=$(foreach sf,$(THSRC),$(sf:.c=.obj))

# define the zlib files, needed by this compile
Changes to win/Makefile.dmc.
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
SSL    =

CFLAGS = -o
BCC    = $(DMDIR)\bin\dmc $(CFLAGS)
TCC    = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
LIBS   = $(DMDIR)\extra\lib\ zlib wsock32 advapi32

SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_USE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB

SHELL_OPTIONS = -DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_USE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=fossil_open -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen

SRC   = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c cookies_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c dispatch_.c doc_.c encode_.c etag_.c event_.c export_.c file_.c finfo_.c foci_.c fshell_.c fusefs_.c glob_.c graph_.c gzip_.c hname_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c piechart_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c security_audit_.c setup_.c sha1_.c sha1hard_.c sha3_.c shun_.c sitemap_.c skins_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c unversioned_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c

OBJ   = $(OBJDIR)\add$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\cookies$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\dispatch$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\etag$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\fshell$O $(OBJDIR)\fusefs$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\hname$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\piechart$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\security_audit$O $(OBJDIR)\setup$O $(OBJDIR)\sha1$O $(OBJDIR)\sha1hard$O $(OBJDIR)\sha3$O $(OBJDIR)\shun$O $(OBJDIR)\sitemap$O $(OBJDIR)\skins$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\statrep$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\unversioned$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O


RC=$(DMDIR)\bin\rcc







|

|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
SSL    =

CFLAGS = -o
BCC    = $(DMDIR)\bin\dmc $(CFLAGS)
TCC    = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
LIBS   = $(DMDIR)\extra\lib\ zlib wsock32 advapi32

SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB

SHELL_OPTIONS = -DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=fossil_open -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen

SRC   = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c cookies_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c dispatch_.c doc_.c encode_.c etag_.c event_.c export_.c file_.c finfo_.c foci_.c fshell_.c fusefs_.c glob_.c graph_.c gzip_.c hname_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c piechart_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c security_audit_.c setup_.c sha1_.c sha1hard_.c sha3_.c shun_.c sitemap_.c skins_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c unversioned_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c

OBJ   = $(OBJDIR)\add$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\cookies$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\dispatch$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\etag$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\fshell$O $(OBJDIR)\fusefs$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\hname$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\piechart$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\security_audit$O $(OBJDIR)\setup$O $(OBJDIR)\sha1$O $(OBJDIR)\sha1hard$O $(OBJDIR)\sha3$O $(OBJDIR)\shun$O $(OBJDIR)\sitemap$O $(OBJDIR)\skins$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\statrep$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\unversioned$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O


RC=$(DMDIR)\bin\rcc
Changes to win/Makefile.mingw.
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
endif

#### The directories where the OpenSSL include and library files are located.
#    The recommended usage here is to use the Sysinternals junction tool
#    to create a hard link between an "openssl-1.x" sub-directory of the
#    Fossil source code directory and the target OpenSSL source directory.
#
OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.1.0h
OPENSSLINCDIR = $(OPENSSLDIR)/include
OPENSSLLIBDIR = $(OPENSSLDIR)

#### Either the directory where the Tcl library is installed or the Tcl
#    source code directory resides (depending on the value of the macro
#    FOSSIL_TCL_SOURCE).  If this points to the Tcl install directory,
#    this directory must have "include" and "lib" sub-directories.  If







|







172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
endif

#### The directories where the OpenSSL include and library files are located.
#    The recommended usage here is to use the Sysinternals junction tool
#    to create a hard link between an "openssl-1.x" sub-directory of the
#    Fossil source code directory and the target OpenSSL source directory.
#
OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.1.1-pre4
OPENSSLINCDIR = $(OPENSSLDIR)/include
OPENSSLLIBDIR = $(OPENSSLDIR)

#### Either the directory where the Tcl library is installed or the Tcl
#    source code directory resides (depending on the value of the macro
#    FOSSIL_TCL_SOURCE).  If this points to the Tcl install directory,
#    this directory must have "include" and "lib" sub-directories.  If
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
                 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                 -DSQLITE_ENABLE_FTS4 \
                 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
                 -DSQLITE_ENABLE_DBSTAT_VTAB \
                 -DSQLITE_ENABLE_JSON1 \
                 -DSQLITE_ENABLE_FTS5 \
                 -DSQLITE_ENABLE_STMTVTAB \
                 -DSQLITE_USE_ZLIB \
                 -DSQLITE_INTROSPECTION_PRAGMAS \
                 -DSQLITE_ENABLE_DBPAGE_VTAB \
                 -DSQLITE_WIN32_NO_ANSI \
                 $(MINGW_OPTIONS) \
                 -DSQLITE_USE_MALLOC_H \
                 -DSQLITE_USE_MSIZE








|







2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
                 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                 -DSQLITE_ENABLE_FTS4 \
                 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
                 -DSQLITE_ENABLE_DBSTAT_VTAB \
                 -DSQLITE_ENABLE_JSON1 \
                 -DSQLITE_ENABLE_FTS5 \
                 -DSQLITE_ENABLE_STMTVTAB \
                 -DSQLITE_HAVE_ZLIB \
                 -DSQLITE_INTROSPECTION_PRAGMAS \
                 -DSQLITE_ENABLE_DBPAGE_VTAB \
                 -DSQLITE_WIN32_NO_ANSI \
                 $(MINGW_OPTIONS) \
                 -DSQLITE_USE_MALLOC_H \
                 -DSQLITE_USE_MSIZE

2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
                -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                -DSQLITE_ENABLE_FTS4 \
                -DSQLITE_ENABLE_FTS3_PARENTHESIS \
                -DSQLITE_ENABLE_DBSTAT_VTAB \
                -DSQLITE_ENABLE_JSON1 \
                -DSQLITE_ENABLE_FTS5 \
                -DSQLITE_ENABLE_STMTVTAB \
                -DSQLITE_USE_ZLIB \
                -DSQLITE_INTROSPECTION_PRAGMAS \
                -DSQLITE_ENABLE_DBPAGE_VTAB \
                -Dmain=sqlite3_shell \
                -DSQLITE_SHELL_IS_UTF8=1 \
                -DSQLITE_OMIT_LOAD_EXTENSION=1 \
                -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
                -DSQLITE_SHELL_DBNAME_PROC=fossil_open \







|







2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
                -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                -DSQLITE_ENABLE_FTS4 \
                -DSQLITE_ENABLE_FTS3_PARENTHESIS \
                -DSQLITE_ENABLE_DBSTAT_VTAB \
                -DSQLITE_ENABLE_JSON1 \
                -DSQLITE_ENABLE_FTS5 \
                -DSQLITE_ENABLE_STMTVTAB \
                -DSQLITE_HAVE_ZLIB \
                -DSQLITE_INTROSPECTION_PRAGMAS \
                -DSQLITE_ENABLE_DBPAGE_VTAB \
                -Dmain=sqlite3_shell \
                -DSQLITE_SHELL_IS_UTF8=1 \
                -DSQLITE_OMIT_LOAD_EXTENSION=1 \
                -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
                -DSQLITE_SHELL_DBNAME_PROC=fossil_open \
Changes to win/Makefile.mingw.mistachkin.
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
endif

#### The directories where the OpenSSL include and library files are located.
#    The recommended usage here is to use the Sysinternals junction tool
#    to create a hard link between an "openssl-1.x" sub-directory of the
#    Fossil source code directory and the target OpenSSL source directory.
#
OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.1.0h
OPENSSLINCDIR = $(OPENSSLDIR)/include
OPENSSLLIBDIR = $(OPENSSLDIR)

#### Either the directory where the Tcl library is installed or the Tcl
#    source code directory resides (depending on the value of the macro
#    FOSSIL_TCL_SOURCE).  If this points to the Tcl install directory,
#    this directory must have "include" and "lib" sub-directories.  If







|







172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
endif

#### The directories where the OpenSSL include and library files are located.
#    The recommended usage here is to use the Sysinternals junction tool
#    to create a hard link between an "openssl-1.x" sub-directory of the
#    Fossil source code directory and the target OpenSSL source directory.
#
OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.1.1-pre4
OPENSSLINCDIR = $(OPENSSLDIR)/include
OPENSSLLIBDIR = $(OPENSSLDIR)

#### Either the directory where the Tcl library is installed or the Tcl
#    source code directory resides (depending on the value of the macro
#    FOSSIL_TCL_SOURCE).  If this points to the Tcl install directory,
#    this directory must have "include" and "lib" sub-directories.  If
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
                 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                 -DSQLITE_ENABLE_FTS4 \
                 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
                 -DSQLITE_ENABLE_DBSTAT_VTAB \
                 -DSQLITE_ENABLE_JSON1 \
                 -DSQLITE_ENABLE_FTS5 \
                 -DSQLITE_ENABLE_STMTVTAB \
                 -DSQLITE_USE_ZLIB \
                 -DSQLITE_INTROSPECTION_PRAGMAS \
                 -DSQLITE_ENABLE_DBPAGE_VTAB \
                 -DSQLITE_WIN32_NO_ANSI \
                 $(MINGW_OPTIONS) \
                 -DSQLITE_USE_MALLOC_H \
                 -DSQLITE_USE_MSIZE








|







2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
                 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                 -DSQLITE_ENABLE_FTS4 \
                 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
                 -DSQLITE_ENABLE_DBSTAT_VTAB \
                 -DSQLITE_ENABLE_JSON1 \
                 -DSQLITE_ENABLE_FTS5 \
                 -DSQLITE_ENABLE_STMTVTAB \
                 -DSQLITE_HAVE_ZLIB \
                 -DSQLITE_INTROSPECTION_PRAGMAS \
                 -DSQLITE_ENABLE_DBPAGE_VTAB \
                 -DSQLITE_WIN32_NO_ANSI \
                 $(MINGW_OPTIONS) \
                 -DSQLITE_USE_MALLOC_H \
                 -DSQLITE_USE_MSIZE

2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
                -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                -DSQLITE_ENABLE_FTS4 \
                -DSQLITE_ENABLE_FTS3_PARENTHESIS \
                -DSQLITE_ENABLE_DBSTAT_VTAB \
                -DSQLITE_ENABLE_JSON1 \
                -DSQLITE_ENABLE_FTS5 \
                -DSQLITE_ENABLE_STMTVTAB \
                -DSQLITE_USE_ZLIB \
                -DSQLITE_INTROSPECTION_PRAGMAS \
                -DSQLITE_ENABLE_DBPAGE_VTAB \
                -Dmain=sqlite3_shell \
                -DSQLITE_SHELL_IS_UTF8=1 \
                -DSQLITE_OMIT_LOAD_EXTENSION=1 \
                -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
                -DSQLITE_SHELL_DBNAME_PROC=fossil_open \







|







2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
                -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                -DSQLITE_ENABLE_FTS4 \
                -DSQLITE_ENABLE_FTS3_PARENTHESIS \
                -DSQLITE_ENABLE_DBSTAT_VTAB \
                -DSQLITE_ENABLE_JSON1 \
                -DSQLITE_ENABLE_FTS5 \
                -DSQLITE_ENABLE_STMTVTAB \
                -DSQLITE_HAVE_ZLIB \
                -DSQLITE_INTROSPECTION_PRAGMAS \
                -DSQLITE_ENABLE_DBPAGE_VTAB \
                -Dmain=sqlite3_shell \
                -DSQLITE_SHELL_IS_UTF8=1 \
                -DSQLITE_OMIT_LOAD_EXTENSION=1 \
                -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
                -DSQLITE_SHELL_DBNAME_PROC=fossil_open \
Changes to win/Makefile.msc.
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

# Enable support for the SQLite Encryption Extension?
!ifndef USE_SEE
USE_SEE = 0
!endif

!if $(FOSSIL_ENABLE_SSL)!=0
SSLDIR    = $(B)\compat\openssl-1.1.0h
SSLINCDIR = $(SSLDIR)\inc32
!if $(FOSSIL_DYNAMIC_BUILD)!=0
SSLLIBDIR = $(SSLDIR)\out32dll
!else
SSLLIBDIR = $(SSLDIR)\out32
!endif
SSLLFLAGS = /nologo /opt:ref /debug







|







96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

# Enable support for the SQLite Encryption Extension?
!ifndef USE_SEE
USE_SEE = 0
!endif

!if $(FOSSIL_ENABLE_SSL)!=0
SSLDIR    = $(B)\compat\openssl-1.1.1-pre4
SSLINCDIR = $(SSLDIR)\inc32
!if $(FOSSIL_DYNAMIC_BUILD)!=0
SSLLIBDIR = $(SSLDIR)\out32dll
!else
SSLLIBDIR = $(SSLDIR)\out32
!endif
SSLLFLAGS = /nologo /opt:ref /debug
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
                 /DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                 /DSQLITE_ENABLE_FTS4 \
                 /DSQLITE_ENABLE_FTS3_PARENTHESIS \
                 /DSQLITE_ENABLE_DBSTAT_VTAB \
                 /DSQLITE_ENABLE_JSON1 \
                 /DSQLITE_ENABLE_FTS5 \
                 /DSQLITE_ENABLE_STMTVTAB \
                 /DSQLITE_USE_ZLIB \
                 /DSQLITE_INTROSPECTION_PRAGMAS \
                 /DSQLITE_ENABLE_DBPAGE_VTAB \
                 /DSQLITE_WIN32_NO_ANSI

SHELL_OPTIONS = /DNDEBUG=1 \
                /DSQLITE_THREADSAFE=0 \
                /DSQLITE_DEFAULT_MEMSTATUS=0 \







|







331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
                 /DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                 /DSQLITE_ENABLE_FTS4 \
                 /DSQLITE_ENABLE_FTS3_PARENTHESIS \
                 /DSQLITE_ENABLE_DBSTAT_VTAB \
                 /DSQLITE_ENABLE_JSON1 \
                 /DSQLITE_ENABLE_FTS5 \
                 /DSQLITE_ENABLE_STMTVTAB \
                 /DSQLITE_HAVE_ZLIB \
                 /DSQLITE_INTROSPECTION_PRAGMAS \
                 /DSQLITE_ENABLE_DBPAGE_VTAB \
                 /DSQLITE_WIN32_NO_ANSI

SHELL_OPTIONS = /DNDEBUG=1 \
                /DSQLITE_THREADSAFE=0 \
                /DSQLITE_DEFAULT_MEMSTATUS=0 \
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
                /DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                /DSQLITE_ENABLE_FTS4 \
                /DSQLITE_ENABLE_FTS3_PARENTHESIS \
                /DSQLITE_ENABLE_DBSTAT_VTAB \
                /DSQLITE_ENABLE_JSON1 \
                /DSQLITE_ENABLE_FTS5 \
                /DSQLITE_ENABLE_STMTVTAB \
                /DSQLITE_USE_ZLIB \
                /DSQLITE_INTROSPECTION_PRAGMAS \
                /DSQLITE_ENABLE_DBPAGE_VTAB \
                /Dmain=sqlite3_shell \
                /DSQLITE_SHELL_IS_UTF8=1 \
                /DSQLITE_OMIT_LOAD_EXTENSION=1 \
                /DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
                /DSQLITE_SHELL_DBNAME_PROC=fossil_open \







|







358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
                /DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                /DSQLITE_ENABLE_FTS4 \
                /DSQLITE_ENABLE_FTS3_PARENTHESIS \
                /DSQLITE_ENABLE_DBSTAT_VTAB \
                /DSQLITE_ENABLE_JSON1 \
                /DSQLITE_ENABLE_FTS5 \
                /DSQLITE_ENABLE_STMTVTAB \
                /DSQLITE_HAVE_ZLIB \
                /DSQLITE_INTROSPECTION_PRAGMAS \
                /DSQLITE_ENABLE_DBPAGE_VTAB \
                /Dmain=sqlite3_shell \
                /DSQLITE_SHELL_IS_UTF8=1 \
                /DSQLITE_OMIT_LOAD_EXTENSION=1 \
                /DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
                /DSQLITE_SHELL_DBNAME_PROC=fossil_open \
Changes to www/build.wiki.
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
file "<b>win\buildmsvc.bat</b>" may be used and it will attempt to
detect and use the latest installed version of MSVC.<br><br>To enable
the optional <a href="https://www.openssl.org/">OpenSSL</a> support,
first <a href="https://www.openssl.org/source/">download the official
source code for OpenSSL</a> and extract it to an appropriately named
"<b>openssl-X.Y.ZA</b>" subdirectory within the local
[/tree?ci=trunk&name=compat | compat] directory (e.g.
"<b>compat/openssl-1.1.0h</b>"), then make sure that some recent
<a href="http://www.perl.org/">Perl</a> binaries are installed locally,
and finally run one of the following commands:
<blockquote><pre>
nmake /f Makefile.msc FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin
</pre></blockquote>
<blockquote><pre>
buildmsvc.bat FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin







|







134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
file "<b>win\buildmsvc.bat</b>" may be used and it will attempt to
detect and use the latest installed version of MSVC.<br><br>To enable
the optional <a href="https://www.openssl.org/">OpenSSL</a> support,
first <a href="https://www.openssl.org/source/">download the official
source code for OpenSSL</a> and extract it to an appropriately named
"<b>openssl-X.Y.ZA</b>" subdirectory within the local
[/tree?ci=trunk&name=compat | compat] directory (e.g.
"<b>compat/openssl-1.1.1-pre4</b>"), then make sure that some recent
<a href="http://www.perl.org/">Perl</a> binaries are installed locally,
and finally run one of the following commands:
<blockquote><pre>
nmake /f Makefile.msc FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin
</pre></blockquote>
<blockquote><pre>
buildmsvc.bat FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin